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

!5946 【userFileMgr】fix coverage && fix case name

Merge pull request !5946 from yangbo/1018_ufm_xts
......@@ -20,7 +20,7 @@ import dataSharePredicates from '@ohos.data.dataSharePredicates';
const presetsCount = {
ActsUserFileMgrAlbumJsTest: { albumsCount: 3, assetsCount: 3 },
ActsUserFileMgrBaseJsTest: { albumsCount: 9, assetsCount: 18 },
ActsUserFileMgrBaseJsTest: { albumsCount: 18, assetsCount: 33 },
ActsUserFileMgrFileAssetJsTest: { albumsCount: 45, assetsCount: 87 },
}
......
......@@ -70,9 +70,9 @@ export default function albumCommitModifyCallback(abilityContext) {
* @tc.desc : image album modify albumname
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 2
*/
it('SUB_USERFILE_MGR_ALBUM_COMMITMODIFY_CALLBACK_01', 0, async function (done) {
it('SUB_USERFILE_MGR_ALBUM_COMMITMODIFY_CALLBACK_01', 2, async function (done) {
const testNum = 'SUB_USERFILE_MGR_ALBUM_COMMITMODIFY_CALLBACK_01';
let currentFetchOp = albumFetchOps(testNum, 'Pictures/', 'DynamicCb');
await albumCommitModify(done, testNum, currentFetchOp);
......
......@@ -69,9 +69,9 @@ export default function albumCommitModifyPromise(abilityContext) {
* @tc.desc : album modify albumname
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 2
*/
it('SUB_USERFILE_MGR_ALBUM_COMMITMODIFY_PROMISE_01', 0, async function (done) {
it('SUB_USERFILE_MGR_ALBUM_COMMITMODIFY_PROMISE_01', 2, async function (done) {
const testNum = 'SUB_USERFILE_MGR_ALBUM_COMMITMODIFY_PROMISE_01';
let currentFetchOp = albumFetchOps(testNum, 'Pictures/', 'DynamicPro');
await albumCommitModify(done, testNum, currentFetchOp);
......
......@@ -101,9 +101,9 @@ export default function albumGetFileAssetsCallback(abilityContext) {
* @tc.desc : Album getPhotoAssets
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 1
*/
it('SUB_USERFILE_MGR_ALBUM_GETPHOTOASSETS_CALLBACK_01', 0, async function (done) {
it('SUB_USERFILE_MGR_ALBUM_GETPHOTOASSETS_CALLBACK_01', 1, async function (done) {
const testNum = 'SUB_USERFILE_MGR_ALBUM_GETPHOTOASSETS_CALLBACK_01';
let currentFetchOp = albumFetchOps(testNum, 'Pictures/', 'Static');
await getPhotoAssetsTest(done, testNum, currentFetchOp);
......@@ -115,9 +115,9 @@ export default function albumGetFileAssetsCallback(abilityContext) {
* @tc.desc : invalid AlbumFetchOptions
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 3
*/
it('SUB_USERFILE_MGR_ALBUM_GETPHOTOASSETS_ERRCODE_CALLBACK_01', 0, async function (done) {
it('SUB_USERFILE_MGR_ALBUM_GETPHOTOASSETS_ERRCODE_CALLBACK_01', 3, async function (done) {
const testNum = 'SUB_USERFILE_MGR_ALBUM_GETPHOTOASSETS_ERRCODE_CALLBACK_01';
let currentFetchOp = albumFetchOps(testNum, 'Pictures/', 'Static');
await getPhotoAssetsErrCodeTest(done, testNum, currentFetchOp);
......
......@@ -95,9 +95,9 @@ export default function albumGetFileAssetsPromise(abilityContext) {
* @tc.desc : Album getPhotoAssets
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 1
*/
it('SUB_USERFILE_MGR_ALBUM_GETPHOTOASSETS_PROMISE_01', 0, async function (done) {
it('SUB_USERFILE_MGR_ALBUM_GETPHOTOASSETS_PROMISE_01', 1, async function (done) {
const testNum = 'SUB_USERFILE_MGR_ALBUM_GETPHOTOASSETS_PROMISE_01';
let currentFetchOp = albumFetchOps(testNum, 'Pictures/', 'Static');
await getPhotoAssetsTest(done, testNum, currentFetchOp);
......@@ -109,9 +109,9 @@ export default function albumGetFileAssetsPromise(abilityContext) {
* @tc.desc : invalid AlbumFetchOptions
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 3
*/
it('SUB_USERFILE_MGR_ALBUM_GETPHOTOASSETS_ERRCODE_PROMISE_01', 0, async function (done) {
it('SUB_USERFILE_MGR_ALBUM_GETPHOTOASSETS_ERRCODE_PROMISE_01', 3, async function (done) {
const testNum = 'SUB_USERFILE_MGR_ALBUM_GETPHOTOASSETS_ERRCODE_PROMISE_01';
let currentFetchOp = albumFetchOps(testNum, 'Pictures/', 'Static');
await getPhotoAssetsErrCodeTest(done, testNum, currentFetchOp);
......
......@@ -31,13 +31,16 @@
{
"type": "ShellKit",
"run-command": [
"mkdir -pv /storage/media/100/local/files/Pictures/{Static,On,Off,myAlbum}",
"mkdir -pv /storage/media/100/local/files/Videos/{Static,On,Off,myAlbum}",
"mkdir -pv /storage/media/100/local/files/Audios/{Static,On,Off,myAlbum}",
"mkdir -pv /storage/media/100/local/files/Pictures/{Static,On,Off,myAlbum,deleteCb,deletePro}",
"mkdir -pv /storage/media/100/local/files/Videos/{Static,On,Off,myAlbum,deleteCb,deletePro}",
"mkdir -pv /storage/media/100/local/files/Audios/{Static,On,Off,myAlbum,deleteCb,deletePro}",
"for d in Static; do for i in $$(seq 4); do cp /storage/media/100/local/temp/01.jpg /storage/media/100/local/files/Pictures/$$d/0$$i.jpg; done;done;",
"for d in Static; do for i in $$(seq 4); do cp /storage/media/100/local/temp/01.mp3 /storage/media/100/local/files/Audios/$$d/0$$i.mp3; done;done;",
"for d in Static; do for i in $$(seq 4); do cp /storage/media/100/local/temp/01.mp4 /storage/media/100/local/files/Videos/$$d/0$$i.mp4; done;done;",
"for d in deleteCb deletePro; do for i in $$(seq 2); do cp /storage/media/100/local/temp/01.jpg /storage/media/100/local/files/Pictures/$$d/0$$i.jpg; done;done;",
"for d in deleteCb deletePro; do for i in $$(seq 2); do cp /storage/media/100/local/temp/01.mp3 /storage/media/100/local/files/Audios/$$d/0$$i.mp3; done;done;",
"for d in deleteCb deletePro; do for i in $$(seq 2); do cp /storage/media/100/local/temp/01.mp4 /storage/media/100/local/files/Videos/$$d/0$$i.mp4; done;done;",
"for d in On Off myAlbum; do for i in $$(seq 1); do cp /storage/media/100/local/temp/01.jpg /storage/media/100/local/files/Pictures/$$d/0$$i.jpg; done;done;",
"for d in On Off myAlbum; do for i in $$(seq 1); do cp /storage/media/100/local/temp/01.mp3 /storage/media/100/local/files/Audios/$$d/0$$i.mp3; done;done;",
"for d in On Off myAlbum; do for i in $$(seq 1); do cp /storage/media/100/local/temp/01.mp4 /storage/media/100/local/files/Videos/$$d/0$$i.mp4; done;done;",
......
......@@ -13,6 +13,8 @@
* limitations under the License.
*/
import deleteCallbackTest from './deleteCallback.test.ets'
import deletePromiseTest from './deletePromise.test.ets'
import getAlbumsCallbackTest from './getAlbumsCallback.test.ets'
import getAlbumsPromiseTest from './getAlbumsPromise.test.ets'
import getFileAssetsCallbackTest from './getFileAssetsCallback.test.ets'
......@@ -20,6 +22,8 @@ import getFileAssetsPromiseTest from './getFileAssetsPromise.test.ets'
import getUserFileMgrTest from './getUserFileMgr.test.ets'
import onOffReleasePromiseTest from './onOffReleasePromise.test.ets'
export default function testsuite(abilityContext) {
deleteCallbackTest(abilityContext)
deletePromiseTest(abilityContext)
getAlbumsCallbackTest(abilityContext)
getAlbumsPromiseTest(abilityContext)
getFileAssetsCallbackTest(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 userFileManager from '@ohos.filemanagement.userFileManager';
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index';
import {
sleep,
audioFetchOps,
imageVideoFetchOps,
checkPresetsAssets,
checkAssetsCount,
getPermission,
} from '../../../../../../common';
export default function deleteCallbackTest(abilityContext) {
describe('deleteCallbackTest', function () {
const userfilemgr = userFileManager.getUserFileMgr(abilityContext);
beforeAll(async function () {
console.info('beforeAll case');
await getPermission();
await checkPresetsAssets(userfilemgr, 'ActsUserFileMgrAlbumJsTest');
});
beforeEach(function () {
console.info('beforeEach case');
});
afterEach(async function () {
console.info('afterEach case');
await sleep()
});
afterAll(function () {
console.info('afterAll case');
});
const deleteTest = async function (done, testNum, fetchOp, isAudio) {
try {
let fetchAssetResult;
if (isAudio) {
fetchAssetResult = await userfilemgr.getAudioAssets(fetchOp);
} else {
fetchAssetResult = await userfilemgr.getPhotoAssets(fetchOp);
}
let expectCount = 2;
let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchAssetResult, expectCount);
if (!checkAssetCountPass) return;
const asset = await fetchAssetResult.getFirstObject();
fetchAssetResult.close();
userfilemgr.delete(asset.uri, async() => {
let newFetchResult;
if (isAudio) {
newFetchResult = await userfilemgr.getAudioAssets(fetchOp);
} else {
newFetchResult = await userfilemgr.getPhotoAssets(fetchOp);
}
expect(newFetchResult.getCount()).assertEqual(1);
newFetchResult.close();
done();
});
} catch (error) {
console.info(`${testNum}, failed: ${error}`);
expect(false).assertTrue();
done();
}
}
/**
* @tc.number : SUB_USERFILE_MGR_DELETE_CALLBACK_01
* @tc.name : delete
* @tc.desc : delete image
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
*/
it('SUB_USERFILE_MGR_DELETE_CALLBACK_01', 2, async function (done) {
let testNum = 'SUB_USERFILE_MGR_DELETE_CALLBACK_01';
let currentFetchOp = imageVideoFetchOps(testNum, 'Pictures/deleteCb/');
let isAudio = false;
await deleteTest(done, testNum, currentFetchOp, isAudio);
});
/**
* @tc.number : SUB_USERFILE_MGR_DELETE_CALLBACK_02
* @tc.name : delete
* @tc.desc : delete video
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
*/
it('SUB_USERFILE_MGR_DELETE_CALLBACK_02', 2, async function (done) {
let testNum = 'SUB_USERFILE_MGR_DELETE_CALLBACK_02';
let currentFetchOp = imageVideoFetchOps(testNum, 'Videos/deleteCb/');
let isAudio = false;
await deleteTest(done, testNum, currentFetchOp, isAudio);
});
/**
* @tc.number : SUB_USERFILE_MGR_DELETE_CALLBACK_03
* @tc.name : delete
* @tc.desc : delete audio
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
*/
it('SUB_USERFILE_MGR_DELETE_CALLBACK_03', 2, async function (done) {
let testNum = 'SUB_USERFILE_MGR_DELETE_CALLBACK_03';
let currentFetchOp = audioFetchOps(testNum, 'Audios/deleteCb/');
let isAudio = true;
await deleteTest(done, testNum, currentFetchOp, isAudio);
});
});
}
/*
* 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 userFileManager from '@ohos.filemanagement.userFileManager';
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index';
import {
sleep,
audioFetchOps,
imageVideoFetchOps,
checkPresetsAssets,
checkAssetsCount,
} from '../../../../../../common';
export default function deletePromiseTest(abilityContext) {
describe('deletePromiseTest', function () {
const userfilemgr = userFileManager.getUserFileMgr(abilityContext);
beforeAll(async function () {
console.info('beforeAll case');
await checkPresetsAssets(userfilemgr, 'ActsUserFileMgrAlbumJsTest');
});
beforeEach(function () {
console.info('beforeEach case');
});
afterEach(async function () {
console.info('afterEach case');
await sleep()
});
afterAll(function () {
console.info('afterAll case');
});
const deleteTest = async function (done, testNum, fetchOp, isAudio) {
try {
let fetchAssetResult;
if (isAudio) {
fetchAssetResult = await userfilemgr.getAudioAssets(fetchOp);
} else {
fetchAssetResult = await userfilemgr.getPhotoAssets(fetchOp);
}
let expectCount = 2;
let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchAssetResult, expectCount);
if (!checkAssetCountPass) return;
let asset = await fetchAssetResult.getFirstObject();
fetchAssetResult.close();
await userfilemgr.delete(asset.uri);
let newFetchResult;
if (isAudio) {
newFetchResult = await userfilemgr.getAudioAssets(fetchOp);
} else {
newFetchResult = await userfilemgr.getPhotoAssets(fetchOp);
}
expect(newFetchResult.getCount()).assertEqual(1);
newFetchResult.close();
done();
} catch (error) {
console.info(`${testNum}, failed: ${error}`);
expect(false).assertTrue();
done();
}
}
/**
* @tc.number : SUB_USERFILE_MGR_DELETE_PROMISE_01
* @tc.name : delete
* @tc.desc : delete image
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
*/
it('SUB_USERFILE_MGR_DELETE_PROMISE_01', 2, async function (done) {
let testNum = 'SUB_USERFILE_MGR_DELETE_PROMISE_01';
let currentFetchOp = imageVideoFetchOps(testNum, 'Pictures/deletePro/');
let isAudio = false;
await deleteTest(done, testNum, currentFetchOp, isAudio);
});
/**
* @tc.number : SUB_USERFILE_MGR_DELETE_PROMISE_02
* @tc.name : delete
* @tc.desc : delete video
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
*/
it('SUB_USERFILE_MGR_DELETE_PROMISE_02', 2, async function (done) {
let testNum = 'SUB_USERFILE_MGR_DELETE_PROMISE_02';
let currentFetchOp = imageVideoFetchOps(testNum, 'Videos/deletePro/');
let isAudio = false;
await deleteTest(done, testNum, currentFetchOp, isAudio);
});
/**
* @tc.number : SUB_USERFILE_MGR_DELETE_PROMISE_03
* @tc.name : delete
* @tc.desc : delete audio
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
*/
it('SUB_USERFILE_MGR_DELETE_PROMISE_03', 2, async function (done) {
let testNum = 'SUB_USERFILE_MGR_DELETE_PROMISE_03';
let currentFetchOp = audioFetchOps(testNum, 'Audios/deletePro/');
let isAudio = true;
await deleteTest(done, testNum, currentFetchOp, isAudio);
});
});
}
......@@ -22,7 +22,6 @@ import {
albumFetchOps,
checkPresetsAssets,
checkAssetsCount,
getPermission,
isNum,
} from '../../../../../../common';
......@@ -32,7 +31,6 @@ export default function getAlbumsCallbackTest(abilityContext) {
const userfilemgr = userFileManager.getUserFileMgr(abilityContext);
beforeAll(async function () {
console.info('beforeAll case');
await getPermission();
await checkPresetsAssets(userfilemgr, 'ActsUserFileMgrAlbumJsTest');
});
beforeEach(function () {
......@@ -135,9 +133,9 @@ export default function getAlbumsCallbackTest(abilityContext) {
* @tc.desc : getPhotoAlbums by relativePath && albumName, print all album info
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 1
*/
it('SUB_USERFILE_MGR_GETPHOTOALBUMS_CALLBACK_01', 0, async function (done) {
it('SUB_USERFILE_MGR_GETPHOTOALBUMS_CALLBACK_01', 1, async function (done) {
let testNum = 'SUB_USERFILE_MGR_GETPHOTOALBUMS_CALLBACK_01';
let currentFetchOp = albumFetchOps(testNum, 'Pictures/', 'myAlbum');
let relativePaths = 'Pictures/';
......@@ -150,9 +148,9 @@ export default function getAlbumsCallbackTest(abilityContext) {
* @tc.desc : getPhotoAlbums by invalid
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 3
*/
it('SUB_USERFILE_MGR_GETPHOTOALBUMS_ERRCODE_CALLBACK_01', 0, async function (done) {
it('SUB_USERFILE_MGR_GETPHOTOALBUMS_ERRCODE_CALLBACK_01', 3, async function (done) {
let testNum = 'SUB_USERFILE_MGR_GETPHOTOALBUMS_ERRCODE_CALLBACK_01';
await getPhotoAlbumsErrCodeTest(done, testNum);
});
......
......@@ -115,9 +115,9 @@ export default function getAlbumsPromiseTest(abilityContext) {
* @tc.desc : getPhotoAlbums by relativePath && albumName, print all album info
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 1
*/
it('SUB_USERFILE_MGR_GETPHOTOALBUMS_PROMISE_01', 0, async function (done) {
it('SUB_USERFILE_MGR_GETPHOTOALBUMS_PROMISE_01', 1, async function (done) {
let testNum = 'SUB_USERFILE_MGR_GETPHOTOALBUMS_PROMISE_01';
let currentFetchOp = albumFetchOps(testNum, 'Pictures/', 'myAlbum');
let relativePaths = 'Pictures/';
......@@ -130,9 +130,9 @@ export default function getAlbumsPromiseTest(abilityContext) {
* @tc.desc : getPhotoAlbums by invalid
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 3
*/
it('SUB_USERFILE_MGR_GETPHOTOALBUMS_ERRCODE_PROMISE_01', 0, async function (done) {
it('SUB_USERFILE_MGR_GETPHOTOALBUMS_ERRCODE_PROMISE_01', 3, async function (done) {
let testNum = 'SUB_USERFILE_MGR_GETPHOTOALBUMS_ERRCODE_PROMISE_01';
await getPhotoAlbumsErrCodeTest(done, testNum);
});
......
......@@ -22,6 +22,7 @@ import {
imageVideoFetchOps,
checkPresetsAssets,
checkAssetsCount,
albumFetchOps,
} from '../../../../../../common';
......@@ -71,9 +72,7 @@ export default function onOffReleasePromiseTest(abilityContext) {
const offTest = async (done, testNum, fetchOp, type, newName, isAudio) => {
try {
let count = 0;
userfilemgr.on(type, () => {
count++;
});
userfilemgr.on(type, () => { count++; });
let fetchAssetResult;
if (isAudio) {
fetchAssetResult = await userfilemgr.getAudioAssets(fetchOp);
......@@ -98,15 +97,15 @@ export default function onOffReleasePromiseTest(abilityContext) {
}
/**
* @tc.number : SUB_USERFILE_MGR_ON_PROMISE_01
* @tc.number : SUB_USERFILE_MGR_ON_01
* @tc.name : ON
* @tc.desc : ON image ASSET
* @tc.desc : ON imageChange
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 2
*/
it('SUB_USERFILE_MGR_ON_PROMISE_01', 0, async function (done) {
let testNum = 'SUB_USERFILE_MGR_ON_PROMISE_01';
it('SUB_USERFILE_MGR_ON_01', 2, async function (done) {
let testNum = 'SUB_USERFILE_MGR_ON_01';
let currentFetchOps = imageVideoFetchOps(testNum, 'Pictures/On/');
let type = 'imageChange';
let newName = 'imageChange.jpg';
......@@ -115,15 +114,32 @@ export default function onOffReleasePromiseTest(abilityContext) {
});
/**
* @tc.number : SUB_USERFILE_MGR_ON_PROMISE_02
* @tc.number : SUB_USERFILE_MGR_ON_02
* @tc.name : ON
* @tc.desc : ON audio ASSET
* @tc.desc : ON videoChange
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 2
*/
it('SUB_USERFILE_MGR_ON_PROMISE_02', 0, async function (done) {
let testNum = 'SUB_USERFILE_MGR_ON_PROMISE_02';
it('SUB_USERFILE_MGR_ON_02', 2, async function (done) {
let testNum = 'SUB_USERFILE_MGR_ON_02';
let currentFetchOps = imageVideoFetchOps(testNum, 'Videos/On/');
let type = 'videoChange';
let newName = 'videoChange.mp4';
let isAudio = false;
await onTest(done, testNum, currentFetchOps, type, newName, isAudio)
});
/**
* @tc.number : SUB_USERFILE_MGR_ON_03
* @tc.name : ON
* @tc.desc : ON audioChange
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
*/
it('SUB_USERFILE_MGR_ON_03', 2, async function (done) {
let testNum = 'SUB_USERFILE_MGR_ON_03';
let currentFetchOps = audioFetchOps(testNum, 'Audios/On/');
let type = 'audioChange';
let newName = 'audioChange.mp3';
......@@ -132,32 +148,50 @@ export default function onOffReleasePromiseTest(abilityContext) {
});
/**
* @tc.number : SUB_USERFILE_MGR_ON_PROMISE_03
* @tc.number : SUB_USERFILE_MGR_ON_04
* @tc.name : ON
* @tc.desc : ON video ASSET
* @tc.desc : ON albumChange
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 2
*/
it('SUB_USERFILE_MGR_ON_PROMISE_03', 0, async function (done) {
let testNum = 'SUB_USERFILE_MGR_ON_PROMISE_03';
let currentFetchOps = imageVideoFetchOps(testNum, 'Videos/On/');
let type = 'videoChange';
let newName = 'videoChange.mp4';
let isAudio = false;
await onTest(done, testNum, currentFetchOps, type, newName, isAudio)
it('SUB_USERFILE_MGR_ON_04', 2, async function (done) {
let testNum = 'SUB_USERFILE_MGR_ON_04';
try {
let currentFetchOps = albumFetchOps(testNum, 'Pictures/', 'On');
let type: userFileManager.ChangeEvent = 'albumChange';
let count = 0;
userfilemgr.on(type, () => { count++; });
const fetchAlbumResult = await userfilemgr.getPhotoAlbums(currentFetchOps);
let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchAlbumResult, 1);
if (!checkAssetCountPass) return;
const album = await fetchAlbumResult.getFirstObject();
const oldName = album.albumName;
fetchAlbumResult.close();
album.albumName = type.toString();
await album.commitModify();
await sleep(1000);
expect(count > 0).assertTrue();
album.albumName = oldName;
await album.commitModify();
done();
} catch (error) {
console.info(`${testNum}:: error :${error}`);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number : SUB_USERFILE_MGR_OFF_PROMISE_01
* @tc.number : SUB_USERFILE_MGR_OFF_01
* @tc.name : off
* @tc.desc : off image ASSET
* @tc.desc : off imageChange
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 2
*/
it('SUB_USERFILE_MGR_OFF_PROMISE_01', 0, async function (done) {
let testNum = 'SUB_USERFILE_MGR_OFF_PROMISE_01';
it('SUB_USERFILE_MGR_OFF_01', 2, async function (done) {
let testNum = 'SUB_USERFILE_MGR_OFF_01';
let currentFetchOps = imageVideoFetchOps(testNum, 'Pictures/Off/');
let type = 'imageChange';
let newName = 'imageChange.jpg';
......@@ -166,15 +200,32 @@ export default function onOffReleasePromiseTest(abilityContext) {
});
/**
* @tc.number : SUB_USERFILE_MGR_OFF_PROMISE_02
* @tc.number : SUB_USERFILE_MGR_OFF_02
* @tc.name : off
* @tc.desc : off videoChange
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
*/
it('SUB_USERFILE_MGR_OFF_02', 2, async function (done) {
let testNum = 'SUB_USERFILE_MGR_OFF_02';
let currentFetchOps = imageVideoFetchOps(testNum, 'Videos/Off/');
let type = 'videoChange';
let newName = 'videoChange.mp4';
let isAudio = false;
await offTest(done, testNum,currentFetchOps, type, newName, isAudio)
});
/**
* @tc.number : SUB_USERFILE_MGR_OFF_03
* @tc.name : off
* @tc.desc : off audio ASSET
* @tc.desc : off audioChange
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 2
*/
it('SUB_USERFILE_MGR_OFF_PROMISE_02', 0, async function (done) {
let testNum = 'SUB_USERFILE_MGR_OFF_PROMISE_02';
it('SUB_USERFILE_MGR_OFF_03', 2, async function (done) {
let testNum = 'SUB_USERFILE_MGR_OFF_03';
let currentFetchOps = audioFetchOps(testNum, 'Audios/Off/');
let type = 'audioChange';
let newName = 'audioChange.mp3';
......@@ -183,32 +234,70 @@ export default function onOffReleasePromiseTest(abilityContext) {
});
/**
* @tc.number : SUB_USERFILE_MGR_OFF_PROMISE_03
* @tc.number : SUB_USERFILE_MGR_OFF_04
* @tc.name : off
* @tc.desc : off video ASSET
* @tc.desc : off albumChange
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 2
*/
it('SUB_USERFILE_MGR_OFF_PROMISE_03', 0, async function (done) {
let testNum = 'SUB_USERFILE_MGR_OFF_PROMISE_03';
let currentFetchOps = imageVideoFetchOps(testNum, 'Videos/Off/');
let type = 'videoChange';
let newName = 'videoChange.mp4';
let isAudio = false;
await offTest(done, testNum,currentFetchOps, type, newName, isAudio)
it('SUB_USERFILE_MGR_OFF_04', 2, async function (done) {
let testNum = 'SUB_USERFILE_MGR_OFF_04';
try {
let currentFetchOps = albumFetchOps(testNum, 'Pictures/', 'Off');
let type: userFileManager.ChangeEvent = 'albumChange';
let count = 0;
userfilemgr.on(type, () => { count++; });
const fetchAlbumResult = await userfilemgr.getPhotoAlbums(currentFetchOps);
let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchAlbumResult, 1);
if (!checkAssetCountPass) return;
const album = await fetchAlbumResult.getFirstObject();
fetchAlbumResult.close();
album.albumName = type.toString();
userfilemgr.off(type);
await album.commitModify();
await sleep(1000);
expect(count).assertEqual(0);
done();
} catch (error) {
console.info(`${testNum}:: error :${error}`);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number : SUB_USERFILE_MGR_RELEASE_CALLBACK_01
* @tc.name : release
* @tc.desc : Release MediaLibrary instance
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
*/
it('SUB_USERFILE_MGR_RELEASE_CALLBACK_01', 2, async function (done) {
let testNum = 'SUB_USERFILE_MGR_RELEASE_CALLBACK_01';
try {
userfilemgr.release(() => {
expect(true).assertTrue();
done();
});
} catch (error) {
console.info(`${testNum}:: error :${error}`);
expect(false).assertTrue();
done();
}
});
/**
* @tc.number : SUB_USERFILE_MGR_PROMISE_PROMISE_01
* @tc.number : SUB_USERFILE_MGR_RELEASE_01
* @tc.name : release
* @tc.desc : Release MediaLibrary instance
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 2
*/
it('SUB_USERFILE_MGR_PROMISE_PROMISE_01', 0, async function (done) {
let testNum = 'SUB_USERFILE_MGR_PROMISE_PROMISE_01';
it('SUB_USERFILE_MGR_RELEASE_01', 2, async function (done) {
let testNum = 'SUB_USERFILE_MGR_RELEASE_PROMISE_01';
try {
await userfilemgr.release();
expect(true).assertTrue();
......
......@@ -22,8 +22,6 @@ import fileAssetGetThumbnailCallbackTest from './fileAssetGetThumbnailCallback.t
import fileAssetGetThumbnailPromiseTest from './fileAssetGetThumbnailPromise.test.ets'
import fileAssetOpenCallbackTest from './fileAssetOpenCallback.test.ets'
import fileAssetOpenPromiseTest from './fileAssetOpenPromise.test.ets'
import fileAssetTrashCallbackTest from './fileAssetTrashCallback.test.ets'
import fileAssetTrashPromiseTest from './fileAssetTrashPromise.test.ets'
export default function testsuite(abilityContext) {
fileAssetCommitModifyCallbackTest(abilityContext)
fileAssetCommitModifyPromiseTest(abilityContext)
......@@ -34,6 +32,4 @@ export default function testsuite(abilityContext) {
fileAssetGetThumbnailPromiseTest(abilityContext)
fileAssetOpenCallbackTest(abilityContext)
fileAssetOpenPromiseTest(abilityContext)
fileAssetTrashCallbackTest(abilityContext)
fileAssetTrashPromiseTest(abilityContext)
}
......@@ -15,6 +15,7 @@
import userFileManager from '@ohos.filemanagement.userFileManager';
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index';
import dataSharePredicates from '@ohos.data.dataSharePredicates';
import {
sleep,
......@@ -50,15 +51,18 @@ export default function fileAssetCommitModifyCallbackTest(abilityContext) {
const checkCommitModify = async function (done, testNum, fetchOp, prop, val, isAudio) {
try {
let fetchAssetResult;
let fileKey;
if (isAudio) {
fetchAssetResult = await userfilemgr.getAudioAssets(fetchOp);
fileKey = userFileManager.AudioKey;
} else {
fetchAssetResult = await userfilemgr.getPhotoAssets(fetchOp);
fileKey = userFileManager.ImageVideoKey;
}
let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchAssetResult, 1);
if (!checkAssetCountPass) return;
const asset = await fetchAssetResult.getFirstObject();
const oldVal = asset.get(prop);
fetchAssetResult.close();
asset.set(prop, val);
await asset.commitModify(async (err) => {
if (err) {
......@@ -67,9 +71,25 @@ export default function fileAssetCommitModifyCallbackTest(abilityContext) {
done();
return;
}
asset.set(prop, oldVal.toString());
await asset.commitModify();
fetchAssetResult.close();
let predicates = new dataSharePredicates.DataSharePredicates();
predicates.equalTo(fileKey.URI, asset.get(fileKey.URI));
let ops = {
fetchColumns: [],
predicates: predicates
};
let newResult;
if (isAudio) {
newResult = await userfilemgr.getAudioAssets(ops);
} else {
newResult = await userfilemgr.getPhotoAssets(ops);
}
let checkAssetCountPass = await checkAssetsCount(done, testNum, newResult, 1);
if (!checkAssetCountPass) return;
const newAsset = await newResult.getFirstObject();
console.info(`${testNum} newAsset : ${newAsset}`)
newResult.close();
expect(newAsset.get(fileKey.DISPLAY_NAME)).assertEqual(val);
console.info(`${testNum} DISPLAY_NAME : ${newAsset.get(fileKey.DISPLAY_NAME)}`)
done();
});
} catch (error) {
......@@ -82,16 +102,16 @@ export default function fileAssetCommitModifyCallbackTest(abilityContext) {
/**
* @tc.number : SUB_USERFILE_MGR_FILEASSET_COMMITMODIFY_CALLBACK_01
* @tc.name : commitModify
* @tc.desc : image asset modify displayName
* @tc.desc : image asset modify title
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 2
*/
it('SUB_USERFILE_MGR_FILEASSET_COMMITMODIFY_CALLBACK_01', 0, async function (done) {
it('SUB_USERFILE_MGR_FILEASSET_COMMITMODIFY_CALLBACK_01', 2, async function (done) {
let testNum = 'SUB_USERFILE_MGR_FILEASSET_COMMITMODIFY_CALLBACK_01';
let fetchOp = imageVideoNameFetchOps(testNum, 'Pictures/ModifyCb/', '01.jpg');
let prop = 'display_name';
let val = IMAGE_TYPE.toString() + '.jpg';
let prop = 'title';
let val = IMAGE_TYPE.toString();
let isAudio = false;
await checkCommitModify(done, testNum, fetchOp, prop, val, isAudio);
});
......@@ -99,34 +119,34 @@ export default function fileAssetCommitModifyCallbackTest(abilityContext) {
/**
* @tc.number : SUB_USERFILE_MGR_FILEASSET_COMMITMODIFY_CALLBACK_02
* @tc.name : commitModify
* @tc.desc : audio asset modify displayName
* @tc.desc : video asset modify title
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 2
*/
it('SUB_USERFILE_MGR_FILEASSET_COMMITMODIFY_CALLBACK_02', 0, async function (done) {
it('SUB_USERFILE_MGR_FILEASSET_COMMITMODIFY_CALLBACK_02', 2, async function (done) {
let testNum = 'SUB_USERFILE_MGR_FILEASSET_COMMITMODIFY_CALLBACK_02';
let fetchOp = audioNameFetchOps(testNum, 'Audios/ModifyCb/', '01.mp3');
let prop = 'display_name';
let val = AUDIO_TYPE.toString() + '.mp3';
let isAudio = true;
let fetchOp = imageVideoNameFetchOps(testNum, 'Videos/ModifyCb/', '01.mp4');
let prop = 'title';
let val = VIDEO_TYPE.toString();
let isAudio = false;
await checkCommitModify(done, testNum, fetchOp, prop, val, isAudio);
});
/**
* @tc.number : SUB_USERFILE_MGR_FILEASSET_COMMITMODIFY_CALLBACK_03
* @tc.name : commitModify
* @tc.desc : video asset modify displayName
* @tc.desc : audio asset modify title
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 2
*/
it('SUB_USERFILE_MGR_FILEASSET_COMMITMODIFY_CALLBACK_03', 0, async function (done) {
it('SUB_USERFILE_MGR_FILEASSET_COMMITMODIFY_CALLBACK_03', 2, async function (done) {
let testNum = 'SUB_USERFILE_MGR_FILEASSET_COMMITMODIFY_CALLBACK_03';
let fetchOp = imageVideoNameFetchOps(testNum, 'Videos/ModifyCb/', '01.mp4');
let prop = 'display_name';
let val = VIDEO_TYPE.toString() + '.mp4';
let isAudio = false;
let fetchOp = audioNameFetchOps(testNum, 'Audios/ModifyCb/', '01.mp3');
let prop = 'title';
let val = AUDIO_TYPE.toString();
let isAudio = true;
await checkCommitModify(done, testNum, fetchOp, prop, val, isAudio);
});
});
......
......@@ -15,6 +15,7 @@
import userFileManager from '@ohos.filemanagement.userFileManager';
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index';
import dataSharePredicates from '@ohos.data.dataSharePredicates';
import {
sleep,
......@@ -48,20 +49,39 @@ export default function fileAssetCommitModifyPromiseTest(abilityContext) {
const checkCommitModify = async function (done, testNum, fetchOp, prop, val, isAudio) {
try {
let fetchAssetResult;
let fileKey;
if (isAudio) {
fetchAssetResult = await userfilemgr.getAudioAssets(fetchOp);
fileKey.userFileManager.AudioKey;
} else {
fetchAssetResult = await userfilemgr.getPhotoAssets(fetchOp);
fileKey = userFileManager.ImageVideoKey;
}
let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchAssetResult, 1);
if (!checkAssetCountPass) return;
const asset = await fetchAssetResult.getFirstObject();
const oldVal = asset.get(prop)
fetchAssetResult.close();
asset.set(prop, val);
await asset.commitModify();
asset.set(prop, oldVal.toString());
await asset.commitModify();
fetchAssetResult.close();
let predicates = new dataSharePredicates.DataSharePredicates();
predicates.equalTo(fileKey.URI, asset.get(fileKey.URI));
let ops = {
fetchColumns: [],
predicates: predicates
};
let newResult;
if (isAudio) {
newResult = await userfilemgr.getAudioAssets(ops);
} else {
newResult = await userfilemgr.getPhotoAssets(ops);
}
checkAssetCountPass = await checkAssetsCount(done, testNum, newResult, 1);
if (!checkAssetCountPass) return;
const newAsset = await newResult.getFirstObject();
console.info(`${testNum} newAsset : ${newAsset}`)
newResult.close();
expect(newAsset.get(fileKey.DISPLAY_NAME)).assertEqual(val);
console.info(`${testNum} DISPLAY_NAME : ${newAsset.get(fileKey.DISPLAY_NAME)}`)
done();
} catch (error) {
console.info(`${testNum} error : ${error}`);
......@@ -73,16 +93,16 @@ export default function fileAssetCommitModifyPromiseTest(abilityContext) {
/**
* @tc.number : SUB_USERFILE_MGR_FILEASSET_COMMITMODIFY_PROMISE_01
* @tc.name : commitModify
* @tc.desc : image asset modify displayName
* @tc.desc : image asset modify title
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 2
*/
it('SUB_USERFILE_MGR_FILEASSET_COMMITMODIFY_PROMISE_01', 0, async function (done) {
it('SUB_USERFILE_MGR_FILEASSET_COMMITMODIFY_PROMISE_01', 2, async function (done) {
let testNum = 'SUB_USERFILE_MGR_FILEASSET_COMMITMODIFY_PROMISE_01';
let fetchOp = imageVideoNameFetchOps(testNum, 'Pictures/ModifyPro/', '01.jpg');
let prop = 'display_name';
let val = IMAGE_TYPE.toString() + '.jpg';
let prop = 'title';
let val = IMAGE_TYPE.toString();
let isAudio = false;
await checkCommitModify(done, testNum, fetchOp, prop, val, isAudio);
});
......@@ -90,34 +110,34 @@ export default function fileAssetCommitModifyPromiseTest(abilityContext) {
/**
* @tc.number : SUB_USERFILE_MGR_FILEASSET_COMMITMODIFY_PROMISE_02
* @tc.name : commitModify
* @tc.desc : audio asset modify displayName
* @tc.desc : video asset modify title
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 2
*/
it('SUB_USERFILE_MGR_FILEASSET_COMMITMODIFY_PROMISE_02', 0, async function (done) {
it('SUB_USERFILE_MGR_FILEASSET_COMMITMODIFY_PROMISE_02', 2, async function (done) {
let testNum = 'SUB_USERFILE_MGR_FILEASSET_COMMITMODIFY_PROMISE_02';
let fetchOp = audioNameFetchOps(testNum, 'Audios/ModifyPro/', '01.mp3');
let prop = 'display_name';
let val = AUDIO_TYPE.toString() + '.mp3';
let isAudio = true;
let fetchOp = imageVideoNameFetchOps(testNum, 'Videos/ModifyPro/', '01.mp4');
let prop = 'title';
let val = VIDEO_TYPE.toString();
let isAudio = false;
await checkCommitModify(done, testNum, fetchOp, prop, val, isAudio);
});
/**
* @tc.number : SUB_USERFILE_MGR_FILEASSET_COMMITMODIFY_PROMISE_03
* @tc.name : commitModify
* @tc.desc : video asset modify displayName
* @tc.desc : audio asset modify title
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 2
*/
it('SUB_USERFILE_MGR_FILEASSET_COMMITMODIFY_PROMISE_03', 0, async function (done) {
it('SUB_USERFILE_MGR_FILEASSET_COMMITMODIFY_PROMISE_03', 2, async function (done) {
let testNum = 'SUB_USERFILE_MGR_FILEASSET_COMMITMODIFY_PROMISE_03';
let fetchOp = imageVideoNameFetchOps(testNum, 'Videos/ModifyPro/', '01.mp4');
let prop = 'display_name';
let val = VIDEO_TYPE.toString() + '.mp4';
let isAudio = false;
let fetchOp = audioNameFetchOps(testNum, 'Audios/ModifyPro/', '01.mp3');
let prop = 'title';
let val = AUDIO_TYPE.toString();
let isAudio = true;
await checkCommitModify(done, testNum, fetchOp, prop, val, isAudio);
});
});
......
......@@ -54,6 +54,7 @@ export default function fileAssetFavoriteCallbackTest(abilityContext) {
let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchAssetResult, 1);
if (!checkAssetCountPass) return;
let asset = await fetchAssetResult.getFirstObject();
console.info(`${testNum} asset: ${asset}`);
asset.isFavorite(async (err, isFavorite) => {
if (err) {
expect(false).assertTrue();
......@@ -82,8 +83,6 @@ export default function fileAssetFavoriteCallbackTest(abilityContext) {
let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchAssetResult, 1);
if (!checkAssetCountPass) return;
const asset = await fetchAssetResult.getFirstObject();
let isFavorite = await asset.isFavorite();
console.info(`${testNum} isFavorite: ${isFavorite}`);
asset.favorite(true, async (err) => {
if(err) {
console.info(`${testNum} failed err: ${err}`);
......@@ -140,9 +139,9 @@ export default function fileAssetFavoriteCallbackTest(abilityContext) {
* @tc.desc : isFavorite(image) result false
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 2
*/
it('SUB_USERFILE_MGR_FILEASSET_FAVORITE_CALLBACK_01_001', 0, async function (done) {
it('SUB_USERFILE_MGR_FILEASSET_FAVORITE_CALLBACK_01_001', 2, async function (done) {
let testNum = 'SUB_USERFILE_MGR_FILEASSET_FAVORITE_CALLBACK_01_001';
let currentFetchOp = imageVideoNameFetchOps(testNum, 'Pictures/FavCb/', '01.jpg');
let isAudio = false;
......@@ -155,9 +154,9 @@ export default function fileAssetFavoriteCallbackTest(abilityContext) {
* @tc.desc : favorite(image) by true
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 2
*/
it('SUB_USERFILE_MGR_FILEASSET_FAVORITE_CALLBACK_01_002', 0, async function (done) {
it('SUB_USERFILE_MGR_FILEASSET_FAVORITE_CALLBACK_01_002', 2, async function (done) {
let testNum = 'SUB_USERFILE_MGR_FILEASSET_FAVORITE_CALLBACK_01_002';
let currentFetchOp = imageVideoNameFetchOps(testNum, 'Pictures/FavCb/', '02.jpg');
let isAudio = false;
......@@ -170,9 +169,9 @@ export default function fileAssetFavoriteCallbackTest(abilityContext) {
* @tc.desc : favorite(image) by false
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 2
*/
it('SUB_USERFILE_MGR_FILEASSET_FAVORITE_CALLBACK_01_003', 0, async function (done) {
it('SUB_USERFILE_MGR_FILEASSET_FAVORITE_CALLBACK_01_003', 2, async function (done) {
let testNum = 'SUB_USERFILE_MGR_FILEASSET_FAVORITE_CALLBACK_01_003';
let currentFetchOp = imageVideoNameFetchOps(testNum, 'Pictures/FavCb/', '03.jpg');
let isAudio = false;
......@@ -182,90 +181,90 @@ export default function fileAssetFavoriteCallbackTest(abilityContext) {
/**
* @tc.number : SUB_USERFILE_MGR_FILEASSET_FAVORITE_CALLBACK_02_001
* @tc.name : isFavorite
* @tc.desc : isFavorite(audio) result false
* @tc.desc : isFavorite(video) result false
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 2
*/
it('SUB_USERFILE_MGR_FILEASSET_FAVORITE_CALLBACK_02_001', 0, async function (done) {
it('SUB_USERFILE_MGR_FILEASSET_FAVORITE_CALLBACK_02_001', 2, async function (done) {
let testNum = 'SUB_USERFILE_MGR_FILEASSET_FAVORITE_CALLBACK_02_001';
let currentFetchOp = audioNameFetchOps(testNum, 'Audios/FavCb/', '01.mp3');
let isAudio = true;
let currentFetchOp = imageVideoNameFetchOps(testNum, 'Videos/FavCb/', '01.mp4');
let isAudio = false;
await favoriteDefaultState(done, testNum, currentFetchOp, isAudio);
});
/**
* @tc.number : SUB_USERFILE_MGR_FILEASSET_FAVORITE_CALLBACK_02_002
* @tc.name : favorite
* @tc.desc : favorite(audio) by true
* @tc.desc : favorite(video) by true
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 2
*/
it('SUB_USERFILE_MGR_FILEASSET_FAVORITE_CALLBACK_02_002', 0, async function (done) {
it('SUB_USERFILE_MGR_FILEASSET_FAVORITE_CALLBACK_02_002', 2, async function (done) {
let testNum = 'SUB_USERFILE_MGR_FILEASSET_FAVORITE_CALLBACK_02_002';
let currentFetchOp = audioNameFetchOps(testNum, 'Audios/FavCb/', '02.mp3');
let isAudio = true;
let currentFetchOp = imageVideoNameFetchOps(testNum, 'Videos/FavCb/', '02.mp4');
let isAudio = false;
await favoriteByTrue(done, testNum, currentFetchOp, isAudio);
});
/**
* @tc.number : SUB_USERFILE_MGR_FILEASSET_FAVORITE_CALLBACK_02_003
* @tc.name : favorite
* @tc.desc : favorite(audio) by false
* @tc.desc : favorite(video) by false
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 2
*/
it('SUB_USERFILE_MGR_FILEASSET_FAVORITE_CALLBACK_02_003', 0, async function (done) {
it('SUB_USERFILE_MGR_FILEASSET_FAVORITE_CALLBACK_02_003', 2, async function (done) {
let testNum = 'SUB_USERFILE_MGR_FILEASSET_FAVORITE_CALLBACK_02_003';
let currentFetchOp = audioNameFetchOps(testNum, 'Audios/FavCb/', '03.mp3');
let isAudio = true;
let currentFetchOp = imageVideoNameFetchOps(testNum, 'Videos/FavCb/', '03.mp4');
let isAudio = false;
await favoriteByFalse(done, testNum, currentFetchOp, isAudio);
});
/**
* @tc.number : SUB_USERFILE_MGR_FILEASSET_FAVORITE_CALLBACK_03_001
* @tc.name : isFavorite
* @tc.desc : isFavorite(video) result false
* @tc.desc : isFavorite(audio) result false
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 2
*/
it('SUB_USERFILE_MGR_FILEASSET_FAVORITE_CALLBACK_03_001', 0, async function (done) {
it('SUB_USERFILE_MGR_FILEASSET_FAVORITE_CALLBACK_03_001', 2, async function (done) {
let testNum = 'SUB_USERFILE_MGR_FILEASSET_FAVORITE_CALLBACK_03_001';
let currentFetchOp = imageVideoNameFetchOps(testNum, 'Videos/FavCb/', '01.mp4');
let isAudio = false;
let currentFetchOp = audioNameFetchOps(testNum, 'Audios/FavCb/', '01.mp3');
let isAudio = true;
await favoriteDefaultState(done, testNum, currentFetchOp, isAudio);
});
/**
* @tc.number : SUB_USERFILE_MGR_FILEASSET_FAVORITE_CALLBACK_03_002
* @tc.name : favorite
* @tc.desc : favorite(video) by true
* @tc.desc : favorite(audio) by true
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 2
*/
it('SUB_USERFILE_MGR_FILEASSET_FAVORITE_CALLBACK_03_002', 0, async function (done) {
it('SUB_USERFILE_MGR_FILEASSET_FAVORITE_CALLBACK_03_002', 2, async function (done) {
let testNum = 'SUB_USERFILE_MGR_FILEASSET_FAVORITE_CALLBACK_03_002';
let currentFetchOp = imageVideoNameFetchOps(testNum, 'Videos/FavCb/', '02.mp4');
let isAudio = false;
let currentFetchOp = audioNameFetchOps(testNum, 'Audios/FavCb/', '02.mp3');
let isAudio = true;
await favoriteByTrue(done, testNum, currentFetchOp, isAudio);
});
/**
* @tc.number : SUB_USERFILE_MGR_FILEASSET_FAVORITE_CALLBACK_03_003
* @tc.name : favorite
* @tc.desc : favorite(video) by false
* @tc.desc : favorite(audio) by false
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 2
*/
it('SUB_USERFILE_MGR_FILEASSET_FAVORITE_CALLBACK_03_003', 0, async function (done) {
it('SUB_USERFILE_MGR_FILEASSET_FAVORITE_CALLBACK_03_003', 2, async function (done) {
let testNum = 'SUB_USERFILE_MGR_FILEASSET_FAVORITE_CALLBACK_03_003';
let currentFetchOp = imageVideoNameFetchOps(testNum, 'Videos/FavCb/', '03.mp4');
let isAudio = false;
let currentFetchOp = audioNameFetchOps(testNum, 'Audios/FavCb/', '03.mp3');
let isAudio = true;
await favoriteByFalse(done, testNum, currentFetchOp, isAudio);
});
});
......
......@@ -114,9 +114,9 @@ export default function fileAssetFavoritePromiseTest(abilityContext) {
* @tc.desc : isFavorite(image) result false
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 2
*/
it('SUB_USERFILE_MGR_FILEASSET_FAVORITE_PROMISE_01_001', 0, async function (done) {
it('SUB_USERFILE_MGR_FILEASSET_FAVORITE_PROMISE_01_001', 2, async function (done) {
let testNum = 'SUB_USERFILE_MGR_FILEASSET_FAVORITE_PROMISE_01_001';
let currentFetchOp = imageVideoNameFetchOps(testNum, 'Pictures/FavPro/', '01.jpg');
let isAudio = false;
......@@ -129,9 +129,9 @@ export default function fileAssetFavoritePromiseTest(abilityContext) {
* @tc.desc : favorite(image) by true
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 2
*/
it('SUB_USERFILE_MGR_FILEASSET_FAVORITE_PROMISE_01_002', 0, async function (done) {
it('SUB_USERFILE_MGR_FILEASSET_FAVORITE_PROMISE_01_002', 2, async function (done) {
let testNum = 'SUB_USERFILE_MGR_FILEASSET_FAVORITE_PROMISE_01_002';
let currentFetchOp = imageVideoNameFetchOps(testNum, 'Pictures/FavPro/', '02.jpg');
let isAudio = false;
......@@ -144,9 +144,9 @@ export default function fileAssetFavoritePromiseTest(abilityContext) {
* @tc.desc : favorite(image) by false
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 2
*/
it('SUB_USERFILE_MGR_FILEASSET_FAVORITE_PROMISE_01_003', 0, async function (done) {
it('SUB_USERFILE_MGR_FILEASSET_FAVORITE_PROMISE_01_003', 2, async function (done) {
let testNum = 'SUB_USERFILE_MGR_FILEASSET_FAVORITE_PROMISE_01_003';
let currentFetchOp = imageVideoNameFetchOps(testNum, 'Pictures/FavPro/', '03.jpg');
let isAudio = false;
......@@ -156,90 +156,90 @@ export default function fileAssetFavoritePromiseTest(abilityContext) {
/**
* @tc.number : SUB_USERFILE_MGR_FILEASSET_FAVORITE_PROMISE_02_001
* @tc.name : isFavorite
* @tc.desc : isFavorite(audio) result false
* @tc.desc : isFavorite(video) result false
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 2
*/
it('SUB_USERFILE_MGR_FILEASSET_FAVORITE_PROMISE_02_001', 0, async function (done) {
it('SUB_USERFILE_MGR_FILEASSET_FAVORITE_PROMISE_02_001', 2, async function (done) {
let testNum = 'SUB_USERFILE_MGR_FILEASSET_FAVORITE_PROMISE_02_001';
let currentFetchOp = audioNameFetchOps(testNum, 'Audios/FavPro/', '01.mp3');
let isAudio = true;
let currentFetchOp = imageVideoNameFetchOps(testNum, 'Videos/FavPro/', '01.mp4');
let isAudio = false;
await favoriteDefaultState(done, testNum, currentFetchOp, isAudio);
});
/**
* @tc.number : SUB_USERFILE_MGR_FILEASSET_FAVORITE_PROMISE_02_002
* @tc.name : favorite
* @tc.desc : favorite(audio) by true
* @tc.desc : favorite(video) by true
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 2
*/
it('SUB_USERFILE_MGR_FILEASSET_FAVORITE_PROMISE_02_002', 0, async function (done) {
it('SUB_USERFILE_MGR_FILEASSET_FAVORITE_PROMISE_02_002', 2, async function (done) {
let testNum = 'SUB_USERFILE_MGR_FILEASSET_FAVORITE_PROMISE_02_002';
let currentFetchOp = audioNameFetchOps(testNum, 'Audios/FavPro/', '02.mp3');
let isAudio = true;
let currentFetchOp = imageVideoNameFetchOps(testNum, 'Videos/FavPro/', '02.mp4');
let isAudio = false;
await favoriteByTrue(done, testNum, currentFetchOp, isAudio);
});
/**
* @tc.number : SUB_USERFILE_MGR_FILEASSET_FAVORITE_PROMISE_03_003
* @tc.number : SUB_USERFILE_MGR_FILEASSET_FAVORITE_PROMISE_02_003
* @tc.name : favorite
* @tc.desc : favorite(audio) by false
* @tc.desc : favorite(video) by false
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 2
*/
it('SUB_USERFILE_MGR_FILEASSET_FAVORITE_PROMISE_03_003', 0, async function (done) {
let testNum = 'SUB_USERFILE_MGR_FILEASSET_FAVORITE_PROMISE_03_003';
let currentFetchOp = audioNameFetchOps(testNum, 'Audios/FavPro/', '03.mp3');
let isAudio = true;
it('SUB_USERFILE_MGR_FILEASSET_FAVORITE_PROMISE_02_003', 2, async function (done) {
let testNum = 'SUB_USERFILE_MGR_FILEASSET_FAVORITE_PROMISE_02_003';
let currentFetchOp = imageVideoNameFetchOps(testNum, 'Videos/FavPro/', '03.mp4');
let isAudio = false;
await favoriteByFalse(done, testNum, currentFetchOp, isAudio);
});
/**
* @tc.number : SUB_USERFILE_MGR_FILEASSET_FAVORITE_PROMISE_03_001
* @tc.name : isFavorite
* @tc.desc : isFavorite(video) result false
* @tc.desc : isFavorite(audio) result false
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 2
*/
it('SUB_USERFILE_MGR_FILEASSET_FAVORITE_PROMISE_03_001', 0, async function (done) {
it('SUB_USERFILE_MGR_FILEASSET_FAVORITE_PROMISE_03_001', 2, async function (done) {
let testNum = 'SUB_USERFILE_MGR_FILEASSET_FAVORITE_PROMISE_03_001';
let currentFetchOp = imageVideoNameFetchOps(testNum, 'Videos/FavPro/', '01.mp4');
let isAudio = false;
let currentFetchOp = audioNameFetchOps(testNum, 'Audios/FavPro/', '01.mp3');
let isAudio = true;
await favoriteDefaultState(done, testNum, currentFetchOp, isAudio);
});
/**
* @tc.number : SUB_USERFILE_MGR_FILEASSET_FAVORITE_PROMISE_03_002
* @tc.name : favorite
* @tc.desc : favorite(video) by true
* @tc.desc : favorite(audio) by true
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 2
*/
it('SUB_USERFILE_MGR_FILEASSET_FAVORITE_PROMISE_03_002', 0, async function (done) {
it('SUB_USERFILE_MGR_FILEASSET_FAVORITE_PROMISE_03_002', 2, async function (done) {
let testNum = 'SUB_USERFILE_MGR_FILEASSET_FAVORITE_PROMISE_03_002';
let currentFetchOp = imageVideoNameFetchOps(testNum, 'Videos/FavPro/', '02.mp4');
let isAudio = false;
let currentFetchOp = audioNameFetchOps(testNum, 'Audios/FavPro/', '02.mp3');
let isAudio = true;
await favoriteByTrue(done, testNum, currentFetchOp, isAudio);
});
/**
* @tc.number : SUB_USERFILE_MGR_FILEASSET_FAVORITE_PROMISE_03_003
* @tc.name : favorite
* @tc.desc : favorite(video) by false
* @tc.desc : favorite(audio) by false
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 2
*/
it('SUB_USERFILE_MGR_FILEASSET_FAVORITE_PROMISE_03_003', 0, async function (done) {
it('SUB_USERFILE_MGR_FILEASSET_FAVORITE_PROMISE_03_003', 2, async function (done) {
let testNum = 'SUB_USERFILE_MGR_FILEASSET_FAVORITE_PROMISE_03_003';
let currentFetchOp = imageVideoNameFetchOps(testNum, 'Videos/FavPro/', '03.mp4');
let isAudio = false;
let currentFetchOp = audioNameFetchOps(testNum, 'Audios/FavPro/', '03.mp3');
let isAudio = true;
await favoriteByFalse(done, testNum, currentFetchOp, isAudio);
});
});
......
......@@ -44,7 +44,7 @@ export default function fileAssetFileKeyTest(abilityContext) {
console.info('afterAll case');
});
const AUDIOKEY = userFileManager.AudioKey;
const AudioKey = userFileManager.AudioKey;
const ImageVideoKey = userFileManager.ImageVideoKey;
const AlbumKey = userFileManager.AlbumKey;
......@@ -160,45 +160,76 @@ export default function fileAssetFileKeyTest(abilityContext) {
}
}
/**
* @tc.number : SUB_USERFILE_MGR_GETPHOTOALBUMSBYKEY_01
* @tc.name : AlbumKey
* @tc.desc : AlbumKey.URI
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
*/
it('SUB_USERFILE_MGR_GETPHOTOALBUMSBYKEY_01', 2, async function (done) {
let testNum = 'SUB_USERFILE_MGR_GETPHOTOALBUMSBYKEY_01';
let type = 'albumUri';
let fileKey = AlbumKey.URI;
await getAlbumsByKey(done, testNum, type, fileKey);
})
/**
* @tc.number : SUB_USERFILE_MGR_GETPHOTOALBUMSBYKEY_02
* @tc.name : AlbumKey
* @tc.desc : AlbumKey.ALBUM_NAME
* @tc.desc : AlbumKey.FILE_TYPE
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 2
*/
it('SUB_USERFILE_MGR_GETPHOTOALBUMSBYKEY_02', 0, async function (done) {
it('SUB_USERFILE_MGR_GETPHOTOALBUMSBYKEY_02', 2, async function (done) {
let testNum = 'SUB_USERFILE_MGR_GETPHOTOALBUMSBYKEY_02';
let type = 'fileType';
let fileKey = AlbumKey.FILE_TYPE;
await getAlbumsByKey(done, testNum, type, fileKey);
})
/**
* @tc.number : SUB_USERFILE_MGR_GETPHOTOALBUMSBYKEY_03
* @tc.name : AlbumKey
* @tc.desc : AlbumKey.ALBUM_NAME
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
*/
it('SUB_USERFILE_MGR_GETPHOTOALBUMSBYKEY_03', 2, async function (done) {
let testNum = 'SUB_USERFILE_MGR_GETPHOTOALBUMSBYKEY_03';
let type = 'albumName';
let fileKey = AlbumKey.ALBUM_NAME;
await getAlbumsByKey(done, testNum, type, fileKey);
})
/**
* @tc.number : SUB_USERFILE_MGR_GETPHOTOALBUMSBYKEY_03
* @tc.number : SUB_USERFILE_MGR_GETPHOTOALBUMSBYKEY_04
* @tc.name : AlbumKey
* @tc.desc : AlbumKey.DATE_ADDED
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 2
*/
it('SUB_USERFILE_MGR_GETPHOTOALBUMSBYKEY_03', 0, async function (done) {
let testNum = 'SUB_USERFILE_MGR_GETPHOTOALBUMSBYKEY_03';
it('SUB_USERFILE_MGR_GETPHOTOALBUMSBYKEY_04', 2, async function (done) {
let testNum = 'SUB_USERFILE_MGR_GETPHOTOALBUMSBYKEY_04';
let type = 'dateAdded';
let fileKey = AlbumKey.DATE_ADDED;
await getAlbumsByKey(done, testNum, type, fileKey);
});
/**
* @tc.number : SUB_USERFILE_MGR_GETPHOTOALBUMSBYKEY_04
* @tc.number : SUB_USERFILE_MGR_GETPHOTOALBUMSBYKEY_05
* @tc.name : AlbumKey
* @tc.desc : AlbumKey.DATE_MODIFIED
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 2
*/
it('SUB_USERFILE_MGR_GETPHOTOALBUMSBYKEY_04', 0, async function (done) {
let testNum = 'SUB_USERFILE_MGR_GETPHOTOALBUMSBYKEY_04';
it('SUB_USERFILE_MGR_GETPHOTOALBUMSBYKEY_05', 2, async function (done) {
let testNum = 'SUB_USERFILE_MGR_GETPHOTOALBUMSBYKEY_05';
let type = 'dateModified';
let fileKey = AlbumKey.DATE_MODIFIED;
await getAlbumsByKey(done, testNum, type, fileKey);
......@@ -206,15 +237,29 @@ export default function fileAssetFileKeyTest(abilityContext) {
//------------------------------------------------------------------------------
/**
* @tc.number : SUB_USERFILE_MGR_GETPHOTOASSETSBYKEY_01
* @tc.name : ImageVideoKey
* @tc.desc : ImageVideoKey.URI
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
*/
it('SUB_USERFILE_MGR_GETPHOTOASSETSBYKEY_01', 2, async function (done) {
let testNum = 'SUB_USERFILE_MGR_GETPHOTOASSETSBYKEY_01';
let fileKey = ImageVideoKey.URI;
await getPhotoAssetsByKey(done, testNum, fileKey);
});
/**
* @tc.number : SUB_USERFILE_MGR_GETPHOTOASSETSBYKEY_02
* @tc.name : ImageVideoKey
* @tc.desc : ImageVideoKey.FILE_TYPE
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 2
*/
it('SUB_USERFILE_MGR_GETPHOTOASSETSBYKEY_02', 0, async function (done) {
it('SUB_USERFILE_MGR_GETPHOTOASSETSBYKEY_02', 2, async function (done) {
let testNum = 'SUB_USERFILE_MGR_GETPHOTOASSETSBYKEY_02';
let fileKey = ImageVideoKey.FILE_TYPE;
await getPhotoAssetsByKey(done, testNum, fileKey);
......@@ -226,9 +271,9 @@ export default function fileAssetFileKeyTest(abilityContext) {
* @tc.desc : ImageVideoKey.DISPLAY_NAME
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 2
*/
it('SUB_USERFILE_MGR_GETPHOTOASSETSBYKEY_03', 0, async function (done) {
it('SUB_USERFILE_MGR_GETPHOTOASSETSBYKEY_03', 2, async function (done) {
let testNum = 'SUB_USERFILE_MGR_GETPHOTOASSETSBYKEY_03';
let fileKey = ImageVideoKey.DISPLAY_NAME;
await getPhotoAssetsByKey(done, testNum, fileKey);
......@@ -240,9 +285,9 @@ export default function fileAssetFileKeyTest(abilityContext) {
* @tc.desc : ImageVideoKey.DATE_ADDED
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 2
*/
it('SUB_USERFILE_MGR_GETPHOTOASSETSBYKEY_04', 0, async function (done) {
it('SUB_USERFILE_MGR_GETPHOTOASSETSBYKEY_04', 2, async function (done) {
let testNum = 'SUB_USERFILE_MGR_GETPHOTOASSETSBYKEY_04';
let fileKey = ImageVideoKey.DATE_ADDED;
await getPhotoAssetsByKey(done, testNum, fileKey);
......@@ -254,9 +299,9 @@ export default function fileAssetFileKeyTest(abilityContext) {
* @tc.desc : ImageVideoKey.DATE_MODIFIED
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 2
*/
it('SUB_USERFILE_MGR_GETPHOTOASSETSBYKEY_05', 0, async function (done) {
it('SUB_USERFILE_MGR_GETPHOTOASSETSBYKEY_05', 2, async function (done) {
let testNum = 'SUB_USERFILE_MGR_GETPHOTOASSETSBYKEY_05';
let fileKey = ImageVideoKey.DATE_MODIFIED;
await getPhotoAssetsByKey(done, testNum, fileKey);
......@@ -268,9 +313,9 @@ export default function fileAssetFileKeyTest(abilityContext) {
* @tc.desc : ImageVideoKey.TITLE
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 2
*/
it('SUB_USERFILE_MGR_GETPHOTOASSETSBYKEY_06', 0, async function (done) {
it('SUB_USERFILE_MGR_GETPHOTOASSETSBYKEY_06', 2, async function (done) {
let testNum = 'SUB_USERFILE_MGR_GETPHOTOASSETSBYKEY_06';
let fileKey = ImageVideoKey.TITLE;
await getPhotoAssetsByKey(done, testNum, fileKey);
......@@ -282,9 +327,9 @@ export default function fileAssetFileKeyTest(abilityContext) {
* @tc.desc : ImageVideoKey.DURATION
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 2
*/
it('SUB_USERFILE_MGR_GETPHOTOASSETSBYKEY_07', 0, async function (done) {
it('SUB_USERFILE_MGR_GETPHOTOASSETSBYKEY_07', 2, async function (done) {
let testNum = 'SUB_USERFILE_MGR_GETPHOTOASSETSBYKEY_07';
let fileKey = ImageVideoKey.DURATION;
await getPhotoAssetsByKey(done, testNum, fileKey);
......@@ -296,9 +341,9 @@ export default function fileAssetFileKeyTest(abilityContext) {
* @tc.desc : ImageVideoKey.WIDTH
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 2
*/
it('SUB_USERFILE_MGR_GETPHOTOASSETSBYKEY_08', 0, async function (done) {
it('SUB_USERFILE_MGR_GETPHOTOASSETSBYKEY_08', 2, async function (done) {
let testNum = 'SUB_USERFILE_MGR_GETPHOTOASSETSBYKEY_08';
let fileKey = ImageVideoKey.WIDTH;
await getPhotoAssetsByKey(done, testNum, fileKey);
......@@ -310,9 +355,9 @@ export default function fileAssetFileKeyTest(abilityContext) {
* @tc.desc : ImageVideoKey.HEIGHT
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 2
*/
it('SUB_USERFILE_MGR_GETPHOTOASSETSBYKEY_09', 0, async function (done) {
it('SUB_USERFILE_MGR_GETPHOTOASSETSBYKEY_09', 2, async function (done) {
let testNum = 'SUB_USERFILE_MGR_GETPHOTOASSETSBYKEY_09';
let fileKey = ImageVideoKey.HEIGHT;
await getPhotoAssetsByKey(done, testNum, fileKey);
......@@ -324,9 +369,9 @@ export default function fileAssetFileKeyTest(abilityContext) {
* @tc.desc : ImageVideoKey.DATE_TAKEN
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 2
*/
it('SUB_USERFILE_MGR_GETPHOTOASSETSBYKEY_010', 0, async function (done) {
it('SUB_USERFILE_MGR_GETPHOTOASSETSBYKEY_010', 2, async function (done) {
let testNum = 'SUB_USERFILE_MGR_GETPHOTOASSETSBYKEY_010';
let fileKey = ImageVideoKey.DATE_TAKEN;
await getPhotoAssetsByKey(done, testNum, fileKey);
......@@ -338,9 +383,9 @@ export default function fileAssetFileKeyTest(abilityContext) {
* @tc.desc : ImageVideoKey.ORIENTATION
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 2
*/
it('SUB_USERFILE_MGR_GETPHOTOASSETSBYKEY_011', 0, async function (done) {
it('SUB_USERFILE_MGR_GETPHOTOASSETSBYKEY_011', 2, async function (done) {
let testNum = 'SUB_USERFILE_MGR_GETPHOTOASSETSBYKEY_011';
let fileKey = ImageVideoKey.ORIENTATION;
await getPhotoAssetsByKey(done, testNum, fileKey);
......@@ -352,9 +397,9 @@ export default function fileAssetFileKeyTest(abilityContext) {
* @tc.desc : ImageVideoKey.FAVORITE
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 2
*/
it('SUB_USERFILE_MGR_GETPHOTOASSETSBYKEY_012', 0, async function (done) {
it('SUB_USERFILE_MGR_GETPHOTOASSETSBYKEY_012', 2, async function (done) {
let testNum = 'SUB_USERFILE_MGR_GETPHOTOASSETSBYKEY_012';
let fileKey = ImageVideoKey.FAVORITE;
await getPhotoAssetsByKey(done, testNum, fileKey);
......@@ -362,115 +407,129 @@ export default function fileAssetFileKeyTest(abilityContext) {
//----------------------------------------------------------------------------
/**
* @tc.number : SUB_USERFILE_MGR_GETAUDIOASSETSBYKEY_01
* @tc.name : AudioKey
* @tc.desc : AudioKey.URI
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
*/
it('SUB_USERFILE_MGR_GETAUDIOASSETSBYKEY_01', 2, async function (done) {
let testNum = 'SUB_USERFILE_MGR_GETAUDIOASSETSBYKEY_01';
let fileKey = AudioKey.URI;
await getAudioAssetsByKey(done, testNum, fileKey);
});
/**
* @tc.number : SUB_USERFILE_MGR_GETAUDIOASSETSBYKEY_02
* @tc.name : AUDIOKEY
* @tc.desc : AUDIOKEY.DISPLAY_NAME
* @tc.name : AudioKey
* @tc.desc : AudioKey.DISPLAY_NAME
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 2
*/
it('SUB_USERFILE_MGR_GETAUDIOASSETSBYKEY_02', 0, async function (done) {
it('SUB_USERFILE_MGR_GETAUDIOASSETSBYKEY_02', 2, async function (done) {
let testNum = 'SUB_USERFILE_MGR_GETAUDIOASSETSBYKEY_02';
let fileKey = AUDIOKEY.DISPLAY_NAME;
let fileKey = AudioKey.DISPLAY_NAME;
await getAudioAssetsByKey(done, testNum, fileKey);
});
/**
* @tc.number : SUB_USERFILE_MGR_GETAUDIOASSETSBYKEY_03
* @tc.name : AUDIOKEY
* @tc.desc : AUDIOKEY.DATE_ADDED
* @tc.name : AudioKey
* @tc.desc : AudioKey.DATE_ADDED
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 2
*/
it('SUB_USERFILE_MGR_GETAUDIOASSETSBYKEY_03', 0, async function (done) {
it('SUB_USERFILE_MGR_GETAUDIOASSETSBYKEY_03', 2, async function (done) {
let testNum = 'SUB_USERFILE_MGR_GETAUDIOASSETSBYKEY_03';
let fileKey = AUDIOKEY.DATE_ADDED;
let fileKey = AudioKey.DATE_ADDED;
await getAudioAssetsByKey(done, testNum, fileKey);
});
/**
* @tc.number : SUB_USERFILE_MGR_GETAUDIOASSETSBYKEY_04
* @tc.name : AUDIOKEY
* @tc.desc : AUDIOKEY.DATE_MODIFIED
* @tc.name : AudioKey
* @tc.desc : AudioKey.DATE_MODIFIED
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 2
*/
it('SUB_USERFILE_MGR_GETAUDIOASSETSBYKEY_04', 0, async function (done) {
it('SUB_USERFILE_MGR_GETAUDIOASSETSBYKEY_04', 2, async function (done) {
let testNum = 'SUB_USERFILE_MGR_GETAUDIOASSETSBYKEY_04';
let fileKey = AUDIOKEY.DATE_MODIFIED;
let fileKey = AudioKey.DATE_MODIFIED;
await getAudioAssetsByKey(done, testNum, fileKey);
});
/**
* @tc.number : SUB_USERFILE_MGR_GETAUDIOASSETSBYKEY_05
* @tc.name : AUDIOKEY
* @tc.desc : AUDIOKEY.TITLE
* @tc.name : AudioKey
* @tc.desc : AudioKey.TITLE
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 2
*/
it('SUB_USERFILE_MGR_GETAUDIOASSETSBYKEY_05', 0, async function (done) {
it('SUB_USERFILE_MGR_GETAUDIOASSETSBYKEY_05', 2, async function (done) {
let testNum = 'SUB_USERFILE_MGR_GETAUDIOASSETSBYKEY_05';
let fileKey = AUDIOKEY.TITLE;
let fileKey = AudioKey.TITLE;
await getAudioAssetsByKey(done, testNum, fileKey);
});
/**
* @tc.number : SUB_USERFILE_MGR_GETAUDIOASSETSBYKEY_06
* @tc.name : AUDIOKEY
* @tc.desc : AUDIOKEY.ARTIST
* @tc.name : AudioKey
* @tc.desc : AudioKey.ARTIST
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 2
*/
it('SUB_USERFILE_MGR_GETAUDIOASSETSBYKEY_06', 0, async function (done) {
it('SUB_USERFILE_MGR_GETAUDIOASSETSBYKEY_06', 2, async function (done) {
let testNum = 'SUB_USERFILE_MGR_GETAUDIOASSETSBYKEY_06';
let fileKey = AUDIOKEY.ARTIST;
let fileKey = AudioKey.ARTIST;
await getAudioAssetsByKey(done, testNum, fileKey);
});
/**
* @tc.number : SUB_USERFILE_MGR_GETAUDIOASSETSBYKEY_07
* @tc.name : AUDIOKEY
* @tc.desc : AUDIOKEY.AUDIOALBUM
* @tc.name : AudioKey
* @tc.desc : AudioKey.AUDIOALBUM
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 2
*/
it('SUB_USERFILE_MGR_GETAUDIOASSETSBYKEY_07', 0, async function (done) {
it('SUB_USERFILE_MGR_GETAUDIOASSETSBYKEY_07', 2, async function (done) {
let testNum = 'SUB_USERFILE_MGR_GETAUDIOASSETSBYKEY_07';
let fileKey = AUDIOKEY.AUDIOALBUM;
let fileKey = AudioKey.AUDIOALBUM;
await getAudioAssetsByKey(done, testNum, fileKey);
});
/**
* @tc.number : SUB_USERFILE_MGR_GETAUDIOASSETSBYKEY_08
* @tc.name : AUDIOKEY
* @tc.desc : AUDIOKEY.DURATION
* @tc.name : AudioKey
* @tc.desc : AudioKey.DURATION
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 2
*/
it('SUB_USERFILE_MGR_GETAUDIOASSETSBYKEY_08', 0, async function (done) {
it('SUB_USERFILE_MGR_GETAUDIOASSETSBYKEY_08', 2, async function (done) {
let testNum = 'SUB_USERFILE_MGR_GETAUDIOASSETSBYKEY_08';
let fileKey = AUDIOKEY.DURATION;
let fileKey = AudioKey.DURATION;
await getAudioAssetsByKey(done, testNum, fileKey);
});
/**
* @tc.number : SUB_USERFILE_MGR_GETAUDIOASSETSBYKEY_09
* @tc.name : AUDIOKEY
* @tc.desc : AUDIOKEY.FAVORITE
* @tc.name : AudioKey
* @tc.desc : AudioKey.FAVORITE
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 2
*/
it('SUB_USERFILE_MGR_GETAUDIOASSETSBYKEY_09', 0, async function (done) {
it('SUB_USERFILE_MGR_GETAUDIOASSETSBYKEY_09', 2, async function (done) {
let testNum = 'SUB_USERFILE_MGR_GETAUDIOASSETSBYKEY_09';
let fileKey = AUDIOKEY.FAVORITE;
let fileKey = AudioKey.FAVORITE;
await getAudioAssetsByKey(done, testNum, fileKey);
});
});
......
......@@ -232,9 +232,9 @@ export default function fileAssetOpenCallbackTest(abilityContext) {
* @tc.desc : open -r the type of image
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 2
*/
it('SUB_USERFILE_MGR_FILEASSET_OPEN_CALLBACK_01_001', 0, async function (done) {
it('SUB_USERFILE_MGR_FILEASSET_OPEN_CALLBACK_01_001', 2, async function (done) {
let testNum = 'SUB_USERFILE_MGR_FILEASSET_OPEN_CALLBACK_01_001';
let fetchOp = imageVideoFetchOps(testNum, 'Pictures/R_Cb/');
let assetProps = {
......@@ -251,9 +251,9 @@ export default function fileAssetOpenCallbackTest(abilityContext) {
* @tc.desc : open -w the type of image
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 2
*/
it('SUB_USERFILE_MGR_FILEASSET_OPEN_CALLBACK_01_002', 0, async function (done) {
it('SUB_USERFILE_MGR_FILEASSET_OPEN_CALLBACK_01_002', 2, async function (done) {
let testNum = 'SUB_USERFILE_MGR_FILEASSET_OPEN_CALLBACK_01_002';
let fetchOp = imageVideoFetchOps(testNum, 'Pictures/W_Cb/');
let assetProps = {
......@@ -270,9 +270,9 @@ export default function fileAssetOpenCallbackTest(abilityContext) {
* @tc.desc : open -rw the type of image
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 2
*/
it('SUB_USERFILE_MGR_FILEASSET_OPEN_CALLBACK_01_003', 0, async function (done) {
it('SUB_USERFILE_MGR_FILEASSET_OPEN_CALLBACK_01_003', 2, async function (done) {
let testNum = 'SUB_USERFILE_MGR_FILEASSET_OPEN_CALLBACK_01_003';
let fetchOp = imageVideoFetchOps(testNum, 'Pictures/RW_Cb/');
let assetProps = {
......@@ -287,116 +287,116 @@ export default function fileAssetOpenCallbackTest(abilityContext) {
/**
* @tc.number : SUB_USERFILE_MGR_FILEASSET_OPEN_CALLBACK_02_001
* @tc.name : open('r')
* @tc.desc : open -r the type of audio
* @tc.desc : open -r the type of video
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 2
*/
it('SUB_USERFILE_MGR_FILEASSET_OPEN_CALLBACK_02_001', 0, async function (done) {
it('SUB_USERFILE_MGR_FILEASSET_OPEN_CALLBACK_02_001', 2, async function (done) {
let testNum = 'SUB_USERFILE_MGR_FILEASSET_OPEN_CALLBACK_02_001';
let fetchOp = audioFetchOps(testNum, 'Audios/R_Cb/');
let fetchOp = imageVideoFetchOps(testNum, 'Videos/R_Cb/');
let assetProps = {
bytesRead: 4096,
};
let expectCount = 1;
let isAudio = true;
let isAudio = false;
await rOpenTest(done, testNum, fetchOp, assetProps, expectCount, isAudio);
});
/**
* @tc.number : SUB_USERFILE_MGR_FILEASSET_OPEN_CALLBACK_02_002
* @tc.name : open('w')
* @tc.desc : open -w the type of audio
* @tc.desc : open -w the type of video
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 2
*/
it('SUB_USERFILE_MGR_FILEASSET_OPEN_CALLBACK_02_002', 0, async function (done) {
it('SUB_USERFILE_MGR_FILEASSET_OPEN_CALLBACK_02_002', 2, async function (done) {
let testNum = 'SUB_USERFILE_MGR_FILEASSET_OPEN_CALLBACK_02_002';
let fetchOp = audioFetchOps(testNum, 'Audios/W_Cb/');
let fetchOp = imageVideoFetchOps(testNum, 'Videos/W_Cb/');
let assetProps = {
write: 4096,
};
let expectCount = 2;
let isAudio = true;
let isAudio = false;
await wOpenTest(done, testNum, fetchOp, assetProps, expectCount, isAudio);
});
/**
* @tc.number : SUB_USERFILE_MGR_FILEASSET_OPEN_CALLBACK_02_003
* @tc.name : open('rw')
* @tc.desc : open -rw the type of audio
* @tc.desc : open -rw the type of video
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 2
*/
it('SUB_USERFILE_MGR_FILEASSET_OPEN_CALLBACK_02_003', 0, async function (done) {
it('SUB_USERFILE_MGR_FILEASSET_OPEN_CALLBACK_02_003', 2, async function (done) {
let testNum = 'SUB_USERFILE_MGR_FILEASSET_OPEN_CALLBACK_02_003';
let fetchOp = audioFetchOps(testNum, 'Audios/RW_Cb/');
let fetchOp = imageVideoFetchOps(testNum, 'Videos/RW_Cb/');
let assetProps = {
bytesRead: 4096,
write: 4096,
};
let expectCount = 2;
let isAudio = true;
let isAudio = false;
await rwOpenTest(done, testNum, fetchOp, assetProps, expectCount, isAudio);
});
/**
* @tc.number : SUB_USERFILE_MGR_FILEASSET_OPEN_CALLBACK_03_001
* @tc.name : open('r')
* @tc.desc : open -r the type of video
* @tc.desc : open -r the type of audio
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 2
*/
it('SUB_USERFILE_MGR_FILEASSET_OPEN_CALLBACK_03_001', 0, async function (done) {
it('SUB_USERFILE_MGR_FILEASSET_OPEN_CALLBACK_03_001', 2, async function (done) {
let testNum = 'SUB_USERFILE_MGR_FILEASSET_OPEN_CALLBACK_03_001';
let fetchOp = imageVideoFetchOps(testNum, 'Videos/R_Cb/');
let fetchOp = audioFetchOps(testNum, 'Audios/R_Cb/');
let assetProps = {
bytesRead: 4096,
};
let expectCount = 1;
let isAudio = false;
let isAudio = true;
await rOpenTest(done, testNum, fetchOp, assetProps, expectCount, isAudio);
});
/**
* @tc.number : SUB_USERFILE_MGR_FILEASSET_OPEN_CALLBACK_03_002
* @tc.name : open('w')
* @tc.desc : open -w the type of video
* @tc.desc : open -w the type of audio
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 2
*/
it('SUB_USERFILE_MGR_FILEASSET_OPEN_CALLBACK_03_002', 0, async function (done) {
it('SUB_USERFILE_MGR_FILEASSET_OPEN_CALLBACK_03_002', 2, async function (done) {
let testNum = 'SUB_USERFILE_MGR_FILEASSET_OPEN_CALLBACK_03_002';
let fetchOp = imageVideoFetchOps(testNum, 'Videos/W_Cb/');
let fetchOp = audioFetchOps(testNum, 'Audios/W_Cb/');
let assetProps = {
write: 4096,
};
let expectCount = 2;
let isAudio = false;
let isAudio = true;
await wOpenTest(done, testNum, fetchOp, assetProps, expectCount, isAudio);
});
/**
* @tc.number : SUB_USERFILE_MGR_FILEASSET_OPEN_CALLBACK_03_003
* @tc.name : open('rw')
* @tc.desc : open -rw the type of video
* @tc.desc : open -rw the type of audio
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 2
*/
it('SUB_USERFILE_MGR_FILEASSET_OPEN_CALLBACK_03_003', 0, async function (done) {
it('SUB_USERFILE_MGR_FILEASSET_OPEN_CALLBACK_03_003', 2, async function (done) {
let testNum = 'SUB_USERFILE_MGR_FILEASSET_OPEN_CALLBACK_03_003';
let fetchOp = imageVideoFetchOps(testNum, 'Videos/RW_Cb/');
let fetchOp = audioFetchOps(testNum, 'Audios/RW_Cb/');
let assetProps = {
bytesRead: 4096,
write: 4096,
};
let expectCount = 2;
let isAudio = false;
let isAudio = true;
await rwOpenTest(done, testNum, fetchOp, assetProps, expectCount, isAudio);
});
......@@ -408,9 +408,9 @@ export default function fileAssetOpenCallbackTest(abilityContext) {
* @tc.desc : asset close the type of image
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 2
*/
it('SUB_USERFILE_MGR_FILEASSET_CLOSE_CALLBACK_01', 0, async function (done) {
it('SUB_USERFILE_MGR_FILEASSET_CLOSE_CALLBACK_01', 2, async function (done) {
let testNum = 'SUB_USERFILE_MGR_FILEASSET_CLOSE_CALLBACK_01';
let fetchOp = imageVideoNameFetchOps(testNum, 'Pictures/openClose/', '01.jpg');
let isAudio = false;
......@@ -420,30 +420,30 @@ export default function fileAssetOpenCallbackTest(abilityContext) {
/**
* @tc.number : SUB_USERFILE_MGR_FILEASSET_CLOSE_CALLBACK_02
* @tc.name : close
* @tc.desc : asset close the type of audio
* @tc.desc : asset close the type of video
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 2
*/
it('SUB_USERFILE_MGR_FILEASSET_CLOSE_CALLBACK_02', 0, async function (done) {
it('SUB_USERFILE_MGR_FILEASSET_CLOSE_CALLBACK_02', 2, async function (done) {
let testNum = 'SUB_USERFILE_MGR_FILEASSET_CLOSE_CALLBACK_02';
let fetchOp = audioNameFetchOps(testNum, 'Audios/openClose/', '01.mp3');
let isAudio = true;
let fetchOp = imageVideoNameFetchOps(testNum, 'Videos/openClose/', '01.mp4');
let isAudio = false;
await closeTest(done, testNum, fetchOp, isAudio);
});
/**
* @tc.number : SUB_USERFILE_MGR_FILEASSET_CLOSE_CALLBACK_03
* @tc.name : close
* @tc.desc : asset close the type of video
* @tc.desc : asset close the type of audio
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 2
*/
it('SUB_USERFILE_MGR_FILEASSET_CLOSE_CALLBACK_03', 0, async function (done) {
it('SUB_USERFILE_MGR_FILEASSET_CLOSE_CALLBACK_03', 2, async function (done) {
let testNum = 'SUB_USERFILE_MGR_FILEASSET_CLOSE_CALLBACK_03';
let fetchOp = imageVideoNameFetchOps(testNum, 'Videos/openClose/', '01.mp4');
let isAudio = false;
let fetchOp = audioNameFetchOps(testNum, 'Audios/openClose/', '01.mp3');
let isAudio = true;
await closeTest(done, testNum, fetchOp, isAudio);
});
});
......
......@@ -208,9 +208,9 @@ export default function fileAssetOpenPromiseTest(abilityContext) {
* @tc.desc : open -r the type of image
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 2
*/
it('SUB_USERFILE_MGR_FILEASSET_OPEN_PROMISE_01_001', 0, async function (done) {
it('SUB_USERFILE_MGR_FILEASSET_OPEN_PROMISE_01_001', 2, async function (done) {
let testNum = 'SUB_USERFILE_MGR_FILEASSET_OPEN_PROMISE_01_001';
let fetchOp = imageVideoFetchOps(testNum, 'Pictures/R_Pro/');
let assetProps = {
......@@ -227,9 +227,9 @@ export default function fileAssetOpenPromiseTest(abilityContext) {
* @tc.desc : open -w the type of image
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 2
*/
it('SUB_USERFILE_MGR_FILEASSET_OPEN_PROMISE_01_002', 0, async function (done) {
it('SUB_USERFILE_MGR_FILEASSET_OPEN_PROMISE_01_002', 2, async function (done) {
let testNum = 'SUB_USERFILE_MGR_FILEASSET_OPEN_PROMISE_01_002';
let fetchOp = imageVideoFetchOps(testNum, 'Pictures/W_Pro/');
let assetProps = {
......@@ -246,9 +246,9 @@ export default function fileAssetOpenPromiseTest(abilityContext) {
* @tc.desc : open -rw the type of image
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 2
*/
it('SUB_USERFILE_MGR_FILEASSET_OPEN_PROMISE_01_003', 0, async function (done) {
it('SUB_USERFILE_MGR_FILEASSET_OPEN_PROMISE_01_003', 2, async function (done) {
let testNum = 'SUB_USERFILE_MGR_FILEASSET_OPEN_PROMISE_01_003';
let fetchOp = imageVideoFetchOps(testNum, 'Pictures/RW_Pro/');
let assetProps = {
......@@ -263,116 +263,116 @@ export default function fileAssetOpenPromiseTest(abilityContext) {
/**
* @tc.number : SUB_USERFILE_MGR_FILEASSET_OPEN_PROMISE_02_001
* @tc.name : open('r')
* @tc.desc : open -r the type of audio
* @tc.desc : open -r the type of video
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 2
*/
it('SUB_USERFILE_MGR_FILEASSET_OPEN_PROMISE_02_001', 0, async function (done) {
it('SUB_USERFILE_MGR_FILEASSET_OPEN_PROMISE_02_001', 2, async function (done) {
let testNum = 'SUB_USERFILE_MGR_FILEASSET_OPEN_PROMISE_02_001';
let fetchOp = audioFetchOps(testNum, 'Audios/R_Pro/');
let fetchOp = imageVideoFetchOps(testNum, 'Videos/R_Pro/');
let assetProps = {
bytesRead: 4096,
};
let expectCount = 1;
let isAudio = true;
let isAudio = false;
await rOpenTest(done, testNum, fetchOp, assetProps, expectCount, isAudio);
});
/**
* @tc.number : SUB_USERFILE_MGR_FILEASSET_OPEN_PROMISE_02_002
* @tc.name : open('w')
* @tc.desc : open -w the type of audio
* @tc.desc : open -w the type of video
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 2
*/
it('SUB_USERFILE_MGR_FILEASSET_OPEN_PROMISE_02_002', 0, async function (done) {
it('SUB_USERFILE_MGR_FILEASSET_OPEN_PROMISE_02_002', 2, async function (done) {
let testNum = 'SUB_USERFILE_MGR_FILEASSET_OPEN_PROMISE_02_002';
let fetchOp = audioFetchOps(testNum, 'Audios/W_Pro/');
let fetchOp = imageVideoFetchOps(testNum, 'Videos/W_Pro/');
let assetProps = {
write: 4096,
};
let expectCount = 2;
let isAudio = true;
let isAudio = false;
await wOpenTest(done, testNum, fetchOp, assetProps, expectCount, isAudio);
});
/**
* @tc.number : SUB_USERFILE_MGR_FILEASSET_OPEN_PROMISE_02_003
* @tc.name : open('rw')
* @tc.desc : open -rw the type of audio
* @tc.desc : open -rw the type of video
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 2
*/
it('SUB_USERFILE_MGR_FILEASSET_OPEN_PROMISE_02_003', 0, async function (done) {
it('SUB_USERFILE_MGR_FILEASSET_OPEN_PROMISE_02_003', 2, async function (done) {
let testNum = 'SUB_USERFILE_MGR_FILEASSET_OPEN_PROMISE_02_003';
let fetchOp = audioFetchOps(testNum, 'Audios/RW_Pro/');
let fetchOp = imageVideoFetchOps(testNum, 'Videos/RW_Pro/');
let assetProps = {
bytesRead: 4096,
write: 4096,
};
let expectCount = 2;
let isAudio = true;
let isAudio = false;
await rwOpenTest(done, testNum, fetchOp, assetProps, expectCount, isAudio);
});
/**
* @tc.number : SUB_USERFILE_MGR_FILEASSET_OPEN_PROMISE_03_001
* @tc.name : open('r')
* @tc.desc : open -r the type of video
* @tc.desc : open -r the type of audio
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 2
*/
it('SUB_USERFILE_MGR_FILEASSET_OPEN_PROMISE_03_001', 0, async function (done) {
it('SUB_USERFILE_MGR_FILEASSET_OPEN_PROMISE_03_001', 2, async function (done) {
let testNum = 'SUB_USERFILE_MGR_FILEASSET_OPEN_PROMISE_03_001';
let fetchOp = imageVideoFetchOps(testNum, 'Videos/R_Pro/');
let fetchOp = audioFetchOps(testNum, 'Audios/R_Pro/');
let assetProps = {
bytesRead: 4096,
};
let expectCount = 1;
let isAudio = false;
let isAudio = true;
await rOpenTest(done, testNum, fetchOp, assetProps, expectCount, isAudio);
});
/**
* @tc.number : SUB_USERFILE_MGR_FILEASSET_OPEN_PROMISE_03_002
* @tc.name : open('w')
* @tc.desc : open -w the type of video
* @tc.desc : open -w the type of audio
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 2
*/
it('SUB_USERFILE_MGR_FILEASSET_OPEN_PROMISE_03_002', 0, async function (done) {
it('SUB_USERFILE_MGR_FILEASSET_OPEN_PROMISE_03_002', 2, async function (done) {
let testNum = 'SUB_USERFILE_MGR_FILEASSET_OPEN_PROMISE_03_002';
let fetchOp = imageVideoFetchOps(testNum, 'Videos/W_Pro/');
let fetchOp = audioFetchOps(testNum, 'Audios/W_Pro/');
let assetProps = {
write: 4096,
};
let expectCount = 2;
let isAudio = false;
let isAudio = true;
await wOpenTest(done, testNum, fetchOp, assetProps, expectCount, isAudio);
});
/**
* @tc.number : SUB_USERFILE_MGR_FILEASSET_OPEN_PROMISE_03_003
* @tc.name : open('rw')
* @tc.desc : open -rw the type of video
* @tc.desc : open -rw the type of audio
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 2
*/
it('SUB_USERFILE_MGR_FILEASSET_OPEN_PROMISE_03_003', 0, async function (done) {
it('SUB_USERFILE_MGR_FILEASSET_OPEN_PROMISE_03_003', 2, async function (done) {
let testNum = 'SUB_USERFILE_MGR_FILEASSET_OPEN_PROMISE_03_003';
let fetchOp = imageVideoFetchOps(testNum, 'Videos/RW_Pro/');
let fetchOp = audioFetchOps(testNum, 'Audios/RW_Pro/');
let assetProps = {
bytesRead: 4096,
write: 4096,
};
let expectCount = 2;
let isAudio = false;
let isAudio = true;
await rwOpenTest(done, testNum, fetchOp, assetProps, expectCount, isAudio);
});
......@@ -384,9 +384,9 @@ export default function fileAssetOpenPromiseTest(abilityContext) {
* @tc.desc : asset close the type of image
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 2
*/
it('SUB_USERFILE_MGR_FILEASSET_CLOSE_PROMISE_01', 0, async function (done) {
it('SUB_USERFILE_MGR_FILEASSET_CLOSE_PROMISE_01', 2, async function (done) {
let testNum = 'SUB_USERFILE_MGR_FILEASSET_CLOSE_PROMISE_01';
let fetchOp = imageVideoNameFetchOps(testNum, 'Pictures/openClose/', '02.jpg');
let isAudio = false;
......@@ -396,30 +396,30 @@ export default function fileAssetOpenPromiseTest(abilityContext) {
/**
* @tc.number : SUB_USERFILE_MGR_FILEASSET_CLOSE_PROMISE_02
* @tc.name : close
* @tc.desc : asset close the type of audio
* @tc.desc : asset close the type of video
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 2
*/
it('SUB_USERFILE_MGR_FILEASSET_CLOSE_PROMISE_02', 0, async function (done) {
let testNum = 'SUB_USERFILE_MGR_FILEASSET_CLOSE_PROMISE_03';
let fetchOp = audioNameFetchOps(testNum, 'Audios/openClose/', '02.mp3');
let isAudio = true;
it('SUB_USERFILE_MGR_FILEASSET_CLOSE_PROMISE_02', 2, async function (done) {
let testNum = 'SUB_USERFILE_MGR_FILEASSET_CLOSE_PROMISE_02';
let fetchOp = imageVideoNameFetchOps(testNum, 'Videos/openClose/', '02.mp4');
let isAudio = false;
await closeTest(done, testNum, fetchOp, isAudio);
});
/**
* @tc.number : SUB_USERFILE_MGR_FILEASSET_CLOSE_PROMISE_03
* @tc.name : close
* @tc.desc : asset close the type of video
* @tc.desc : asset close the type of audio
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 2
*/
it('SUB_USERFILE_MGR_FILEASSET_CLOSE_PROMISE_03', 0, async function (done) {
it('SUB_USERFILE_MGR_FILEASSET_CLOSE_PROMISE_03', 2, async function (done) {
let testNum = 'SUB_USERFILE_MGR_FILEASSET_CLOSE_PROMISE_03';
let fetchOp = imageVideoNameFetchOps(testNum, 'Videos/openClose/', '02.mp4');
let isAudio = false;
let fetchOp = audioNameFetchOps(testNum, 'Audios/openClose/', '02.mp3');
let isAudio = true;
await closeTest(done, testNum, fetchOp, isAudio);
});
});
......
/*
* 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 userFileManager from '@ohos.filemanagement.userFileManager';
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "deccjsunit/index";
import {
sleep,
allFetchOp,
audioNameFetchOps,
imageVideoNameFetchOps,
albumFetchOps,
checkAssetsCount,
} from "../../../../../../common";
export default function fileAssetTrashCallbackTest(abilityContext) {
describe("fileAssetTrashCallbackTest", function () {
const userfilemgr = userFileManager.getUserFileMgr(abilityContext);
beforeAll(async function () {
console.info("beforeAll case");
});
beforeEach(function () {
console.info("beforeEach case");
});
afterEach(async function () {
console.info("afterEach case");
await sleep;
});
afterAll(async function () {
console.info("afterAll case");
});
const isTrashTest = async function (done, testNum, fetchOp, isAudio) {
try {
let fetchAssetResult;
if (isAudio) {
fetchAssetResult = await userfilemgr.getAudioAssets(fetchOp);
} else {
fetchAssetResult = await userfilemgr.getPhotoAssets(fetchOp);
}
let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchAssetResult, 1);
if (!checkAssetCountPass) return;
let asset = await fetchAssetResult.getFirstObject();
asset.isTrash(async (err, isTrash) => {
if (err) {
expect(false).assertTrue();
await fetchAssetResult.close();
done();
return;
}
expect(isTrash).assertEqual(false);
fetchAssetResult.close();
done()
});
} catch (error) {
console.info(`${testNum} failed error: ${error}`)
expect(false).assertTrue();
done();
}
}
async function setTrash(done, testNum, databasefFetchOps, ablumFetchOps, noAlbum, isAudio) {
let expectAssetNum = 3
try {
// database info
let databaseFetchFileResult;
if (isAudio) {
databaseFetchFileResult = await userfilemgr.getAudioAssets(databasefFetchOps);
} else {
databaseFetchFileResult = await userfilemgr.getPhotoAssets(databasefFetchOps);
}
let count = databaseFetchFileResult.getCount();
//album info
if (!noAlbum) {
let fetchAlbumResult = await userfilemgr.getPhotoAlbums(ablumFetchOps);
let album = await fetchAlbumResult.getFirstObject();
let op: userFileManager.FetchOptions = allFetchOp();
let albumFetchFileResult = await album.getPhotoAssets(op);
let albumFilesCount = albumFetchFileResult.getCount();
expect(albumFilesCount).assertEqual(expectAssetNum);
fetchAlbumResult.close();
}
// file info
let asset = await databaseFetchFileResult.getFirstObject();
let istrash = await asset.isTrash();
console.info(`${testNum} istrash: ${istrash}`);
// trash operation
asset.trash(true, async (err) => {
if (err) {
console.info(`${testNum} err: ${err}`);
expect(false).assertTrue();
done();
return;
}
asset.isTrash(async (err, trashState) => {
if (err) {
console.info(`${testNum} err: ${err}`);
expect(false).assertTrue();
done();
return;
}
expect(trashState).assertTrue();
try {
// after trash database info
let databaseFetchFileResult;
if (isAudio) {
databaseFetchFileResult = await userfilemgr.getAudioAssets(databasefFetchOps);
} else {
databaseFetchFileResult = await userfilemgr.getPhotoAssets(databasefFetchOps);
}
let databaseCount = databaseFetchFileResult.getCount();
databaseFetchFileResult.close();
expect(databaseCount).assertEqual(count - 1);
//album info
if (!noAlbum) {
let fetchAlbumResult = await userfilemgr.getPhotoAlbums(ablumFetchOps);
let album = await fetchAlbumResult.getFirstObject();
let op: userFileManager.FetchOptions = allFetchOp();
let albumFetchFileResult = await album.getPhotoAssets(op);
let albumFilesCount = albumFetchFileResult.getCount();
expect(albumFilesCount).assertEqual(expectAssetNum - 1);
fetchAlbumResult.close();
}
await asset.trash(false);
done();
} catch (error) {
console.info(`${testNum} error: ${error}`);
expect(false).assertTrue();
done();
}
});
});
} catch (error) {
console.info(`${testNum} error: ${error}`);
expect(false).assertTrue();
done();
}
}
async function recovery(done, testNum, databasefFetchOps, ablumFetchOps, noAlbum, isAudio) {
let expectAssetNum = 3;
try {
let databaseFetchFileResult;
if (isAudio) {
databaseFetchFileResult = await userfilemgr.getAudioAssets(databasefFetchOps);
} else {
databaseFetchFileResult = await userfilemgr.getPhotoAssets(databasefFetchOps);
}
let count = databaseFetchFileResult.getCount();
let asset = await databaseFetchFileResult.getFirstObject();
await asset.trash(true);
asset.trash(false, async (err) => {
if (err) {
console.info(`${testNum} err: ${err}`);
expect(false).assertTrue();
done();
return;
}
asset.isTrash(async (err, trashState) => {
if (err) {
console.info(`${testNum} err: ${err}`);
expect(false).assertTrue();
done();
return;
}
expect(trashState).assertFalse();
try {
let databaseFetchFileResult;
if (isAudio) {
databaseFetchFileResult = await userfilemgr.getAudioAssets(databasefFetchOps);
} else {
databaseFetchFileResult = await userfilemgr.getPhotoAssets(databasefFetchOps);
}
let databaseCount = databaseFetchFileResult.getCount();
databaseFetchFileResult.close();
expect(databaseCount).assertEqual(count);
//album info
if (!noAlbum) {
let fetchAlbumResult = await userfilemgr.getPhotoAlbums(ablumFetchOps);
let album = await fetchAlbumResult.getFirstObject();
let op: userFileManager.FetchOptions = allFetchOp();
let albumFetchFileResult = await album.getPhotoAssets(op);
let albumFilesCount = albumFetchFileResult.getCount();
expect(albumFilesCount).assertEqual(expectAssetNum);
fetchAlbumResult.close();
}
done();
} catch (error) {
console.info(`${testNum} error: ${error}`);
expect(false).assertTrue();
done();
}
});
});
} catch (error) {
console.info(`${testNum} error: ${error}`);
expect(false).assertTrue();
done();
}
}
/**
* @tc.number : SUB_USERFILE_MGR_FILEASSET_TRASH_CALLBACK_01_001
* @tc.name : isTrash
* @tc.desc : isTrash(image) result false
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_USERFILE_MGR_FILEASSET_TRASH_CALLBACK_01_001', 0, async function (done) {
let testNum = 'SUB_USERFILE_MGR_FILEASSET_TRASH_CALLBACK_01_001'
let currentFetchOp = imageVideoNameFetchOps(testNum, 'Pictures/trashCb/', '01.jpg');
let isAudio = false;
await isTrashTest(done, testNum, currentFetchOp, isAudio)
});
/**
* @tc.number : SUB_USERFILE_MGR_FILEASSET_TRASH_CALLBACK_01_002
* @tc.name : trash
* @tc.desc : trash(image) by true
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_USERFILE_MGR_FILEASSET_TRASH_CALLBACK_01_002', 0, async function (done) {
let testNum = 'SUB_USERFILE_MGR_FILEASSET_TRASH_CALLBACK_01_002'
let rOps = imageVideoNameFetchOps(testNum, "Pictures/trashCb/", '02.jpg');
let aOps = albumFetchOps(testNum, "Pictures/", "trashCb");
let noAlbum = false;
let isAudio = false;
await setTrash(done, testNum, rOps, aOps, noAlbum, isAudio);
});
/**
* @tc.number : SUB_USERFILE_MGR_FILEASSET_TRASH_CALLBACK_01_003
* @tc.name : trash
* @tc.desc : trash(image) by false
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_USERFILE_MGR_FILEASSET_TRASH_CALLBACK_01_003', 0, async function (done) {
let testNum = 'SUB_USERFILE_MGR_FILEASSET_TRASH_CALLBACK_01_003'
let rOps = imageVideoNameFetchOps(testNum, "Pictures/trashCb/", '03.jpg');
let aOps = albumFetchOps(testNum, "Pictures/", "trashCb");
let noAlbum = false;
let isAudio = false;
await recovery(done, testNum, rOps, aOps, noAlbum, isAudio);
});
/**
* @tc.number : SUB_USERFILE_MGR_FILEASSET_TRASH_CALLBACK_02_001
* @tc.name : isTrash
* @tc.desc : isTrash(audio) result false
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_USERFILE_MGR_FILEASSET_TRASH_CALLBACK_02_001', 0, async function (done) {
let testNum = 'SUB_USERFILE_MGR_FILEASSET_TRASH_CALLBACK_02_001'
let currentFetchOp = audioNameFetchOps(testNum, 'Audios/trashCb/', '01.mp3');
let isAudio = true;
await isTrashTest(done, testNum, currentFetchOp, isAudio)
});
/**
* @tc.number : SUB_USERFILE_MGR_FILEASSET_TRASH_CALLBACK_02_002
* @tc.name : trash
* @tc.desc : trash(audio) by true
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_USERFILE_MGR_FILEASSET_TRASH_CALLBACK_02_002', 0, async function (done) {
let testNum = 'SUB_USERFILE_MGR_FILEASSET_TRASH_CALLBACK_02_002'
let rOps = audioNameFetchOps(testNum, "Audios/trashCb/", '02.mp3');
let aOps = albumFetchOps(testNum, "Audios/", "trashCb");
let noAlbum = true;
let isAudio = true;
await setTrash(done, testNum, rOps, aOps, noAlbum, isAudio);
});
/**
* @tc.number : SUB_USERFILE_MGR_FILEASSET_TRASH_CALLBACK_02_003
* @tc.name : trash
* @tc.desc : trash(audio) by false
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_USERFILE_MGR_FILEASSET_TRASH_CALLBACK_02_003', 0, async function (done) {
let testNum = 'SUB_USERFILE_MGR_FILEASSET_TRASH_CALLBACK_02_003'
let rOps = audioNameFetchOps(testNum, "Audios/trashCb/", '03.mp3');
let aOps = albumFetchOps(testNum, "Audios/", "trashCb");
let noAlbum = true;
let isAudio = true;
await recovery(done, testNum, rOps, aOps, noAlbum, isAudio);
});
/**
* @tc.number : SUB_USERFILE_MGR_FILEASSET_TRASH_CALLBACK_03_001
* @tc.name : isTrash
* @tc.desc : isTrash(video) result false
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_USERFILE_MGR_FILEASSET_TRASH_CALLBACK_03_001', 0, async function (done) {
let testNum = 'SUB_USERFILE_MGR_FILEASSET_TRASH_CALLBACK_03_001'
let currentFetchOp = imageVideoNameFetchOps(testNum, 'Videos/trashCb/', '01.mp4');
let isAudio = false;
await isTrashTest(done, testNum, currentFetchOp, isAudio)
});
/**
* @tc.number : SUB_USERFILE_MGR_FILEASSET_TRASH_CALLBACK_03_002
* @tc.name : trash
* @tc.desc : trash(video) by true
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_USERFILE_MGR_FILEASSET_TRASH_CALLBACK_03_002', 0, async function (done) {
let testNum = 'SUB_USERFILE_MGR_FILEASSET_TRASH_CALLBACK_03_002'
let rOps = imageVideoNameFetchOps(testNum, "Videos/trashCb/", '02.mp4');
let aOps = albumFetchOps(testNum, "Videos/", "trashCb");
let noAlbum = true;
let isAudio = false;
await setTrash(done, testNum, rOps, aOps, noAlbum, isAudio);
});
/**
* @tc.number : SUB_USERFILE_MGR_FILEASSET_TRASH_CALLBACK_03_003
* @tc.name : trash
* @tc.desc : trash(video) by false
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_USERFILE_MGR_FILEASSET_TRASH_CALLBACK_03_003', 0, async function (done) {
let testNum = 'SUB_USERFILE_MGR_FILEASSET_TRASH_CALLBACK_03_003'
let rOps = imageVideoNameFetchOps(testNum, "Videos/trashCb/", '03.mp4');
let aOps = albumFetchOps(testNum, "Videos/", "trashCb");
let noAlbum = true;
let isAudio = false;
await recovery(done, testNum, rOps, aOps, noAlbum, isAudio);
});
});
}
\ No newline at end of file
/*
* 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 userFileManager from '@ohos.filemanagement.userFileManager';
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "deccjsunit/index";
import {
sleep,
allFetchOp,
audioNameFetchOps,
imageVideoNameFetchOps,
albumFetchOps,
checkAssetsCount,
} from "../../../../../../common";
export default function fileAssetTrashPromiseTest(abilityContext) {
describe("fileAssetTrashPromiseTest", function () {
const userfilemgr = userFileManager.getUserFileMgr(abilityContext);
beforeAll(async function () {
console.info("beforeAll case");
});
beforeEach(function () {
console.info("beforeEach case");
});
afterEach(async function () {
console.info("afterEach case");
await sleep;
});
afterAll(async function () {
console.info("afterAll case");
});
const isTrashTest = async function (done, testNum, fetchOp, isAudio) {
try {
let fetchAssetResult;
if (isAudio) {
fetchAssetResult = await userfilemgr.getAudioAssets(fetchOp);
} else {
fetchAssetResult = await userfilemgr.getPhotoAssets(fetchOp);
}
let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchAssetResult, 1);
if (!checkAssetCountPass) return;
let asset = await fetchAssetResult.getFirstObject();
let isTrash = await asset.isTrash();
expect(isTrash).assertEqual(false);
fetchAssetResult.close();
done();
} catch (error) {
console.info(`${testNum} failed error: ${error}`)
expect(false).assertTrue();
done();
}
}
async function setTrash(done, testNum, databasefFetchOps, ablumFetchOps, noAlbum, isAudio) {
let expectAssetNum = 3
try {
// database info
let databaseFetchFileResult;
if (isAudio) {
databaseFetchFileResult = await userfilemgr.getAudioAssets(databasefFetchOps);
} else {
databaseFetchFileResult = await userfilemgr.getPhotoAssets(databasefFetchOps);
}
let count = databaseFetchFileResult.getCount();
//album info
if (!noAlbum) {
let fetchAlbumResult = await userfilemgr.getPhotoAlbums(ablumFetchOps);
let album = await fetchAlbumResult.getFirstObject();
let op: userFileManager.FetchOptions = allFetchOp();
let albumFetchFileResult = await album.getPhotoAssets(op);
let albumFilesCount = albumFetchFileResult.getCount();
expect(albumFilesCount).assertEqual(expectAssetNum);
fetchAlbumResult.close();
}
// file info
let asset = await databaseFetchFileResult.getFirstObject();
// trash operation
await asset.trash(true);
let istrash = await asset.isTrash();
console.info(`${testNum} istrash: ${istrash}`);
databaseFetchFileResult = await userfilemgr.getPhotoAssets(databasefFetchOps);
if (isAudio) {
databaseFetchFileResult = await userfilemgr.getAudioAssets(databasefFetchOps);
} else {
databaseFetchFileResult = await userfilemgr.getPhotoAssets(databasefFetchOps);
}
let databaseCount = databaseFetchFileResult.getCount();
databaseFetchFileResult.close()
expect(databaseCount).assertEqual(count - 1);
//album info
if (!noAlbum) {
var fetchAlbumResult = await userfilemgr.getPhotoAlbums(ablumFetchOps);
var album = await fetchAlbumResult.getFirstObject();
let op: userFileManager.FetchOptions = allFetchOp();
var albumFetchFileResult = await album.getPhotoAssets(op);
var albumFilesCount = albumFetchFileResult.getCount();
expect(albumFilesCount).assertEqual(expectAssetNum - 1);
fetchAlbumResult.close();
}
await asset.trash(false);
done();
} catch (error) {
console.info(`${testNum} error: ${error}`);
expect(false).assertTrue();
done();
}
}
async function recovery(done, testNum, databasefFetchOps, ablumFetchOps, noAlbum, isAudio) {
let expectAssetNum = 3;
try {
let databaseFetchFileResult;
if (isAudio) {
databaseFetchFileResult = await userfilemgr.getAudioAssets(databasefFetchOps);
} else {
databaseFetchFileResult = await userfilemgr.getPhotoAssets(databasefFetchOps);
}
let count = databaseFetchFileResult.getCount();
let asset = await databaseFetchFileResult.getFirstObject();
await asset.trash(true);
await asset.trash(false);
if (isAudio) {
databaseFetchFileResult = await userfilemgr.getAudioAssets(databasefFetchOps);
} else {
databaseFetchFileResult = await userfilemgr.getPhotoAssets(databasefFetchOps);
}
let databaseCount = databaseFetchFileResult.getCount();
databaseFetchFileResult.close();
expect(databaseCount).assertEqual(count);
//album info
if (!noAlbum) {
let fetchAlbumResult = await userfilemgr.getPhotoAlbums(ablumFetchOps);
let album = await fetchAlbumResult.getFirstObject();
let op: userFileManager.FetchOptions = allFetchOp();
let albumFetchFileResult = await album.getPhotoAssets(op);
let albumFilesCount = albumFetchFileResult.getCount();
expect(albumFilesCount).assertEqual(expectAssetNum);
fetchAlbumResult.close();
}
done();
} catch (error) {
console.info(`${testNum} error: ${error}`);
expect(false).assertTrue();
done();
}
}
/**
* @tc.number : SUB_USERFILE_MGR_FILEASSET_TRASH_PROMISE_01_001
* @tc.name : isTrash
* @tc.desc : isTrash(image) result false
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_USERFILE_MGR_FILEASSET_TRASH_PROMISE_01_001', 0, async function (done) {
let testNum = 'SUB_USERFILE_MGR_FILEASSET_TRASH_PROMISE_01_001';
let currentFetchOp = imageVideoNameFetchOps(testNum, 'Pictures/trashPro/', '01.jpg');
let isAudio = false;
await isTrashTest(done, testNum, currentFetchOp, isAudio);
});
/**
* @tc.number : SUB_USERFILE_MGR_FILEASSET_TRASH_PROMISE_01_002
* @tc.name : trash
* @tc.desc : trash(image) by true
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_USERFILE_MGR_FILEASSET_TRASH_PROMISE_01_002', 0, async function (done) {
let testNum = 'SUB_USERFILE_MGR_FILEASSET_TRASH_PROMISE_01_002';
let rOps = imageVideoNameFetchOps(testNum, "Pictures/trashPro/", '02.jpg');
let aOps = albumFetchOps(testNum, "Pictures/", "trashPro");
let noAlbum = false;
let isAudio = false;
await setTrash(done, testNum, rOps, aOps, noAlbum, isAudio);
});
/**
* @tc.number : SUB_USERFILE_MGR_FILEASSET_TRASH_PROMISE_01_003
* @tc.name : trash
* @tc.desc : trash(image) by false
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_USERFILE_MGR_FILEASSET_TRASH_PROMISE_01_003', 0, async function (done) {
let testNum = 'SUB_USERFILE_MGR_FILEASSET_TRASH_PROMISE_01_003'
let rOps = imageVideoNameFetchOps(testNum, "Pictures/trashPro/", '03.jpg');
let aOps = albumFetchOps(testNum, "Pictures/", "trashPro");
let noAlbum = false;
let isAudio = false;
await recovery(done, testNum, rOps, aOps, noAlbum, isAudio);
});
/**
* @tc.number : SUB_USERFILE_MGR_FILEASSET_TRASH_PROMISE_02_001
* @tc.name : isTrash
* @tc.desc : isTrash(audio) result false
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_USERFILE_MGR_FILEASSET_TRASH_PROMISE_02_001', 0, async function (done) {
let testNum = 'SUB_USERFILE_MGR_FILEASSET_TRASH_PROMISE_02_001'
let currentFetchOp = audioNameFetchOps(testNum, 'Audios/trashPro/', '01.mp3');
let isAudio = true;
await isTrashTest(done, testNum, currentFetchOp, isAudio)
});
/**
* @tc.number : SUB_USERFILE_MGR_FILEASSET_TRASH_PROMISE_02_002
* @tc.name : trash
* @tc.desc : trash(audio) by true
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_USERFILE_MGR_FILEASSET_TRASH_PROMISE_02_002', 0, async function (done) {
let testNum = 'SUB_USERFILE_MGR_FILEASSET_TRASH_PROMISE_02_002'
let rOps = audioNameFetchOps(testNum, "Audios/trashPro/", '02.mp3');
let aOps = albumFetchOps(testNum, "Audios/", "trashPro");
let noAlbum = true;
let isAudio = true;
await setTrash(done, testNum, rOps, aOps, noAlbum, isAudio);
});
/**
* @tc.number : SUB_USERFILE_MGR_FILEASSET_TRASH_PROMISE_02_003
* @tc.name : trash
* @tc.desc : trash(audio) by false
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_USERFILE_MGR_FILEASSET_TRASH_PROMISE_02_003', 0, async function (done) {
let testNum = 'SUB_USERFILE_MGR_FILEASSET_TRASH_PROMISE_02_003'
let rOps = audioNameFetchOps(testNum, "Audios/trashPro/", '03.mp3');
let aOps = albumFetchOps(testNum, "Audios/", "trashPro");
let noAlbum = true;
let isAudio = true;
await recovery(done, testNum, rOps, aOps, noAlbum, isAudio);
});
/**
* @tc.number : SUB_USERFILE_MGR_FILEASSET_TRASH_PROMISE_03_001
* @tc.name : isTrash
* @tc.desc : isTrash(video) result false
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_USERFILE_MGR_FILEASSET_TRASH_PROMISE_03_001', 0, async function (done) {
let testNum = 'SUB_USERFILE_MGR_FILEASSET_TRASH_PROMISE_03_001'
let currentFetchOp = imageVideoNameFetchOps(testNum, 'Videos/trashPro/', '01.mp4');
let isAudio = false;
await isTrashTest(done, testNum, currentFetchOp, isAudio);
});
/**
* @tc.number : SUB_USERFILE_MGR_FILEASSET_TRASH_PROMISE_03_002
* @tc.name : trash
* @tc.desc : trash(video) by true
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_USERFILE_MGR_FILEASSET_TRASH_PROMISE_03_002', 0, async function (done) {
let testNum = 'SUB_USERFILE_MGR_FILEASSET_TRASH_PROMISE_03_002'
let rOps = imageVideoNameFetchOps(testNum, "Videos/trashPro/", '02.mp4');
let aOps = albumFetchOps(testNum, "Videos/", "trashPro");
let noAlbum = false;
let isAudio = false;
await setTrash(done, testNum, rOps, aOps, noAlbum, isAudio);
});
/**
* @tc.number : SUB_USERFILE_MGR_FILEASSET_TRASH_PROMISE_03_003
* @tc.name : trash
* @tc.desc : trash(video) by false
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_USERFILE_MGR_FILEASSET_TRASH_PROMISE_03_003', 0, async function (done) {
let testNum = 'SUB_USERFILE_MGR_FILEASSET_TRASH_PROMISE_03_003'
let rOps = imageVideoNameFetchOps(testNum, "Videos/trashPro/", '03.mp4');
let aOps = albumFetchOps(testNum, "Videos/", "trashPro");
let noAlbum = false;
let isAudio = false;
await recovery(done, testNum, rOps, aOps, noAlbum, isAudio);
});
});
}
\ No newline at end of file
......@@ -39,6 +39,25 @@ export default function userFileMgrNoPermissionCallback(abilityContext) {
console.info('afterAll case');
});
const getPhotoAlbumsTest = async function (done, testNum) {
try {
await userfilemgr.getPhotoAlbums(allFetchOp(), async (err, fetchAlbumResult) => {
if (err != undefined) {
console.info(`${testNum}, err: ${err}`);
expect(true).assertTrue();
done();
return;
}
expect(false).assertTrue();
done();
})
} catch (error) {
console.info(`${testNum}, failed error: ${error}`)
expect(false).assertTrue();
done();
}
}
const getPhotoAssetsTest = async function (done, testNum) {
try {
await userfilemgr.getPhotoAssets(allFetchOp(), async (err, fetchAssetResult) => {
......@@ -58,9 +77,9 @@ export default function userFileMgrNoPermissionCallback(abilityContext) {
}
}
const getPhotoAlbumsTest = async function (done, testNum) {
const getAudioAssetsTest = async function (done, testNum) {
try {
await userfilemgr.getPhotoAlbums(allFetchOp(), async (err, fetchAlbumResult) => {
await userfilemgr.getAudioAssets(allFetchOp(), async (err, fetchAssetResult) => {
if (err != undefined) {
console.info(`${testNum}, err: ${err}`);
expect(true).assertTrue();
......@@ -78,31 +97,42 @@ export default function userFileMgrNoPermissionCallback(abilityContext) {
}
/**
* @tc.number : SUB_USERFILE_MGR_GETFILEASSETS_NOPERMISSION_CALLBACK_01
* @tc.number : SUB_USERFILE_MGR_GETPHOTOALBUMS_NOPERMISSION_CALLBACK_01
* @tc.name : getPhotoAlbums
* @tc.desc : getPhotoAlbums with no permission
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 1
*/
it('SUB_USERFILE_MGR_GETPHOTOALBUMS_NOPERMISSION_CALLBACK_01', 1, async function (done) {
const testNum = 'SUB_USERFILE_MGR_GETPHOTOALBUMS_NOPERMISSION_CALLBACK_01';
await getPhotoAlbumsTest(done, testNum);
});
/**
* @tc.number : SUB_USERFILE_MGR_GETPHOTOASSETS_NOPERMISSION_CALLBACK_01
* @tc.name : getPhotoAssets
* @tc.desc : getPhotoAssets(image) with no permission
* @tc.desc : getPhotoAssets with no permission
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 1
*/
it('SUB_USERFILE_MGR_GETFILEASSETS_NOPERMISSION_CALLBACK_01', 0, async function (done) {
const testNum = 'SUB_USERFILE_MGR_GETFILEASSETS_NOPERMISSION_CALLBACK_01';
it('SUB_USERFILE_MGR_GETPHOTOASSETS_NOPERMISSION_CALLBACK_01', 1, async function (done) {
const testNum = 'SUB_USERFILE_MGR_GETPHOTOASSETS_NOPERMISSION_CALLBACK_01';
await getPhotoAssetsTest(done, testNum);
});
//--------------------------------------------------------------------------------------
/**
* @tc.number : SUB_USERFILE_MGR_GETPHOTOALBUMS_NOPERMISSION_CALLBACK_01
* @tc.name : getPhotoAlbums
* @tc.desc : getPhotoAlbums with no permission
* @tc.number : SUB_USERFILE_MGR_GETAUDIOASSETS_NOPERMISSION_CALLBACK_01
* @tc.name : getAudioAssets
* @tc.desc : getAudioAssets with no permission
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 1
*/
it('SUB_USERFILE_MGR_GETPHOTOALBUMS_NOPERMISSION_CALLBACK_01', 0, async function (done) {
const testNum = 'SUB_USERFILE_MGR_GETPHOTOALBUMS_NOPERMISSION_CALLBACK_01';
await getPhotoAlbumsTest(done, testNum);
it('SUB_USERFILE_MGR_GETAUDIOASSETS_NOPERMISSION_CALLBACK_01', 1, async function (done) {
const testNum = 'SUB_USERFILE_MGR_GETAUDIOASSETS_NOPERMISSION_CALLBACK_01';
await getAudioAssetsTest(done, testNum);
});
});
}
......
......@@ -39,6 +39,18 @@ export default function userFileMgrNoPermissionPromise(abilityContext) {
console.info('afterAll case');
});
const getPhotoAlbumsTest = async function (done, testNum) {
try {
await userfilemgr.getPhotoAlbums(allFetchOp());
expect(false).assertTrue();
done();
} catch (error) {
console.info(`${testNum}, failed error: ${error}`)
expect(true).assertTrue();
done();
}
}
const getPhotoAssetsTest = async function (done, testNum) {
try {
await userfilemgr.getPhotoAssets(allFetchOp());
......@@ -51,9 +63,9 @@ export default function userFileMgrNoPermissionPromise(abilityContext) {
}
}
const getPhotoAlbumsTest = async function (done, testNum) {
const getAudioAssetsTest = async function (done, testNum) {
try {
await userfilemgr.getPhotoAlbums(allFetchOp());
await userfilemgr.getAudioAssets(allFetchOp());
expect(false).assertTrue();
done();
} catch (error) {
......@@ -64,31 +76,42 @@ export default function userFileMgrNoPermissionPromise(abilityContext) {
}
/**
* @tc.number : SUB_USERFILE_MGR_GETFILEASSETS_NOPERMISSION_PROMISE_01
* @tc.number : SUB_USERFILE_MGR_GETALBUMS_NOPERMISSION_PROMISE_01
* @tc.name : getPhotoAlbums
* @tc.desc : getPhotoAlbums with no permission
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 1
*/
it('SUB_USERFILE_MGR_GETALBUMS_NOPERMISSION_PROMISE_01', 1, async function (done) {
const testNum = 'SUB_USERFILE_MGR_GETALBUMS_NOPERMISSION_PROMISE_01';
await getPhotoAlbumsTest(done, testNum);
});
/**
* @tc.number : SUB_USERFILE_MGR_GETPHOTOASSETS_NOPERMISSION_PROMISE_01
* @tc.name : getPhotoAssets
* @tc.desc : getPhotoAssets(image) with no permission
* @tc.desc : getPhotoAssets with no permission
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 1
*/
it('SUB_USERFILE_MGR_GETFILEASSETS_NOPERMISSION_PROMISE_01', 0, async function (done) {
const testNum = 'SUB_USERFILE_MGR_GETFILEASSETS_NOPERMISSION_PROMISE_01';
it('SUB_USERFILE_MGR_GETPHOTOASSETS_NOPERMISSION_PROMISE_01', 1, async function (done) {
const testNum = 'SUB_USERFILE_MGR_GETPHOTOASSETS_NOPERMISSION_PROMISE_01';
await getPhotoAssetsTest(done, testNum);
});
//--------------------------------------------------------------------------------------
/**
* @tc.number : SUB_USERFILE_MGR_GETALBUMS_NOPERMISSION_PROMISE_01
* @tc.name : getPhotoAlbums
* @tc.desc : getPhotoAlbums with no permission
* @tc.number : SUB_USERFILE_MGR_GETAUDIOASSETS_NOPERMISSION_PROMISE_01
* @tc.name : getAudioAssets
* @tc.desc : getAudioAssets with no permission
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
* @tc.level : Level 1
*/
it('SUB_USERFILE_MGR_GETALBUMS_NOPERMISSION_PROMISE_01', 0, async function (done) {
const testNum = 'SUB_USERFILE_MGR_GETALBUMS_NOPERMISSION_PROMISE_01';
await getPhotoAlbumsTest(done, testNum);
it('SUB_USERFILE_MGR_GETAUDIOASSETS_NOPERMISSION_PROMISE_01', 1, async function (done) {
const testNum = 'SUB_USERFILE_MGR_GETAUDIOASSETS_NOPERMISSION_PROMISE_01';
await getAudioAssetsTest(done, testNum);
});
});
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册