Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
96d9ac29
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看板
提交
96d9ac29
编写于
9月 01, 2022
作者:
C
caochuan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Detail optimization
- mediaLibrary_album - mediaLibrary_base Signed-off-by:
N
caochuan
<
caochuan@huawei.com
>
上级
707d9743
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
54 addition
and
92 deletion
+54
-92
multimedia/medialibrary/mediaLibrary_album/entry/src/main/ets/test/albumGetFileAssetsCallback.test.ets
...try/src/main/ets/test/albumGetFileAssetsCallback.test.ets
+9
-25
multimedia/medialibrary/mediaLibrary_album/entry/src/main/ets/test/albumGetFileAssetsPromise.test.ets
...ntry/src/main/ets/test/albumGetFileAssetsPromise.test.ets
+7
-24
multimedia/medialibrary/mediaLibrary_album/entry/src/main/ets/test/albumTestCallBack.test.ets
..._album/entry/src/main/ets/test/albumTestCallBack.test.ets
+8
-9
multimedia/medialibrary/mediaLibrary_album/entry/src/main/ets/test/albumTestPromise.test.ets
...y_album/entry/src/main/ets/test/albumTestPromise.test.ets
+8
-10
multimedia/medialibrary/mediaLibrary_base/entry/src/main/ets/test/mediaLibraryTestCallback.test.ets
...entry/src/main/ets/test/mediaLibraryTestCallback.test.ets
+4
-4
multimedia/medialibrary/mediaLibrary_base/entry/src/main/ets/test/mediaLibraryTestPromiseOnOff.test.ets
...y/src/main/ets/test/mediaLibraryTestPromiseOnOff.test.ets
+18
-20
未找到文件。
multimedia/medialibrary/mediaLibrary_album/entry/src/main/ets/test/albumGetFileAssetsCallback.test.ets
浏览文件 @
96d9ac29
...
...
@@ -62,8 +62,9 @@ export default function albumGetFileAssetsCallbackTest(abilityContext) {
const albumCountPass = await checkAlbumsCount(done, testNum, albumList, expectAlbumCount);
if (!albumCountPass) return;
// one asset type
if (expectAlbumCount == 1) {
const album = albumList[0];
let count = 0;
for (const album of albumList) {
album.getFileAssets(allFetchOp({ order: `date_added DESC LIMIT 0,${expectAssetsCount}` }), (error, fetchFileResult) => {
if (fetchFileResult == undefined || error) {
console.info(`${testNum} fetchFileResult undefined or error, error: ${error}`)
...
...
@@ -71,33 +72,16 @@ export default function albumGetFileAssetsCallbackTest(abilityContext) {
done();
return;
}
console.info(`${testNum}, getCount: ${fetchFileResult.getCount()}`)
console.info(`${testNum}, expectAssetsCount: ${expectAssetsCount}`)
count++;
console.info(`${testNum}, expectAssetsCount: ${expectAssetsCount}
getCount: ${fetchFileResult.getCount()}`)
expect(fetchFileResult.getCount()).assertEqual(expectAssetsCount);
done();
});
} else {
// more asset type
let count = 0;
for (const album of albumList) {
album.getFileAssets(allFetchOp({ order: `date_added DESC LIMIT 0,${expectAssetsCount}` }), (error, fetchFileResult) => {
if (fetchFileResult == undefined || error) {
console.info(`${testNum} fetchFileResult undefined or error, error: ${error}`)
expect(false).assertTrue();
done();
return;
}
count++;
console.info(`${testNum}, getCount: ${fetchFileResult.getCount()}`)
console.info(`${testNum}, expectAssetsCount: ${expectAssetsCount}`)
expect(fetchFileResult.getCount()).assertEqual(expectAssetsCount);
});
await sleep(500)
}
await sleep(500)
expect(count).assertEqual(expectAlbumCount);
done();
}
await sleep(500)
expect(count).assertEqual(expectAlbumCount);
done();
} catch (error) {
console.info(`${testNum}, error: ${error}`)
expect(false).assertTrue();
...
...
multimedia/medialibrary/mediaLibrary_album/entry/src/main/ets/test/albumGetFileAssetsPromise.test.ets
浏览文件 @
96d9ac29
...
...
@@ -62,9 +62,8 @@ export default function albumGetFileAssetsPromiseTest(abilityContext) {
// one asset type
let op: mediaLibrary.MediaFetchOptions =
allFetchOp({ order: `date_added DESC LIMIT 0,${expectAssetsCount}` })
if (expectAlbumCount == 1) {
const album = albumList[0];
let count = 0;
for (const album of albumList) {
let fetchFileResult = await album.getFileAssets(op);
if (fetchFileResult == undefined) {
console.info(`${testNum} fetchFileResult undefined`)
...
...
@@ -72,29 +71,13 @@ export default function albumGetFileAssetsPromiseTest(abilityContext) {
done();
return;
}
console.info(`${testNum}, getCount: ${fetchFileResult.getCount()}`)
console.info(`${testNum}, expectAssetsCount: ${expectAssetsCount}`)
count++;
console.info(`${testNum}, expectAssetsCount: ${expectAssetsCount}
getCount: ${fetchFileResult.getCount()}`)
expect(fetchFileResult.getCount()).assertEqual(expectAssetsCount);
done();
} else {
// more asset type
let count = 0;
for (const album of albumList) {
let fetchFileResult = await album.getFileAssets(op);
if (fetchFileResult == undefined) {
console.info(`${testNum} fetchFileResult undefined`)
expect(false).assertTrue();
done();
return;
}
count++;
console.info(`${testNum}, getCount: ${fetchFileResult.getCount()}`)
console.info(`${testNum}, expectAssetsCount: ${expectAssetsCount}`)
expect(fetchFileResult.getCount()).assertEqual(expectAssetsCount);
}
expect(count).assertEqual(expectAlbumCount);
done();
}
expect(count).assertEqual(expectAlbumCount);
done();
} catch (error) {
console.info(`${testNum}, error: ${error}`)
expect(false).assertTrue();
...
...
multimedia/medialibrary/mediaLibrary_album/entry/src/main/ets/test/albumTestCallBack.test.ets
浏览文件 @
96d9ac29
...
...
@@ -51,13 +51,13 @@ export default function albumTestCallbackTest(abilityContext) {
});
function printAlbumMessage(testNum, album) {
console.info(`${testNum} album.albumId: ${album.albumId}
`);
console.info(`${testNum} album.albumName: ${album.albumName}`);
console.info(`${testNum} album.albumUri: ${album.albumUri}`);
console.info(`${testNum} album.dateModified: ${album.dateModified}`);
console.info(`${testNum} album.count: ${album.count}`);
console.info(`${testNum} album.relativePath: ${album.relativePath}`);
console.info(`${testNum}
album.coverUri: ${album.coverUri}`);
console.info(`${testNum} album.albumId: ${album.albumId}
album.albumName: ${album.albumName}
album.albumUri: ${album.albumUri}
album.dateModified: ${album.dateModified}
album.count: ${album.count}
album.relativePath: ${album.relativePath}
album.coverUri: ${album.coverUri}`);
}
const props = {
...
...
@@ -148,8 +148,7 @@ export default function albumTestCallbackTest(abilityContext) {
const album = albumList[0];
album.albumName = newName;
album.commitModify(async (error) => {
console.info(`${testNum}, error.message: ${error.message}`)
console.info(`${testNum}, error.code: ${error.code}`)
console.info(`${testNum}, error.message: ${error.message} error.code: ${error.code}`)
expect(error.code != undefined).assertTrue();
done();
});
...
...
multimedia/medialibrary/mediaLibrary_album/entry/src/main/ets/test/albumTestPromise.test.ets
浏览文件 @
96d9ac29
...
...
@@ -50,13 +50,13 @@ export default function albumTestPromiseTest(abilityContext) {
});
function printAlbumMessage(testNum, album) {
console.info(`${testNum} album.albumId: ${album.albumId}
`);
console.info(`${testNum} album.albumName: ${album.albumName}`);
console.info(`${testNum} album.albumUri: ${album.albumUri}`);
console.info(`${testNum} album.dateModified: ${album.dateModified}`);
console.info(`${testNum} album.count: ${album.count}`);
console.info(`${testNum} album.relativePath: ${album.relativePath}`);
console.info(`${testNum}
album.coverUri: ${album.coverUri}`);
console.info(`${testNum} album.albumId: ${album.albumId}
album.albumName: ${album.albumName}
album.albumUri: ${album.albumUri}
album.dateModified: ${album.dateModified}
album.count: ${album.count}
album.relativePath: ${album.relativePath}
album.coverUri: ${album.coverUri}`);
}
const props = {
...
...
@@ -115,7 +115,6 @@ export default function albumTestPromiseTest(abilityContext) {
const abnormalAlbumCount = async function (done, testNum, fetchOp) {
try {
const albumList = await media.getAlbums(fetchOp);
console.info(`${testNum}, albumList.length: ${albumList.length}`)
expect(albumList.length).assertEqual(0);
...
...
@@ -139,8 +138,7 @@ export default function albumTestPromiseTest(abilityContext) {
expect(false).assertTrue();
done();
} catch (error) {
console.info(`${testNum}, error.message: ${error.message}`)
console.info(`${testNum}, error.code: ${error.code}`)
console.info(`${testNum}, error.message: ${error.message} error.code: ${error.code}`)
expect(error.code!=undefined).assertTrue();
done();
}
...
...
multimedia/medialibrary/mediaLibrary_base/entry/src/main/ets/test/mediaLibraryTestCallback.test.ets
浏览文件 @
96d9ac29
...
...
@@ -276,14 +276,14 @@ export default function mediaLibraryTestCallback(abilityContext) {
await
asset
.
close
(
fd
);
try
{
media
.
createAsset
(
type
,
name
,
path
,
async
(
err
,
creatAsset
)
=>
{
if
(
err
||
creatAsset
=
=
undefined
)
{
if
(
err
!
=
undefined
)
{
expect
(
true
)
.
assertTrue
();
done
();
return
;
}
else
{
expect
(
false
)
.
assertTrue
();
done
();
}
expect
(
false
)
.
assertTrue
();
done
();
});
}
catch
(
error
)
{
console
.
info
(
`${testNum}:: error :${error}`
);
...
...
multimedia/medialibrary/mediaLibrary_base/entry/src/main/ets/test/mediaLibraryTestPromiseOnOff.test.ets
浏览文件 @
96d9ac29
...
...
@@ -50,8 +50,8 @@ export default function mediaLibraryTestPromiseOnOffTest(abilityContext) {
const onTest = async (done, testNum, type, fetchOps) => {
try {
let co
nu
t = 0;
media.on(type, () => { co
nu
t++; });
let co
un
t = 0;
media.on(type, () => { co
un
t++; });
const fetchFileResult = await media.getFileAssets(fetchOps);
let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchFileResult, 1);
if (!checkAssetCountPass) return;
...
...
@@ -59,7 +59,7 @@ export default function mediaLibraryTestPromiseOnOffTest(abilityContext) {
asset.title = asset.title + 'changename';
await asset.commitModify();
await sleep(1000)
expect(co
nu
t > 0).assertTrue();
expect(co
un
t > 0).assertTrue();
done();
} catch (error) {
console.info(`${testNum}:: error :${error}`);
...
...
@@ -69,21 +69,19 @@ export default function mediaLibraryTestPromiseOnOffTest(abilityContext) {
}
const offTest = async (done, testNum, type, fetchOps) => {
try {
let co
nu
t = 0;
let co
un
t = 0;
media.on(type, () => {
co
nu
t++;
co
un
t++;
});
await sleep(200)
const fetchFileResult = await media.getFileAssets(fetchOps);
let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchFileResult, 1);
if (!checkAssetCountPass) return;
const asset = await fetchFileResult.getFirstObject();
asset.title = asset.title + 'changename';
media.off(type);
await sleep(200)
await asset.commitModify();
await sleep(1000)
expect(co
nu
t).assertEqual(0);
expect(co
un
t).assertEqual(0);
done();
} catch (error) {
console.info(`${testNum}:: error :${error}`);
...
...
@@ -162,9 +160,9 @@ export default function mediaLibraryTestPromiseOnOffTest(abilityContext) {
it('SUB_MEDIA_MEDIALIBRARY_PROMISE_ON_005', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_PROMISE_ON_005'
try {
let co
nu
t = 0;
let co
un
t = 0;
media.on('albumChange', () => {
co
nu
t++;
co
un
t++;
});
let currentFetchOps = albumFetchOps(testNum, 'Pictures/', 'OnAlbum', IMAGE_TYPE);
const albumList = await media.getAlbums(currentFetchOps);
...
...
@@ -175,7 +173,7 @@ export default function mediaLibraryTestPromiseOnOffTest(abilityContext) {
album.albumName = album.albumName + 'changename';
await album.commitModify();
await sleep(1000)
expect(co
nu
t > 0).assertTrue();
expect(co
un
t > 0).assertTrue();
album.albumName = oldName;
await album.commitModify();
done();
...
...
@@ -197,12 +195,12 @@ export default function mediaLibraryTestPromiseOnOffTest(abilityContext) {
it('SUB_MEDIA_MEDIALIBRARY_PROMISE_ON_006', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_PROMISE_ON_006'
try {
let co
nu
t = 0;
let co
un
t = 0;
expect(true).assertTrue();
done();
media.on('deviceChange', () => {
console.info('MediaLibraryTest : on 006 callback');
co
nu
t++;
co
un
t++;
});
let currentFetchOps = fetchOps(testNum, 'Documents/On/', FILE_TYPE);
const fetchFileResult = await media.getFileAssets(currentFetchOps);
...
...
@@ -214,7 +212,7 @@ export default function mediaLibraryTestPromiseOnOffTest(abilityContext) {
res(true)
}, 1000)
})
expect(co
nu
t == 0).assertTrue();
expect(co
un
t == 0).assertTrue();
done();
} catch (error) {
console.info(`MediaLibraryTest : on 006 failed, error: ${error}`);
...
...
@@ -235,12 +233,12 @@ export default function mediaLibraryTestPromiseOnOffTest(abilityContext) {
it('SUB_MEDIA_MEDIALIBRARY_PROMISE_ON_007', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_PROMISE_ON_007'
try {
let co
nu
t = 0;
let co
un
t = 0;
expect(true).assertTrue();
done();
media.on('remoteFileChange', () => {
console.info('MediaLibraryTest : on 007 callback');
co
nu
t++;
co
un
t++;
});
let currentFetchOps = fetchOps(testNum, 'Documents/On/', FILE_TYPE);
...
...
@@ -253,7 +251,7 @@ export default function mediaLibraryTestPromiseOnOffTest(abilityContext) {
res(true)
}, 1000)
})
expect(co
nu
t == 0).assertTrue();
expect(co
un
t == 0).assertTrue();
done();
} catch (error) {
console.info(`MediaLibraryTest : on 006 failed, error: ${error}`);
...
...
@@ -334,9 +332,9 @@ export default function mediaLibraryTestPromiseOnOffTest(abilityContext) {
it('SUB_MEDIA_MEDIALIBRARY_PROMISE_OFF_005', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_PROMISE_OFF_005'
try {
let co
nu
t = 0;
let co
un
t = 0;
media.on('albumChange', () => {
co
nu
t++;
co
un
t++;
});
await sleep(300)
media.off('albumChange');
...
...
@@ -352,7 +350,7 @@ export default function mediaLibraryTestPromiseOnOffTest(abilityContext) {
await sleep(300)
album.albumName = oldName;
await album.commitModify();
expect(co
nu
t).assertEqual(0);
expect(co
un
t).assertEqual(0);
done();
} catch (error) {
console.info(`${testNum}:: error :${error}`);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录