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,22 +62,7 @@ export default function albumGetFileAssetsCallbackTest(abilityContext) {
...
@@ -62,22 +62,7 @@ export default function albumGetFileAssetsCallbackTest(abilityContext) {
const albumCountPass = await checkAlbumsCount(done, testNum, albumList, expectAlbumCount);
const albumCountPass = await checkAlbumsCount(done, testNum, albumList, expectAlbumCount);
if (!albumCountPass) return;
if (!albumCountPass) return;
// one asset type
// one asset type
if (expectAlbumCount == 1) {
const album = albumList[0];
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;
}
console.info(`${testNum}, getCount: ${fetchFileResult.getCount()}`)
console.info(`${testNum}, expectAssetsCount: ${expectAssetsCount}`)
expect(fetchFileResult.getCount()).assertEqual(expectAssetsCount);
done();
});
} else {
// more asset type
let count = 0;
let count = 0;
for (const album of albumList) {
for (const album of albumList) {
album.getFileAssets(allFetchOp({ order: `date_added DESC LIMIT 0,${expectAssetsCount}` }), (error, fetchFileResult) => {
album.getFileAssets(allFetchOp({ order: `date_added DESC LIMIT 0,${expectAssetsCount}` }), (error, fetchFileResult) => {
...
@@ -88,8 +73,8 @@ export default function albumGetFileAssetsCallbackTest(abilityContext) {
...
@@ -88,8 +73,8 @@ export default function albumGetFileAssetsCallbackTest(abilityContext) {
return;
return;
}
}
count++;
count++;
console.info(`${testNum}, getCount: ${fetchFileResult.getCount()}`)
console.info(`${testNum}, expectAssetsCount: ${expectAssetsCount}
console.info(`${testNum}, expectAssetsCount: ${expectAssetsCount
}`)
getCount: ${fetchFileResult.getCount()
}`)
expect(fetchFileResult.getCount()).assertEqual(expectAssetsCount);
expect(fetchFileResult.getCount()).assertEqual(expectAssetsCount);
});
});
await sleep(500)
await sleep(500)
...
@@ -97,7 +82,6 @@ export default function albumGetFileAssetsCallbackTest(abilityContext) {
...
@@ -97,7 +82,6 @@ export default function albumGetFileAssetsCallbackTest(abilityContext) {
await sleep(500)
await sleep(500)
expect(count).assertEqual(expectAlbumCount);
expect(count).assertEqual(expectAlbumCount);
done();
done();
}
} catch (error) {
} catch (error) {
console.info(`${testNum}, error: ${error}`)
console.info(`${testNum}, error: ${error}`)
expect(false).assertTrue();
expect(false).assertTrue();
...
...
multimedia/medialibrary/mediaLibrary_album/entry/src/main/ets/test/albumGetFileAssetsPromise.test.ets
浏览文件 @
96d9ac29
...
@@ -62,22 +62,6 @@ export default function albumGetFileAssetsPromiseTest(abilityContext) {
...
@@ -62,22 +62,6 @@ export default function albumGetFileAssetsPromiseTest(abilityContext) {
// one asset type
// one asset type
let op: mediaLibrary.MediaFetchOptions =
let op: mediaLibrary.MediaFetchOptions =
allFetchOp({ order: `date_added DESC LIMIT 0,${expectAssetsCount}` })
allFetchOp({ order: `date_added DESC LIMIT 0,${expectAssetsCount}` })
if (expectAlbumCount == 1) {
const album = albumList[0];
let fetchFileResult = await album.getFileAssets(op);
if (fetchFileResult == undefined) {
console.info(`${testNum} fetchFileResult undefined`)
expect(false).assertTrue();
done();
return;
}
console.info(`${testNum}, getCount: ${fetchFileResult.getCount()}`)
console.info(`${testNum}, expectAssetsCount: ${expectAssetsCount}`)
expect(fetchFileResult.getCount()).assertEqual(expectAssetsCount);
done();
} else {
// more asset type
let count = 0;
let count = 0;
for (const album of albumList) {
for (const album of albumList) {
let fetchFileResult = await album.getFileAssets(op);
let fetchFileResult = await album.getFileAssets(op);
...
@@ -88,13 +72,12 @@ export default function albumGetFileAssetsPromiseTest(abilityContext) {
...
@@ -88,13 +72,12 @@ export default function albumGetFileAssetsPromiseTest(abilityContext) {
return;
return;
}
}
count++;
count++;
console.info(`${testNum}, getCount: ${fetchFileResult.getCount()}`)
console.info(`${testNum}, expectAssetsCount: ${expectAssetsCount}
console.info(`${testNum}, expectAssetsCount: ${expectAssetsCount
}`)
getCount: ${fetchFileResult.getCount()
}`)
expect(fetchFileResult.getCount()).assertEqual(expectAssetsCount);
expect(fetchFileResult.getCount()).assertEqual(expectAssetsCount);
}
}
expect(count).assertEqual(expectAlbumCount);
expect(count).assertEqual(expectAlbumCount);
done();
done();
}
} catch (error) {
} catch (error) {
console.info(`${testNum}, error: ${error}`)
console.info(`${testNum}, error: ${error}`)
expect(false).assertTrue();
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) {
...
@@ -51,13 +51,13 @@ export default function albumTestCallbackTest(abilityContext) {
});
});
function printAlbumMessage(testNum, album) {
function printAlbumMessage(testNum, album) {
console.info(`${testNum} album.albumId: ${album.albumId}
`);
console.info(`${testNum} album.albumId: ${album.albumId}
console.info(`${testNum} album.albumName: ${album.albumName}`);
album.albumName: ${album.albumName}
console.info(`${testNum} album.albumUri: ${album.albumUri}`);
album.albumUri: ${album.albumUri}
console.info(`${testNum} album.dateModified: ${album.dateModified}`);
album.dateModified: ${album.dateModified}
console.info(`${testNum} album.count: ${album.count}`);
album.count: ${album.count}
console.info(`${testNum} album.relativePath: ${album.relativePath}`);
album.relativePath: ${album.relativePath}
console.info(`${testNum}
album.coverUri: ${album.coverUri}`);
album.coverUri: ${album.coverUri}`);
}
}
const props = {
const props = {
...
@@ -148,8 +148,7 @@ export default function albumTestCallbackTest(abilityContext) {
...
@@ -148,8 +148,7 @@ export default function albumTestCallbackTest(abilityContext) {
const album = albumList[0];
const album = albumList[0];
album.albumName = newName;
album.albumName = newName;
album.commitModify(async (error) => {
album.commitModify(async (error) => {
console.info(`${testNum}, error.message: ${error.message}`)
console.info(`${testNum}, error.message: ${error.message} error.code: ${error.code}`)
console.info(`${testNum}, error.code: ${error.code}`)
expect(error.code != undefined).assertTrue();
expect(error.code != undefined).assertTrue();
done();
done();
});
});
...
...
multimedia/medialibrary/mediaLibrary_album/entry/src/main/ets/test/albumTestPromise.test.ets
浏览文件 @
96d9ac29
...
@@ -50,13 +50,13 @@ export default function albumTestPromiseTest(abilityContext) {
...
@@ -50,13 +50,13 @@ export default function albumTestPromiseTest(abilityContext) {
});
});
function printAlbumMessage(testNum, album) {
function printAlbumMessage(testNum, album) {
console.info(`${testNum} album.albumId: ${album.albumId}
`);
console.info(`${testNum} album.albumId: ${album.albumId}
console.info(`${testNum} album.albumName: ${album.albumName}`);
album.albumName: ${album.albumName}
console.info(`${testNum} album.albumUri: ${album.albumUri}`);
album.albumUri: ${album.albumUri}
console.info(`${testNum} album.dateModified: ${album.dateModified}`);
album.dateModified: ${album.dateModified}
console.info(`${testNum} album.count: ${album.count}`);
album.count: ${album.count}
console.info(`${testNum} album.relativePath: ${album.relativePath}`);
album.relativePath: ${album.relativePath}
console.info(`${testNum}
album.coverUri: ${album.coverUri}`);
album.coverUri: ${album.coverUri}`);
}
}
const props = {
const props = {
...
@@ -115,7 +115,6 @@ export default function albumTestPromiseTest(abilityContext) {
...
@@ -115,7 +115,6 @@ export default function albumTestPromiseTest(abilityContext) {
const abnormalAlbumCount = async function (done, testNum, fetchOp) {
const abnormalAlbumCount = async function (done, testNum, fetchOp) {
try {
try {
const albumList = await media.getAlbums(fetchOp);
const albumList = await media.getAlbums(fetchOp);
console.info(`${testNum}, albumList.length: ${albumList.length}`)
console.info(`${testNum}, albumList.length: ${albumList.length}`)
expect(albumList.length).assertEqual(0);
expect(albumList.length).assertEqual(0);
...
@@ -139,8 +138,7 @@ export default function albumTestPromiseTest(abilityContext) {
...
@@ -139,8 +138,7 @@ export default function albumTestPromiseTest(abilityContext) {
expect(false).assertTrue();
expect(false).assertTrue();
done();
done();
} catch (error) {
} catch (error) {
console.info(`${testNum}, error.message: ${error.message}`)
console.info(`${testNum}, error.message: ${error.message} error.code: ${error.code}`)
console.info(`${testNum}, error.code: ${error.code}`)
expect(error.code!=undefined).assertTrue();
expect(error.code!=undefined).assertTrue();
done();
done();
}
}
...
...
multimedia/medialibrary/mediaLibrary_base/entry/src/main/ets/test/mediaLibraryTestCallback.test.ets
浏览文件 @
96d9ac29
...
@@ -276,14 +276,14 @@ export default function mediaLibraryTestCallback(abilityContext) {
...
@@ -276,14 +276,14 @@ export default function mediaLibraryTestCallback(abilityContext) {
await
asset
.
close
(
fd
);
await
asset
.
close
(
fd
);
try
{
try
{
media
.
createAsset
(
type
,
name
,
path
,
async
(
err
,
creatAsset
)
=>
{
media
.
createAsset
(
type
,
name
,
path
,
async
(
err
,
creatAsset
)
=>
{
if
(
err
||
creatAsset
=
=
undefined
)
{
if
(
err
!
=
undefined
)
{
expect
(
true
)
.
assertTrue
();
expect
(
true
)
.
assertTrue
();
done
();
done
();
return
;
return
;
}
else
{
}
expect
(
false
)
.
assertTrue
();
expect
(
false
)
.
assertTrue
();
done
();
done
();
}
});
});
}
catch
(
error
)
{
}
catch
(
error
)
{
console
.
info
(
`${testNum}:: error :${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) {
...
@@ -50,8 +50,8 @@ export default function mediaLibraryTestPromiseOnOffTest(abilityContext) {
const onTest = async (done, testNum, type, fetchOps) => {
const onTest = async (done, testNum, type, fetchOps) => {
try {
try {
let co
nu
t = 0;
let co
un
t = 0;
media.on(type, () => { co
nu
t++; });
media.on(type, () => { co
un
t++; });
const fetchFileResult = await media.getFileAssets(fetchOps);
const fetchFileResult = await media.getFileAssets(fetchOps);
let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchFileResult, 1);
let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchFileResult, 1);
if (!checkAssetCountPass) return;
if (!checkAssetCountPass) return;
...
@@ -59,7 +59,7 @@ export default function mediaLibraryTestPromiseOnOffTest(abilityContext) {
...
@@ -59,7 +59,7 @@ export default function mediaLibraryTestPromiseOnOffTest(abilityContext) {
asset.title = asset.title + 'changename';
asset.title = asset.title + 'changename';
await asset.commitModify();
await asset.commitModify();
await sleep(1000)
await sleep(1000)
expect(co
nu
t > 0).assertTrue();
expect(co
un
t > 0).assertTrue();
done();
done();
} catch (error) {
} catch (error) {
console.info(`${testNum}:: error :${error}`);
console.info(`${testNum}:: error :${error}`);
...
@@ -69,21 +69,19 @@ export default function mediaLibraryTestPromiseOnOffTest(abilityContext) {
...
@@ -69,21 +69,19 @@ export default function mediaLibraryTestPromiseOnOffTest(abilityContext) {
}
}
const offTest = async (done, testNum, type, fetchOps) => {
const offTest = async (done, testNum, type, fetchOps) => {
try {
try {
let co
nu
t = 0;
let co
un
t = 0;
media.on(type, () => {
media.on(type, () => {
co
nu
t++;
co
un
t++;
});
});
await sleep(200)
const fetchFileResult = await media.getFileAssets(fetchOps);
const fetchFileResult = await media.getFileAssets(fetchOps);
let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchFileResult, 1);
let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchFileResult, 1);
if (!checkAssetCountPass) return;
if (!checkAssetCountPass) return;
const asset = await fetchFileResult.getFirstObject();
const asset = await fetchFileResult.getFirstObject();
asset.title = asset.title + 'changename';
asset.title = asset.title + 'changename';
media.off(type);
media.off(type);
await sleep(200)
await asset.commitModify();
await asset.commitModify();
await sleep(1000)
await sleep(1000)
expect(co
nu
t).assertEqual(0);
expect(co
un
t).assertEqual(0);
done();
done();
} catch (error) {
} catch (error) {
console.info(`${testNum}:: error :${error}`);
console.info(`${testNum}:: error :${error}`);
...
@@ -162,9 +160,9 @@ export default function mediaLibraryTestPromiseOnOffTest(abilityContext) {
...
@@ -162,9 +160,9 @@ export default function mediaLibraryTestPromiseOnOffTest(abilityContext) {
it('SUB_MEDIA_MEDIALIBRARY_PROMISE_ON_005', 0, async function (done) {
it('SUB_MEDIA_MEDIALIBRARY_PROMISE_ON_005', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_PROMISE_ON_005'
let testNum = 'SUB_MEDIA_MEDIALIBRARY_PROMISE_ON_005'
try {
try {
let co
nu
t = 0;
let co
un
t = 0;
media.on('albumChange', () => {
media.on('albumChange', () => {
co
nu
t++;
co
un
t++;
});
});
let currentFetchOps = albumFetchOps(testNum, 'Pictures/', 'OnAlbum', IMAGE_TYPE);
let currentFetchOps = albumFetchOps(testNum, 'Pictures/', 'OnAlbum', IMAGE_TYPE);
const albumList = await media.getAlbums(currentFetchOps);
const albumList = await media.getAlbums(currentFetchOps);
...
@@ -175,7 +173,7 @@ export default function mediaLibraryTestPromiseOnOffTest(abilityContext) {
...
@@ -175,7 +173,7 @@ export default function mediaLibraryTestPromiseOnOffTest(abilityContext) {
album.albumName = album.albumName + 'changename';
album.albumName = album.albumName + 'changename';
await album.commitModify();
await album.commitModify();
await sleep(1000)
await sleep(1000)
expect(co
nu
t > 0).assertTrue();
expect(co
un
t > 0).assertTrue();
album.albumName = oldName;
album.albumName = oldName;
await album.commitModify();
await album.commitModify();
done();
done();
...
@@ -197,12 +195,12 @@ export default function mediaLibraryTestPromiseOnOffTest(abilityContext) {
...
@@ -197,12 +195,12 @@ export default function mediaLibraryTestPromiseOnOffTest(abilityContext) {
it('SUB_MEDIA_MEDIALIBRARY_PROMISE_ON_006', 0, async function (done) {
it('SUB_MEDIA_MEDIALIBRARY_PROMISE_ON_006', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_PROMISE_ON_006'
let testNum = 'SUB_MEDIA_MEDIALIBRARY_PROMISE_ON_006'
try {
try {
let co
nu
t = 0;
let co
un
t = 0;
expect(true).assertTrue();
expect(true).assertTrue();
done();
done();
media.on('deviceChange', () => {
media.on('deviceChange', () => {
console.info('MediaLibraryTest : on 006 callback');
console.info('MediaLibraryTest : on 006 callback');
co
nu
t++;
co
un
t++;
});
});
let currentFetchOps = fetchOps(testNum, 'Documents/On/', FILE_TYPE);
let currentFetchOps = fetchOps(testNum, 'Documents/On/', FILE_TYPE);
const fetchFileResult = await media.getFileAssets(currentFetchOps);
const fetchFileResult = await media.getFileAssets(currentFetchOps);
...
@@ -214,7 +212,7 @@ export default function mediaLibraryTestPromiseOnOffTest(abilityContext) {
...
@@ -214,7 +212,7 @@ export default function mediaLibraryTestPromiseOnOffTest(abilityContext) {
res(true)
res(true)
}, 1000)
}, 1000)
})
})
expect(co
nu
t == 0).assertTrue();
expect(co
un
t == 0).assertTrue();
done();
done();
} catch (error) {
} catch (error) {
console.info(`MediaLibraryTest : on 006 failed, error: ${error}`);
console.info(`MediaLibraryTest : on 006 failed, error: ${error}`);
...
@@ -235,12 +233,12 @@ export default function mediaLibraryTestPromiseOnOffTest(abilityContext) {
...
@@ -235,12 +233,12 @@ export default function mediaLibraryTestPromiseOnOffTest(abilityContext) {
it('SUB_MEDIA_MEDIALIBRARY_PROMISE_ON_007', 0, async function (done) {
it('SUB_MEDIA_MEDIALIBRARY_PROMISE_ON_007', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_PROMISE_ON_007'
let testNum = 'SUB_MEDIA_MEDIALIBRARY_PROMISE_ON_007'
try {
try {
let co
nu
t = 0;
let co
un
t = 0;
expect(true).assertTrue();
expect(true).assertTrue();
done();
done();
media.on('remoteFileChange', () => {
media.on('remoteFileChange', () => {
console.info('MediaLibraryTest : on 007 callback');
console.info('MediaLibraryTest : on 007 callback');
co
nu
t++;
co
un
t++;
});
});
let currentFetchOps = fetchOps(testNum, 'Documents/On/', FILE_TYPE);
let currentFetchOps = fetchOps(testNum, 'Documents/On/', FILE_TYPE);
...
@@ -253,7 +251,7 @@ export default function mediaLibraryTestPromiseOnOffTest(abilityContext) {
...
@@ -253,7 +251,7 @@ export default function mediaLibraryTestPromiseOnOffTest(abilityContext) {
res(true)
res(true)
}, 1000)
}, 1000)
})
})
expect(co
nu
t == 0).assertTrue();
expect(co
un
t == 0).assertTrue();
done();
done();
} catch (error) {
} catch (error) {
console.info(`MediaLibraryTest : on 006 failed, error: ${error}`);
console.info(`MediaLibraryTest : on 006 failed, error: ${error}`);
...
@@ -334,9 +332,9 @@ export default function mediaLibraryTestPromiseOnOffTest(abilityContext) {
...
@@ -334,9 +332,9 @@ export default function mediaLibraryTestPromiseOnOffTest(abilityContext) {
it('SUB_MEDIA_MEDIALIBRARY_PROMISE_OFF_005', 0, async function (done) {
it('SUB_MEDIA_MEDIALIBRARY_PROMISE_OFF_005', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_PROMISE_OFF_005'
let testNum = 'SUB_MEDIA_MEDIALIBRARY_PROMISE_OFF_005'
try {
try {
let co
nu
t = 0;
let co
un
t = 0;
media.on('albumChange', () => {
media.on('albumChange', () => {
co
nu
t++;
co
un
t++;
});
});
await sleep(300)
await sleep(300)
media.off('albumChange');
media.off('albumChange');
...
@@ -352,7 +350,7 @@ export default function mediaLibraryTestPromiseOnOffTest(abilityContext) {
...
@@ -352,7 +350,7 @@ export default function mediaLibraryTestPromiseOnOffTest(abilityContext) {
await sleep(300)
await sleep(300)
album.albumName = oldName;
album.albumName = oldName;
await album.commitModify();
await album.commitModify();
expect(co
nu
t).assertEqual(0);
expect(co
un
t).assertEqual(0);
done();
done();
} catch (error) {
} catch (error) {
console.info(`${testNum}:: error :${error}`);
console.info(`${testNum}:: error :${error}`);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录