未验证 提交 3a9edf57 编写于 作者: O openharmony_ci 提交者: Gitee

!5037 Supplementary test cases

Merge pull request !5037 from caochuan/master
......@@ -41,10 +41,10 @@ group("multimedia") {
"medialibrary/mediaLibrary_favorite:mediaLibrary_favorite_hap",
"medialibrary/mediaLibrary_file:mediaLibrary_file_hap",
"medialibrary/mediaLibrary_fileAsset:mediaLibrary_fileAsset_hap",
"medialibrary/mediaLibrary_fileAssetUri:mediaLibrary_fileAssetUri_hap",
"medialibrary/mediaLibrary_fileKey:mediaLibrary_fileKey_hap",
"medialibrary/mediaLibrary_fileResult:mediaLibrary_fileResult_hap",
"medialibrary/mediaLibrary_getThumbnail:mediaLibrary_getThumbnail_hap",
"medialibrary/mediaLibrary_mediafetchoptions:mediaLibrary_mediafetchoptions_hap",
]
} else {
deps = [
......
......@@ -48,37 +48,47 @@ const allFetchOp = function (others = {}) {
};
}
const fetchOps = function (path, type, others = {}) {
return {
const fetchOps = function (testNum, path, type, others = {}) {
let ops = {
selections: FILEKEY.RELATIVE_PATH + '= ? AND ' + FILEKEY.MEDIA_TYPE + '=?',
selectionArgs: [path, type.toString()],
...others
};
console.info(`${testNum}: fetchOps${JSON.stringify(ops)}`)
return ops
}
const nameFetchOps = function (path, title, type) {
return {
const nameFetchOps = function (testNum, path, title, type) {
let ops = {
selections: FILEKEY.RELATIVE_PATH + '= ? AND ' + FILEKEY.TITLE + '= ? AND ' + FILEKEY.MEDIA_TYPE + '=?',
selectionArgs: [path, title, type.toString()],
};
console.info(`${testNum}: fetchOps${JSON.stringify(ops)}`)
return ops
}
const idFetchOps = function (albumId) {
return {
const idFetchOps = function (testNum, albumId) {
let ops = {
selections: FILEKEY.ALBUM_ID + '= ?',
selectionArgs: [albumId + ''],
};
console.info(`${testNum}: fetchOps${JSON.stringify(ops)}`)
return ops
}
const albumFetchOps = function (path, albumName, type, others = { order: FILEKEY.DATE_ADDED + " DESC", }) {
return {
const albumFetchOps = function (testNum, path, albumName, type,
others = { order: FILEKEY.DATE_ADDED + " DESC", }) {
let ops = {
selections: RELATIVE_PATH + '= ? AND ' + ALBUM_NAME + '= ? AND ' + MEDIA_TYPE + '= ?',
selectionArgs: [path, albumName, type.toString()],
...others
};
console.info(`${testNum}: fetchOps${JSON.stringify(ops)}`)
return ops
}
// albums of two resource types
const albumTwoTypesFetchOps = function (paths, albumName, types, others = { order: FILEKEY.DATE_ADDED + " DESC", }) {
const albumTwoTypesFetchOps = function (testNum, paths, albumName, types,
others = { order: FILEKEY.DATE_ADDED + " DESC", }) {
try {
let ops = {
selections: '(' + RELATIVE_PATH + '= ? or ' +
......@@ -89,6 +99,7 @@ const albumTwoTypesFetchOps = function (paths, albumName, types, others = { orde
selectionArgs: [paths[0], paths[1], albumName, types[0].toString(), types[1].toString()],
...others
};
console.info(`${testNum}: fetchOps${JSON.stringify(ops)}`)
return ops
} catch (error) {
console.info(`albumTwoTypesFetchOps :: error: ${error}`);
......@@ -96,7 +107,7 @@ const albumTwoTypesFetchOps = function (paths, albumName, types, others = { orde
}
// albums of three resource types
const albumThreeTypesFetchOps = function (paths, albumName, types, others = { order: FILEKEY.DATE_ADDED, }) {
const albumThreeTypesFetchOps = function (testNum, paths, albumName, types, others = { order: FILEKEY.DATE_ADDED, }) {
try {
let ops = {
selections: '(' + RELATIVE_PATH + '= ? or ' +
......@@ -110,6 +121,7 @@ const albumThreeTypesFetchOps = function (paths, albumName, types, others = { or
types[0].toString(), types[1].toString(), types[2].toString()],
...others
};
console.info(`${testNum}: fetchOps${JSON.stringify(ops)}`)
return ops
} catch (error) {
console.info(`albumThreeTypesFetchOps :: error: ${error}`);
......@@ -122,7 +134,7 @@ const checkPresetsAssets = async function (media, hapName) {
let albumsCount = albumList.length;
let fetchFileResult = await media.getFileAssets(allFetchOp());
let assetsCount = await fetchFileResult.getCount();
console.info(`${hapName}:: assetsCount: ${assetsCount} albumsCount: ${albumsCount}
console.info(`${hapName}:: assetsCount: ${assetsCount} albumsCount: ${albumsCount},
presetsassetsCount: ${presetsCount[hapName].assetsCount}
presetsalbumsCount: ${presetsCount[hapName].albumsCount}`);
console.info('checkPresetsAssets end')
......@@ -137,8 +149,7 @@ const checkAssetsCount = async function (done, testNum, fetchFileResult, expectC
}
let count = await fetchFileResult.getCount();
if (count != expectCount) {
console.info(`${testNum}:: count: ${count}`);
console.info(`${testNum}:: expectCount: ${expectCount}`);
console.info(`${testNum}:: count:expectCount - ${count} : ${expectCount}`);
expect(count).assertEqual(expectCount);
done();
}
......@@ -154,9 +165,7 @@ const checkAlbumsCount = function (done, testNum, albumList, expectCount) {
}
let albumsCount = albumList.length;
if (albumsCount != expectCount) {
console.info(`${testNum}:: albumsCount: ${albumsCount}`);
console.info(`${testNum}:: expectCount: ${expectCount}`);
console.info(`${testNum} failed:: albums length error`);
console.info(`${testNum}:: albumsCount: expectCount - ${albumsCount} : ${expectCount}`);
expect(albumsCount).assertEqual(expectCount);
done();
}
......
......@@ -34,14 +34,20 @@ export default function albumGetFileAssetsCallbackTest(abilityContext) {
describe('albumGetFileAssetsCallbackTest', function () {
const media = mediaLibrary.getMediaLibrary(abilityContext);
beforeAll(async function () {
console.info('beforeAll case');
await getPermission();
await checkPresetsAssets(media, 'ActsMediaLibraryAlbum');
});
beforeEach(function () { });
beforeEach(function () {
console.info('beforeEach case');
});
afterEach(async function () {
console.info('afterEach case');
await sleep()
});
afterAll(function () { });
afterAll(function () {
console.info('afterAll case');
});
const abnormalFetchOp = {
selections: 'date_added < 0',
......@@ -51,8 +57,6 @@ export default function albumGetFileAssetsCallbackTest(abilityContext) {
const checkAlbumAssetsCount = async function (done, testNum, fetchOp, expectAssetsCount, expectAlbumCount = 1) {
try {
console.info(`${testNum}, fetchOp: ${JSON.stringify(fetchOp)}`)
const albumList = await media.getAlbums(fetchOp);
// check album length
const albumCountPass = await checkAlbumsCount(done, testNum, albumList, expectAlbumCount);
......@@ -101,9 +105,35 @@ export default function albumGetFileAssetsCallbackTest(abilityContext) {
}
}
const checkAlbumAssetsNoOps = async function (done, testNum, fetchOp, expectAssetsCount, expectAlbumCount = 1) {
try {
const albumList = await media.getAlbums(fetchOp);
// check album length
const albumCountPass = await checkAlbumsCount(done, testNum, albumList, expectAlbumCount);
if (!albumCountPass) return;
const album = albumList[0];
album.getFileAssets(async (err, fetchFileResult) => {
if (fetchFileResult == undefined || err) {
console.info(`${testNum} fetchFileResult undefined or error, error: ${err}`)
expect(false).assertTrue();
done();
return;
}
console.info(`${testNum}, getCount:expectAssetsCount - ${fetchFileResult.getCount()} : ${expectAssetsCount}`)
expect(fetchFileResult.getCount()).assertEqual(expectAssetsCount);
done();
});
} catch (error) {
console.info(`${testNum}, error: ${error}`)
expect(false).assertTrue();
done();
}
}
const abnormalAlbumAssetsCount = async function (done, testNum, fetchOp, expectAssetsCount, expectAlbumCount = 1) {
try {
console.info(`${testNum}, fetchOp: ${JSON.stringify(fetchOp)}`)
const albumList = await media.getAlbums(fetchOp);
// check album length
const albumCountPass = await checkAlbumsCount(done, testNum, albumList, expectAlbumCount);
......@@ -138,7 +168,7 @@ export default function albumGetFileAssetsCallbackTest(abilityContext) {
it('SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_CALLBACK_001_01', 0, async function (done) {
const testNum = 'SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_CALLBACK_001_01';
let assetsCount = 3;
let currentFetchOp = albumFetchOps('Pictures/', 'Static', IMAGE_TYPE)
let currentFetchOp = albumFetchOps(testNum, 'Pictures/', 'Static', IMAGE_TYPE)
await checkAlbumAssetsCount(done, testNum, currentFetchOp, assetsCount)
});
......@@ -153,7 +183,7 @@ export default function albumGetFileAssetsCallbackTest(abilityContext) {
it('SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_CALLBACK_001_02', 0, async function (done) {
const testNum = 'SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_CALLBACK_001_02';
let assetsCount = 3;
let currentFetchOp = albumFetchOps('Audios/', 'Static', AUDIO_TYPE)
let currentFetchOp = albumFetchOps(testNum, 'Audios/', 'Static', AUDIO_TYPE)
await checkAlbumAssetsCount(done, testNum, currentFetchOp, assetsCount)
});
......@@ -168,7 +198,7 @@ export default function albumGetFileAssetsCallbackTest(abilityContext) {
it('SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_CALLBACK_001_03', 0, async function (done) {
const testNum = 'SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_CALLBACK_001_03';
let assetsCount = 3;
let currentFetchOp = albumFetchOps('Videos/', 'Static', VIDEO_TYPE)
let currentFetchOp = albumFetchOps(testNum, 'Videos/', 'Static', VIDEO_TYPE)
await checkAlbumAssetsCount(done, testNum, currentFetchOp, assetsCount)
});
......@@ -183,7 +213,7 @@ export default function albumGetFileAssetsCallbackTest(abilityContext) {
it('SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_CALLBACK_001_04', 0, async function (done) {
const testNum = 'SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_CALLBACK_001_04';
let assetsCount = 3;
let currentFetchOp = albumTwoTypesFetchOps(['Pictures/', 'Videos/'], 'Static', [IMAGE_TYPE, VIDEO_TYPE])
let currentFetchOp = albumTwoTypesFetchOps(testNum, ['Pictures/', 'Videos/'], 'Static', [IMAGE_TYPE, VIDEO_TYPE])
let albumCount = 2;
await checkAlbumAssetsCount(done, testNum, currentFetchOp, assetsCount, albumCount)
});
......@@ -199,7 +229,7 @@ export default function albumGetFileAssetsCallbackTest(abilityContext) {
it('SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_CALLBACK_001_05', 0, async function (done) {
const testNum = 'SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_CALLBACK_001_05';
let assetsCount = 3;
let currentFetchOp = albumTwoTypesFetchOps(['Pictures/', 'Audios/'], 'Static', [IMAGE_TYPE, AUDIO_TYPE])
let currentFetchOp = albumTwoTypesFetchOps(testNum, ['Pictures/', 'Audios/'], 'Static', [IMAGE_TYPE, AUDIO_TYPE])
let albumCount = 2;
await checkAlbumAssetsCount(done, testNum, currentFetchOp, assetsCount, albumCount)
});
......@@ -215,7 +245,7 @@ export default function albumGetFileAssetsCallbackTest(abilityContext) {
it('SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_CALLBACK_001_06', 0, async function (done) {
const testNum = 'SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_CALLBACK_001_06';
let assetsCount = 3;
let currentFetchOp = albumTwoTypesFetchOps(['Videos/', 'Audios/'], 'Static', [VIDEO_TYPE, AUDIO_TYPE])
let currentFetchOp = albumTwoTypesFetchOps(testNum, ['Videos/', 'Audios/'], 'Static', [VIDEO_TYPE, AUDIO_TYPE])
let albumCount = 2;
await checkAlbumAssetsCount(done, testNum, currentFetchOp, assetsCount, albumCount)
});
......@@ -231,7 +261,7 @@ export default function albumGetFileAssetsCallbackTest(abilityContext) {
it('SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_CALLBACK_001_07', 0, async function (done) {
const testNum = 'SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_CALLBACK_001_07';
let assetsCount = 3;
let currentFetchOp = albumThreeTypesFetchOps(['Pictures/', 'Videos/', 'Audios/'], 'Static', [IMAGE_TYPE, VIDEO_TYPE, AUDIO_TYPE])
let currentFetchOp = albumThreeTypesFetchOps(testNum, ['Pictures/', 'Videos/', 'Audios/'], 'Static', [IMAGE_TYPE, VIDEO_TYPE, AUDIO_TYPE])
let albumCount = 3;
await checkAlbumAssetsCount(done, testNum, currentFetchOp, assetsCount, albumCount)
});
......@@ -247,7 +277,7 @@ export default function albumGetFileAssetsCallbackTest(abilityContext) {
it('SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_CALLBACK_002_01', 0, async function (done) {
const testNum = 'SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_CALLBACK_002_01';
let assetsCount = 1;
let currentFetchOp = albumFetchOps('Pictures/', 'Static', IMAGE_TYPE)
let currentFetchOp = albumFetchOps(testNum, 'Pictures/', 'Static', IMAGE_TYPE)
await checkAlbumAssetsCount(done, testNum, currentFetchOp, assetsCount)
});
......@@ -262,7 +292,7 @@ export default function albumGetFileAssetsCallbackTest(abilityContext) {
it('SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_CALLBACK_002_02', 0, async function (done) {
const testNum = 'SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_CALLBACK_002_02';
let assetsCount = 1;
let currentFetchOp = albumFetchOps('Audios/', 'Static', AUDIO_TYPE)
let currentFetchOp = albumFetchOps(testNum, 'Audios/', 'Static', AUDIO_TYPE)
await checkAlbumAssetsCount(done, testNum, currentFetchOp, assetsCount)
});
......@@ -277,7 +307,7 @@ export default function albumGetFileAssetsCallbackTest(abilityContext) {
it('SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_CALLBACK_002_03', 0, async function (done) {
const testNum = 'SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_CALLBACK_002_03';
let assetsCount = 1;
let currentFetchOp = albumFetchOps('Videos/', 'Static', VIDEO_TYPE)
let currentFetchOp = albumFetchOps(testNum, 'Videos/', 'Static', VIDEO_TYPE)
await checkAlbumAssetsCount(done, testNum, currentFetchOp, assetsCount)
});
......@@ -292,7 +322,7 @@ export default function albumGetFileAssetsCallbackTest(abilityContext) {
it('SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_CALLBACK_002_04', 0, async function (done) {
const testNum = 'SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_CALLBACK_002_04';
let assetsCount = 1;
let currentFetchOp = albumTwoTypesFetchOps(['Pictures/', 'Videos/'], 'Static', [IMAGE_TYPE, VIDEO_TYPE])
let currentFetchOp = albumTwoTypesFetchOps(testNum, ['Pictures/', 'Videos/'], 'Static', [IMAGE_TYPE, VIDEO_TYPE])
let albumCount = 2;
await checkAlbumAssetsCount(done, testNum, currentFetchOp, assetsCount, albumCount)
});
......@@ -308,7 +338,7 @@ export default function albumGetFileAssetsCallbackTest(abilityContext) {
it('SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_CALLBACK_002_05', 0, async function (done) {
const testNum = 'SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_CALLBACK_002_05';
let assetsCount = 1;
let currentFetchOp = albumTwoTypesFetchOps(['Pictures/', 'Audios/'], 'Static', [IMAGE_TYPE, AUDIO_TYPE],)
let currentFetchOp = albumTwoTypesFetchOps(testNum, ['Pictures/', 'Audios/'], 'Static', [IMAGE_TYPE, AUDIO_TYPE],)
let albumCount = 2;
await checkAlbumAssetsCount(done, testNum, currentFetchOp, assetsCount, albumCount)
});
......@@ -324,7 +354,7 @@ export default function albumGetFileAssetsCallbackTest(abilityContext) {
it('SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_CALLBACK_002_06', 0, async function (done) {
const testNum = 'SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_CALLBACK_002_06';
let assetsCount = 1;
let currentFetchOp = albumTwoTypesFetchOps(['Videos/', 'Audios/'], 'Static', [VIDEO_TYPE, AUDIO_TYPE])
let currentFetchOp = albumTwoTypesFetchOps(testNum, ['Videos/', 'Audios/'], 'Static', [VIDEO_TYPE, AUDIO_TYPE])
let albumCount = 2;
await checkAlbumAssetsCount(done, testNum, currentFetchOp, assetsCount, albumCount)
});
......@@ -340,7 +370,7 @@ export default function albumGetFileAssetsCallbackTest(abilityContext) {
it('SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_CALLBACK_002_07', 0, async function (done) {
const testNum = 'SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_CALLBACK_002_07';
let assetsCount = 1;
let currentFetchOp = albumThreeTypesFetchOps(['Pictures/', 'Videos/', 'Audios/'], 'Static',
let currentFetchOp = albumThreeTypesFetchOps(testNum, ['Pictures/', 'Videos/', 'Audios/'], 'Static',
[IMAGE_TYPE, VIDEO_TYPE, AUDIO_TYPE])
let albumCount = 3;
await checkAlbumAssetsCount(done, testNum, currentFetchOp, assetsCount, albumCount)
......@@ -357,7 +387,7 @@ export default function albumGetFileAssetsCallbackTest(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_CALLBACK_003_01', 0, async function (done) {
const testNum = 'SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_CALLBACK_003_01';
let currentFetchOp = albumFetchOps('Pictures/', 'Static', IMAGE_TYPE)
let currentFetchOp = albumFetchOps(testNum, 'Pictures/', 'Static', IMAGE_TYPE)
let assetsCount = 0;
await abnormalAlbumAssetsCount(done, testNum, currentFetchOp, assetsCount)
});
......@@ -372,7 +402,7 @@ export default function albumGetFileAssetsCallbackTest(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_CALLBACK_003_02', 0, async function (done) {
const testNum = 'SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_CALLBACK_003_02';
let currentFetchOp = albumFetchOps('Videos/', 'Static', VIDEO_TYPE)
let currentFetchOp = albumFetchOps(testNum, 'Videos/', 'Static', VIDEO_TYPE)
let assetsCount = 0;
await abnormalAlbumAssetsCount(done, testNum, currentFetchOp, assetsCount)
});
......@@ -387,9 +417,54 @@ export default function albumGetFileAssetsCallbackTest(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_CALLBACK_003_03', 0, async function (done) {
const testNum = 'SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_CALLBACK_003_03';
let currentFetchOp = albumFetchOps('Audios/', 'Static', AUDIO_TYPE)
let currentFetchOp = albumFetchOps(testNum, 'Audios/', 'Static', AUDIO_TYPE)
let assetsCount = 0;
await abnormalAlbumAssetsCount(done, testNum, currentFetchOp, assetsCount)
});
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_CALLBACK_004_01
* @tc.name : getFileAssets
* @tc.desc : Image type getFileAssets by no ops
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_CALLBACK_004_01', 0, async function (done) {
const testNum = 'SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_CALLBACK_004_01';
let assetsCount = 5;
let currentFetchOp = albumFetchOps(testNum, 'Pictures/', 'Static', IMAGE_TYPE)
await checkAlbumAssetsNoOps(done, testNum, currentFetchOp, assetsCount)
});
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_CALLBACK_004_02
* @tc.name : getFileAssets
* @tc.desc : Audios type getFileAssets by no ops
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_CALLBACK_004_02', 0, async function (done) {
const testNum = 'SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_CALLBACK_004_02';
let assetsCount = 5;
let currentFetchOp = albumFetchOps(testNum, 'Audios/', 'Static', AUDIO_TYPE)
await checkAlbumAssetsNoOps(done, testNum, currentFetchOp, assetsCount)
});
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_CALLBACK_004_03
* @tc.name : getFileAssets
* @tc.desc : Videos type getFileAssets by no ops
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_CALLBACK_004_03', 0, async function (done) {
const testNum = 'SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_CALLBACK_004_03';
let assetsCount = 5;
let currentFetchOp = albumFetchOps(testNum, 'Videos/', 'Static', VIDEO_TYPE)
await checkAlbumAssetsNoOps(done, testNum, currentFetchOp, assetsCount)
});
});
}
\ No newline at end of file
......@@ -20,7 +20,6 @@ import {
IMAGE_TYPE,
VIDEO_TYPE,
AUDIO_TYPE,
FILEKEY,
allFetchOp,
albumFetchOps,
albumTwoTypesFetchOps,
......@@ -33,14 +32,20 @@ export default function albumGetFileAssetsPromiseTest(abilityContext) {
describe('albumGetFileAssetsPromiseTest', function () {
const media = mediaLibrary.getMediaLibrary(abilityContext);
beforeAll(async function () {
console.info('beforeAll case');
await checkPresetsAssets(media, 'ActsMediaLibraryAlbum');
});
beforeEach(function () { });
beforeEach(function () {
console.info('beforeEach case');
});
afterEach(async function () {
console.info('afterEach case');
await sleep()
});
afterAll(function () { });
afterAll(function () {
console.info('afterAll case');
});
// Exception request
const abnormalFetchOp = {
selections: 'date_added < 0',
......@@ -50,18 +55,16 @@ export default function albumGetFileAssetsPromiseTest(abilityContext) {
const checkAlbumAssetsCount = async function (done, testNum, fetchOp, expectAssetsCount, expectAlbumCount = 1) {
try {
console.info(`${testNum}, fetchOp: ${JSON.stringify(fetchOp)}`)
const albumList = await media.getAlbums(fetchOp);
// check album length
const albumCountPass = await checkAlbumsCount(done, testNum, albumList, expectAlbumCount);
if (!albumCountPass) return;
// one asset type
let op:mediaLibrary.MediaFetchOptions =
let op: mediaLibrary.MediaFetchOptions =
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`)
......@@ -98,10 +101,33 @@ export default function albumGetFileAssetsPromiseTest(abilityContext) {
done();
}
}
const checkAlbumAssetsNoOps = async function (done, testNum, fetchOp, expectAssetsCount, expectAlbumCount = 1) {
try {
const albumList = await media.getAlbums(fetchOp);
// check album length
const albumCountPass = await checkAlbumsCount(done, testNum, albumList, expectAlbumCount);
if (!albumCountPass) return;
const album = albumList[0];
let fetchFileResult = await album.getFileAssets();
if (fetchFileResult == undefined) {
console.info(`${testNum} fetchFileResult undefined`)
expect(false).assertTrue();
done();
return;
}
console.info(`${testNum}, getCount:expectAssetsCount - ${fetchFileResult.getCount()} : ${expectAssetsCount}`)
expect(fetchFileResult.getCount()).assertEqual(expectAssetsCount);
done();
} catch (error) {
console.info(`${testNum}, error: ${error}`)
expect(false).assertTrue();
done();
}
}
const abnormalAlbumAssetsCount = async function (done, testNum, fetchOp, expectAssetsCount, expectAlbumCount = 1) {
try {
console.info(`${testNum}, fetchOp: ${JSON.stringify(fetchOp)}`)
const albumList = await media.getAlbums(fetchOp);
// check album length
const albumCountPass = await checkAlbumsCount(done, testNum, albumList, expectAlbumCount);
......@@ -135,7 +161,7 @@ export default function albumGetFileAssetsPromiseTest(abilityContext) {
it('SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_001_01', 0, async function (done) {
const testNum = 'SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_001_01';
let assetsCount = 3;
let currentFetchOp = albumFetchOps('Pictures/', 'Static', IMAGE_TYPE)
let currentFetchOp = albumFetchOps(testNum, 'Pictures/', 'Static', IMAGE_TYPE)
await checkAlbumAssetsCount(done, testNum, currentFetchOp, assetsCount)
});
......@@ -150,7 +176,7 @@ export default function albumGetFileAssetsPromiseTest(abilityContext) {
it('SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_001_02', 0, async function (done) {
const testNum = 'SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_001_02';
let assetsCount = 3;
let currentFetchOp = albumFetchOps('Audios/', 'Static', AUDIO_TYPE)
let currentFetchOp = albumFetchOps(testNum, 'Audios/', 'Static', AUDIO_TYPE)
await checkAlbumAssetsCount(done, testNum, currentFetchOp, assetsCount)
});
......@@ -165,7 +191,7 @@ export default function albumGetFileAssetsPromiseTest(abilityContext) {
it('SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_001_03', 0, async function (done) {
const testNum = 'SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_001_03';
let assetsCount = 3;
let currentFetchOp = albumFetchOps('Videos/', 'Static', VIDEO_TYPE)
let currentFetchOp = albumFetchOps(testNum, 'Videos/', 'Static', VIDEO_TYPE)
await checkAlbumAssetsCount(done, testNum, currentFetchOp, assetsCount)
});
......@@ -180,7 +206,7 @@ export default function albumGetFileAssetsPromiseTest(abilityContext) {
it('SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_001_04', 0, async function (done) {
const testNum = 'SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_001_04';
let assetsCount = 3;
let currentFetchOp = albumTwoTypesFetchOps(['Pictures/', 'Videos/'], 'Static', [IMAGE_TYPE, VIDEO_TYPE])
let currentFetchOp = albumTwoTypesFetchOps(testNum, ['Pictures/', 'Videos/'], 'Static', [IMAGE_TYPE, VIDEO_TYPE])
let albumCount = 2;
await checkAlbumAssetsCount(done, testNum, currentFetchOp, assetsCount, albumCount)
});
......@@ -196,7 +222,7 @@ export default function albumGetFileAssetsPromiseTest(abilityContext) {
it('SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_001_05', 0, async function (done) {
const testNum = 'SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_001_05';
let assetsCount = 3;
let currentFetchOp = albumTwoTypesFetchOps(['Pictures/', 'Audios/'], 'Static', [IMAGE_TYPE, AUDIO_TYPE])
let currentFetchOp = albumTwoTypesFetchOps(testNum, ['Pictures/', 'Audios/'], 'Static', [IMAGE_TYPE, AUDIO_TYPE])
let albumCount = 2;
await checkAlbumAssetsCount(done, testNum, currentFetchOp, assetsCount, albumCount)
});
......@@ -212,7 +238,7 @@ export default function albumGetFileAssetsPromiseTest(abilityContext) {
it('SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_001_06', 0, async function (done) {
const testNum = 'SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_001_06';
let assetsCount = 3;
let currentFetchOp = albumTwoTypesFetchOps(['Videos/', 'Audios/'], 'Static', [VIDEO_TYPE, AUDIO_TYPE])
let currentFetchOp = albumTwoTypesFetchOps(testNum, ['Videos/', 'Audios/'], 'Static', [VIDEO_TYPE, AUDIO_TYPE])
let albumCount = 2;
await checkAlbumAssetsCount(done, testNum, currentFetchOp, assetsCount, albumCount)
});
......@@ -228,7 +254,7 @@ export default function albumGetFileAssetsPromiseTest(abilityContext) {
it('SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_001_07', 0, async function (done) {
const testNum = 'SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_001_07';
let assetsCount = 3;
let currentFetchOp = albumThreeTypesFetchOps(['Pictures/', 'Videos/', 'Audios/'], 'Static', [IMAGE_TYPE, VIDEO_TYPE, AUDIO_TYPE])
let currentFetchOp = albumThreeTypesFetchOps(testNum, ['Pictures/', 'Videos/', 'Audios/'], 'Static', [IMAGE_TYPE, VIDEO_TYPE, AUDIO_TYPE])
let albumCount = 3;
await checkAlbumAssetsCount(done, testNum, currentFetchOp, assetsCount, albumCount)
});
......@@ -244,7 +270,7 @@ export default function albumGetFileAssetsPromiseTest(abilityContext) {
it('SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_002_01', 0, async function (done) {
const testNum = 'SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_002_01';
let assetsCount = 1;
let currentFetchOp = albumFetchOps('Pictures/', 'Static', IMAGE_TYPE)
let currentFetchOp = albumFetchOps(testNum, 'Pictures/', 'Static', IMAGE_TYPE)
await checkAlbumAssetsCount(done, testNum, currentFetchOp, assetsCount)
});
......@@ -259,7 +285,7 @@ export default function albumGetFileAssetsPromiseTest(abilityContext) {
it('SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_002_02', 0, async function (done) {
const testNum = 'SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_002_02';
let assetsCount = 1;
let currentFetchOp = albumFetchOps('Audios/', 'Static', AUDIO_TYPE)
let currentFetchOp = albumFetchOps(testNum, 'Audios/', 'Static', AUDIO_TYPE)
await checkAlbumAssetsCount(done, testNum, currentFetchOp, assetsCount)
});
......@@ -274,7 +300,7 @@ export default function albumGetFileAssetsPromiseTest(abilityContext) {
it('SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_002_03', 0, async function (done) {
const testNum = 'SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_002_03';
let assetsCount = 1;
let currentFetchOp = albumFetchOps('Videos/', 'Static', VIDEO_TYPE)
let currentFetchOp = albumFetchOps(testNum, 'Videos/', 'Static', VIDEO_TYPE)
await checkAlbumAssetsCount(done, testNum, currentFetchOp, assetsCount)
});
......@@ -289,7 +315,7 @@ export default function albumGetFileAssetsPromiseTest(abilityContext) {
it('SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_002_04', 0, async function (done) {
const testNum = 'SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_002_04';
let assetsCount = 1;
let currentFetchOp = albumTwoTypesFetchOps(['Pictures/', 'Videos/'], 'Static', [IMAGE_TYPE, VIDEO_TYPE])
let currentFetchOp = albumTwoTypesFetchOps(testNum, ['Pictures/', 'Videos/'], 'Static', [IMAGE_TYPE, VIDEO_TYPE])
let albumCount = 2;
await checkAlbumAssetsCount(done, testNum, currentFetchOp, assetsCount, albumCount)
});
......@@ -305,7 +331,7 @@ export default function albumGetFileAssetsPromiseTest(abilityContext) {
it('SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_002_05', 0, async function (done) {
const testNum = 'SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_002_05';
let assetsCount = 1;
let currentFetchOp = albumTwoTypesFetchOps(['Pictures/', 'Audios/'], 'Static', [IMAGE_TYPE, AUDIO_TYPE],)
let currentFetchOp = albumTwoTypesFetchOps(testNum, ['Pictures/', 'Audios/'], 'Static', [IMAGE_TYPE, AUDIO_TYPE],)
let albumCount = 2;
await checkAlbumAssetsCount(done, testNum, currentFetchOp, assetsCount, albumCount)
});
......@@ -321,7 +347,7 @@ export default function albumGetFileAssetsPromiseTest(abilityContext) {
it('SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_002_06', 0, async function (done) {
const testNum = 'SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_002_06';
let assetsCount = 1;
let currentFetchOp = albumTwoTypesFetchOps(['Videos/', 'Audios/'], 'Static', [VIDEO_TYPE, AUDIO_TYPE])
let currentFetchOp = albumTwoTypesFetchOps(testNum, ['Videos/', 'Audios/'], 'Static', [VIDEO_TYPE, AUDIO_TYPE])
let albumCount = 2;
await checkAlbumAssetsCount(done, testNum, currentFetchOp, assetsCount, albumCount)
});
......@@ -337,7 +363,7 @@ export default function albumGetFileAssetsPromiseTest(abilityContext) {
it('SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_002_07', 0, async function (done) {
const testNum = 'SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_002_07';
let assetsCount = 1;
let currentFetchOp = albumThreeTypesFetchOps(['Pictures/', 'Videos/', 'Audios/'], 'Static',
let currentFetchOp = albumThreeTypesFetchOps(testNum, ['Pictures/', 'Videos/', 'Audios/'], 'Static',
[IMAGE_TYPE, VIDEO_TYPE, AUDIO_TYPE])
let albumCount = 3;
await checkAlbumAssetsCount(done, testNum, currentFetchOp, assetsCount, albumCount)
......@@ -354,7 +380,7 @@ export default function albumGetFileAssetsPromiseTest(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_003_01', 0, async function (done) {
const testNum = 'SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_003_01';
let currentFetchOp = albumFetchOps('Pictures/', 'Static', IMAGE_TYPE)
let currentFetchOp = albumFetchOps(testNum, 'Pictures/', 'Static', IMAGE_TYPE)
let assetsCount = 0;
await abnormalAlbumAssetsCount(done, testNum, currentFetchOp, assetsCount)
});
......@@ -369,7 +395,7 @@ export default function albumGetFileAssetsPromiseTest(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_003_02', 0, async function (done) {
const testNum = 'SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_003_02';
let currentFetchOp = albumFetchOps('Videos/', 'Static', VIDEO_TYPE)
let currentFetchOp = albumFetchOps(testNum, 'Videos/', 'Static', VIDEO_TYPE)
let assetsCount = 0;
await abnormalAlbumAssetsCount(done, testNum, currentFetchOp, assetsCount)
});
......@@ -384,9 +410,54 @@ export default function albumGetFileAssetsPromiseTest(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_003_03', 0, async function (done) {
const testNum = 'SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_003_03';
let currentFetchOp = albumFetchOps('Audios/', 'Static', AUDIO_TYPE)
let currentFetchOp = albumFetchOps(testNum, 'Audios/', 'Static', AUDIO_TYPE)
let assetsCount = 0;
await abnormalAlbumAssetsCount(done, testNum, currentFetchOp, assetsCount)
});
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_004_01
* @tc.name : getFileAssets
* @tc.desc : Image type getFileAssets by no ops
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_004_01', 0, async function (done) {
const testNum = 'SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_004_01';
let assetsCount = 5;
let currentFetchOp = albumFetchOps(testNum, 'Pictures/', 'Static', IMAGE_TYPE)
await checkAlbumAssetsNoOps(done, testNum, currentFetchOp, assetsCount)
});
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_004_02
* @tc.name : getFileAssets
* @tc.desc : Audios type getFileAssets by no ops
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_004_02', 0, async function (done) {
const testNum = 'SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_004_02';
let assetsCount = 5;
let currentFetchOp = albumFetchOps(testNum, 'Audios/', 'Static', AUDIO_TYPE)
await checkAlbumAssetsNoOps(done, testNum, currentFetchOp, assetsCount)
});
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_004_03
* @tc.name : getFileAssets
* @tc.desc : Videos type getFileAssets by no ops
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_004_03', 0, async function (done) {
const testNum = 'SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_004_03';
let assetsCount = 5;
let currentFetchOp = albumFetchOps(testNum, 'Videos/', 'Static', VIDEO_TYPE)
await checkAlbumAssetsNoOps(done, testNum, currentFetchOp, assetsCount)
});
});
}
\ No newline at end of file
......@@ -36,13 +36,19 @@ export default function albumTestCallbackTest(abilityContext) {
describe('albumTestCallbackTest', function () {
const media = mediaLibrary.getMediaLibrary(abilityContext);
beforeAll(async function () {
console.info('beforeAll case');
await checkPresetsAssets(media, 'ActsMediaLibraryAlbum');
});
beforeEach(function () { });
beforeEach(function () {
console.info('beforeEach case');
});
afterEach(async function () {
console.info('afterEach case');
await sleep()
});
afterAll(function () { });
afterAll(function () {
console.info('afterAll case');
});
function printAlbumMessage(testNum, album) {
console.info(`${testNum} album.albumId: ${album.albumId}`);
......@@ -83,7 +89,6 @@ export default function albumTestCallbackTest(abilityContext) {
}
}
const checkAlbumInfo = async function (done, testNum, fetchOp, relativePaths, expectAlbumCount) {
console.info(`${testNum}, fetchOp: ${JSON.stringify(fetchOp)}`)
try {
media.getAlbums(fetchOp, async (err, albumList) => {
if(err) {
......@@ -118,7 +123,6 @@ export default function albumTestCallbackTest(abilityContext) {
const abnormalAlbumCount = async function (done, testNum, fetchOp) {
try {
console.info(`${testNum}, fetchOp: ${JSON.stringify(fetchOp)}`)
media.getAlbums(fetchOp, async (err, albumList) => {
if(err) {
expect(true).assertTrue();
......@@ -138,7 +142,6 @@ export default function albumTestCallbackTest(abilityContext) {
const abnormalAlbumCommitModify = async function (done, testNum, fetchOp, newName, expectAlbumCount) {
try {
console.info(`${testNum}, fetchOp: ${JSON.stringify(fetchOp)}`)
const albumList = await media.getAlbums(fetchOp);
const albumCountPass = await checkAlbumsCount(done, testNum, albumList, expectAlbumCount);
if (!albumCountPass) return;
......@@ -168,7 +171,7 @@ export default function albumTestCallbackTest(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_GETALBUM_CALLBACK_001_01', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_GETALBUM_CALLBACK_001_01';
let currentFetchOp = albumFetchOps('Pictures/', 'Static', IMAGE_TYPE);
let currentFetchOp = albumFetchOps(testNum, 'Pictures/', 'Static', IMAGE_TYPE);
let relativePaths = 'Pictures/';
let expectAlbumCount = 1;
await checkAlbumInfo(done, testNum, currentFetchOp, relativePaths, expectAlbumCount);
......@@ -185,7 +188,7 @@ export default function albumTestCallbackTest(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_GETALBUM_CALLBACK_001_02', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_GETALBUM_CALLBACK_001_02';
let currentFetchOp = albumFetchOps('Videos/', 'Static', VIDEO_TYPE);
let currentFetchOp = albumFetchOps(testNum, 'Videos/', 'Static', VIDEO_TYPE);
let relativePaths = 'Videos/';
let expectAlbumCount = 1;
await checkAlbumInfo(done, testNum, currentFetchOp, relativePaths, expectAlbumCount);
......@@ -202,7 +205,7 @@ export default function albumTestCallbackTest(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_GETALBUM_CALLBACK_001_03', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_GETALBUM_CALLBACK_001_03';
let currentFetchOp = albumFetchOps('Audios/', 'Static', AUDIO_TYPE);
let currentFetchOp = albumFetchOps(testNum, 'Audios/', 'Static', AUDIO_TYPE);
let relativePaths = 'Audios/';
let expectAlbumCount = 1;
await checkAlbumInfo(done, testNum, currentFetchOp, relativePaths, expectAlbumCount);
......@@ -220,7 +223,7 @@ export default function albumTestCallbackTest(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_GETALBUM_CALLBACK_001_04', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_GETALBUM_CALLBACK_001_04';
let currentFetchOp = albumTwoTypesFetchOps(['Pictures/', 'Videos/'], 'Static', [IMAGE_TYPE, VIDEO_TYPE])
let currentFetchOp = albumTwoTypesFetchOps(testNum, ['Pictures/', 'Videos/'], 'Static', [IMAGE_TYPE, VIDEO_TYPE])
let relativePaths = ['Pictures/', 'Videos/'];
let expectAlbumCount = 2;
await checkAlbumInfo(done, testNum, currentFetchOp, relativePaths, expectAlbumCount);
......@@ -238,7 +241,7 @@ export default function albumTestCallbackTest(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_GETALBUM_CALLBACK_001_05', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_GETALBUM_CALLBACK_001_05';
let currentFetchOp = albumTwoTypesFetchOps(['Pictures/', 'Audios/'], 'Static', [IMAGE_TYPE, AUDIO_TYPE])
let currentFetchOp = albumTwoTypesFetchOps(testNum, ['Pictures/', 'Audios/'], 'Static', [IMAGE_TYPE, AUDIO_TYPE])
let relativePaths = ['Pictures/', 'Audios/'];
let expectAlbumCount = 2;
await checkAlbumInfo(done, testNum, currentFetchOp, relativePaths, expectAlbumCount);
......@@ -256,7 +259,7 @@ export default function albumTestCallbackTest(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_GETALBUM_CALLBACK_001_06', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_GETALBUM_CALLBACK_001_06';
let currentFetchOp = albumTwoTypesFetchOps(['Videos/', 'Audios/'], 'Static', [VIDEO_TYPE, AUDIO_TYPE])
let currentFetchOp = albumTwoTypesFetchOps(testNum, ['Videos/', 'Audios/'], 'Static', [VIDEO_TYPE, AUDIO_TYPE])
let relativePaths = ['Videos/', 'Audios/'];
let expectAlbumCount = 2;
await checkAlbumInfo(done, testNum, currentFetchOp, relativePaths, expectAlbumCount);
......@@ -274,7 +277,7 @@ export default function albumTestCallbackTest(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_GETALBUM_CALLBACK_001_07', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_GETALBUM_CALLBACK_001_07';
let currentFetchOp = albumThreeTypesFetchOps(['Pictures/', 'Videos/', 'Audios/'], 'Static', [IMAGE_TYPE, VIDEO_TYPE, AUDIO_TYPE])
let currentFetchOp = albumThreeTypesFetchOps(testNum, ['Pictures/', 'Videos/', 'Audios/'], 'Static', [IMAGE_TYPE, VIDEO_TYPE, AUDIO_TYPE])
let relativePaths = ['Pictures/', 'Videos/', 'Audios/'];
let expectAlbumCount = 3;
await checkAlbumInfo(done, testNum, currentFetchOp, relativePaths, expectAlbumCount);
......@@ -348,9 +351,7 @@ export default function albumTestCallbackTest(abilityContext) {
it('SUB_MEDIA_MEDIALIBRARY_MODIFYALBUM_CALLBACK_003_01', 0, async function (done) {
const testNum = 'SUB_MEDIA_MEDIALIBRARY_MODIFYALBUM_CALLBACK_003_01';
try {
let currentFetchOp = albumFetchOps('Pictures/', 'DynamicCb1', IMAGE_TYPE);
console.info(`${testNum}, currentFetchOp: ${JSON.stringify(currentFetchOp)}`)
let currentFetchOp = albumFetchOps(testNum, 'Pictures/', 'DynamicCb1', IMAGE_TYPE);
const albumList = await media.getAlbums(currentFetchOp);
const expectAlbumCount = 1;
const albumCountPass = await checkAlbumsCount(done, testNum, albumList, expectAlbumCount);
......@@ -361,7 +362,7 @@ export default function albumTestCallbackTest(abilityContext) {
const newName = 'albumName' + new Date().getTime();
album.albumName = newName;
album.commitModify(async () => {
let currentfetchOp = idFetchOps(albumId)
let currentfetchOp = idFetchOps(testNum, albumId)
const newAlbumList = await media.getAlbums(currentfetchOp);
console.info(`${testNum}, album.albumName(new): ${newAlbumList[0].albumName}`)
expect(newAlbumList[0].albumName).assertEqual(newName);
......@@ -387,7 +388,7 @@ export default function albumTestCallbackTest(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_MODIFYALBUM_CALLBACK_003_02', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_MODIFYALBUM_CALLBACK_003_02';
let currentFetchOp = albumFetchOps('Pictures/', 'DynamicCb2', IMAGE_TYPE);
let currentFetchOp = albumFetchOps(testNum, 'Pictures/', 'DynamicCb2', IMAGE_TYPE);
let newName = '';
let expectAlbumCount = 1;
await abnormalAlbumCommitModify(done, testNum, currentFetchOp, newName, expectAlbumCount)
......@@ -403,7 +404,7 @@ export default function albumTestCallbackTest(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_MODIFYALBUM_CALLBACK_003_04', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_MODIFYALBUM_CALLBACK_003_04';
let currentFetchOp = albumFetchOps('Pictures/', 'DynamicCb2', IMAGE_TYPE);
let currentFetchOp = albumFetchOps(testNum, 'Pictures/', 'DynamicCb2', IMAGE_TYPE);
let newName = "";
for (var i = 0; i < 1200; i++) {
newName += i.toString();
......
......@@ -35,13 +35,19 @@ export default function albumTestPromiseTest(abilityContext) {
describe('albumTestPromiseTest', function () {
const media = mediaLibrary.getMediaLibrary(abilityContext);
beforeAll(async function () {
console.info('beforeAll case');
await checkPresetsAssets(media, 'ActsMediaLibraryAlbum');
});
beforeEach(function () { });
beforeEach(function () {
console.info('beforeEach case');
});
afterEach(async function () {
console.info('afterEach case');
await sleep()
});
afterAll(function () { });
afterAll(function () {
console.info('afterAll case');
});
function printAlbumMessage(testNum, album) {
console.info(`${testNum} album.albumId: ${album.albumId}`);
......@@ -82,7 +88,6 @@ export default function albumTestPromiseTest(abilityContext) {
}
}
const checkAlbumInfo = async function (done, testNum, fetchOp, relativePaths, expectAlbumCount = 1) {
console.info(`${testNum}, fetchOp: ${JSON.stringify(fetchOp)}`)
try {
const albumList = await media.getAlbums(fetchOp);
const albumCountPass = await checkAlbumsCount(done, testNum, albumList, expectAlbumCount);
......@@ -110,7 +115,7 @@ export default function albumTestPromiseTest(abilityContext) {
const abnormalAlbumCount = async function (done, testNum, fetchOp) {
try {
console.info(`${testNum}, fetchOp: ${JSON.stringify(fetchOp)}`)
const albumList = await media.getAlbums(fetchOp);
console.info(`${testNum}, albumList.length: ${albumList.length}`)
expect(albumList.length).assertEqual(0);
......@@ -124,7 +129,6 @@ export default function albumTestPromiseTest(abilityContext) {
const abnormalAlbumCommitModify = async function (done, testNum, fetchOp, newName, expectAlbumCount) {
try {
console.info(`${testNum}, fetchOp: ${JSON.stringify(fetchOp)}`)
const albumList = await media.getAlbums(fetchOp);
const albumCountPass = await checkAlbumsCount(done, testNum, albumList, expectAlbumCount);
if (!albumCountPass) return;
......@@ -153,7 +157,7 @@ export default function albumTestPromiseTest(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_GETALBUM_PROMISE_001_01', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_GETALBUM_PROMISE_001_01';
let currentFetchOp = albumFetchOps('Pictures/', 'Static', IMAGE_TYPE);
let currentFetchOp = albumFetchOps(testNum, 'Pictures/', 'Static', IMAGE_TYPE);
let relativePaths = 'Pictures/';
await checkAlbumInfo(done, testNum, currentFetchOp, relativePaths);
});
......@@ -169,7 +173,7 @@ export default function albumTestPromiseTest(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_GETALBUM_PROMISE_001_02', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_GETALBUM_PROMISE_001_02';
let currentFetchOp = albumFetchOps('Videos/', 'Static', VIDEO_TYPE);
let currentFetchOp = albumFetchOps(testNum, 'Videos/', 'Static', VIDEO_TYPE);
let relativePaths = 'Videos/';
await checkAlbumInfo(done, testNum, currentFetchOp, relativePaths);
});
......@@ -185,7 +189,7 @@ export default function albumTestPromiseTest(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_GETALBUM_PROMISE_001_03', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_GETALBUM_PROMISE_001_03';
let currentFetchOp = albumFetchOps('Audios/', 'Static', AUDIO_TYPE);
let currentFetchOp = albumFetchOps(testNum, 'Audios/', 'Static', AUDIO_TYPE);
let relativePaths = 'Audios/';
await checkAlbumInfo(done, testNum, currentFetchOp, relativePaths);
});
......@@ -202,7 +206,7 @@ export default function albumTestPromiseTest(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_GETALBUM_PROMISE_001_04', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_GETALBUM_PROMISE_001_04';
let currentFetchOp = albumTwoTypesFetchOps(['Pictures/', 'Videos/'], 'Static', [IMAGE_TYPE, VIDEO_TYPE])
let currentFetchOp = albumTwoTypesFetchOps(testNum, ['Pictures/', 'Videos/'], 'Static', [IMAGE_TYPE, VIDEO_TYPE])
let relativePaths = ['Pictures/', 'Videos/'];
let albumCount = 2;
await checkAlbumInfo(done, testNum, currentFetchOp, relativePaths, albumCount);
......@@ -220,7 +224,7 @@ export default function albumTestPromiseTest(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_GETALBUM_PROMISE_001_05', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_GETALBUM_PROMISE_001_05';
let currentFetchOp = albumTwoTypesFetchOps(['Pictures/', 'Audios/'], 'Static', [IMAGE_TYPE, AUDIO_TYPE])
let currentFetchOp = albumTwoTypesFetchOps(testNum, ['Pictures/', 'Audios/'], 'Static', [IMAGE_TYPE, AUDIO_TYPE])
let relativePaths = ['Pictures/', 'Audios/'];
let albumCount = 2;
await checkAlbumInfo(done, testNum, currentFetchOp, relativePaths, albumCount);
......@@ -238,7 +242,7 @@ export default function albumTestPromiseTest(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_GETALBUM_PROMISE_001_06', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_GETALBUM_PROMISE_001_06';
let currentFetchOp = albumTwoTypesFetchOps(['Videos/', 'Audios/'], 'Static', [VIDEO_TYPE, AUDIO_TYPE])
let currentFetchOp = albumTwoTypesFetchOps(testNum, ['Videos/', 'Audios/'], 'Static', [VIDEO_TYPE, AUDIO_TYPE])
let relativePaths = ['Videos/', 'Audios/'];
let albumCount = 2;
await checkAlbumInfo(done, testNum, currentFetchOp, relativePaths, albumCount);
......@@ -256,7 +260,7 @@ export default function albumTestPromiseTest(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_GETALBUM_PROMISE_001_07', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_GETALBUM_PROMISE_001_07';
let currentFetchOp = albumThreeTypesFetchOps(['Pictures/', 'Videos/', 'Audios/'], 'Static', [IMAGE_TYPE, VIDEO_TYPE, AUDIO_TYPE])
let currentFetchOp = albumThreeTypesFetchOps(testNum, ['Pictures/', 'Videos/', 'Audios/'], 'Static', [IMAGE_TYPE, VIDEO_TYPE, AUDIO_TYPE])
let relativePaths = ['Pictures/', 'Videos/', 'Audios/'];
let albumCount = 3;
await checkAlbumInfo(done, testNum, currentFetchOp, relativePaths, albumCount);
......@@ -330,9 +334,7 @@ export default function albumTestPromiseTest(abilityContext) {
it('SUB_MEDIA_MEDIALIBRARY_MODIFYALBUM_PROMISE_003_01', 0, async function (done) {
const testNum = 'SUB_MEDIA_MEDIALIBRARY_MODIFYALBUM_PROMISE_003_01';
try {
let currentFetchOp = albumFetchOps('Pictures/', 'DynamicPro1', IMAGE_TYPE);
console.info(`${testNum}, currentFetchOp: ${JSON.stringify(currentFetchOp)}`)
let currentFetchOp = albumFetchOps(testNum, 'Pictures/', 'DynamicPro1', IMAGE_TYPE);
const albumList = await media.getAlbums(currentFetchOp);
const expectAlbumCount = 1;
const albumCountPass = await checkAlbumsCount(done, testNum, albumList, expectAlbumCount);
......@@ -343,7 +345,7 @@ export default function albumTestPromiseTest(abilityContext) {
const newName = 'albumName' + new Date().getTime();
album.albumName = newName;
await album.commitModify();
let currentfetchOp = idFetchOps(albumId)
let currentfetchOp = idFetchOps(testNum, albumId)
const newAlbumList = await media.getAlbums(currentfetchOp);
console.info(`${testNum}, album.albumName(new): ${newAlbumList[0].albumName}`)
expect(newAlbumList[0].albumName).assertEqual(newName);
......@@ -368,7 +370,7 @@ export default function albumTestPromiseTest(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_MODIFYALBUM_PROMISE_003_02', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_MODIFYALBUM_PROMISE_003_02';
let currentFetchOp = albumFetchOps('Pictures/', 'DynamicPro2', IMAGE_TYPE);
let currentFetchOp = albumFetchOps(testNum, 'Pictures/', 'DynamicPro2', IMAGE_TYPE);
let newName = '';
let expectAlbumCount = 1;
await abnormalAlbumCommitModify(done, testNum, currentFetchOp, newName, expectAlbumCount)
......@@ -384,7 +386,7 @@ export default function albumTestPromiseTest(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_MODIFYALBUM_PROMISE_003_04', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_MODIFYALBUM_PROMISE_003_04';
let currentFetchOp = albumFetchOps('Pictures/', 'DynamicPro2', IMAGE_TYPE);
let currentFetchOp = albumFetchOps(testNum, 'Pictures/', 'DynamicPro2', IMAGE_TYPE);
let newName = "";
for (var i = 0; i < 1200; i++) {
newName += i.toString();
......@@ -412,7 +414,7 @@ export default function albumTestPromiseTest(abilityContext) {
order: 'date_added DESC LIMIT 0,1',
};
let expectAlbumCount = 1;
let currentFetchOp = albumFetchOps('Pictures/', 'Static', IMAGE_TYPE);
let currentFetchOp = albumFetchOps(testNum, 'Pictures/', 'Static', IMAGE_TYPE);
const albumList = await media.getAlbums(currentFetchOp);
const albumCountPass = await checkAlbumsCount(done, testNum, albumList, expectAlbumCount);
if (!albumCountPass) return;
......
......@@ -48,6 +48,7 @@
"hilog -p off",
"hilog -b I",
"hilog -b D -D 0xD002B70",
"setenforce 0",
"scanner_demo",
"sleep 10"
]
......
......@@ -43,7 +43,7 @@ export default function mediaLibraryTestCallback(abilityContext) {
});
afterEach(async function () {
console.info('afterEach case');
await sleep()
await sleep(500)
});
afterAll(function () {
console.info('afterAll case');
......@@ -108,8 +108,6 @@ export default function mediaLibraryTestCallback(abilityContext) {
mediaType: AUDIO_TYPE.toString(),
title: '01',
artist: '元数据测试',
width: 219600,
height: 219600,
orientation: 0,
duration: '219600',
},
......@@ -162,8 +160,10 @@ export default function mediaLibraryTestCallback(abilityContext) {
expect(asset.size).assertEqual(props[type].size);
expect(asset.mediaType.toString()).assertEqual(props[type].mediaType);
expect(asset.title.toString()).assertEqual(props[type].title);
expect(asset.width).assertEqual(props[type].width);
expect(asset.height).assertEqual(props[type].height);
if(type != 'audio') {
expect(asset.width).assertEqual(props[type].width);
expect(asset.height).assertEqual(props[type].height);
}
expect(asset.orientation).assertEqual(props[type].orientation);
expect(asset.duration.toString()).assertEqual(props[type].duration);
done();
......@@ -307,7 +307,7 @@ export default function mediaLibraryTestCallback(abilityContext) {
*/
it('SUB__MEDIA_MIDIALIBRARY_CALLBACK_GETFILEASSETS_001', 0, async function (done) {
let testNum = 'SUB__MEDIA_MIDIALIBRARY_CALLBACK_GETFILEASSETS_001';
let currentFetchOps = fetchOps('Pictures/Static/', IMAGE_TYPE);
let currentFetchOps = fetchOps(testNum, 'Pictures/Static/', IMAGE_TYPE);
let type = 'image';
let count = 1;
await checkFileAssetAttr(done, testNum, currentFetchOps, type, count, null)
......@@ -323,7 +323,7 @@ export default function mediaLibraryTestCallback(abilityContext) {
*/
it('SUB__MEDIA_MIDIALIBRARY_CALLBACK_GETFILEASSETS_002', 0, async function (done) {
let testNum = 'SUB__MEDIA_MIDIALIBRARY_CALLBACK_GETFILEASSETS_002';
let currentFetchOps = fetchOps('Videos/Static/', VIDEO_TYPE);
let currentFetchOps = fetchOps(testNum, 'Videos/Static/', VIDEO_TYPE);
let type = 'video';
let count = 1;
await checkFileAssetAttr(done, testNum, currentFetchOps, type, count, null)
......@@ -339,7 +339,7 @@ export default function mediaLibraryTestCallback(abilityContext) {
*/
it('SUB__MEDIA_MIDIALIBRARY_CALLBACK_GETFILEASSETS_003', 0, async function (done) {
let testNum = 'SUB__MEDIA_MIDIALIBRARY_CALLBACK_GETFILEASSETS_003';
let currentFetchOps = fetchOps('Audios/Static/', AUDIO_TYPE);
let currentFetchOps = fetchOps(testNum, 'Audios/Static/', AUDIO_TYPE);
let type = 'audio';
let count = 1;
await checkFileAssetAttr(done, testNum, currentFetchOps, type, count, null)
......@@ -355,7 +355,7 @@ export default function mediaLibraryTestCallback(abilityContext) {
*/
it('SUB__MEDIA_MIDIALIBRARY_CALLBACK_GETFILEASSETS_004', 0, async function (done) {
let testNum = 'SUB__MEDIA_MIDIALIBRARY_CALLBACK_GETFILEASSETS_004';
let currentFetchOps = fetchOps('Documents/Static/', FILE_TYPE);
let currentFetchOps = fetchOps(testNum, 'Documents/Static/', FILE_TYPE);
let type = 'file';
let count = 1;
await checkFileAssetAttr(done, testNum, currentFetchOps, type, count, null)
......@@ -586,7 +586,7 @@ export default function mediaLibraryTestCallback(abilityContext) {
*/
it('SUB__MEDIA_MIDIALIBRARY_CALLBACK_CREATEASSET_001', 0, async function (done) {
let testNum = 'SUB__MEDIA_MIDIALIBRARY_CALLBACK_CREATEASSET_001';
let currentFetchOps = fetchOps('Pictures/Static/', IMAGE_TYPE);
let currentFetchOps = fetchOps(testNum, 'Pictures/Static/', IMAGE_TYPE);
let type = IMAGE_TYPE;
let name = new Date().getTime() + '.jpg';
let path = 'Pictures/Create/';
......@@ -603,7 +603,7 @@ export default function mediaLibraryTestCallback(abilityContext) {
*/
it('SUB__MEDIA_MIDIALIBRARY_CALLBACK_CREATEASSET_002', 0, async function (done) {
let testNum = 'SUB__MEDIA_MIDIALIBRARY_CALLBACK_CREATEASSET_002';
let currentFetchOps = fetchOps('Pictures/Static/', IMAGE_TYPE);
let currentFetchOps = fetchOps(testNum, 'Pictures/Static/', IMAGE_TYPE);
let type = IMAGE_TYPE;
let name = new Date().getTime() + '.jpg';
let path = 'Pictures/Create/';
......@@ -621,7 +621,7 @@ export default function mediaLibraryTestCallback(abilityContext) {
*/
it('SUB__MEDIA_MIDIALIBRARY_CALLBACK_CREATEASSET_003', 0, async function (done) {
let testNum = 'SUB__MEDIA_MIDIALIBRARY_CALLBACK_CREATEASSET_003';
let currentFetchOps = fetchOps('Videos/Static/', VIDEO_TYPE);
let currentFetchOps = fetchOps(testNum, 'Videos/Static/', VIDEO_TYPE);
let type = VIDEO_TYPE;
let name = new Date().getTime() + '.mp4';
let path = 'Videos/Create/';
......@@ -638,7 +638,7 @@ export default function mediaLibraryTestCallback(abilityContext) {
*/
it('SUB__MEDIA_MIDIALIBRARY_CALLBACK_CREATEASSET_004', 0, async function (done) {
let testNum = 'SUB__MEDIA_MIDIALIBRARY_CALLBACK_CREATEASSET_004';
let currentFetchOps = fetchOps('Videos/Static/', VIDEO_TYPE);
let currentFetchOps = fetchOps(testNum, 'Videos/Static/', VIDEO_TYPE);
let type = VIDEO_TYPE;
let name = new Date().getTime() + '.mp4';
let path = 'Videos/Create/';
......@@ -655,7 +655,7 @@ export default function mediaLibraryTestCallback(abilityContext) {
*/
it('SUB__MEDIA_MIDIALIBRARY_CALLBACK_CREATEASSET_005', 0, async function (done) {
let testNum = 'SUB__MEDIA_MIDIALIBRARY_CALLBACK_CREATEASSET_005';
let currentFetchOps = fetchOps('Audios/Static/', AUDIO_TYPE);
let currentFetchOps = fetchOps(testNum, 'Audios/Static/', AUDIO_TYPE);
let type = AUDIO_TYPE;
let name = new Date().getTime() + '.mp3';
let path = 'Audios/Create/';
......@@ -672,7 +672,7 @@ export default function mediaLibraryTestCallback(abilityContext) {
*/
it('SUB__MEDIA_MIDIALIBRARY_CALLBACK_CREATEASSET_006', 0, async function (done) {
let testNum = 'SUB__MEDIA_MIDIALIBRARY_CALLBACK_CREATEASSET_006';
let currentFetchOps = fetchOps('Audios/Static/', AUDIO_TYPE);
let currentFetchOps = fetchOps(testNum, 'Audios/Static/', AUDIO_TYPE);
let type = AUDIO_TYPE;
let name = new Date().getTime() + '.mp3';
let path = 'Audios/Create/';
......@@ -689,7 +689,7 @@ export default function mediaLibraryTestCallback(abilityContext) {
*/
it('SUB__MEDIA_MIDIALIBRARY_CALLBACK_CREATEASSET_007', 0, async function (done) {
let testNum = 'SUB__MEDIA_MIDIALIBRARY_CALLBACK_CREATEASSET_007';
let currentFetchOps = fetchOps('Documents/Static/', FILE_TYPE);
let currentFetchOps = fetchOps(testNum, 'Documents/Static/', FILE_TYPE);
let type = FILE_TYPE;
let name = new Date().getTime() + '.dat';
let path = 'Documents/Create/';
......@@ -706,7 +706,7 @@ export default function mediaLibraryTestCallback(abilityContext) {
*/
it('SUB__MEDIA_MIDIALIBRARY_CALLBACK_CREATEASSET_008', 0, async function (done) {
let testNum = 'SUB__MEDIA_MIDIALIBRARY_CALLBACK_CREATEASSET_008';
let currentFetchOps = fetchOps('Documents/Static/', FILE_TYPE);
let currentFetchOps = fetchOps(testNum, 'Documents/Static/', FILE_TYPE);
let type = FILE_TYPE;
let name = new Date().getTime() + '.dat';
let path = 'Documents/Create/';
......@@ -723,7 +723,7 @@ export default function mediaLibraryTestCallback(abilityContext) {
*/
it('SUB__MEDIA_MIDIALIBRARY_CALLBACK_CREATEASSET_009', 0, async function (done) {
let testNum = 'SUB__MEDIA_MIDIALIBRARY_CALLBACK_CREATEASSET_001';
let currentFetchOps = fetchOps('Pictures/Static/', IMAGE_TYPE);
let currentFetchOps = fetchOps(testNum, 'Pictures/Static/', IMAGE_TYPE);
let type = IMAGE_TYPE;
let name = new Date().getTime() + '.jpg';
let path = 'Pictures/Create/Temp';
......
......@@ -43,7 +43,7 @@ export default function mediaLibraryTestPromiseTest(abilityContext) {
});
afterEach(async function () {
console.info('afterEach case');
await sleep()
await sleep(200)
});
afterAll(function () {
console.info('afterAll case');
......@@ -108,8 +108,6 @@ export default function mediaLibraryTestPromiseTest(abilityContext) {
mediaType: AUDIO_TYPE.toString(),
title: '01',
artist: '元数据测试',
width: 219600,
height: 219600,
orientation: 0,
duration: '219600',
},
......@@ -150,14 +148,21 @@ export default function mediaLibraryTestPromiseTest(abilityContext) {
done();
return;
}
if(asset.size !== props[type].size) {
console.info(`${testNum}:: asset.size: props.size - ${asset.size} : ${props[type].size}`);
expect(false).assertTrue();
done();
return;
}
expect(asset.mimeType).assertEqual(props[type].mimeType);
expect(asset.displayName).assertEqual(props[type].displayName);
expect(asset.relativePath).assertEqual(props[type].relativePath);
expect(asset.size).assertEqual(props[type].size);
expect(asset.mediaType.toString()).assertEqual(props[type].mediaType);
expect(asset.title.toString()).assertEqual(props[type].title);
expect(asset.width).assertEqual(props[type].width);
expect(asset.height).assertEqual(props[type].height);
if(type != 'audio') {
expect(asset.width).assertEqual(props[type].width);
expect(asset.height).assertEqual(props[type].height);
}
expect(asset.orientation).assertEqual(props[type].orientation);
expect(asset.duration.toString()).assertEqual(props[type].duration);
done();
......@@ -281,7 +286,7 @@ export default function mediaLibraryTestPromiseTest(abilityContext) {
*/
it('SUB__MEDIA_MIDIALIBRARY_PROMISE_GETFILEASSETS_001', 0, async function (done) {
let testNum = 'SUB__MEDIA_MIDIALIBRARY_PROMISE_GETFILEASSETS_001';
let currentFetchOps = fetchOps('Pictures/Static/', IMAGE_TYPE);
let currentFetchOps = fetchOps(testNum, 'Pictures/Static/', IMAGE_TYPE);
let type = 'image';
let count = 1;
await checkFileAssetAttr(done, testNum, currentFetchOps, type, count, null)
......@@ -297,7 +302,7 @@ export default function mediaLibraryTestPromiseTest(abilityContext) {
*/
it('SUB__MEDIA_MIDIALIBRARY_PROMISE_GETFILEASSETS_002', 0, async function (done) {
let testNum = 'SUB__MEDIA_MIDIALIBRARY_PROMISE_GETFILEASSETS_002';
let currentFetchOps = fetchOps('Videos/Static/', VIDEO_TYPE);
let currentFetchOps = fetchOps(testNum, 'Videos/Static/', VIDEO_TYPE);
let type = 'video';
let count = 1;
await checkFileAssetAttr(done, testNum, currentFetchOps, type, count, null)
......@@ -313,7 +318,7 @@ export default function mediaLibraryTestPromiseTest(abilityContext) {
*/
it('SUB__MEDIA_MIDIALIBRARY_PROMISE_GETFILEASSETS_003', 0, async function (done) {
let testNum = 'SUB__MEDIA_MIDIALIBRARY_PROMISE_GETFILEASSETS_003';
let currentFetchOps = fetchOps('Audios/Static/', AUDIO_TYPE);
let currentFetchOps = fetchOps(testNum, 'Audios/Static/', AUDIO_TYPE);
let type = 'audio';
let count = 1;
await checkFileAssetAttr(done, testNum, currentFetchOps, type, count, null)
......@@ -329,7 +334,7 @@ export default function mediaLibraryTestPromiseTest(abilityContext) {
*/
it('SUB__MEDIA_MIDIALIBRARY_PROMISE_GETFILEASSETS_004', 0, async function (done) {
let testNum = 'SUB__MEDIA_MIDIALIBRARY_PROMISE_GETFILEASSETS_004';
let currentFetchOps = fetchOps('Documents/Static/', FILE_TYPE);
let currentFetchOps = fetchOps(testNum, 'Documents/Static/', FILE_TYPE);
let type = 'file';
let count = 1;
await checkFileAssetAttr(done, testNum, currentFetchOps, type, count, null)
......@@ -560,7 +565,7 @@ export default function mediaLibraryTestPromiseTest(abilityContext) {
*/
it('SUB__MEDIA_MIDIALIBRARY_PROMISE_CREATEASSET_001', 0, async function (done) {
let testNum = 'SUB__MEDIA_MIDIALIBRARY_PROMISE_CREATEASSET_001';
let currentFetchOps = fetchOps('Pictures/Static/', IMAGE_TYPE);
let currentFetchOps = fetchOps(testNum, 'Pictures/Static/', IMAGE_TYPE);
let type = IMAGE_TYPE;
let name = new Date().getTime() + '.jpg';
let path = 'Pictures/Create/';
......@@ -577,7 +582,7 @@ export default function mediaLibraryTestPromiseTest(abilityContext) {
*/
it('SUB__MEDIA_MIDIALIBRARY_PROMISE_CREATEASSET_002', 0, async function (done) {
let testNum = 'SUB__MEDIA_MIDIALIBRARY_PROMISE_CREATEASSET_002';
let currentFetchOps = fetchOps('Pictures/Static/', IMAGE_TYPE);
let currentFetchOps = fetchOps(testNum, 'Pictures/Static/', IMAGE_TYPE);
let type = IMAGE_TYPE;
let name = new Date().getTime() + '.jpg';
let path = 'Pictures/Create/';
......@@ -595,7 +600,7 @@ export default function mediaLibraryTestPromiseTest(abilityContext) {
*/
it('SUB__MEDIA_MIDIALIBRARY_PROMISE_CREATEASSET_003', 0, async function (done) {
let testNum = 'SUB__MEDIA_MIDIALIBRARY_PROMISE_CREATEASSET_003';
let currentFetchOps = fetchOps('Videos/Static/', VIDEO_TYPE);
let currentFetchOps = fetchOps(testNum, 'Videos/Static/', VIDEO_TYPE);
let type = VIDEO_TYPE;
let name = new Date().getTime() + '.mp4';
let path = 'Videos/Create/';
......@@ -612,7 +617,7 @@ export default function mediaLibraryTestPromiseTest(abilityContext) {
*/
it('SUB__MEDIA_MIDIALIBRARY_PROMISE_CREATEASSET_004', 0, async function (done) {
let testNum = 'SUB__MEDIA_MIDIALIBRARY_PROMISE_CREATEASSET_004';
let currentFetchOps = fetchOps('Videos/Static/', VIDEO_TYPE);
let currentFetchOps = fetchOps(testNum, 'Videos/Static/', VIDEO_TYPE);
let type = VIDEO_TYPE;
let name = new Date().getTime() + '.mp4';
let path = 'Videos/Create/';
......@@ -629,7 +634,7 @@ export default function mediaLibraryTestPromiseTest(abilityContext) {
*/
it('SUB__MEDIA_MIDIALIBRARY_PROMISE_CREATEASSET_005', 0, async function (done) {
let testNum = 'SUB__MEDIA_MIDIALIBRARY_PROMISE_CREATEASSET_005';
let currentFetchOps = fetchOps('Audios/Static/', AUDIO_TYPE);
let currentFetchOps = fetchOps(testNum, 'Audios/Static/', AUDIO_TYPE);
let type = AUDIO_TYPE;
let name = new Date().getTime() + '.mp3';
let path = 'Audios/Create/';
......@@ -646,7 +651,7 @@ export default function mediaLibraryTestPromiseTest(abilityContext) {
*/
it('SUB__MEDIA_MIDIALIBRARY_PROMISE_CREATEASSET_006', 0, async function (done) {
let testNum = 'SUB__MEDIA_MIDIALIBRARY_PROMISE_CREATEASSET_006';
let currentFetchOps = fetchOps('Audios/Static/', AUDIO_TYPE);
let currentFetchOps = fetchOps(testNum, 'Audios/Static/', AUDIO_TYPE);
let type = AUDIO_TYPE;
let name = new Date().getTime() + '.mp3';
let path = 'Audios/Create/';
......@@ -663,7 +668,7 @@ export default function mediaLibraryTestPromiseTest(abilityContext) {
*/
it('SUB__MEDIA_MIDIALIBRARY_PROMISE_CREATEASSET_007', 0, async function (done) {
let testNum = 'SUB__MEDIA_MIDIALIBRARY_PROMISE_CREATEASSET_007';
let currentFetchOps = fetchOps('Documents/Static/', FILE_TYPE);
let currentFetchOps = fetchOps(testNum, 'Documents/Static/', FILE_TYPE);
let type = FILE_TYPE;
let name = new Date().getTime() + '.dat';
let path = 'Documents/Create/';
......@@ -680,7 +685,7 @@ export default function mediaLibraryTestPromiseTest(abilityContext) {
*/
it('SUB__MEDIA_MIDIALIBRARY_PROMISE_CREATEASSET_008', 0, async function (done) {
let testNum = 'SUB__MEDIA_MIDIALIBRARY_PROMISE_CREATEASSET_008';
let currentFetchOps = fetchOps('Documents/Static/', FILE_TYPE);
let currentFetchOps = fetchOps(testNum, 'Documents/Static/', FILE_TYPE);
let type = FILE_TYPE;
let name = new Date().getTime() + '.dat';
let path = 'Documents/Create/';
......@@ -697,7 +702,7 @@ export default function mediaLibraryTestPromiseTest(abilityContext) {
*/
it('SUB__MEDIA_MIDIALIBRARY_PROMISE_CREATEASSET_009', 0, async function (done) {
let testNum = 'SUB__MEDIA_MIDIALIBRARY_PROMISE_CREATEASSET_001';
let currentFetchOps = fetchOps('Pictures/Static/', IMAGE_TYPE);
let currentFetchOps = fetchOps(testNum, 'Pictures/Static/', IMAGE_TYPE);
let type = IMAGE_TYPE;
let name = new Date().getTime() + '.jpg';
let path = 'Pictures/Create/Temp';
......
......@@ -102,7 +102,7 @@ export default function mediaLibraryTestPromiseOnOffTest(abilityContext) {
it('SUB_MEDIA_MIDIALIBRARY_PROMISE_ON_001', 0, async function (done) {
let type = 'imageChange'
let testNum = 'SUB_MEDIA_MIDIALIBRARY_PROMISE_ON_001';
let currentFetchOps = fetchOps('Pictures/On/', IMAGE_TYPE);
let currentFetchOps = fetchOps(testNum, 'Pictures/On/', IMAGE_TYPE);
await onTest(done, testNum, type, currentFetchOps)
});
......@@ -117,7 +117,7 @@ export default function mediaLibraryTestPromiseOnOffTest(abilityContext) {
it('SUB_MEDIA_MIDIALIBRARY_PROMISE_ON_002', 0, async function (done) {
let type = 'videoChange'
let testNum = 'SUB_MEDIA_MIDIALIBRARY_PROMISE_ON_002';
let currentFetchOps = fetchOps('Videos/On/', VIDEO_TYPE);
let currentFetchOps = fetchOps(testNum, 'Videos/On/', VIDEO_TYPE);
await onTest(done, testNum, type, currentFetchOps)
});
......@@ -132,7 +132,7 @@ export default function mediaLibraryTestPromiseOnOffTest(abilityContext) {
it('SUB_MEDIA_MIDIALIBRARY_PROMISE_ON_003', 0, async function (done) {
let type = 'audioChange'
let testNum = 'SUB_MEDIA_MIDIALIBRARY_PROMISE_ON_003';
let currentFetchOps = fetchOps('Audios/On/', AUDIO_TYPE);
let currentFetchOps = fetchOps(testNum, 'Audios/On/', AUDIO_TYPE);
await onTest(done, testNum, type, currentFetchOps)
});
......@@ -147,7 +147,7 @@ export default function mediaLibraryTestPromiseOnOffTest(abilityContext) {
it('SUB_MEDIA_MIDIALIBRARY_PROMISE_ON_004', 0, async function (done) {
let type = 'fileChange'
let testNum = 'SUB_MEDIA_MIDIALIBRARY_PROMISE_ON_004';
let currentFetchOps = fetchOps('Documents/On/', FILE_TYPE);
let currentFetchOps = fetchOps(testNum, 'Documents/On/', FILE_TYPE);
await onTest(done, testNum, type, currentFetchOps)
});
......@@ -166,7 +166,7 @@ export default function mediaLibraryTestPromiseOnOffTest(abilityContext) {
media.on('albumChange', () => {
conut++;
});
let currentFetchOps = albumFetchOps('Pictures/', 'OnAlbum', IMAGE_TYPE);
let currentFetchOps = albumFetchOps(testNum, 'Pictures/', 'OnAlbum', IMAGE_TYPE);
const albumList = await media.getAlbums(currentFetchOps);
const albumCountPass = await checkAlbumsCount(done, testNum, albumList, 1);
if (!albumCountPass) return;
......@@ -195,6 +195,7 @@ export default function mediaLibraryTestPromiseOnOffTest(abilityContext) {
* @tc.level : Level 0
*/
it('SUB_MEDIA_MIDIALIBRARY_PROMISE_ON_006', 0, async function (done) {
let testNum = 'SUB_MEDIA_MIDIALIBRARY_PROMISE_ON_006'
try {
let conut = 0;
expect(true).assertTrue();
......@@ -203,7 +204,7 @@ export default function mediaLibraryTestPromiseOnOffTest(abilityContext) {
console.info('MediaLibraryTest : on 006 callback');
conut++;
});
let currentFetchOps = fetchOps('Documents/On/', FILE_TYPE);
let currentFetchOps = fetchOps(testNum, 'Documents/On/', FILE_TYPE);
const fetchFileResult = await media.getFileAssets(currentFetchOps);
const asset = await fetchFileResult.getFirstObject();
asset.title = asset.title + 'changename';
......@@ -232,6 +233,7 @@ export default function mediaLibraryTestPromiseOnOffTest(abilityContext) {
* @tc.level : Level 0
*/
it('SUB_MEDIA_MIDIALIBRARY_PROMISE_ON_007', 0, async function (done) {
let testNum = 'SUB_MEDIA_MIDIALIBRARY_PROMISE_ON_007'
try {
let conut = 0;
expect(true).assertTrue();
......@@ -241,7 +243,7 @@ export default function mediaLibraryTestPromiseOnOffTest(abilityContext) {
conut++;
});
let currentFetchOps = fetchOps('Documents/On/', FILE_TYPE);
let currentFetchOps = fetchOps(testNum, 'Documents/On/', FILE_TYPE);
const fetchFileResult = await media.getFileAssets(currentFetchOps);
const asset = await fetchFileResult.getFirstObject();
asset.title = asset.title + 'changename';
......@@ -272,7 +274,7 @@ export default function mediaLibraryTestPromiseOnOffTest(abilityContext) {
it('SUB_MEDIA_MIDIALIBRARY_PROMISE_OFF_001', 0, async function (done) {
let type = 'imageChange'
let testNum = 'SUB_MEDIA_MIDIALIBRARY_PROMISE_OFF_001';
let currentFetchOps = fetchOps('Pictures/Off/', IMAGE_TYPE);
let currentFetchOps = fetchOps(testNum, 'Pictures/Off/', IMAGE_TYPE);
await offTest(done, testNum, type, currentFetchOps)
});
......@@ -287,7 +289,7 @@ export default function mediaLibraryTestPromiseOnOffTest(abilityContext) {
it('SUB_MEDIA_MIDIALIBRARY_PROMISE_OFF_002', 0, async function (done) {
let type = 'videoChange'
let testNum = 'SUB_MEDIA_MIDIALIBRARY_PROMISE_OFF_002';
let currentFetchOps = fetchOps('Videos/Off/', VIDEO_TYPE);
let currentFetchOps = fetchOps(testNum, 'Videos/Off/', VIDEO_TYPE);
await offTest(done, testNum, type, currentFetchOps)
});
......@@ -302,7 +304,7 @@ export default function mediaLibraryTestPromiseOnOffTest(abilityContext) {
it('SUB_MEDIA_MIDIALIBRARY_PROMISE_OFF_003', 0, async function (done) {
let type = 'audioChange'
let testNum = 'SUB_MEDIA_MIDIALIBRARY_PROMISE_OFF_003';
let currentFetchOps = fetchOps('Audios/Off/', AUDIO_TYPE);
let currentFetchOps = fetchOps(testNum, 'Audios/Off/', AUDIO_TYPE);
await offTest(done, testNum, type, currentFetchOps)
});
......@@ -317,7 +319,7 @@ export default function mediaLibraryTestPromiseOnOffTest(abilityContext) {
it('SUB_MEDIA_MIDIALIBRARY_PROMISE_OFF_004', 0, async function (done) {
let type = 'fileChange'
let testNum = 'SUB_MEDIA_MIDIALIBRARY_PROMISE_OFF_004';
let currentFetchOps = fetchOps('Documents/Off/', FILE_TYPE);
let currentFetchOps = fetchOps(testNum, 'Documents/Off/', FILE_TYPE);
await offTest(done, testNum, type, currentFetchOps)
});
......@@ -338,7 +340,7 @@ export default function mediaLibraryTestPromiseOnOffTest(abilityContext) {
});
await sleep(300)
media.off('albumChange');
let currentFetchOps = albumFetchOps('Pictures/', 'OffAlbum', IMAGE_TYPE);
let currentFetchOps = albumFetchOps(testNum, 'Pictures/', 'OffAlbum', IMAGE_TYPE);
const albumList = await media.getAlbums(currentFetchOps);
const albumCountPass = await checkAlbumsCount(done, testNum, albumList, 1);
if (!albumCountPass) return;
......@@ -367,6 +369,7 @@ export default function mediaLibraryTestPromiseOnOffTest(abilityContext) {
* @tc.level : Level 0
*/
it('SUB_MEDIA_MIDIALIBRARY_PROMISE_OFF_006', 0, async function (done) {
let testNum = 'SUB_MEDIA_MIDIALIBRARY_PROMISE_OFF_006'
try {
media.on('deviceChange', () => {
console.info('MediaLibraryTest : off 006 failed');
......@@ -379,7 +382,7 @@ export default function mediaLibraryTestPromiseOnOffTest(abilityContext) {
res(true)
}, 300)
})
let currentFetchOps = fetchOps('Documents/On/', FILE_TYPE);
let currentFetchOps = fetchOps(testNum, 'Documents/On/', FILE_TYPE);
const fetchFileResult = await media.getFileAssets(currentFetchOps);
const asset = await fetchFileResult.getFirstObject();
asset.title = asset.title + 'deviceChange';
......@@ -415,6 +418,7 @@ export default function mediaLibraryTestPromiseOnOffTest(abilityContext) {
* @tc.level : Level 0
*/
it('SUB_MEDIA_MIDIALIBRARY_PROMISE_OFF_007', 0, async function (done) {
let testNum = 'SUB_MEDIA_MIDIALIBRARY_PROMISE_OFF_007'
try {
media.on('remoteFileChange', () => {
console.info('MediaLibraryTest : off 007 failed');
......@@ -429,7 +433,7 @@ export default function mediaLibraryTestPromiseOnOffTest(abilityContext) {
})
media.off('remoteFileChange');
let currentFetchOps = fetchOps('Documents/On/', FILE_TYPE);
let currentFetchOps = fetchOps(testNum, 'Documents/On/', FILE_TYPE);
const fetchFileResult = await media.getFileAssets(currentFetchOps);
const asset = await fetchFileResult.getFirstObject();
asset.title = asset.title + 'remoteFileChange';
......
......@@ -31,17 +31,22 @@ export default function favoriteTestCallbackTest(abilityContext) {
describe('favoriteTestCallbackTest', function () {
var media = mediaLibrary.getMediaLibrary(abilityContext);
beforeAll(async function () {
console.info('beforeAll case');
await getPermission();
await checkPresetsAssets(media, 'ActsMediaLibraryFavorite');
});
beforeEach(function () { });
beforeEach(function () {
console.info('beforeEach case');
});
afterEach(async function () {
sleep()
console.info('afterEach case');
await sleep()
});
afterAll(function () {
console.info('afterAll case');
});
afterAll(function () { });
const favoriteDefaultState = async function (done, testNum, fetchOp) {
console.info(`${testNum} fetchOp ${JSON.stringify(fetchOp)}`)
try {
let fetchFileResult = await media.getFileAssets(fetchOp);
let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchFileResult, 1);
......@@ -65,7 +70,6 @@ export default function favoriteTestCallbackTest(abilityContext) {
}
}
const favoriteByTrue = async function (done, testNum, fetchOp) {
console.info(`${testNum} fetchOp ${JSON.stringify(fetchOp)}`)
try {
const fetchFileResult = await media.getFileAssets(fetchOp);
let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchFileResult, 1);
......@@ -91,7 +95,6 @@ export default function favoriteTestCallbackTest(abilityContext) {
}
}
const favoriteByFalse = async function (done, testNum, fetchOp) {
console.info(`${testNum} fetchOp ${JSON.stringify(fetchOp)}`)
try {
const fetchFileResult = await media.getFileAssets(fetchOp);
let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchFileResult, 1);
......@@ -127,7 +130,7 @@ export default function favoriteTestCallbackTest(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_001_01', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_001_01'
let currentFetchOp = nameFetchOps('Pictures/StaticCb/', '01', IMAGE_TYPE)
let currentFetchOp = nameFetchOps(testNum, 'Pictures/StaticCb/', '01', IMAGE_TYPE)
await favoriteDefaultState(done, testNum, currentFetchOp)
});
......@@ -141,7 +144,7 @@ export default function favoriteTestCallbackTest(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_001_02', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_001_02'
let currentFetchOp = nameFetchOps('Pictures/StaticCb/', '02', IMAGE_TYPE)
let currentFetchOp = nameFetchOps(testNum, 'Pictures/StaticCb/', '02', IMAGE_TYPE)
await favoriteByTrue(done, testNum, currentFetchOp)
});
......@@ -155,7 +158,7 @@ export default function favoriteTestCallbackTest(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_001_03', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_001_03'
let currentFetchOp = nameFetchOps('Pictures/StaticCb/', '03', IMAGE_TYPE)
let currentFetchOp = nameFetchOps(testNum, 'Pictures/StaticCb/', '03', IMAGE_TYPE)
await favoriteByFalse(done, testNum, currentFetchOp)
});
......@@ -169,7 +172,7 @@ export default function favoriteTestCallbackTest(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_002_01', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_002_01'
let currentFetchOp = nameFetchOps('Videos/StaticCb/', '01', VIDEO_TYPE)
let currentFetchOp = nameFetchOps(testNum, 'Videos/StaticCb/', '01', VIDEO_TYPE)
await favoriteDefaultState(done, testNum, currentFetchOp)
});
......@@ -183,7 +186,7 @@ export default function favoriteTestCallbackTest(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_002_02', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_002_02'
let currentFetchOp = nameFetchOps('Videos/StaticCb/', '02', VIDEO_TYPE)
let currentFetchOp = nameFetchOps(testNum, 'Videos/StaticCb/', '02', VIDEO_TYPE)
await favoriteByTrue(done, testNum, currentFetchOp)
});
......@@ -197,7 +200,7 @@ export default function favoriteTestCallbackTest(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_002_03', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_002_03'
let currentFetchOp = nameFetchOps('Videos/StaticCb/', '03', VIDEO_TYPE)
let currentFetchOp = nameFetchOps(testNum, 'Videos/StaticCb/', '03', VIDEO_TYPE)
await favoriteByFalse(done, testNum, currentFetchOp)
});
......@@ -211,7 +214,7 @@ export default function favoriteTestCallbackTest(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_003_01', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_003_01'
let currentFetchOp = nameFetchOps('Audios/StaticCb/', '01', AUDIO_TYPE)
let currentFetchOp = nameFetchOps(testNum, 'Audios/StaticCb/', '01', AUDIO_TYPE)
await favoriteDefaultState(done, testNum, currentFetchOp)
});
......@@ -225,7 +228,7 @@ export default function favoriteTestCallbackTest(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_003_02', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_003_02'
let currentFetchOp = nameFetchOps('Audios/StaticCb/', '02', AUDIO_TYPE)
let currentFetchOp = nameFetchOps(testNum, 'Audios/StaticCb/', '02', AUDIO_TYPE)
await favoriteByTrue(done, testNum, currentFetchOp)
});
......@@ -239,7 +242,7 @@ export default function favoriteTestCallbackTest(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_003_03', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_003_03'
let currentFetchOp = nameFetchOps('Audios/StaticCb/', '03', AUDIO_TYPE)
let currentFetchOp = nameFetchOps(testNum, 'Audios/StaticCb/', '03', AUDIO_TYPE)
await favoriteByFalse(done, testNum, currentFetchOp)
});
......@@ -253,7 +256,7 @@ export default function favoriteTestCallbackTest(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_004_01', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_004_01'
let currentFetchOp = nameFetchOps('Documents/StaticCb/', '01', FILE_TYPE)
let currentFetchOp = nameFetchOps(testNum, 'Documents/StaticCb/', '01', FILE_TYPE)
await favoriteDefaultState(done, testNum, currentFetchOp)
});
......@@ -267,7 +270,7 @@ export default function favoriteTestCallbackTest(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_004_02', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_004_02'
let currentFetchOp = nameFetchOps('Documents/StaticCb/', '02', FILE_TYPE)
let currentFetchOp = nameFetchOps(testNum, 'Documents/StaticCb/', '02', FILE_TYPE)
await favoriteByTrue(done, testNum, currentFetchOp)
});
......@@ -281,7 +284,7 @@ export default function favoriteTestCallbackTest(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_004_03', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_004_03'
let currentFetchOp = nameFetchOps('Documents/StaticCb/', '03', FILE_TYPE)
let currentFetchOp = nameFetchOps(testNum, 'Documents/StaticCb/', '03', FILE_TYPE)
await favoriteByFalse(done, testNum, currentFetchOp)
});
});
......
......@@ -30,16 +30,21 @@ export default function favoriteTestPromiseTest(abilityContext) {
describe('favoriteTestPromiseTest', function () {
var media = mediaLibrary.getMediaLibrary(abilityContext);
beforeAll(async function () {
console.info('beforeAll case');
await checkPresetsAssets(media, 'ActsMediaLibraryFavorite');
});
beforeEach(function () { });
beforeEach(function () {
console.info('beforeEach case');
});
afterEach(async function () {
sleep()
console.info('afterEach case');
await sleep()
});
afterAll(function () {
console.info('afterAll case');
});
afterAll(function () { });
const favoriteDefaultState = async function (done, testNum, fetchOp) {
console.info(`${testNum} fetchOp ${JSON.stringify(fetchOp)}`)
try {
let fetchFileResult = await media.getFileAssets(fetchOp);
let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchFileResult, 1);
......@@ -56,7 +61,6 @@ export default function favoriteTestPromiseTest(abilityContext) {
}
}
const favoriteByTrue = async function (done, testNum, fetchOp) {
console.info(`${testNum} fetchOp ${JSON.stringify(fetchOp)}`)
try {
const fetchFileResult = await media.getFileAssets(fetchOp);
let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchFileResult, 1);
......@@ -74,7 +78,6 @@ export default function favoriteTestPromiseTest(abilityContext) {
}
}
const favoriteByFalse = async function (done, testNum, fetchOp) {
console.info(`${testNum} fetchOp ${JSON.stringify(fetchOp)}`)
try {
const fetchFileResult = await media.getFileAssets(fetchOp);
let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchFileResult, 1);
......@@ -103,7 +106,7 @@ export default function favoriteTestPromiseTest(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_001_01', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_001_01'
let currentFetchOp = nameFetchOps('Pictures/StaticPro/', '01', IMAGE_TYPE)
let currentFetchOp = nameFetchOps(testNum, 'Pictures/StaticPro/', '01', IMAGE_TYPE)
await favoriteDefaultState(done, testNum, currentFetchOp)
});
......@@ -117,7 +120,7 @@ export default function favoriteTestPromiseTest(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_001_02', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_001_02'
let currentFetchOp = nameFetchOps('Pictures/StaticPro/', '02', IMAGE_TYPE)
let currentFetchOp = nameFetchOps(testNum, 'Pictures/StaticPro/', '02', IMAGE_TYPE)
await favoriteByTrue(done, testNum, currentFetchOp)
});
......@@ -131,7 +134,7 @@ export default function favoriteTestPromiseTest(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_001_03', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_001_03'
let currentFetchOp = nameFetchOps('Pictures/StaticPro/', '03', IMAGE_TYPE)
let currentFetchOp = nameFetchOps(testNum, 'Pictures/StaticPro/', '03', IMAGE_TYPE)
await favoriteByFalse(done, testNum, currentFetchOp)
});
......@@ -145,7 +148,7 @@ export default function favoriteTestPromiseTest(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_002_01', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_002_01'
let currentFetchOp = nameFetchOps('Videos/StaticPro/', '01', VIDEO_TYPE)
let currentFetchOp = nameFetchOps(testNum, 'Videos/StaticPro/', '01', VIDEO_TYPE)
await favoriteDefaultState(done, testNum, currentFetchOp)
});
......@@ -159,7 +162,7 @@ export default function favoriteTestPromiseTest(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_002_02', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_002_02'
let currentFetchOp = nameFetchOps('Videos/StaticPro/', '02', VIDEO_TYPE)
let currentFetchOp = nameFetchOps(testNum, 'Videos/StaticPro/', '02', VIDEO_TYPE)
await favoriteByTrue(done, testNum, currentFetchOp)
});
......@@ -173,7 +176,7 @@ export default function favoriteTestPromiseTest(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_002_03', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_002_03'
let currentFetchOp = nameFetchOps('Videos/StaticPro/', '03', VIDEO_TYPE)
let currentFetchOp = nameFetchOps(testNum, 'Videos/StaticPro/', '03', VIDEO_TYPE)
await favoriteByFalse(done, testNum, currentFetchOp)
});
......@@ -187,7 +190,7 @@ export default function favoriteTestPromiseTest(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_003_01', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_003_01'
let currentFetchOp = nameFetchOps('Audios/StaticPro/', '01', AUDIO_TYPE)
let currentFetchOp = nameFetchOps(testNum, 'Audios/StaticPro/', '01', AUDIO_TYPE)
await favoriteDefaultState(done, testNum, currentFetchOp)
});
......@@ -201,7 +204,7 @@ export default function favoriteTestPromiseTest(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_003_02', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_003_02'
let currentFetchOp = nameFetchOps('Audios/StaticPro/', '02', AUDIO_TYPE)
let currentFetchOp = nameFetchOps(testNum, 'Audios/StaticPro/', '02', AUDIO_TYPE)
await favoriteByTrue(done, testNum, currentFetchOp)
});
......@@ -215,7 +218,7 @@ export default function favoriteTestPromiseTest(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_003_03', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_003_03'
let currentFetchOp = nameFetchOps('Audios/StaticPro/', '03', AUDIO_TYPE)
let currentFetchOp = nameFetchOps(testNum, 'Audios/StaticPro/', '03', AUDIO_TYPE)
await favoriteByFalse(done, testNum, currentFetchOp)
});
......@@ -229,7 +232,7 @@ export default function favoriteTestPromiseTest(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_004_01', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_004_01'
let currentFetchOp = nameFetchOps('Documents/StaticPro/', '01', FILE_TYPE)
let currentFetchOp = nameFetchOps(testNum, 'Documents/StaticPro/', '01', FILE_TYPE)
await favoriteDefaultState(done, testNum, currentFetchOp)
});
......@@ -243,7 +246,7 @@ export default function favoriteTestPromiseTest(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_004_02', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_004_02'
let currentFetchOp = nameFetchOps('Documents/StaticPro/', '02', FILE_TYPE)
let currentFetchOp = nameFetchOps(testNum, 'Documents/StaticPro/', '02', FILE_TYPE)
await favoriteByTrue(done, testNum, currentFetchOp)
});
......@@ -257,7 +260,7 @@ export default function favoriteTestPromiseTest(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_004_03', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_004_03'
let currentFetchOp = nameFetchOps('Documents/StaticPro/', '03', FILE_TYPE)
let currentFetchOp = nameFetchOps(testNum, 'Documents/StaticPro/', '03', FILE_TYPE)
await favoriteByFalse(done, testNum, currentFetchOp)
});
});
......
......@@ -52,6 +52,7 @@
"hilog -Q pidoff",
"hilog -p off",
"hilog -b I",
"setenforce 0",
"hilog -b D -D 0xD002B70",
"scanner_demo",
"sleep 10"
......
......@@ -37,14 +37,20 @@ export default function fileTestCallbackTest(abilityContext) {
describe('fileTestCallbackTest', function () {
const media = mediaLibrary.getMediaLibrary(abilityContext);
beforeAll(async function () {
console.info('beforeAll case');
await getPermission();
await checkPresetsAssets(media, 'ActsMediaLibraryFile')
});
beforeEach(function () { });
beforeEach(function () {
console.info('beforeEach case');
});
afterEach(async function () {
await sleep()
console.info('afterEach case');
await sleep(400)
});
afterAll(function () {
console.info('afterAll case');
});
afterAll(function () { });
async function copyFile(fd1, fd2) {
let stat = await fileio.fstat(fd1);
......@@ -55,8 +61,6 @@ export default function fileTestCallbackTest(abilityContext) {
const creatAssetTest = async (done, testNum, fetchOp, path, type, name) => {
try {
const fetchFileResult = await media.getFileAssets(fetchOp);
console.info(`${testNum} fetchOp: ${JSON.stringify(fetchOp)}`)
let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchFileResult, 1);
if (!checkAssetCountPass) return;
const asset = await fetchFileResult.getFirstObject();
......@@ -93,8 +97,6 @@ export default function fileTestCallbackTest(abilityContext) {
const checkCreatAssetProps = async (done, testNum, fetchOp, path, type, name, key, val) => {
try {
const fetchFileResult = await media.getFileAssets(fetchOp);
console.info(`${testNum} fetchOp: ${JSON.stringify(fetchOp)}`)
let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchFileResult, 1);
if (!checkAssetCountPass) return;
const asset = await fetchFileResult.getFirstObject();
......@@ -128,8 +130,6 @@ export default function fileTestCallbackTest(abilityContext) {
const checkdateModified = async (done, testNum, fetchOp) => {
try {
let fetchFileResult = await media.getFileAssets(fetchOp);
console.info(`${testNum} fetchOp: ${JSON.stringify(fetchOp)}`)
let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchFileResult, 1);
if (!checkAssetCountPass) return;
let asset = await fetchFileResult.getFirstObject();
......@@ -167,9 +167,9 @@ export default function fileTestCallbackTest(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_001_01', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_001_01';
let currentFetchOp = nameFetchOps('Pictures/Static/', '01', IMAGE_TYPE)
let currentFetchOp = nameFetchOps(testNum, 'Pictures/Static/', '01', IMAGE_TYPE)
let name = 'jpg'
let path = await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_IMAGE) + '/create/'
let path = await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_IMAGE) + 'create/'
let type = IMAGE_TYPE;
await creatAssetTest(done, testNum, currentFetchOp, path, type, name)
});
......@@ -184,9 +184,9 @@ export default function fileTestCallbackTest(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_001_02', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_001_02';
let currentFetchOp = nameFetchOps('Pictures/Static/', '02', IMAGE_TYPE)
let currentFetchOp = nameFetchOps(testNum, 'Pictures/Static/', '02', IMAGE_TYPE)
let name = 'jpg'
let path = await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_IMAGE) + '/create/';
let path = await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_IMAGE) + 'create/';
let type = IMAGE_TYPE;
let key = 'displayName';
let val = 'displayName';
......@@ -203,9 +203,9 @@ export default function fileTestCallbackTest(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_001_03', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_001_03';
let currentFetchOp = nameFetchOps('Pictures/Static/', '03', IMAGE_TYPE)
let currentFetchOp = nameFetchOps(testNum, 'Pictures/Static/', '03', IMAGE_TYPE)
let name = 'jpg'
let path = await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_IMAGE) + '/create/';
let path = await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_IMAGE) + 'create/';
let type = IMAGE_TYPE;
let key = 'relativePath';
let val = path;
......@@ -222,7 +222,7 @@ export default function fileTestCallbackTest(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_001_07', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_001_07';
let currentFetchOp = fetchOps('Pictures/Dynamic/', IMAGE_TYPE)
let currentFetchOp = fetchOps(testNum, 'Pictures/Dynamic/', IMAGE_TYPE)
await checkdateModified(done, testNum, currentFetchOp)
});
......@@ -236,9 +236,9 @@ export default function fileTestCallbackTest(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_001_08', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_001_08';
let currentFetchOp = nameFetchOps('Pictures/Static/', '04', IMAGE_TYPE)
let currentFetchOp = nameFetchOps(testNum, 'Pictures/Static/', '04', IMAGE_TYPE)
let name = 'jpg'
let path = await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_IMAGE) + '/create/';
let path = await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_IMAGE) + 'create/';
let type = IMAGE_TYPE;
let key = 'mediaType';
let val = IMAGE_TYPE;
......@@ -255,9 +255,9 @@ export default function fileTestCallbackTest(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_001_11', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_001_11';
let currentFetchOp = nameFetchOps('Pictures/Static/', '05', IMAGE_TYPE)
let currentFetchOp = nameFetchOps(testNum, 'Pictures/Static/', '05', IMAGE_TYPE)
let name = 'jpg'
let path = await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_IMAGE) + '/create/';
let path = await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_IMAGE) + 'create/';
let type = IMAGE_TYPE;
let key = 'orientation';
let val = 0;
......@@ -277,9 +277,9 @@ export default function fileTestCallbackTest(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_002_01', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_002_01';
let currentFetchOp = nameFetchOps('Videos/Static/', '01', VIDEO_TYPE)
let currentFetchOp = nameFetchOps(testNum, 'Videos/Static/', '01', VIDEO_TYPE)
let name = 'mp4'
let path = await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_VIDEO) + '/create/'
let path = await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_VIDEO) + 'create/'
let type = VIDEO_TYPE;
await creatAssetTest(done, testNum, currentFetchOp, path, type, name)
});
......@@ -294,9 +294,9 @@ export default function fileTestCallbackTest(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_002_02', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_002_02';
let currentFetchOp = nameFetchOps('Videos/Static/', '02', VIDEO_TYPE)
let currentFetchOp = nameFetchOps(testNum, 'Videos/Static/', '02', VIDEO_TYPE)
let name = 'mp4'
let path = await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_VIDEO) + '/create/';
let path = await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_VIDEO) + 'create/';
let type = VIDEO_TYPE;
let key = 'displayName';
let val = 'displayName';
......@@ -313,9 +313,9 @@ export default function fileTestCallbackTest(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_002_03', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_002_03';
let currentFetchOp = nameFetchOps('Videos/Static/', '03', VIDEO_TYPE)
let currentFetchOp = nameFetchOps(testNum, 'Videos/Static/', '03', VIDEO_TYPE)
let name = 'mp4'
let path = await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_VIDEO) + '/create/';
let path = await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_VIDEO) + 'create/';
let type = VIDEO_TYPE;
let key = 'relativePath';
let val = path;
......@@ -332,7 +332,7 @@ export default function fileTestCallbackTest(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_002_07', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_002_07';
let currentFetchOp = fetchOps('Videos/Dynamic/', VIDEO_TYPE)
let currentFetchOp = fetchOps(testNum, 'Videos/Dynamic/', VIDEO_TYPE)
await checkdateModified(done, testNum, currentFetchOp)
});
......@@ -346,9 +346,9 @@ export default function fileTestCallbackTest(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_002_08', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_002_08';
let currentFetchOp = nameFetchOps('Videos/Static/', '04', VIDEO_TYPE)
let currentFetchOp = nameFetchOps(testNum, 'Videos/Static/', '04', VIDEO_TYPE)
let name = 'mp4'
let path = await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_VIDEO) + '/create/';
let path = await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_VIDEO) + 'create/';
let type = VIDEO_TYPE;
let key = 'mediaType';
let val = VIDEO_TYPE;
......@@ -365,9 +365,9 @@ export default function fileTestCallbackTest(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_002_11', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_002_11';
let currentFetchOp = nameFetchOps('Videos/Static/', '05', VIDEO_TYPE)
let currentFetchOp = nameFetchOps(testNum, 'Videos/Static/', '05', VIDEO_TYPE)
let name = 'mp4'
let path = await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_VIDEO) + '/create/';
let path = await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_VIDEO) + 'create/';
let type = VIDEO_TYPE;
let key = 'orientation';
let val = 0;
......@@ -386,9 +386,9 @@ export default function fileTestCallbackTest(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_003_01', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_003_01';
let currentFetchOp = nameFetchOps('Audios/Static/', '01', AUDIO_TYPE)
let currentFetchOp = nameFetchOps(testNum, 'Audios/Static/', '01', AUDIO_TYPE)
let name = 'mp3'
let path = await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_AUDIO) + '/create/'
let path = await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_AUDIO) + 'create/'
let type = AUDIO_TYPE;
await creatAssetTest(done, testNum, currentFetchOp, path, type, name)
});
......@@ -403,9 +403,9 @@ export default function fileTestCallbackTest(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_003_02', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_003_02';
let currentFetchOp = nameFetchOps('Audios/Static/', '02', AUDIO_TYPE)
let currentFetchOp = nameFetchOps(testNum, 'Audios/Static/', '02', AUDIO_TYPE)
let name = 'mp3'
let path = await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_AUDIO) + '/create/';
let path = await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_AUDIO) + 'create/';
let type = AUDIO_TYPE;
let key = 'displayName';
let val = 'displayName';
......@@ -422,9 +422,9 @@ export default function fileTestCallbackTest(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_003_03', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_003_03';
let currentFetchOp = nameFetchOps('Audios/Static/', '03', AUDIO_TYPE)
let currentFetchOp = nameFetchOps(testNum, 'Audios/Static/', '03', AUDIO_TYPE)
let name = 'mp3'
let path = await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_AUDIO) + '/create/';
let path = await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_AUDIO) + 'create/';
let type = AUDIO_TYPE;
let key = 'relativePath';
let val = path;
......@@ -441,7 +441,7 @@ export default function fileTestCallbackTest(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_003_07', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_003_07';
let currentFetchOp = fetchOps('Audios/Dynamic/', AUDIO_TYPE)
let currentFetchOp = fetchOps(testNum, 'Audios/Dynamic/', AUDIO_TYPE)
await checkdateModified(done, testNum, currentFetchOp)
});
......@@ -455,9 +455,9 @@ export default function fileTestCallbackTest(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_003_08', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_003_08';
let currentFetchOp = nameFetchOps('Audios/Static/', '05', AUDIO_TYPE)
let currentFetchOp = nameFetchOps(testNum, 'Audios/Static/', '05', AUDIO_TYPE)
let name = 'mp3'
let path = await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_AUDIO) + '/create/';
let path = await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_AUDIO) + 'create/';
let type = AUDIO_TYPE;
let key = 'mediaType';
let val = AUDIO_TYPE;
......@@ -477,9 +477,9 @@ export default function fileTestCallbackTest(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_004_01', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_004_01';
let currentFetchOp = nameFetchOps('Documents/Static/', '01', FILE_TYPE)
let currentFetchOp = nameFetchOps(testNum, 'Documents/Static/', '01', FILE_TYPE)
let name = 'dat'
let path = await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_DOCUMENTS) + '/create/'
let path = await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_DOCUMENTS) + 'create/'
let type = FILE_TYPE;
await creatAssetTest(done, testNum, currentFetchOp, path, type, name)
});
......@@ -494,9 +494,9 @@ export default function fileTestCallbackTest(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_004_02', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_004_02';
let currentFetchOp = nameFetchOps('Documents/Static/', '02', FILE_TYPE)
let currentFetchOp = nameFetchOps(testNum, 'Documents/Static/', '02', FILE_TYPE)
let name = 'dat'
let path = await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_DOCUMENTS) + '/create/';
let path = await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_DOCUMENTS) + 'create/';
let type = FILE_TYPE;
let key = 'displayName';
let val = 'displayName';
......@@ -513,9 +513,9 @@ export default function fileTestCallbackTest(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_004_03', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_004_03';
let currentFetchOp = nameFetchOps('Documents/Static/', '03', FILE_TYPE)
let currentFetchOp = nameFetchOps(testNum, 'Documents/Static/', '03', FILE_TYPE)
let name = 'dat'
let path = await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_DOCUMENTS) + '/create/';
let path = await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_DOCUMENTS) + 'create/';
let type = FILE_TYPE;
let key = 'relativePath';
let val = path;
......@@ -532,7 +532,7 @@ export default function fileTestCallbackTest(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_004_07', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_004_07';
let currentFetchOp = fetchOps('Documents/Dynamic/', FILE_TYPE)
let currentFetchOp = fetchOps(testNum, 'Documents/Dynamic/', FILE_TYPE)
await checkdateModified(done, testNum, currentFetchOp)
});
......@@ -546,9 +546,9 @@ export default function fileTestCallbackTest(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_004_08', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_004_08';
let currentFetchOp = nameFetchOps('Documents/Static/', '04', FILE_TYPE)
let currentFetchOp = nameFetchOps(testNum, 'Documents/Static/', '04', FILE_TYPE)
let name = 'dat'
let path = await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_DOCUMENTS) + '/create/';
let path = await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_DOCUMENTS) + 'create/';
let type = FILE_TYPE;
let key = 'mediaType';
let val = FILE_TYPE;
......
......@@ -36,13 +36,19 @@ export default function fileTestPromiseTest(abilityContext) {
describe('fileTestPromiseTest', function () {
const media = mediaLibrary.getMediaLibrary(abilityContext);
beforeAll(async function () {
console.info('beforeAll case');
await checkPresetsAssets(media, 'ActsMediaLibraryFile')
});
beforeEach(function () { });
beforeEach(function () {
console.info('beforeEach case');
});
afterEach(async function () {
await sleep()
console.info('afterEach case');
await sleep(200)
});
afterAll(function () {
console.info('afterAll case');
});
afterAll(function () { });
async function copyFile(fd1, fd2) {
let stat = await fileio.fstat(fd1);
......@@ -53,8 +59,6 @@ export default function fileTestPromiseTest(abilityContext) {
const creatAssetTest = async (done, testNum, fetchOp, path, type, name) => {
try {
const fetchFileResult = await media.getFileAssets(fetchOp);
console.info(`${testNum} fetchOp: ${JSON.stringify(fetchOp)}`)
let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchFileResult, 1);
if (!checkAssetCountPass) return;
const asset = await fetchFileResult.getFirstObject();
......@@ -86,8 +90,6 @@ export default function fileTestPromiseTest(abilityContext) {
const checkCreatAssetProps = async (done, testNum, fetchOp, path, type, name, key, val) => {
try {
const fetchFileResult = await media.getFileAssets(fetchOp);
console.info(`${testNum} fetchOp: ${JSON.stringify(fetchOp)}`)
let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchFileResult, 1);
if (!checkAssetCountPass) return;
const asset = await fetchFileResult.getFirstObject();
......@@ -117,8 +119,6 @@ export default function fileTestPromiseTest(abilityContext) {
const checkdateModified = async (done, testNum, fetchOp) => {
try {
let fetchFileResult = await media.getFileAssets(fetchOp);
console.info(`${testNum} fetchOp: ${JSON.stringify(fetchOp)}`)
let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchFileResult, 1);
if (!checkAssetCountPass) return;
let asset = await fetchFileResult.getFirstObject();
......@@ -151,9 +151,9 @@ export default function fileTestPromiseTest(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_001_01', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_001_01';
let currentFetchOp = nameFetchOps('Pictures/Static/', '01', IMAGE_TYPE)
let currentFetchOp = nameFetchOps(testNum, 'Pictures/Static/', '01', IMAGE_TYPE)
let name = 'jpg'
let path = await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_IMAGE) + '/create/'
let path = await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_IMAGE) + 'create/'
let type = IMAGE_TYPE;
await creatAssetTest(done, testNum, currentFetchOp, path, type, name)
});
......@@ -168,9 +168,9 @@ export default function fileTestPromiseTest(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_001_02', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_001_02';
let currentFetchOp = nameFetchOps('Pictures/Static/', '02', IMAGE_TYPE)
let currentFetchOp = nameFetchOps(testNum, 'Pictures/Static/', '02', IMAGE_TYPE)
let name = 'jpg'
let path = await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_IMAGE) + '/create/';
let path = await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_IMAGE) + 'create/';
let type = IMAGE_TYPE;
let key = 'displayName';
let val = 'displayName';
......@@ -187,9 +187,9 @@ export default function fileTestPromiseTest(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_001_03', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_001_03';
let currentFetchOp = nameFetchOps('Pictures/Static/', '03', IMAGE_TYPE)
let currentFetchOp = nameFetchOps(testNum, 'Pictures/Static/', '03', IMAGE_TYPE)
let name = 'jpg'
let path = await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_IMAGE) + '/create/';
let path = await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_IMAGE) + 'create/';
let type = IMAGE_TYPE;
let key = 'relativePath';
let val = path;
......@@ -206,7 +206,7 @@ export default function fileTestPromiseTest(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_001_07', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_001_07';
let currentFetchOp = fetchOps('Pictures/Dynamic/', IMAGE_TYPE)
let currentFetchOp = fetchOps(testNum, 'Pictures/Dynamic/', IMAGE_TYPE)
await checkdateModified(done, testNum, currentFetchOp)
});
......@@ -220,9 +220,9 @@ export default function fileTestPromiseTest(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_001_08', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_001_08';
let currentFetchOp = nameFetchOps('Pictures/Static/', '04', IMAGE_TYPE)
let currentFetchOp = nameFetchOps(testNum, 'Pictures/Static/', '04', IMAGE_TYPE)
let name = 'jpg'
let path = await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_IMAGE) + '/create/';
let path = await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_IMAGE) + 'create/';
let type = IMAGE_TYPE;
let key = 'mediaType';
let val = IMAGE_TYPE;
......@@ -239,9 +239,9 @@ export default function fileTestPromiseTest(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_001_11', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_001_11';
let currentFetchOp = nameFetchOps('Pictures/Static/', '05', IMAGE_TYPE)
let currentFetchOp = nameFetchOps(testNum, 'Pictures/Static/', '05', IMAGE_TYPE)
let name = 'jpg'
let path = await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_IMAGE) + '/create/';
let path = await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_IMAGE) + 'create/';
let type = IMAGE_TYPE;
let key = 'orientation';
let val = 0;
......@@ -261,9 +261,9 @@ export default function fileTestPromiseTest(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_002_01', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_002_01';
let currentFetchOp = nameFetchOps('Videos/Static/', '01', VIDEO_TYPE)
let currentFetchOp = nameFetchOps(testNum, 'Videos/Static/', '01', VIDEO_TYPE)
let name = 'mp4'
let path = await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_VIDEO) + '/create/'
let path = await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_VIDEO) + 'create/'
let type = VIDEO_TYPE;
await creatAssetTest(done, testNum, currentFetchOp, path, type, name)
});
......@@ -278,9 +278,9 @@ export default function fileTestPromiseTest(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_002_02', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_002_02';
let currentFetchOp = nameFetchOps('Videos/Static/', '02', VIDEO_TYPE)
let currentFetchOp = nameFetchOps(testNum, 'Videos/Static/', '02', VIDEO_TYPE)
let name = 'mp4'
let path = await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_VIDEO) + '/create/';
let path = await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_VIDEO) + 'create/';
let type = VIDEO_TYPE;
let key = 'displayName';
let val = 'displayName';
......@@ -297,9 +297,9 @@ export default function fileTestPromiseTest(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_002_03', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_002_03';
let currentFetchOp = nameFetchOps('Videos/Static/', '03', VIDEO_TYPE)
let currentFetchOp = nameFetchOps(testNum, 'Videos/Static/', '03', VIDEO_TYPE)
let name = 'mp4'
let path = await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_VIDEO) + '/create/';
let path = await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_VIDEO) + 'create/';
let type = VIDEO_TYPE;
let key = 'relativePath';
let val = path;
......@@ -316,7 +316,7 @@ export default function fileTestPromiseTest(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_002_07', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_002_07';
let currentFetchOp = fetchOps('Videos/Dynamic/', VIDEO_TYPE)
let currentFetchOp = fetchOps(testNum, 'Videos/Dynamic/', VIDEO_TYPE)
await checkdateModified(done, testNum, currentFetchOp)
});
......@@ -330,9 +330,9 @@ export default function fileTestPromiseTest(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_002_08', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_002_08';
let currentFetchOp = nameFetchOps('Videos/Static/', '04', VIDEO_TYPE)
let currentFetchOp = nameFetchOps(testNum, 'Videos/Static/', '04', VIDEO_TYPE)
let name = 'mp4'
let path = await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_VIDEO) + '/create/';
let path = await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_VIDEO) + 'create/';
let type = VIDEO_TYPE;
let key = 'mediaType';
let val = VIDEO_TYPE;
......@@ -349,9 +349,9 @@ export default function fileTestPromiseTest(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_002_11', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_002_11';
let currentFetchOp = nameFetchOps('Videos/Static/', '05', VIDEO_TYPE)
let currentFetchOp = nameFetchOps(testNum, 'Videos/Static/', '05', VIDEO_TYPE)
let name = 'mp4'
let path = await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_VIDEO) + '/create/';
let path = await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_VIDEO) + 'create/';
let type = VIDEO_TYPE;
let key = 'orientation';
let val = 0;
......@@ -370,9 +370,9 @@ export default function fileTestPromiseTest(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_003_01', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_003_01';
let currentFetchOp = nameFetchOps('Audios/Static/', '01', AUDIO_TYPE)
let currentFetchOp = nameFetchOps(testNum, 'Audios/Static/', '01', AUDIO_TYPE)
let name = 'mp3'
let path = await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_AUDIO) + '/create/'
let path = await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_AUDIO) + 'create/'
let type = AUDIO_TYPE;
await creatAssetTest(done, testNum, currentFetchOp, path, type, name)
});
......@@ -387,9 +387,9 @@ export default function fileTestPromiseTest(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_003_02', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_003_02';
let currentFetchOp = nameFetchOps('Audios/Static/', '02', AUDIO_TYPE)
let currentFetchOp = nameFetchOps(testNum, 'Audios/Static/', '02', AUDIO_TYPE)
let name = 'mp3'
let path = await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_AUDIO) + '/create/';
let path = await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_AUDIO) + 'create/';
let type = AUDIO_TYPE;
let key = 'displayName';
let val = 'displayName';
......@@ -406,9 +406,9 @@ export default function fileTestPromiseTest(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_003_03', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_003_03';
let currentFetchOp = nameFetchOps('Audios/Static/', '03', AUDIO_TYPE)
let currentFetchOp = nameFetchOps(testNum, 'Audios/Static/', '03', AUDIO_TYPE)
let name = 'mp3'
let path = await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_AUDIO) + '/create/';
let path = await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_AUDIO) + 'create/';
let type = AUDIO_TYPE;
let key = 'relativePath';
let val = path;
......@@ -425,7 +425,7 @@ export default function fileTestPromiseTest(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_003_07', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_003_07';
let currentFetchOp = fetchOps('Audios/Dynamic/', AUDIO_TYPE)
let currentFetchOp = fetchOps(testNum, 'Audios/Dynamic/', AUDIO_TYPE)
await checkdateModified(done, testNum, currentFetchOp)
});
......@@ -439,9 +439,9 @@ export default function fileTestPromiseTest(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_003_08', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_003_08';
let currentFetchOp = nameFetchOps('Audios/Static/', '05', AUDIO_TYPE)
let currentFetchOp = nameFetchOps(testNum, 'Audios/Static/', '05', AUDIO_TYPE)
let name = 'mp3'
let path = await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_AUDIO) + '/create/';
let path = await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_AUDIO) + 'create/';
let type = AUDIO_TYPE;
let key = 'mediaType';
let val = AUDIO_TYPE;
......@@ -461,9 +461,9 @@ export default function fileTestPromiseTest(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_004_01', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_004_01';
let currentFetchOp = nameFetchOps('Documents/Static/', '01', FILE_TYPE)
let currentFetchOp = nameFetchOps(testNum, 'Documents/Static/', '01', FILE_TYPE)
let name = 'dat'
let path = await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_DOCUMENTS) + '/create/'
let path = await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_DOCUMENTS) + 'create/'
let type = FILE_TYPE;
await creatAssetTest(done, testNum, currentFetchOp, path, type, name)
});
......@@ -478,9 +478,9 @@ export default function fileTestPromiseTest(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_004_02', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_004_02';
let currentFetchOp = nameFetchOps('Documents/Static/', '02', FILE_TYPE)
let currentFetchOp = nameFetchOps(testNum, 'Documents/Static/', '02', FILE_TYPE)
let name = 'dat'
let path = await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_DOCUMENTS) + '/create/';
let path = await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_DOCUMENTS) + 'create/';
let type = FILE_TYPE;
let key = 'displayName';
let val = 'displayName';
......@@ -497,9 +497,9 @@ export default function fileTestPromiseTest(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_004_03', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_004_03';
let currentFetchOp = nameFetchOps('Documents/Static/', '03', FILE_TYPE)
let currentFetchOp = nameFetchOps(testNum, 'Documents/Static/', '03', FILE_TYPE)
let name = 'dat'
let path = await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_DOCUMENTS) + '/create/';
let path = await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_DOCUMENTS) + 'create/';
let type = FILE_TYPE;
let key = 'relativePath';
let val = path;
......@@ -516,7 +516,7 @@ export default function fileTestPromiseTest(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_004_07', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_004_07';
let currentFetchOp = fetchOps('Documents/Dynamic/', FILE_TYPE)
let currentFetchOp = fetchOps(testNum, 'Documents/Dynamic/', FILE_TYPE)
await checkdateModified(done, testNum, currentFetchOp)
});
......@@ -530,9 +530,9 @@ export default function fileTestPromiseTest(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_004_08', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_004_08';
let currentFetchOp = nameFetchOps('Documents/Static/', '04', FILE_TYPE)
let currentFetchOp = nameFetchOps(testNum, 'Documents/Static/', '04', FILE_TYPE)
let name = 'dat'
let path = await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_DOCUMENTS) + '/create/';
let path = await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_DOCUMENTS) + 'create/';
let type = FILE_TYPE;
let key = 'mediaType';
let val = FILE_TYPE;
......
......@@ -42,7 +42,7 @@
"for d in RW_cb R_cb W_cb RW R W openClose; do for i in $$(seq 2); do cp /data/accounts/account_0/appdata/com.ohos.medialibrary.medialibrarydata/01.mp4 /storage/media/100/local/files/Videos/$$d/0$$i.mp4; done;done;",
"for d in RW_cb R_cb W_cb RW R W openClose; do for i in $$(seq 2); do cp /data/accounts/account_0/appdata/com.ohos.medialibrary.medialibrarydata/01.dat /storage/media/100/local/files/Documents/$$d/0$$i.dat; done;done;",
"for d in ModifyCb ModifyPro; do for i in $$(seq 5); do cp /data/accounts/account_0/appdata/com.ohos.medialibrary.medialibrarydata/01.jpg /storage/media/100/local/files/Pictures/$$d/0$$i.jpg; done;done;",
"for d in ModifyCb ModifyPro; do for i in $$(seq 7); do cp /data/accounts/account_0/appdata/com.ohos.medialibrary.medialibrarydata/01.jpg /storage/media/100/local/files/Pictures/$$d/0$$i.jpg; done;done;",
"for d in ModifyCb ModifyPro; do for i in $$(seq 5); do cp /data/accounts/account_0/appdata/com.ohos.medialibrary.medialibrarydata/01.mp3 /storage/media/100/local/files/Audios/$$d/0$$i.mp3; done;done;",
"for d in ModifyCb ModifyPro; do for i in $$(seq 5); do cp /data/accounts/account_0/appdata/com.ohos.medialibrary.medialibrarydata/01.mp4 /storage/media/100/local/files/Videos/$$d/0$$i.mp4; done;done;",
"for d in ModifyCb ModifyPro; do for i in $$(seq 5); do cp /data/accounts/account_0/appdata/com.ohos.medialibrary.medialibrarydata/01.dat /storage/media/100/local/files/Documents/$$d/0$$i.dat; done;done;",
......
......@@ -31,18 +31,23 @@ export default function fileAssetCallback2Test(abilityContext) {
describe('fileAssetCallback2Test', function () {
const media = mediaLibrary.getMediaLibrary(abilityContext);
beforeAll(async function () {
console.info('beforeAll case');
await getPermission();
await checkPresetsAssets(media, 'ActsMediaLibraryFileAsset')
});
beforeEach(function () { });
beforeEach(function () {
console.info('beforeEach case');
});
afterEach(async function () {
console.info('afterEach case');
await sleep()
});
afterAll(function () { });
afterAll(function () {
console.info('afterAll case');
});
const checkCommitModify = async function (done, testNum, fetchOp, prop, val) {
try {
console.info(`${testNum} fetchOp : ${JSON.stringify(fetchOp)}`)
const fetchFileResult = await media.getFileAssets(fetchOp);
let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchFileResult, 1);
if (!checkAssetCountPass) return;
......@@ -78,6 +83,7 @@ export default function fileAssetCallback2Test(abilityContext) {
}
}
/**
* @tc.number : SUB_MEDIA_FILEASSET_commitModify_callback_001
* @tc.name : commitModify
......@@ -88,7 +94,7 @@ export default function fileAssetCallback2Test(abilityContext) {
*/
it('SUB_MEDIA_FILEASSET_commitModify_callback_001', 0, async function (done) {
let testNum = 'SUB_MEDIA_FILEASSET_commitModify_callback_001'
let fetchOp = nameFetchOps('Pictures/ModifyCb/', '01', IMAGE_TYPE);
let fetchOp = nameFetchOps(testNum, 'Pictures/ModifyCb/', '01', IMAGE_TYPE);
let prop = 'displayName'
let val = new Date().getTime() + '.jpg'
await checkCommitModify(done, testNum, fetchOp, prop, val)
......@@ -104,7 +110,7 @@ export default function fileAssetCallback2Test(abilityContext) {
*/
it('SUB_MEDIA_FILEASSET_commitModify_callback_002', 0, async function (done) {
let testNum = 'SUB_MEDIA_FILEASSET_commitModify_callback_002'
let fetchOp = nameFetchOps('Pictures/ModifyCb/', '02', IMAGE_TYPE);
let fetchOp = nameFetchOps(testNum, 'Pictures/ModifyCb/', '02', IMAGE_TYPE);
let prop = 'title'
let val = new Date().getTime() + 'newTitle'
await checkCommitModify(done, testNum, fetchOp, prop, val)
......@@ -120,7 +126,7 @@ export default function fileAssetCallback2Test(abilityContext) {
*/
it('SUB_MEDIA_FILEASSET_commitModify_callback_003', 0, async function (done) {
let testNum = 'SUB_MEDIA_FILEASSET_commitModify_callback_003'
let fetchOp = nameFetchOps('Pictures/ModifyCb/', '03', IMAGE_TYPE);
let fetchOp = nameFetchOps(testNum, 'Pictures/ModifyCb/', '03', IMAGE_TYPE);
let prop = 'relativePath'
let val = 'Pictures/Temp/'
await checkCommitModify(done, testNum, fetchOp, prop, val)
......@@ -137,7 +143,7 @@ export default function fileAssetCallback2Test(abilityContext) {
it('SUB_MEDIA_FILEASSET_commitModify_callback_004', 0, async function (done) {
let testNum = 'SUB_MEDIA_FILEASSET_commitModify_callback_004'
let fetchOp = nameFetchOps('Pictures/ModifyCb/', '04', IMAGE_TYPE);
let fetchOp = nameFetchOps(testNum, 'Pictures/ModifyCb/', '04', IMAGE_TYPE);
let prop = 'orientation'
let val = 1
await checkCommitModify(done, testNum, fetchOp, prop, val)
......@@ -153,7 +159,8 @@ export default function fileAssetCallback2Test(abilityContext) {
*/
it('SUB_MEDIA_FILEASSET_isDirectory_callback_001', 0, async function (done) {
try {
let fetchOp = nameFetchOps('Pictures/ModifyCb/', '05', IMAGE_TYPE);
let testNum = 'SUB_MEDIA_FILEASSET_isDirectory_callback_001'
let fetchOp = nameFetchOps(testNum, 'Pictures/ModifyCb/', '05', IMAGE_TYPE);
const fetchFileResult = await media.getFileAssets(fetchOp);
const asset = await fetchFileResult.getFirstObject();
const isDir = await asset.isDirectory();
......
......@@ -30,17 +30,22 @@ export default function fileAssetPromise2Test(abilityContext) {
describe('fileAssetPromise2Test', function () {
const media = mediaLibrary.getMediaLibrary(abilityContext);
beforeAll(async function () {
console.info('beforeAll case');
await checkPresetsAssets(media, 'ActsMediaLibraryFileAsset')
});
beforeEach(function () { });
beforeEach(function () {
console.info('beforeEach case');
});
afterEach(async function () {
console.info('afterEach case');
await sleep()
});
afterAll(function () { });
afterAll(function () {
console.info('afterAll case');
});
const checkCommitModify = async function (done, testNum, fetchOp, prop, val) {
try {
console.info(`${testNum} fetchOp : ${JSON.stringify(fetchOp)}`)
const fetchFileResult = await media.getFileAssets(fetchOp);
let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchFileResult, 1);
if (!checkAssetCountPass) return;
......@@ -67,7 +72,29 @@ export default function fileAssetPromise2Test(abilityContext) {
done();
}
}
const staticPropsCommitModify = async (done, testNum, fetchOp, prop, val) => {
try {
const fetchFileResult = await media.getFileAssets(fetchOp);
let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchFileResult, 1);
if (!checkAssetCountPass) return;
const asset = await fetchFileResult.getFirstObject();
try {
asset[prop] = val;
console.info(`${testNum} failed`)
expect(false).assertTrue();
done();
} catch (error) {
console.info(`${testNum} passed : ${error}`)
expect(true).assertTrue();
done();
}
done();
} catch (error) {
console.info(`${testNum} error : ${error}`)
expect(false).assertTrue();
done();
}
}
/**
* @tc.number : SUB_MEDIA_FILEASSET_commitModify_promise_001
* @tc.name : commitModify
......@@ -78,7 +105,7 @@ export default function fileAssetPromise2Test(abilityContext) {
*/
it('SUB_MEDIA_FILEASSET_commitModify_promise_001', 0, async function (done) {
let testNum = 'SUB_MEDIA_FILEASSET_commitModify_promise_001'
let fetchOp = nameFetchOps('Pictures/ModifyPro/', '01', IMAGE_TYPE);
let fetchOp = nameFetchOps(testNum, 'Pictures/ModifyPro/', '01', IMAGE_TYPE);
let prop = 'displayName'
let val = new Date().getTime() + '.jpg'
await checkCommitModify(done, testNum, fetchOp, prop, val)
......@@ -94,7 +121,7 @@ export default function fileAssetPromise2Test(abilityContext) {
*/
it('SUB_MEDIA_FILEASSET_commitModify_promise_002', 0, async function (done) {
let testNum = 'SUB_MEDIA_FILEASSET_commitModify_promise_002'
let fetchOp = nameFetchOps('Pictures/ModifyPro/', '02', IMAGE_TYPE);
let fetchOp = nameFetchOps(testNum, 'Pictures/ModifyPro/', '02', IMAGE_TYPE);
let prop = 'title'
let val = new Date().getTime() + 'newTitle'
await checkCommitModify(done, testNum, fetchOp, prop, val)
......@@ -110,7 +137,7 @@ export default function fileAssetPromise2Test(abilityContext) {
*/
it('SUB_MEDIA_FILEASSET_commitModify_promise_003', 0, async function (done) {
let testNum = 'SUB_MEDIA_FILEASSET_commitModify_promise_003'
let fetchOp = nameFetchOps('Pictures/ModifyPro/', '03', IMAGE_TYPE);
let fetchOp = nameFetchOps(testNum, 'Pictures/ModifyPro/', '03', IMAGE_TYPE);
let prop = 'relativePath'
let val = 'Pictures/Temp/'
await checkCommitModify(done, testNum, fetchOp, prop, val)
......@@ -125,14 +152,45 @@ export default function fileAssetPromise2Test(abilityContext) {
* @tc.level : Level 0
*/
it('SUB_MEDIA_FILEASSET_commitModify_promise_004', 0, async function (done) {
let testNum = 'SUB_MEDIA_FILEASSET_commitModify_promise_004'
let fetchOp = nameFetchOps('Pictures/ModifyPro/', '04', IMAGE_TYPE);
let fetchOp = nameFetchOps(testNum, 'Pictures/ModifyPro/', '04', IMAGE_TYPE);
let prop = 'orientation'
let val = 1
await checkCommitModify(done, testNum, fetchOp, prop, val)
});
/**
* @tc.number : SUB_MEDIA_FILEASSET_commitModify_promise_005
* @tc.name : commitModify
* @tc.desc : Modify uri
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MEDIA_FILEASSET_commitModify_promise_005', 0, async function (done) {
let testNum = 'SUB_MEDIA_FILEASSET_commitModify_promise_005'
let fetchOp = nameFetchOps(testNum, 'Pictures/ModifyPro/', '06', IMAGE_TYPE);
let prop = 'uri'
let val = 'newUri'
await staticPropsCommitModify(done, testNum, fetchOp, prop, val)
});
/**
* @tc.number : SUB_MEDIA_FILEASSET_commitModify_promise_006
* @tc.name : commitModify
* @tc.desc : Modify mediaType
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MEDIA_FILEASSET_commitModify_promise_006', 0, async function (done) {
let testNum = 'SUB_MEDIA_FILEASSET_commitModify_promise_006'
let fetchOp = nameFetchOps(testNum, 'Pictures/ModifyPro/', '07', IMAGE_TYPE);
let prop = 'mediaType'
let val = 'newMediaType'
await staticPropsCommitModify(done, testNum, fetchOp, prop, val)
});
/**
* @tc.number : SUB_MEDIA_FILEASSET_isDirectory_promise_001
* @tc.name : isDirectory
......@@ -143,7 +201,8 @@ export default function fileAssetPromise2Test(abilityContext) {
*/
it('SUB_MEDIA_FILEASSET_isDirectory_promise_001', 0, async function (done) {
try {
let fetchOp = nameFetchOps('Pictures/ModifyPro/', '05', IMAGE_TYPE);
let testNum = 'SUB_MEDIA_FILEASSET_isDirectory_promise_001'
let fetchOp = nameFetchOps(testNum, 'Pictures/ModifyPro/', '05', IMAGE_TYPE);
const fetchFileResult = await media.getFileAssets(fetchOp);
const asset = await fetchFileResult.getFirstObject();
const isDir = await asset.isDirectory();
......
......@@ -25,21 +25,25 @@ import {
checkPresetsAssets,
checkAssetsCount,
fetchOps,
isNum,
} from '../../../../../../common';
export default function fileAssetTestCallbackTest(abilityContext) {
describe('fileAssetTestCallbackTest', function () {
const media = mediaLibrary.getMediaLibrary(abilityContext);
beforeAll(async function () {
console.info('beforeAll case');
await checkPresetsAssets(media, 'ActsMediaLibraryFileAsset')
});
beforeEach(function () { });
beforeEach(function () {
console.info('beforeEach case');
});
afterEach(async function () {
console.info('afterEach case');
await sleep()
});
afterAll(function () { });
function isNum(value) {
return typeof value === 'number' && !isNaN(value);
}
afterAll(function () {
console.info('afterAll case');
});
const rwOpenTest = async function (done, testNum, fetchOp, assetProps, expectCount) {
let asset, asset1;
......@@ -220,13 +224,13 @@ export default function fileAssetTestCallbackTest(abilityContext) {
* @tc.level : Level 0
*/
it('SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_CALLBACK_005_01', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_CALLBACK_005_01';
let assetProps = {
bytesRead: 10,
write: 4096,
}
let fetchOp = fetchOps('Documents/RW_cb/', FILE_TYPE);
let fetchOp = fetchOps(testNum, 'Documents/RW_cb/', FILE_TYPE);
let expectCount = 2;
let testNum = 'SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_CALLBACK_005_01';
await rwOpenTest(done, testNum, fetchOp, assetProps, expectCount)
});
......@@ -239,13 +243,13 @@ export default function fileAssetTestCallbackTest(abilityContext) {
* @tc.level : Level 0
*/
it('SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_CALLBACK_005_02', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_CALLBACK_005_02';
let assetProps = {
bytesRead: 10,
write: 4096,
}
let fetchOp = fetchOps('Documents/R_cb/', FILE_TYPE);
let fetchOp = fetchOps(testNum, 'Documents/R_cb/', FILE_TYPE);
let expectCount = 2;
let testNum = 'SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_CALLBACK_005_02';
await rOpenTest(done, testNum, fetchOp, assetProps, expectCount)
});
......@@ -258,12 +262,12 @@ export default function fileAssetTestCallbackTest(abilityContext) {
* @tc.level : Level 0
*/
it('SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_CALLBACK_005_03', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_CALLBACK_005_03';
let assetProps = {
write: 4096,
}
let fetchOp = fetchOps('Documents/W_cb/', FILE_TYPE);
let fetchOp = fetchOps(testNum, 'Documents/W_cb/', FILE_TYPE);
let expectCount = 2;
let testNum = 'SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_CALLBACK_005_03';
await wOpenTest(done, testNum, fetchOp, assetProps, expectCount)
});
......@@ -279,13 +283,13 @@ export default function fileAssetTestCallbackTest(abilityContext) {
* @tc.level : Level 0
*/
it('SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_CALLBACK_005_07', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_CALLBACK_005_07';
let assetProps = {
bytesRead: 4096,
write: 4096,
}
let fetchOp = fetchOps('Pictures/RW_cb/', IMAGE_TYPE);
let fetchOp = fetchOps(testNum, 'Pictures/RW_cb/', IMAGE_TYPE);
let expectCount = 2;
let testNum = 'SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_CALLBACK_005_07';
await rwOpenTest(done, testNum, fetchOp, assetProps, expectCount)
});
......@@ -298,12 +302,12 @@ export default function fileAssetTestCallbackTest(abilityContext) {
* @tc.level : Level 0
*/
it('SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_CALLBACK_005_08', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_CALLBACK_005_08';
let assetProps = {
bytesRead: 4096,
}
let fetchOp = fetchOps('Pictures/R_cb/', IMAGE_TYPE);
let fetchOp = fetchOps(testNum, 'Pictures/R_cb/', IMAGE_TYPE);
let expectCount = 2;
let testNum = 'SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_CALLBACK_005_08';
await rOpenTest(done, testNum, fetchOp, assetProps, expectCount)
});
......@@ -316,12 +320,12 @@ export default function fileAssetTestCallbackTest(abilityContext) {
* @tc.level : Level 0
*/
it('SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_CALLBACK_005_09', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_CALLBACK_005_09';
let assetProps = {
write: 4096,
}
let fetchOp = fetchOps('Pictures/W_cb/', IMAGE_TYPE);
let fetchOp = fetchOps(testNum, 'Pictures/W_cb/', IMAGE_TYPE);
let expectCount = 2;
let testNum = 'SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_CALLBACK_005_09';
await wOpenTest(done, testNum, fetchOp, assetProps, expectCount)
});
......@@ -337,13 +341,13 @@ export default function fileAssetTestCallbackTest(abilityContext) {
* @tc.level : Level 0
*/
it('SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_CALLBACK_005_10', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_CALLBACK_005_10';
let assetProps = {
bytesRead: 4096,
write: 4096,
}
let fetchOp = fetchOps('Audios/RW_cb/', AUDIO_TYPE);
let fetchOp = fetchOps(testNum, 'Audios/RW_cb/', AUDIO_TYPE);
let expectCount = 2;
let testNum = 'SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_CALLBACK_005_10';
await rwOpenTest(done, testNum, fetchOp, assetProps, expectCount)
});
......@@ -356,12 +360,12 @@ export default function fileAssetTestCallbackTest(abilityContext) {
* @tc.level : Level 0
*/
it('SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_CALLBACK_005_11', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_CALLBACK_005_11';
let assetProps = {
bytesRead: 4096,
}
let fetchOp = fetchOps('Audios/R_cb/', AUDIO_TYPE);
let fetchOp = fetchOps(testNum, 'Audios/R_cb/', AUDIO_TYPE);
let expectCount = 2;
let testNum = 'SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_CALLBACK_005_11';
await rOpenTest(done, testNum, fetchOp, assetProps, expectCount)
});
......@@ -374,12 +378,12 @@ export default function fileAssetTestCallbackTest(abilityContext) {
* @tc.level : Level 0
*/
it('SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_CALLBACK_005_12', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_CALLBACK_005_12';
let assetProps = {
write: 4096,
}
let fetchOp = fetchOps('Audios/W_cb/', AUDIO_TYPE);
let fetchOp = fetchOps(testNum, 'Audios/W_cb/', AUDIO_TYPE);
let expectCount = 2;
let testNum = 'SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_CALLBACK_005_12';
await wOpenTest(done, testNum, fetchOp, assetProps, expectCount)
});
......@@ -395,13 +399,13 @@ export default function fileAssetTestCallbackTest(abilityContext) {
* @tc.level : Level 0
*/
it('SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_CALLBACK_005_13', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_CALLBACK_005_13';
let assetProps = {
bytesRead: 4096,
write: 4096,
}
let fetchOp = fetchOps('Videos/RW_cb/', VIDEO_TYPE);
let fetchOp = fetchOps(testNum, 'Videos/RW_cb/', VIDEO_TYPE);
let expectCount = 2;
let testNum = 'SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_CALLBACK_005_13';
await rwOpenTest(done, testNum, fetchOp, assetProps, expectCount)
});
......@@ -414,12 +418,12 @@ export default function fileAssetTestCallbackTest(abilityContext) {
* @tc.level : Level 0
*/
it('SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_CALLBACK_005_14', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_CALLBACK_005_14';
let assetProps = {
bytesRead: 4096,
}
let fetchOp = fetchOps('Videos/R_cb/', VIDEO_TYPE);
let fetchOp = fetchOps(testNum, 'Videos/R_cb/', VIDEO_TYPE);
let expectCount = 2;
let testNum = 'SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_CALLBACK_005_14';
await rOpenTest(done, testNum, fetchOp, assetProps, expectCount)
});
......@@ -432,12 +436,12 @@ export default function fileAssetTestCallbackTest(abilityContext) {
* @tc.level : Level 0
*/
it('SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_CALLBACK_005_15', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_CALLBACK_005_15';
let assetProps = {
write: 4096,
}
let fetchOp = fetchOps('Videos/W_cb/', VIDEO_TYPE);
let fetchOp = fetchOps(testNum, 'Videos/W_cb/', VIDEO_TYPE);
let expectCount = 2;
let testNum = 'SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_CALLBACK_005_15';
await wOpenTest(done, testNum, fetchOp, assetProps, expectCount)
});
......@@ -455,7 +459,7 @@ export default function fileAssetTestCallbackTest(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_CALLBACK_005_31', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_CALLBACK_005_31'
let fetchOp = fetchOps('Documents/openClose/', FILE_TYPE);
let fetchOp = fetchOps(testNum, 'Documents/openClose/', FILE_TYPE);
await closeTest(done, testNum, fetchOp)
});
......@@ -469,7 +473,7 @@ export default function fileAssetTestCallbackTest(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_CALLBACK_005_33', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_CALLBACK_005_33'
let fetchOp = fetchOps('Pictures/openClose/', IMAGE_TYPE);
let fetchOp = fetchOps(testNum, 'Pictures/openClose/', IMAGE_TYPE);
await closeTest(done, testNum, fetchOp)
});
......@@ -483,7 +487,7 @@ export default function fileAssetTestCallbackTest(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_CALLBACK_005_34', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_CALLBACK_005_34'
let fetchOp = fetchOps('Audios/openClose/', AUDIO_TYPE);
let fetchOp = fetchOps(testNum, 'Audios/openClose/', AUDIO_TYPE);
await closeTest(done, testNum, fetchOp)
});
......@@ -497,7 +501,7 @@ export default function fileAssetTestCallbackTest(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_CALLBACK_005_35', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_CALLBACK_005_35'
let fetchOp = fetchOps('Videos/openClose/', VIDEO_TYPE);
let fetchOp = fetchOps(testNum, 'Videos/openClose/', VIDEO_TYPE);
await closeTest(done, testNum, fetchOp)
});
......
......@@ -25,21 +25,25 @@ import {
checkPresetsAssets,
checkAssetsCount,
fetchOps,
isNum,
} from '../../../../../../common';
export default function fileAssetTestPromiseTest(abilityContext) {
describe('fileAssetTestPromiseTest', function () {
const media = mediaLibrary.getMediaLibrary(abilityContext);
beforeAll(async function () {
console.info('beforeAll case');
await checkPresetsAssets(media, 'ActsMediaLibraryFileAsset')
});
beforeEach(function () { });
beforeEach(function () {
console.info('beforeEach case');
});
afterEach(async function () {
console.info('afterEach case');
await sleep()
});
afterAll(function () { });
function isNum(value) {
return typeof value === 'number' && !isNaN(value);
}
afterAll(function () {
console.info('afterAll case');
});
const rwOpenTest = async function (done, testNum, fetchOp, assetProps, expectCount) {
let asset, asset1;
......@@ -188,13 +192,13 @@ export default function fileAssetTestPromiseTest(abilityContext) {
* @tc.level : Level 0
*/
it('SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_01', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_01';
let assetProps = {
bytesRead: 10,
write: 4096,
}
let fetchOp = fetchOps('Documents/RW/', FILE_TYPE);
let fetchOp = fetchOps(testNum, 'Documents/RW/', FILE_TYPE);
let expectCount = 2;
let testNum = 'SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_01';
await rwOpenTest(done, testNum, fetchOp, assetProps, expectCount)
});
......@@ -207,13 +211,13 @@ export default function fileAssetTestPromiseTest(abilityContext) {
* @tc.level : Level 0
*/
it('SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_02', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_02';
let assetProps = {
bytesRead: 10,
write: 4096,
}
let fetchOp = fetchOps('Documents/R/', FILE_TYPE);
let fetchOp = fetchOps(testNum, 'Documents/R/', FILE_TYPE);
let expectCount = 2;
let testNum = 'SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_02';
await rOpenTest(done, testNum, fetchOp, assetProps, expectCount)
});
......@@ -226,12 +230,12 @@ export default function fileAssetTestPromiseTest(abilityContext) {
* @tc.level : Level 0
*/
it('SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_03', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_03';
let assetProps = {
write: 4096,
}
let fetchOp = fetchOps('Documents/W/', FILE_TYPE);
let fetchOp = fetchOps(testNum, 'Documents/W/', FILE_TYPE);
let expectCount = 2;
let testNum = 'SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_03';
await wOpenTest(done, testNum, fetchOp, assetProps, expectCount)
});
......@@ -247,13 +251,13 @@ export default function fileAssetTestPromiseTest(abilityContext) {
* @tc.level : Level 0
*/
it('SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_07', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_07';
let assetProps = {
bytesRead: 4096,
write: 4096,
}
let fetchOp = fetchOps('Pictures/RW/', IMAGE_TYPE);
let fetchOp = fetchOps(testNum, 'Pictures/RW/', IMAGE_TYPE);
let expectCount = 2;
let testNum = 'SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_07';
await rwOpenTest(done, testNum, fetchOp, assetProps, expectCount)
});
......@@ -266,12 +270,12 @@ export default function fileAssetTestPromiseTest(abilityContext) {
* @tc.level : Level 0
*/
it('SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_08', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_08';
let assetProps = {
bytesRead: 4096,
}
let fetchOp = fetchOps('Pictures/R/', IMAGE_TYPE);
let fetchOp = fetchOps(testNum, 'Pictures/R/', IMAGE_TYPE);
let expectCount = 2;
let testNum = 'SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_08';
await rOpenTest(done, testNum, fetchOp, assetProps, expectCount)
});
......@@ -284,12 +288,12 @@ export default function fileAssetTestPromiseTest(abilityContext) {
* @tc.level : Level 0
*/
it('SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_09', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_09';
let assetProps = {
write: 4096,
}
let fetchOp = fetchOps('Pictures/W/', IMAGE_TYPE);
let fetchOp = fetchOps(testNum, 'Pictures/W/', IMAGE_TYPE);
let expectCount = 2;
let testNum = 'SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_09';
await wOpenTest(done, testNum, fetchOp, assetProps, expectCount)
});
......@@ -305,13 +309,13 @@ export default function fileAssetTestPromiseTest(abilityContext) {
* @tc.level : Level 0
*/
it('SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_10', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_10';
let assetProps = {
bytesRead: 4096,
write: 4096,
}
let fetchOp = fetchOps('Audios/RW/', AUDIO_TYPE);
let fetchOp = fetchOps(testNum, 'Audios/RW/', AUDIO_TYPE);
let expectCount = 2;
let testNum = 'SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_10';
await rwOpenTest(done, testNum, fetchOp, assetProps, expectCount)
});
......@@ -324,12 +328,12 @@ export default function fileAssetTestPromiseTest(abilityContext) {
* @tc.level : Level 0
*/
it('SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_11', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_11';
let assetProps = {
bytesRead: 4096,
}
let fetchOp = fetchOps('Audios/R/', AUDIO_TYPE);
let fetchOp = fetchOps(testNum, 'Audios/R/', AUDIO_TYPE);
let expectCount = 2;
let testNum = 'SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_11';
await rOpenTest(done, testNum, fetchOp, assetProps, expectCount)
});
......@@ -342,12 +346,12 @@ export default function fileAssetTestPromiseTest(abilityContext) {
* @tc.level : Level 0
*/
it('SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_12', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_12';
let assetProps = {
write: 4096,
}
let fetchOp = fetchOps('Audios/W/', AUDIO_TYPE);
let fetchOp = fetchOps(testNum, 'Audios/W/', AUDIO_TYPE);
let expectCount = 2;
let testNum = 'SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_12';
await wOpenTest(done, testNum, fetchOp, assetProps, expectCount)
});
......@@ -363,13 +367,13 @@ export default function fileAssetTestPromiseTest(abilityContext) {
* @tc.level : Level 0
*/
it('SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_13', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_13';
let assetProps = {
bytesRead: 4096,
write: 4096,
}
let fetchOp = fetchOps('Videos/RW/', VIDEO_TYPE);
let fetchOp = fetchOps(testNum, 'Videos/RW/', VIDEO_TYPE);
let expectCount = 2;
let testNum = 'SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_13';
await rwOpenTest(done, testNum, fetchOp, assetProps, expectCount)
});
......@@ -382,12 +386,12 @@ export default function fileAssetTestPromiseTest(abilityContext) {
* @tc.level : Level 0
*/
it('SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_14', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_14';
let assetProps = {
bytesRead: 4096,
}
let fetchOp = fetchOps('Videos/R/', VIDEO_TYPE);
let fetchOp = fetchOps(testNum, 'Videos/R/', VIDEO_TYPE);
let expectCount = 2;
let testNum = 'SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_14';
await rOpenTest(done, testNum, fetchOp, assetProps, expectCount)
});
......@@ -400,12 +404,12 @@ export default function fileAssetTestPromiseTest(abilityContext) {
* @tc.level : Level 0
*/
it('SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_15', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_15';
let assetProps = {
write: 4096,
}
let fetchOp = fetchOps('Videos/W/', VIDEO_TYPE);
let fetchOp = fetchOps(testNum, 'Videos/W/', VIDEO_TYPE);
let expectCount = 2;
let testNum = 'SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_15';
await wOpenTest(done, testNum, fetchOp, assetProps, expectCount)
});
......@@ -423,7 +427,7 @@ export default function fileAssetTestPromiseTest(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_31', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_31'
let fetchOp = fetchOps('Documents/openClose/', FILE_TYPE);
let fetchOp = fetchOps(testNum, 'Documents/openClose/', FILE_TYPE);
await closeTest(done, testNum, fetchOp)
});
......@@ -437,7 +441,7 @@ export default function fileAssetTestPromiseTest(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_33', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_33'
let fetchOp = fetchOps('Pictures/openClose/', IMAGE_TYPE);
let fetchOp = fetchOps(testNum, 'Pictures/openClose/', IMAGE_TYPE);
await closeTest(done, testNum, fetchOp)
});
......@@ -451,7 +455,7 @@ export default function fileAssetTestPromiseTest(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_34', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_34'
let fetchOp = fetchOps('Audios/openClose/', AUDIO_TYPE);
let fetchOp = fetchOps(testNum, 'Audios/openClose/', AUDIO_TYPE);
await closeTest(done, testNum, fetchOp)
});
......@@ -465,7 +469,7 @@ export default function fileAssetTestPromiseTest(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_35', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_35'
let fetchOp = fetchOps('Videos/openClose/', VIDEO_TYPE);
let fetchOp = fetchOps(testNum, 'Videos/openClose/', VIDEO_TYPE);
await closeTest(done, testNum, fetchOp)
});
......
......@@ -27,44 +27,36 @@ import {
getPermission,
} from '../../../../../../common';
const filekeys = {
parent: 'PARENT',
mimeType: 'MIME_TYPE',
size: 'SIZE',
dateAdded: 'DATE_ADDED',
title: 'TITLE',
duration: 'DURATION',
width: 'WIDTH',
height: 'HEIGHT',
orientation: 'ORIENTATION',
albumId: 'ALBUM_ID',
artist: 'ARTIST',
audioAlbum: 'AUDIOALBUM',
dateModified: 'DATE_MODIFIED',
dateTaken: 'DATE_TAKEN',
relativePath: 'RELATIVE_PATH',
displayName: 'DISPLAY_NAME',
}
export default function filekeyTestCallbackTest(abilityContext) {
describe('filekeyTestCallbackTest', function () {
const media = mediaLibrary.getMediaLibrary(abilityContext);
beforeAll(async function () {
console.info('beforeAll case');
await getPermission();
await checkPresetsAssets(media, 'ActsMediaLibraryFileKey')
});
beforeEach(function () { });
beforeEach(function () {
console.info('beforeEach case');
});
afterEach(async function () {
console.info('afterEach case');
await sleep()
});
afterAll(function () { });
afterAll(function () {
console.info('afterAll case');
});
const { PARENT, MIME_TYPE, SIZE, DATE_ADDED, TITLE, ALBUM_NAME, DURATION,
WIDTH, HEIGHT, ORIENTATION, ALBUM_ID, ARTIST, AUDIOALBUM, DATE_MODIFIED,
DATE_TAKEN, RELATIVE_PATH, DISPLAY_NAME, MEDIA_TYPE
} = FILEKEY;
async function getFileAssetsBy(done, testNum, type, count = 1) {
async function getFileAssetsBy(done, testNum, type, fileKey) {
try {
let assetOp = fetchOps('Pictures/ImageInfo/', IMAGE_TYPE);
let assetOp = fetchOps(testNum, 'Pictures/ImageInfo/', IMAGE_TYPE);
if (type == 'audioAlbum' || type == 'artist' || type == 'duration') {
assetOp = fetchOps('Audios/Static/', AUDIO_TYPE);
assetOp = fetchOps(testNum, 'Audios/Static/', AUDIO_TYPE);
}
console.info(`${testNum} assOp : ${JSON.stringify(assetOp)}`)
let fetchFileResult = await media.getFileAssets(assetOp);
......@@ -72,11 +64,11 @@ export default function filekeyTestCallbackTest(abilityContext) {
if (!checkAssetCountPass) return;
const asset = await fetchFileResult.getFirstObject();
let Op = {
selections: FILEKEY[filekeys[type]] + '= ?',
selections: fileKey + '= ?',
selectionArgs: [asset[type] + ''],
};
media.getFileAssets(Op, async (err, fetchFileResult) => {
if(err) {
if (err) {
console.info(`${testNum}, err: ${err}`)
expect(false).assertTrue();
done();
......@@ -85,7 +77,7 @@ export default function filekeyTestCallbackTest(abilityContext) {
const fetchCount = fetchFileResult.getCount();
const currentAsset = await fetchFileResult.getFirstObject();
expect(currentAsset[type]).assertEqual(asset[type]);
expect(fetchCount>0).assertTrue();
expect(fetchCount > 0).assertTrue();
done();
});
} catch (error) {
......@@ -106,7 +98,7 @@ export default function filekeyTestCallbackTest(abilityContext) {
it('SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_001', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_001'
await getFileAssetsBy(done, testNum, 'parent');
await getFileAssetsBy(done, testNum, 'parent', PARENT);
});
/**
......@@ -119,7 +111,7 @@ export default function filekeyTestCallbackTest(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_002', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_002'
await getFileAssetsBy(done, testNum, 'mimeType');
await getFileAssetsBy(done, testNum, 'mimeType', MIME_TYPE);
});
/**
......@@ -132,7 +124,7 @@ export default function filekeyTestCallbackTest(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_003', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_003'
await getFileAssetsBy(done, testNum, 'size');
await getFileAssetsBy(done, testNum, 'size', SIZE);
});
/**
......@@ -145,7 +137,7 @@ export default function filekeyTestCallbackTest(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_004', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_004'
await getFileAssetsBy(done, testNum, 'dateAdded', 2);
await getFileAssetsBy(done, testNum, 'dateAdded', DATE_ADDED);
});
/**
......@@ -158,7 +150,7 @@ export default function filekeyTestCallbackTest(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_005', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_005'
await getFileAssetsBy(done, testNum, 'dateModified', 2);
await getFileAssetsBy(done, testNum, 'dateModified', DATE_MODIFIED);
});
/**
......@@ -171,7 +163,7 @@ export default function filekeyTestCallbackTest(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_006', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_006'
await getFileAssetsBy(done, testNum, 'dateTaken', 2);
await getFileAssetsBy(done, testNum, 'dateTaken', DATE_TAKEN);
});
/**
......@@ -184,7 +176,7 @@ export default function filekeyTestCallbackTest(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_007', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_007'
await getFileAssetsBy(done, testNum, 'title', 2);
await getFileAssetsBy(done, testNum, 'title', TITLE,);
});
/**
......@@ -197,7 +189,7 @@ export default function filekeyTestCallbackTest(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_008', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_008'
await getFileAssetsBy(done, testNum, 'duration');
await getFileAssetsBy(done, testNum, 'duration', DURATION);
});
/**
......@@ -210,7 +202,7 @@ export default function filekeyTestCallbackTest(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_009', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_009'
await getFileAssetsBy(done, testNum, 'width');
await getFileAssetsBy(done, testNum, 'width', WIDTH);
});
/**
......@@ -223,7 +215,7 @@ export default function filekeyTestCallbackTest(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_010', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_010'
await getFileAssetsBy(done, testNum, 'height');
await getFileAssetsBy(done, testNum, 'height', HEIGHT);
});
/**
......@@ -236,7 +228,7 @@ export default function filekeyTestCallbackTest(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_011', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_011'
await getFileAssetsBy(done, testNum, 'orientation', 2);
await getFileAssetsBy(done, testNum, 'orientation', ORIENTATION);
});
/**
......@@ -249,7 +241,7 @@ export default function filekeyTestCallbackTest(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_012', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_012'
await getFileAssetsBy(done, testNum, 'albumId');
await getFileAssetsBy(done, testNum, 'albumId', ALBUM_ID);
});
/**
......@@ -262,7 +254,7 @@ export default function filekeyTestCallbackTest(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_0014', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_014'
await getFileAssetsBy(done, testNum, 'artist');
await getFileAssetsBy(done, testNum, 'artist', ARTIST);
});
/**
......@@ -275,7 +267,7 @@ export default function filekeyTestCallbackTest(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_0015', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_015'
await getFileAssetsBy(done, testNum, 'audioAlbum');
await getFileAssetsBy(done, testNum, 'audioAlbum', AUDIOALBUM);
});
/**
......@@ -288,7 +280,7 @@ export default function filekeyTestCallbackTest(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_0016', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_0016'
await getFileAssetsBy(done, testNum, 'relativePath');
await getFileAssetsBy(done, testNum, 'relativePath', RELATIVE_PATH);
});
/**
......@@ -301,10 +293,37 @@ export default function filekeyTestCallbackTest(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_0017', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_0017'
await getFileAssetsBy(done, testNum, 'displayName');
await getFileAssetsBy(done, testNum, 'displayName', DISPLAY_NAME);
});
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_0018
* @tc.name : getFileAssets
* @tc.desc : filekey album_name
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_0018', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_0018'
try {
let albumName = 'ImageInfo'
let currentFetchOp = {
selections: RELATIVE_PATH + '= ? AND ' + ALBUM_NAME + '= ? AND ' + MEDIA_TYPE + '= ?',
selectionArgs: ['Pictures/', albumName, IMAGE_TYPE.toString()],
}
console.info(`${testNum} currentFetchOp : ${JSON.stringify(currentFetchOp)}`)
const albumList = await media.getAlbums(currentFetchOp);
const album = albumList[0];
expect(album.albumName).assertEqual(albumName);
done();
} catch (error) {
console.info(`${testNum} error : ${error}`)
expect(false).assertTrue();
done();
}
});
});
}
......@@ -28,43 +28,36 @@ import {
fetchOps,
} from '../../../../../../common';
const filekeys = {
parent: 'PARENT',
mimeType: 'MIME_TYPE',
size: 'SIZE',
dateAdded: 'DATE_ADDED',
title: 'TITLE',
duration: 'DURATION',
width: 'WIDTH',
height: 'HEIGHT',
orientation: 'ORIENTATION',
albumId: 'ALBUM_ID',
artist: 'ARTIST',
audioAlbum: 'AUDIOALBUM',
dateModified: 'DATE_MODIFIED',
dateTaken: 'DATE_TAKEN',
relativePath: 'RELATIVE_PATH',
displayName: 'DISPLAY_NAME',
}
export default function filekeyTestPromiseTest(abilityContext) {
describe('filekeyTestPromiseTest', function () {
const media = mediaLibrary.getMediaLibrary(abilityContext);
beforeAll(async function () {
console.info('beforeAll case');
await checkPresetsAssets(media, 'ActsMediaLibraryFileKey')
});
beforeEach(function () { });
beforeEach(function () {
console.info('beforeEach case');
});
afterEach(async function () {
console.info('afterEach case');
await sleep()
});
afterAll(function () { });
afterAll(function () {
console.info('afterAll case');
});
async function getFileAssetsBy(done, testNum, type, count = 1) {
const { PARENT, MIME_TYPE, SIZE, DATE_ADDED, TITLE, ALBUM_NAME, DURATION,
WIDTH, HEIGHT, ORIENTATION, ALBUM_ID, ARTIST, AUDIOALBUM, DATE_MODIFIED,
DATE_TAKEN, RELATIVE_PATH, DISPLAY_NAME, MEDIA_TYPE
} = FILEKEY;
async function getFileAssetsBy(done, testNum, type, fileKey) {
try {
let assetOp = fetchOps('Pictures/ImageInfo/', IMAGE_TYPE);
let assetOp = fetchOps(testNum, 'Pictures/ImageInfo/', IMAGE_TYPE);
if (type == 'audioAlbum' || type == 'artist' || type == 'duration') {
assetOp = fetchOps('Audios/Static/', AUDIO_TYPE);
assetOp = fetchOps(testNum, 'Audios/Static/', AUDIO_TYPE);
}
console.info(`${testNum} assOp : ${JSON.stringify(assetOp)}`)
let fetchFileResult = await media.getFileAssets(assetOp);
......@@ -72,12 +65,12 @@ export default function filekeyTestPromiseTest(abilityContext) {
if (!checkAssetCountPass) return;
const asset = await fetchFileResult.getFirstObject();
let Op = {
selections: FILEKEY[filekeys[type]] + '= ?',
selections: fileKey + '= ?',
selectionArgs: [asset[type] + ''],
};
fetchFileResult = await media.getFileAssets(Op);
const fetchCount = fetchFileResult.getCount();
expect(fetchCount>0).assertTrue();
expect(fetchCount > 0).assertTrue();
let firstObject = await fetchFileResult.getFirstObject();
expect(firstObject[type]).assertEqual(asset[type]);
done();
......@@ -99,7 +92,7 @@ export default function filekeyTestPromiseTest(abilityContext) {
it('SUB_MEDIA_MEDIALIBRARY_FILE_KEY_PROMISE_001', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_FILE_KEY_PROMISE_001'
await getFileAssetsBy(done, testNum, 'parent');
await getFileAssetsBy(done, testNum, 'parent', PARENT);
});
/**
......@@ -112,7 +105,7 @@ export default function filekeyTestPromiseTest(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_FILE_KEY_PROMISE_002', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_FILE_KEY_PROMISE_002'
await getFileAssetsBy(done, testNum, 'mimeType');
await getFileAssetsBy(done, testNum, 'mimeType', MIME_TYPE);
});
/**
......@@ -125,7 +118,7 @@ export default function filekeyTestPromiseTest(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_FILE_KEY_PROMISE_003', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_FILE_KEY_PROMISE_003'
await getFileAssetsBy(done, testNum, 'size');
await getFileAssetsBy(done, testNum, 'size', SIZE);
});
/**
......@@ -138,7 +131,7 @@ export default function filekeyTestPromiseTest(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_FILE_KEY_PROMISE_004', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_FILE_KEY_PROMISE_004'
await getFileAssetsBy(done, testNum, 'dateAdded', 2);
await getFileAssetsBy(done, testNum, 'dateAdded', DATE_ADDED);
});
/**
......@@ -151,7 +144,7 @@ export default function filekeyTestPromiseTest(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_FILE_KEY_PROMISE_005', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_FILE_KEY_PROMISE_005'
await getFileAssetsBy(done, testNum, 'dateModified', 2);
await getFileAssetsBy(done, testNum, 'dateModified', DATE_MODIFIED);
});
/**
......@@ -164,7 +157,7 @@ export default function filekeyTestPromiseTest(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_FILE_KEY_PROMISE_006', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_FILE_KEY_PROMISE_006'
await getFileAssetsBy(done, testNum, 'dateTaken', 2);
await getFileAssetsBy(done, testNum, 'dateTaken', DATE_TAKEN);
});
/**
......@@ -177,7 +170,7 @@ export default function filekeyTestPromiseTest(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_FILE_KEY_PROMISE_007', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_FILE_KEY_PROMISE_007'
await getFileAssetsBy(done, testNum, 'title', 2);
await getFileAssetsBy(done, testNum, 'title', TITLE,);
});
/**
......@@ -190,7 +183,7 @@ export default function filekeyTestPromiseTest(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_FILE_KEY_PROMISE_008', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_FILE_KEY_PROMISE_008'
await getFileAssetsBy(done, testNum, 'duration');
await getFileAssetsBy(done, testNum, 'duration', DURATION);
});
/**
......@@ -203,7 +196,7 @@ export default function filekeyTestPromiseTest(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_FILE_KEY_PROMISE_009', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_FILE_KEY_PROMISE_009'
await getFileAssetsBy(done, testNum, 'width');
await getFileAssetsBy(done, testNum, 'width', WIDTH);
});
/**
......@@ -216,7 +209,7 @@ export default function filekeyTestPromiseTest(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_FILE_KEY_PROMISE_010', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_FILE_KEY_PROMISE_010'
await getFileAssetsBy(done, testNum, 'height');
await getFileAssetsBy(done, testNum, 'height', HEIGHT);
});
/**
......@@ -229,7 +222,7 @@ export default function filekeyTestPromiseTest(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_FILE_KEY_PROMISE_011', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_FILE_KEY_PROMISE_011'
await getFileAssetsBy(done, testNum, 'orientation', 2);
await getFileAssetsBy(done, testNum, 'orientation', ORIENTATION);
});
/**
......@@ -242,7 +235,7 @@ export default function filekeyTestPromiseTest(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_FILE_KEY_PROMISE_012', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_FILE_KEY_PROMISE_012'
await getFileAssetsBy(done, testNum, 'albumId');
await getFileAssetsBy(done, testNum, 'albumId', ALBUM_ID);
});
/**
......@@ -255,7 +248,7 @@ export default function filekeyTestPromiseTest(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_FILE_KEY_PROMISE_0014', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_FILE_KEY_PROMISE_014'
await getFileAssetsBy(done, testNum, 'artist');
await getFileAssetsBy(done, testNum, 'artist', ARTIST);
});
/**
......@@ -268,11 +261,11 @@ export default function filekeyTestPromiseTest(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_FILE_KEY_PROMISE_0015', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_FILE_KEY_PROMISE_015'
await getFileAssetsBy(done, testNum, 'audioAlbum');
await getFileAssetsBy(done, testNum, 'audioAlbum', AUDIOALBUM);
});
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_FILE_KEY_PROMISE_0017
* @tc.number : SUB_MEDIA_MEDIALIBRARY_FILE_KEY_PROMISE_0016
* @tc.name : getFileAssets
* @tc.desc : filekey relative_path
* @tc.size : MEDIUM
......@@ -280,8 +273,8 @@ export default function filekeyTestPromiseTest(abilityContext) {
* @tc.level : Level 0
*/
it('SUB_MEDIA_MEDIALIBRARY_FILE_KEY_PROMISE_0016', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_FILE_KEY_PROMISE_015'
await getFileAssetsBy(done, testNum, 'relativePath');
let testNum = 'SUB_MEDIA_MEDIALIBRARY_FILE_KEY_PROMISE_0016'
await getFileAssetsBy(done, testNum, 'relativePath', RELATIVE_PATH);
});
/**
......@@ -294,8 +287,35 @@ export default function filekeyTestPromiseTest(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_FILE_KEY_PROMISE_0017', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_FILE_KEY_PROMISE_0017'
await getFileAssetsBy(done, testNum, 'displayName');
await getFileAssetsBy(done, testNum, 'displayName', DISPLAY_NAME);
});
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_FILE_KEY_PROMISE_0018
* @tc.name : getFileAssets
* @tc.desc : filekey album_name
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MEDIA_MEDIALIBRARY_FILE_KEY_PROMISE_0018', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_FILE_KEY_PROMISE_0018'
try {
let albumName = 'ImageInfo'
let currentFetchOp = {
selections: RELATIVE_PATH + '= ? AND ' + ALBUM_NAME + '= ? AND ' + MEDIA_TYPE + '= ?',
selectionArgs: ['Pictures/', albumName, IMAGE_TYPE.toString()],
}
console.info(`${testNum} currentFetchOp : ${JSON.stringify(currentFetchOp)}`)
const albumList = await media.getAlbums(currentFetchOp);
const album = albumList[0];
expect(album.albumName).assertEqual(albumName);
done();
} catch (error) {
console.info(`${testNum} error : ${error}`)
expect(false).assertTrue();
done();
}
});
});
}
......
......@@ -31,18 +31,23 @@ export default function fetchFileResultCallbackTest(abilityContext) {
describe('fetchFileResultCallbackTest', function () {
const media = mediaLibrary.getMediaLibrary(abilityContext);
beforeAll(async function () {
console.info('beforeAll case');
await getPermission();
await checkPresetsAssets(media, 'ActsMediaLibraryFileResult');
});
beforeEach(function () { });
beforeEach(function () {
console.info('beforeEach case');
});
afterEach(async function () {
console.info('afterEach case');
await sleep()
});
afterAll(function () { });
afterAll(function () {
console.info('afterAll case');
});
const checkAssetCount = async function (done, testNum, fetchOp, expectCount) {
try {
console.info(`${testNum} fetchOp: ${JSON.stringify(fetchOp)}`)
media.getFileAssets(fetchOp, async (err, fetchFileResult) => {
let checkResult = await checkAssetsCount(done, testNum, fetchFileResult, expectCount)
expect(checkResult).assertTrue();
......@@ -58,7 +63,7 @@ export default function fetchFileResultCallbackTest(abilityContext) {
const checkGetPositionObject = async function (done, testNum, pos) {
try {
let currentFetchOp = fetchOps('Pictures/Static/', IMAGE_TYPE, { order: FILEKEY.DATE_ADDED + " DESC" })
let currentFetchOp = fetchOps(testNum, 'Pictures/Static/', IMAGE_TYPE, { order: FILEKEY.DATE_ADDED + " DESC" })
console.info(`${testNum} currentFetchOp ${currentFetchOp} `)
let fetchFileResult = await media.getFileAssets(currentFetchOp);
......@@ -86,7 +91,7 @@ export default function fetchFileResultCallbackTest(abilityContext) {
const checkGetAllObject = async function (done, testNum, expectCount) {
try {
let currentFetchOp = fetchOps('Documents/Static/', FILE_TYPE, { order: FILEKEY.DATE_ADDED + ` DESC LIMIT 0,${expectCount}` })
let currentFetchOp = fetchOps(testNum, 'Documents/Static/', FILE_TYPE, { order: FILEKEY.DATE_ADDED + ` DESC LIMIT 0,${expectCount}` })
console.info(`${testNum} currentFetchOp ${currentFetchOp} `)
let fetchFileResult = await media.getFileAssets(currentFetchOp);
......@@ -121,7 +126,7 @@ export default function fetchFileResultCallbackTest(abilityContext) {
it('SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETCOUNT_CALLBACK_001_01', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETCOUNT_CALLBACK_001_01'
let expectCount = 1
let currentFetchOp = fetchOps('Documents/Static/', FILE_TYPE,
let currentFetchOp = fetchOps(testNum, 'Documents/Static/', FILE_TYPE,
{ order: FILEKEY.DATE_ADDED + " DESC LIMIT 0,1", })
await checkAssetCount(done, testNum, currentFetchOp, expectCount)
});
......@@ -137,7 +142,7 @@ export default function fetchFileResultCallbackTest(abilityContext) {
it('SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETCOUNT_CALLBACK_001_02', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETCOUNT_CALLBACK_001_02'
let expectCount = 2
let currentFetchOp = fetchOps('Documents/Static/', FILE_TYPE,
let currentFetchOp = fetchOps(testNum, 'Documents/Static/', FILE_TYPE,
{ order: FILEKEY.DATE_ADDED + " DESC LIMIT 0,2", })
await checkAssetCount(done, testNum, currentFetchOp, expectCount)
});
......@@ -153,7 +158,7 @@ export default function fetchFileResultCallbackTest(abilityContext) {
it('SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETCOUNT_CALLBACK_001_03', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETCOUNT_CALLBACK_001_03'
let expectCount = 100
let currentFetchOp = fetchOps('Documents/Static/', FILE_TYPE,
let currentFetchOp = fetchOps(testNum, 'Documents/Static/', FILE_TYPE,
{ order: FILEKEY.DATE_ADDED + " DESC LIMIT 0,100", })
await checkAssetCount(done, testNum, currentFetchOp, expectCount)
});
......@@ -169,7 +174,7 @@ export default function fetchFileResultCallbackTest(abilityContext) {
it('SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETCOUNT_CALLBACK_001_04', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETCOUNT_CALLBACK_001_03'
let expectCount = 0
let currentFetchOp = fetchOps('Documents/zeor/', FILE_TYPE)
let currentFetchOp = fetchOps(testNum, 'Documents/zeor/', FILE_TYPE)
await checkAssetCount(done, testNum, currentFetchOp, expectCount)
});
......@@ -187,7 +192,7 @@ export default function fetchFileResultCallbackTest(abilityContext) {
it('SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETFIRSTOBJECT_CALLBACK_004', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETFIRSTOBJECT_CALLBACK_004'
try {
let currentFetchOp = fetchOps('Pictures/Static/', IMAGE_TYPE, { order: FILEKEY.DATE_ADDED + " DESC" })
let currentFetchOp = fetchOps(testNum, 'Pictures/Static/', IMAGE_TYPE, { order: FILEKEY.DATE_ADDED + " DESC" })
console.info(`${testNum} currentFetchOp ${JSON.stringify(currentFetchOp)} `)
let fetchFileResult = await media.getFileAssets(currentFetchOp);
let expectCount = 4;
......@@ -227,7 +232,7 @@ export default function fetchFileResultCallbackTest(abilityContext) {
it('SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETNEXTOBJECT_CALLBACK_005', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETNEXTOBJECT_CALLBACK_005'
try {
let currentFetchOp = fetchOps('Pictures/Static/', IMAGE_TYPE, { order: FILEKEY.DATE_ADDED + " DESC" })
let currentFetchOp = fetchOps(testNum, 'Pictures/Static/', IMAGE_TYPE, { order: FILEKEY.DATE_ADDED + " DESC" })
console.info(`${testNum} currentFetchOp ${JSON.stringify(currentFetchOp)} `)
let fetchFileResult = await media.getFileAssets(currentFetchOp);
......@@ -267,7 +272,7 @@ export default function fetchFileResultCallbackTest(abilityContext) {
it('SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETLASTOBJECT_CALLBACK_006', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETLASTOBJECT_CALLBACK_006'
try {
let currentFetchOp = fetchOps('Pictures/Static/', IMAGE_TYPE, { order: FILEKEY.DATE_ADDED + " DESC" })
let currentFetchOp = fetchOps(testNum, 'Pictures/Static/', IMAGE_TYPE, { order: FILEKEY.DATE_ADDED + " DESC" })
console.info(`${testNum} currentFetchOp ${JSON.stringify(currentFetchOp)} `)
let fetchFileResult = await media.getFileAssets(currentFetchOp);
......@@ -343,7 +348,7 @@ export default function fetchFileResultCallbackTest(abilityContext) {
it('SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETPOSITIONOBJECT_CALLBACK_007_04', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETPOSITIONOBJECT_CALLBACK_007_04'
try {
let currentFetchOp = fetchOps('Pictures/Static/', IMAGE_TYPE, { order: FILEKEY.DATE_ADDED + " DESC" })
let currentFetchOp = fetchOps(testNum, 'Pictures/Static/', IMAGE_TYPE, { order: FILEKEY.DATE_ADDED + " DESC" })
console.info(`${testNum} currentFetchOp ${currentFetchOp} `)
let fetchFileResult = await media.getFileAssets(currentFetchOp);
......@@ -413,94 +418,5 @@ export default function fetchFileResultCallbackTest(abilityContext) {
await checkGetAllObject(done, testNum, expectCount)
});
// ------------------------------ 008 test end -------------------------
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_getFirstObject_CALLBACK_009_01
* @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_009_01', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_getFirstObject_CALLBACK_009_01';
try {
let currentFetchOp = fetchOps('Pictures/ImageInfo/', IMAGE_TYPE)
let fetchFileResult = await media.getFileAssets(currentFetchOp);
let expectCount = 1;
let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchFileResult, expectCount);
if (!checkAssetCountPass) return;
fetchFileResult.getFirstObject(async (err, firstObject) => {
expect(firstObject.id != undefined).assertTrue();
if (firstObject.id == undefined) {
console.info('MediaLibraryTest :firstObject.id == undefined');
}
expect(firstObject.uri != undefined).assertTrue();
if (firstObject.uri == undefined) {
console.info('MediaLibraryTest :firstObject.uri === undefined');
}
expect(firstObject.mimeType).assertEqual('image/*');
expect(firstObject.mediaType).assertEqual(IMAGE_TYPE);
expect(firstObject.displayName).assertEqual('01.jpg');
expect(firstObject.title).assertEqual('01');
expect(firstObject.relativePath).assertEqual('Pictures/ImageInfo/');
expect(firstObject.parent != undefined).assertTrue();
if (firstObject.parent == undefined) {
console.info('MediaLibraryTest :firstObject.parent == undefined');
}
expect(firstObject.size).assertEqual(348113);
expect(firstObject.dateTaken).assertEqual(0);
expect(firstObject.artist).assertEqual('');
expect(firstObject.audioAlbum).assertEqual('');
expect(firstObject.width).assertEqual(1279);
expect(firstObject.height).assertEqual(1706);
expect(firstObject.orientation).assertEqual(0);
expect(firstObject.duration).assertEqual(0);
expect(firstObject.albumId != undefined).assertTrue();
if (firstObject.albumId == undefined) {
console.info('MediaLibraryTest :firstObject.albumId == undefined');
}
expect(firstObject.albumUri != undefined).assertTrue();
if (firstObject.albumUri == undefined) {
console.info('MediaLibraryTest :firstObject.albumUri:' + firstObject.albumUri);
}
expect(firstObject.albumName).assertEqual('ImageInfo');
expect(firstObject.dateAdded != undefined).assertTrue();
if (firstObject.dateAdded == undefined) {
console.info('MediaLibraryTest :firstObject.dateAdded:' + firstObject.dateAdded);
}
expect(firstObject.albumName != undefined).assertTrue();
if (firstObject.albumName == undefined) {
console.info('MediaLibraryTest :firstObject.albumName:' + firstObject.albumName);
}
done();
});
} catch (error) {
console.info(`${testNum} error : ${error}`);
expect(false).assertTrue();
done();
}
});
});
}
......@@ -33,17 +33,22 @@ export default function fetchFileResultPromiseTest(abilityContext) {
describe('fetchFileResultPromiseTest', function () {
const media = mediaLibrary.getMediaLibrary(abilityContext);
beforeAll(async function () {
console.info('beforeAll case');
await checkPresetsAssets(media, 'ActsMediaLibraryFileResult');
});
beforeEach(function () { });
beforeEach(function () {
console.info('beforeEach case');
});
afterEach(async function () {
sleep()
console.info('afterEach case');
await sleep()
});
afterAll(function () {
console.info('afterAll case');
});
afterAll(function () { });
const checkAssetCount = async function (done, testNum, fetchOp, expectCount) {
try {
console.info(`${testNum} fetchOp: ${JSON.stringify(fetchOp)}`)
let fetchFileResult = await media.getFileAssets(fetchOp);
let checkResult = await checkAssetsCount(done, testNum, fetchFileResult, expectCount)
expect(checkResult).assertTrue();
......@@ -58,7 +63,7 @@ export default function fetchFileResultPromiseTest(abilityContext) {
const checkGetPositionObject = async function (done, testNum, pos) {
try {
let currentFetchOp = fetchOps('Pictures/Static/', IMAGE_TYPE, { order: FILEKEY.DATE_ADDED + " DESC" })
let currentFetchOp = fetchOps(testNum, 'Pictures/Static/', IMAGE_TYPE, { order: FILEKEY.DATE_ADDED + " DESC" })
console.info(`${testNum} currentFetchOp ${currentFetchOp} `)
let fetchFileResult = await media.getFileAssets(currentFetchOp);
......@@ -79,7 +84,7 @@ export default function fetchFileResultPromiseTest(abilityContext) {
const checkGetAllObject = async function (done, testNum, expectCount) {
try {
let currentFetchOp = fetchOps('Documents/Static/', FILE_TYPE, { order: FILEKEY.DATE_ADDED + ` DESC LIMIT 0,${expectCount}` })
let currentFetchOp = fetchOps(testNum, 'Documents/Static/', FILE_TYPE, { order: FILEKEY.DATE_ADDED + ` DESC LIMIT 0,${expectCount}` })
console.info(`${testNum} currentFetchOp ${currentFetchOp} `)
let fetchFileResult = await media.getFileAssets(currentFetchOp);
......@@ -108,7 +113,7 @@ export default function fetchFileResultPromiseTest(abilityContext) {
it('SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETCOUNT_PROMISE_001_01', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETCOUNT_PROMISE_001_01'
let expectCount = 1
let currentFetchOp = fetchOps('Documents/Static/', FILE_TYPE,
let currentFetchOp = fetchOps(testNum, 'Documents/Static/', FILE_TYPE,
{ order: FILEKEY.DATE_ADDED + " DESC LIMIT 0,1", })
await checkAssetCount(done, testNum, currentFetchOp, expectCount)
});
......@@ -124,7 +129,7 @@ export default function fetchFileResultPromiseTest(abilityContext) {
it('SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETCOUNT_PROMISE_001_02', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETCOUNT_PROMISE_001_02'
let expectCount = 2
let currentFetchOp = fetchOps('Documents/Static/', FILE_TYPE,
let currentFetchOp = fetchOps(testNum, 'Documents/Static/', FILE_TYPE,
{ order: FILEKEY.DATE_ADDED + " DESC LIMIT 0,2", })
await checkAssetCount(done, testNum, currentFetchOp, expectCount)
});
......@@ -140,7 +145,7 @@ export default function fetchFileResultPromiseTest(abilityContext) {
it('SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETCOUNT_PROMISE_001_03', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETCOUNT_PROMISE_001_03'
let expectCount = 100
let currentFetchOp = fetchOps('Documents/Static/', FILE_TYPE,
let currentFetchOp = fetchOps(testNum, 'Documents/Static/', FILE_TYPE,
{ order: FILEKEY.DATE_ADDED + " DESC LIMIT 0,100", })
await checkAssetCount(done, testNum, currentFetchOp, expectCount)
});
......@@ -156,7 +161,7 @@ export default function fetchFileResultPromiseTest(abilityContext) {
it('SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETCOUNT_PROMISE_001_04', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETCOUNT_PROMISE_001_03'
let expectCount = 0
let currentFetchOp = fetchOps('Documents/zeor/', FILE_TYPE)
let currentFetchOp = fetchOps(testNum, 'Documents/zeor/', FILE_TYPE)
await checkAssetCount(done, testNum, currentFetchOp, expectCount)
});
......@@ -174,7 +179,7 @@ export default function fetchFileResultPromiseTest(abilityContext) {
it('SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_ISAFTERLAST_PROMISE_002', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_ISAFTERLAST_PROMISE_002'
try {
let currentFetchOp = fetchOps('Pictures/Static/', IMAGE_TYPE);
let currentFetchOp = fetchOps(testNum, 'Pictures/Static/', IMAGE_TYPE);
console.info(`${testNum} currentFetchOp :${JSON.stringify(currentFetchOp)}`)
let fetchFileResult = await media.getFileAssets(currentFetchOp);
let expectCount = 4;
......@@ -211,7 +216,7 @@ export default function fetchFileResultPromiseTest(abilityContext) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_CLOSE_PROMISE_003';
try {
let expectCount = 4;
let currentFetchOp = fetchOps('Pictures/Static/', IMAGE_TYPE)
let currentFetchOp = fetchOps(testNum, 'Pictures/Static/', IMAGE_TYPE)
let fetchFileResult = await media.getFileAssets(currentFetchOp);
let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchFileResult, expectCount);
if (!checkAssetCountPass) return;
......@@ -256,7 +261,7 @@ export default function fetchFileResultPromiseTest(abilityContext) {
it('SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETFIRSTOBJECT_PROMISE_004', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETFIRSTOBJECT_PROMISE_004'
try {
let currentFetchOp = fetchOps('Pictures/Static/', IMAGE_TYPE, { order: FILEKEY.DATE_ADDED + " DESC" })
let currentFetchOp = fetchOps(testNum, 'Pictures/Static/', IMAGE_TYPE, { order: FILEKEY.DATE_ADDED + " DESC" })
console.info(`${testNum} currentFetchOp ${JSON.stringify(currentFetchOp)} `)
let fetchFileResult = await media.getFileAssets(currentFetchOp);
let expectCount = 4;
......@@ -288,7 +293,7 @@ export default function fetchFileResultPromiseTest(abilityContext) {
it('SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETNEXTOBJECT_PROMISE_005', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETNEXTOBJECT_PROMISE_005'
try {
let currentFetchOp = fetchOps('Pictures/Static/', IMAGE_TYPE, { order: FILEKEY.DATE_ADDED + " DESC" })
let currentFetchOp = fetchOps(testNum, 'Pictures/Static/', IMAGE_TYPE, { order: FILEKEY.DATE_ADDED + " DESC" })
console.info(`${testNum} currentFetchOp ${JSON.stringify(currentFetchOp)} `)
let fetchFileResult = await media.getFileAssets(currentFetchOp);
......@@ -323,7 +328,7 @@ export default function fetchFileResultPromiseTest(abilityContext) {
it('SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETLASTOBJECT_PROMISE_006', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETLASTOBJECT_PROMISE_006'
try {
let currentFetchOp = fetchOps('Pictures/Static/', IMAGE_TYPE, { order: FILEKEY.DATE_ADDED + " DESC" })
let currentFetchOp = fetchOps(testNum, 'Pictures/Static/', IMAGE_TYPE, { order: FILEKEY.DATE_ADDED + " DESC" })
console.info(`${testNum} currentFetchOp ${JSON.stringify(currentFetchOp)} `)
let fetchFileResult = await media.getFileAssets(currentFetchOp);
......@@ -397,7 +402,7 @@ export default function fetchFileResultPromiseTest(abilityContext) {
it('SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETPOSITIONOBJECT_PROMISE_007_04', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETPOSITIONOBJECT_PROMISE_007_04'
try {
let currentFetchOp = fetchOps('Pictures/Static/', IMAGE_TYPE, { order: FILEKEY.DATE_ADDED + " DESC" })
let currentFetchOp = fetchOps(testNum, 'Pictures/Static/', IMAGE_TYPE, { order: FILEKEY.DATE_ADDED + " DESC" })
console.info(`${testNum} currentFetchOp ${currentFetchOp} `)
let fetchFileResult = await media.getFileAssets(currentFetchOp);
......@@ -466,91 +471,5 @@ export default function fetchFileResultPromiseTest(abilityContext) {
});
// ------------------------------ 008 test end -------------------------
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_getFirstObject_PROMISE_009_01
* @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_PROMISE_009_01', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_getFirstObject_PROMISE_009_01';
try {
let currentFetchOp = fetchOps('Pictures/ImageInfo/', IMAGE_TYPE)
let fetchFileResult = await media.getFileAssets(currentFetchOp);
let expectCount = 1;
let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchFileResult, expectCount);
if (!checkAssetCountPass) return;
let firstObject = await fetchFileResult.getFirstObject();
expect(firstObject.id != undefined).assertTrue();
if (firstObject.id == undefined) {
console.info('MediaLibraryTest :firstObject.id == undefined');
}
expect(firstObject.uri != undefined).assertTrue();
if (firstObject.uri == undefined) {
console.info('MediaLibraryTest :firstObject.uri === undefined');
}
expect(firstObject.mimeType).assertEqual('image/*');
expect(firstObject.mediaType).assertEqual(IMAGE_TYPE);
expect(firstObject.displayName).assertEqual('01.jpg');
expect(firstObject.title).assertEqual('01');
expect(firstObject.relativePath).assertEqual('Pictures/ImageInfo/');
expect(firstObject.parent != undefined).assertTrue();
if (firstObject.parent == undefined) {
console.info('MediaLibraryTest :firstObject.parent == undefined');
}
expect(firstObject.size).assertEqual(348113);
expect(firstObject.dateTaken).assertEqual(0);
expect(firstObject.artist).assertEqual('');
expect(firstObject.audioAlbum).assertEqual('');
expect(firstObject.width).assertEqual(1279);
expect(firstObject.height).assertEqual(1706);
expect(firstObject.orientation).assertEqual(0);
expect(firstObject.duration).assertEqual(0);
expect(firstObject.albumId != undefined).assertTrue();
if (firstObject.albumId == undefined) {
console.info('MediaLibraryTest :firstObject.albumId == undefined');
}
expect(firstObject.albumUri != undefined).assertTrue();
if (firstObject.albumUri == undefined) {
console.info('MediaLibraryTest :firstObject.albumUri:' + firstObject.albumUri);
}
expect(firstObject.albumName).assertEqual('ImageInfo');
expect(firstObject.dateAdded != undefined).assertTrue();
if (firstObject.dateAdded == undefined) {
console.info('MediaLibraryTest :firstObject.dateAdded:' + firstObject.dateAdded);
}
expect(firstObject.albumName != undefined).assertTrue();
if (firstObject.albumName == undefined) {
console.info('MediaLibraryTest :firstObject.albumName:' + firstObject.albumName);
}
done();
} catch (error) {
console.info(`${testNum} error : ${error}`);
expect(false).assertTrue();
done();
}
});
});
}
......@@ -122,7 +122,7 @@ export default function getThumbnailCallback(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_001_01', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_001_01';
let dOp = fetchOps('Pictures/Thumbnail/', IMAGE_TYPE);
let dOp = fetchOps(testNum, 'Pictures/Thumbnail/', IMAGE_TYPE);
let size = { width: 128, height: 128 };
await testGetThumbnail(done, testNum, dOp, size)
});
......@@ -137,7 +137,7 @@ export default function getThumbnailCallback(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_001_02', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_001_02';
let dOp = fetchOps('Pictures/Thumbnail/', IMAGE_TYPE);
let dOp = fetchOps(testNum, 'Pictures/Thumbnail/', IMAGE_TYPE);
let size = { width: 128, height: 256 };
await testGetThumbnail(done, testNum, dOp, size);
});
......@@ -152,7 +152,7 @@ export default function getThumbnailCallback(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_001_03', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_001_03';
let dOp = fetchOps('Pictures/Thumbnail/', IMAGE_TYPE);
let dOp = fetchOps(testNum, 'Pictures/Thumbnail/', IMAGE_TYPE);
let size = 'default';
await testGetThumbnail(done, testNum, dOp, size,);
});
......@@ -167,7 +167,7 @@ export default function getThumbnailCallback(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_001_04', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_001_04';
let dOp = fetchOps('Pictures/Thumbnail/', IMAGE_TYPE);
let dOp = fetchOps(testNum, 'Pictures/Thumbnail/', IMAGE_TYPE);
let size = { width: 1, height: 1 };
await testGetThumbnail(done, testNum, dOp, size,);
});
......@@ -183,7 +183,7 @@ export default function getThumbnailCallback(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_001_05', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_001_05';
let dOp = fetchOps('Pictures/Thumbnail/', IMAGE_TYPE);
let dOp = fetchOps(testNum, 'Pictures/Thumbnail/', IMAGE_TYPE);
let size = { width: 0, height: 0 };
await testGetThumbnailError(done, testNum, dOp, size,);
});
......@@ -199,7 +199,7 @@ export default function getThumbnailCallback(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_001_06', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_001_06';
let dOp = fetchOps('Pictures/Thumbnail/', IMAGE_TYPE);
let dOp = fetchOps(testNum, 'Pictures/Thumbnail/', IMAGE_TYPE);
let size = { width: -128, height: -128 };
await testGetThumbnailError(done, testNum, dOp, size,);
});
......@@ -214,7 +214,7 @@ export default function getThumbnailCallback(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_001_07', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_001_07';
let dOp = fetchOps('Pictures/Thumbnail/', IMAGE_TYPE);
let dOp = fetchOps(testNum, 'Pictures/Thumbnail/', IMAGE_TYPE);
let size = { width: 1024, height: 1024 };
await testGetThumbnail(done, testNum, dOp, size,);
});
......@@ -231,7 +231,7 @@ export default function getThumbnailCallback(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_002_01', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_002_01';
let dOp = fetchOps('Videos/Thumbnail/', VIDEO_TYPE);
let dOp = fetchOps(testNum, 'Videos/Thumbnail/', VIDEO_TYPE);
let size = { width: 128, height: 128 };
await testGetThumbnail(done, testNum, dOp, size)
});
......@@ -246,7 +246,7 @@ export default function getThumbnailCallback(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_002_02', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_002_02';
let dOp = fetchOps('Videos/Thumbnail/', VIDEO_TYPE);
let dOp = fetchOps(testNum, 'Videos/Thumbnail/', VIDEO_TYPE);
let size = { width: 128, height: 256 };
await testGetThumbnail(done, testNum, dOp, size);
});
......@@ -261,7 +261,7 @@ export default function getThumbnailCallback(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_002_03', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_002_03';
let dOp = fetchOps('Videos/Thumbnail/', VIDEO_TYPE);
let dOp = fetchOps(testNum, 'Videos/Thumbnail/', VIDEO_TYPE);
let size = 'default';
await testGetThumbnail(done, testNum, dOp, size,);
});
......@@ -276,7 +276,7 @@ export default function getThumbnailCallback(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_002_04', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_002_04';
let dOp = fetchOps('Videos/Thumbnail/', VIDEO_TYPE);
let dOp = fetchOps(testNum, 'Videos/Thumbnail/', VIDEO_TYPE);
let size = { width: 1, height: 1 };
await testGetThumbnail(done, testNum, dOp, size,);
});
......@@ -291,7 +291,7 @@ export default function getThumbnailCallback(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_002_05', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_002_05';
let dOp = fetchOps('Videos/Thumbnail/', VIDEO_TYPE);
let dOp = fetchOps(testNum, 'Videos/Thumbnail/', VIDEO_TYPE);
let size = { width: 0, height: 0 };
await testGetThumbnailError(done, testNum, dOp, size,);
});
......@@ -306,7 +306,7 @@ export default function getThumbnailCallback(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_002_06', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_002_06';
let dOp = fetchOps('Videos/Thumbnail/', VIDEO_TYPE);
let dOp = fetchOps(testNum, 'Videos/Thumbnail/', VIDEO_TYPE);
let size = { width: -128, height: -128 };
await testGetThumbnailError(done, testNum, dOp, size,);
});
......@@ -321,7 +321,7 @@ export default function getThumbnailCallback(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_002_07', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_002_07';
let dOp = fetchOps('Videos/Thumbnail/', VIDEO_TYPE);
let dOp = fetchOps(testNum, 'Videos/Thumbnail/', VIDEO_TYPE);
let size = { width: 1024, height: 1024 };
await testGetThumbnail(done, testNum, dOp, size,);
});
......@@ -338,7 +338,7 @@ export default function getThumbnailCallback(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_003_01', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_003_01';
let dOp = fetchOps('Audios/Thumbnail/', AUDIO_TYPE);
let dOp = fetchOps(testNum, 'Audios/Thumbnail/', AUDIO_TYPE);
let size = { width: 128, height: 128 };
await testGetThumbnail(done, testNum, dOp, size)
});
......@@ -353,7 +353,7 @@ export default function getThumbnailCallback(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_003_02', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_003_02';
let dOp = fetchOps('Audios/Thumbnail/', AUDIO_TYPE);
let dOp = fetchOps(testNum, 'Audios/Thumbnail/', AUDIO_TYPE);
let size = { width: 128, height: 256 };
await testGetThumbnail(done, testNum, dOp, size);
});
......@@ -368,7 +368,7 @@ export default function getThumbnailCallback(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_003_03', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_003_03';
let dOp = fetchOps('Audios/Thumbnail/', AUDIO_TYPE);
let dOp = fetchOps(testNum, 'Audios/Thumbnail/', AUDIO_TYPE);
let size = 'default';
await testGetThumbnail(done, testNum, dOp, size,);
});
......@@ -383,7 +383,7 @@ export default function getThumbnailCallback(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_003_04', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_003_04';
let dOp = fetchOps('Audios/Thumbnail/', AUDIO_TYPE);
let dOp = fetchOps(testNum, 'Audios/Thumbnail/', AUDIO_TYPE);
let size = { width: 1, height: 1 };
await testGetThumbnail(done, testNum, dOp, size,);
});
......@@ -398,7 +398,7 @@ export default function getThumbnailCallback(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_003_05', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_003_05';
let dOp = fetchOps('Audios/Thumbnail/', AUDIO_TYPE);
let dOp = fetchOps(testNum, 'Audios/Thumbnail/', AUDIO_TYPE);
let size = { width: 0, height: 0 };
await testGetThumbnailError(done, testNum, dOp, size,);
});
......@@ -413,7 +413,7 @@ export default function getThumbnailCallback(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_003_06', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_003_06';
let dOp = fetchOps('Audios/Thumbnail/', AUDIO_TYPE);
let dOp = fetchOps(testNum, 'Audios/Thumbnail/', AUDIO_TYPE);
let size = { width: -128, height: -128 };
await testGetThumbnailError(done, testNum, dOp, size,);
});
......@@ -428,7 +428,7 @@ export default function getThumbnailCallback(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_003_07', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_003_07';
let dOp = fetchOps('Audios/Thumbnail/', AUDIO_TYPE);
let dOp = fetchOps(testNum, 'Audios/Thumbnail/', AUDIO_TYPE);
let size = { width: 1024, height: 1024 };
await testGetThumbnail(done, testNum, dOp, size,);
});
......
......@@ -103,7 +103,7 @@ export default function getThumbnailPromise(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_001_01', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_001_01';
let dOp = fetchOps('Pictures/Thumbnail/', IMAGE_TYPE);
let dOp = fetchOps(testNum, 'Pictures/Thumbnail/', IMAGE_TYPE);
let size = { width: 128, height: 128 };
await testGetThumbnail(done, testNum, dOp, size)
});
......@@ -118,7 +118,7 @@ export default function getThumbnailPromise(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_001_02', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_001_02';
let dOp = fetchOps('Pictures/Thumbnail/', IMAGE_TYPE);
let dOp = fetchOps(testNum, 'Pictures/Thumbnail/', IMAGE_TYPE);
let size = { width: 128, height: 256 };
await testGetThumbnail(done, testNum, dOp, size);
});
......@@ -133,7 +133,7 @@ export default function getThumbnailPromise(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_001_03', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_001_03';
let dOp = fetchOps('Pictures/Thumbnail/', IMAGE_TYPE);
let dOp = fetchOps(testNum, 'Pictures/Thumbnail/', IMAGE_TYPE);
let size = 'default';
await testGetThumbnail(done, testNum, dOp, size,);
});
......@@ -148,7 +148,7 @@ export default function getThumbnailPromise(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_001_04', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_001_04';
let dOp = fetchOps('Pictures/Thumbnail/', IMAGE_TYPE);
let dOp = fetchOps(testNum, 'Pictures/Thumbnail/', IMAGE_TYPE);
let size = { width: 1, height: 1 };
await testGetThumbnail(done, testNum, dOp, size,);
});
......@@ -163,7 +163,7 @@ export default function getThumbnailPromise(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_001_05', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_001_05';
let dOp = fetchOps('Pictures/Thumbnail/', IMAGE_TYPE);
let dOp = fetchOps(testNum, 'Pictures/Thumbnail/', IMAGE_TYPE);
let size = { width: 0, height: 0 };
await testGetThumbnailError(done, testNum, dOp, size,);
});
......@@ -178,7 +178,7 @@ export default function getThumbnailPromise(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_001_06', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_001_06';
let dOp = fetchOps('Pictures/Thumbnail/', IMAGE_TYPE);
let dOp = fetchOps(testNum, 'Pictures/Thumbnail/', IMAGE_TYPE);
let size = { width: -128, height: -128 };
await testGetThumbnailError(done, testNum, dOp, size,);
});
......@@ -192,7 +192,7 @@ export default function getThumbnailPromise(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_001_07', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_001_07';
let dOp = fetchOps('Pictures/Thumbnail/', IMAGE_TYPE);
let dOp = fetchOps(testNum, 'Pictures/Thumbnail/', IMAGE_TYPE);
let size = { width: 1024, height: 1024 };
await testGetThumbnail(done, testNum, dOp, size,);
});
......@@ -209,7 +209,7 @@ export default function getThumbnailPromise(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_002_01', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_002_01';
let dOp = fetchOps('Videos/Thumbnail/', VIDEO_TYPE);
let dOp = fetchOps(testNum, 'Videos/Thumbnail/', VIDEO_TYPE);
let size = { width: 128, height: 128 };
await testGetThumbnail(done, testNum, dOp, size)
});
......@@ -224,7 +224,7 @@ export default function getThumbnailPromise(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_002_02', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_002_02';
let dOp = fetchOps('Videos/Thumbnail/', VIDEO_TYPE);
let dOp = fetchOps(testNum, 'Videos/Thumbnail/', VIDEO_TYPE);
let size = { width: 128, height: 256 };
await testGetThumbnail(done, testNum, dOp, size);
});
......@@ -239,7 +239,7 @@ export default function getThumbnailPromise(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_002_03', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_002_03';
let dOp = fetchOps('Videos/Thumbnail/', VIDEO_TYPE);
let dOp = fetchOps(testNum, 'Videos/Thumbnail/', VIDEO_TYPE);
let size = 'default';
await testGetThumbnail(done, testNum, dOp, size,);
});
......@@ -254,7 +254,7 @@ export default function getThumbnailPromise(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_002_04', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_002_04';
let dOp = fetchOps('Videos/Thumbnail/', VIDEO_TYPE);
let dOp = fetchOps(testNum, 'Videos/Thumbnail/', VIDEO_TYPE);
let size = { width: 1, height: 1 };
await testGetThumbnail(done, testNum, dOp, size,);
});
......@@ -270,7 +270,7 @@ export default function getThumbnailPromise(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_002_05', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_002_05';
let dOp = fetchOps('Videos/Thumbnail/', VIDEO_TYPE);
let dOp = fetchOps(testNum, 'Videos/Thumbnail/', VIDEO_TYPE);
let size = { width: 0, height: 0 };
await testGetThumbnailError(done, testNum, dOp, size,);
});
......@@ -285,7 +285,7 @@ export default function getThumbnailPromise(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_002_06', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_002_06';
let dOp = fetchOps('Videos/Thumbnail/', VIDEO_TYPE);
let dOp = fetchOps(testNum, 'Videos/Thumbnail/', VIDEO_TYPE);
let size = { width: -128, height: -128 };
await testGetThumbnailError(done, testNum, dOp, size,);
});
......@@ -300,7 +300,7 @@ export default function getThumbnailPromise(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_002_07', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_002_07';
let dOp = fetchOps('Videos/Thumbnail/', VIDEO_TYPE);
let dOp = fetchOps(testNum, 'Videos/Thumbnail/', VIDEO_TYPE);
let size = { width: 1024, height: 1024 };
await testGetThumbnail(done, testNum, dOp, size,);
});
......@@ -317,7 +317,7 @@ export default function getThumbnailPromise(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_003_01', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_003_01';
let dOp = fetchOps('Audios/Thumbnail/', AUDIO_TYPE);
let dOp = fetchOps(testNum, 'Audios/Thumbnail/', AUDIO_TYPE);
let size = { width: 128, height: 128 };
await testGetThumbnail(done, testNum, dOp, size)
});
......@@ -332,7 +332,7 @@ export default function getThumbnailPromise(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_003_02', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_003_02';
let dOp = fetchOps('Audios/Thumbnail/', AUDIO_TYPE);
let dOp = fetchOps(testNum, 'Audios/Thumbnail/', AUDIO_TYPE);
let size = { width: 128, height: 256 };
await testGetThumbnail(done, testNum, dOp, size);
});
......@@ -347,7 +347,7 @@ export default function getThumbnailPromise(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_003_03', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_003_03';
let dOp = fetchOps('Audios/Thumbnail/', AUDIO_TYPE);
let dOp = fetchOps(testNum, 'Audios/Thumbnail/', AUDIO_TYPE);
let size = 'default';
await testGetThumbnail(done, testNum, dOp, size,);
});
......@@ -362,7 +362,7 @@ export default function getThumbnailPromise(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_003_04', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_003_04';
let dOp = fetchOps('Audios/Thumbnail/', AUDIO_TYPE);
let dOp = fetchOps(testNum, 'Audios/Thumbnail/', AUDIO_TYPE);
let size = { width: 1, height: 1 };
await testGetThumbnail(done, testNum, dOp, size,);
});
......@@ -377,7 +377,7 @@ export default function getThumbnailPromise(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_003_05', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_003_05';
let dOp = fetchOps('Audios/Thumbnail/', AUDIO_TYPE);
let dOp = fetchOps(testNum, 'Audios/Thumbnail/', AUDIO_TYPE);
let size = { width: 0, height: 0 };
await testGetThumbnailError(done, testNum, dOp, size,);
});
......@@ -392,7 +392,7 @@ export default function getThumbnailPromise(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_003_06', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_003_06';
let dOp = fetchOps('Audios/Thumbnail/', AUDIO_TYPE);
let dOp = fetchOps(testNum, 'Audios/Thumbnail/', AUDIO_TYPE);
let size = { width: -128, height: -128 };
await testGetThumbnailError(done, testNum, dOp, size,);
});
......@@ -407,7 +407,7 @@ export default function getThumbnailPromise(abilityContext) {
*/
it('SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_003_07', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_003_07';
let dOp = fetchOps('Audios/Thumbnail/', AUDIO_TYPE);
let dOp = fetchOps(testNum, 'Audios/Thumbnail/', AUDIO_TYPE);
let size = { width: 1024, height: 1024 };
await testGetThumbnail(done, testNum, dOp, size,);
});
......
/*
* Copyright (C) 2021 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 mediaLibrary from '@ohos.multimedia.mediaLibrary';
import featureAbility from '@ohos.ability.featureAbility';
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index';
function printAttr(asset) {
for (const key in asset) {
console.info(`${key}: asset[key]`);
}
}
function checkAttrs(done, asset, tNum) {
let passed = true;
for (const key in asset) {
if (asset[key] == undefined) {
passed = false;
break;
}
}
if (passed) {
console.info(`FileAsset checkAttrs ${tNum} passed`);
expect(true).assertTrue();
done();
} else {
console.info(`FileAsset checkAttrs ${tNum} failed`);
expect(false).assertTrue();
done();
}
}
describe('fileAsset2.test.js', async function () {
let fileKeyObj = mediaLibrary.FileKey;
let imageType = mediaLibrary.MediaType.IMAGE;
let videoType = mediaLibrary.MediaType.VIDEO;
let audioType = mediaLibrary.MediaType.AUDIO;
let imagesfetchOp = {
selections: fileKeyObj.MEDIA_TYPE + '= ?',
selectionArgs: [imageType.toString()],
};
let videosfetchOp = {
selections: fileKeyObj.MEDIA_TYPE + '= ?',
selectionArgs: [videoType.toString()],
};
let audiosfetchOp = {
selections: fileKeyObj.MEDIA_TYPE + '= ?',
selectionArgs: [audioType.toString()],
};
let allTypefetchOp = {
selections: '',
selectionArgs: [],
};
const context = featureAbility.getContext();
const media = mediaLibrary.getMediaLibrary(context);
beforeAll(function () {});
beforeEach(function () {});
afterEach(function () {});
afterAll(function () {});
/**
* @tc.number : SUB_MEDIA_FILEASSET_commitModify_promise_001
* @tc.name : commitModify
* @tc.desc : Modify displayName
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MEDIA_FILEASSET_commitModify_promise_001', 0, async function (done) {
try {
const fetchFileResult = await media.getFileAssets(imagesfetchOp);
const asset = await fetchFileResult.getFirstObject();
const newName = 'newName';
asset.displayName = newName;
const id = asset.id;
await asset.commitModify();
const fetchFileResult2 = await media.getFileAssets(imagesfetchOp);
const dataList = await fetchFileResult2.getAllObject();
let passed = false;
for (let i = 0; i < dataList.length; i++) {
const asset = dataList[i];
if (asset.id == id && asset.displayName == newName) {
passed = true;
break;
}
}
expect(passed).assertTrue();
done();
} catch (error) {
console.info('FileAsset commitModify 001 failed, message = ' + error);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number : SUB_MEDIA_FILEASSET_commitModify_promise_002
* @tc.name : commitModify
* @tc.desc : Modify title
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MEDIA_FILEASSET_commitModify_promise_002', 0, async function (done) {
try {
const fetchFileResult = await media.getFileAssets(imagesfetchOp);
const asset = await fetchFileResult.getFirstObject();
const newTitle = 'newTitle';
asset.title = newTitle;
const id = asset.id;
await asset.commitModify();
const fetchFileResult2 = await media.getFileAssets(imagesfetchOp);
const dataList = await fetchFileResult2.getAllObject();
let passed = false;
for (let i = 0; i < dataList.length; i++) {
const asset = dataList[i];
if (asset.id == id && asset.title == newTitle) {
passed = true;
break;
}
}
expect(passed).assertTrue();
done();
} catch (error) {
console.info('FileAsset commitModify 002 failed, message = ' + error);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number : SUB_MEDIA_FILEASSET_commitModify_promise_003
* @tc.name : commitModify
* @tc.desc : Modify relativePath
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MEDIA_FILEASSET_commitModify_promise_003', 0, async function (done) {
try {
const path1 = await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_IMAGE);
const path2 = await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_VIDEO);
const fetchFileResult = await media.getFileAssets(imagesfetchOp);
const asset = await fetchFileResult.getFirstObject();
let relativePath = asset.relativePath;
let newrelativePath = path1;
if (relativePath == path1) {
newrelativePath = path2;
}
asset.relativePath = newrelativePath;
const id = asset.id;
await asset.commitModify();
const fetchFileResult2 = await media.getFileAssets(imagesfetchOp);
const dataList = await fetchFileResult2.getAllObject();
let passed = false;
for (let i = 0; i < dataList.length; i++) {
const asset = dataList[i];
if (asset.id == id && asset.relativePath == newrelativePath) {
passed = true;
break;
}
}
expect(passed).assertTrue();
done();
} catch (error) {
console.info('FileAsset commitModify 003 failed, message = ' + error);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number : SUB_MEDIA_FILEASSET_commitModify_promise_004
* @tc.name : commitModify
* @tc.desc : Modify orientation
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MEDIA_FILEASSET_commitModify_promise_004', 0, async function (done) {
try {
const fetchFileResult = await media.getFileAssets(imagesfetchOp);
const asset = await fetchFileResult.getFirstObject();
let neworientation = 1;
if (asset.orientation == 1) {
neworientation = 0;
}
asset.orientation = neworientation;
const id = asset.id;
await asset.commitModify();
const fetchFileResult2 = await media.getFileAssets(imagesfetchOp);
const dataList = await fetchFileResult2.getAllObject();
let passed = false;
for (let i = 0; i < dataList.length; i++) {
const asset = dataList[i];
if (asset.id == id && asset.orientation == neworientation) {
passed = true;
break;
}
}
expect(passed).assertTrue();
done();
} catch (error) {
console.info('FileAsset commitModify 004 failed, message = ' + error);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number : SUB_MEDIA_FILEASSET_commitModify_promise_005
* @tc.name : commitModify
* @tc.desc : Modify uri
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MEDIA_FILEASSET_commitModify_promise_005', 0, async function (done) {
try {
const fetchFileResult = await media.getFileAssets(imagesfetchOp);
const asset = await fetchFileResult.getFirstObject();
const id = asset.id;
const newUri = 'newUri';
asset.uri = newUri;
await asset.commitModify();
console.info('FileAsset commitModify 005 failed');
expect(false).assertTrue();
done();
} catch (error) {
console.info('FileAsset commitModify 005 passed');
expect(true).assertTrue();
done();
}
});
/**
* @tc.number : SUB_MEDIA_FILEASSET_commitModify_promise_006
* @tc.name : commitModify
* @tc.desc : Modify mediaType
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MEDIA_FILEASSET_commitModify_promise_006', 0, async function (done) {
try {
const fetchFileResult = await media.getFileAssets(imagesfetchOp);
const asset = await fetchFileResult.getFirstObject();
const id = asset.id;
const newMediaType = 'newMediaType';
asset.mediaType = newMediaType;
await asset.commitModify();
console.info('FileAsset commitModify 006 failed');
expect(false).assertTrue();
done();
} catch (error) {
console.info('FileAsset commitModify 006 passed');
expect(true).assertTrue();
done();
}
});
/**
* @tc.number : SUB_MEDIA_FILEASSET_isDirectory_promise_001
* @tc.name : isDirectory
* @tc.desc : isDirectory asset
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MEDIA_FILEASSET_isDirectory_promise_001', 0, async function (done) {
try {
const fetchFileResult = await media.getFileAssets(imagesfetchOp);
const asset = await fetchFileResult.getFirstObject();
const isDir = await asset.isDirectory();
expect(!isDir).assertTrue();
done();
} catch (error) {
console.info('FileAsset isDirectory 001 failed, message = ' + error);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number : SUB_MEDIA_FILEASSET_checkAttr_promise_001
* @tc.name : attrs
* @tc.desc : imagesfetchOp attrs print and check
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MEDIA_FILEASSET_checkAttr_promise_001', 0, async function (done) {
try {
const fetchFileResult = await media.getFileAssets(imagesfetchOp);
const asset = await fetchFileResult.getFirstObject();
printAttr(asset);
checkAttrs(done, asset, '001');
} catch (error) {
console.info('FileAsset checkAttr 001 failed, message = ' + error);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number : SUB_MEDIA_FILEASSET_checkAttr_promise_002
* @tc.name : attrs
* @tc.desc : videosfetchOp attrs print and check
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MEDIA_FILEASSET_checkAttr_promise_002', 0, async function (done) {
try {
const fetchFileResult = await media.getFileAssets(videosfetchOp);
const asset = await fetchFileResult.getFirstObject();
printAttr(asset);
checkAttrs(done, asset, '002');
} catch (error) {
console.info('FileAsset checkAttr 002 failed, message = ' + error);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number : SUB_MEDIA_FILEASSET_checkAttr_promise_003
* @tc.name : attrs
* @tc.desc : audiosfetchOp attrs print and check
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MEDIA_FILEASSET_checkAttr_promise_003', 0, async function (done) {
try {
const fetchFileResult = await media.getFileAssets(audiosfetchOp);
const asset = await fetchFileResult.getFirstObject();
printAttr(asset);
checkAttrs(done, asset, '003');
} catch (error) {
console.info('FileAsset checkAttr 003 failed, message = ' + error);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number : SUB_MEDIA_FILEASSET_checkAttr_promise_004
* @tc.name : attrs
* @tc.desc : album attrs print and check
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MEDIA_FILEASSET_checkAttr_promise_004', 0, async function (done) {
try {
const albumList = await media.getAlbums(allTypefetchOp);
const album = albumList[0];
const fetchFileResult = await album.getFileAssets(allTypefetchOp);
const asset = await fetchFileResult.getFirstObject();
printAttr(asset);
checkAttrs(done, asset, '004');
} catch (error) {
console.info('FileAsset checkAttr 003 failed, message = ' + error);
expect(false).assertTrue();
done();
}
});
});
......@@ -13,7 +13,7 @@
import("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("mediaLibrary_fileAssetUri_hap") {
ohos_js_hap_suite("mediaLibrary_mediafetchoptions_hap") {
hap_profile = "entry/src/main/module.json"
deps = [
":mediaLibrary_js_assets",
......@@ -21,7 +21,7 @@ ohos_js_hap_suite("mediaLibrary_fileAssetUri_hap") {
]
ets2abc = true
certificate_profile = "signature/openharmony_sx.p7b"
hap_name = "ActsMediaLibraryFileAssetUri"
hap_name = "ActsMediaLibraryMediafetchoptions"
}
ohos_app_scope("medialibrary_app_profile") {
......
......@@ -54,7 +54,7 @@
},
{
"test-file-name": [
"ActsMediaLibraryFileAssetUri.hap"
"ActsMediaLibraryMediafetchoptions.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
......
......@@ -13,9 +13,9 @@
* limitations under the License.
*/
import fileAssetUriTestPromise from './fileAssetUriTestPromise.test.ets'
import fileAssetUriTestCallback from './fileAssetUriTestCallback.test.ets'
import mediafetchoptionsCallback from './mediafetchoptionsCallback.test.ets'
import mediafetchoptionsPromise from './mediafetchoptionsPromise.test.ets'
export default function testsuite(abilityContext) {
fileAssetUriTestCallback(abilityContext)
fileAssetUriTestPromise(abilityContext)
mediafetchoptionsCallback(abilityContext)
mediafetchoptionsPromise(abilityContext)
}
/*
* Copyright (C) 2022 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 mediaLibrary from '@ohos.multimedia.mediaLibrary';
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index';
import {
sleep,
IMAGE_TYPE,
AUDIO_TYPE,
VIDEO_TYPE,
FILE_TYPE,
FILEKEY,
checkPresetsAssets,
checkAssetsCount,
fetchOps,
getPermission,
} from '../../../../../../common';
export default function filekeyTestCallbackTest(abilityContext) {
describe('filekeyTestCallbackTest', function () {
const media = mediaLibrary.getMediaLibrary(abilityContext);
beforeAll(async function () {
console.info('beforeAll case');
await getPermission();
await checkPresetsAssets(media, 'ActsMediaLibraryFileAssetUri');
});
beforeEach(function () {
console.info('beforeEach case');
});
afterEach(async function () {
console.info('afterEach case');
await sleep()
});
afterAll(function () {
console.info('afterAll case');
});
const serachUri = async (done, testNum, fetchOp, type) => {
try {
const fetchFileResult = await media.getFileAssets(fetchOp);
let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchFileResult, 2);
if (!checkAssetCountPass) return;
let firstObject = await fetchFileResult.getFirstObject();
const id = firstObject.id;
const uri = firstObject.uri;
const serachUri = `datashare:///media/${type}/${id}`;
console.info(`${testNum} :uri ${uri};serachUri${serachUri})`)
let serchfetchOp = {
uri: serachUri.toString(),
selections: '',
selectionArgs: [],
};
media.getFileAssets(serchfetchOp, async (err, result) => {
if (err) {
console.info(`${testNum}, err: ${err}`)
expect(false).assertTrue();
done();
return;
}
checkAssetCountPass = await checkAssetsCount(done, testNum, result, 1);
if (!checkAssetCountPass) return;
let asset = await result.getFirstObject();
expect(asset.uri).assertEqual(serachUri);
expect(asset.id).assertEqual(id);
done();
});
} catch (error) {
console.info(`${testNum} failed error: ${error}`)
expect(false).assertTrue();
done();
}
}
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_ASSET_URI_Callback_001
* @tc.name : uri
* @tc.desc : serach image asset by uri
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MEDIA_MEDIALIBRARY_ASSET_URI_Callback_001', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_ASSET_URI_Callback_001';
let currentFetchOp = fetchOps('Pictures/Static/', IMAGE_TYPE);
let type = 'image';
await serachUri(done, testNum, currentFetchOp, type);
});
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_ASSET_URI_Callback_002
* @tc.name : uri
* @tc.desc : serach audio asset by uri
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MEDIA_MEDIALIBRARY_ASSET_URI_Callback_002', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_ASSET_URI_Callback_002';
let currentFetchOp = fetchOps('Audios/Static/', AUDIO_TYPE);
let type = 'audio';
await serachUri(done, testNum, currentFetchOp, type);
});
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_ASSET_URI_Callback_003
* @tc.name : uri
* @tc.desc : serach video asset by uri
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MEDIA_MEDIALIBRARY_ASSET_URI_Callback_003', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_ASSET_URI_Callback_003';
let currentFetchOp = fetchOps('Videos/Static/', VIDEO_TYPE);
let type = 'video';
await serachUri(done, testNum, currentFetchOp, type);
});
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_ASSET_URI_Callback_004
* @tc.name : uri
* @tc.desc : serach file asset by uri
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MEDIA_MEDIALIBRARY_ASSET_URI_Callback_004', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_ASSET_URI_Callback_004';
let currentFetchOp = fetchOps('Documents/Static/', FILE_TYPE);
let type = 'file';
await serachUri(done, testNum, currentFetchOp, type);
});
});
}
/*
* Copyright (C) 2022 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 mediaLibrary from '@ohos.multimedia.mediaLibrary';
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index';
import {
sleep,
IMAGE_TYPE,
AUDIO_TYPE,
VIDEO_TYPE,
FILE_TYPE,
FILEKEY,
checkPresetsAssets,
checkAssetsCount,
fetchOps,
getPermission,
} from '../../../../../../common';
export default function filekeyTestCallbackTest(abilityContext) {
describe('filekeyTestCallbackTest', function () {
const media = mediaLibrary.getMediaLibrary(abilityContext);
beforeAll(async function () {
console.info('beforeAll case');
await getPermission();
await checkPresetsAssets(media, 'ActsMediaLibraryFileAssetUri');
});
beforeEach(function () {
console.info('beforeEach case');
});
afterEach(async function () {
console.info('afterEach case');
await sleep()
});
afterAll(function () {
console.info('afterAll case');
});
const serachUri = async (done, testNum, fetchOp, type) => {
try {
const fetchFileResult = await media.getFileAssets(fetchOp);
let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchFileResult, 2);
if (!checkAssetCountPass) return;
let firstObject = await fetchFileResult.getFirstObject();
const id = firstObject.id;
const uri = firstObject.uri;
const serachUri = `datashare:///media/${type}/${id}`;
console.info(`${testNum} :uri ${uri};serachUri${serachUri})`)
let serchfetchOp = {
uri: serachUri.toString(),
selections: '',
selectionArgs: [],
};
media.getFileAssets(serchfetchOp, async (err, result) => {
if (err) {
console.info(`${testNum}, err: ${err}`)
expect(false).assertTrue();
done();
return;
}
checkAssetCountPass = await checkAssetsCount(done, testNum, result, 1);
if (!checkAssetCountPass) return;
let asset = await result.getFirstObject();
expect(asset.uri).assertEqual(serachUri);
expect(asset.id).assertEqual(id);
done();
});
} catch (error) {
console.info(`${testNum} failed error: ${error}`)
expect(false).assertTrue();
done();
}
}
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_ASSET_URI_Callback_001
* @tc.name : uri
* @tc.desc : serach image asset by uri
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MEDIA_MEDIALIBRARY_ASSET_URI_Callback_001', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_ASSET_URI_Callback_001';
let currentFetchOp = fetchOps(testNum, 'Pictures/Static/', IMAGE_TYPE);
let type = 'image';
await serachUri(done, testNum, currentFetchOp, type);
});
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_ASSET_URI_Callback_002
* @tc.name : uri
* @tc.desc : serach audio asset by uri
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MEDIA_MEDIALIBRARY_ASSET_URI_Callback_002', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_ASSET_URI_Callback_002';
let currentFetchOp = fetchOps(testNum, 'Audios/Static/', AUDIO_TYPE);
let type = 'audio';
await serachUri(done, testNum, currentFetchOp, type);
});
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_ASSET_URI_Callback_003
* @tc.name : uri
* @tc.desc : serach video asset by uri
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MEDIA_MEDIALIBRARY_ASSET_URI_Callback_003', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_ASSET_URI_Callback_003';
let currentFetchOp = fetchOps(testNum, 'Videos/Static/', VIDEO_TYPE);
let type = 'video';
await serachUri(done, testNum, currentFetchOp, type);
});
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_ASSET_URI_Callback_004
* @tc.name : uri
* @tc.desc : serach file asset by uri
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MEDIA_MEDIALIBRARY_ASSET_URI_Callback_004', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_ASSET_URI_Callback_004';
let currentFetchOp = fetchOps(testNum, 'Documents/Static/', FILE_TYPE);
let type = 'file';
await serachUri(done, testNum, currentFetchOp, type);
});
});
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册