Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
aeeb3cbe
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看板
未验证
提交
aeeb3cbe
编写于
7月 11, 2022
作者:
O
openharmony_ci
提交者:
Gitee
7月 11, 2022
浏览文件
操作
浏览文件
下载
差异文件
!4027 add media library xts cases
Merge pull request !4027 from jiahaoluo/xts
上级
de6b13e9
85f6df9d
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
140 addition
and
2 deletion
+140
-2
multimedia/medialibrary/mediaLibrary_js_standard/entry/src/main/ets/test/fetchFileResultCallBack.test.ets
.../entry/src/main/ets/test/fetchFileResultCallBack.test.ets
+48
-1
multimedia/medialibrary/mediaLibrary_js_standard/entry/src/main/ets/test/filekeyTestCallBack.test.ets
...dard/entry/src/main/ets/test/filekeyTestCallBack.test.ets
+67
-0
multimedia/medialibrary/mediaLibrary_js_standard/entry/src/main/ets/test/mediaLibraryTestCallBack.test.ets
...entry/src/main/ets/test/mediaLibraryTestCallBack.test.ets
+25
-1
未找到文件。
multimedia/medialibrary/mediaLibrary_js_standard/entry/src/main/ets/test/fetchFileResultCallBack.test.ets
浏览文件 @
aeeb3cbe
...
...
@@ -71,6 +71,53 @@ export default function fetchFileResultCallBackTest(abilityContext) {
afterAll(function () {
});
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETFIRSTOBJECT_CALLBACK_003
* @tc.name : getFirstObject
* @tc.desc : Get FetchResult, get first object, check result
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETFIRSTOBJECT_CALLBACK_003', 0, async function (done) {
try {
console.info('MediaLibraryTest : FETCHRESULT getFirstObject 003 begin');
let mediaType = mediaLibrary.MediaType.IMAGE;
let dir = mediaLibrary.DirectoryType.DIR_IMAGE;
const path = await media.getPublicDirectory(dir);
let fileAsset = await media.createAsset(mediaType, 'forUri.jpg', path + 'myPicture/');
if (fileAsset == undefined) {
console.info('MediaLibraryTest : FETCHRESULT createAsset fail');
expect(false).assertTrue();
done();
return;
}
let fetchOption = {
selections: '',
selectionArgs: [],
uri: fileAsset.uri,
networkId: ''
}
let fetchFileResult = await media.getFileAssets(fetchOption);
fetchFileResult.getFirstObject(async (error, firstObject) => {
if (firstObject == undefined) {
expect(false).assertTrue();
console.info('MediaLibraryTest : FETCHRESULT getFirstObject 003 fail');
done();
} else {
expect(firstObject.displayName == 'forUri.jpg').assertTrue();
fetchFileResult.close();
console.info('MediaLibraryTest : FETCHRESULT getFirstObject 003 end');
done();
}
});
} catch (error) {
console.info('MediaLibraryTest : FETCHRESULT getFirstObject 003 failed, message = ' + error);
expect(false).assertTrue();
done();
}
});
// ------------------------------ 004 test start -------------------------
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETFIRSTOBJECT_CALLBACK_004
...
...
@@ -82,7 +129,7 @@ export default function fetchFileResultCallBackTest(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETFIRSTOBJECT_CALLBACK_004', 0, async function (done) {
try {
console.info('MediaLibraryTest : FETCHRESULT getFirstObject begin');
console.info('MediaLibraryTest : FETCHRESULT getFirstObject
004
begin');
let fetchFileResult = await media.getFileAssets(getFirstObjectOp);
fetchFileResult.getFirstObject(async (error, firstObject) => {
if (firstObject == undefined) {
...
...
multimedia/medialibrary/mediaLibrary_js_standard/entry/src/main/ets/test/filekeyTestCallBack.test.ets
浏览文件 @
aeeb3cbe
...
...
@@ -323,6 +323,73 @@ export default function filekeyTestCallBackTest(abilityContext){
it
(
'test_fileKey_0015'
,
0
,
async
function
(
done
)
{
getFileAssetsBy
(
done
,
'audioAlbum'
);
});
/**
* @tc.number : test_fileKey_0016
* @tc.name : getFileAssets
* @tc.desc : filekey relative_path
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it
(
'test_fileKey_0016'
,
0
,
async
function
(
done
)
{
try
{
let
mediaType
=
mediaLibrary
.
MediaType
.
IMAGE
;
let
DIR_IMAGE
=
mediaLibrary
.
DirectoryType
.
DIR_IMAGE
;
const
path
=
await
media
.
getPublicDirectory
(
DIR_IMAGE
);
let
fileAsset
=
await
media
.
createAsset
(
mediaType
,
'forRelative.jpg'
,
path
);
if
(
fileAsset
==
undefined
)
{
console
.
info
(
'MediaLibraryTest : FETCHRESULT createAsset fail'
);
expect
(
false
)
.
assertTrue
();
done
();
return
;
}
let
fetchOption
=
{
selections
:
fileKeyObj
.
RELATIVE_PATH
+
'= ?'
,
selectionArgs
:
[
path
]
}
let
fetchFileResult
=
await
media
.
getFileAssets
(
fetchOption
);
let
firstObject
=
await
fetchFileResult
.
getFirstObject
();
expect
(
firstObject
.
relativePath
==
path
)
.
assertTrue
();
done
();
}
catch
(
error
)
{
console
.
info
(
'ASSET_CALLBACK test_fileKey_0016 failed, message = '
+
error
);
}
});
/**
* @tc.number : test_fileKey_0017
* @tc.name : getFileAssets
* @tc.desc : filekey display_name
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it
(
'test_fileKey_0017'
,
0
,
async
function
(
done
)
{
try
{
let
mediaType
=
mediaLibrary
.
MediaType
.
IMAGE
;
let
DIR_IMAGE
=
mediaLibrary
.
DirectoryType
.
DIR_IMAGE
;
const
path
=
await
media
.
getPublicDirectory
(
DIR_IMAGE
);
let
name
=
'forDisplay.jpg'
let
fileAsset
=
await
media
.
createAsset
(
mediaType
,
name
,
path
);
if
(
fileAsset
==
undefined
)
{
console
.
info
(
'MediaLibraryTest : FETCHRESULT createAsset fail'
);
expect
(
false
)
.
assertTrue
();
done
();
return
;
}
let
fetchOption
=
{
selections
:
fileKeyObj
.
DISPLAY_NAME
+
'= ?'
,
selectionArgs
:
[
name
]
}
let
fetchFileResult
=
await
media
.
getFileAssets
(
fetchOption
);
let
firstObject
=
await
fetchFileResult
.
getFirstObject
();
expect
(
firstObject
.
displayName
==
name
)
.
assertTrue
();
done
();
}
catch
(
error
)
{
console
.
info
(
'ASSET_CALLBACK test_fileKey_0017 failed, message = '
+
error
);
}
});
});
}
multimedia/medialibrary/mediaLibrary_js_standard/entry/src/main/ets/test/mediaLibraryTestCallBack.test.ets
浏览文件 @
aeeb3cbe
...
...
@@ -980,7 +980,31 @@ export default function mediaLibraryTestCallBackTest(abilityContext){
}
});
/**
* @tc.number : SUB__MEDIA_MIDIALIBRARY_CALLBACK_RELEASE_001
* @tc.name : release
* @tc.desc : Release MediaLibrary instance
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it
(
'SUB__MEDIA_MIDIALIBRARY_CALLBACK_RELEASE_001'
,
0
,
async
function
(
done
)
{
try
{
console
.
info
(
'MediaLibraryTest : release 001 begin'
);
media
.
release
((
err
,
data
)
=>
{
if
(
err
==
undefined
)
{
expect
(
true
)
.
assertTrue
();
done
();
}
else
{
expect
(
false
)
.
assertTrue
();
done
();
}});
}
catch
(
error
)
{
console
.
info
(
'MediaLibraryTest : release 001 failed, message = '
+
error
);
expect
(
false
)
.
assertTrue
();
done
();
}
});
});
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录