提交 85cebab4 编写于 作者: C caochuan

补充修改displayname长度测试用例

Signed-off-by: Ncaochuan <caochuan@huawei.com>
上级 63fc2591
...@@ -17,11 +17,11 @@ import abilityAccessCtrl from '@ohos.abilityAccessCtrl'; ...@@ -17,11 +17,11 @@ import abilityAccessCtrl from '@ohos.abilityAccessCtrl';
import bundle from '@ohos.bundle'; import bundle from '@ohos.bundle';
const presetsCount = { const presetsCount = {
ActsMediaLibraryAlbumTest: { albumsCount: 7, assetsCount: 19 }, ActsMediaLibraryAlbumTest: { albumsCount: 15, assetsCount: 27 },
ActsMediaLibraryBaseTest: { albumsCount: 11, assetsCount: 14 }, ActsMediaLibraryBaseTest: { albumsCount: 11, assetsCount: 14 },
ActsMediaLibraryFavoriteTest: { albumsCount: 6, assetsCount: 32 }, ActsMediaLibraryFavoriteTest: { albumsCount: 6, assetsCount: 32 },
ActsMediaLibraryFileTest: { albumsCount: 6, assetsCount: 28 }, ActsMediaLibraryFileTest: { albumsCount: 6, assetsCount: 28 },
ActsMediaLibraryFileAssetTest: { albumsCount: 27, assetsCount: 100 }, ActsMediaLibraryFileAssetTest: { albumsCount: 27, assetsCount: 116 },
ActsMediaLibraryFileKeyTest: { albumsCount: 2, assetsCount: 2 }, ActsMediaLibraryFileKeyTest: { albumsCount: 2, assetsCount: 2 },
ActsMediaLibraryFileResultTest: { albumsCount: 3, assetsCount: 112 }, ActsMediaLibraryFileResultTest: { albumsCount: 3, assetsCount: 112 },
ActsMediaLibraryGetThumbnailTest: { albumsCount: 3, assetsCount: 3 }, ActsMediaLibraryGetThumbnailTest: { albumsCount: 3, assetsCount: 3 },
......
...@@ -31,15 +31,17 @@ ...@@ -31,15 +31,17 @@
{ {
"type": "ShellKit", "type": "ShellKit",
"run-command": [ "run-command": [
"mkdir -pv /storage/media/100/local/files/Pictures/{Static,DynamicPro1,DynamicPro2,DynamicCb1,DynamicCb2}", "mkdir -pv /storage/media/100/local/files/Pictures/Static",
"mkdir -pv /storage/media/100/local/files/Videos/Static", "mkdir -pv /storage/media/100/local/files/Videos/Static",
"mkdir -pv /storage/media/100/local/files/Audios/Static", "mkdir -pv /storage/media/100/local/files/Audios/Static",
"for i in $$(seq 6); do mkdir -pv /storage/media/100/local/files/Pictures/DynamicPro$$i; done;",
"for i in $$(seq 6); do mkdir -pv /storage/media/100/local/files/Pictures/DynamicCb$$i; done;",
"for d in Static; do for i in $$(seq 5); 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 5); 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 5); 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 5); 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 5); do cp /storage/media/100/local/temp/01.mp4 /storage/media/100/local/files/Videos/$$d/0$$i.mp4; done;done;", "for d in Static; do for i in $$(seq 5); do cp /storage/media/100/local/temp/01.mp4 /storage/media/100/local/files/Videos/$$d/0$$i.mp4; done;done;",
"for d in DynamicPro1 DynamicPro2 DynamicCb1 DynamicCb2; do cp /storage/media/100/local/temp/01.jpg /storage/media/100/local/files/Pictures/$$d ;done;", "for d in DynamicPro1 DynamicPro2 DynamicPro3 DynamicPro4 DynamicPro5 DynamicPro6 DynamicCb1 DynamicCb2 DynamicCb3 DynamicCb4 DynamicCb5 DynamicCb6; do cp /storage/media/100/local/temp/01.jpg /storage/media/100/local/files/Pictures/$$d ;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/*",
......
...@@ -144,8 +144,14 @@ export default function albumTestCallbackTest(abilityContext) { ...@@ -144,8 +144,14 @@ export default function albumTestCallbackTest(abilityContext) {
const album = albumList[0]; const album = albumList[0];
album.albumName = newName; album.albumName = newName;
album.commitModify(async (error) => { album.commitModify(async (error) => {
console.info(`${testNum}, error.message: ${error.message} error.code: ${error.code}`) if(error) {
expect(error.code != undefined).assertTrue(); console.info(`${testNum}, error.message: ${error.message} error.code: ${error.code}`)
expect(error.code != undefined).assertTrue();
done();
return;
}
console.info(`${testNum}, commitModify error`)
expect(false).assertTrue();
done(); done();
}); });
} catch (error) { } catch (error) {
...@@ -154,6 +160,33 @@ export default function albumTestCallbackTest(abilityContext) { ...@@ -154,6 +160,33 @@ export default function albumTestCallbackTest(abilityContext) {
done(); done();
} }
} }
const albumCommitModify = async function (done, testNum, fetchOp, newName, expectAlbumCount) {
try {
const albumList = await media.getAlbums(fetchOp);
const albumCountPass = await checkAlbumsCount(done, testNum, albumList, expectAlbumCount);
if (!albumCountPass) return;
const album = albumList[0];
const albumId = album.albumId;
console.info(`${testNum}, album.albumName(old): ${album.albumName}`)
const oldAlbumName = album.albumName;
album.albumName = newName;
album.commitModify(async () => {
let currentfetchOp = idFetchOps(testNum, albumId)
const newAlbumList = await media.getAlbums(currentfetchOp);
console.info(`${testNum}, album.albumName(new): ${newAlbumList[0].albumName}`)
expect(newAlbumList[0].albumName).assertEqual(newName);
album.albumName = oldAlbumName;
await album.commitModify();
done();
});
} catch (error) {
console.info(`${testNum}, error: ${error}`)
expect(false).assertTrue();
done();
}
}
// ------------------------------ 001 test start ------------------------- // ------------------------------ 001 test start -------------------------
/** /**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_GETALBUM_CALLBACK_001_01 * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETALBUM_CALLBACK_001_01
...@@ -392,22 +425,79 @@ export default function albumTestCallbackTest(abilityContext) { ...@@ -392,22 +425,79 @@ export default function albumTestCallbackTest(abilityContext) {
/** /**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_MODIFYALBUM_CALLBACK_003_04 * @tc.number : SUB_MEDIA_MEDIALIBRARY_MODIFYALBUM_CALLBACK_003_04
* @tc.name : commitModify * @tc.name : commitModify
* @tc.desc : Modify Album name 'i123456...119' * @tc.desc : Modify Album name 'aaaaa....' (256)
* @tc.size : MEDIUM * @tc.size : MEDIUM
* @tc.type : Function * @tc.type : Function
* @tc.level : Level 0 * @tc.level : Level 0
*/ */
it('SUB_MEDIA_MEDIALIBRARY_MODIFYALBUM_CALLBACK_003_04', 0, async function (done) { it('SUB_MEDIA_MEDIALIBRARY_MODIFYALBUM_CALLBACK_003_04', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_MODIFYALBUM_CALLBACK_003_04'; let testNum = 'SUB_MEDIA_MEDIALIBRARY_MODIFYALBUM_CALLBACK_003_04';
let currentFetchOp = albumFetchOps(testNum, 'Pictures/', 'DynamicCb2', IMAGE_TYPE); let currentFetchOp = albumFetchOps(testNum, 'Pictures/', 'DynamicCb3', IMAGE_TYPE);
let newName = ""; let newName = "";
for (var i = 0; i < 1200; i++) { for (var i = 0; i < 256; i++) {
newName += i.toString(); newName += "a";
} }
let expectAlbumCount = 1; let expectAlbumCount = 1;
await abnormalAlbumCommitModify(done, testNum, currentFetchOp, newName, expectAlbumCount) await abnormalAlbumCommitModify(done, testNum, currentFetchOp, newName, expectAlbumCount)
}); });
// // ------------------------------ 003 test end -------------------------
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_MODIFYALBUM_CALLBACK_003_05
* @tc.name : commitModify
* @tc.desc : Modify Album name '中中中中中....' (86 *3)
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MEDIA_MEDIALIBRARY_MODIFYALBUM_CALLBACK_003_05', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_MODIFYALBUM_CALLBACK_003_05';
let currentFetchOp = albumFetchOps(testNum, 'Pictures/', 'DynamicCb4', IMAGE_TYPE);
let newName = "";
for (var i = 0; i < 86; i++) {
newName += "中";
}
let expectAlbumCount = 1;
await abnormalAlbumCommitModify(done, testNum, currentFetchOp, newName, expectAlbumCount)
});
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_MODIFYALBUM_CALLBACK_003_06
* @tc.name : commitModify
* @tc.desc : Modify Album name 'aaaaaaa....' (255)
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MEDIA_MEDIALIBRARY_MODIFYALBUM_CALLBACK_003_06', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_MODIFYALBUM_CALLBACK_003_06';
let currentFetchOp = albumFetchOps(testNum, 'Pictures/', 'DynamicCb5', IMAGE_TYPE);
let newName = "";
for (var i = 0; i < 255; i++) {
newName += "a";
}
let expectAlbumCount = 1;
await albumCommitModify(done, testNum, currentFetchOp, newName, expectAlbumCount)
});
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_MODIFYALBUM_CALLBACK_003_07
* @tc.name : commitModify
* @tc.desc : Modify Album name '中中中中中中中....' (85*3)
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MEDIA_MEDIALIBRARY_MODIFYALBUM_CALLBACK_003_07', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_MODIFYALBUM_CALLBACK_003_07';
let currentFetchOp = albumFetchOps(testNum, 'Pictures/', 'DynamicCb6', IMAGE_TYPE);
let newName = "";
for (var i = 0; i < 85; i++) {
newName += "中";
}
let expectAlbumCount = 1;
await albumCommitModify(done, testNum, currentFetchOp, newName, expectAlbumCount)
});
// ------------------------------ 003 test end -------------------------
}); });
} }
......
...@@ -153,6 +153,31 @@ export default function albumTestPromiseTest(abilityContext) { ...@@ -153,6 +153,31 @@ export default function albumTestPromiseTest(abilityContext) {
done(); done();
} }
} }
const albumCommitModify = async function (done, testNum, fetchOp, newName, expectAlbumCount) {
try {
const albumList = await media.getAlbums(fetchOp);
const albumCountPass = await checkAlbumsCount(done, testNum, albumList, expectAlbumCount);
if (!albumCountPass) return;
const album = albumList[0];
const albumId = album.albumId;
console.info(`${testNum}, album.albumName(old): ${album.albumName}`)
const oldAlbumName = album.albumName;
album.albumName = newName;
await album.commitModify();
let currentfetchOp = idFetchOps(testNum, albumId)
const newAlbumList = await media.getAlbums(currentfetchOp);
console.info(`${testNum}, album.albumName(new): ${newAlbumList[0].albumName}`)
expect(newAlbumList[0].albumName).assertEqual(newName);
album.albumName = oldAlbumName;
await album.commitModify();
done();
} catch (error) {
console.info(`${testNum}, error: ${error}`)
expect(false).assertTrue();
done();
}
}
// ------------------------------ 001 test start ------------------------- // ------------------------------ 001 test start -------------------------
/** /**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_GETALBUM_PROMISE_001_01 * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETALBUM_PROMISE_001_01
...@@ -387,22 +412,79 @@ export default function albumTestPromiseTest(abilityContext) { ...@@ -387,22 +412,79 @@ export default function albumTestPromiseTest(abilityContext) {
/** /**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_MODIFYALBUM_PROMISE_003_04 * @tc.number : SUB_MEDIA_MEDIALIBRARY_MODIFYALBUM_PROMISE_003_04
* @tc.name : commitModify * @tc.name : commitModify
* @tc.desc : Modify Album name 'i123456...119' * @tc.desc : Modify Album name 'aaaaa....' (256)
* @tc.size : MEDIUM * @tc.size : MEDIUM
* @tc.type : Function * @tc.type : Function
* @tc.level : Level 0 * @tc.level : Level 0
*/ */
it('SUB_MEDIA_MEDIALIBRARY_MODIFYALBUM_PROMISE_003_04', 0, async function (done) { it('SUB_MEDIA_MEDIALIBRARY_MODIFYALBUM_PROMISE_003_04', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_MODIFYALBUM_PROMISE_003_04'; let testNum = 'SUB_MEDIA_MEDIALIBRARY_MODIFYALBUM_PROMISE_003_04';
let currentFetchOp = albumFetchOps(testNum, 'Pictures/', 'DynamicPro2', IMAGE_TYPE); let currentFetchOp = albumFetchOps(testNum, 'Pictures/', 'DynamicPro3', IMAGE_TYPE);
let newName = "";
for (var i = 0; i < 256; i++) {
newName += "a";
}
let expectAlbumCount = 1;
await abnormalAlbumCommitModify(done, testNum, currentFetchOp, newName, expectAlbumCount)
});
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_MODIFYALBUM_PROMISE_003_05
* @tc.name : commitModify
* @tc.desc : Modify Album name '中中中中中....' (86 *3)
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MEDIA_MEDIALIBRARY_MODIFYALBUM_PROMISE_003_05', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_MODIFYALBUM_PROMISE_003_05';
let currentFetchOp = albumFetchOps(testNum, 'Pictures/', 'DynamicPro4', IMAGE_TYPE);
let newName = ""; let newName = "";
for (var i = 0; i < 1200; i++) { for (var i = 0; i < 86; i++) {
newName += i.toString(); newName += "中";
} }
let expectAlbumCount = 1; let expectAlbumCount = 1;
await abnormalAlbumCommitModify(done, testNum, currentFetchOp, newName, expectAlbumCount) await abnormalAlbumCommitModify(done, testNum, currentFetchOp, newName, expectAlbumCount)
}); });
// // ------------------------------ 003 test end -------------------------
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_MODIFYALBUM_PROMISE_003_06
* @tc.name : commitModify
* @tc.desc : Modify Album name 'aaaaaaa....' (255)
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MEDIA_MEDIALIBRARY_MODIFYALBUM_PROMISE_003_06', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_MODIFYALBUM_PROMISE_003_06';
let currentFetchOp = albumFetchOps(testNum, 'Pictures/', 'DynamicPro5', IMAGE_TYPE);
let newName = "";
for (var i = 0; i < 255; i++) {
newName += "a";
}
let expectAlbumCount = 1;
await albumCommitModify(done, testNum, currentFetchOp, newName, expectAlbumCount)
});
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_MODIFYALBUM_PROMISE_003_07
* @tc.name : commitModify
* @tc.desc : Modify Album name '中中中中中中中....' (85*3)
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MEDIA_MEDIALIBRARY_MODIFYALBUM_PROMISE_003_07', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_MODIFYALBUM_PROMISE_003_07';
let currentFetchOp = albumFetchOps(testNum, 'Pictures/', 'DynamicPro6', IMAGE_TYPE);
let newName = "";
for (var i = 0; i < 85; i++) {
newName += "中";
}
let expectAlbumCount = 1;
await albumCommitModify(done, testNum, currentFetchOp, newName, expectAlbumCount)
});
// ------------------------------ 003 test end -------------------------
// ------------------------------ 004 test start ------------------------- // ------------------------------ 004 test start -------------------------
/** /**
......
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
"for d in RW_cb R_cb W_cb RW R W openClose; 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 RW_cb R_cb W_cb RW R W openClose; 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 RW_cb R_cb W_cb RW R W openClose; 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 RW_cb R_cb W_cb RW R W openClose; 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 RW_cb R_cb W_cb RW R W openClose; do for i in $$(seq 2); do cp /storage/media/100/local/temp/01.dat /storage/media/100/local/files/Documents/$$d/0$$i.dat; done;done;", "for d in RW_cb R_cb W_cb RW R W openClose; do for i in $$(seq 2); do cp /storage/media/100/local/temp/01.dat /storage/media/100/local/files/Documents/$$d/0$$i.dat; done;done;",
"for d in ModifyCb ModifyPro; do for i in $$(seq 7); 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; do for i in $$(seq 15); 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; do for i in $$(seq 5); 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; do for i in $$(seq 5); 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; do for i in $$(seq 5); 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; do for i in $$(seq 5); 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; do for i in $$(seq 5); do cp /storage/media/100/local/temp/01.dat /storage/media/100/local/files/Documents/$$d/0$$i.dat; done;done;", "for d in ModifyCb ModifyPro; do for i in $$(seq 5); do cp /storage/media/100/local/temp/01.dat /storage/media/100/local/files/Documents/$$d/0$$i.dat; done;done;",
......
...@@ -55,7 +55,7 @@ export default function fileAssetCallback2Test(abilityContext) { ...@@ -55,7 +55,7 @@ export default function fileAssetCallback2Test(abilityContext) {
const oldVal = asset[prop] const oldVal = asset[prop]
asset[prop] = val; asset[prop] = val;
const id = asset.id; const id = asset.id;
await asset.commitModify(async (err) => { asset.commitModify(async (err) => {
if (err) { if (err) {
console.info(`${testNum} err : ${err}`) console.info(`${testNum} err : ${err}`)
expect.assertFail(); expect.assertFail();
...@@ -69,7 +69,6 @@ export default function fileAssetCallback2Test(abilityContext) { ...@@ -69,7 +69,6 @@ export default function fileAssetCallback2Test(abilityContext) {
const fetchFileResultById = await media.getFileAssets(currentfetchOp); const fetchFileResultById = await media.getFileAssets(currentfetchOp);
const currentAsset = await fetchFileResultById.getFirstObject(); const currentAsset = await fetchFileResultById.getFirstObject();
expect(currentAsset[prop]).assertEqual(val); expect(currentAsset[prop]).assertEqual(val);
asset[prop] = oldVal; asset[prop] = oldVal;
await asset.commitModify(); await asset.commitModify();
await fetchFileResult.close(); await fetchFileResult.close();
...@@ -83,6 +82,30 @@ export default function fileAssetCallback2Test(abilityContext) { ...@@ -83,6 +82,30 @@ export default function fileAssetCallback2Test(abilityContext) {
} }
} }
const abnormalCheckCommitModify = async function (done, testNum, fetchOp, prop, val) {
try {
const fetchFileResult = await media.getFileAssets(fetchOp);
let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchFileResult, 1);
if (!checkAssetCountPass) return;
const asset = await fetchFileResult.getFirstObject();
asset[prop] = val;
asset.commitModify(async (err) => {
if (err) {
console.info(`${testNum} passed : ${err}`)
expect(true).assertTrue();
done();
return;
}
expect.assertFail();
done();
});
} catch (error) {
console.info(`${testNum} error : ${error}`)
expect(false).assertTrue();
done();
}
}
/** /**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_FILEASSET_COMMITMODIFY_CALLBACK_001 * @tc.number : SUB_MEDIA_MEDIALIBRARY_FILEASSET_COMMITMODIFY_CALLBACK_001
...@@ -149,6 +172,84 @@ export default function fileAssetCallback2Test(abilityContext) { ...@@ -149,6 +172,84 @@ export default function fileAssetCallback2Test(abilityContext) {
await checkCommitModify(done, testNum, fetchOp, prop, val) await checkCommitModify(done, testNum, fetchOp, prop, val)
}); });
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_FILEASSET_COMMITMODIFY_CALLBACK_005
* @tc.name : commitModify
* @tc.desc : Modify displayName '中中....jpg' (83)
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MEDIA_MEDIALIBRARY_FILEASSET_COMMITMODIFY_CALLBACK_005', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_FILEASSET_COMMITMODIFY_CALLBACK_005'
let fetchOp = nameFetchOps(testNum, 'Pictures/ModifyCb/', '05', IMAGE_TYPE);
let prop = 'displayName'
let newName = "";
for (var i = 0; i < 83; i++) {
newName += "中";
}
let val = newName + '.jpg'
await checkCommitModify(done, testNum, fetchOp, prop, val)
});
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_FILEASSET_COMMITMODIFY_CALLBACK_006
* @tc.name : commitModify
* @tc.desc : Modify displayName 'aaaaaaa....jpg' (255)
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MEDIA_MEDIALIBRARY_FILEASSET_COMMITMODIFY_CALLBACK_006', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_FILEASSET_COMMITMODIFY_CALLBACK_006'
let fetchOp = nameFetchOps(testNum, 'Pictures/ModifyCb/', '06', IMAGE_TYPE);
let prop = 'displayName'
let newName = "";
for (var i = 0; i < 251; i++) {
newName += "a";
}
let val = newName + '.jpg'
await checkCommitModify(done, testNum, fetchOp, prop, val)
});
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_FILEASSET_COMMITMODIFY_CALLBACK_009
* @tc.name : commitModify
* @tc.desc : Modify displayName '中中....jpg' (84)
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MEDIA_MEDIALIBRARY_FILEASSET_COMMITMODIFY_CALLBACK_009', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_FILEASSET_COMMITMODIFY_CALLBACK_009'
let fetchOp = nameFetchOps(testNum, 'Pictures/ModifyCb/', '09', IMAGE_TYPE);
let prop = 'displayName'
let newName = "";
for (var i = 0; i < 84; i++) {
newName += "中";
}
let val = newName + '.jpg'
await abnormalCheckCommitModify(done, testNum, fetchOp, prop, val)
});
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_FILEASSET_COMMITMODIFY_CALLBACK_010
* @tc.name : commitModify
* @tc.desc : Modify displayName 'aaaaaaa....jpg' (256)
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MEDIA_MEDIALIBRARY_FILEASSET_COMMITMODIFY_CALLBACK_010', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_FILEASSET_COMMITMODIFY_CALLBACK_010'
let fetchOp = nameFetchOps(testNum, 'Pictures/ModifyCb/', '010', IMAGE_TYPE);
let prop = 'displayName'
let newName = "";
for (var i = 0; i < 252; i++) {
newName += "a";
}
let val = newName + '.jpg'
await abnormalCheckCommitModify(done, testNum, fetchOp, prop, val)
});
/** /**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_FILEASSET_ISDIRECTORY_CALLBACK_001 * @tc.number : SUB_MEDIA_MEDIALIBRARY_FILEASSET_ISDIRECTORY_CALLBACK_001
* @tc.name : isDirectory * @tc.name : isDirectory
...@@ -160,7 +261,7 @@ export default function fileAssetCallback2Test(abilityContext) { ...@@ -160,7 +261,7 @@ export default function fileAssetCallback2Test(abilityContext) {
it('SUB_MEDIA_MEDIALIBRARY_FILEASSET_ISDIRECTORY_CALLBACK_001', 0, async function (done) { it('SUB_MEDIA_MEDIALIBRARY_FILEASSET_ISDIRECTORY_CALLBACK_001', 0, async function (done) {
try { try {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_FILEASSET_ISDIRECTORY_CALLBACK_001' let testNum = 'SUB_MEDIA_MEDIALIBRARY_FILEASSET_ISDIRECTORY_CALLBACK_001'
let fetchOp = nameFetchOps(testNum, 'Pictures/ModifyCb/', '05', IMAGE_TYPE); let fetchOp = nameFetchOps(testNum, 'Pictures/ModifyCb/', '013', IMAGE_TYPE);
const fetchFileResult = await media.getFileAssets(fetchOp); const fetchFileResult = await media.getFileAssets(fetchOp);
const asset = await fetchFileResult.getFirstObject(); const asset = await fetchFileResult.getFirstObject();
asset.isDirectory((err, isDir) =>{ asset.isDirectory((err, isDir) =>{
......
...@@ -93,6 +93,30 @@ export default function fileAssetPromise2Test(abilityContext) { ...@@ -93,6 +93,30 @@ export default function fileAssetPromise2Test(abilityContext) {
done(); done();
} }
} }
const abnormalCheckCommitModify = async function (done, testNum, fetchOp, prop, val) {
try {
const fetchFileResult = await media.getFileAssets(fetchOp);
let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchFileResult, 1);
if (!checkAssetCountPass) return;
const asset = await fetchFileResult.getFirstObject();
asset[prop] = val;
try {
await asset.commitModify();
expect.assertFail();
done();
} catch (error) {
console.info(`${testNum} passed : ${error}`)
expect(true).assertTrue();
done();
}
} catch (error) {
console.info(`${testNum} error : ${error}`)
expect(false).assertTrue();
done();
}
}
/** /**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_FILEASSET_COMMITMODIFY_PROMISE_001 * @tc.number : SUB_MEDIA_MEDIALIBRARY_FILEASSET_COMMITMODIFY_PROMISE_001
* @tc.name : commitModify * @tc.name : commitModify
...@@ -160,30 +184,109 @@ export default function fileAssetPromise2Test(abilityContext) { ...@@ -160,30 +184,109 @@ export default function fileAssetPromise2Test(abilityContext) {
/** /**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_FILEASSET_COMMITMODIFY_PROMISE_005 * @tc.number : SUB_MEDIA_MEDIALIBRARY_FILEASSET_COMMITMODIFY_PROMISE_005
* @tc.name : commitModify * @tc.name : commitModify
* @tc.desc : Modify uri * @tc.desc : Modify displayName '中中....jpg' (83)
* @tc.size : MEDIUM * @tc.size : MEDIUM
* @tc.type : Function * @tc.type : Function
* @tc.level : Level 0 * @tc.level : Level 0
*/ */
it('SUB_MEDIA_MEDIALIBRARY_FILEASSET_COMMITMODIFY_PROMISE_005', 0, async function (done) { it('SUB_MEDIA_MEDIALIBRARY_FILEASSET_COMMITMODIFY_PROMISE_005', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_FILEASSET_COMMITMODIFY_PROMISE_005' let testNum = 'SUB_MEDIA_MEDIALIBRARY_FILEASSET_COMMITMODIFY_PROMISE_005'
let fetchOp = nameFetchOps(testNum, 'Pictures/ModifyPro/', '05', IMAGE_TYPE);
let prop = 'displayName'
let newName = "";
for (var i = 0; i < 83; i++) {
newName += "中";
}
let val = newName + '.jpg'
await checkCommitModify(done, testNum, fetchOp, prop, val)
});
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_FILEASSET_COMMITMODIFY_PROMISE_006
* @tc.name : commitModify
* @tc.desc : Modify displayName 'aaaaaaa....jpg' (255)
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MEDIA_MEDIALIBRARY_FILEASSET_COMMITMODIFY_PROMISE_006', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_FILEASSET_COMMITMODIFY_PROMISE_006'
let fetchOp = nameFetchOps(testNum, 'Pictures/ModifyPro/', '06', IMAGE_TYPE); let fetchOp = nameFetchOps(testNum, 'Pictures/ModifyPro/', '06', IMAGE_TYPE);
let prop = 'displayName'
let newName = "";
for (var i = 0; i < 251; i++) {
newName += "a";
}
let val = newName + '.jpg'
await checkCommitModify(done, testNum, fetchOp, prop, val)
});
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_FILEASSET_COMMITMODIFY_PROMISE_009
* @tc.name : commitModify
* @tc.desc : Modify displayName '中中....jpg' (84)
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MEDIA_MEDIALIBRARY_FILEASSET_COMMITMODIFY_PROMISE_009', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_FILEASSET_COMMITMODIFY_PROMISE_009'
let fetchOp = nameFetchOps(testNum, 'Pictures/ModifyPro/', '09', IMAGE_TYPE);
let prop = 'displayName'
let newName = "";
for (var i = 0; i < 84; i++) {
newName += "中";
}
let val = newName + '.jpg'
await abnormalCheckCommitModify(done, testNum, fetchOp, prop, val)
});
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_FILEASSET_COMMITMODIFY_PROMISE_010
* @tc.name : commitModify
* @tc.desc : Modify displayName 'aaaaaaa....jpg' (256)
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MEDIA_MEDIALIBRARY_FILEASSET_COMMITMODIFY_PROMISE_010', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_FILEASSET_COMMITMODIFY_PROMISE_010'
let fetchOp = nameFetchOps(testNum, 'Pictures/ModifyPro/', '010', IMAGE_TYPE);
let prop = 'displayName'
let newName = "";
for (var i = 0; i < 252; i++) {
newName += "a";
}
let val = newName + '.jpg'
await abnormalCheckCommitModify(done, testNum, fetchOp, prop, val)
});
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_FILEASSET_COMMITMODIFY_PROMISE_02_001
* @tc.name : commitModify
* @tc.desc : Modify uri
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_MEDIA_MEDIALIBRARY_FILEASSET_COMMITMODIFY_PROMISE_02_001', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_FILEASSET_COMMITMODIFY_PROMISE_02_001'
let fetchOp = nameFetchOps(testNum, 'Pictures/ModifyPro/', '013', IMAGE_TYPE);
let prop = 'uri' let prop = 'uri'
let val = 'newUri' let val = 'newUri'
await staticPropsCommitModify(done, testNum, fetchOp, prop, val) await staticPropsCommitModify(done, testNum, fetchOp, prop, val)
}); });
/** /**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_FILEASSET_COMMITMODIFY_PROMISE_006 * @tc.number : SUB_MEDIA_MEDIALIBRARY_FILEASSET_COMMITMODIFY_PROMISE_02_002
* @tc.name : commitModify * @tc.name : commitModify
* @tc.desc : Modify mediaType * @tc.desc : Modify mediaType
* @tc.size : MEDIUM * @tc.size : MEDIUM
* @tc.type : Function * @tc.type : Function
* @tc.level : Level 0 * @tc.level : Level 0
*/ */
it('SUB_MEDIA_MEDIALIBRARY_FILEASSET_COMMITMODIFY_PROMISE_006', 0, async function (done) { it('SUB_MEDIA_MEDIALIBRARY_FILEASSET_COMMITMODIFY_PROMISE_02_002', 0, async function (done) {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_FILEASSET_COMMITMODIFY_PROMISE_006' let testNum = 'SUB_MEDIA_MEDIALIBRARY_FILEASSET_COMMITMODIFY_PROMISE_02_002'
let fetchOp = nameFetchOps(testNum, 'Pictures/ModifyPro/', '07', IMAGE_TYPE); let fetchOp = nameFetchOps(testNum, 'Pictures/ModifyPro/', '014', IMAGE_TYPE);
let prop = 'mediaType' let prop = 'mediaType'
let val = 'newMediaType' let val = 'newMediaType'
await staticPropsCommitModify(done, testNum, fetchOp, prop, val) await staticPropsCommitModify(done, testNum, fetchOp, prop, val)
...@@ -200,7 +303,7 @@ export default function fileAssetPromise2Test(abilityContext) { ...@@ -200,7 +303,7 @@ export default function fileAssetPromise2Test(abilityContext) {
it('SUB_MEDIA_MEDIALIBRARY_FILEASSET_ISDIRECTORY_PROMISE_001', 0, async function (done) { it('SUB_MEDIA_MEDIALIBRARY_FILEASSET_ISDIRECTORY_PROMISE_001', 0, async function (done) {
try { try {
let testNum = 'SUB_MEDIA_MEDIALIBRARY_FILEASSET_ISDIRECTORY_PROMISE_001' let testNum = 'SUB_MEDIA_MEDIALIBRARY_FILEASSET_ISDIRECTORY_PROMISE_001'
let fetchOp = nameFetchOps(testNum, 'Pictures/ModifyPro/', '05', IMAGE_TYPE); let fetchOp = nameFetchOps(testNum, 'Pictures/ModifyPro/', '015', IMAGE_TYPE);
const fetchFileResult = await media.getFileAssets(fetchOp); const fetchFileResult = await media.getFileAssets(fetchOp);
const asset = await fetchFileResult.getFirstObject(); const asset = await fetchFileResult.getFirstObject();
const isDir = await asset.isDirectory(); const isDir = await asset.isDirectory();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册