diff --git a/multimedia/medialibrary/common.js b/multimedia/medialibrary/common.js index f97c7048a70e08b40477ee92542fdbff6b08e689..fc716d5e2d4322cce51f6036259c71cad3edb3f4 100755 --- a/multimedia/medialibrary/common.js +++ b/multimedia/medialibrary/common.js @@ -17,11 +17,11 @@ import abilityAccessCtrl from '@ohos.abilityAccessCtrl'; import bundle from '@ohos.bundle'; const presetsCount = { - ActsMediaLibraryAlbumTest: { albumsCount: 7, assetsCount: 19 }, + ActsMediaLibraryAlbumTest: { albumsCount: 15, assetsCount: 27 }, ActsMediaLibraryBaseTest: { albumsCount: 11, assetsCount: 14 }, ActsMediaLibraryFavoriteTest: { albumsCount: 6, assetsCount: 32 }, ActsMediaLibraryFileTest: { albumsCount: 6, assetsCount: 28 }, - ActsMediaLibraryFileAssetTest: { albumsCount: 27, assetsCount: 100 }, + ActsMediaLibraryFileAssetTest: { albumsCount: 27, assetsCount: 116 }, ActsMediaLibraryFileKeyTest: { albumsCount: 2, assetsCount: 2 }, ActsMediaLibraryFileResultTest: { albumsCount: 3, assetsCount: 112 }, ActsMediaLibraryGetThumbnailTest: { albumsCount: 3, assetsCount: 3 }, diff --git a/multimedia/medialibrary/mediaLibrary_album/Test.json b/multimedia/medialibrary/mediaLibrary_album/Test.json index fd0e3fb4cb1786687d8fd66bafbc0909f9932d1d..b815d6ff6d66defc07c434218d8dbe0d927771e1 100755 --- a/multimedia/medialibrary/mediaLibrary_album/Test.json +++ b/multimedia/medialibrary/mediaLibrary_album/Test.json @@ -31,15 +31,17 @@ { "type": "ShellKit", "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/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.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 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 /data/service/el2/100/hmdfs/account/files/*", diff --git a/multimedia/medialibrary/mediaLibrary_album/entry/src/main/ets/test/albumTestCallBack.test.ets b/multimedia/medialibrary/mediaLibrary_album/entry/src/main/ets/test/albumTestCallBack.test.ets index 47e0c98a3a0bf82c2f47a55f2df33d19de7959dc..77eb83c49ab1c65c3d3296940c8e955d1e40f4c5 100755 --- a/multimedia/medialibrary/mediaLibrary_album/entry/src/main/ets/test/albumTestCallBack.test.ets +++ b/multimedia/medialibrary/mediaLibrary_album/entry/src/main/ets/test/albumTestCallBack.test.ets @@ -144,8 +144,14 @@ export default function albumTestCallbackTest(abilityContext) { const album = albumList[0]; album.albumName = newName; album.commitModify(async (error) => { - console.info(`${testNum}, error.message: ${error.message} error.code: ${error.code}`) - expect(error.code != undefined).assertTrue(); + if(error) { + 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(); }); } catch (error) { @@ -154,6 +160,33 @@ export default function albumTestCallbackTest(abilityContext) { 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 ------------------------- /** * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETALBUM_CALLBACK_001_01 @@ -392,22 +425,79 @@ export default function albumTestCallbackTest(abilityContext) { /** * @tc.number : SUB_MEDIA_MEDIALIBRARY_MODIFYALBUM_CALLBACK_003_04 * @tc.name : commitModify - * @tc.desc : Modify Album name 'i123456...119' + * @tc.desc : Modify Album name 'aaaaa....' (256) * @tc.size : MEDIUM * @tc.type : Function * @tc.level : Level 0 */ it('SUB_MEDIA_MEDIALIBRARY_MODIFYALBUM_CALLBACK_003_04', 0, async function (done) { 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 = ""; - for (var i = 0; i < 1200; i++) { - newName += i.toString(); + for (var i = 0; i < 256; i++) { + newName += "a"; } let expectAlbumCount = 1; 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 ------------------------- }); } diff --git a/multimedia/medialibrary/mediaLibrary_album/entry/src/main/ets/test/albumTestPromise.test.ets b/multimedia/medialibrary/mediaLibrary_album/entry/src/main/ets/test/albumTestPromise.test.ets index eaf19f41f3fa06623e43316019d09b860bb725bb..5755d4baf0219cef8c179725e608ef92aee39c52 100755 --- a/multimedia/medialibrary/mediaLibrary_album/entry/src/main/ets/test/albumTestPromise.test.ets +++ b/multimedia/medialibrary/mediaLibrary_album/entry/src/main/ets/test/albumTestPromise.test.ets @@ -153,6 +153,31 @@ export default function albumTestPromiseTest(abilityContext) { 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 ------------------------- /** * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETALBUM_PROMISE_001_01 @@ -387,22 +412,79 @@ export default function albumTestPromiseTest(abilityContext) { /** * @tc.number : SUB_MEDIA_MEDIALIBRARY_MODIFYALBUM_PROMISE_003_04 * @tc.name : commitModify - * @tc.desc : Modify Album name 'i123456...119' + * @tc.desc : Modify Album name 'aaaaa....' (256) * @tc.size : MEDIUM * @tc.type : Function * @tc.level : Level 0 */ it('SUB_MEDIA_MEDIALIBRARY_MODIFYALBUM_PROMISE_003_04', 0, async function (done) { 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 = ""; - for (var i = 0; i < 1200; i++) { - newName += i.toString(); + for (var i = 0; i < 86; i++) { + newName += "中"; } let expectAlbumCount = 1; 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 ------------------------- /** diff --git a/multimedia/medialibrary/mediaLibrary_fileAsset/Test.json b/multimedia/medialibrary/mediaLibrary_fileAsset/Test.json index 953cab14c6786c32cb71bff42fa14e924e883bbe..abbfa6e538921c5923fc3c325e5523211ee928f4 100755 --- a/multimedia/medialibrary/mediaLibrary_fileAsset/Test.json +++ b/multimedia/medialibrary/mediaLibrary_fileAsset/Test.json @@ -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.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 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.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;", diff --git a/multimedia/medialibrary/mediaLibrary_fileAsset/entry/src/main/ets/test/fileAssetCallback2.test.ets b/multimedia/medialibrary/mediaLibrary_fileAsset/entry/src/main/ets/test/fileAssetCallback2.test.ets index da973774054627a73b142ec56bf9ee4291a72be0..609b3c7ecf8c71f266df8c17a3f80b1ded8115d0 100755 --- a/multimedia/medialibrary/mediaLibrary_fileAsset/entry/src/main/ets/test/fileAssetCallback2.test.ets +++ b/multimedia/medialibrary/mediaLibrary_fileAsset/entry/src/main/ets/test/fileAssetCallback2.test.ets @@ -55,7 +55,7 @@ export default function fileAssetCallback2Test(abilityContext) { const oldVal = asset[prop] asset[prop] = val; const id = asset.id; - await asset.commitModify(async (err) => { + asset.commitModify(async (err) => { if (err) { console.info(`${testNum} err : ${err}`) expect.assertFail(); @@ -69,7 +69,6 @@ export default function fileAssetCallback2Test(abilityContext) { const fetchFileResultById = await media.getFileAssets(currentfetchOp); const currentAsset = await fetchFileResultById.getFirstObject(); expect(currentAsset[prop]).assertEqual(val); - asset[prop] = oldVal; await asset.commitModify(); await fetchFileResult.close(); @@ -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 @@ -149,6 +172,84 @@ export default function fileAssetCallback2Test(abilityContext) { 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.name : isDirectory @@ -160,7 +261,7 @@ export default function fileAssetCallback2Test(abilityContext) { it('SUB_MEDIA_MEDIALIBRARY_FILEASSET_ISDIRECTORY_CALLBACK_001', 0, async function (done) { try { 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 asset = await fetchFileResult.getFirstObject(); asset.isDirectory((err, isDir) =>{ diff --git a/multimedia/medialibrary/mediaLibrary_fileAsset/entry/src/main/ets/test/fileAssetPromise2.test.ets b/multimedia/medialibrary/mediaLibrary_fileAsset/entry/src/main/ets/test/fileAssetPromise2.test.ets index 0d2399362ac940f390bc826aa9cabd4908f5b7f5..1e7b7d35147f326f0c46eb20cf10755453e0793e 100755 --- a/multimedia/medialibrary/mediaLibrary_fileAsset/entry/src/main/ets/test/fileAssetPromise2.test.ets +++ b/multimedia/medialibrary/mediaLibrary_fileAsset/entry/src/main/ets/test/fileAssetPromise2.test.ets @@ -93,6 +93,30 @@ export default function fileAssetPromise2Test(abilityContext) { 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.name : commitModify @@ -160,30 +184,109 @@ export default function fileAssetPromise2Test(abilityContext) { /** * @tc.number : SUB_MEDIA_MEDIALIBRARY_FILEASSET_COMMITMODIFY_PROMISE_005 * @tc.name : commitModify - * @tc.desc : Modify uri + * @tc.desc : Modify displayName '中中....jpg' (83) * @tc.size : MEDIUM * @tc.type : Function * @tc.level : Level 0 */ it('SUB_MEDIA_MEDIALIBRARY_FILEASSET_COMMITMODIFY_PROMISE_005', 0, async function (done) { 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 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 val = 'newUri' 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.desc : Modify mediaType * @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/', '07', IMAGE_TYPE); + it('SUB_MEDIA_MEDIALIBRARY_FILEASSET_COMMITMODIFY_PROMISE_02_002', 0, async function (done) { + let testNum = 'SUB_MEDIA_MEDIALIBRARY_FILEASSET_COMMITMODIFY_PROMISE_02_002' + let fetchOp = nameFetchOps(testNum, 'Pictures/ModifyPro/', '014', IMAGE_TYPE); let prop = 'mediaType' let val = 'newMediaType' await staticPropsCommitModify(done, testNum, fetchOp, prop, val) @@ -200,7 +303,7 @@ export default function fileAssetPromise2Test(abilityContext) { it('SUB_MEDIA_MEDIALIBRARY_FILEASSET_ISDIRECTORY_PROMISE_001', 0, async function (done) { try { 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 asset = await fetchFileResult.getFirstObject(); const isDir = await asset.isDirectory();