Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
7465ed7f
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看板
提交
7465ed7f
编写于
7月 19, 2023
作者:
Y
yangbo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
photoAccessHelper xts update
Signed-off-by:
N
yangbo
<
yangbo258@huawei.com
>
上级
eb5bed67
变更
64
展开全部
隐藏空白更改
内联
并排
Showing
64 changed file
with
871 addition
and
373 deletion
+871
-373
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
+0
-27
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
+0
-1
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
+20
-22
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
+32
-36
multimedia/photoAccess/photoAccess/entry/src/main/ets/test/PhotoAsset/checkAttr.ets
...toAccess/entry/src/main/ets/test/PhotoAsset/checkAttr.ets
+3
-3
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
+4
-2
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
+344
-121
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
浏览文件 @
7465ed7f
...
...
@@ -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
浏览文件 @
7465ed7f
...
...
@@ -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
浏览文件 @
7465ed7f
...
...
@@ -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
浏览文件 @
7465ed7f
...
...
@@ -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
浏览文件 @
7465ed7f
...
...
@@ -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
浏览文件 @
7465ed7f
...
...
@@ -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
浏览文件 @
7465ed7f
...
...
@@ -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
浏览文件 @
7465ed7f
...
...
@@ -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
浏览文件 @
7465ed7f
...
...
@@ -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
浏览文件 @
7465ed7f
...
...
@@ -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
浏览文件 @
7465ed7f
...
...
@@ -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
浏览文件 @
7465ed7f
...
...
@@ -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
浏览文件 @
7465ed7f
...
...
@@ -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
浏览文件 @
7465ed7f
...
...
@@ -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
'
;
...
...
@@ -159,32 +158,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
浏览文件 @
7465ed7f
...
...
@@ -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
浏览文件 @
7465ed7f
...
...
@@ -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/AbsAlbum/getAssets.ets
浏览文件 @
7465ed7f
...
...
@@ -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
浏览文件 @
7465ed7f
...
...
@@ -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
浏览文件 @
7465ed7f
...
...
@@ -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
浏览文件 @
7465ed7f
...
...
@@ -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
浏览文件 @
7465ed7f
...
...
@@ -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
浏览文件 @
7465ed7f
...
...
@@ -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
浏览文件 @
7465ed7f
...
...
@@ -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
浏览文件 @
7465ed7f
...
...
@@ -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
浏览文件 @
7465ed7f
...
...
@@ -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
浏览文件 @
7465ed7f
...
...
@@ -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
浏览文件 @
7465ed7f
...
...
@@ -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
浏览文件 @
7465ed7f
...
...
@@ -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
浏览文件 @
7465ed7f
...
...
@@ -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
浏览文件 @
7465ed7f
...
...
@@ -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
浏览文件 @
7465ed7f
/*
* 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
浏览文件 @
7465ed7f
...
...
@@ -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
浏览文件 @
7465ed7f
...
...
@@ -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
浏览文件 @
7465ed7f
...
...
@@ -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,15 +32,15 @@ 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);
...
...
@@ -69,15 +67,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;
...
...
@@ -104,15 +102,15 @@ 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;
...
...
@@ -140,15 +138,15 @@ 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);
...
...
@@ -176,15 +174,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);
...
...
multimedia/photoAccess/photoAccess/entry/src/main/ets/test/PhotoAccessHelper/release.ets
浏览文件 @
7465ed7f
...
...
@@ -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
浏览文件 @
7465ed7f
...
...
@@ -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,15 +30,15 @@ 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
);
...
...
@@ -69,15 +65,15 @@ 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
)
=>
{
...
...
@@ -100,15 +96,15 @@ 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
;
...
...
@@ -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
;
...
...
@@ -175,15 +171,15 @@ 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
);
...
...
@@ -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
);
...
...
@@ -246,15 +242,15 @@ 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
);
...
...
@@ -285,15 +281,15 @@ 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
);
...
...
multimedia/photoAccess/photoAccess/entry/src/main/ets/test/PhotoAsset/checkAttr.ets
浏览文件 @
7465ed7f
...
...
@@ -13,7 +13,6 @@
* limitations under the License.
*/
// @ts-nocheck
import
{
describe
,
it
,
expect
}
from
'deccjsunit/index'
import
{
photoKeys
,
...
...
@@ -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
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
浏览文件 @
7465ed7f
...
...
@@ -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
浏览文件 @
7465ed7f
...
...
@@ -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
浏览文件 @
7465ed7f
...
...
@@ -13,7 +13,6 @@
* limitations under the License.
*/
// @ts-nocheck
import
{
describe
,
it
,
expect
}
from
'deccjsunit/index'
import
{
photoKeys
,
...
...
@@ -32,7 +31,10 @@ export default function getTest () {
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
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
浏览文件 @
7465ed7f
...
...
@@ -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
浏览文件 @
7465ed7f
...
...
@@ -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
浏览文件 @
7465ed7f
...
...
@@ -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
浏览文件 @
7465ed7f
...
...
@@ -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
浏览文件 @
7465ed7f
...
...
@@ -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
浏览文件 @
7465ed7f
...
...
@@ -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
浏览文件 @
7465ed7f
...
...
@@ -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
浏览文件 @
7465ed7f
...
...
@@ -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
浏览文件 @
7465ed7f
...
...
@@ -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
浏览文件 @
7465ed7f
...
...
@@ -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
浏览文件 @
7465ed7f
...
...
@@ -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
浏览文件 @
7465ed7f
...
...
@@ -8,8 +8,7 @@
"deviceTypes"
:
[
"tablet"
,
"default"
,
"phone"
,
"2in1"
"phone"
],
"deliveryWithInstall"
:
true
,
"installationFree"
:
false
,
...
...
multimedia/photoAccess/photoAccessSystem/Test.json
浏览文件 @
7465ed7f
...
...
@@ -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
浏览文件 @
7465ed7f
...
...
@@ -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
浏览文件 @
7465ed7f
...
...
@@ -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
浏览文件 @
7465ed7f
...
...
@@ -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
浏览文件 @
7465ed7f
...
...
@@ -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
浏览文件 @
7465ed7f
...
...
@@ -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
浏览文件 @
7465ed7f
...
...
@@ -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
浏览文件 @
7465ed7f
...
...
@@ -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
浏览文件 @
7465ed7f
此差异已折叠。
点击以展开。
multimedia/photoAccess/photoAccessSystem/entry/src/main/ets/test/setFavorite.ets
浏览文件 @
7465ed7f
...
...
@@ -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
浏览文件 @
7465ed7f
...
...
@@ -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
浏览文件 @
7465ed7f
...
...
@@ -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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录