Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
5e20d578
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看板
未验证
提交
5e20d578
编写于
7月 24, 2023
作者:
O
openharmony_ci
提交者:
Gitee
7月 24, 2023
浏览文件
操作
浏览文件
下载
差异文件
!9392 photoAccessHelper xts update
Merge pull request !9392 from yangbo/xts0719
上级
5b087768
40dc8cc7
变更
64
隐藏空白更改
内联
并排
Showing
64 changed file
with
986 addition
and
457 deletion
+986
-457
multimedia/medialibrary/common.js
multimedia/medialibrary/common.js
+26
-18
multimedia/medialibrary/mediaLibrary_album/Test.json
multimedia/medialibrary/mediaLibrary_album/Test.json
+1
-1
multimedia/medialibrary/mediaLibrary_base/Test.json
multimedia/medialibrary/mediaLibrary_base/Test.json
+1
-1
multimedia/medialibrary/mediaLibrary_favorite/Test.json
multimedia/medialibrary/mediaLibrary_favorite/Test.json
+1
-1
multimedia/medialibrary/mediaLibrary_file/Test.json
multimedia/medialibrary/mediaLibrary_file/Test.json
+1
-1
multimedia/medialibrary/mediaLibrary_fileAsset/Test.json
multimedia/medialibrary/mediaLibrary_fileAsset/Test.json
+1
-1
multimedia/medialibrary/mediaLibrary_fileKey/Test.json
multimedia/medialibrary/mediaLibrary_fileKey/Test.json
+1
-1
multimedia/medialibrary/mediaLibrary_fileResult/Test.json
multimedia/medialibrary/mediaLibrary_fileResult/Test.json
+1
-1
multimedia/medialibrary/mediaLibrary_getExifNoLocation/Test.json
...dia/medialibrary/mediaLibrary_getExifNoLocation/Test.json
+1
-1
multimedia/medialibrary/mediaLibrary_getExiflocation/Test.json
...media/medialibrary/mediaLibrary_getExiflocation/Test.json
+1
-1
multimedia/medialibrary/mediaLibrary_getThumbnail/Test.json
multimedia/medialibrary/mediaLibrary_getThumbnail/Test.json
+1
-1
multimedia/medialibrary/mediaLibrary_mediafetchoptions/Test.json
...dia/medialibrary/mediaLibrary_mediafetchoptions/Test.json
+1
-1
multimedia/medialibrary/mediaLibrary_trash/Test.json
multimedia/medialibrary/mediaLibrary_trash/Test.json
+1
-1
multimedia/photoAccess/common.ts
multimedia/photoAccess/common.ts
+11
-29
multimedia/photoAccess/photoAccess/Test.json
multimedia/photoAccess/photoAccess/Test.json
+14
-2
multimedia/photoAccess/photoAccess/entry/src/main/ets/test/AbsAlbum/checkAttr.ets
...hotoAccess/entry/src/main/ets/test/AbsAlbum/checkAttr.ets
+2
-3
multimedia/photoAccess/photoAccess/entry/src/main/ets/test/AbsAlbum/getAssets.ets
...hotoAccess/entry/src/main/ets/test/AbsAlbum/getAssets.ets
+0
-2
multimedia/photoAccess/photoAccess/entry/src/main/ets/test/Album/addAssets.ets
...s/photoAccess/entry/src/main/ets/test/Album/addAssets.ets
+55
-20
multimedia/photoAccess/photoAccess/entry/src/main/ets/test/Album/commitModify.ets
...hotoAccess/entry/src/main/ets/test/Album/commitModify.ets
+0
-1
multimedia/photoAccess/photoAccess/entry/src/main/ets/test/Album/removeAssets.ets
...hotoAccess/entry/src/main/ets/test/Album/removeAssets.ets
+30
-1
multimedia/photoAccess/photoAccess/entry/src/main/ets/test/AlbumFetchResult/close.ets
...Access/entry/src/main/ets/test/AlbumFetchResult/close.ets
+0
-1
multimedia/photoAccess/photoAccess/entry/src/main/ets/test/AlbumFetchResult/getAllObjects.ets
...ntry/src/main/ets/test/AlbumFetchResult/getAllObjects.ets
+0
-1
multimedia/photoAccess/photoAccess/entry/src/main/ets/test/AlbumFetchResult/getCount.ets
...ess/entry/src/main/ets/test/AlbumFetchResult/getCount.ets
+5
-6
multimedia/photoAccess/photoAccess/entry/src/main/ets/test/AlbumFetchResult/getFirstObject.ets
...try/src/main/ets/test/AlbumFetchResult/getFirstObject.ets
+0
-1
multimedia/photoAccess/photoAccess/entry/src/main/ets/test/AlbumFetchResult/getLastObject.ets
...ntry/src/main/ets/test/AlbumFetchResult/getLastObject.ets
+0
-1
multimedia/photoAccess/photoAccess/entry/src/main/ets/test/AlbumFetchResult/getNextObject.ets
...ntry/src/main/ets/test/AlbumFetchResult/getNextObject.ets
+0
-1
multimedia/photoAccess/photoAccess/entry/src/main/ets/test/AlbumFetchResult/getObjectByPosition.ets
...rc/main/ets/test/AlbumFetchResult/getObjectByPosition.ets
+0
-1
multimedia/photoAccess/photoAccess/entry/src/main/ets/test/AlbumFetchResult/isAfterLast.ets
.../entry/src/main/ets/test/AlbumFetchResult/isAfterLast.ets
+0
-1
multimedia/photoAccess/photoAccess/entry/src/main/ets/test/List.test.ets
...oAccess/photoAccess/entry/src/main/ets/test/List.test.ets
+2
-0
multimedia/photoAccess/photoAccess/entry/src/main/ets/test/PhotoAccessHelper/createAsset.ets
...entry/src/main/ets/test/PhotoAccessHelper/createAsset.ets
+1
-2
multimedia/photoAccess/photoAccess/entry/src/main/ets/test/PhotoAccessHelper/createDeleteRequest.ets
...c/main/ets/test/PhotoAccessHelper/createDeleteRequest.ets
+100
-0
multimedia/photoAccess/photoAccess/entry/src/main/ets/test/PhotoAccessHelper/getAlbums.ets
...s/entry/src/main/ets/test/PhotoAccessHelper/getAlbums.ets
+81
-5
multimedia/photoAccess/photoAccess/entry/src/main/ets/test/PhotoAccessHelper/getAssets.ets
...s/entry/src/main/ets/test/PhotoAccessHelper/getAssets.ets
+0
-1
multimedia/photoAccess/photoAccess/entry/src/main/ets/test/PhotoAccessHelper/registerChange.ets
...ry/src/main/ets/test/PhotoAccessHelper/registerChange.ets
+30
-27
multimedia/photoAccess/photoAccess/entry/src/main/ets/test/PhotoAccessHelper/release.ets
...ess/entry/src/main/ets/test/PhotoAccessHelper/release.ets
+0
-1
multimedia/photoAccess/photoAccess/entry/src/main/ets/test/PhotoAccessHelper/unRegisterChange.ets
.../src/main/ets/test/PhotoAccessHelper/unRegisterChange.ets
+55
-59
multimedia/photoAccess/photoAccess/entry/src/main/ets/test/PhotoAsset/checkAttr.ets
...toAccess/entry/src/main/ets/test/PhotoAsset/checkAttr.ets
+5
-5
multimedia/photoAccess/photoAccess/entry/src/main/ets/test/PhotoAsset/close.ets
.../photoAccess/entry/src/main/ets/test/PhotoAsset/close.ets
+0
-1
multimedia/photoAccess/photoAccess/entry/src/main/ets/test/PhotoAsset/commitModify.ets
...ccess/entry/src/main/ets/test/PhotoAsset/commitModify.ets
+2
-2
multimedia/photoAccess/photoAccess/entry/src/main/ets/test/PhotoAsset/get.ets
...ss/photoAccess/entry/src/main/ets/test/PhotoAsset/get.ets
+6
-4
multimedia/photoAccess/photoAccess/entry/src/main/ets/test/PhotoAsset/getReadOnlyFd.ets
...cess/entry/src/main/ets/test/PhotoAsset/getReadOnlyFd.ets
+0
-2
multimedia/photoAccess/photoAccess/entry/src/main/ets/test/PhotoAsset/getThumbnail.ets
...ccess/entry/src/main/ets/test/PhotoAsset/getThumbnail.ets
+0
-1
multimedia/photoAccess/photoAccess/entry/src/main/ets/test/PhotoAssetFetchResult/close.ets
...s/entry/src/main/ets/test/PhotoAssetFetchResult/close.ets
+0
-1
multimedia/photoAccess/photoAccess/entry/src/main/ets/test/PhotoAssetFetchResult/getAllObjects.ets
...src/main/ets/test/PhotoAssetFetchResult/getAllObjects.ets
+0
-1
multimedia/photoAccess/photoAccess/entry/src/main/ets/test/PhotoAssetFetchResult/getCount.ets
...ntry/src/main/ets/test/PhotoAssetFetchResult/getCount.ets
+0
-1
multimedia/photoAccess/photoAccess/entry/src/main/ets/test/PhotoAssetFetchResult/getFirstObject.ets
...rc/main/ets/test/PhotoAssetFetchResult/getFirstObject.ets
+31
-10
multimedia/photoAccess/photoAccess/entry/src/main/ets/test/PhotoAssetFetchResult/getLastObject.ets
...src/main/ets/test/PhotoAssetFetchResult/getLastObject.ets
+0
-1
multimedia/photoAccess/photoAccess/entry/src/main/ets/test/PhotoAssetFetchResult/getNextObject.ets
...src/main/ets/test/PhotoAssetFetchResult/getNextObject.ets
+27
-8
multimedia/photoAccess/photoAccess/entry/src/main/ets/test/PhotoAssetFetchResult/getObjectByPosition.ets
...in/ets/test/PhotoAssetFetchResult/getObjectByPosition.ets
+0
-1
multimedia/photoAccess/photoAccess/entry/src/main/ets/test/PhotoAssetFetchResult/isAfterLast.ets
...y/src/main/ets/test/PhotoAssetFetchResult/isAfterLast.ets
+18
-14
multimedia/photoAccess/photoAccess/entry/src/main/ets/test/getPhotoAccessHelper.ets
...toAccess/entry/src/main/ets/test/getPhotoAccessHelper.ets
+3
-4
multimedia/photoAccess/photoAccess/entry/src/main/module.json
...imedia/photoAccess/photoAccess/entry/src/main/module.json
+1
-2
multimedia/photoAccess/photoAccessSystem/Test.json
multimedia/photoAccess/photoAccessSystem/Test.json
+14
-2
multimedia/photoAccess/photoAccessSystem/entry/src/main/ets/test/Album/deleteAssets.ets
...cessSystem/entry/src/main/ets/test/Album/deleteAssets.ets
+0
-1
multimedia/photoAccess/photoAccessSystem/entry/src/main/ets/test/Album/recoverAssets.ets
...essSystem/entry/src/main/ets/test/Album/recoverAssets.ets
+0
-1
multimedia/photoAccess/photoAccessSystem/entry/src/main/ets/test/Album/setCoverUri.ets
...ccessSystem/entry/src/main/ets/test/Album/setCoverUri.ets
+0
-1
multimedia/photoAccess/photoAccessSystem/entry/src/main/ets/test/createAlbum.ets
...photoAccessSystem/entry/src/main/ets/test/createAlbum.ets
+0
-1
multimedia/photoAccess/photoAccessSystem/entry/src/main/ets/test/deleteAlbums.ets
...hotoAccessSystem/entry/src/main/ets/test/deleteAlbums.ets
+2
-3
multimedia/photoAccess/photoAccessSystem/entry/src/main/ets/test/deleteAssets.ets
...hotoAccessSystem/entry/src/main/ets/test/deleteAssets.ets
+0
-1
multimedia/photoAccess/photoAccessSystem/entry/src/main/ets/test/open.ets
...Access/photoAccessSystem/entry/src/main/ets/test/open.ets
+43
-20
multimedia/photoAccess/photoAccessSystem/entry/src/main/ets/test/publicApiTestWithSystemApi.ets
...em/entry/src/main/ets/test/publicApiTestWithSystemApi.ets
+409
-169
multimedia/photoAccess/photoAccessSystem/entry/src/main/ets/test/setFavorite.ets
...photoAccessSystem/entry/src/main/ets/test/setFavorite.ets
+0
-1
multimedia/photoAccess/photoAccessSystem/entry/src/main/ets/test/setHidden.ets
...s/photoAccessSystem/entry/src/main/ets/test/setHidden.ets
+0
-1
multimedia/photoAccess/photoAccessSystem/entry/src/main/module.json
.../photoAccess/photoAccessSystem/entry/src/main/module.json
+1
-2
未找到文件。
multimedia/medialibrary/common.js
浏览文件 @
5e20d578
...
...
@@ -238,28 +238,36 @@ const getPermission = async function (name, context) {
name
=
"
ohos.acts.multimedia.mediaLibrary
"
;
}
console
.
info
(
'
getPermission start:
'
+
name
);
let
permissions
=
[
"
ohos.permission.MEDIA_LOCATION
"
,
"
ohos.permission.READ_MEDIA
"
,
"
ohos.permission.WRITE_MEDIA
"
]
;
let
atManager
=
abilityAccessCtrl
.
createAtManager
()
;
atManager
.
requestPermissionsFromUser
(
context
,
permissions
,
(
err
,
result
)
=>
{
if
(
err
)
{
console
.
info
(
'
getPermission failed:
'
+
JSON
.
stringify
(
err
));
}
else
{
console
.
info
(
'
getPermission suc:
'
+
JSON
.
stringify
(
result
));
}
}
);
let
driver
=
uitest
.
Driver
.
create
();
await
sleep
(
500
);
try
{
console
.
info
(
'
getPermission start:
'
+
name
)
;
let
isGetPermission
=
false
;
let
permissions
=
[
"
ohos.permission.MEDIA_LOCATION
"
,
"
ohos.permission.READ_MEDIA
"
,
"
ohos.permission.WRITE_MEDIA
"
];
let
atManager
=
abilityAccessCtrl
.
createAtManager
();
atManager
.
requestPermissionsFromUser
(
context
,
permissions
,
(
err
,
result
)
=>
{
if
(
err
)
{
console
.
info
(
'
getPermission failed:
'
+
JSON
.
stringify
(
err
));
}
else
{
console
.
info
(
'
getPermission suc:
'
+
JSON
.
stringify
(
result
)
);
isGetPermission
=
true
;
}
}
);
for
(
let
i
=
0
;
i
<
10
;
i
++
)
{
let
driver
=
uitest
.
Driver
.
create
();
await
sleep
(
500
);
let
button
=
await
driver
.
findComponent
(
uitest
.
ON
.
text
(
'
允许
'
));
if
(
button
!=
undefined
)
{
await
button
.
click
();
for
(
let
i
=
0
;
i
<
10
;
i
++
)
{
if
(
isGetPermission
)
{
break
;
}
await
sleep
(
500
);
let
button
=
await
driver
.
findComponent
(
uitest
.
ON
.
text
(
'
允许
'
));
if
(
button
!=
undefined
)
{
await
button
.
click
();
}
}
console
.
info
(
"
getPermission end
"
);
}
catch
(
error
)
{
console
.
info
(
'
getPermission error:
'
+
error
);
}
console
.
info
(
"
getPermission end
"
);
};
const
MODIFY_ERROR_CODE_01
=
"
-1000
"
;
...
...
multimedia/medialibrary/mediaLibrary_album/Test.json
浏览文件 @
5e20d578
...
...
@@ -6,7 +6,7 @@
"bundle-name"
:
"ohos.acts.multimedia.mediaLibrary"
,
"module-name"
:
"phone"
,
"shell-timeout"
:
"600000"
,
"testcase-timeout"
:
7
0000
"testcase-timeout"
:
1
0000
},
"kits"
:
[
{
...
...
multimedia/medialibrary/mediaLibrary_base/Test.json
浏览文件 @
5e20d578
...
...
@@ -6,7 +6,7 @@
"bundle-name"
:
"ohos.acts.multimedia.mediaLibrary"
,
"module-name"
:
"phone"
,
"shell-timeout"
:
"600000"
,
"testcase-timeout"
:
7
0000
"testcase-timeout"
:
1
0000
},
"kits"
:
[
{
...
...
multimedia/medialibrary/mediaLibrary_favorite/Test.json
浏览文件 @
5e20d578
...
...
@@ -6,7 +6,7 @@
"bundle-name"
:
"ohos.acts.multimedia.mediaLibrary"
,
"module-name"
:
"phone"
,
"shell-timeout"
:
"600000"
,
"testcase-timeout"
:
7
0000
"testcase-timeout"
:
1
0000
},
"kits"
:
[
{
...
...
multimedia/medialibrary/mediaLibrary_file/Test.json
浏览文件 @
5e20d578
...
...
@@ -6,7 +6,7 @@
"bundle-name"
:
"ohos.acts.multimedia.mediaLibrary"
,
"module-name"
:
"phone"
,
"shell-timeout"
:
"600000"
,
"testcase-timeout"
:
7
0000
"testcase-timeout"
:
1
0000
},
"kits"
:
[
{
...
...
multimedia/medialibrary/mediaLibrary_fileAsset/Test.json
浏览文件 @
5e20d578
...
...
@@ -6,7 +6,7 @@
"bundle-name"
:
"ohos.acts.multimedia.mediaLibrary"
,
"module-name"
:
"phone"
,
"shell-timeout"
:
"600000"
,
"testcase-timeout"
:
7
0000
"testcase-timeout"
:
1
0000
},
"kits"
:
[
{
...
...
multimedia/medialibrary/mediaLibrary_fileKey/Test.json
浏览文件 @
5e20d578
...
...
@@ -6,7 +6,7 @@
"bundle-name"
:
"ohos.acts.multimedia.mediaLibrary"
,
"module-name"
:
"phone"
,
"shell-timeout"
:
"600000"
,
"testcase-timeout"
:
7
0000
"testcase-timeout"
:
1
0000
},
"kits"
:
[
{
...
...
multimedia/medialibrary/mediaLibrary_fileResult/Test.json
浏览文件 @
5e20d578
...
...
@@ -6,7 +6,7 @@
"bundle-name"
:
"ohos.acts.multimedia.mediaLibrary"
,
"module-name"
:
"phone"
,
"shell-timeout"
:
"600000"
,
"testcase-timeout"
:
7
0000
"testcase-timeout"
:
1
0000
},
"kits"
:
[
{
...
...
multimedia/medialibrary/mediaLibrary_getExifNoLocation/Test.json
浏览文件 @
5e20d578
...
...
@@ -6,7 +6,7 @@
"bundle-name"
:
"ohos.acts.multimedia.mediaLibrary"
,
"module-name"
:
"phone"
,
"shell-timeout"
:
"600000"
,
"testcase-timeout"
:
7
0000
"testcase-timeout"
:
1
0000
},
"kits"
:
[
{
...
...
multimedia/medialibrary/mediaLibrary_getExiflocation/Test.json
浏览文件 @
5e20d578
...
...
@@ -6,7 +6,7 @@
"bundle-name"
:
"ohos.acts.multimedia.mediaLibrary"
,
"module-name"
:
"phone"
,
"shell-timeout"
:
"600000"
,
"testcase-timeout"
:
7
0000
"testcase-timeout"
:
1
0000
},
"kits"
:
[
{
...
...
multimedia/medialibrary/mediaLibrary_getThumbnail/Test.json
浏览文件 @
5e20d578
...
...
@@ -6,7 +6,7 @@
"bundle-name"
:
"ohos.acts.multimedia.mediaLibrary"
,
"module-name"
:
"phone"
,
"shell-timeout"
:
"600000"
,
"testcase-timeout"
:
7
0000
"testcase-timeout"
:
1
0000
},
"kits"
:
[
{
...
...
multimedia/medialibrary/mediaLibrary_mediafetchoptions/Test.json
浏览文件 @
5e20d578
...
...
@@ -6,7 +6,7 @@
"bundle-name"
:
"ohos.acts.multimedia.mediaLibrary"
,
"module-name"
:
"phone"
,
"shell-timeout"
:
"600000"
,
"testcase-timeout"
:
7
0000
"testcase-timeout"
:
1
0000
},
"kits"
:
[
{
...
...
multimedia/medialibrary/mediaLibrary_trash/Test.json
浏览文件 @
5e20d578
...
...
@@ -6,7 +6,7 @@
"bundle-name"
:
"ohos.acts.multimedia.mediaLibrary"
,
"module-name"
:
"phone"
,
"shell-timeout"
:
"600000"
,
"testcase-timeout"
:
7
0000
"testcase-timeout"
:
1
0000
},
"kits"
:
[
{
...
...
multimedia/photoAccess/common.ts
浏览文件 @
5e20d578
...
...
@@ -13,7 +13,6 @@
* limitations under the License.
*/
// @ts-nocheck
import
photoAccessHelper
from
'
@ohos.file.photoAccessHelper
'
;
import
abilityAccessCtrl
from
'
@ohos.abilityAccessCtrl
'
;
import
bundleManager
from
'
@ohos.bundle.bundleManager
'
;
...
...
@@ -127,9 +126,18 @@ export function isNum(value) : boolean {
return
typeof
value
===
'
number
'
&&
!
isNaN
(
value
);
};
export
function
getId
(
uri
)
:
string
{
let
index
=
uri
.
lastIndexOf
(
'
/
'
);
export
function
getAssetId
(
uri
)
:
string
{
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
);
console
.
info
(
`getAlbumId str:
${
str
}
`
);
return
str
;
}
...
...
@@ -159,32 +167,6 @@ export async function createUserAlbum(testNum, albumName) : Promise<photoAccessH
});
}
//systemApi
export
async
function
deleteAllUserAlbum
(
testNum
)
:
Promise
<
void
>
{
try
{
const
helper
=
photoAccessHelper
.
getPhotoAccessHelper
(
globalThis
.
abilityContext
);
let
fetchResult
=
await
helper
.
getAlbums
(
albumType
.
USER
,
albumSubtype
.
USER_GENERIC
);
let
count
=
fetchResult
.
getCount
();
console
.
info
(
`
${
testNum
}
deleteAllUserAlbum count:
${
count
}
`
);
if
(
count
<=
0
)
{
return
;
}
const
albumList
=
await
fetchResult
.
getAllObjects
();
console
.
info
(
`
${
testNum
}
deleteAllUserAlbum getAllObjects:
${
albumList
.
length
}
`
);
await
helper
.
deleteAlbums
(
albumList
);
fetchResult
=
await
helper
.
getAlbums
(
albumType
.
USER
,
albumSubtype
.
USER_GENERIC
);
if
(
fetchResult
.
getCount
()
===
0
)
{
console
.
info
(
`
${
testNum
}
deleteAllUserAlbum suc`
);
}
else
{
console
.
info
(
`
${
testNum
}
deleteAllUserAlbum failed! fetchResult.getCount():
${
fetchResult
.
getCount
()}
`
);
}
fetchResult
.
close
();
}
catch
(
error
)
{
console
.
info
(
`
${
testNum
}
deleteAllUserAlbum failed! error:
${
error
}
`
);
throw
error
;
}
};
export
async
function
getFileAsset
(
testNum
,
fetchOps
)
:
Promise
<
photoAccessHelper
.
PhotoAsset
>
{
let
asset
:
photoAccessHelper
.
PhotoAsset
;
try
{
...
...
multimedia/photoAccess/photoAccess/Test.json
浏览文件 @
5e20d578
...
...
@@ -6,14 +6,26 @@
"bundle-name"
:
"ohos.acts.multimedia.photoaccess"
,
"module-name"
:
"phone"
,
"shell-timeout"
:
"600000"
,
"testcase-timeout"
:
7
0000
"testcase-timeout"
:
1
0000
},
"kits"
:
[
{
"type"
:
"ShellKit"
,
"pre-push"
:
[],
"run-command"
:
[
"rm -rf /storage/media/100/local/files/*"
,
"rm -rf /storage/media/100/local/files/Audios/*"
,
"rm -rf /storage/media/100/local/files/Audios/.*"
,
"rm -rf /storage/media/100/local/files/Camera/*"
,
"rm -rf /storage/media/100/local/files/Camera/.*"
,
"rm -rf /storage/media/100/local/files/Documents/*"
,
"rm -rf /storage/media/100/local/files/Documents/.*"
,
"rm -rf /storage/media/100/local/files/Download/*"
,
"rm -rf /storage/media/100/local/files/Download/.*"
,
"rm -rf /storage/media/100/local/files/Pictures/*"
,
"rm -rf /storage/media/100/local/files/Pictures/.*"
,
"rm -rf /storage/media/100/local/files/Videos/*"
,
"rm -rf /storage/media/100/local/files/Videos/.*"
,
"sleep 5"
,
"rm -rf /data/app/el2/100/database/com.ohos.medialibrary.medialibrarydata/*"
,
"kill -9 `pidof com.ohos.medialibrary.medialibrarydata`"
,
"scanner"
,
...
...
multimedia/photoAccess/photoAccess/entry/src/main/ets/test/AbsAlbum/checkAttr.ets
浏览文件 @
5e20d578
...
...
@@ -13,7 +13,6 @@
* limitations under the License.
*/
// @ts-nocheck
import
photoAccessHelper
from
'@ohos.file.photoAccessHelper'
import
{
describe
,
it
,
expect
}
from
'deccjsunit/index'
import
{
...
...
@@ -21,7 +20,7 @@ import {
albumSubtype
,
fetchOption
,
getFileAsset
,
getId
,
get
Album
Id
,
photoKeys
}
from
'../../../../../../../common'
...
...
@@ -35,7 +34,7 @@ export default function checkAlbumAttrTest () {
expect
(
album
.
albumType
)
.
assertEqual
(
albumType
.
USER
);
expect
(
album
.
albumSubtype
)
.
assertEqual
(
albumSubtype
.
USER_GENERIC
);
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
);
const
fetchOps
=
fetchOption
(
testNum
,
photoKeys
.
DISPLAY_NAME
,
'01.jpg'
);
const
asset
=
await
getFileAsset
(
testNum
,
fetchOps
);
...
...
multimedia/photoAccess/photoAccess/entry/src/main/ets/test/AbsAlbum/getAssets.ets
浏览文件 @
5e20d578
...
...
@@ -13,7 +13,6 @@
* limitations under the License.
*/
// @ts-nocheck
import photoAccessHelper from '@ohos.file.photoAccessHelper'
import { describe, it, expect } from 'deccjsunit/index'
import {
...
...
@@ -21,7 +20,6 @@ import {
albumSubtype,
photoKeys,
fetchOption,
getFileAsset,
} from '../../../../../../../common'
export default function albumGetAssetsTest () {
...
...
multimedia/photoAccess/photoAccess/entry/src/main/ets/test/Album/addAssets.ets
浏览文件 @
5e20d578
...
...
@@ -13,7 +13,7 @@
* limitations under the License.
*/
// @ts-nocheck
import dataSharePredicates from '@ohos.data.dataSharePredicates';
import photoAccessHelper from '@ohos.file.photoAccessHelper'
import { describe, it, expect } from 'deccjsunit/index'
import {
...
...
@@ -78,14 +78,16 @@ export default function addAssetsTest () {
const testNum = 'addAssets_callback_003';
try {
const album = await helper.createAlbum(testNum);
const fetchOps1 = fetchOption(testNum, photoKeys.DISPLAY_NAME, 'addCb03.jpg');
const fetchOps2 = fetchOption(testNum, photoKeys.DISPLAY_NAME, 'addCb01.mp4');
const assetList: Array<photoAccessHelper.PhotoAsset> = new Array();
const asset1 = await getFileAsset(testNum, fetchOps1);
assetList.push(asset1);
const asset2 = await getFileAsset(testNum, fetchOps2);
assetList.push(asset2);
const predicates = new dataSharePredicates.DataSharePredicates();
predicates.in(photoKeys.DISPLAY_NAME, ['addCb03.jpg', 'addCb01.mp4']);
const fetchOps : photoAccessHelper.FetchOptions = {
fetchColumns: [],
predicates: predicates
};
const fetchResult = await helper.getAssets(fetchOps);
console.info(`${testNum} fetchResult: ${fetchResult.getCount()}`);
const assetList = await fetchResult.getAllObjects();
fetchResult.close();
album.addAssets(assetList, async (err) => {
try {
if (err) {
...
...
@@ -109,6 +111,37 @@ export default function addAssetsTest () {
}
});
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_CALLBACK_ADD_ASSETS_0400
* @tc.name : addAssets_callback_004
* @tc.desc : add empty array to user album
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
*/
it('addAssets_callback_004', 2, async function (done) {
const testNum = 'addAssets_callback_004';
try {
const album = await helper.createAlbum(testNum);
album.addAssets([], async (err) => {
try {
if (err) {
console.info(`${testNum} err: ${err}`);
expect(false).assertTrue();
}
} catch (error) {
console.info(`${testNum} error: ${error}`);
}
done();
})
} catch (error) {
console.info(`${testNum} failed; error: ${error}`);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_CALLBACK_ADD_ASSETS_0500
* @tc.name : addAssets_callback_005
...
...
@@ -176,18 +209,20 @@ export default function addAssetsTest () {
const testNum = 'addAssets_promise_003';
try {
const album = await helper.createAlbum(testNum);
const fetchOps1 = fetchOption(testNum, photoKeys.DISPLAY_NAME, 'addPro03.jpg');
const fetchOps2 = fetchOption(testNum, photoKeys.DISPLAY_NAME, 'addPro01.mp4');
const assetList: Array<photoAccessHelper.PhotoAsset> = new Array();
const asset1 = await getFileAsset(testNum, fetchOps1);
assetList.push(asset1);
const asset2 = await getFileAsset(testNum, fetchOps2);
assetList.push(asset2);
await album.addAssets(assetList);
const fetchResult = await album.getAssets(fetchAllOption());
expect(fetchResult.getCount()).assertEqual(2);
const predicates = new dataSharePredicates.DataSharePredicates();
predicates.in(photoKeys.DISPLAY_NAME, ['addCb03.jpg', 'addCb01.mp4']);
const fetchOps : photoAccessHelper.FetchOptions = {
fetchColumns: [],
predicates: predicates
};
const fetchResult = await helper.getAssets(fetchOps);
console.info(`${testNum} fetchResult: ${fetchResult.getCount()}`);
const assetList = await fetchResult.getAllObjects();
fetchResult.close();
await album.addAssets(assetList);
const albumFetchResult = await album.getAssets(fetchAllOption());
expect(albumFetchResult.getCount()).assertEqual(2);
albumFetchResult.close();
done();
} catch (error) {
console.info(`${testNum} failed; error: ${error}`);
...
...
multimedia/photoAccess/photoAccess/entry/src/main/ets/test/Album/commitModify.ets
浏览文件 @
5e20d578
...
...
@@ -13,7 +13,6 @@
* limitations under the License.
*/
// @ts-nocheck
import photoAccessHelper from '@ohos.file.photoAccessHelper'
import { describe, it, expect } from 'deccjsunit/index'
import {
...
...
multimedia/photoAccess/photoAccess/entry/src/main/ets/test/Album/removeAssets.ets
浏览文件 @
5e20d578
...
...
@@ -13,7 +13,6 @@
* limitations under the License.
*/
// @ts-nocheck
import photoAccessHelper from '@ohos.file.photoAccessHelper'
import { describe, it, expect } from 'deccjsunit/index'
import {
...
...
@@ -115,6 +114,36 @@ export default function removeAssetsTest () {
}
});
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_CALLBACK_REMOVE_ASSETS_0300
* @tc.name : removeAssets_callback_003
* @tc.desc : user album remove empty array
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
*/
it('removeAssets_callback_003', 2, async function (done) {
const testNum = 'removeAssets_callback_003';
try {
const album = await helper.createAlbum(testNum);
album.removeAssets([], async (err) => {
try {
if (err) {
console.info(`${testNum} err: ${err}`);
expect(false).assertTrue();
}
} catch (error) {
console.info(`${testNum} error: ${error}`);
}
done();
})
} catch (error) {
console.info(`${testNum} failed; error: ${error}`);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_CALLBACK_REMOVE_ASSETS_0400
* @tc.name : removeAssets_callback_004
...
...
multimedia/photoAccess/photoAccess/entry/src/main/ets/test/AlbumFetchResult/close.ets
浏览文件 @
5e20d578
...
...
@@ -13,7 +13,6 @@
* limitations under the License.
*/
// @ts-nocheck
import photoAccessHelper from '@ohos.file.photoAccessHelper'
import { describe, it, expect } from 'deccjsunit/index'
import {
...
...
multimedia/photoAccess/photoAccess/entry/src/main/ets/test/AlbumFetchResult/getAllObjects.ets
浏览文件 @
5e20d578
...
...
@@ -13,7 +13,6 @@
* limitations under the License.
*/
// @ts-nocheck
import photoAccessHelper from '@ohos.file.photoAccessHelper'
import { describe, it, expect } from 'deccjsunit/index'
import {
...
...
multimedia/photoAccess/photoAccess/entry/src/main/ets/test/AlbumFetchResult/getCount.ets
浏览文件 @
5e20d578
...
...
@@ -13,7 +13,6 @@
* limitations under the License.
*/
// @ts-nocheck
import photoAccessHelper from '@ohos.file.photoAccessHelper'
import { describe, it, expect } from 'deccjsunit/index'
import {
...
...
@@ -38,7 +37,7 @@ export default function albumGetCountTest () {
* @tc.level : Level 0
*/
it('album_getCount_callback_000', 0, async function (done) {
const testNum = 'album_getCount_callback_000';
const testNum = 'album_getCount_callback_000';
try {
const subTypes : Array<photoAccessHelper.AlbumSubtype> = [
albumSubtype.VIDEO,
...
...
@@ -61,8 +60,8 @@ export default function albumGetCountTest () {
}
}
} catch (error) {
console.info(`${testNum} failed; error: ${error}`);
expect(false).assertTrue();
console.info(`${testNum} failed; error: ${error}`);
expect(false).assertTrue();
done();
}
});
...
...
@@ -76,7 +75,7 @@ export default function albumGetCountTest () {
* @tc.level : Level 0
*/
it('album_getCount_callback_001', 0, async function (done) {
const testNum = 'album_getCount_callback_001';
const testNum = 'album_getCount_callback_001';
try {
const albumName = genRadomStr(10);
await createUserAlbum(testNum, albumName);
...
...
@@ -92,7 +91,7 @@ export default function albumGetCountTest () {
done();
} catch (error) {
console.info(`${testNum} failed; error: ${error}`);
expect(false).assertTrue();
expect(false).assertTrue();
done();
}
});
...
...
multimedia/photoAccess/photoAccess/entry/src/main/ets/test/AlbumFetchResult/getFirstObject.ets
浏览文件 @
5e20d578
...
...
@@ -13,7 +13,6 @@
* limitations under the License.
*/
// @ts-nocheck
import photoAccessHelper from '@ohos.file.photoAccessHelper'
import { describe, it, expect } from 'deccjsunit/index'
import {
...
...
multimedia/photoAccess/photoAccess/entry/src/main/ets/test/AlbumFetchResult/getLastObject.ets
浏览文件 @
5e20d578
...
...
@@ -13,7 +13,6 @@
* limitations under the License.
*/
// @ts-nocheck
import photoAccessHelper from '@ohos.file.photoAccessHelper'
import { describe, it, expect } from 'deccjsunit/index'
import {
...
...
multimedia/photoAccess/photoAccess/entry/src/main/ets/test/AlbumFetchResult/getNextObject.ets
浏览文件 @
5e20d578
...
...
@@ -13,7 +13,6 @@
* limitations under the License.
*/
// @ts-nocheck
import photoAccessHelper from '@ohos.file.photoAccessHelper'
import { describe, it, expect } from 'deccjsunit/index'
import {
...
...
multimedia/photoAccess/photoAccess/entry/src/main/ets/test/AlbumFetchResult/getObjectByPosition.ets
浏览文件 @
5e20d578
...
...
@@ -13,7 +13,6 @@
* limitations under the License.
*/
// @ts-nocheck
import photoAccessHelper from '@ohos.file.photoAccessHelper'
import { describe, it, expect } from 'deccjsunit/index'
import {
...
...
multimedia/photoAccess/photoAccess/entry/src/main/ets/test/AlbumFetchResult/isAfterLast.ets
浏览文件 @
5e20d578
...
...
@@ -13,7 +13,6 @@
* limitations under the License.
*/
// @ts-nocheck
import photoAccessHelper from '@ohos.file.photoAccessHelper'
import { describe, it, expect } from 'deccjsunit/index'
import {
...
...
multimedia/photoAccess/photoAccess/entry/src/main/ets/test/List.test.ets
浏览文件 @
5e20d578
...
...
@@ -36,6 +36,7 @@ import assetGetNextObjectTest from './PhotoAssetFetchResult/getNextObject'
import assetGetPositionObjectTest from './PhotoAssetFetchResult/getObjectByPosition'
import assetIsAfterLastTest from './PhotoAssetFetchResult/isAfterLast'
import createAssetTest from './PhotoAccessHelper/createAsset'
import createDeleteRequestTest from './PhotoAccessHelper/createDeleteRequest'
import getAlbumsTest from './PhotoAccessHelper/getAlbums'
import getAssetsTest from './PhotoAccessHelper/getAssets'
import unRegisterChangeTest from './PhotoAccessHelper/unRegisterChange'
...
...
@@ -72,6 +73,7 @@ export default function testsuite () {
assetGetPositionObjectTest()
assetIsAfterLastTest()
createAssetTest()
createDeleteRequestTest()
getAlbumsTest()
getAssetsTest()
unRegisterChangeTest()
...
...
multimedia/photoAccess/photoAccess/entry/src/main/ets/test/PhotoAccessHelper/createAsset.ets
浏览文件 @
5e20d578
...
...
@@ -13,7 +13,6 @@
* limitations under the License.
*/
// @ts-nocheck
import
photoAccessHelper
from
'@ohos.file.photoAccessHelper'
import
{
describe
,
it
,
expect
}
from
'deccjsunit/index'
import
{
photoType
}
from
'../../../../../../../common'
...
...
@@ -242,7 +241,7 @@ export default function createAssetTest () {
const
options
:
photoAccessHelper
.
CreateOptions
=
undefined
;
await
createAssetAbnormalCallback1
(
done
,
testNum
,
type
,
extension
,
options
);
});
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_PROMISE_CREATE_IMAGE_0000
* @tc.name : createImage_promise_000
...
...
multimedia/photoAccess/photoAccess/entry/src/main/ets/test/PhotoAccessHelper/createDeleteRequest.ets
0 → 100644
浏览文件 @
5e20d578
/*
* 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 photoAccessHelper from '@ohos.file.photoAccessHelper'
import { describe, it, expect } from 'deccjsunit/index'
import { genRadomStr, photoType } from '../../../../../../../common';
export default function createDeleteRequestTest() {
describe('createDeleteRequestTest', function () {
const helper = photoAccessHelper.getPhotoAccessHelper(globalThis.abilityContext)
const ERR_CODE_PARAMERTER_INVALID = 13900020;
const createFiles = async (count) => {
try {
const uriList: Array<string> = new Array();
for (let i = 0; i < count; i++) {
let title = genRadomStr(10);
let asset = await helper.createAsset(title + '.jpg');
let fd = await asset.open('rw');
await asset.close(fd);
uriList.push(asset.uri);
}
return uriList;
} catch (error) {
console.info(`delete_popup createFiles error ${error}`);
}
};
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_CALLBACK_CREATE_DELETE_REQUEST_0000
* @tc.name : createDeleteRequest_callback_000
* @tc.desc : delete 1 file
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('createDeleteRequest_callback_000', 0, async function (done) {
const testNum = 'createDeleteRequest_callback_000';
try {
let uriList = await createFiles(1);
console.info(`${testNum} uriList: ${JSON.stringify(uriList)}`)
helper.createDeleteRequest(uriList, (err) => {
try {
if (err) {
console.info(`${testNum} error ${JSON.stringify(err)}`);
} else {
console.log(`${testNum} delete suc`);
}
} catch (error) {
console.info(`${testNum} error ${JSON.stringify(error)}`);
}
done();
})
done();
} catch (error) {
expect(false).assertTrue();
done();
}
});
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_PROMISE_CREATE_DELETE_REQUEST_0000
* @tc.name : createDeleteRequest_promise_000
* @tc.desc : delete 1 file
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('createDeleteRequest_promise_000', 0, async function (done) {
const testNum = 'createDeleteRequest_promise_000';
try {
let uriList = await createFiles(1);
helper.createDeleteRequest(uriList)
.then(() => {
console.log(`${testNum} delete suc`);
})
.catch((error) => {
console.info(`${testNum} error ${JSON.stringify(error)}`);
expect(true).assertTrue();
});
done();
} catch (error) {
expect(false).assertTrue();
done();
}
});
});
}
multimedia/photoAccess/photoAccess/entry/src/main/ets/test/PhotoAccessHelper/getAlbums.ets
浏览文件 @
5e20d578
...
...
@@ -13,7 +13,7 @@
* limitations under the License.
*/
// @ts-nocheck
import dataSharePredicates from '@ohos.data.dataSharePredicates';
import photoAccessHelper from '@ohos.file.photoAccessHelper'
import { describe, it, expect } from 'deccjsunit/index'
import {
...
...
@@ -94,7 +94,7 @@ export default function getAlbumsTest () {
* @tc.type : Function
* @tc.level : Level 2
*/
it('getAlbums_callback_001',
0
, async function (done) {
it('getAlbums_callback_001',
2
, async function (done) {
const testNum = 'getAlbums_callback_001';
try {
// Firstly, create an album
...
...
@@ -134,7 +134,7 @@ export default function getAlbumsTest () {
* @tc.type : Function
* @tc.level : Level 0
*/
it('
SUB_PHOTOACCESS_HELPER_CALLBACK_GET_ALBUM_003
', 0, async function (done) {
it('
getAlbums_callback_002
', 0, async function (done) {
const testNum = 'getAlbums_callback_002';
try {
let subTypes : Array<photoAccessHelper.AlbumSubtype> = [
...
...
@@ -225,7 +225,7 @@ export default function getAlbumsTest () {
* @tc.type : Function
* @tc.level : Level 2
*/
it('getAlbums_promise_001',
0
, async function (done) {
it('getAlbums_promise_001',
2
, async function (done) {
const testNum = 'getAlbums_promise_001';
try {
// Firstly, create an album
...
...
@@ -254,7 +254,7 @@ export default function getAlbumsTest () {
* @tc.type : Function
* @tc.level : Level 0
*/
it('
SUB_PHOTOACCESS_HELPER_PROMISE_GET_ALBUM_003
', 0, async function (done) {
it('
getAlbums_promise_002
', 0, async function (done) {
const testNum = 'getAlbums_promise_002';
try {
let subTypes : Array<photoAccessHelper.AlbumSubtype> = [
...
...
@@ -278,5 +278,81 @@ export default function getAlbumsTest () {
done();
}
});
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_PROMISE_GET_ALBUMS_0300
* @tc.name : getAlbums_promise_003
* @tc.desc : get user albums by orderByAsc
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
*/
it('getAlbums_promise_003', 2, async function (done) {
const testNum = 'getAlbums_promise_003';
try {
const albumNames = ['b', 'a', 'c'];
for (let i = 0; i < albumNames.length; i++) {
await helper.createAlbum(albumNames[i]);
}
const predicates = new dataSharePredicates.DataSharePredicates();
predicates.in(albumKeys.ALBUM_NAME, albumNames).orderByAsc(albumKeys.ALBUM_NAME);
const fetchOps : photoAccessHelper.FetchOptions = {
fetchColumns: [],
predicates: predicates
};
const fetchResult = await helper.getAlbums(albumType.USER, albumSubtype.USER_GENERIC, fetchOps);
expect(fetchResult.getCount()).assertEqual(3);
const resultList = await fetchResult.getAllObjects();
const expectNames = ['a', 'b', 'c'];
for (let i = 0; i < albumNames.length; i++) {
console.info(`${testNum} albumName: ${resultList[i].albumName}`);
expect(resultList[i].albumName).assertEqual(expectNames[i]);
}
done();
} catch (error) {
console.info(`${testNum} failed, error: ${error}`);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_PROMISE_GET_ALBUMS_0400
* @tc.name : getAlbums_promise_004
* @tc.desc : get user albums by orderByDesc
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
*/
it('getAlbums_promise_004', 2, async function (done) {
const testNum = 'getAlbums_promise_004';
try {
const albumNames = ['x', 'y', 'z'];
for (let i = 0; i < albumNames.length; i++) {
await helper.createAlbum(albumNames[i]);
}
const predicates = new dataSharePredicates.DataSharePredicates();
predicates.in(albumKeys.ALBUM_NAME, albumNames).orderByDesc(albumKeys.ALBUM_NAME);
const fetchOps : photoAccessHelper.FetchOptions = {
fetchColumns: [],
predicates: predicates
};
const fetchResult = await helper.getAlbums(albumType.USER, albumSubtype.USER_GENERIC, fetchOps);
expect(fetchResult.getCount()).assertEqual(3);
const resultList = await fetchResult.getAllObjects();
const expectNames = ['z', 'y', 'x'];
for (let i = 0; i < albumNames.length; i++) {
console.info(`${testNum} albumName: ${resultList[i].albumName}`);
expect(resultList[i].albumName).assertEqual(expectNames[i]);
}
done();
} catch (error) {
console.info(`${testNum} failed, error: ${error}`);
expect(false).assertTrue();
done();
}
});
})
}
multimedia/photoAccess/photoAccess/entry/src/main/ets/test/PhotoAccessHelper/getAssets.ets
浏览文件 @
5e20d578
...
...
@@ -13,7 +13,6 @@
* limitations under the License.
*/
// @ts-nocheck
import
photoAccessHelper
from
'@ohos.file.photoAccessHelper'
import
{
describe
,
it
,
expect
}
from
'deccjsunit/index'
import
{
...
...
multimedia/photoAccess/photoAccess/entry/src/main/ets/test/PhotoAccessHelper/registerChange.ets
浏览文件 @
5e20d578
...
...
@@ -13,7 +13,6 @@
* limitations under the License.
*/
// @ts-nocheck
import photoAccessHelper from '@ohos.file.photoAccessHelper'
import { describe, it, expect } from 'deccjsunit/index'
import {
...
...
@@ -22,7 +21,6 @@ import {
photoKeys,
getFileAsset,
photoFetchOption,
photoType,
} from '../../../../../../../common'
export default function registerChangeTest () {
...
...
@@ -34,20 +32,20 @@ export default function registerChangeTest () {
const DEFAULT_ALBUM_URI = photoAccessHelper.DefaultChangeUri.DEFAULT_ALBUM_URI;
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_
ON
_CALLBACK_0100
* @tc.name :
on
_callback_001
* @tc.number : SUB_PHOTOACCESS_HELPER_
REGISTERCHANGE
_CALLBACK_0100
* @tc.name :
registerChange
_callback_001
* @tc.desc : listening motify file displayName, type NOTIFY_UPDATE
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('
on
_callback_001', 0, async function (done) {
const testNum = '
on
_callback_001';
it('
registerChange
_callback_001', 0, async function (done) {
const testNum = '
registerChange
_callback_001';
try {
let fetchOps = photoFetchOption(testNum, photoKeys.DISPLAY_NAME, 'on01.jpg');
const asset = await getFileAsset(testNum, fetchOps);
let count = 0;
await sleep(5
0
0);
await sleep(5
5
0);
helper.registerChange(asset.uri, false, async (changeData) => {
count++;
console.info(`${testNum} changeData: ${JSON.stringify(changeData)}`);
...
...
@@ -55,6 +53,7 @@ export default function registerChangeTest () {
expect(changeData.type).assertEqual(NOTIFY_UPDATE);
expect(changeData.uris[0]).assertEqual(asset.uri);
});
await sleep(550);
const newTitle = testNum + asset.get(photoKeys.TITLE);
asset.set(photoKeys.TITLE, newTitle);
await asset.commitModify();
...
...
@@ -69,15 +68,15 @@ export default function registerChangeTest () {
});
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_
ON
_CALLBACK_0700
* @tc.name :
on
_callback_007
* @tc.number : SUB_PHOTOACCESS_HELPER_
REGISTERCHANGE
_CALLBACK_0700
* @tc.name :
registerChange
_callback_007
* @tc.desc : listening create album, type NOTIFY_ADD
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('
on
_callback_007', 0, async function (done) {
const testNum = '
on
_callback_007';
it('
registerChange
_callback_007', 0, async function (done) {
const testNum = '
registerChange
_callback_007';
try {
let changeDataUri = '';
let listenCount = 0;
...
...
@@ -88,10 +87,11 @@ export default function registerChangeTest () {
changeDataUri = changeData.uris[0];
expect(changeData.type).assertEqual(NOTIFY_ADD);
});
await sleep(550);
let albumName = 'testAlbum' + Date.now();
let album = await helper.createAlbum(albumName);
let creatAlbumUri = album.albumUri;
await sleep(
2
000);
await sleep(
1
000);
helper.unRegisterChange(DEFAULT_ALBUM_URI);
expect(creatAlbumUri).assertEqual(changeDataUri);
expect(listenCount).assertEqual(1);
...
...
@@ -104,28 +104,29 @@ export default function registerChangeTest () {
});
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_
ON
_CALLBACK_0800
* @tc.name :
on
_callback_008
* @tc.number : SUB_PHOTOACCESS_HELPER_
REGISTERCHANGE
_CALLBACK_0800
* @tc.name :
registerChange
_callback_008
* @tc.desc : listening change albumName, type NOTIFY_UPDATE
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('
on
_callback_008', 0, async function (done) {
const testNum = '
on
_callback_008';
it('
registerChange
_callback_008', 0, async function (done) {
const testNum = '
registerChange
_callback_008';
try {
let albumUri = '';
let count = 0;
let albumName = 'testAlbum' + Date.now();
let album = await helper.createAlbum(albumName);
albumUri = album.albumUri;
await sleep(5
0
0);
await sleep(5
5
0);
helper.registerChange(albumUri, false, async (changeData) => {
count++;
console.info(`${testNum} changeData: ${JSON.stringify(changeData)}`);
expect(changeData.type).assertEqual(NOTIFY_UPDATE);
expect(changeData.uris[0]).assertEqual(albumUri);
});
await sleep(550);
album.albumName = Date.now() + album.albumName;
await album.commitModify();
await sleep(1000);
...
...
@@ -140,22 +141,22 @@ export default function registerChangeTest () {
});
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_
ON
_CALLBACK_1100
* @tc.name :
on
_callback_011
* @tc.number : SUB_PHOTOACCESS_HELPER_
REGISTERCHANGE
_CALLBACK_1100
* @tc.name :
registerChange
_callback_011
* @tc.desc : listening album removeAssets, type NOTIFY_ALBUM_ADD_ASSET
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
*/
it('
on
_callback_011', 0, async function (done) {
const testNum = '
on
_callback_011';
it('
registerChange
_callback_011', 0, async function (done) {
const testNum = '
registerChange
_callback_011';
try {
let albumName = 'testAlbum' + Date.now();
let album = await helper.createAlbum(albumName);
const fetchOps = fetchOption(testNum, photoKeys.DISPLAY_NAME, 'on11.jpg');
const asset = await getFileAsset(testNum, fetchOps);
let count = 0;
await sleep(5
0
0);
await sleep(5
5
0);
helper.registerChange(album.albumUri, false, async (changeData) => {
count++;
console.info(`${testNum} changeData: ${JSON.stringify(changeData)}`);
...
...
@@ -163,6 +164,7 @@ export default function registerChangeTest () {
expect(changeData.uris[0]).assertEqual(album.albumUri);
expect(changeData.extraUris[0]).assertEqual(asset.uri);
});
await sleep(550);
await album.addAssets([asset]);
await sleep(1000);
helper.unRegisterChange(album.albumUri);
...
...
@@ -176,15 +178,15 @@ export default function registerChangeTest () {
});
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_
ON
_CALLBACK_1200
* @tc.name :
on
_callback_012
* @tc.number : SUB_PHOTOACCESS_HELPER_
REGISTERCHANGE
_CALLBACK_1200
* @tc.name :
registerChange
_callback_012
* @tc.desc : listening album removeAssets, type NOTIFY_ALBUM_REMOVE_ASSET
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
*/
it('
on
_callback_012', 0, async function (done) {
const testNum = '
on
_callback_012';
it('
registerChange
_callback_012', 0, async function (done) {
const testNum = '
registerChange
_callback_012';
try {
let albumName = 'testAlbum' + Date.now();
let album = await helper.createAlbum(albumName);
...
...
@@ -192,7 +194,7 @@ export default function registerChangeTest () {
const asset = await getFileAsset(testNum, fetchOps);
let count = 0;
await album.addAssets([asset]);
await sleep(5
0
0);
await sleep(5
5
0);
helper.registerChange(album.albumUri, false, async (changeData) => {
count++;
console.info(`${testNum} changeData: ${JSON.stringify(changeData)}`);
...
...
@@ -200,6 +202,7 @@ export default function registerChangeTest () {
expect(changeData.uris[0]).assertEqual(album.albumUri);
expect(changeData.extraUris[0]).assertEqual(asset.uri);
});
await sleep(550);
await album.removeAssets([asset]);
await sleep(1000);
helper.unRegisterChange(album.albumUri);
...
...
multimedia/photoAccess/photoAccess/entry/src/main/ets/test/PhotoAccessHelper/release.ets
浏览文件 @
5e20d578
...
...
@@ -13,7 +13,6 @@
* limitations under the License.
*/
// @ts-nocheck
import photoAccessHelper from '@ohos.file.photoAccessHelper'
import { describe, it, expect } from 'deccjsunit/index'
...
...
multimedia/photoAccess/photoAccess/entry/src/main/ets/test/PhotoAccessHelper/unRegisterChange.ets
浏览文件 @
5e20d578
...
...
@@ -13,7 +13,6 @@
* limitations under the License.
*/
// @ts-nocheck
import
photoAccessHelper
from
'@ohos.file.photoAccessHelper'
import
{
describe
,
it
,
expect
}
from
'deccjsunit/index'
import
{
...
...
@@ -22,9 +21,6 @@ import {
photoKeys
,
getFileAsset
,
photoFetchOption
,
photoType
,
albumType
,
albumSubtype
}
from
'../../../../../../../common'
export
default
function
unRegisterChangeTest
()
{
...
...
@@ -34,27 +30,27 @@ export default function unRegisterChangeTest () {
const
DEFAULT_ALBUM_URI
=
photoAccessHelper
.
DefaultChangeUri
.
DEFAULT_ALBUM_URI
;
/**
* @tc.number : SUB_PHOTOACCESS_
HELPER_OFF
_0100
* @tc.name :
off
_001
* @tc.number : SUB_PHOTOACCESS_
UNREGISTERCHANGE
_0100
* @tc.name :
unRegisterChange
_001
* @tc.desc : off listening motify file displayName, type NOTIFY_UPDATE
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it
(
'
off
_001'
,
0
,
async
function
(
done
)
{
const
testNum
=
'
off
_001'
;
it
(
'
unRegisterChange
_001'
,
0
,
async
function
(
done
)
{
const
testNum
=
'
unRegisterChange
_001'
;
try
{
const
fetchOps
=
photoFetchOption
(
testNum
,
photoKeys
.
DISPLAY_NAME
,
'off01.jpg'
);
const
asset
=
await
getFileAsset
(
testNum
,
fetchOps
);
let
count
=
0
;
await
sleep
(
5
0
0
);
await
sleep
(
5
5
0
);
helper
.
registerChange
(
asset
.
uri
,
false
,
async
(
changeData
)
=>
{
count
++
;
console
.
info
(
`${testNum} changeData: ${JSON.stringify(changeData)}`
);
});
await
sleep
(
10
0
);
await
sleep
(
55
0
);
helper
.
unRegisterChange
(
asset
.
uri
);
await
sleep
(
10
0
);
await
sleep
(
55
0
);
const
newTitle
=
testNum
+
asset
.
get
(
photoKeys
.
TITLE
);
asset
.
set
(
photoKeys
.
TITLE
,
newTitle
);
await
asset
.
commitModify
();
...
...
@@ -69,24 +65,24 @@ export default function unRegisterChangeTest () {
});
/**
* @tc.number : SUB_PHOTOACCESS_
HELPER_OFF
_0700
* @tc.name :
off
_007
* @tc.number : SUB_PHOTOACCESS_
UNREGISTERCHANGE
_0700
* @tc.name :
unRegisterChange
_007
* @tc.desc : off listening create album, type NOTIFY_ADD
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it
(
'
off
_007'
,
0
,
async
function
(
done
)
{
const
testNum
=
'
off
_007'
;
it
(
'
unRegisterChange
_007'
,
0
,
async
function
(
done
)
{
const
testNum
=
'
unRegisterChange
_007'
;
try
{
let
count
=
0
;
helper
.
registerChange
(
DEFAULT_ALBUM_URI
,
true
,
async
(
changeData
)
=>
{
count
++
;
console
.
info
(
`${testNum} changeData: ${JSON.stringify(changeData)}`
);
});
await
sleep
(
10
0
);
await
sleep
(
55
0
);
helper
.
unRegisterChange
(
DEFAULT_ALBUM_URI
);
await
sleep
(
10
0
);
await
sleep
(
55
0
);
let
albumName
=
testNum
+
Date
.
now
();
await
helper
.
createAlbum
(
albumName
);
await
sleep
(
1000
);
...
...
@@ -100,29 +96,29 @@ export default function unRegisterChangeTest () {
});
/**
* @tc.number : SUB_PHOTOACCESS_
HELPER_OFF
_0800
* @tc.name :
off
_008
* @tc.number : SUB_PHOTOACCESS_
UNREGISTERCHANGE
_0800
* @tc.name :
unRegisterChange
_008
* @tc.desc : off listening create album, type NOTIFY_UPDATE
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it
(
'
off
_008'
,
0
,
async
function
(
done
)
{
const
testNum
=
'
off
_008'
;
it
(
'
unRegisterChange
_008'
,
0
,
async
function
(
done
)
{
const
testNum
=
'
unRegisterChange
_008'
;
try
{
let
albumUri
=
''
;
let
count
=
0
;
let
albumName
=
testNum
+
Date
.
now
();
let
album
=
await
helper
.
createAlbum
(
albumName
);
albumUri
=
album
.
albumUri
;
await
sleep
(
5
0
0
);
await
sleep
(
5
5
0
);
helper
.
registerChange
(
albumUri
,
false
,
async
(
changeData
)
=>
{
count
++
;
console
.
info
(
`${testNum} changeData: ${JSON.stringify(changeData)}`
);
});
await
sleep
(
10
0
);
await
sleep
(
55
0
);
helper
.
unRegisterChange
(
albumUri
);
await
sleep
(
10
0
);
await
sleep
(
55
0
);
album
.
albumName
=
Date
.
now
()
+
album
.
albumName
;
await
album
.
commitModify
();
await
sleep
(
1000
);
...
...
@@ -136,15 +132,15 @@ export default function unRegisterChangeTest () {
});
/**
* @tc.number : SUB_PHOTOACCESS_
HELPER_OFF
_1000
* @tc.name :
off
_010
* @tc.number : SUB_PHOTOACCESS_
UNREGISTERCHANGE
_1000
* @tc.name :
unRegisterChange
_010
* @tc.desc : off listening change album overUri, type NOTIFY_UPDATE
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it
(
'
off
_010'
,
0
,
async
function
example
(
done
)
{
const
testNum
=
'
off
_010'
;
it
(
'
unRegisterChange
_010'
,
0
,
async
function
example
(
done
)
{
const
testNum
=
'
unRegisterChange
_010'
;
try
{
let
albumUri
=
''
;
let
count
=
0
;
...
...
@@ -154,14 +150,14 @@ export default function unRegisterChangeTest () {
const
asset
=
await
getFileAsset
(
testNum
,
fetchOps
);
albumUri
=
album
.
albumUri
;
await
album
.
addAssets
([
asset
]);
await
sleep
(
5
0
0
);
await
sleep
(
5
5
0
);
helper
.
registerChange
(
albumUri
,
false
,
async
(
changeData
)
=>
{
count
++
;
console
.
info
(
`${testNum} changeData: ${JSON.stringify(changeData)}`
);
});
await
sleep
(
10
0
);
await
sleep
(
55
0
);
helper
.
unRegisterChange
(
albumUri
);
await
sleep
(
10
0
);
await
sleep
(
55
0
);
album
.
albumName
=
testNum
+
album
.
albumName
;
await
album
.
commitModify
();
await
sleep
(
1000
);
...
...
@@ -175,29 +171,29 @@ export default function unRegisterChangeTest () {
});
/**
* @tc.number : SUB_PHOTOACCESS_
HELPER_OFF
_1100
* @tc.name :
off
_011
* @tc.number : SUB_PHOTOACCESS_
UNREGISTERCHANGE
_1100
* @tc.name :
unRegisterChange
_011
* @tc.desc : off listening album removeAssets, type NOTIFY_ALBUM_ADD_ASSET
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it
(
'
off
_011'
,
0
,
async
function
(
done
)
{
const
testNum
=
'
off
_011'
;
it
(
'
unRegisterChange
_011'
,
0
,
async
function
(
done
)
{
const
testNum
=
'
unRegisterChange
_011'
;
try
{
let
albumName
=
'testAlbum'
+
Date
.
now
();
let
album
=
await
helper
.
createAlbum
(
albumName
);
const
fetchOps
=
fetchOption
(
testNum
,
photoKeys
.
DISPLAY_NAME
,
'off11.jpg'
);
const
asset
=
await
getFileAsset
(
testNum
,
fetchOps
);
let
count
=
0
;
await
sleep
(
5
0
0
);
await
sleep
(
5
5
0
);
helper
.
registerChange
(
album
.
albumUri
,
false
,
async
(
changeData
)
=>
{
count
++
;
console
.
info
(
`${testNum} changeData: ${JSON.stringify(changeData)}`
);
});
await
sleep
(
10
0
);
await
sleep
(
55
0
);
helper
.
unRegisterChange
(
album
.
albumUri
);
await
sleep
(
10
0
);
await
sleep
(
55
0
);
await
album
.
addAssets
([
asset
]);
await
sleep
(
1000
);
expect
(
count
)
.
assertEqual
(
0
);
...
...
@@ -210,15 +206,15 @@ export default function unRegisterChangeTest () {
});
/**
* @tc.number : SUB_PHOTOACCESS_
HELPER_OFF
_1200
* @tc.name :
off
_012
* @tc.number : SUB_PHOTOACCESS_
UNREGISTERCHANGE
_1200
* @tc.name :
unRegisterChange
_012
* @tc.desc : off listening album removeAssets, type NOTIFY_ALBUM_REMOVE_ASSET
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it
(
'
off
_012'
,
0
,
async
function
(
done
)
{
const
testNum
=
'
off
_012'
;
it
(
'
unRegisterChange
_012'
,
0
,
async
function
(
done
)
{
const
testNum
=
'
unRegisterChange
_012'
;
try
{
let
albumName
=
'testAlbum'
+
Date
.
now
();
let
album
=
await
helper
.
createAlbum
(
albumName
);
...
...
@@ -226,14 +222,14 @@ export default function unRegisterChangeTest () {
const
asset
=
await
getFileAsset
(
testNum
,
fetchOps
);
let
count
=
0
;
await
album
.
addAssets
([
asset
]);
await
sleep
(
5
0
0
);
await
sleep
(
5
5
0
);
helper
.
registerChange
(
album
.
albumUri
,
false
,
async
(
changeData
)
=>
{
count
++
;
console
.
info
(
`${testNum} changeData: ${JSON.stringify(changeData)}`
);
});
await
sleep
(
10
0
);
await
sleep
(
55
0
);
helper
.
unRegisterChange
(
album
.
albumUri
);
await
sleep
(
10
0
);
await
sleep
(
55
0
);
await
album
.
removeAssets
([
asset
]);
await
sleep
(
1000
);
expect
(
count
)
.
assertEqual
(
0
);
...
...
@@ -246,20 +242,20 @@ export default function unRegisterChangeTest () {
});
/**
* @tc.number : SUB_PHOTOACCESS_
HELPER_OFF
_1500
* @tc.name :
off
_015
* @tc.number : SUB_PHOTOACCESS_
UNREGISTERCHANGE
_1500
* @tc.name :
unRegisterChange
_015
* @tc.desc : off remove all listening
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 3
*/
it
(
'
off
_015'
,
0
,
async
function
(
done
)
{
const
testNum
=
'
off
_015'
;
it
(
'
unRegisterChange
_015'
,
0
,
async
function
(
done
)
{
const
testNum
=
'
unRegisterChange
_015'
;
try
{
let
fetchOps
=
photoFetchOption
(
testNum
,
photoKeys
.
DISPLAY_NAME
,
'off15.jpg'
);
const
asset
=
await
getFileAsset
(
testNum
,
fetchOps
);
let
listenCount
=
0
;
await
sleep
(
5
0
0
);
await
sleep
(
5
5
0
);
helper
.
registerChange
(
asset
.
uri
,
false
,
async
(
changeData
)
=>
{
listenCount
++
;
console
.
info
(
`${testNum} changeData1: ${JSON.stringify(changeData)}`
);
...
...
@@ -268,9 +264,9 @@ export default function unRegisterChangeTest () {
listenCount
++
;
console
.
info
(
`${testNum} changeData2: ${JSON.stringify(changeData)}`
);
});
await
sleep
(
10
0
);
await
sleep
(
55
0
);
helper
.
unRegisterChange
(
asset
.
uri
);
await
sleep
(
10
0
);
await
sleep
(
55
0
);
const
newTitle
=
testNum
+
asset
.
get
(
photoKeys
.
TITLE
);
asset
.
set
(
photoKeys
.
TITLE
,
newTitle
);
await
asset
.
commitModify
();
...
...
@@ -285,21 +281,21 @@ export default function unRegisterChangeTest () {
});
/**
* @tc.number : SUB_PHOTOACCESS_
HELPER_OFF
_CALLBACK_0000
* @tc.name :
off
_callback_000
* @tc.number : SUB_PHOTOACCESS_
UNREGISTERCHANGE
_CALLBACK_0000
* @tc.name :
unRegisterChange
_callback_000
* @tc.desc : off remove specified callback
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 3
*/
it
(
'
off
_callback_000'
,
0
,
async
function
(
done
)
{
const
testNum
=
'
off
_callback_000'
;
it
(
'
unRegisterChange
_callback_000'
,
0
,
async
function
(
done
)
{
const
testNum
=
'
unRegisterChange
_callback_000'
;
try
{
let
fetchOps
=
photoFetchOption
(
testNum
,
photoKeys
.
DISPLAY_NAME
,
'offCb01.jpg'
);
const
asset
=
await
getFileAsset
(
testNum
,
fetchOps
);
let
listenCount1
=
0
;
let
listenCount2
=
0
;
await
sleep
(
5
0
0
);
await
sleep
(
5
5
0
);
const
callback1
=
async
(
changeData
)
=>
{
listenCount1
++
;
console
.
info
(
`${testNum} callback1: ${JSON.stringify(changeData)}`
);
...
...
@@ -312,9 +308,9 @@ export default function unRegisterChangeTest () {
helper
.
registerChange
(
asset
.
uri
,
false
,
callback1
);
helper
.
registerChange
(
asset
.
uri
,
false
,
callback2
);
await
sleep
(
10
0
);
await
sleep
(
55
0
);
helper
.
unRegisterChange
(
asset
.
uri
,
callback1
);
await
sleep
(
10
0
);
await
sleep
(
55
0
);
const
newTitle
=
testNum
+
asset
.
get
(
photoKeys
.
TITLE
);
asset
.
set
(
photoKeys
.
TITLE
,
newTitle
);
await
asset
.
commitModify
();
...
...
multimedia/photoAccess/photoAccess/entry/src/main/ets/test/PhotoAsset/checkAttr.ets
浏览文件 @
5e20d578
...
...
@@ -13,13 +13,12 @@
* limitations under the License.
*/
// @ts-nocheck
import
{
describe
,
it
,
expect
}
from
'deccjsunit/index'
import
{
photoKeys
,
fetchOption
,
getFileAsset
,
getId
,
get
Asset
Id
,
photoType
}
from
'../../../../../../../common'
...
...
@@ -28,12 +27,13 @@ export default function checkAttrTest () {
async
function
checkAssetAttr
(
done
,
testNum
,
displayName
,
mediaType
)
{
try
{
let
key
=
photoKeys
.
DISPLAY_NAME
;
let
uri
=
'file://media/Photo/'
;
const
fetchOps
=
fetchOption
(
testNum
,
key
,
displayName
);
const
asset
=
await
getFileAsset
(
testNum
,
fetchOps
);
console
.
info
(
`${testNum} uri: ${asset.uri} filetype: ${asset.photoType} displayName: ${asset.displayName}`
)
const
id
=
getId
(
asset
.
uri
);
expect
(
asset
.
uri
)
.
assertEqual
(
uri
+
id
);
const
id
=
getAssetId
(
asset
.
uri
);
const
expectUri
=
'file://media/Photo/'
+
id
;
const
isIncludes
=
asset
.
uri
.
includes
(
expectUri
);
expect
(
isIncludes
)
.
assertTrue
();
expect
(
asset
.
photoType
)
.
assertEqual
(
mediaType
);
expect
(
asset
.
displayName
)
.
assertEqual
(
displayName
);
done
();
...
...
multimedia/photoAccess/photoAccess/entry/src/main/ets/test/PhotoAsset/close.ets
浏览文件 @
5e20d578
...
...
@@ -13,7 +13,6 @@
* limitations under the License.
*/
// @ts-nocheck
import
fileio
from
"@ohos.fileio"
;
import
{
describe
,
it
,
expect
}
from
'deccjsunit/index'
import
{
...
...
multimedia/photoAccess/photoAccess/entry/src/main/ets/test/PhotoAsset/commitModify.ets
浏览文件 @
5e20d578
...
...
@@ -13,7 +13,6 @@
* limitations under the License.
*/
// @ts-nocheck
import
photoAccessHelper
from
'@ohos.file.photoAccessHelper'
import
{
describe
,
it
,
expect
}
from
'deccjsunit/index'
import
{
...
...
@@ -30,8 +29,9 @@ export default function commitModifyTest () {
try
{
const
asset
=
await
getFileAsset
(
testNum
,
fetchOps
);
const
oldTitle
:
photoAccessHelper
.
MemberType
=
asset
.
get
(
photoKeys
.
TITLE
)
.
toString
();
console
.
info
(
`${testNum} oldTitle: ${
typeof
oldTitle}`
);
console
.
info
(
`${testNum} oldTitle: ${oldTitle}`
);
asset
.
set
(
photoKeys
.
TITLE
,
newTitle
);
console
.
info
(
`${testNum} newTitle: ${newTitle}`
);
asset
.
commitModify
(
async
(
err
)
=>
{
try
{
if
(
err
)
{
...
...
multimedia/photoAccess/photoAccess/entry/src/main/ets/test/PhotoAsset/get.ets
浏览文件 @
5e20d578
...
...
@@ -13,13 +13,12 @@
* limitations under the License.
*/
// @ts-nocheck
import
{
describe
,
it
,
expect
}
from
'deccjsunit/index'
import
{
photoKeys
,
photoFetchOption
,
getFileAsset
,
getId
,
get
Asset
Id
,
isNum
,
photoType
,
}
from
'../../../../../../../common'
...
...
@@ -31,8 +30,11 @@ export default function getTest () {
let
asset
=
await
getFileAsset
(
testNum
,
fetchOps
);
console
.
info
(
`${testNum} key: ${key}, value: ${value}, asset.key: ${asset.get(key)}`
);
if
(
key
===
'uri'
)
{
const
id
=
getId
(
asset
.
get
(
key
));
expect
(
asset
.
get
(
key
))
.
assertEqual
(
value
+
id
);
const
id
=
getAssetId
(
asset
.
get
(
key
));
const
expectUri
=
value
+
id
;
const
uri
=
asset
.
get
(
key
)
.
toString
();
const
isIncludes
=
uri
.
includes
(
expectUri
);
expect
(
isIncludes
)
.
assertTrue
();
}
else
if
(
key
===
'date_added'
||
key
===
'date_modified'
||
key
===
'date_taken'
)
{
expect
(
isNum
(
asset
.
get
(
key
)))
.
assertTrue
();
}
else
{
...
...
multimedia/photoAccess/photoAccess/entry/src/main/ets/test/PhotoAsset/getReadOnlyFd.ets
浏览文件 @
5e20d578
...
...
@@ -13,14 +13,12 @@
* limitations under the License.
*/
// @ts-nocheck
import
fileio
from
"@ohos.fileio"
;
import
{
describe
,
it
,
expect
}
from
'deccjsunit/index'
import
{
photoKeys
,
fetchOption
,
getFileAsset
,
isNum
,
}
from
'../../../../../../../common'
export
default
function
getReadOnlyFdTest
()
{
...
...
multimedia/photoAccess/photoAccess/entry/src/main/ets/test/PhotoAsset/getThumbnail.ets
浏览文件 @
5e20d578
...
...
@@ -13,7 +13,6 @@
* limitations under the License.
*/
// @ts-nocheck
import
photoAccessHelper
from
'@ohos.file.photoAccessHelper'
import
image
from
'@ohos.multimedia.image'
;
import
{
describe
,
it
,
expect
}
from
'deccjsunit/index'
...
...
multimedia/photoAccess/photoAccess/entry/src/main/ets/test/PhotoAssetFetchResult/close.ets
浏览文件 @
5e20d578
...
...
@@ -13,7 +13,6 @@
* limitations under the License.
*/
// @ts-nocheck
import
photoAccessHelper
from
'@ohos.file.photoAccessHelper'
import
{
describe
,
it
,
expect
}
from
'deccjsunit/index'
import
{
...
...
multimedia/photoAccess/photoAccess/entry/src/main/ets/test/PhotoAssetFetchResult/getAllObjects.ets
浏览文件 @
5e20d578
...
...
@@ -13,7 +13,6 @@
* limitations under the License.
*/
// @ts-nocheck
import
photoAccessHelper
from
'@ohos.file.photoAccessHelper'
import
{
describe
,
it
,
expect
}
from
'deccjsunit/index'
import
{
...
...
multimedia/photoAccess/photoAccess/entry/src/main/ets/test/PhotoAssetFetchResult/getCount.ets
浏览文件 @
5e20d578
...
...
@@ -13,7 +13,6 @@
* limitations under the License.
*/
// @ts-nocheck
import
photoAccessHelper
from
'@ohos.file.photoAccessHelper'
import
{
describe
,
it
,
expect
}
from
'deccjsunit/index'
import
{
...
...
multimedia/photoAccess/photoAccess/entry/src/main/ets/test/PhotoAssetFetchResult/getFirstObject.ets
浏览文件 @
5e20d578
...
...
@@ -13,11 +13,10 @@
* limitations under the License.
*/
// @ts-nocheck
import
dataSharePredicates
from
'@ohos.data.dataSharePredicates'
;
import
photoAccessHelper
from
'@ohos.file.photoAccessHelper'
import
{
describe
,
it
,
expect
}
from
'deccjsunit/index'
import
{
fetchOption
,
photoType
,
photoKeys
}
from
'../../../../../../../common'
...
...
@@ -30,17 +29,18 @@ export default function assetGetFirstObjectTest () {
try
{
let
fetchResult
=
await
helper
.
getAssets
(
fetchOps
);
console
.
info
(
`${testNum} fetchResult: ${fetchResult.getCount()}`
);
expect
(
fetchResult
.
getCount
()
>
0
)
.
assertTrue
(
);
expect
(
fetchResult
.
getCount
()
)
.
assertEqual
(
1
);
fetchResult
.
getFirstObject
((
err
,
asset
)
=>
{
try
{
if
(
err
!==
undefined
)
{
console
.
info
(
`${testNum}
getFirstObject failed;
err: ${err}`
);
console
.
info
(
`${testNum} err: ${err}`
);
expect
(
false
)
.
assertTrue
();
}
else
{
console
.
info
(
`${testNum} asset: ${asset.displayName}`
);
expect
(
asset
!==
undefined
)
.
assertTrue
();
}
}
catch
(
error
)
{
console
.
info
(
`${testNum}
getFirstObject failed;
error: ${error}`
);
console
.
info
(
`${testNum} error: ${error}`
);
}
fetchResult
.
close
();
done
();
...
...
@@ -55,9 +55,10 @@ export default function assetGetFirstObjectTest () {
async
function
getFirstObjectPromiseTest
(
done
,
testNum
,
fetchOps
)
{
try
{
let
fetchResult
=
await
helper
.
getAssets
(
fetchOps
);
expect
(
fetchResult
.
getCount
()
>
0
)
.
assertTrue
(
);
expect
(
fetchResult
.
getCount
()
)
.
assertEqual
(
1
);
const
asset
=
await
fetchResult
.
getFirstObject
();
fetchResult
.
close
();
console
.
info
(
`${testNum} asset: ${asset.displayName}`
);
expect
(
asset
!==
undefined
)
.
assertTrue
();
done
();
}
catch
(
error
)
{
...
...
@@ -79,7 +80,12 @@ export default function assetGetFirstObjectTest () {
*/
it
(
'getFirstObject_callback_000'
,
0
,
async
function
(
done
)
{
const
testNum
=
'getFirstObject_callback_000'
;
const
fetchOps
=
fetchOption
(
testNum
,
photoKeys
.
PHOTO_TYPE
,
photoType
.
IMAGE
);
const
predicates
=
new
dataSharePredicates
.
DataSharePredicates
();
predicates
.
equalTo
(
photoKeys
.
PHOTO_TYPE
,
photoType
.
IMAGE
)
.
and
()
.
equalTo
(
photoKeys
.
DISPLAY_NAME
,
'01.jpg'
);
const
fetchOps
:
photoAccessHelper
.
FetchOptions
=
{
fetchColumns
:
[],
predicates
:
predicates
};
await
getFirstObjectCallbackTest
(
done
,
testNum
,
fetchOps
);
});
...
...
@@ -94,7 +100,12 @@ export default function assetGetFirstObjectTest () {
*/
it
(
'getFirstObject_promise_000'
,
0
,
async
function
(
done
)
{
const
testNum
=
'getFirstObject_promise_000'
;
const
fetchOps
=
fetchOption
(
testNum
,
photoKeys
.
PHOTO_TYPE
,
photoType
.
IMAGE
);
const
predicates
=
new
dataSharePredicates
.
DataSharePredicates
();
predicates
.
equalTo
(
photoKeys
.
PHOTO_TYPE
,
photoType
.
IMAGE
)
.
and
()
.
equalTo
(
photoKeys
.
DISPLAY_NAME
,
'01.jpg'
);
const
fetchOps
:
photoAccessHelper
.
FetchOptions
=
{
fetchColumns
:
[],
predicates
:
predicates
};
await
getFirstObjectPromiseTest
(
done
,
testNum
,
fetchOps
);
});
...
...
@@ -110,7 +121,12 @@ export default function assetGetFirstObjectTest () {
*/
it
(
'getFirstObject_callback_001'
,
0
,
async
function
(
done
)
{
const
testNum
=
'getFirstObject_callback_001'
;
const
fetchOps
=
fetchOption
(
testNum
,
photoKeys
.
PHOTO_TYPE
,
photoType
.
VIDEO
);
const
predicates
=
new
dataSharePredicates
.
DataSharePredicates
();
predicates
.
equalTo
(
photoKeys
.
PHOTO_TYPE
,
photoType
.
VIDEO
)
.
and
()
.
equalTo
(
photoKeys
.
DISPLAY_NAME
,
'01.mp4'
);
const
fetchOps
:
photoAccessHelper
.
FetchOptions
=
{
fetchColumns
:
[],
predicates
:
predicates
};
await
getFirstObjectCallbackTest
(
done
,
testNum
,
fetchOps
);
});
...
...
@@ -125,7 +141,12 @@ export default function assetGetFirstObjectTest () {
*/
it
(
'getFirstObject_promise_001'
,
0
,
async
function
(
done
)
{
const
testNum
=
'getFirstObject_promise_001'
;
const
fetchOps
=
fetchOption
(
testNum
,
photoKeys
.
PHOTO_TYPE
,
photoType
.
VIDEO
);
const
predicates
=
new
dataSharePredicates
.
DataSharePredicates
();
predicates
.
equalTo
(
photoKeys
.
PHOTO_TYPE
,
photoType
.
VIDEO
)
.
and
()
.
equalTo
(
photoKeys
.
DISPLAY_NAME
,
'01.mp4'
);
const
fetchOps
:
photoAccessHelper
.
FetchOptions
=
{
fetchColumns
:
[],
predicates
:
predicates
};
await
getFirstObjectPromiseTest
(
done
,
testNum
,
fetchOps
);
});
})
...
...
multimedia/photoAccess/photoAccess/entry/src/main/ets/test/PhotoAssetFetchResult/getLastObject.ets
浏览文件 @
5e20d578
...
...
@@ -13,7 +13,6 @@
* limitations under the License.
*/
// @ts-nocheck
import
photoAccessHelper
from
'@ohos.file.photoAccessHelper'
import
{
describe
,
it
,
expect
}
from
'deccjsunit/index'
import
{
...
...
multimedia/photoAccess/photoAccess/entry/src/main/ets/test/PhotoAssetFetchResult/getNextObject.ets
浏览文件 @
5e20d578
...
...
@@ -13,11 +13,10 @@
* limitations under the License.
*/
// @ts-nocheck
import
dataSharePredicates
from
'@ohos.data.dataSharePredicates'
;
import
photoAccessHelper
from
'@ohos.file.photoAccessHelper'
import
{
describe
,
it
,
expect
}
from
'deccjsunit/index'
import
{
fetchOption
,
photoType
,
photoKeys
}
from
'../../../../../../../common'
...
...
@@ -29,7 +28,7 @@ export default function assetGetNextObjectTest () {
async
function
getNextObjectCallbackTest
(
done
,
testNum
,
fetchOps
)
{
try
{
let
fetchResult
=
await
helper
.
getAssets
(
fetchOps
);
expect
(
fetchResult
.
getCount
()
>
1
)
.
assertTrue
(
);
expect
(
fetchResult
.
getCount
()
)
.
assertEqual
(
2
);
await
fetchResult
.
getFirstObject
();
fetchResult
.
getNextObject
((
err
,
asset
)
=>
{
try
{
...
...
@@ -55,7 +54,7 @@ export default function assetGetNextObjectTest () {
async
function
getNextObjectPromiseTest
(
done
,
testNum
,
fetchOps
)
{
try
{
let
fetchResult
=
await
helper
.
getAssets
(
fetchOps
);
expect
(
fetchResult
.
getCount
()
>
1
)
.
assertTrue
(
);
expect
(
fetchResult
.
getCount
()
)
.
assertEqual
(
2
);
let
asset
=
await
fetchResult
.
getFirstObject
();
asset
=
await
fetchResult
.
getNextObject
();
fetchResult
.
close
();
...
...
@@ -80,7 +79,12 @@ export default function assetGetNextObjectTest () {
*/
it
(
'getNextObject_callback_000'
,
0
,
async
function
(
done
)
{
const
testNum
=
'getNextObject_callback_000'
;
const
fetchOps
=
fetchOption
(
testNum
,
photoKeys
.
PHOTO_TYPE
,
photoType
.
IMAGE
);
const
predicates
=
new
dataSharePredicates
.
DataSharePredicates
();
predicates
.
equalTo
(
photoKeys
.
PHOTO_TYPE
,
photoType
.
IMAGE
)
.
limit
(
2
,
0
);
const
fetchOps
:
photoAccessHelper
.
FetchOptions
=
{
fetchColumns
:
[],
predicates
:
predicates
};
await
getNextObjectCallbackTest
(
done
,
testNum
,
fetchOps
);
});
...
...
@@ -95,7 +99,12 @@ export default function assetGetNextObjectTest () {
*/
it
(
'getNextObject_promise_000'
,
0
,
async
function
(
done
)
{
const
testNum
=
'getNextObject_promise_000'
;
const
fetchOps
=
fetchOption
(
testNum
,
photoKeys
.
PHOTO_TYPE
,
photoType
.
IMAGE
);
const
predicates
=
new
dataSharePredicates
.
DataSharePredicates
();
predicates
.
equalTo
(
photoKeys
.
PHOTO_TYPE
,
photoType
.
IMAGE
)
.
limit
(
2
,
0
);
const
fetchOps
:
photoAccessHelper
.
FetchOptions
=
{
fetchColumns
:
[],
predicates
:
predicates
};
await
getNextObjectPromiseTest
(
done
,
testNum
,
fetchOps
);
});
...
...
@@ -111,7 +120,12 @@ export default function assetGetNextObjectTest () {
*/
it
(
'getNextObject_callback_001'
,
0
,
async
function
(
done
)
{
const
testNum
=
'getNextObject_callback_001'
;
const
fetchOps
=
fetchOption
(
testNum
,
photoKeys
.
PHOTO_TYPE
,
photoType
.
VIDEO
);
const
predicates
=
new
dataSharePredicates
.
DataSharePredicates
();
predicates
.
equalTo
(
photoKeys
.
PHOTO_TYPE
,
photoType
.
VIDEO
)
.
limit
(
2
,
0
);
const
fetchOps
:
photoAccessHelper
.
FetchOptions
=
{
fetchColumns
:
[],
predicates
:
predicates
};
await
getNextObjectCallbackTest
(
done
,
testNum
,
fetchOps
);
});
...
...
@@ -126,7 +140,12 @@ export default function assetGetNextObjectTest () {
*/
it
(
'getNextObject_promise_001'
,
0
,
async
function
(
done
)
{
const
testNum
=
'getNextObject_promise_001'
;
const
fetchOps
=
fetchOption
(
testNum
,
photoKeys
.
PHOTO_TYPE
,
photoType
.
VIDEO
);
const
predicates
=
new
dataSharePredicates
.
DataSharePredicates
();
predicates
.
equalTo
(
photoKeys
.
PHOTO_TYPE
,
photoType
.
VIDEO
)
.
limit
(
2
,
0
);
const
fetchOps
:
photoAccessHelper
.
FetchOptions
=
{
fetchColumns
:
[],
predicates
:
predicates
};
await
getNextObjectPromiseTest
(
done
,
testNum
,
fetchOps
);
});
})
...
...
multimedia/photoAccess/photoAccess/entry/src/main/ets/test/PhotoAssetFetchResult/getObjectByPosition.ets
浏览文件 @
5e20d578
...
...
@@ -13,7 +13,6 @@
* limitations under the License.
*/
// @ts-nocheck
import
photoAccessHelper
from
'@ohos.file.photoAccessHelper'
import
{
describe
,
it
,
expect
}
from
'deccjsunit/index'
import
{
...
...
multimedia/photoAccess/photoAccess/entry/src/main/ets/test/PhotoAssetFetchResult/isAfterLast.ets
浏览文件 @
5e20d578
...
...
@@ -13,11 +13,10 @@
* limitations under the License.
*/
// @ts-nocheck
import
dataSharePredicates
from
'@ohos.data.dataSharePredicates'
;
import
photoAccessHelper
from
'@ohos.file.photoAccessHelper'
import
{
describe
,
it
,
expect
}
from
'deccjsunit/index'
import
{
fetchOption
,
photoType
,
photoKeys
}
from
'../../../../../../../common'
...
...
@@ -30,17 +29,12 @@ export default function assetIsAfterLastTest () {
try
{
let
fetchResult
=
await
helper
.
getAssets
(
fetchOps
);
let
count
=
fetchResult
.
getCount
();
expect
(
count
>
1
)
.
assertTrue
(
);
expect
(
count
)
.
assertEqual
(
2
);
let
asset
=
await
fetchResult
.
getFirstObject
();
for
(
let
i
=
1
;
i
<
count
;
i
++
)
{
asset
=
await
fetchResult
.
getNextObject
();
if
(
i
+
1
===
count
)
{
const
result
=
fetchResult
.
isAfterLast
();
expect
(
result
)
.
assertTrue
();
fetchResult
.
close
();
done
();
}
}
asset
=
await
fetchResult
.
getNextObject
();
const
result
=
fetchResult
.
isAfterLast
();
expect
(
result
)
.
assertTrue
();
done
();
}
catch
(
error
)
{
console
.
info
(
`${testNum} failed; error: ${error}`
);
expect
(
false
)
.
assertTrue
();
...
...
@@ -59,7 +53,12 @@ export default function assetIsAfterLastTest () {
*/
it
(
'isAfterLast_callback_000'
,
0
,
async
function
(
done
)
{
const
testNum
=
'isAfterLast_callback_000'
;
const
fetchOps
=
fetchOption
(
testNum
,
photoKeys
.
PHOTO_TYPE
,
photoType
.
IMAGE
);
const
predicates
=
new
dataSharePredicates
.
DataSharePredicates
();
predicates
.
equalTo
(
photoKeys
.
PHOTO_TYPE
,
photoType
.
IMAGE
)
.
limit
(
2
,
0
);
const
fetchOps
:
photoAccessHelper
.
FetchOptions
=
{
fetchColumns
:
[],
predicates
:
predicates
};
await
isAfterLastCallbackTest
(
done
,
testNum
,
fetchOps
);
});
...
...
@@ -74,7 +73,12 @@ export default function assetIsAfterLastTest () {
*/
it
(
'isAfterLast_callback_001'
,
0
,
async
function
(
done
)
{
const
testNum
=
'isAfterLast_callback_001'
;
const
fetchOps
=
fetchOption
(
testNum
,
photoKeys
.
PHOTO_TYPE
,
photoType
.
VIDEO
);
const
predicates
=
new
dataSharePredicates
.
DataSharePredicates
();
predicates
.
equalTo
(
photoKeys
.
PHOTO_TYPE
,
photoType
.
IMAGE
)
.
limit
(
2
,
0
);
const
fetchOps
:
photoAccessHelper
.
FetchOptions
=
{
fetchColumns
:
[],
predicates
:
predicates
};
await
isAfterLastCallbackTest
(
done
,
testNum
,
fetchOps
);
});
})
...
...
multimedia/photoAccess/photoAccess/entry/src/main/ets/test/getPhotoAccessHelper.ets
浏览文件 @
5e20d578
...
...
@@ -13,16 +13,15 @@
* limitations under the License.
*/
// @ts-nocheck
import photoAccessHelper from '@ohos.file.photoAccessHelper'
import { describe, beforeAll, it, expect } from 'deccjsunit/index'
import { getPermission } from '../../../../../../common'
export default function get
UserFileMgrTest
() {
describe('get
UserFileMgrTest
', function () {
export default function get
PhotoAccessHelper
() {
describe('get
PhotoAccessHelper
', function () {
beforeAll(async function () {
console.info('beforeAll case')
await getPermission(
'ohos.acts.multimedia.photoaccess'
);
await getPermission();
})
/**
...
...
multimedia/photoAccess/photoAccess/entry/src/main/module.json
浏览文件 @
5e20d578
...
...
@@ -8,8 +8,7 @@
"deviceTypes"
:
[
"tablet"
,
"default"
,
"phone"
,
"2in1"
"phone"
],
"deliveryWithInstall"
:
true
,
"installationFree"
:
false
,
...
...
multimedia/photoAccess/photoAccessSystem/Test.json
浏览文件 @
5e20d578
...
...
@@ -6,14 +6,26 @@
"bundle-name"
:
"ohos.acts.multimedia.photoaccess"
,
"module-name"
:
"phone"
,
"shell-timeout"
:
"600000"
,
"testcase-timeout"
:
7
0000
"testcase-timeout"
:
1
0000
},
"kits"
:
[
{
"type"
:
"ShellKit"
,
"pre-push"
:
[],
"run-command"
:
[
"rm -rf /storage/media/100/local/files/*"
,
"rm -rf /storage/media/100/local/files/Audios/*"
,
"rm -rf /storage/media/100/local/files/Audios/.*"
,
"rm -rf /storage/media/100/local/files/Camera/*"
,
"rm -rf /storage/media/100/local/files/Camera/.*"
,
"rm -rf /storage/media/100/local/files/Documents/*"
,
"rm -rf /storage/media/100/local/files/Documents/.*"
,
"rm -rf /storage/media/100/local/files/Download/*"
,
"rm -rf /storage/media/100/local/files/Download/.*"
,
"rm -rf /storage/media/100/local/files/Pictures/*"
,
"rm -rf /storage/media/100/local/files/Pictures/.*"
,
"rm -rf /storage/media/100/local/files/Videos/*"
,
"rm -rf /storage/media/100/local/files/Videos/.*"
,
"sleep 5"
,
"rm -rf /data/app/el2/100/database/com.ohos.medialibrary.medialibrarydata/*"
,
"kill -9 `pidof com.ohos.medialibrary.medialibrarydata`"
,
"scanner"
,
...
...
multimedia/photoAccess/photoAccessSystem/entry/src/main/ets/test/Album/deleteAssets.ets
浏览文件 @
5e20d578
...
...
@@ -13,7 +13,6 @@
* limitations under the License.
*/
// @ts-nocheck
import
photoAccessHelper
from
'@ohos.file.photoAccessHelper'
import
{
describe
,
beforeAll
,
it
,
expect
}
from
'deccjsunit/index'
import
{
...
...
multimedia/photoAccess/photoAccessSystem/entry/src/main/ets/test/Album/recoverAssets.ets
浏览文件 @
5e20d578
...
...
@@ -13,7 +13,6 @@
* limitations under the License.
*/
// @ts-nocheck
import
photoAccessHelper
from
'@ohos.file.photoAccessHelper'
import
{
describe
,
beforeAll
,
it
,
expect
}
from
'deccjsunit/index'
import
{
...
...
multimedia/photoAccess/photoAccessSystem/entry/src/main/ets/test/Album/setCoverUri.ets
浏览文件 @
5e20d578
...
...
@@ -13,7 +13,6 @@
* limitations under the License.
*/
// @ts-nocheck
import photoAccessHelper from '@ohos.file.photoAccessHelper'
import { describe, beforeAll, it, expect } from 'deccjsunit/index'
import {
...
...
multimedia/photoAccess/photoAccessSystem/entry/src/main/ets/test/createAlbum.ets
浏览文件 @
5e20d578
...
...
@@ -13,7 +13,6 @@
* limitations under the License.
*/
// @ts-nocheck
import photoAccessHelper from '@ohos.file.photoAccessHelper'
import { describe, beforeAll, it, expect } from 'deccjsunit/index'
import {
...
...
multimedia/photoAccess/photoAccessSystem/entry/src/main/ets/test/deleteAlbums.ets
浏览文件 @
5e20d578
...
...
@@ -13,7 +13,6 @@
* limitations under the License.
*/
// @ts-nocheck
import photoAccessHelper from '@ohos.file.photoAccessHelper'
import { describe, beforeAll, it, expect } from 'deccjsunit/index'
import {
...
...
@@ -36,7 +35,7 @@ export default function deleteAlbumsTest () {
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_CALLBACK_DELETE_ALBUMS_0000
* @tc.name : deleteAlbums_callback_000
* @tc.desc : delete user
test
* @tc.desc : delete user
albums
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
...
...
@@ -120,7 +119,7 @@ export default function deleteAlbumsTest () {
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_PROMISE_DELETE_ALBUMS_0000
* @tc.name : deleteAlbums_promise_000
* @tc.desc : delete
albums test
* @tc.desc : delete
user albums
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
...
...
multimedia/photoAccess/photoAccessSystem/entry/src/main/ets/test/deleteAssets.ets
浏览文件 @
5e20d578
...
...
@@ -13,7 +13,6 @@
* limitations under the License.
*/
// @ts-nocheck
import
photoAccessHelper
from
'@ohos.file.photoAccessHelper'
import
{
describe
,
it
,
expect
}
from
'deccjsunit/index'
import
{
...
...
multimedia/photoAccess/photoAccessSystem/entry/src/main/ets/test/open.ets
浏览文件 @
5e20d578
...
...
@@ -13,7 +13,6 @@
* limitations under the License.
*/
// @ts-nocheck
import
fileio
from
"@ohos.fileio"
;
import
{
describe
,
beforeAll
,
it
,
expect
}
from
'deccjsunit/index'
import
{
...
...
@@ -46,8 +45,6 @@ export default function openTest() {
let
write
=
await
fileio
.
write
(
fd
,
testNum
);
expect
(
write
)
.
assertEqual
(
testNum
.
length
);
let
newAsset
=
await
getFileAsset
(
testNum
,
fetchOp
);
// expect(newAsset.get(photoKeys.DATE_MODIFIED) != asset.get(photoKeys.DATE_MODIFIED)).assertTrue();
}
}
catch
(
error
)
{
console
.
info
(
`${testNum} error: ${error}`
);
...
...
@@ -75,6 +72,9 @@ export default function openTest() {
let
buf
=
new
ArrayBuffer
(
4096
);
let
res
=
await
fileio
.
read
(
fd
,
buf
);
expect
(
res
.
bytesRead
)
.
assertEqual
(
assetBytes
);
console
.
info
(
`${testNum} read suc`
);
await
fileio
.
write
(
fd
,
testNum
);
expect
(
false
)
.
assertTrue
();
}
}
catch
(
error
)
{
console
.
info
(
`${testNum} error: ${error}`
);
...
...
@@ -100,14 +100,15 @@ export default function openTest() {
}
else
{
let
write
=
await
fileio
.
write
(
fd
,
testNum
);
expect
(
write
)
.
assertEqual
(
testNum
.
length
);
await
asset
.
close
(
fd
);
let
newAsset
=
await
getFileAsset
(
testNum
,
fetchOp
);
// expect(newAsset.get(photoKeys.DATE_MODIFIED) != asset.get(photoKeys.DATE_MODIFIED)).assertTrue();
let
buf
=
new
ArrayBuffer
(
4096
);
await
fileio
.
read
(
fd
,
buf
);
expect
(
false
)
.
assertTrue
();
}
}
catch
(
error
)
{
console
.
info
(
`${testNum} error: ${error}`
);
await
asset
.
close
(
fd
);
}
await
asset
.
close
(
fd
);
done
();
});
}
catch
(
error
)
{
...
...
@@ -118,9 +119,10 @@ export default function openTest() {
};
async
function
rwOpenPromise
(
done
,
testNum
,
fetchOp
,
assetBytes
)
{
const
asset
=
await
getFileAsset
(
testNum
,
fetchOp
)
;
let
asset
;
let
fd
;
try
{
asset
=
await
getFileAsset
(
testNum
,
fetchOp
);
fd
=
await
asset
.
open
(
'rw'
);
console
.
info
(
`${testNum} fd: ${fd}`
);
let
buf
=
new
ArrayBuffer
(
4096
);
...
...
@@ -129,50 +131,71 @@ export default function openTest() {
let
write
=
await
fileio
.
write
(
fd
,
testNum
);
expect
(
write
)
.
assertEqual
(
testNum
.
length
);
let
newAsset
=
await
getFileAsset
(
testNum
,
fetchOp
);
// expect(newAsset.get(photoKeys.DATE_MODIFIED) != asset.get(photoKeys.DATE_MODIFIED)).assertTrue();
await
asset
.
close
(
fd
);
done
();
}
catch
(
error
)
{
console
.
info
(
`${testNum} failed, error: ${error}`
);
await
asset
.
close
(
fd
);
expect
(
false
)
.
assertTrue
();
done
();
}
finally
{
if
(
asset
)
{
await
asset
.
close
(
fd
);
}
}
};
async
function
rOpenPromise
(
done
,
testNum
,
fetchOp
,
assetBytes
)
{
let
asset
;
let
fd
;
try
{
const
asset
=
await
getFileAsset
(
testNum
,
fetchOp
);
const
fd
=
await
asset
.
open
(
'r'
);
asset
=
await
getFileAsset
(
testNum
,
fetchOp
);
fd
=
await
asset
.
open
(
'r'
);
console
.
info
(
`${testNum} fd: ${fd}`
);
let
buf
=
new
ArrayBuffer
(
4096
);
let
res
=
await
fileio
.
read
(
fd
,
buf
);
expect
(
res
.
bytesRead
)
.
assertEqual
(
assetBytes
);
await
asset
.
close
(
fd
);
try
{
await
fileio
.
write
(
fd
,
testNum
);
expect
(
false
)
.
assertTrue
();
}
catch
(
error
)
{
console
.
info
(
`${testNum} error: ${error}`
);
}
done
();
}
catch
(
error
)
{
console
.
info
(
`${testNum} failed, error: ${error}`
);
expect
(
false
)
.
assertTrue
();
done
();
}
finally
{
if
(
asset
)
{
await
asset
.
close
(
fd
);
}
}
};
async
function
wOpenPromise
(
done
,
testNum
,
fetchOp
)
{
let
asset
;
let
fd
;
try
{
const
asset
=
await
getFileAsset
(
testNum
,
fetchOp
);
const
fd
=
await
asset
.
open
(
'w'
);
asset
=
await
getFileAsset
(
testNum
,
fetchOp
);
fd
=
await
asset
.
open
(
'w'
);
let
write
=
await
fileio
.
write
(
fd
,
testNum
);
expect
(
write
)
.
assertEqual
(
testNum
.
length
);
let
newAsset
=
await
getFileAsset
(
testNum
,
fetchOp
);
// expect(newAsset.get(photoKeys.DATE_MODIFIED) != asset.get(photoKeys.DATE_MODIFIED)).assertTrue();
await
asset
.
close
(
fd
);
try
{
let
buf
=
new
ArrayBuffer
(
4096
);
await
fileio
.
read
(
fd
,
buf
);
expect
(
false
)
.
assertTrue
();
}
catch
(
error
)
{
console
.
info
(
`${testNum} error: ${error}`
);
}
done
();
}
catch
(
error
)
{
console
.
info
(
`${testNum} failed, error: ${error}`
);
expect
(
false
)
.
assertTrue
();
done
();
}
finally
{
if
(
asset
)
{
await
asset
.
close
(
fd
);
}
}
};
...
...
multimedia/photoAccess/photoAccessSystem/entry/src/main/ets/test/publicApiTestWithSystemApi.ets
浏览文件 @
5e20d578
...
...
@@ -13,10 +13,9 @@
* limitations under the License.
*/
// @ts-nocheck
import
fileio
from
"@ohos.fileio"
;
import
photoAccessHelper
from
'@ohos.file.photoAccessHelper'
import
{
describe
,
it
,
expect
}
from
'deccjsunit/index'
import
{
describe
,
beforeAll
,
afterEach
,
it
,
expect
}
from
'deccjsunit/index'
import
{
albumType
,
albumSubtype
,
...
...
@@ -25,6 +24,7 @@ import {
getFileAsset
,
photoFetchOption
,
sleep
,
getPermission
,
}
from
'../../../../../../common'
export
default
function
publicApiTestWithSystemApiTest
()
{
...
...
@@ -35,6 +35,15 @@ export default function publicApiTestWithSystemApiTest () {
const
DEFAULT_PHOTO_URI
=
photoAccessHelper
.
DefaultChangeUri
.
DEFAULT_PHOTO_URI
;
const
DEFAULT_ALBUM_URI
=
photoAccessHelper
.
DefaultChangeUri
.
DEFAULT_ALBUM_URI
;
beforeAll
(
async
function
()
{
console
.
info
(
'beforeAll case'
)
await
getPermission
()
})
afterEach
(
async
function
()
{
await
sleep
(
550
)
})
//callback
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_CALLBACK_GET_ASSETS_0100
...
...
@@ -258,27 +267,28 @@ export default function publicApiTestWithSystemApiTest () {
});
/**
* @tc.number : SUB_PHOTOACCESS_
HELPER_OFF
_0000
* @tc.name :
off
_000
* @tc.number : SUB_PHOTOACCESS_
UNREGISTERCHANGE
_0000
* @tc.name :
unRegisterChange
_000
* @tc.desc : off listening create file, type NOTIFY_ADD
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it
(
'
off
_000'
,
0
,
async
function
(
done
)
{
const
testNum
=
'
off
_000'
;
it
(
'
unRegisterChange
_000'
,
0
,
async
function
(
done
)
{
const
testNum
=
'
unRegisterChange
_000'
;
try
{
const
createAsset
=
await
helper
.
createAsset
(
testNum
+
'.jpg'
);
let
fd
=
await
createAsset
.
open
(
'rw'
);
await
createAsset
.
close
(
fd
);
let
count
=
0
;
await
sleep
(
5
0
0
);
await
sleep
(
5
5
0
);
helper
.
registerChange
(
createAsset
.
uri
,
false
,
async
(
changeData
)
=>
{
count
++
;
console
.
info
(
`${testNum} changeData: ${JSON.stringify(changeData)}`
);
});
await
sleep
(
550
);
helper
.
unRegisterChange
(
createAsset
.
uri
);
await
sleep
(
10
0
);
await
sleep
(
55
0
);
fd
=
await
createAsset
.
getReadOnlyFd
();
await
createAsset
.
close
(
fd
);
await
sleep
(
1000
);
...
...
@@ -292,27 +302,27 @@ export default function publicApiTestWithSystemApiTest () {
});
/**
* @tc.number : SUB_PHOTOACCESS_
HELPER_OFF
_0200
* @tc.name :
off
_002
* @tc.number : SUB_PHOTOACCESS_
UNREGISTERCHANGE
_0200
* @tc.name :
unRegisterChange
_002
* @tc.desc : off listening setFavorite(true) file, type NOTIFY_UPDATE
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it
(
'
off_002
'
,
0
,
async
function
(
done
)
{
const
testNum
=
'
off_002
'
;
it
(
'
unRegisterChange_000
'
,
0
,
async
function
(
done
)
{
const
testNum
=
'
unRegisterChange_000
'
;
try
{
const
fetchOps
=
fetchOption
(
testNum
,
photoKeys
.
DISPLAY_NAME
,
'off02.jpg'
);
const
asset
=
await
getFileAsset
(
testNum
,
fetchOps
);
let
count
=
0
;
await
sleep
(
5
0
0
);
await
sleep
(
5
5
0
);
helper
.
registerChange
(
asset
.
uri
,
false
,
async
(
changeData
)
=>
{
count
++
;
console
.
info
(
`${testNum} changeData: ${JSON.stringify(changeData)}`
);
});
await
sleep
(
10
0
);
await
sleep
(
55
0
);
helper
.
unRegisterChange
(
asset
.
uri
);
await
sleep
(
10
0
);
await
sleep
(
55
0
);
await
asset
.
setFavorite
(
true
);
await
sleep
(
1000
);
expect
(
count
)
.
assertEqual
(
0
);
...
...
@@ -325,28 +335,28 @@ export default function publicApiTestWithSystemApiTest () {
});
/**
* @tc.number : SUB_PHOTOACCESS_
HELPER_OFF
_0300
* @tc.name :
off
_003
* @tc.number : SUB_PHOTOACCESS_
UNREGISTERCHANGE
_0300
* @tc.name :
unRegisterChange
_003
* @tc.desc : off listening setFavorite(false) file, type NOTIFY_UPDATE
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it
(
'
off
_003'
,
0
,
async
function
(
done
)
{
const
testNum
=
'
off
_003'
;
it
(
'
unRegisterChange
_003'
,
0
,
async
function
(
done
)
{
const
testNum
=
'
unRegisterChange
_003'
;
try
{
const
fetchOps
=
fetchOption
(
testNum
,
photoKeys
.
DISPLAY_NAME
,
'off03.jpg'
);
const
asset
=
await
getFileAsset
(
testNum
,
fetchOps
);
await
asset
.
setFavorite
(
true
);
let
count
=
0
;
await
sleep
(
5
0
0
);
await
sleep
(
5
5
0
);
helper
.
registerChange
(
asset
.
uri
,
false
,
async
(
changeData
)
=>
{
count
++
;
console
.
info
(
`${testNum} changeData: ${JSON.stringify(changeData)}`
);
});
await
sleep
(
10
0
);
await
sleep
(
55
0
);
helper
.
unRegisterChange
(
asset
.
uri
);
await
sleep
(
10
0
);
await
sleep
(
55
0
);
await
asset
.
setFavorite
(
false
);
await
sleep
(
1000
);
expect
(
count
)
.
assertEqual
(
0
);
...
...
@@ -359,29 +369,29 @@ export default function publicApiTestWithSystemApiTest () {
});
/**
* @tc.number : SUB_PHOTOACCESS_
HELPER_OFF
_0400
* @tc.name :
off
_004
* @tc.number : SUB_PHOTOACCESS_
UNREGISTERCHANGE
_0400
* @tc.name :
unRegisterChange
_004
* @tc.desc : off listening delete file, type NOTIFY_REMOVE
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
*/
it
(
'
off
_004'
,
0
,
async
function
(
done
)
{
const
testNum
=
'
off
_004'
;
it
(
'
unRegisterChange
_004'
,
0
,
async
function
(
done
)
{
const
testNum
=
'
unRegisterChange
_004'
;
try
{
const
fetchOps
=
fetchOption
(
testNum
,
photoKeys
.
DISPLAY_NAME
,
'off04.jpg'
);
const
asset
=
await
getFileAsset
(
testNum
,
fetchOps
);
let
count
=
0
;
await
sleep
(
5
0
0
);
await
sleep
(
5
5
0
);
helper
.
registerChange
(
asset
.
uri
,
false
,
async
(
changeData
)
=>
{
count
++
;
console
.
info
(
`${testNum} asset changeData: ${JSON.stringify(changeData)}`
);
});
await
sleep
(
10
0
);
await
sleep
(
55
0
);
helper
.
unRegisterChange
(
asset
.
uri
);
await
sleep
(
10
0
);
await
sleep
(
55
0
);
await
helper
.
deleteAssets
([
asset
.
uri
]);
await
sleep
(
2
000
);
await
sleep
(
1
000
);
expect
(
count
)
.
assertEqual
(
0
);
done
();
}
catch
(
error
)
{
...
...
@@ -392,15 +402,15 @@ export default function publicApiTestWithSystemApiTest () {
});
/**
* @tc.number : SUB_PHOTOACCESS_
HELPER_OFF
_0500
* @tc.name :
off
_005
* @tc.number : SUB_PHOTOACCESS_
UNREGISTERCHANGE
_0500
* @tc.name :
unRegisterChange
_005
* @tc.desc : off listening recover file, type NOTIFY_ADD
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
*/
it
(
'
off
_005'
,
0
,
async
function
(
done
)
{
const
testNum
=
'
off
_005'
;
it
(
'
unRegisterChange
_005'
,
0
,
async
function
(
done
)
{
const
testNum
=
'
unRegisterChange
_005'
;
try
{
let
testFileName
=
'testCreateFile'
+
Date
.
now
()
+
'.jpg'
;
let
fileAsset
=
await
helper
.
createAsset
(
testFileName
);
...
...
@@ -413,37 +423,37 @@ export default function publicApiTestWithSystemApiTest () {
let
trashFetchResult
=
await
trashAlbum
.
getAssets
(
fetchOps
);
const
trashFileAsset
=
await
trashFetchResult
.
getFirstObject
();
let
count
=
0
;
await
sleep
(
5
0
0
);
await
sleep
(
5
5
0
);
helper
.
registerChange
(
trashFileAsset
.
uri
,
false
,
async
(
changeData
)
=>
{
count
++
;
console
.
info
(
`
off_005
changeData: ${JSON.stringify(changeData)}`
);
console
.
info
(
`
${testNum}
changeData: ${JSON.stringify(changeData)}`
);
expect
(
false
)
.
assertTrue
();
done
();
});
await
sleep
(
10
0
);
await
sleep
(
55
0
);
helper
.
unRegisterChange
(
trashFileAsset
.
uri
);
await
sleep
(
10
0
);
await
sleep
(
55
0
);
await
trashAlbum
.
recoverAssets
([
trashFileAsset
]);
await
sleep
(
2
000
);
await
sleep
(
1
000
);
expect
(
count
)
.
assertEqual
(
0
);
done
();
}
catch
(
error
)
{
console
.
log
(
`
off_005
: tryError: $${error}`
);
console
.
log
(
`
${testNum}
: tryError: $${error}`
);
expect
(
false
)
.
assertTrue
();
done
();
}
});
/**
* @tc.number : SUB_PHOTOACCESS_
HELPER_OFF
_0600
* @tc.name :
off
_006
* @tc.number : SUB_PHOTOACCESS_
UNREGISTERCHANGE
_0600
* @tc.name :
unRegisterChange
_006
* @tc.desc : off listening trash delete file, type NOTIFY_REMOVE
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
*/
it
(
'
off
_006'
,
0
,
async
function
(
done
)
{
const
testNum
=
'
off
_006'
;
it
(
'
unRegisterChange
_006'
,
0
,
async
function
(
done
)
{
const
testNum
=
'
unRegisterChange
_006'
;
try
{
let
testFileName
=
'testCreateFile'
+
Date
.
now
()
+
'.jpg'
;
let
fileAsset
=
await
helper
.
createAsset
(
testFileName
);
...
...
@@ -456,67 +466,68 @@ export default function publicApiTestWithSystemApiTest () {
let
trashFetchResult
=
await
trashAlbum
.
getAssets
(
fetchOps
);
const
trashFileAsset
=
await
trashFetchResult
.
getFirstObject
();
let
count
=
0
;
await
sleep
(
5
0
0
);
await
sleep
(
5
5
0
);
helper
.
registerChange
(
trashAlbum
.
albumUri
,
false
,
async
(
changeData
)
=>
{
count
++
;
console
.
info
(
`
off_006
changeData: ${JSON.stringify(changeData)}`
);
console
.
info
(
`
${testNum}
changeData: ${JSON.stringify(changeData)}`
);
});
await
sleep
(
10
0
);
await
sleep
(
55
0
);
helper
.
unRegisterChange
(
trashAlbum
.
albumUri
);
await
sleep
(
10
0
);
await
sleep
(
55
0
);
await
trashAlbum
.
deleteAssets
([
trashFileAsset
]);
await
sleep
(
1000
);
expect
(
count
)
.
assertEqual
(
0
);
done
();
}
catch
(
error
)
{
console
.
log
(
`
off_006
: tryError: $${error}`
);
console
.
log
(
`
${testNum}
: tryError: $${error}`
);
expect
(
false
)
.
assertTrue
();
done
();
}
});
/**
* @tc.number : SUB_PHOTOACCESS_
HELPER_OFF
_0900
* @tc.name :
off
_009
* @tc.number : SUB_PHOTOACCESS_
UNREGISTERCHANGE
_0900
* @tc.name :
unRegisterChange
_009
* @tc.desc : off listening delete album, type NOTIFY_REMOVE
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it
(
'off_009'
,
0
,
async
function
(
done
)
{
it
(
'unRegisterChange_009'
,
0
,
async
function
(
done
)
{
const
testNum
=
'unRegisterChange_009'
;
try
{
let
count
=
0
;
let
albumName
=
'testAlbum'
+
Date
.
now
();
let
album
=
await
helper
.
createAlbum
(
albumName
);
await
sleep
(
5
0
0
);
await
sleep
(
5
5
0
);
helper
.
registerChange
(
DEFAULT_ALBUM_URI
,
true
,
async
(
changeData
)
=>
{
count
++
;
console
.
info
(
`
off_009
changeData: ${JSON.stringify(changeData)}`
);
console
.
info
(
`
${testNum}
changeData: ${JSON.stringify(changeData)}`
);
});
await
sleep
(
10
0
);
await
sleep
(
55
0
);
helper
.
unRegisterChange
(
DEFAULT_ALBUM_URI
);
await
sleep
(
10
0
);
await
sleep
(
55
0
);
await
helper
.
deleteAlbums
([
album
]);
await
sleep
(
1000
);
expect
(
count
)
.
assertEqual
(
0
);
done
();
}
catch
(
error
)
{
console
.
log
(
`
off_009
: tryError: $${error}`
);
console
.
log
(
`
${testNum}
: tryError: $${error}`
);
expect
(
false
)
.
assertTrue
();
done
();
}
});
/**
* @tc.number : SUB_PHOTOACCESS_
HELPER_OFF
_1300
* @tc.name :
off
_013
* @tc.number : SUB_PHOTOACCESS_
UNREGISTERCHANGE
_1300
* @tc.name :
unRegisterChange
_013
* @tc.desc : off listening DEFAULT_ALBUM_URI
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 3
*/
it
(
'
off
_013'
,
0
,
async
function
(
done
)
{
const
testNum
=
'
off
_013'
;
it
(
'
unRegisterChange
_013'
,
0
,
async
function
(
done
)
{
const
testNum
=
'
unRegisterChange
_013'
;
try
{
const
fetchOps
=
fetchOption
(
testNum
,
photoKeys
.
DISPLAY_NAME
,
'off13.jpg'
);
const
asset
=
await
getFileAsset
(
testNum
,
fetchOps
);
...
...
@@ -525,30 +536,30 @@ export default function publicApiTestWithSystemApiTest () {
let
fd
=
await
fileAsset
.
open
(
'rw'
);
await
fileAsset
.
close
(
fd
);
await
helper
.
deleteAssets
([
fileAsset
.
uri
]);
await
sleep
(
5
0
0
);
await
sleep
(
5
5
0
);
let
listenCount
=
0
;
helper
.
registerChange
(
DEFAULT_ALBUM_URI
,
true
,
async
(
changeData
)
=>
{
listenCount
++
;
console
.
info
(
`${testNum} changeData: ${JSON.stringify(changeData)}`
);
});
await
sleep
(
10
0
);
await
sleep
(
55
0
);
helper
.
unRegisterChange
(
DEFAULT_ALBUM_URI
);
await
sleep
(
10
0
);
await
sleep
(
55
0
);
// 1
let
albumName
=
'testAlbum'
+
Date
.
now
();
let
album
=
await
helper
.
createAlbum
(
albumName
);
// 2
await
sleep
(
5
0
0
);
await
sleep
(
5
5
0
);
album
.
albumName
=
'hello'
;
await
album
.
commitModify
();
// 3
await
sleep
(
5
0
0
);
await
sleep
(
5
5
0
);
await
album
.
addAssets
([
asset
]);
// 5
await
sleep
(
5
0
0
);
await
sleep
(
5
5
0
);
await
album
.
removeAssets
([
asset
]);
// 6
await
sleep
(
5
0
0
);
await
sleep
(
5
5
0
);
await
helper
.
deleteAlbums
([
album
]);
// 7
let
trashAlbumList
=
await
helper
.
getAlbums
(
albumType
.
SYSTEM
,
albumSubtype
.
TRASH
);
...
...
@@ -568,45 +579,46 @@ export default function publicApiTestWithSystemApiTest () {
});
/**
* @tc.number : SUB_PHOTOACCESS_
HELPER_OFF
_1400
* @tc.name :
off
_014
* @tc.number : SUB_PHOTOACCESS_
UNREGISTERCHANGE
_1400
* @tc.name :
unRegisterChange
_014
* @tc.desc : off listening DEFAULT_PHOTO_URI
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 3
*/
it
(
'
off
_014'
,
0
,
async
function
(
done
)
{
const
testNum
=
'
off
_014'
;
it
(
'
unRegisterChange
_014'
,
0
,
async
function
(
done
)
{
const
testNum
=
'
unRegisterChange
_014'
;
try
{
let
listenCount
=
0
;
let
fetchOps
=
photoFetchOption
(
testNum
,
photoKeys
.
DISPLAY_NAME
,
'off14.jpg'
);
const
asset
=
await
getFileAsset
(
testNum
,
fetchOps
);
await
sleep
(
550
);
helper
.
registerChange
(
DEFAULT_PHOTO_URI
,
true
,
async
(
changeData
)
=>
{
listenCount
++
;
console
.
info
(
`${testNum} changeData: ${JSON.stringify(changeData)}`
);
});
await
sleep
(
10
0
);
await
sleep
(
55
0
);
helper
.
unRegisterChange
(
DEFAULT_PHOTO_URI
);
await
sleep
(
10
0
);
await
sleep
(
55
0
);
// 1
let
fd
=
await
asset
.
open
(
'rw'
);
await
asset
.
close
(
fd
);
// 2
await
sleep
(
5
0
0
);
await
sleep
(
5
5
0
);
const
newTitle
=
testNum
+
asset
.
get
(
photoKeys
.
TITLE
);
asset
.
set
(
photoKeys
.
TITLE
,
newTitle
);
await
asset
.
commitModify
();
// 3
await
sleep
(
5
0
0
);
await
sleep
(
5
5
0
);
await
asset
.
setFavorite
(
true
);
// 4
await
sleep
(
5
0
0
);
await
sleep
(
5
5
0
);
await
asset
.
setFavorite
(
false
);
// 5
await
sleep
(
5
0
0
);
await
sleep
(
5
5
0
);
await
helper
.
deleteAssets
([
asset
.
uri
]);
// 6
await
sleep
(
5
0
0
);
await
sleep
(
5
5
0
);
let
trashAlbumList
=
await
helper
.
getAlbums
(
albumType
.
SYSTEM
,
albumSubtype
.
TRASH
);
let
trashAlbum
=
await
trashAlbumList
.
getFirstObject
();
const
fetchOps1
=
fetchOption
(
testNum
,
photoKeys
.
DISPLAY_NAME
,
'off14.jpg'
)
...
...
@@ -624,118 +636,131 @@ export default function publicApiTestWithSystemApiTest () {
});
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_
ON
_CALLBACK_0000
* @tc.name :
on
_callback_000
* @tc.number : SUB_PHOTOACCESS_HELPER_
REGISTERCHANGE
_CALLBACK_0000
* @tc.name :
registerChange
_callback_000
* @tc.desc : off listening create file, type NOTIFY_ADD
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it
(
'on_callback_000'
,
0
,
async
function
(
done
)
{
const
testNum
=
'on_callback_000'
;
it
(
'registerChange_callback_000'
,
0
,
async
function
(
done
)
{
const
testNum
=
'registerChange_callback_000'
;
let
uri
;
try
{
const
createAsset
=
await
helper
.
createAsset
(
testNum
+
'.jpg'
);
let
fd
=
await
createAsset
.
open
(
'rw'
);
await
createAsset
.
close
(
fd
);
uri
=
createAsset
.
uri
;
let
count
=
0
;
await
sleep
(
5
0
0
);
helper
.
registerChange
(
createAsset
.
uri
,
false
,
async
(
changeData
)
=>
{
await
sleep
(
5
5
0
);
helper
.
registerChange
(
uri
,
false
,
async
(
changeData
)
=>
{
count
++
;
console
.
info
(
`${testNum} changeData: ${JSON.stringify(changeData)}`
);
expect
(
changeData
.
type
)
.
assertEqual
(
NOTIFY_ADD
);
expect
(
changeData
.
uris
[
0
])
.
assertEqual
(
createAsset
.
uri
);
expect
(
changeData
.
uris
[
0
])
.
assertEqual
(
uri
);
});
await
sleep
(
100
);
fd
=
await
createAsset
.
getReadOnlyFd
();
await
sleep
(
550
);
let
fd
=
await
createAsset
.
open
(
'rw'
);
await
fileio
.
write
(
fd
,
testNum
);
await
createAsset
.
close
(
fd
);
await
sleep
(
1000
);
helper
.
unRegisterChange
(
createAsset
.
uri
);
expect
(
count
)
.
assertEqual
(
0
);
expect
(
count
)
.
assertEqual
(
1
);
done
();
}
catch
(
error
)
{
console
.
log
(
`${testNum}: tryError: ${error}`
);
expect
(
false
)
.
assertTrue
();
done
();
}
finally
{
helper
.
unRegisterChange
(
uri
);
}
});
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_
ON
_CALLBACK_0200
* @tc.name :
on
_callback_002
* @tc.number : SUB_PHOTOACCESS_HELPER_
REGISTERCHANGE
_CALLBACK_0200
* @tc.name :
registerChange
_callback_002
* @tc.desc : listening setFavorite(true) file, type NOTIFY_UPDATE
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it
(
'on_callback_002'
,
0
,
async
function
(
done
)
{
const
testNum
=
'on_callback_002'
;
it
(
'registerChange_callback_002'
,
0
,
async
function
(
done
)
{
const
testNum
=
'registerChange_callback_002'
;
let
uri
;
try
{
let
fetchOps
=
fetchOption
(
testNum
,
photoKeys
.
DISPLAY_NAME
,
'on02.jpg'
);
const
asset
=
await
getFileAsset
(
testNum
,
fetchOps
);
uri
=
asset
.
uri
;
let
count
=
0
;
await
sleep
(
5
0
0
);
helper
.
registerChange
(
asset
.
uri
,
false
,
async
(
changeData
)
=>
{
await
sleep
(
5
5
0
);
helper
.
registerChange
(
uri
,
false
,
async
(
changeData
)
=>
{
count
++
;
console
.
info
(
`${testNum} changeData: ${JSON.stringify(changeData)}`
);
expect
(
changeData
.
type
)
.
assertEqual
(
NOTIFY_UPDATE
);
expect
(
changeData
.
uris
[
0
])
.
assertEqual
(
asset
.
uri
);
expect
(
changeData
.
uris
[
0
])
.
assertEqual
(
uri
);
});
await
sleep
(
550
);
await
asset
.
setFavorite
(
true
);
await
sleep
(
1000
);
helper
.
unRegisterChange
(
asset
.
uri
);
expect
(
count
)
.
assertEqual
(
1
);
done
();
}
catch
(
error
)
{
console
.
log
(
`${testNum}: tryError: ${error}`
);
expect
(
false
)
.
assertTrue
();
done
();
}
finally
{
helper
.
unRegisterChange
(
uri
);
}
});
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_
ON
_CALLBACK_0300
* @tc.name :
on
_callback_003
* @tc.number : SUB_PHOTOACCESS_HELPER_
REGISTERCHANGE
_CALLBACK_0300
* @tc.name :
registerChange
_callback_003
* @tc.desc : listening setFavorite(false) file, type NOTIFY_UPDATE
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it
(
'on_callback_003'
,
0
,
async
function
(
done
)
{
const
testNum
=
'on_callback_003'
;
it
(
'registerChange_callback_003'
,
0
,
async
function
(
done
)
{
const
testNum
=
'registerChange_callback_003'
;
let
uri
;
try
{
let
fetchOps
=
fetchOption
(
testNum
,
photoKeys
.
DISPLAY_NAME
,
'on03.jpg'
);
const
asset
=
await
getFileAsset
(
testNum
,
fetchOps
);
uri
=
asset
.
uri
;
await
asset
.
setFavorite
(
true
);
let
count
=
0
;
await
sleep
(
5
0
0
);
helper
.
registerChange
(
asset
.
uri
,
false
,
async
(
changeData
)
=>
{
await
sleep
(
5
5
0
);
helper
.
registerChange
(
uri
,
false
,
async
(
changeData
)
=>
{
count
++
;
console
.
info
(
`${testNum} changeData: ${JSON.stringify(changeData)}`
);
expect
(
changeData
.
type
)
.
assertEqual
(
NOTIFY_UPDATE
);
expect
(
changeData
.
uris
[
0
])
.
assertEqual
(
asset
.
uri
);
expect
(
changeData
.
uris
[
0
])
.
assertEqual
(
uri
);
});
await
sleep
(
550
);
await
asset
.
setFavorite
(
false
);
await
sleep
(
1000
);
helper
.
unRegisterChange
(
asset
.
uri
);
expect
(
count
)
.
assertEqual
(
1
);
done
();
}
catch
(
error
)
{
console
.
log
(
`${testNum}: tryError: ${error}`
);
expect
(
false
)
.
assertTrue
();
done
();
}
finally
{
helper
.
unRegisterChange
(
uri
);
}
});
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_
ON
_CALLBACK_0500
* @tc.name :
on
_callback_005
* @tc.number : SUB_PHOTOACCESS_HELPER_
REGISTERCHANGE
_CALLBACK_0500
* @tc.name :
registerChange
_callback_005
* @tc.desc : listening recover file, type NOTIFY_ADD
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
*/
it
(
'on_callback_005'
,
0
,
async
function
(
done
)
{
const
testNum
=
'on_callback_005'
;
it
(
'registerChange_callback_005'
,
0
,
async
function
(
done
)
{
const
testNum
=
'registerChange_callback_005'
;
let
uri
;
try
{
let
testFileName
=
'testCreateFile'
+
Date
.
now
()
+
'.jpg'
;
let
fileAsset
=
await
helper
.
createAsset
(
testFileName
);
...
...
@@ -747,120 +772,268 @@ export default function publicApiTestWithSystemApiTest () {
const
fetchOps
=
fetchOption
(
testNum
,
photoKeys
.
DISPLAY_NAME
,
testFileName
);
let
trashFetchResult
=
await
trashAlbum
.
getAssets
(
fetchOps
);
const
trashFileAsset
=
await
trashFetchResult
.
getFirstObject
();
uri
=
trashFileAsset
.
uri
;
let
count
=
0
;
await
sleep
(
500
);
helper
.
registerChange
(
trashFileAsset
.
uri
,
false
,
async
(
changeData
)
=>
{
await
sleep
(
550
);
console
.
log
(
`${testNum}: uri: ${uri}`
);
helper
.
registerChange
(
uri
,
false
,
async
(
changeData
)
=>
{
count
++
;
console
.
info
(
`
on_callback_005
changeData: ${JSON.stringify(changeData)}`
);
console
.
info
(
`
${testNum}
changeData: ${JSON.stringify(changeData)}`
);
expect
(
changeData
.
type
)
.
assertEqual
(
NOTIFY_ADD
);
expect
(
changeData
.
uris
[
0
])
.
assertEqual
(
trashFileAsset
.
uri
);
expect
(
changeData
.
uris
[
0
])
.
assertEqual
(
uri
);
});
await
sleep
(
550
);
await
trashAlbum
.
recoverAssets
([
trashFileAsset
]);
await
sleep
(
2
000
);
helper
.
unRegisterChange
(
trashFileAsset
.
uri
);
await
sleep
(
1
000
);
expect
(
count
)
.
assertEqual
(
1
);
done
();
}
catch
(
error
)
{
console
.
log
(
`
on_callback_005
: tryError: $${error}`
);
console
.
log
(
`
${testNum}
: tryError: $${error}`
);
expect
(
false
)
.
assertTrue
();
done
();
}
finally
{
helper
.
unRegisterChange
(
uri
);
}
});
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_
ON
_CALLBACK_0600
* @tc.name :
on
_callback_006
* @tc.number : SUB_PHOTOACCESS_HELPER_
REGISTERCHANGE
_CALLBACK_0600
* @tc.name :
registerChange
_callback_006
* @tc.desc : listening trash delete file, type NOTIFY_REMOVE
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
*/
it
(
'on_callback_006'
,
0
,
async
function
(
done
)
{
const
testNum
=
'on_callback_006'
;
it
(
'registerChange_callback_006'
,
0
,
async
function
(
done
)
{
const
testNum
=
'registerChange_callback_006'
;
let
uri
;
try
{
let
testFileName
=
'testCreateFile'
+
Date
.
now
()
+
'.jpg'
;
let
fileAsset
=
await
helper
.
createAsset
(
testFileName
);
let
fd
=
await
fileAsset
.
open
(
'rw'
);
await
fileAsset
.
close
(
fd
);
console
.
info
(
`${testNum} fileAsset.uri: ${fileAsset.uri}`
);
await
helper
.
deleteAssets
([
fileAsset
.
uri
]);
let
trashAlbumList
=
await
helper
.
getAlbums
(
albumType
.
SYSTEM
,
albumSubtype
.
TRASH
);
let
trashAlbum
=
await
trashAlbumList
.
getFirstObject
();
uri
=
trashAlbum
.
albumUri
;
const
fetchOps
=
fetchOption
(
testNum
,
photoKeys
.
DISPLAY_NAME
,
testFileName
);
let
trashFetchResult
=
await
trashAlbum
.
getAssets
(
fetchOps
);
const
trashFileAsset
=
await
trashFetchResult
.
getFirstObject
();
console
.
info
(
`${testNum} trashFileAsset.uri: ${trashFileAsset.uri}`
);
let
count
=
0
;
await
sleep
(
5
0
0
);
helper
.
registerChange
(
trashAlbum
.
albumU
ri
,
false
,
async
(
changeData
)
=>
{
await
sleep
(
5
5
0
);
helper
.
registerChange
(
u
ri
,
false
,
async
(
changeData
)
=>
{
count
++
;
console
.
info
(
`
on_callback_006
changeData: ${JSON.stringify(changeData)}`
);
console
.
info
(
`
${testNum}
changeData: ${JSON.stringify(changeData)}`
);
expect
(
changeData
.
type
)
.
assertEqual
(
NOTIFY_ALBUM_REMOVE_ASSET
);
expect
(
changeData
.
uris
[
0
])
.
assertEqual
(
uri
);
expect
(
changeData
.
extraUris
[
0
])
.
assertEqual
(
trashFileAsset
.
uri
);
});
await
sleep
(
550
);
await
trashAlbum
.
deleteAssets
([
trashFileAsset
]);
await
sleep
(
1000
);
helper
.
unRegisterChange
(
trashAlbum
.
albumUri
);
expect
(
count
)
.
assertEqual
(
1
);
done
();
}
catch
(
error
)
{
console
.
log
(
`
on_callback_006
: tryError: $${error}`
);
console
.
log
(
`
${testNum}
: tryError: $${error}`
);
expect
(
false
)
.
assertTrue
();
done
();
}
finally
{
helper
.
unRegisterChange
(
uri
);
}
});
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_
ON
_CALLBACK_0900
* @tc.name :
on
_callback_009
* @tc.number : SUB_PHOTOACCESS_HELPER_
REGISTERCHANGE
_CALLBACK_0900
* @tc.name :
registerChange
_callback_009
* @tc.desc : listening delete album, type NOTIFY_REMOVE
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it
(
'on_callback_009'
,
0
,
async
function
(
done
)
{
it
(
'registerChange_callback_009'
,
0
,
async
function
(
done
)
{
const
testNum
=
'registerChange_callback_009'
;
let
uri
;
try
{
let
albumUri
=
''
;
let
listenCount
=
0
;
let
albumName
=
'testAlbum'
+
Date
.
now
();
let
album
=
await
helper
.
createAlbum
(
albumName
);
albumUri
=
album
.
albumUri
;
await
sleep
(
500
);
helper
.
registerChange
(
DEFAULT_ALBUM_URI
,
true
,
async
(
changeData
)
=>
{
await
sleep
(
550
);
uri
=
DEFAULT_ALBUM_URI
;
helper
.
registerChange
(
uri
,
true
,
async
(
changeData
)
=>
{
listenCount
++
;
if
(
listenCount
<
2
)
{
console
.
info
(
`on_callback_009 changeData: ${JSON.stringify(changeData)}`
);
expect
(
changeData
.
type
)
.
assertEqual
(
NOTIFY_REMOVE
);
expect
(
changeData
.
uris
[
0
])
.
assertEqual
(
albumUri
);
done
();
}
console
.
info
(
`${testNum} changeData: ${JSON.stringify(changeData)}`
);
expect
(
changeData
.
type
)
.
assertEqual
(
NOTIFY_REMOVE
);
expect
(
changeData
.
uris
[
0
])
.
assertEqual
(
albumUri
);
done
();
});
await
sleep
(
550
);
await
helper
.
deleteAlbums
([
album
]);
await
sleep
(
1000
);
expect
(
listenCount
)
.
assertEqual
(
1
);
helper
.
unRegisterChange
(
DEFAULT_ALBUM_URI
);
done
();
}
catch
(
error
)
{
console
.
log
(
`on_callback_009: tryError: $${error}`
);
console
.
log
(
`${testNum}: tryError: $${error}`
);
expect
(
false
)
.
assertTrue
();
done
();
}
finally
{
helper
.
unRegisterChange
(
uri
);
}
});
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_ON_CALLBACK_1300
* @tc.name : registerChange_callback_013
* @tc.desc : listening DEFAULT_ALBUM_URI
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 3
*/
it
(
'registerChange_callback_013'
,
0
,
async
function
(
done
)
{
const
testNum
=
'registerChange_callback_013'
;
let
uri
;
try
{
let
albumUri
=
''
;
let
trashAlbumUri
=
''
;
let
trashFileAssetUri
=
''
;
let
listenCount
=
0
;
const
fetchOps
=
fetchOption
(
testNum
,
photoKeys
.
DISPLAY_NAME
,
'on13.jpg'
);
const
asset
=
await
getFileAsset
(
testNum
,
fetchOps
);
let
testFileName
=
'testCreateFile'
+
Date
.
now
()
+
'.jpg'
;
let
fileAsset
=
await
helper
.
createAsset
(
testFileName
);
let
fd
=
await
fileAsset
.
open
(
'rw'
);
await
fileAsset
.
close
(
fd
);
await
helper
.
deleteAssets
([
fileAsset
.
uri
]);
await
sleep
(
550
);
uri
=
DEFAULT_ALBUM_URI
;
helper
.
registerChange
(
uri
,
true
,
async
(
changeData
)
=>
{
listenCount
++
;
switch
(
listenCount
)
{
case
1
:
console
.
info
(
`${testNum} 1 changeData: ${JSON.stringify(changeData)}`
);
expect
(
changeData
.
type
)
.
assertEqual
(
NOTIFY_ADD
);
expect
(
changeData
.
uris
[
0
])
.
assertEqual
(
albumUri
);
break
;
case
2
:
console
.
info
(
`${testNum} 2 changeData: ${JSON.stringify(changeData)}`
);
expect
(
changeData
.
type
)
.
assertEqual
(
NOTIFY_UPDATE
);
expect
(
changeData
.
uris
[
0
])
.
assertEqual
(
albumUri
);
break
;
case
3
:
console
.
info
(
`${testNum} 3 changeData: ${JSON.stringify(changeData)}`
);
expect
(
changeData
.
type
)
.
assertEqual
(
NOTIFY_ALBUM_ADD_ASSET
);
expect
(
changeData
.
uris
[
0
])
.
assertEqual
(
albumUri
);
break
;
case
4
:
console
.
info
(
`${testNum} 4 changeData: ${JSON.stringify(changeData)}`
);
expect
(
changeData
.
type
)
.
assertEqual
(
NOTIFY_UPDATE
);
expect
(
changeData
.
uris
[
0
])
.
assertEqual
(
albumUri
);
break
;
case
5
:
console
.
info
(
`${testNum} 5 changeData: ${JSON.stringify(changeData)}`
);
expect
(
changeData
.
type
)
.
assertEqual
(
NOTIFY_ALBUM_REMOVE_ASSET
);
expect
(
changeData
.
uris
[
0
])
.
assertEqual
(
albumUri
);
break
;
case
6
:
console
.
info
(
`${testNum} 6 changeData: ${JSON.stringify(changeData)}`
);
expect
(
changeData
.
type
)
.
assertEqual
(
NOTIFY_REMOVE
);
expect
(
changeData
.
uris
[
0
])
.
assertEqual
(
albumUri
);
break
;
case
7
:
console
.
info
(
`${testNum} 7 changeData: ${JSON.stringify(changeData)}`
);
expect
(
changeData
.
uris
[
0
])
.
assertEqual
(
trashAlbumUri
);
expect
(
changeData
.
type
)
.
assertEqual
(
NOTIFY_ALBUM_REMOVE_ASSET
);
expect
(
changeData
.
extraUris
[
0
])
.
assertEqual
(
trashFileAssetUri
);
break
;
default
:
break
;
}
});
await
sleep
(
550
);
let
testCount
=
0
;
// 1
testCount
++
;
console
.
info
(
`${testNum} testCount: ${testCount}`
);
let
albumName
=
testNum
+
Date
.
now
();
let
album
=
await
helper
.
createAlbum
(
albumName
);
albumUri
=
album
.
albumUri
;
// 2
await
sleep
(
550
);
testCount
++
;
console
.
info
(
`${testNum} testCount: ${testCount}`
);
album
.
albumName
=
Date
.
now
()
+
album
.
albumName
;
await
album
.
commitModify
();
// 3
await
sleep
(
550
);
testCount
++
;
console
.
info
(
`${testNum} testCount: ${testCount}`
);
await
album
.
addAssets
([
asset
]);
// 4
await
sleep
(
550
);
testCount
++
;
console
.
info
(
`${testNum} testCount: ${testCount}`
);
album
.
albumName
=
testNum
+
album
.
albumName
;
await
album
.
commitModify
();
// 5
await
sleep
(
550
);
testCount
++
;
console
.
info
(
`${testNum} testCount: ${testCount}`
);
await
album
.
removeAssets
([
asset
]);
// 6
await
sleep
(
550
);
testCount
++
;
console
.
info
(
`${testNum} testCount: ${testCount}`
);
await
helper
.
deleteAlbums
([
album
]);
// 7
await
sleep
(
550
);
testCount
++
;
console
.
info
(
`${testNum} testCount: ${testCount}`
);
let
trashAlbumList
=
await
helper
.
getAlbums
(
albumType
.
SYSTEM
,
albumSubtype
.
TRASH
);
let
trashAlbum
=
await
trashAlbumList
.
getFirstObject
();
trashAlbumUri
=
trashAlbum
.
albumUri
;
const
fetchOps1
=
fetchOption
(
testNum
,
photoKeys
.
DISPLAY_NAME
,
testFileName
);
let
trashFetchResult
=
await
trashAlbum
.
getAssets
(
fetchOps1
);
let
trashFileAsset
=
await
trashFetchResult
.
getFirstObject
();
trashFileAssetUri
=
trashFileAsset
.
uri
;
console
.
log
(
`${testNum}: trashFileAssetUri: ${trashFileAssetUri}`
);
await
trashAlbum
.
deleteAssets
([
trashFileAsset
]);
await
sleep
(
1000
);
expect
(
listenCount
)
.
assertEqual
(
testCount
);
done
();
}
catch
(
error
)
{
console
.
log
(
`${testNum}: tryError: ${error}`
);
expect
(
false
)
.
assertTrue
();
done
();
}
finally
{
helper
.
unRegisterChange
(
uri
);
}
});
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_
ON
_CALLBACK_1400
* @tc.name :
on
_callback_014
* @tc.number : SUB_PHOTOACCESS_HELPER_
REGISTERCHANGE
_CALLBACK_1400
* @tc.name :
registerChange
_callback_014
* @tc.desc : listening DEFAULT_PHOTO_URI
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 3
*/
it
(
'on_callback_014'
,
0
,
async
function
(
done
)
{
const
testNum
=
'on_callback_014'
;
it
(
'registerChange_callback_014'
,
0
,
async
function
(
done
)
{
const
testNum
=
'registerChange_callback_014'
;
let
uri
;
try
{
let
listenCount
=
0
;
const
fetchOps
=
photoFetchOption
(
testNum
,
photoKeys
.
DISPLAY_NAME
,
'on14.jpg'
);
const
asset
=
await
getFileAsset
(
testNum
,
fetchOps
);
let
photoAssetUri
=
asset
.
uri
;
helper
.
registerChange
(
DEFAULT_PHOTO_URI
,
true
,
async
(
changeData
)
=>
{
await
sleep
(
550
);
uri
=
DEFAULT_PHOTO_URI
;
helper
.
registerChange
(
uri
,
true
,
async
(
changeData
)
=>
{
listenCount
++
;
switch
(
listenCount
)
{
case
1
:
...
...
@@ -883,78 +1056,142 @@ export default function publicApiTestWithSystemApiTest () {
}
});
// 1
await
sleep
(
5
0
0
);
await
sleep
(
5
5
0
);
const
newTitle
=
testNum
+
asset
.
get
(
photoKeys
.
TITLE
);
asset
.
set
(
photoKeys
.
TITLE
,
newTitle
);
await
asset
.
commitModify
();
// 2
await
sleep
(
5
0
0
);
await
sleep
(
5
5
0
);
await
asset
.
setFavorite
(
true
);
// 3
await
sleep
(
5
0
0
);
await
sleep
(
5
5
0
);
await
asset
.
setFavorite
(
false
);
await
sleep
(
1000
);
helper
.
unRegisterChange
(
DEFAULT_PHOTO_URI
);
expect
(
listenCount
)
.
assertEqual
(
3
);
done
();
}
catch
(
error
)
{
console
.
log
(
`${testNum}: tryError: ${error}`
);
expect
(
false
)
.
assertTrue
();
done
();
}
finally
{
helper
.
unRegisterChange
(
uri
);
}
});
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_ON_CALLBACK_1600
* @tc.name : on_callback_016
* @tc.number : SUB_PHOTOACCESS_HELPER_REGISTERCHANGE_CALLBACK_1500
* @tc.name : registerChange_callback_015
* @tc.desc : listening 32
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 3
*/
it
(
'registerChange_callback_015'
,
0
,
async
function
(
done
)
{
const
testNum
=
'registerChange_callback_015'
;
let
uri
;
try
{
let
listenCount
=
0
;
let
fetchOps
=
photoFetchOption
(
testNum
,
photoKeys
.
DISPLAY_NAME
,
'on15.jpg'
);
let
asset
=
await
getFileAsset
(
testNum
,
fetchOps
);
await
sleep
(
550
);
//notify times lessthan 32 in 500ms
let
i
=
0
;
uri
=
DEFAULT_PHOTO_URI
;
helper
.
registerChange
(
DEFAULT_PHOTO_URI
,
true
,
async
(
changeData
)
=>
{
listenCount
++
;
console
.
info
(
`${testNum} i: ${i}, listenCount: ${listenCount}`
);
if
(
listenCount
>
1
)
{
if
(
i
<=
32
)
{
expect
(
listenCount
-
1
)
.
assertEqual
(
1
);
}
else
{
expect
(
listenCount
-
1
)
.
assertEqual
(
Math
.
ceil
(
i
/
32
))
}
console
.
info
(
`${testNum} changeData: ${JSON.stringify(changeData)}`
);
expect
(
changeData
.
type
)
.
assertEqual
(
NOTIFY_UPDATE
);
expect
(
changeData
.
uris
[
0
])
.
assertEqual
(
asset
.
uri
);
listenCount
--
;
}
});
await
sleep
(
550
);
const
endTime
=
Date
.
now
()
+
500
;
for
(
let
now
=
Date
.
now
();
now
<
endTime
;
now
=
Date
.
now
())
{
i
++
;
const
newTitle
=
asset
.
get
(
photoKeys
.
TITLE
)
.
toString
()
+
i
;
asset
.
set
(
photoKeys
.
TITLE
,
newTitle
);
await
asset
.
commitModify
();
}
await
sleep
(
1000
);
done
();
}
catch
(
error
)
{
console
.
log
(
`${testNum}: tryError: ${error}`
);
expect
(
false
)
.
assertTrue
();
done
();
}
finally
{
helper
.
unRegisterChange
(
uri
);
}
});
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_REGISTERCHANGE_CALLBACK_1600
* @tc.name : registerChange_callback_016
* @tc.desc : listening 500ms
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 3
*/
it
(
'on_callback_016'
,
0
,
async
function
(
done
)
{
const
testNum
=
'on_callback_016'
;
it
(
'registerChange_callback_016'
,
0
,
async
function
(
done
)
{
const
testNum
=
'registerChange_callback_016'
;
let
uri
;
try
{
const
fetchOps
=
fetchOption
(
testNum
,
photoKeys
.
DISPLAY_NAME
,
'on16.jpg'
);
const
asset
=
await
getFileAsset
(
testNum
,
fetchOps
);
uri
=
asset
.
uri
;
let
fd
=
await
asset
.
open
(
'rw'
);
await
asset
.
close
(
fd
);
let
listenCount
=
0
;
await
sleep
(
5
0
0
);
helper
.
registerChange
(
asset
.
uri
,
false
,
async
(
changeData
)
=>
{
await
sleep
(
5
5
0
);
helper
.
registerChange
(
uri
,
false
,
async
(
changeData
)
=>
{
listenCount
++
;
console
.
info
(
`${testNum} changeData: ${JSON.stringify(changeData)}`
);
expect
(
changeData
.
type
)
.
assertEqual
(
NOTIFY_UPDATE
);
expect
(
changeData
.
uris
[
0
])
.
assertEqual
(
asset
.
uri
);
expect
(
changeData
.
uris
[
0
])
.
assertEqual
(
uri
);
});
await
sleep
(
550
);
for
(
let
i
=
0
;
i
<
10
;
i
++
)
{
if
(
i
%
2
==
0
)
{
await
asset
.
setFavorite
(
true
);
}
else
{
await
asset
.
setFavorite
(
false
);
}
await
sleep
(
5
0
0
);
await
sleep
(
5
5
0
);
}
await
sleep
(
2
000
);
helper
.
unRegisterChange
(
asset
.
uri
);
await
sleep
(
1
000
);
expect
(
listenCount
)
.
assertEqual
(
10
);
done
();
}
catch
(
error
)
{
console
.
log
(
`${testNum}: tryError: ${error}`
);
expect
(
false
)
.
assertTrue
();
done
();
}
finally
{
helper
.
unRegisterChange
(
uri
);
}
});
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_
ON
_CALLBACK_1700
* @tc.name :
on
_callback_017
* @tc.number : SUB_PHOTOACCESS_HELPER_
REGISTERCHANGE
_CALLBACK_1700
* @tc.name :
registerChange
_callback_017
* @tc.desc : listening update file, type NOTIFY_UPDATE
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it
(
'on_callback_017'
,
0
,
async
function
example
(
done
)
{
it
(
'registerChange_callback_017'
,
0
,
async
function
example
(
done
)
{
const
testNum
=
'registerChange_callback_017'
;
let
uri
;
try
{
let
testFileName
=
'testCreateFile'
+
Date
.
now
()
+
'.jpg'
;
let
fileAsset
=
await
helper
.
createAsset
(
testFileName
);
...
...
@@ -964,14 +1201,16 @@ export default function publicApiTestWithSystemApiTest () {
await
fileio
.
write
(
fd
,
buf
);
await
fileAsset
.
close
(
fd
);
let
count
=
0
;
await
sleep
(
1000
);
helper
.
registerChange
(
fileAsset
.
uri
,
false
,
async
(
changeData
)
=>
{
await
sleep
(
550
);
uri
=
fileAsset
.
uri
;
helper
.
registerChange
(
uri
,
false
,
async
(
changeData
)
=>
{
count
++
;
console
.
info
(
`
on_callback_017
changeData: ${JSON.stringify(changeData)}`
);
console
.
info
(
`
${testNum}
changeData: ${JSON.stringify(changeData)}`
);
expect
(
changeData
.
type
)
.
assertEqual
(
NOTIFY_UPDATE
);
expect
(
changeData
.
uris
[
0
])
.
assertEqual
(
fileAsset
.
uri
);
expect
(
changeData
.
uris
[
0
])
.
assertEqual
(
uri
);
done
();
});
await
sleep
(
550
);
fd
=
await
fileAsset
.
open
(
'rw'
);
buf
=
new
ArrayBuffer
(
1
);
buf
[
0
]
=
0
;
...
...
@@ -979,12 +1218,13 @@ export default function publicApiTestWithSystemApiTest () {
await
fileAsset
.
close
(
fd
);
await
sleep
(
1000
);
expect
(
count
)
.
assertEqual
(
1
);
helper
.
unRegisterChange
(
fileAsset
.
uri
);
done
();
}
catch
(
error
)
{
console
.
log
(
`
on_callback_017
: tryError: $${error}`
);
console
.
log
(
`
${testNum}
: tryError: $${error}`
);
expect
(
false
)
.
assertTrue
();
done
();
}
finally
{
helper
.
unRegisterChange
(
uri
);
}
});
...
...
multimedia/photoAccess/photoAccessSystem/entry/src/main/ets/test/setFavorite.ets
浏览文件 @
5e20d578
...
...
@@ -13,7 +13,6 @@
* limitations under the License.
*/
// @ts-nocheck
import
photoAccessHelper
from
'@ohos.file.photoAccessHelper'
import
{
describe
,
it
,
expect
}
from
'deccjsunit/index'
import
{
...
...
multimedia/photoAccess/photoAccessSystem/entry/src/main/ets/test/setHidden.ets
浏览文件 @
5e20d578
...
...
@@ -13,7 +13,6 @@
* limitations under the License.
*/
// @ts-nocheck
import
photoAccessHelper
from
'@ohos.file.photoAccessHelper'
import
{
describe
,
it
,
expect
}
from
'deccjsunit/index'
import
{
...
...
multimedia/photoAccess/photoAccessSystem/entry/src/main/module.json
浏览文件 @
5e20d578
...
...
@@ -8,8 +8,7 @@
"deviceTypes"
:
[
"tablet"
,
"default"
,
"phone"
,
"2in1"
"phone"
],
"deliveryWithInstall"
:
true
,
"installationFree"
:
false
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录