提交 b7b8f238 编写于 作者: Y yangbo

fetchResult<Album>

Signed-off-by: Nyangbo <yangbo258@h-partners.com>
上级 ca568c00
...@@ -111,8 +111,8 @@ const albumFetchOps = function (testNum, path, albumName) { ...@@ -111,8 +111,8 @@ const albumFetchOps = function (testNum, path, albumName) {
const checkPresetsAssets = async function (userfilemgr, hapName) { const checkPresetsAssets = async function (userfilemgr, hapName) {
console.info('checkPresetsAssets start') console.info('checkPresetsAssets start')
let albumList = await userfilemgr.getAlbums([IMAGE_TYPE, VIDEO_TYPE, AUDIO_TYPE], allFetchOp()); let fetchAlbumResult = await userfilemgr.getAlbums([IMAGE_TYPE, VIDEO_TYPE, AUDIO_TYPE], allFetchOp());
let albumsCount = albumList.length; let albumsCount = fetchAlbumResult.getCount();
let fetchFileResult = await userfilemgr.getFileAssets([IMAGE_TYPE, VIDEO_TYPE, AUDIO_TYPE], let fetchFileResult = await userfilemgr.getFileAssets([IMAGE_TYPE, VIDEO_TYPE, AUDIO_TYPE],
allFetchOp()); allFetchOp());
let assetsCount = await fetchFileResult.getCount(); let assetsCount = await fetchFileResult.getCount();
...@@ -124,7 +124,7 @@ const checkPresetsAssets = async function (userfilemgr, hapName) { ...@@ -124,7 +124,7 @@ const checkPresetsAssets = async function (userfilemgr, hapName) {
const checkAssetsCount = async function (done, testNum, fetchFileResult, expectCount) { const checkAssetsCount = async function (done, testNum, fetchFileResult, expectCount) {
if (!fetchFileResult) { if (!fetchFileResult) {
console.info(`${testNum}:: fetchFileResult error:`); console.info(`${testNum}:: fetchFileResult is undefined`);
expect(false).assertTrue(); expect(false).assertTrue();
done(); done();
return false return false
...@@ -138,22 +138,6 @@ const checkAssetsCount = async function (done, testNum, fetchFileResult, expectC ...@@ -138,22 +138,6 @@ const checkAssetsCount = async function (done, testNum, fetchFileResult, expectC
return count == expectCount; return count == expectCount;
} }
const checkAlbumsCount = function (done, testNum, albumList, expectCount) {
if (!Array.isArray(albumList)) {
console.info(`${testNum}:: albumList error:`);
expect(false).assertTrue();
done();
return false
}
let albumsCount = albumList.length;
if (albumsCount != expectCount) {
console.info(`${testNum}:: albumsCount: expectCount - ${albumsCount} : ${expectCount}`);
expect(albumsCount).assertEqual(expectCount);
done();
}
return albumsCount == expectCount;
}
const getPermission = async function (name = 'ohos.acts.multimedia.userfilemgr') { const getPermission = async function (name = 'ohos.acts.multimedia.userfilemgr') {
console.info('getPermission start', name) console.info('getPermission start', name)
let appInfo = await bundle.getApplicationInfo('ohos.acts.multimedia.userfilemgr', 0, 100); let appInfo = await bundle.getApplicationInfo('ohos.acts.multimedia.userfilemgr', 0, 100);
...@@ -203,6 +187,5 @@ export { ...@@ -203,6 +187,5 @@ export {
albumFetchOps, albumFetchOps,
checkPresetsAssets, checkPresetsAssets,
checkAssetsCount, checkAssetsCount,
checkAlbumsCount,
isNum, isNum,
}; };
\ No newline at end of file
...@@ -23,7 +23,7 @@ import { ...@@ -23,7 +23,7 @@ import {
AUDIO_TYPE, AUDIO_TYPE,
albumFetchOps, albumFetchOps,
checkPresetsAssets, checkPresetsAssets,
checkAlbumsCount, checkAssetsCount,
getPermission, getPermission,
} from '../../../../../../common'; } from '../../../../../../common';
...@@ -49,17 +49,16 @@ export default function albumCommitModifyCallback(abilityContext) { ...@@ -49,17 +49,16 @@ export default function albumCommitModifyCallback(abilityContext) {
const albumCommitModify = async function (done, testNum, media_type, fetchOp, expectAlbumCount) { const albumCommitModify = async function (done, testNum, media_type, fetchOp, expectAlbumCount) {
try { try {
const albumList = await userfile_mgr.getAlbums(media_type, fetchOp); const fetchAlbumResult = await userfile_mgr.getAlbums(media_type, fetchOp);
const albumCountPass = await checkAlbumsCount(done, testNum, albumList, expectAlbumCount); const albumCountPass = await checkAssetsCount(done, testNum, fetchAlbumResult, expectAlbumCount);
if (!albumCountPass) return; if (!albumCountPass) return;
const album = albumList[0]; const album = await fetchAlbumResult.getFirstObject();
const newName = 'albumName' + media_type.toString(); const newName = 'albumName' + media_type.toString();
album.albumName = newName; album.albumName = newName;
album.commitModify(async () => { album.commitModify(async () => {
expect(true).assertTrue(); expect(true).assertTrue();
done(); done();
}); });
} catch (error) { } catch (error) {
console.info(`${testNum}, failed error: ${error}`) console.info(`${testNum}, failed error: ${error}`)
expect(false).assertTrue(); expect(false).assertTrue();
......
...@@ -23,7 +23,7 @@ import { ...@@ -23,7 +23,7 @@ import {
AUDIO_TYPE, AUDIO_TYPE,
albumFetchOps, albumFetchOps,
checkPresetsAssets, checkPresetsAssets,
checkAlbumsCount, checkAssetsCount,
getPermission, getPermission,
} from '../../../../../../common'; } from '../../../../../../common';
...@@ -49,10 +49,10 @@ export default function albumCommitModifyPromise(abilityContext) { ...@@ -49,10 +49,10 @@ export default function albumCommitModifyPromise(abilityContext) {
const albumCommitModify = async function (done, testNum, media_type, fetchOp, expectAlbumCount) { const albumCommitModify = async function (done, testNum, media_type, fetchOp, expectAlbumCount) {
try { try {
const albumList = await userfile_mgr.getAlbums(media_type, fetchOp); const fetchAlbumResult = await userfile_mgr.getAlbums(media_type, fetchOp);
const albumCountPass = await checkAlbumsCount(done, testNum, albumList, expectAlbumCount); const albumCountPass = await checkAssetsCount(done, testNum, fetchAlbumResult, expectAlbumCount);
if (!albumCountPass) return; if (!albumCountPass) return;
const album = albumList[0]; const album = await fetchAlbumResult.getFirstObject();
const newName = 'albumName' + media_type.toString(); const newName = 'albumName' + media_type.toString();
album.albumName = newName; album.albumName = newName;
await album.commitModify(); await album.commitModify();
......
...@@ -24,7 +24,7 @@ import { ...@@ -24,7 +24,7 @@ import {
allFetchOp, allFetchOp,
albumFetchOps, albumFetchOps,
checkPresetsAssets, checkPresetsAssets,
checkAlbumsCount, checkAssetsCount,
} from '../../../../../../common'; } from '../../../../../../common';
export default function albumGetFileAssetsCallback(abilityContext) { export default function albumGetFileAssetsCallback(abilityContext) {
...@@ -47,14 +47,13 @@ export default function albumGetFileAssetsCallback(abilityContext) { ...@@ -47,14 +47,13 @@ export default function albumGetFileAssetsCallback(abilityContext) {
const checkAlbumAssetsCount = async function (done, testNum, media_type, fetchOp, expectAssetsCount, expectAlbumCount = 1) { const checkAlbumAssetsCount = async function (done, testNum, media_type, fetchOp, expectAssetsCount, expectAlbumCount = 1) {
try { try {
const albumList = await userfile_mgr.getAlbums(media_type, fetchOp); const fetchAlbumResult = await userfile_mgr.getAlbums(media_type, fetchOp);
// check album length const albumCountPass = await checkAssetsCount(done, testNum, fetchAlbumResult, expectAlbumCount);
const albumCountPass = await checkAlbumsCount(done, testNum, albumList, expectAlbumCount);
if (!albumCountPass) return; if (!albumCountPass) return;
const album = albumList[0]; const album = await fetchAlbumResult.getFirstObject();
album.getFileAssets(media_type, allFetchOp(), (error, fetchFileResult) => { album.getFileAssets(media_type, allFetchOp(), (error, fetchFileResult) => {
if (error != undefined) { if (error != undefined) {
console.info(`${testNum} fetchFileResult error: ${error}`); console.info(`${testNum} getFileAssets error: ${error}`);
expect(false).assertTrue(); expect(false).assertTrue();
done(); done();
return; return;
......
...@@ -26,7 +26,7 @@ import { ...@@ -26,7 +26,7 @@ import {
allFetchOp, allFetchOp,
albumFetchOps, albumFetchOps,
checkPresetsAssets, checkPresetsAssets,
checkAlbumsCount, checkAssetsCount,
} from '../../../../../../common'; } from '../../../../../../common';
export default function albumGetFileAssetsPromise(abilityContext) { export default function albumGetFileAssetsPromise(abilityContext) {
...@@ -56,11 +56,10 @@ export default function albumGetFileAssetsPromise(abilityContext) { ...@@ -56,11 +56,10 @@ export default function albumGetFileAssetsPromise(abilityContext) {
const checkAlbumAssetsCount = async function (done, testNum, media_type, fetchOp, expectAssetsCount, expectAlbumCount = 1) { const checkAlbumAssetsCount = async function (done, testNum, media_type, fetchOp, expectAssetsCount, expectAlbumCount = 1) {
try { try {
const albumList = await userfile_mgr.getAlbums(media_type, fetchOp); const fetchAlbumResult = await userfile_mgr.getAlbums(media_type, fetchOp);
// check album length const albumCountPass = await checkAssetsCount(done, testNum, fetchAlbumResult, expectAlbumCount);
const albumCountPass = await checkAlbumsCount(done, testNum, albumList, expectAlbumCount);
if (!albumCountPass) return; if (!albumCountPass) return;
const album = albumList[0]; const album = await fetchAlbumResult.getFirstObject();
let op: userfile_manager.MediaFetchOptions = allFetchOp(); let op: userfile_manager.MediaFetchOptions = allFetchOp();
let fetchFileResult = await album.getFileAssets(media_type, op); let fetchFileResult = await album.getFileAssets(media_type, op);
if (fetchFileResult == undefined) { if (fetchFileResult == undefined) {
......
...@@ -24,7 +24,7 @@ import { ...@@ -24,7 +24,7 @@ import {
allFetchOp, allFetchOp,
albumFetchOps, albumFetchOps,
checkPresetsAssets, checkPresetsAssets,
checkAlbumsCount, checkAssetsCount,
getPermission, getPermission,
isNum, isNum,
} from '../../../../../../common'; } from '../../../../../../common';
...@@ -89,17 +89,17 @@ export default function getAlbumsCallbackTest(abilityContext) { ...@@ -89,17 +89,17 @@ export default function getAlbumsCallbackTest(abilityContext) {
} }
const checkAlbumInfo = async function (done, testNum, media_type, fetchOp, relativePaths) { const checkAlbumInfo = async function (done, testNum, media_type, fetchOp, relativePaths) {
try { try {
userfile_mgr.getAlbums(media_type, fetchOp, async (err, albumList) => { userfile_mgr.getAlbums(media_type, fetchOp, async (err, fetchAlbumResult) => {
if(err) { if(err) {
console.info(`${testNum}, err: ${err}`) console.info(`${testNum} getAlbums err: ${err}`)
expect(false).assertTrue(); expect(false).assertTrue();
done(); done();
return; return;
} }
let expectAlbumCount = 1; let expectAlbumCount = 1;
const albumCountPass = await checkAlbumsCount(done, testNum, albumList, expectAlbumCount); const albumCountPass = await checkAssetsCount(done, testNum, fetchAlbumResult, expectAlbumCount);
if (!albumCountPass) return; if (!albumCountPass) return;
const album = albumList[0]; const album = fetchAlbumResult.getFirstObject();
checkProps(done, testNum, album, relativePaths); checkProps(done, testNum, album, relativePaths);
done(); done();
}); });
...@@ -171,7 +171,7 @@ export default function getAlbumsCallbackTest(abilityContext) { ...@@ -171,7 +171,7 @@ export default function getAlbumsCallbackTest(abilityContext) {
try { try {
let media_type = [-1]; let media_type = [-1];
let currentFetchOp = allFetchOp(); let currentFetchOp = allFetchOp();
userfile_mgr.getAlbums(media_type, currentFetchOp, async (err, albumList) => { userfile_mgr.getAlbums(media_type, currentFetchOp, async (err, fetchAlbumResult) => {
console.info(`${testNum}, err: ${err}`); console.info(`${testNum}, err: ${err}`);
if (err != undefined) { if (err != undefined) {
expect(true).assertTrue(); expect(true).assertTrue();
......
...@@ -24,7 +24,7 @@ import { ...@@ -24,7 +24,7 @@ import {
allFetchOp, allFetchOp,
albumFetchOps, albumFetchOps,
checkPresetsAssets, checkPresetsAssets,
checkAlbumsCount, checkAssetsCount,
} from '../../../../../../common'; } from '../../../../../../common';
export default function getAlbumsPromiseTest(abilityContext) { export default function getAlbumsPromiseTest(abilityContext) {
...@@ -84,10 +84,10 @@ export default function getAlbumsPromiseTest(abilityContext) { ...@@ -84,10 +84,10 @@ export default function getAlbumsPromiseTest(abilityContext) {
} }
const checkAlbumInfo = async function (done, testNum, media_type, fetchOp, relativePaths, expectAlbumCount = 1) { const checkAlbumInfo = async function (done, testNum, media_type, fetchOp, relativePaths, expectAlbumCount = 1) {
try { try {
const albumList = await userfile_mgr.getAlbums(media_type, fetchOp); const fetchAlbumResult = await userfile_mgr.getAlbums(media_type, fetchOp);
const albumCountPass = await checkAlbumsCount(done, testNum, albumList, expectAlbumCount); const albumCountPass = await checkAssetsCount(done, testNum, fetchAlbumResult, expectAlbumCount);
if (!albumCountPass) return; if (!albumCountPass) return;
const album = albumList[0]; const album = fetchAlbumResult.getFirstObject();
checkProps(done, testNum, album, relativePaths); checkProps(done, testNum, album, relativePaths);
done(); done();
} catch (error) { } catch (error) {
......
...@@ -77,8 +77,8 @@ export default function fileAssetTrashCallbackTest(abilityContext) { ...@@ -77,8 +77,8 @@ export default function fileAssetTrashCallbackTest(abilityContext) {
let count = databaseFetchFileResult.getCount(); let count = databaseFetchFileResult.getCount();
//album info //album info
if (!noAlbum) { if (!noAlbum) {
let albumList = await userfile_mgr.getAlbums(media_type, ablumFetchOps); let fetchAlbumResult = await userfile_mgr.getAlbums(media_type, ablumFetchOps);
let album = albumList[0]; let album = await fetchAlbumResult.getFirstObject();
let op: userfile_manager.MediaFetchOptions = allFetchOp(); let op: userfile_manager.MediaFetchOptions = allFetchOp();
let albumFetchFileResult = await album.getFileAssets(media_type, op); let albumFetchFileResult = await album.getFileAssets(media_type, op);
let albumFilesCount = albumFetchFileResult.getCount(); let albumFilesCount = albumFetchFileResult.getCount();
...@@ -110,8 +110,8 @@ export default function fileAssetTrashCallbackTest(abilityContext) { ...@@ -110,8 +110,8 @@ export default function fileAssetTrashCallbackTest(abilityContext) {
expect(databaseCount).assertEqual(count - 1); expect(databaseCount).assertEqual(count - 1);
//album info //album info
if (!noAlbum) { if (!noAlbum) {
let albumList = await userfile_mgr.getAlbums(media_type, ablumFetchOps); let fetchAlbumResult = await userfile_mgr.getAlbums(media_type, ablumFetchOps);
let album = albumList[0]; let album = await fetchAlbumResult.getFirstObject();
let op: userfile_manager.MediaFetchOptions = allFetchOp(); let op: userfile_manager.MediaFetchOptions = allFetchOp();
let albumFetchFileResult = await album.getFileAssets(media_type, op); let albumFetchFileResult = await album.getFileAssets(media_type, op);
let albumFilesCount = albumFetchFileResult.getCount(); let albumFilesCount = albumFetchFileResult.getCount();
...@@ -160,8 +160,8 @@ export default function fileAssetTrashCallbackTest(abilityContext) { ...@@ -160,8 +160,8 @@ export default function fileAssetTrashCallbackTest(abilityContext) {
expect(databaseCount).assertEqual(count); expect(databaseCount).assertEqual(count);
//album info //album info
if (!noAlbum) { if (!noAlbum) {
let albumList = await userfile_mgr.getAlbums(media_type, ablumFetchOps); let fetchAlbumResult = await userfile_mgr.getAlbums(media_type, ablumFetchOps);
let album = albumList[0]; let album = await fetchAlbumResult.getFirstObject();
let op: userfile_manager.MediaFetchOptions = allFetchOp(); let op: userfile_manager.MediaFetchOptions = allFetchOp();
let albumFetchFileResult = await album.getFileAssets(media_type, op); let albumFetchFileResult = await album.getFileAssets(media_type, op);
let albumFilesCount = albumFetchFileResult.getCount(); let albumFilesCount = albumFetchFileResult.getCount();
......
...@@ -70,8 +70,8 @@ export default function fileAssetTrashPromiseTest(abilityContext) { ...@@ -70,8 +70,8 @@ export default function fileAssetTrashPromiseTest(abilityContext) {
let count = databaseFetchFileResult.getCount(); let count = databaseFetchFileResult.getCount();
//album info //album info
if (!noAlbum) { if (!noAlbum) {
let albumList = await userfile_mgr.getAlbums(media_type, ablumFetchOps); let fetchAlbumResult = await userfile_mgr.getAlbums(media_type, ablumFetchOps);
let album = albumList[0]; let album = await fetchAlbumResult.getFirstObject();
let op: userfile_manager.MediaFetchOptions = allFetchOp(); let op: userfile_manager.MediaFetchOptions = allFetchOp();
let albumFetchFileResult = await album.getFileAssets(media_type, op); let albumFetchFileResult = await album.getFileAssets(media_type, op);
let albumFilesCount = albumFetchFileResult.getCount(); let albumFilesCount = albumFetchFileResult.getCount();
...@@ -88,8 +88,8 @@ export default function fileAssetTrashPromiseTest(abilityContext) { ...@@ -88,8 +88,8 @@ export default function fileAssetTrashPromiseTest(abilityContext) {
expect(databaseCount).assertEqual(count - 1); expect(databaseCount).assertEqual(count - 1);
//album info //album info
if (!noAlbum) { if (!noAlbum) {
var albumList = await userfile_mgr.getAlbums(media_type, ablumFetchOps); var fetchAlbumResult = await userfile_mgr.getAlbums(media_type, ablumFetchOps);
var album = albumList[0]; var album = await fetchAlbumResult.getFirstObject();
let op: userfile_manager.MediaFetchOptions = allFetchOp(); let op: userfile_manager.MediaFetchOptions = allFetchOp();
var albumFetchFileResult = await album.getFileAssets(media_type, op); var albumFetchFileResult = await album.getFileAssets(media_type, op);
var albumFilesCount = albumFetchFileResult.getCount(); var albumFilesCount = albumFetchFileResult.getCount();
...@@ -116,8 +116,8 @@ export default function fileAssetTrashPromiseTest(abilityContext) { ...@@ -116,8 +116,8 @@ export default function fileAssetTrashPromiseTest(abilityContext) {
expect(databaseCount).assertEqual(count); expect(databaseCount).assertEqual(count);
//album info //album info
if (!noAlbum) { if (!noAlbum) {
let albumList = await userfile_mgr.getAlbums(media_type, ablumFetchOps); let fetchAlbumResult = await userfile_mgr.getAlbums(media_type, ablumFetchOps);
let album = albumList[0]; let album = await fetchAlbumResult.getFirstObject();
let op: userfile_manager.MediaFetchOptions = allFetchOp(); let op: userfile_manager.MediaFetchOptions = allFetchOp();
let albumFetchFileResult = await album.getFileAssets(media_type, op); let albumFetchFileResult = await album.getFileAssets(media_type, op);
let albumFilesCount = albumFetchFileResult.getCount(); let albumFilesCount = albumFetchFileResult.getCount();
......
...@@ -82,7 +82,7 @@ export default function userFileMgrNoPermissionCallback(abilityContext) { ...@@ -82,7 +82,7 @@ export default function userFileMgrNoPermissionCallback(abilityContext) {
const getAlbumsTest = async function (done, testNum, media_type) { const getAlbumsTest = async function (done, testNum, media_type) {
try { try {
await userfile_mgr.getAlbums(media_type, allFetchOp(), async (err, albumList) => { await userfile_mgr.getAlbums(media_type, allFetchOp(), async (err, fetchAlbumResult) => {
if (err != undefined) { if (err != undefined) {
console.info(`${testNum}, err: ${err}`); console.info(`${testNum}, err: ${err}`);
expect(true).assertTrue(); expect(true).assertTrue();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册