提交 34f7d612 编写于 作者: Y yangbo
上级 5afdefe5
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
import userFileManager from '@ohos.filemanagement.userFileManager'; import userFileManager from '@ohos.filemanagement.userFileManager';
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'; import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index';
import dataSharePredicates from '@ohos.data.dataSharePredicates';
import { import {
sleep, sleep,
...@@ -50,11 +51,24 @@ export default function albumCommitModifyCallback(abilityContext) { ...@@ -50,11 +51,24 @@ export default function albumCommitModifyCallback(abilityContext) {
const albumCountPass = await checkAssetsCount(done, testNum, fetchAlbumResult, expectAlbumCount); const albumCountPass = await checkAssetsCount(done, testNum, fetchAlbumResult, expectAlbumCount);
if (!albumCountPass) return; if (!albumCountPass) return;
const album = await fetchAlbumResult.getFirstObject(); const album = await fetchAlbumResult.getFirstObject();
const oldName = album.albumName;
const albumUri = album.albumUri;
const newName = 'newAlbumNameCallback'; const newName = 'newAlbumNameCallback';
fetchAlbumResult.close(); fetchAlbumResult.close();
album.albumName = newName; album.albumName = newName;
album.commitModify(async () => { album.commitModify(async () => {
expect(true).assertTrue(); let predicates = new dataSharePredicates.DataSharePredicates();
predicates.equalTo(userFileManager.AlbumKey.URI.toString(), albumUri);
let ops = {
predicates: predicates
};
const newResult = await userfilemgr.getPhotoAlbums(ops);
const albumCountPass = await checkAssetsCount(done, testNum, newResult, expectAlbumCount);
if (!albumCountPass) return;
const newAlbum = await newResult.getFirstObject();
expect(newAlbum.albumName).assertEqual(newName);
newAlbum.albumName = oldName;
await newAlbum.commitModify();
done(); done();
}); });
} catch (error) { } catch (error) {
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
import userFileManager from '@ohos.filemanagement.userFileManager'; import userFileManager from '@ohos.filemanagement.userFileManager';
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'; import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index';
import dataSharePredicates from '@ohos.data.dataSharePredicates';
import { import {
sleep, sleep,
...@@ -50,11 +51,24 @@ export default function albumCommitModifyPromise(abilityContext) { ...@@ -50,11 +51,24 @@ export default function albumCommitModifyPromise(abilityContext) {
const albumCountPass = await checkAssetsCount(done, testNum, fetchAlbumResult, expectAlbumCount); const albumCountPass = await checkAssetsCount(done, testNum, fetchAlbumResult, expectAlbumCount);
if (!albumCountPass) return; if (!albumCountPass) return;
const album = await fetchAlbumResult.getFirstObject(); const album = await fetchAlbumResult.getFirstObject();
const oldName = album.albumName;
const albumUri = album.albumUri;
const newName = 'newAlbumNamePromise'; const newName = 'newAlbumNamePromise';
fetchAlbumResult.close(); fetchAlbumResult.close();
album.albumName = newName; album.albumName = newName;
await album.commitModify(); await album.commitModify();
expect(true).assertTrue(); let predicates = new dataSharePredicates.DataSharePredicates();
predicates.equalTo(userFileManager.AlbumKey.URI.toString(), albumUri);
let ops = {
predicates: predicates
};
const newResult = await userfilemgr.getPhotoAlbums(ops);
const checkAlbumCountPass = await checkAssetsCount(done, testNum, newResult, expectAlbumCount);
if (!checkAlbumCountPass) return;
const newAlbum = await newResult.getFirstObject();
expect(newAlbum.albumName).assertEqual(newName);
newAlbum.albumName = oldName;
await newAlbum.commitModify();
done(); done();
} catch (error) { } catch (error) {
console.info(`${testNum}, failed error: ${error}`) console.info(`${testNum}, failed error: ${error}`)
......
...@@ -31,9 +31,9 @@ ...@@ -31,9 +31,9 @@
{ {
"type": "ShellKit", "type": "ShellKit",
"run-command": [ "run-command": [
"mkdir -pv /storage/media/100/local/files/Pictures/{Static,On,Off,myAlbum,deleteCb,deletePro}", "mkdir -pv /storage/media/100/local/files/Pictures/{Static,onAsset,offAsset,onAlbum,offAlbum,myAlbum,deleteCb,deletePro}",
"mkdir -pv /storage/media/100/local/files/Videos/{Static,On,Off,myAlbum,deleteCb,deletePro}", "mkdir -pv /storage/media/100/local/files/Videos/{Static,onAsset,offAsset,onAlbum,offAlbum,myAlbum,deleteCb,deletePro}",
"mkdir -pv /storage/media/100/local/files/Audios/{Static,On,Off,myAlbum,deleteCb,deletePro}", "mkdir -pv /storage/media/100/local/files/Audios/{Static,onAsset,offAsset,onAlbum,offAlbum,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.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.mp3 /storage/media/100/local/files/Audios/$$d/0$$i.mp3; done;done;",
...@@ -41,9 +41,9 @@ ...@@ -41,9 +41,9 @@
"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.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.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 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 onAsset offAsset onAlbum offAlbum 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 onAsset offAsset onAlbum offAlbum 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;", "for d in onAsset offAsset onAlbum offAlbum 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;",
"chmod -R 777 /storage/media/100/local/files/*", "chmod -R 777 /storage/media/100/local/files/*",
"chmod -R 777 /data/service/el2/100/hmdfs/account/files/*", "chmod -R 777 /data/service/el2/100/hmdfs/account/files/*",
......
...@@ -18,8 +18,8 @@ import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from ...@@ -18,8 +18,8 @@ import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from
import { import {
sleep, sleep,
audioFetchOps, audioNameFetchOps,
imageVideoFetchOps, imageVideoNameFetchOps,
checkPresetsAssets, checkPresetsAssets,
checkAssetsCount, checkAssetsCount,
albumFetchOps, albumFetchOps,
...@@ -106,7 +106,7 @@ export default function onOffReleasePromiseTest(abilityContext) { ...@@ -106,7 +106,7 @@ export default function onOffReleasePromiseTest(abilityContext) {
*/ */
it('SUB_USERFILE_MGR_ON_01', 2, async function (done) { it('SUB_USERFILE_MGR_ON_01', 2, async function (done) {
let testNum = 'SUB_USERFILE_MGR_ON_01'; let testNum = 'SUB_USERFILE_MGR_ON_01';
let currentFetchOps = imageVideoFetchOps(testNum, 'Pictures/On/'); let currentFetchOps = imageVideoNameFetchOps(testNum, 'Pictures/onAsset/', '01.jpg');
let type = 'imageChange'; let type = 'imageChange';
let newName = 'imageChange.jpg'; let newName = 'imageChange.jpg';
let isAudio = false; let isAudio = false;
...@@ -123,7 +123,7 @@ export default function onOffReleasePromiseTest(abilityContext) { ...@@ -123,7 +123,7 @@ export default function onOffReleasePromiseTest(abilityContext) {
*/ */
it('SUB_USERFILE_MGR_ON_02', 2, async function (done) { it('SUB_USERFILE_MGR_ON_02', 2, async function (done) {
let testNum = 'SUB_USERFILE_MGR_ON_02'; let testNum = 'SUB_USERFILE_MGR_ON_02';
let currentFetchOps = imageVideoFetchOps(testNum, 'Videos/On/'); let currentFetchOps = imageVideoNameFetchOps(testNum, 'Videos/onAsset/', '01.mp4');
let type = 'videoChange'; let type = 'videoChange';
let newName = 'videoChange.mp4'; let newName = 'videoChange.mp4';
let isAudio = false; let isAudio = false;
...@@ -140,7 +140,7 @@ export default function onOffReleasePromiseTest(abilityContext) { ...@@ -140,7 +140,7 @@ export default function onOffReleasePromiseTest(abilityContext) {
*/ */
it('SUB_USERFILE_MGR_ON_03', 2, async function (done) { it('SUB_USERFILE_MGR_ON_03', 2, async function (done) {
let testNum = 'SUB_USERFILE_MGR_ON_03'; let testNum = 'SUB_USERFILE_MGR_ON_03';
let currentFetchOps = audioFetchOps(testNum, 'Audios/On/'); let currentFetchOps = audioNameFetchOps(testNum, 'Audios/onAsset/', '01.mp3');
let type = 'audioChange'; let type = 'audioChange';
let newName = 'audioChange.mp3'; let newName = 'audioChange.mp3';
let isAudio = true; let isAudio = true;
...@@ -155,10 +155,10 @@ export default function onOffReleasePromiseTest(abilityContext) { ...@@ -155,10 +155,10 @@ export default function onOffReleasePromiseTest(abilityContext) {
* @tc.type : Function * @tc.type : Function
* @tc.level : Level 2 * @tc.level : Level 2
*/ */
it('SUB_USERFILE_MGR_ON_04', 2, async function (done) { it('SUB_USERFILE_MGR_ON_04', 2, async function (done) {
let testNum = 'SUB_USERFILE_MGR_ON_04'; let testNum = 'SUB_USERFILE_MGR_ON_04';
try { try {
let currentFetchOps = albumFetchOps(testNum, 'Pictures/', 'On'); let currentFetchOps = albumFetchOps(testNum, 'Pictures/', 'onAlbum');
let type: userFileManager.ChangeEvent = 'albumChange'; let type: userFileManager.ChangeEvent = 'albumChange';
let count = 0; let count = 0;
userfilemgr.on(type, () => { count++; }); userfilemgr.on(type, () => { count++; });
...@@ -173,7 +173,7 @@ export default function onOffReleasePromiseTest(abilityContext) { ...@@ -173,7 +173,7 @@ export default function onOffReleasePromiseTest(abilityContext) {
await sleep(1000); await sleep(1000);
expect(count > 0).assertTrue(); expect(count > 0).assertTrue();
album.albumName = oldName; album.albumName = oldName;
await album.commitModify(); await album.commitModify();
done(); done();
} catch (error) { } catch (error) {
console.info(`${testNum}:: error :${error}`); console.info(`${testNum}:: error :${error}`);
...@@ -192,7 +192,7 @@ export default function onOffReleasePromiseTest(abilityContext) { ...@@ -192,7 +192,7 @@ export default function onOffReleasePromiseTest(abilityContext) {
*/ */
it('SUB_USERFILE_MGR_OFF_01', 2, async function (done) { it('SUB_USERFILE_MGR_OFF_01', 2, async function (done) {
let testNum = 'SUB_USERFILE_MGR_OFF_01'; let testNum = 'SUB_USERFILE_MGR_OFF_01';
let currentFetchOps = imageVideoFetchOps(testNum, 'Pictures/Off/'); let currentFetchOps = imageVideoNameFetchOps(testNum, 'Pictures/offAsset/', '01.jpg');
let type = 'imageChange'; let type = 'imageChange';
let newName = 'imageChange.jpg'; let newName = 'imageChange.jpg';
let isAudio = false; let isAudio = false;
...@@ -209,7 +209,7 @@ export default function onOffReleasePromiseTest(abilityContext) { ...@@ -209,7 +209,7 @@ export default function onOffReleasePromiseTest(abilityContext) {
*/ */
it('SUB_USERFILE_MGR_OFF_02', 2, async function (done) { it('SUB_USERFILE_MGR_OFF_02', 2, async function (done) {
let testNum = 'SUB_USERFILE_MGR_OFF_02'; let testNum = 'SUB_USERFILE_MGR_OFF_02';
let currentFetchOps = imageVideoFetchOps(testNum, 'Videos/Off/'); let currentFetchOps = imageVideoNameFetchOps(testNum, 'Videos/offAsset/', '01.mp4');
let type = 'videoChange'; let type = 'videoChange';
let newName = 'videoChange.mp4'; let newName = 'videoChange.mp4';
let isAudio = false; let isAudio = false;
...@@ -226,7 +226,7 @@ export default function onOffReleasePromiseTest(abilityContext) { ...@@ -226,7 +226,7 @@ export default function onOffReleasePromiseTest(abilityContext) {
*/ */
it('SUB_USERFILE_MGR_OFF_03', 2, async function (done) { it('SUB_USERFILE_MGR_OFF_03', 2, async function (done) {
let testNum = 'SUB_USERFILE_MGR_OFF_03'; let testNum = 'SUB_USERFILE_MGR_OFF_03';
let currentFetchOps = audioFetchOps(testNum, 'Audios/Off/'); let currentFetchOps = audioNameFetchOps(testNum, 'Audios/offAsset/', '01.mp3');
let type = 'audioChange'; let type = 'audioChange';
let newName = 'audioChange.mp3'; let newName = 'audioChange.mp3';
let isAudio = true; let isAudio = true;
...@@ -241,10 +241,10 @@ export default function onOffReleasePromiseTest(abilityContext) { ...@@ -241,10 +241,10 @@ export default function onOffReleasePromiseTest(abilityContext) {
* @tc.type : Function * @tc.type : Function
* @tc.level : Level 2 * @tc.level : Level 2
*/ */
it('SUB_USERFILE_MGR_OFF_04', 2, async function (done) { it('SUB_USERFILE_MGR_OFF_04', 2, async function (done) {
let testNum = 'SUB_USERFILE_MGR_OFF_04'; let testNum = 'SUB_USERFILE_MGR_OFF_04';
try { try {
let currentFetchOps = albumFetchOps(testNum, 'Pictures/', 'Off'); let currentFetchOps = albumFetchOps(testNum, 'Pictures/', 'offAlbum');
let type: userFileManager.ChangeEvent = 'albumChange'; let type: userFileManager.ChangeEvent = 'albumChange';
let count = 0; let count = 0;
userfilemgr.on(type, () => { count++; }); userfilemgr.on(type, () => { count++; });
...@@ -252,12 +252,15 @@ export default function onOffReleasePromiseTest(abilityContext) { ...@@ -252,12 +252,15 @@ export default function onOffReleasePromiseTest(abilityContext) {
let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchAlbumResult, 1); let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchAlbumResult, 1);
if (!checkAssetCountPass) return; if (!checkAssetCountPass) return;
const album = await fetchAlbumResult.getFirstObject(); const album = await fetchAlbumResult.getFirstObject();
const oldName = album.albumName
fetchAlbumResult.close(); fetchAlbumResult.close();
album.albumName = type.toString(); album.albumName = type.toString();
userfilemgr.off(type); userfilemgr.off(type);
await album.commitModify(); await album.commitModify();
await sleep(1000); await sleep(1000);
expect(count).assertEqual(0); expect(count).assertEqual(0);
album.albumName = oldName;
await album.commitModify();
done(); done();
} catch (error) { } catch (error) {
console.info(`${testNum}:: error :${error}`); console.info(`${testNum}:: error :${error}`);
......
...@@ -31,9 +31,9 @@ ...@@ -31,9 +31,9 @@
{ {
"type": "ShellKit", "type": "ShellKit",
"run-command": [ "run-command": [
"mkdir -pv /storage/media/100/local/files/Pictures/{ModifyCb,ModifyPro,FavCb,FavPro,Thumbnail,Static,R_Cb,W_Cb,RW_Cb,R_Pro,W_Pro,RW_Pro,openClose,trashCb,trashPro}", "mkdir -pv /storage/media/100/local/files/Pictures/{ModifyCb,ModifyPro,FavCb,FavPro,Thumbnail,FileKey,R_Cb,W_Cb,RW_Cb,R_Pro,W_Pro,RW_Pro,openClose,trashCb,trashPro}",
"mkdir -pv /storage/media/100/local/files/Videos/{ModifyCb,ModifyPro,FavCb,FavPro,Thumbnail,Static,R_Cb,W_Cb,RW_Cb,R_Pro,W_Pro,RW_Pro,openClose,trashCb,trashPro}", "mkdir -pv /storage/media/100/local/files/Videos/{ModifyCb,ModifyPro,FavCb,FavPro,Thumbnail,FileKey,R_Cb,W_Cb,RW_Cb,R_Pro,W_Pro,RW_Pro,openClose,trashCb,trashPro}",
"mkdir -pv /storage/media/100/local/files/Audios/{ModifyCb,ModifyPro,FavCb,FavPro,Thumbnail,Static,R_Cb,W_Cb,RW_Cb,R_Pro,W_Pro,RW_Pro,openClose,trashCb,trashPro}", "mkdir -pv /storage/media/100/local/files/Audios/{ModifyCb,ModifyPro,FavCb,FavPro,Thumbnail,FileKey,R_Cb,W_Cb,RW_Cb,R_Pro,W_Pro,RW_Pro,openClose,trashCb,trashPro}",
"for d in FavCb FavPro trashCb trashPro; do for i in $$(seq 3); do cp /storage/media/100/local/temp/01.jpg /storage/media/100/local/files/Pictures/$$d/0$$i.jpg; done;done;", "for d in FavCb FavPro trashCb trashPro; do for i in $$(seq 3); do cp /storage/media/100/local/temp/01.jpg /storage/media/100/local/files/Pictures/$$d/0$$i.jpg; done;done;",
"for d in FavCb FavPro trashCb trashPro; do for i in $$(seq 3); do cp /storage/media/100/local/temp/01.mp3 /storage/media/100/local/files/Audios/$$d/0$$i.mp3; done;done;", "for d in FavCb FavPro trashCb trashPro; do for i in $$(seq 3); do cp /storage/media/100/local/temp/01.mp3 /storage/media/100/local/files/Audios/$$d/0$$i.mp3; done;done;",
...@@ -43,10 +43,10 @@ ...@@ -43,10 +43,10 @@
"for d in Thumbnail openClose W_Cb RW_Cb W_Pro RW_Pro; 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 Thumbnail openClose W_Cb RW_Cb W_Pro RW_Pro; 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 Thumbnail openClose W_Cb RW_Cb W_Pro RW_Pro; 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 Thumbnail openClose W_Cb RW_Cb W_Pro RW_Pro; 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 ModifyCb ModifyPro Static R_Cb R_Pro; 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 ModifyCb ModifyPro FileKey R_Cb R_Pro; 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 ModifyCb ModifyPro Static R_Cb R_Pro; 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 ModifyCb ModifyPro FileKey R_Cb R_Pro; 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 ModifyCb ModifyPro Static R_Cb R_Pro; 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;", "for d in ModifyCb ModifyPro FileKey R_Cb R_Pro; 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;",
"chmod -R 777 /storage/media/100/local/files/*", "chmod -R 777 /storage/media/100/local/files/*",
"chmod -R 777 /data/service/el2/100/hmdfs/account/files/*", "chmod -R 777 /data/service/el2/100/hmdfs/account/files/*",
"hilog -Q pidoff", "hilog -Q pidoff",
......
...@@ -86,10 +86,8 @@ export default function fileAssetCommitModifyCallbackTest(abilityContext) { ...@@ -86,10 +86,8 @@ export default function fileAssetCommitModifyCallbackTest(abilityContext) {
let checkAssetCountPass = await checkAssetsCount(done, testNum, newResult, 1); let checkAssetCountPass = await checkAssetsCount(done, testNum, newResult, 1);
if (!checkAssetCountPass) return; if (!checkAssetCountPass) return;
const newAsset = await newResult.getFirstObject(); const newAsset = await newResult.getFirstObject();
console.info(`${testNum} newAsset : ${newAsset}`)
newResult.close(); newResult.close();
expect(newAsset.get(fileKey.DISPLAY_NAME)).assertEqual(val); expect(newAsset.get(fileKey.TITLE)).assertEqual(val);
console.info(`${testNum} DISPLAY_NAME : ${newAsset.get(fileKey.DISPLAY_NAME)}`)
done(); done();
}); });
} catch (error) { } catch (error) {
......
...@@ -52,7 +52,7 @@ export default function fileAssetCommitModifyPromiseTest(abilityContext) { ...@@ -52,7 +52,7 @@ export default function fileAssetCommitModifyPromiseTest(abilityContext) {
let fileKey; let fileKey;
if (isAudio) { if (isAudio) {
fetchAssetResult = await userfilemgr.getAudioAssets(fetchOp); fetchAssetResult = await userfilemgr.getAudioAssets(fetchOp);
fileKey.userFileManager.AudioKey; fileKey = userFileManager.AudioKey;
} else { } else {
fetchAssetResult = await userfilemgr.getPhotoAssets(fetchOp); fetchAssetResult = await userfilemgr.getPhotoAssets(fetchOp);
fileKey = userFileManager.ImageVideoKey; fileKey = userFileManager.ImageVideoKey;
...@@ -78,10 +78,8 @@ export default function fileAssetCommitModifyPromiseTest(abilityContext) { ...@@ -78,10 +78,8 @@ export default function fileAssetCommitModifyPromiseTest(abilityContext) {
checkAssetCountPass = await checkAssetsCount(done, testNum, newResult, 1); checkAssetCountPass = await checkAssetsCount(done, testNum, newResult, 1);
if (!checkAssetCountPass) return; if (!checkAssetCountPass) return;
const newAsset = await newResult.getFirstObject(); const newAsset = await newResult.getFirstObject();
console.info(`${testNum} newAsset : ${newAsset}`)
newResult.close(); newResult.close();
expect(newAsset.get(fileKey.DISPLAY_NAME)).assertEqual(val); expect(newAsset.get(fileKey.TITLE)).assertEqual(val);
console.info(`${testNum} DISPLAY_NAME : ${newAsset.get(fileKey.DISPLAY_NAME)}`)
done(); done();
} catch (error) { } catch (error) {
console.info(`${testNum} error : ${error}`); console.info(`${testNum} error : ${error}`);
......
...@@ -51,7 +51,7 @@ export default function fileAssetFileKeyTest(abilityContext) { ...@@ -51,7 +51,7 @@ export default function fileAssetFileKeyTest(abilityContext) {
const getAlbumsByKey = async function (done, testNum, type, fileKey) { const getAlbumsByKey = async function (done, testNum, type, fileKey) {
try { try {
let expectAlbumNum = 1; let expectAlbumNum = 1;
let fetchOps = albumFetchOps(testNum, 'Pictures/', 'Static'); let fetchOps = albumFetchOps(testNum, 'Pictures/', 'FileKey');
let fetchAlbumResult = await userfilemgr.getPhotoAlbums(fetchOps); let fetchAlbumResult = await userfilemgr.getPhotoAlbums(fetchOps);
let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchAlbumResult, expectAlbumNum); let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchAlbumResult, expectAlbumNum);
if (!checkAssetCountPass) return; if (!checkAssetCountPass) return;
...@@ -73,10 +73,13 @@ export default function fileAssetFileKeyTest(abilityContext) { ...@@ -73,10 +73,13 @@ export default function fileAssetFileKeyTest(abilityContext) {
return; return;
} }
const fetchCount = newAlbumResult.getCount(); const fetchCount = newAlbumResult.getCount();
if (fetchCount <= 0) {
expect(false).assertTrue();
done();
return;
}
const currentAlbum = await newAlbumResult.getFirstObject(); const currentAlbum = await newAlbumResult.getFirstObject();
expect(currentAlbum[type]).assertEqual(album[type]); expect(currentAlbum[type]).assertEqual(album[type]);
expect(fetchCount > 0).assertTrue();
console.info(`${testNum} newAlbum : ${currentAlbum[type]} count: ${fetchCount}`)
newAlbumResult.close(); newAlbumResult.close();
done(); done();
}); });
...@@ -90,7 +93,7 @@ export default function fileAssetFileKeyTest(abilityContext) { ...@@ -90,7 +93,7 @@ export default function fileAssetFileKeyTest(abilityContext) {
const getPhotoAssetsByKey = async function (done, testNum, fileKey) { const getPhotoAssetsByKey = async function (done, testNum, fileKey) {
try { try {
let expectAssetNum = 1; let expectAssetNum = 1;
let fetchOps = imageVideoFetchOps(testNum, 'Pictures/Static/'); let fetchOps = imageVideoFetchOps(testNum, 'Pictures/FileKey/');
let fetchAssetResult = await userfilemgr.getPhotoAssets(fetchOps); let fetchAssetResult = await userfilemgr.getPhotoAssets(fetchOps);
let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchAssetResult, expectAssetNum); let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchAssetResult, expectAssetNum);
if (!checkAssetCountPass) return; if (!checkAssetCountPass) return;
...@@ -112,9 +115,13 @@ export default function fileAssetFileKeyTest(abilityContext) { ...@@ -112,9 +115,13 @@ export default function fileAssetFileKeyTest(abilityContext) {
return; return;
} }
const fetchCount = newAssetResult.getCount(); const fetchCount = newAssetResult.getCount();
if (fetchCount <= 0) {
expect(false).assertTrue();
done();
return;
}
const currentAsset = await newAssetResult.getFirstObject(); const currentAsset = await newAssetResult.getFirstObject();
expect(currentAsset.get(fileKey)).assertEqual(asset.get(fileKey)); expect(currentAsset.get(fileKey)).assertEqual(asset.get(fileKey));
expect(fetchCount > 0).assertTrue();
done(); done();
}); });
} catch (error) { } catch (error) {
...@@ -127,7 +134,7 @@ export default function fileAssetFileKeyTest(abilityContext) { ...@@ -127,7 +134,7 @@ export default function fileAssetFileKeyTest(abilityContext) {
const getAudioAssetsByKey = async function (done, testNum, fileKey) { const getAudioAssetsByKey = async function (done, testNum, fileKey) {
try { try {
let expectAssetNum = 1; let expectAssetNum = 1;
let fetchOps = audioFetchOps(testNum, 'Audios/Static/'); let fetchOps = audioFetchOps(testNum, 'Audios/FileKey/');
let fetchAssetResult = await userfilemgr.getAudioAssets(fetchOps); let fetchAssetResult = await userfilemgr.getAudioAssets(fetchOps);
let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchAssetResult, expectAssetNum); let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchAssetResult, expectAssetNum);
if (!checkAssetCountPass) return; if (!checkAssetCountPass) return;
...@@ -148,9 +155,13 @@ export default function fileAssetFileKeyTest(abilityContext) { ...@@ -148,9 +155,13 @@ export default function fileAssetFileKeyTest(abilityContext) {
return; return;
} }
const fetchCount = newAssetResult.getCount(); const fetchCount = newAssetResult.getCount();
if (fetchCount <= 0) {
expect(false).assertTrue();
done();
return;
}
const currentAsset = await newAssetResult.getFirstObject(); const currentAsset = await newAssetResult.getFirstObject();
expect(currentAsset.get(fileKey)).assertEqual(asset.get(fileKey)); expect(currentAsset.get(fileKey)).assertEqual(asset.get(fileKey));
expect(fetchCount > 0).assertTrue();
done(); done();
}); });
} catch (error) { } catch (error) {
...@@ -168,7 +179,7 @@ export default function fileAssetFileKeyTest(abilityContext) { ...@@ -168,7 +179,7 @@ export default function fileAssetFileKeyTest(abilityContext) {
* @tc.type : Function * @tc.type : Function
* @tc.level : Level 2 * @tc.level : Level 2
*/ */
it('SUB_USERFILE_MGR_GETPHOTOALBUMSBYKEY_01', 2, async function (done) { it('SUB_USERFILE_MGR_GETPHOTOALBUMSBYKEY_01', 2, async function (done) {
let testNum = 'SUB_USERFILE_MGR_GETPHOTOALBUMSBYKEY_01'; let testNum = 'SUB_USERFILE_MGR_GETPHOTOALBUMSBYKEY_01';
let type = 'albumUri'; let type = 'albumUri';
let fileKey = AlbumKey.URI; let fileKey = AlbumKey.URI;
...@@ -183,7 +194,7 @@ export default function fileAssetFileKeyTest(abilityContext) { ...@@ -183,7 +194,7 @@ export default function fileAssetFileKeyTest(abilityContext) {
* @tc.type : Function * @tc.type : Function
* @tc.level : Level 2 * @tc.level : Level 2
*/ */
it('SUB_USERFILE_MGR_GETPHOTOALBUMSBYKEY_02', 2, async function (done) { it('SUB_USERFILE_MGR_GETPHOTOALBUMSBYKEY_02', 2, async function (done) {
let testNum = 'SUB_USERFILE_MGR_GETPHOTOALBUMSBYKEY_02'; let testNum = 'SUB_USERFILE_MGR_GETPHOTOALBUMSBYKEY_02';
let type = 'fileType'; let type = 'fileType';
let fileKey = AlbumKey.FILE_TYPE; let fileKey = AlbumKey.FILE_TYPE;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册