diff --git a/multimedia/medialibrary/common.js b/multimedia/medialibrary/common.js old mode 100755 new mode 100644 index c3f1c1bb964da84a45cf7d37b710c3b411e99afb..268239933e0e86c37e82a68cb15772db2bc231de --- a/multimedia/medialibrary/common.js +++ b/multimedia/medialibrary/common.js @@ -12,10 +12,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import mediaLibrary from '@ohos.multimedia.mediaLibrary'; -import abilityAccessCtrl from '@ohos.abilityAccessCtrl'; -import bundle from '@ohos.bundle'; - +import mediaLibrary from "@ohos.multimedia.mediaLibrary"; +import abilityAccessCtrl from "@ohos.abilityAccessCtrl"; +import bundle from "@ohos.bundle"; +import uitest from "@ohos.uitest"; const presetsCount = { ActsMediaLibraryAlbumTest: { albumsCount: 15, assetsCount: 27 }, ActsMediaLibraryBaseTest: { albumsCount: 11, assetsCount: 14 }, @@ -27,7 +27,7 @@ const presetsCount = { ActsMediaLibraryGetThumbnailTest: { albumsCount: 3, assetsCount: 3 }, ActsMediaLibraryMediafetchoptionsTest: { albumsCount: 3, assetsCount: 8 }, ActsMediaLibraryTrashJsTest: { albumsCount: 6, assetsCount: 24 }, -} +}; const IMAGE_TYPE = mediaLibrary.MediaType.IMAGE; const VIDEO_TYPE = mediaLibrary.MediaType.VIDEO; @@ -35,7 +35,7 @@ const AUDIO_TYPE = mediaLibrary.MediaType.AUDIO; const FILE_TYPE = mediaLibrary.MediaType.FILE; const FILEKEY = mediaLibrary.FileKey; -const { RELATIVE_PATH, ALBUM_NAME, MEDIA_TYPE } = FILEKEY +const { RELATIVE_PATH, ALBUM_NAME, MEDIA_TYPE } = FILEKEY; const sleep = async function sleep(times) { if (!times) { @@ -49,41 +49,41 @@ const allFetchOp = function (others) { others = {}; } return { - selections: '', + selections: "", selectionArgs: [], - ...others + ...others, }; -} +}; const fetchOps = function (testNum, path, type, others) { if (!others) { others = {}; } let ops = { - selections: FILEKEY.RELATIVE_PATH + '= ? AND ' + FILEKEY.MEDIA_TYPE + '=?', + selections: FILEKEY.RELATIVE_PATH + "= ? AND " + FILEKEY.MEDIA_TYPE + "=?", selectionArgs: [path, type.toString()], - ...others + ...others, }; - console.info(`${testNum}: fetchOps${JSON.stringify(ops)}`) - return ops -} + console.info(`${testNum}: fetchOps${JSON.stringify(ops)}`); + return ops; +}; const nameFetchOps = function (testNum, path, display_name, type) { let ops = { - selections: FILEKEY.RELATIVE_PATH + '= ? AND ' + FILEKEY.DISPLAY_NAME + '= ? AND ' + FILEKEY.MEDIA_TYPE + '=?', + selections: FILEKEY.RELATIVE_PATH + "= ? AND " + FILEKEY.DISPLAY_NAME + "= ? AND " + FILEKEY.MEDIA_TYPE + "=?", selectionArgs: [path, display_name, type.toString()], }; - console.info(`${testNum}: fetchOps${JSON.stringify(ops)}`) - return ops -} + console.info(`${testNum}: fetchOps${JSON.stringify(ops)}`); + return ops; +}; const idFetchOps = function (testNum, albumId) { let ops = { - selections: FILEKEY.ALBUM_ID + '= ?', - selectionArgs: [albumId + ''], + selections: FILEKEY.ALBUM_ID + "= ?", + selectionArgs: [albumId + ""], }; - console.info(`${testNum}: fetchOps${JSON.stringify(ops)}`) - return ops -} + console.info(`${testNum}: fetchOps${JSON.stringify(ops)}`); + return ops; +}; const fileIdFetchOps = function (testNum, id) { let ops = { @@ -96,16 +96,16 @@ const fileIdFetchOps = function (testNum, id) { const albumFetchOps = function (testNum, path, albumName, type, others) { if (!others) { - others = { order: FILEKEY.DATE_ADDED + " DESC", }; + others = { order: FILEKEY.DATE_ADDED + " DESC" }; } let ops = { - selections: RELATIVE_PATH + '= ? AND ' + ALBUM_NAME + '= ? AND ' + MEDIA_TYPE + '= ?', + selections: RELATIVE_PATH + "= ? AND " + ALBUM_NAME + "= ? AND " + MEDIA_TYPE + "= ?", selectionArgs: [path, albumName, type.toString()], - ...others + ...others, }; - console.info(`${testNum}: fetchOps${JSON.stringify(ops)}`) - return ops -} + console.info(`${testNum}: fetchOps${JSON.stringify(ops)}`); + return ops; +}; // albums of two resource types const albumTwoTypesFetchOps = function (testNum, paths, albumName, types, others) { @@ -114,20 +114,27 @@ const albumTwoTypesFetchOps = function (testNum, paths, albumName, types, others } try { let ops = { - selections: '(' + RELATIVE_PATH + '= ? or ' + - RELATIVE_PATH + '= ? ) AND ' + - ALBUM_NAME + '= ? AND (' + - MEDIA_TYPE + '= ? or ' + - MEDIA_TYPE + '= ?)', + selections: + "(" + + RELATIVE_PATH + + "= ? or " + + RELATIVE_PATH + + "= ? ) AND " + + ALBUM_NAME + + "= ? AND (" + + MEDIA_TYPE + + "= ? or " + + MEDIA_TYPE + + "= ?)", selectionArgs: [paths[0], paths[1], albumName, types[0].toString(), types[1].toString()], - ...others + ...others, }; - console.info(`${testNum}: fetchOps${JSON.stringify(ops)}`) - return ops + console.info(`${testNum}: fetchOps${JSON.stringify(ops)}`); + return ops; } catch (error) { console.info(`albumTwoTypesFetchOps :: error: ${error}`); } -} +}; // albums of three resource types const albumThreeTypesFetchOps = function (testNum, paths, albumName, types, others) { @@ -136,47 +143,63 @@ const albumThreeTypesFetchOps = function (testNum, paths, albumName, types, othe } try { let ops = { - selections: '(' + RELATIVE_PATH + '= ? or ' + - RELATIVE_PATH + '= ? or ' + - RELATIVE_PATH + '= ? ) AND ' + - ALBUM_NAME + '= ? AND (' + - MEDIA_TYPE + '= ? or ' + - MEDIA_TYPE + '= ? or ' + - MEDIA_TYPE + '= ?)', - selectionArgs: [paths[0], paths[1], paths[2], albumName, - types[0].toString(), types[1].toString(), types[2].toString()], - ...others + selections: + "(" + + RELATIVE_PATH + + "= ? or " + + RELATIVE_PATH + + "= ? or " + + RELATIVE_PATH + + "= ? ) AND " + + ALBUM_NAME + + "= ? AND (" + + MEDIA_TYPE + + "= ? or " + + MEDIA_TYPE + + "= ? or " + + MEDIA_TYPE + + "= ?)", + selectionArgs: [ + paths[0], + paths[1], + paths[2], + albumName, + types[0].toString(), + types[1].toString(), + types[2].toString(), + ], + ...others, }; - console.info(`${testNum}: fetchOps${JSON.stringify(ops)}`) - return ops + console.info(`${testNum}: fetchOps${JSON.stringify(ops)}`); + return ops; } catch (error) { console.info(`albumThreeTypesFetchOps :: error: ${error}`); } -} +}; const checkPresetsAssets = async function (media, hapName) { - console.info('checkPresetsAssets start') + console.info("checkPresetsAssets start"); let albumList = await media.getAlbums(allFetchOp()); let albumsCount = albumList.length; let fetchFileResult = await media.getFileAssets(allFetchOp()); let assetsCount = await fetchFileResult.getCount(); let presetsassetsCount = presetsCount[hapName].assetsCount; let presetsalbumsCount = presetsCount[hapName].albumsCount; - if (assetsCount != presetsCount[hapName].assetsCount || albumsCount !=presetsCount[hapName].albumsCount) { + if (assetsCount != presetsCount[hapName].assetsCount || albumsCount != presetsCount[hapName].albumsCount) { console.info(`${hapName} checkPresetsAssets failed; assetsCount : presetsassetsCount = ${assetsCount} : ${presetsassetsCount} - albumsCount : presetsalbumsCount = ${albumsCount} : ${presetsalbumsCount}`) + albumsCount : presetsalbumsCount = ${albumsCount} : ${presetsalbumsCount}`); } else { - console.info(`${hapName} checkPresetsAssets passed`) + console.info(`${hapName} checkPresetsAssets passed`); } -} +}; const checkAssetsCount = async function (done, testNum, fetchFileResult, expectCount) { if (!fetchFileResult) { console.info(`${testNum}:: fetchFileResult error:`); expect(false).assertTrue(); done(); - return false + return false; } let count = await fetchFileResult.getCount(); if (count != expectCount) { @@ -185,14 +208,14 @@ const checkAssetsCount = async function (done, testNum, fetchFileResult, expectC done(); } return count == expectCount; -} +}; const checkAlbumsCount = function (done, testNum, albumList, expectCount) { if (!Array.isArray(albumList)) { console.info(`${testNum}:: albumList error:`); expect(false).assertTrue(); done(); - return false + return false; } let albumsCount = albumList.length; if (albumsCount != expectCount) { @@ -201,45 +224,43 @@ const checkAlbumsCount = function (done, testNum, albumList, expectCount) { done(); } return albumsCount == expectCount; -} +}; -const getPermission = async function (name) { +const getPermission = async function (name, context) { if (!name) { name = "ohos.acts.multimedia.mediaLibrary"; } - console.info('getPermission start', name) + console.info("getPermission start", name); + + let permissions = ["ohos.permission.MEDIA_LOCATION", "ohos.permission.READ_MEDIA", "ohos.permission.WRITE_MEDIA"]; + context.requestPermissionsFromUser(permissions, (data) => { + console.info(`getPermission requestPermissionsFromUser ${JSON.stringify(data)}`); + }); + await sleep(200); + + let driver = uitest.Driver.create(); + await sleep(200); + + let button = await driver.findComponent(uitest.ON.text("允许")); + await button.click(); + let appInfo = await bundle.getApplicationInfo(name, 0, 100); let tokenID = appInfo.accessTokenId; let atManager = abilityAccessCtrl.createAtManager(); - try { - await atManager.grantUserGrantedPermission(tokenID, "ohos.permission.MEDIA_LOCATION", 1); - } catch (error) { - console.info('getPermission MEDIA_LOCATION failed') - } - try { - await atManager.grantUserGrantedPermission(tokenID, "ohos.permission.READ_MEDIA", 1); - } catch (error) { - console.info('getPermission READ_MEDIA failed') - } - try { - await atManager.grantUserGrantedPermission(tokenID, "ohos.permission.WRITE_MEDIA", 1); - } catch (error) { - console.info('getPermission WRITE_MEDIA failed') - } let isGranted1 = await atManager.verifyAccessToken(tokenID, "ohos.permission.MEDIA_LOCATION"); let isGranted2 = await atManager.verifyAccessToken(tokenID, "ohos.permission.READ_MEDIA"); let isGranted3 = await atManager.verifyAccessToken(tokenID, "ohos.permission.WRITE_MEDIA"); if (!(isGranted1 == 0 && isGranted2 == 0 && isGranted3 == 0)) { - console.info('getPermission failed') + console.info("getPermission failed"); } - console.info('getPermission end') -} + console.info("getPermission end"); +}; -const MODIFY_ERROR_CODE_01 = '-1000'; +const MODIFY_ERROR_CODE_01 = "-1000"; const isNum = function (value) { - return typeof value === 'number' && !isNaN(value); -} + return typeof value === "number" && !isNaN(value); +}; export { getPermission, IMAGE_TYPE, diff --git a/multimedia/medialibrary/mediaLibrary_album/AppScope/app.json b/multimedia/medialibrary/mediaLibrary_album/AppScope/app.json old mode 100755 new mode 100644 index 841282ae47b98590bdbc8aea744fbbcd178e9195..803955ad0d2a5b4ce4e103816a6a917b4701286b --- a/multimedia/medialibrary/mediaLibrary_album/AppScope/app.json +++ b/multimedia/medialibrary/mediaLibrary_album/AppScope/app.json @@ -1,21 +1,21 @@ -{ - "app":{ - "bundleName":"ohos.acts.multimedia.mediaLibrary", - "vendor":"huawei", - "versionCode":1000000, - "versionName":"1.0.0", - "debug":false, - "icon":"$media:icon", - "label":"$string:entry_MainAbility", - "description":"$string:mainability_description", - "distributedNotificationEnabled":true, - "keepAlive":true, - "singleUser":true, - "minAPIVersion":8, - "targetAPIVersion":8, - "car":{ - "apiCompatibleVersion":8, - "singleUser":false - } - } -} +{ + "app": { + "bundleName": "ohos.acts.multimedia.mediaLibrary", + "vendor": "huawei", + "versionCode": 1000000, + "versionName": "1.0.0", + "debug": false, + "icon": "$media:icon", + "label": "$string:app_name", + "description": "$string:description_application", + "distributedNotificationEnabled": true, + "keepAlive": true, + "singleUser": true, + "minAPIVersion": 9, + "targetAPIVersion": 9, + "car": { + "apiCompatibleVersion": 9, + "singleUser": false + } + } +} \ No newline at end of file diff --git a/multimedia/medialibrary/mediaLibrary_album/AppScope/resources/base/element/string.json b/multimedia/medialibrary/mediaLibrary_album/AppScope/resources/base/element/string.json old mode 100755 new mode 100644 index 9b9d5b5e10c7ce74908c32b43d24568367b46d97..ee69f9a861d9dc269ed6638735d52674583498e1 --- a/multimedia/medialibrary/mediaLibrary_album/AppScope/resources/base/element/string.json +++ b/multimedia/medialibrary/mediaLibrary_album/AppScope/resources/base/element/string.json @@ -1,12 +1,8 @@ -{ - "string": [ - { - "name": "entry_MainAbility", - "value": "MediaLibraryJSTestMain" - }, - { - "name": "mainability_description", - "value": "MediaLibraryJSTestMain Ability" - } - ] -} \ No newline at end of file +{ + "string":[ + { + "name":"app_name", + "value":"ohosProject" + } + ] +} \ No newline at end of file diff --git a/multimedia/medialibrary/mediaLibrary_album/BUILD.gn b/multimedia/medialibrary/mediaLibrary_album/BUILD.gn old mode 100755 new mode 100644 index e82fb7aaf2957c605df92bc18dc006737b215d1c..463f4cfe7c4aee4fba4ba5ed3282ab049ef2f5b2 --- a/multimedia/medialibrary/mediaLibrary_album/BUILD.gn +++ b/multimedia/medialibrary/mediaLibrary_album/BUILD.gn @@ -15,6 +15,7 @@ import("//test/xts/tools/build/suite.gni") ohos_js_hap_suite("mediaLibrary_album_hap") { hap_profile = "entry/src/main/module.json" + js_build_mode = "debug" deps = [ ":mediaLibrary_js_assets", ":mediaLibrary_resources", diff --git a/multimedia/medialibrary/mediaLibrary_album/Test.json b/multimedia/medialibrary/mediaLibrary_album/Test.json old mode 100755 new mode 100644 index b815d6ff6d66defc07c434218d8dbe0d927771e1..860fd4efbef84cea43331bbce6b18afd62512308 --- a/multimedia/medialibrary/mediaLibrary_album/Test.json +++ b/multimedia/medialibrary/mediaLibrary_album/Test.json @@ -1,67 +1,68 @@ -{ - "description": "Configuration for mediaLibrary Tests", - "driver": { - "type": "JSUnitTest", - "test-timeout": "300000", - "package": "ohos.acts.multimedia.mediaLibrary", - "shell-timeout": "600000" - }, - "kits": [ - { - "type": "ShellKit", - "pre-push": [ - ], - "run-command": [ - "rm -rf /storage/media/100/local/files/*", - "rm -rf /data/app/el2/100/database/com.ohos.medialibrary.medialibrarydata/*", - "mkdir -pv /storage/media/100/local/files/{Pictures,Videos,Audios}", - "mkdir -p /storage/media/100/local/temp" - ] - }, - { - "type": "PushKit", - "pre-push": [ - ], - "push": [ - "./resource/medialibrary/01.jpg ->/storage/media/100/local/temp", - "./resource/medialibrary/01.mp3 ->/storage/media/100/local/temp", - "./resource/medialibrary/01.mp4 ->/storage/media/100/local/temp" - ] - }, - { - "type": "ShellKit", - "run-command": [ - "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 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/*", - "hilog -Q pidoff", - "hilog -p off", - "hilog -b I", - "hilog -b D -D 0xD002B70", - "scanner", - "sleep 10" - ], - "teardown-command":[ - "hilog -b X -D 0xD002B70" - ] - }, - { - "test-file-name": [ - "ActsMediaLibraryAlbumTest.hap" - ], - "type": "AppInstallKit", - "cleanup-apps": true - } - ] +{ + "description": "Configuration for mediaLibrary Tests", + "driver": { + "type": "OHJSUnitTest", + "test-timeout": "180000", + "bundle-name": "ohos.acts.multimedia.mediaLibrary", + "module-name": "phone", + "shell-timeout": "600000", + "testcase-timeout": 70000 + }, + "kits": [ + { + "type": "ShellKit", + "pre-push": [], + "run-command": [ + "rm -rf /storage/media/100/local/files/*", + "rm -rf /data/app/el2/100/database/com.ohos.medialibrary.medialibrarydata/*", + "mkdir -pv /storage/media/100/local/files/{Pictures,Videos,Audios}", + "mkdir -p /storage/media/100/local/temp", + "power-shell wakeup", + "uinput -T -d 300 600 -m 300 600 300 100 -u 300 100", + "power-shell setmode 602" + ] + }, + { + "type": "PushKit", + "pre-push": [], + "push": [ + "./resource/medialibrary/01.jpg ->/storage/media/100/local/temp", + "./resource/medialibrary/01.mp3 ->/storage/media/100/local/temp", + "./resource/medialibrary/01.mp4 ->/storage/media/100/local/temp" + ] + }, + { + "type": "ShellKit", + "run-command": [ + "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 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/*", + "hilog -Q pidoff", + "hilog -p off", + "hilog -b I", + "hilog -b D -D 0xD002B70", + "scanner", + "sleep 10" + ], + "teardown-command": [ + "hilog -b X -D 0xD002B70", + "power-shell setmode 600" + ] + }, + { + "test-file-name": [ + "ActsMediaLibraryAlbumTest.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + } + ] } \ No newline at end of file diff --git a/multimedia/medialibrary/mediaLibrary_album/entry/src/main/ets/Application/AbilityStage.ts b/multimedia/medialibrary/mediaLibrary_album/entry/src/main/ets/Application/AbilityStage.ts old mode 100755 new mode 100644 index 14f230e140160dc5f94ecc462304621178f4cf64..b0e0206ea9fb5ce94ef140d69510b6280969dd8e --- a/multimedia/medialibrary/mediaLibrary_album/entry/src/main/ets/Application/AbilityStage.ts +++ b/multimedia/medialibrary/mediaLibrary_album/entry/src/main/ets/Application/AbilityStage.ts @@ -1,9 +1,9 @@ -import AbilityStage from "@ohos.application.AbilityStage" - -export default class MyAbilityStage extends AbilityStage { - onCreate() { - console.log("[Demo] MyAbilityStage onCreate") - globalThis.stageOnCreateRun = 1; - globalThis.stageContext = this.context; - } -} +import AbilityStage from "@ohos.app.ability.AbilityStage" + +export default class MyAbilityStage extends AbilityStage { + onCreate() { + console.log("[Demo] MyAbilityStage onCreate") + globalThis.stageOnCreateRun = 1; + globalThis.stageContext = this.context; + } +} diff --git a/multimedia/medialibrary/mediaLibrary_album/entry/src/main/ets/MainAbility/MainAbility.ts b/multimedia/medialibrary/mediaLibrary_album/entry/src/main/ets/MainAbility/MainAbility.ts old mode 100755 new mode 100644 index 72b03d747b3e2e8bdf18ea37c54c789bebb767bb..df41851318f3385890e235a96dfbcc0441cb13f1 --- a/multimedia/medialibrary/mediaLibrary_album/entry/src/main/ets/MainAbility/MainAbility.ts +++ b/multimedia/medialibrary/mediaLibrary_album/entry/src/main/ets/MainAbility/MainAbility.ts @@ -1,36 +1,36 @@ -import Ability from '@ohos.application.Ability' - -export default class MainAbility extends Ability { - onCreate(want,launchParam){ - // Ability is creating, initialize resources for this ability - console.log("[Demo] MainAbility onCreate") - globalThis.abilityWant = want; - } - - onDestroy() { - // Ability is destroying, release resources for this ability - console.log("[Demo] MainAbility onDestroy") - } - - onWindowStageCreate(windowStage) { - // Main window is created, set main page for this ability - console.log("[Demo] MainAbility onWindowStageCreate") - globalThis.abilityContext = this.context - windowStage.setUIContent(this.context, "pages/index/index", null) - } - - onWindowStageDestroy() { - //Main window is destroyed, release UI related resources - console.log("[Demo] MainAbility onWindowStageDestroy") - } - - onForeground() { - // Ability has brought to foreground - console.log("[Demo] MainAbility onForeground") - } - - onBackground() { - // Ability has back to background - console.log("[Demo] MainAbility onBackground") - } +import Ability from '@ohos.app.ability.UIAbility' + +export default class MainAbility extends Ability { + onCreate(want, launchParam) { + // Ability is creating, initialize resources for this ability + console.log("[Demo] MainAbility onCreate") + globalThis.abilityWant = want; + } + + onDestroy() { + // Ability is destroying, release resources for this ability + console.log("[Demo] MainAbility onDestroy") + } + + async onWindowStageCreate(windowStage) { + console.log("[Demo] MainAbility onWindowStageCreate windowStage=" + windowStage) + globalThis.windowStage = windowStage + globalThis.abilityContext = this.context + windowStage.setUIContent(this.context, "MainAbility/pages/index/index", null) + } + + onWindowStageDestroy() { + //Main window is destroyed, release UI related resources + console.log("[Demo] MainAbility onWindowStageDestroy") + } + + onForeground() { + // Ability has brought to foreground + console.log("[Demo] MainAbility onForeground") + } + + onBackground() { + // Ability has back to background + console.log("[Demo] MainAbility onBackground") + } }; \ No newline at end of file diff --git a/multimedia/medialibrary/mediaLibrary_getThumbnail/entry/src/main/ets/pages/index/index.ets b/multimedia/medialibrary/mediaLibrary_album/entry/src/main/ets/MainAbility/pages/index/index.ets old mode 100755 new mode 100644 similarity index 58% rename from multimedia/medialibrary/mediaLibrary_getThumbnail/entry/src/main/ets/pages/index/index.ets rename to multimedia/medialibrary/mediaLibrary_album/entry/src/main/ets/MainAbility/pages/index/index.ets index e45e49a3b7b1f7478c19dfae76022aff91a6896e..6a8c567d5a86048b1c269e4f00cc288ec136200b --- a/multimedia/medialibrary/mediaLibrary_getThumbnail/entry/src/main/ets/pages/index/index.ets +++ b/multimedia/medialibrary/mediaLibrary_album/entry/src/main/ets/MainAbility/pages/index/index.ets @@ -12,10 +12,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import file from '@system.file'; +import router from '@ohos.router'; +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' +import { Hypium } from '@ohos/hypium' +import testsuite from '../../../test/List.test' -import {Core, ExpectExtend, InstrumentLog, ReportExtend} from "deccjsunit/index" -import testsuite from "../../test/List.test.ets" @Entry @Component @@ -23,24 +24,12 @@ struct Index { aboutToAppear(){ console.info("start run testcase!!!!") - const core = Core.getInstance() - const expectExtend = new ExpectExtend({ - 'id': 'extend' - }) - core.addService('expect', expectExtend) - const reportExtend = new ReportExtend(file) - - core.addService('report', reportExtend) - core.init() - core.subscribeEvent('task', reportExtend) - const configService = core.getDefaultService('config') - console.info('parameters---->' + JSON.stringify(globalThis.abilityWant.parameters)) - globalThis.abilityWant.parameters.timeout = 70000; - configService.setConfig(globalThis.abilityWant.parameters) - console.info('testsuite()---->') - testsuite(globalThis.abilityContext) - core.execute() - console.info('core.execute()---->') + var abilityDelegator: any + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var abilityDelegatorArguments: any + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + console.info('start run testcase!!!') + Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) } build() { diff --git a/multimedia/medialibrary/mediaLibrary_album/entry/src/main/ets/TestAbility/TestAbility.ts b/multimedia/medialibrary/mediaLibrary_album/entry/src/main/ets/TestAbility/TestAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..8028a70f8af44690b95a08bd177bca6b09f24687 --- /dev/null +++ b/multimedia/medialibrary/mediaLibrary_album/entry/src/main/ets/TestAbility/TestAbility.ts @@ -0,0 +1,50 @@ +/* + * 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 Ability from '@ohos.app.ability.UIAbility' + +export default class TestAbility extends Ability { + onCreate(want, launchParam) { + console.log('TestAbility onCreate') + } + + onDestroy() { + console.log('TestAbility onDestroy') + } + + onWindowStageCreate(windowStage) { + console.log('TestAbility onWindowStageCreate') + windowStage.loadContent("TestAbility/pages/index", (err, data) => { + if (err.code) { + console.error('Failed to load the content. Cause:' + JSON.stringify(err)); + return; + } + console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data)) + }); + + globalThis.abilityContext = this.context; + } + + onWindowStageDestroy() { + console.log('TestAbility onWindowStageDestroy') + } + + onForeground() { + console.log('TestAbility onForeground') + } + + onBackground() { + console.log('TestAbility onBackground') + } +}; \ No newline at end of file diff --git a/multimedia/medialibrary/mediaLibrary_album/entry/src/main/ets/TestAbility/pages/index.ets b/multimedia/medialibrary/mediaLibrary_album/entry/src/main/ets/TestAbility/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..b93567f962921124b282f78c8ef123965d1460c9 --- /dev/null +++ b/multimedia/medialibrary/mediaLibrary_album/entry/src/main/ets/TestAbility/pages/index.ets @@ -0,0 +1,48 @@ +/* + * 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 router from '@ohos.router'; + +@Entry +@Component +struct Index { + aboutToAppear() { + console.info('TestAbility index aboutToAppear') + } + @State message: string = 'Hello World' + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('next page') + .fontSize(20) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .width('35%') + .height('5%') + .onClick(()=>{ + }) + } + .width('100%') + } + .height('100%') + } + } \ No newline at end of file diff --git a/multimedia/medialibrary/mediaLibrary_album/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts b/multimedia/medialibrary/mediaLibrary_album/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts new file mode 100644 index 0000000000000000000000000000000000000000..a4ee2f1652b3d04ce83ece64ef70f8dfa62a2dc8 --- /dev/null +++ b/multimedia/medialibrary/mediaLibrary_album/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts @@ -0,0 +1,78 @@ +/* + * 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 TestRunner from '@ohos.application.testRunner' +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' + +var abilityDelegator = undefined +var abilityDelegatorArguments = undefined + +function translateParamsToString(parameters) { + const keySet = new Set([ + '-s class', '-s notClass', '-s suite', '-s it', + '-s level', '-s testType', '-s size', '-s timeout', + '-s dryRun' + ]) + let targetParams = ''; + for (const key in parameters) { + if (keySet.has(key)) { + targetParams = `${targetParams} ${key} ${parameters[key]}` + } + } + return targetParams.trim() +} + +async function onAbilityCreateCallback() { + console.log("onAbilityCreateCallback"); +} + +async function addAbilityMonitorCallback(err: any) { + console.info("addAbilityMonitorCallback : " + JSON.stringify(err)) +} + +export default class OpenHarmonyTestRunner implements TestRunner { + constructor() { + } + + onPrepare() { + console.info("OpenHarmonyTestRunner OnPrepare ") + } + + async onRun() { + console.log('OpenHarmonyTestRunner onRun run') + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var testAbilityName = abilityDelegatorArguments.bundleName + '.MainAbility' + let lMonitor = { + abilityName: testAbilityName, + onAbilityCreate: onAbilityCreateCallback, + }; + abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback) + var cmd = 'aa start -d 0 -a com.example.myapplication.MainAbility' + ' -b ' + abilityDelegatorArguments.bundleName + cmd += ' '+translateParamsToString(abilityDelegatorArguments.parameters) + var debug = abilityDelegatorArguments.parameters["-D"] + if (debug == 'true') + { + cmd += ' -D' + } + console.info('cmd : '+cmd) + abilityDelegator.executeShellCommand(cmd, + (err: any, d: any) => { + console.info('executeShellCommand : err : ' + JSON.stringify(err)); + console.info('executeShellCommand : data : ' + d.stdResult); + console.info('executeShellCommand : data : ' + d.exitCode); + }) + console.info('OpenHarmonyTestRunner onRun end') + } +}; \ No newline at end of file diff --git a/multimedia/medialibrary/mediaLibrary_album/entry/src/main/ets/pages/index/index.ets b/multimedia/medialibrary/mediaLibrary_album/entry/src/main/ets/pages/index/index.ets deleted file mode 100755 index ac301f98781abd45f4d9d98fd7ffecfde9053ed9..0000000000000000000000000000000000000000 --- a/multimedia/medialibrary/mediaLibrary_album/entry/src/main/ets/pages/index/index.ets +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import file from '@system.file'; - -import { Core, ExpectExtend, InstrumentLog, ReportExtend } from "deccjsunit/index" -import testsuite from "../../test/List.test.ets" - -@Entry -@Component -struct Index { - - aboutToAppear(){ - console.info("start run testcase!!!!") - const core = Core.getInstance() - const expectExtend = new ExpectExtend({ - 'id': 'extend' - }) - core.addService('expect', expectExtend) - const reportExtend = new ReportExtend(file) - - core.addService('report', reportExtend) - core.init() - core.subscribeEvent('task', reportExtend) - const configService = core.getDefaultService('config') - console.info('parameters---->' + JSON.stringify(globalThis.abilityWant.parameters)) - globalThis.abilityWant.parameters.timeout = 70000; - configService.setConfig(globalThis.abilityWant.parameters) - console.info('testsuite()---->') - testsuite(globalThis.abilityContext) - core.execute() - console.info('core.execute()---->') - } - - build() { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { - Text('Hello World') - .fontSize(50) - .fontWeight(FontWeight.Bold) - Button() { - Text('next page') - .fontSize(25) - .fontWeight(FontWeight.Bold) - }.type(ButtonType.Capsule) - .margin({ - top: 20 - }) - .backgroundColor('#0D9FFB') - .onClick(() => { - - }) - } - .width('100%') - .height('100%') - } -} \ No newline at end of file diff --git a/multimedia/medialibrary/mediaLibrary_album/entry/src/main/ets/pages/second/second.ets b/multimedia/medialibrary/mediaLibrary_album/entry/src/main/ets/pages/second/second.ets deleted file mode 100755 index 1f2a06b64cdadcc83027bb6797e24536a2c85757..0000000000000000000000000000000000000000 --- a/multimedia/medialibrary/mediaLibrary_album/entry/src/main/ets/pages/second/second.ets +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import router from '@system.router'; - -@Entry -@Component -struct Second { - private content: string = "Second Page" - - build() { - Flex({ direction: FlexDirection.Column,alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { - Text(`${this.content}`) - .fontSize(50) - .fontWeight(FontWeight.Bold) - Button() { - Text('back to index') - .fontSize(20) - .fontWeight(FontWeight.Bold) - }.type(ButtonType.Capsule) - .margin({ - top: 20 - }) - .backgroundColor('#0D9FFB') - .onClick(() => { - router.back() - }) - } - .width('100%') - .height('100%') - } -} \ No newline at end of file diff --git a/multimedia/medialibrary/mediaLibrary_album/entry/src/main/ets/test/List.test.ets b/multimedia/medialibrary/mediaLibrary_album/entry/src/main/ets/test/List.test.ets old mode 100755 new mode 100644 index a1815e3af63565a6051a434bc1351dbed77650b4..9ea0eb246a71ff70015c6e7866a1bb929827fe9f --- a/multimedia/medialibrary/mediaLibrary_album/entry/src/main/ets/test/List.test.ets +++ b/multimedia/medialibrary/mediaLibrary_album/entry/src/main/ets/test/List.test.ets @@ -1,24 +1,24 @@ -/* - * 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 albumGetFileAssetsCallbackTest from './albumGetFileAssetsCallback.test.ets' -import albumGetFileAssetsPromiseTest from './albumGetFileAssetsPromise.test.ets' -import albumTestCallBackTest from './albumTestCallBack.test.ets' -import albumTestPromiseTest from './albumTestPromise.test.ets' -export default function testsuite(abilityContext) { - albumGetFileAssetsCallbackTest(abilityContext) - albumGetFileAssetsPromiseTest(abilityContext) - albumTestPromiseTest(abilityContext) - albumTestCallBackTest(abilityContext) -} +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import albumGetFileAssetsCallbackTest from './albumGetFileAssetsCallback.test.ets' +import albumGetFileAssetsPromiseTest from './albumGetFileAssetsPromise.test.ets' +import albumTestCallBackTest from './albumTestCallBack.test.ets' +import albumTestPromiseTest from './albumTestPromise.test.ets' +export default function testsuite() { + albumGetFileAssetsCallbackTest(globalThis.abilityContext) + albumGetFileAssetsPromiseTest(globalThis.abilityContext) + albumTestPromiseTest(globalThis.abilityContext) + albumTestCallBackTest(globalThis.abilityContext) +} diff --git a/multimedia/medialibrary/mediaLibrary_album/entry/src/main/ets/test/albumGetFileAssetsCallback.test.ets b/multimedia/medialibrary/mediaLibrary_album/entry/src/main/ets/test/albumGetFileAssetsCallback.test.ets old mode 100755 new mode 100644 index a1ed61c33f7d62751ea95f95b162d27a7787e810..e628be50be05765b5fc12de94cdfca149be4c2ed --- a/multimedia/medialibrary/mediaLibrary_album/entry/src/main/ets/test/albumGetFileAssetsCallback.test.ets +++ b/multimedia/medialibrary/mediaLibrary_album/entry/src/main/ets/test/albumGetFileAssetsCallback.test.ets @@ -35,7 +35,7 @@ export default function albumGetFileAssetsCallbackTest(abilityContext) { const media = mediaLibrary.getMediaLibrary(abilityContext); beforeAll(async function () { console.info('beforeAll case'); - await getPermission(); + await getPermission(null, abilityContext); await checkPresetsAssets(media, 'ActsMediaLibraryAlbumTest'); }); beforeEach(function () { diff --git a/multimedia/medialibrary/mediaLibrary_album/entry/src/main/ets/test/albumGetFileAssetsPromise.test.ets b/multimedia/medialibrary/mediaLibrary_album/entry/src/main/ets/test/albumGetFileAssetsPromise.test.ets old mode 100755 new mode 100644 index 7806a225d7a003895bd42deb0a3965aaacc1ef1b..3556e0cd2404b3d12d03810010fb687571fccc6c --- a/multimedia/medialibrary/mediaLibrary_album/entry/src/main/ets/test/albumGetFileAssetsPromise.test.ets +++ b/multimedia/medialibrary/mediaLibrary_album/entry/src/main/ets/test/albumGetFileAssetsPromise.test.ets @@ -12,8 +12,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import mediaLibrary from '@ohos.multimedia.mediaLibrary'; -import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'; +import mediaLibrary from "@ohos.multimedia.mediaLibrary"; +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "deccjsunit/index"; import { sleep, @@ -25,31 +25,31 @@ import { albumTwoTypesFetchOps, albumThreeTypesFetchOps, checkAlbumsCount, -} from '../../../../../../common'; +} from "../../../../../../common"; export default function albumGetFileAssetsPromiseTest(abilityContext) { - describe('albumGetFileAssetsPromiseTest', function () { + describe("albumGetFileAssetsPromiseTest", function () { const media = mediaLibrary.getMediaLibrary(abilityContext); beforeAll(async function () { - console.info('beforeAll case'); + console.info("beforeAll case"); }); beforeEach(function () { - console.info('beforeEach case'); + console.info("beforeEach case"); }); afterEach(async function () { - console.info('afterEach case'); - await sleep() + console.info("afterEach case"); + await sleep(); }); afterAll(function () { - console.info('afterAll case'); + console.info("afterAll case"); }); // Exception request const abnormalFetchOp = { - selections: 'date_added < 0', + selections: "date_added < 0", selectionArgs: [], - order: 'date_added DESC LIMIT 0,1', - } + order: "date_added DESC LIMIT 0,1", + }; const checkAlbumAssetsCount = async function (done, testNum, fetchOp, expectAssetsCount, expectAlbumCount = 1) { try { @@ -58,30 +58,31 @@ export default function albumGetFileAssetsPromiseTest(abilityContext) { const albumCountPass = await checkAlbumsCount(done, testNum, albumList, expectAlbumCount); if (!albumCountPass) return; // one asset type - let op: mediaLibrary.MediaFetchOptions = - allFetchOp({ order: `date_added DESC LIMIT 0,${expectAssetsCount}` }) + let op: mediaLibrary.MediaFetchOptions = allFetchOp({ + order: `date_added DESC LIMIT 0,${expectAssetsCount}`, + }); let count = 0; for (const album of albumList) { let fetchFileResult = await album.getFileAssets(op); if (fetchFileResult == undefined) { - console.info(`${testNum} fetchFileResult undefined`) + console.info(`${testNum} fetchFileResult undefined`); expect(false).assertTrue(); done(); return; } count++; console.info(`${testNum}, expectAssetsCount: ${expectAssetsCount} - getCount: ${fetchFileResult.getCount()}`) + getCount: ${fetchFileResult.getCount()}`); expect(fetchFileResult.getCount()).assertEqual(expectAssetsCount); } expect(count).assertEqual(expectAlbumCount); done(); } catch (error) { - console.info(`${testNum}, error: ${error}`) + console.info(`${testNum}, error: ${error}`); expect(false).assertTrue(); done(); } - } + }; const checkAlbumAssetsNoOps = async function (done, testNum, fetchOp, expectAssetsCount, expectAlbumCount = 1) { try { const albumList = await media.getAlbums(fetchOp); @@ -93,21 +94,29 @@ export default function albumGetFileAssetsPromiseTest(abilityContext) { let fetchFileResult = await album.getFileAssets(); if (fetchFileResult == undefined) { - console.info(`${testNum} fetchFileResult undefined`) + console.info(`${testNum} fetchFileResult undefined`); expect(false).assertTrue(); done(); return; } - console.info(`${testNum}, getCount:expectAssetsCount - ${fetchFileResult.getCount()} : ${expectAssetsCount}`) + console.info( + `${testNum}, getCount:expectAssetsCount - ${fetchFileResult.getCount()} : ${expectAssetsCount}` + ); expect(fetchFileResult.getCount()).assertEqual(expectAssetsCount); done(); } catch (error) { - console.info(`${testNum}, error: ${error}`) + console.info(`${testNum}, error: ${error}`); expect(false).assertTrue(); done(); } - } - const abnormalAlbumAssetsCount = async function (done, testNum, fetchOp, expectAssetsCount, expectAlbumCount = 1) { + }; + const abnormalAlbumAssetsCount = async function ( + done, + testNum, + fetchOp, + expectAssetsCount, + expectAlbumCount = 1 + ) { try { const albumList = await media.getAlbums(fetchOp); // check album length @@ -116,21 +125,21 @@ export default function albumGetFileAssetsPromiseTest(abilityContext) { const album = albumList[0]; const fetchFileResult = await album.getFileAssets(abnormalFetchOp); if (fetchFileResult == undefined) { - console.info(`${testNum} fetchFileResult undefined`) + console.info(`${testNum} fetchFileResult undefined`); expect(false).assertTrue(); done(); return; } - console.info(`${testNum}, getCount: ${fetchFileResult.getCount()}`) - console.info(`${testNum}, expectAssetsCount: ${expectAssetsCount}`) + console.info(`${testNum}, getCount: ${fetchFileResult.getCount()}`); + console.info(`${testNum}, expectAssetsCount: ${expectAssetsCount}`); expect(fetchFileResult.getCount()).assertEqual(expectAssetsCount); done(); } catch (error) { - console.info(`${testNum} error: ${error}`) + console.info(`${testNum} error: ${error}`); expect(false).assertTrue(); done(); } - } + }; /** * @tc.number : SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_001_01 * @tc.name : getFileAssets @@ -139,11 +148,11 @@ export default function albumGetFileAssetsPromiseTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_001_01', 0, async function (done) { - const testNum = 'SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_001_01'; + it("SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_001_01", 0, async function (done) { + const testNum = "SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_001_01"; let assetsCount = 3; - let currentFetchOp = albumFetchOps(testNum, 'Pictures/', 'Static', IMAGE_TYPE) - await checkAlbumAssetsCount(done, testNum, currentFetchOp, assetsCount) + let currentFetchOp = albumFetchOps(testNum, "Pictures/", "Static", IMAGE_TYPE); + await checkAlbumAssetsCount(done, testNum, currentFetchOp, assetsCount); }); /** @@ -154,11 +163,11 @@ export default function albumGetFileAssetsPromiseTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_001_02', 0, async function (done) { - const testNum = 'SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_001_02'; + it("SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_001_02", 0, async function (done) { + const testNum = "SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_001_02"; let assetsCount = 3; - let currentFetchOp = albumFetchOps(testNum, 'Audios/', 'Static', AUDIO_TYPE) - await checkAlbumAssetsCount(done, testNum, currentFetchOp, assetsCount) + let currentFetchOp = albumFetchOps(testNum, "Audios/", "Static", AUDIO_TYPE); + await checkAlbumAssetsCount(done, testNum, currentFetchOp, assetsCount); }); /** @@ -169,11 +178,11 @@ export default function albumGetFileAssetsPromiseTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_001_03', 0, async function (done) { - const testNum = 'SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_001_03'; + it("SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_001_03", 0, async function (done) { + const testNum = "SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_001_03"; let assetsCount = 3; - let currentFetchOp = albumFetchOps(testNum, 'Videos/', 'Static', VIDEO_TYPE) - await checkAlbumAssetsCount(done, testNum, currentFetchOp, assetsCount) + let currentFetchOp = albumFetchOps(testNum, "Videos/", "Static", VIDEO_TYPE); + await checkAlbumAssetsCount(done, testNum, currentFetchOp, assetsCount); }); /** @@ -184,12 +193,15 @@ export default function albumGetFileAssetsPromiseTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_001_04', 0, async function (done) { - const testNum = 'SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_001_04'; + it("SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_001_04", 0, async function (done) { + const testNum = "SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_001_04"; let assetsCount = 3; - let currentFetchOp = albumTwoTypesFetchOps(testNum, ['Pictures/', 'Videos/'], 'Static', [IMAGE_TYPE, VIDEO_TYPE]) + let currentFetchOp = albumTwoTypesFetchOps(testNum, ["Pictures/", "Videos/"], "Static", [ + IMAGE_TYPE, + VIDEO_TYPE, + ]); let albumCount = 2; - await checkAlbumAssetsCount(done, testNum, currentFetchOp, assetsCount, albumCount) + await checkAlbumAssetsCount(done, testNum, currentFetchOp, assetsCount, albumCount); }); /** @@ -200,12 +212,15 @@ export default function albumGetFileAssetsPromiseTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_001_05', 0, async function (done) { - const testNum = 'SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_001_05'; + it("SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_001_05", 0, async function (done) { + const testNum = "SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_001_05"; let assetsCount = 3; - let currentFetchOp = albumTwoTypesFetchOps(testNum, ['Pictures/', 'Audios/'], 'Static', [IMAGE_TYPE, AUDIO_TYPE]) + let currentFetchOp = albumTwoTypesFetchOps(testNum, ["Pictures/", "Audios/"], "Static", [ + IMAGE_TYPE, + AUDIO_TYPE, + ]); let albumCount = 2; - await checkAlbumAssetsCount(done, testNum, currentFetchOp, assetsCount, albumCount) + await checkAlbumAssetsCount(done, testNum, currentFetchOp, assetsCount, albumCount); }); /** @@ -216,15 +231,18 @@ export default function albumGetFileAssetsPromiseTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_001_06', 0, async function (done) { - const testNum = 'SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_001_06'; + it("SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_001_06", 0, async function (done) { + const testNum = "SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_001_06"; let assetsCount = 3; - let currentFetchOp = albumTwoTypesFetchOps(testNum, ['Videos/', 'Audios/'], 'Static', [VIDEO_TYPE, AUDIO_TYPE]) + let currentFetchOp = albumTwoTypesFetchOps(testNum, ["Videos/", "Audios/"], "Static", [ + VIDEO_TYPE, + AUDIO_TYPE, + ]); let albumCount = 2; - await checkAlbumAssetsCount(done, testNum, currentFetchOp, assetsCount, albumCount) + await checkAlbumAssetsCount(done, testNum, currentFetchOp, assetsCount, albumCount); }); - /** + /** * @tc.number : SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_001_07 * @tc.name : getFileAssets * @tc.desc : Pictures Videos Audios types album get 3 resources @@ -232,27 +250,31 @@ export default function albumGetFileAssetsPromiseTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_001_07', 0, async function (done) { - const testNum = 'SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_001_07'; + it("SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_001_07", 0, async function (done) { + const testNum = "SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_001_07"; let assetsCount = 3; - let currentFetchOp = albumThreeTypesFetchOps(testNum, ['Pictures/', 'Videos/', 'Audios/'], 'Static', [IMAGE_TYPE, VIDEO_TYPE, AUDIO_TYPE]) + let currentFetchOp = albumThreeTypesFetchOps(testNum, ["Pictures/", "Videos/", "Audios/"], "Static", [ + IMAGE_TYPE, + VIDEO_TYPE, + AUDIO_TYPE, + ]); let albumCount = 3; - await checkAlbumAssetsCount(done, testNum, currentFetchOp, assetsCount, albumCount) + await checkAlbumAssetsCount(done, testNum, currentFetchOp, assetsCount, albumCount); }); /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_002_01 - * @tc.name : getFileAssets - * @tc.desc : Image type album get 1 resources - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_002_01', 0, async function (done) { - const testNum = 'SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_002_01'; + * @tc.number : SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_002_01 + * @tc.name : getFileAssets + * @tc.desc : Image type album get 1 resources + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it("SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_002_01", 0, async function (done) { + const testNum = "SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_002_01"; let assetsCount = 1; - let currentFetchOp = albumFetchOps(testNum, 'Pictures/', 'Static', IMAGE_TYPE) - await checkAlbumAssetsCount(done, testNum, currentFetchOp, assetsCount) + let currentFetchOp = albumFetchOps(testNum, "Pictures/", "Static", IMAGE_TYPE); + await checkAlbumAssetsCount(done, testNum, currentFetchOp, assetsCount); }); /** @@ -263,11 +285,11 @@ export default function albumGetFileAssetsPromiseTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_002_02', 0, async function (done) { - const testNum = 'SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_002_02'; + it("SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_002_02", 0, async function (done) { + const testNum = "SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_002_02"; let assetsCount = 1; - let currentFetchOp = albumFetchOps(testNum, 'Audios/', 'Static', AUDIO_TYPE) - await checkAlbumAssetsCount(done, testNum, currentFetchOp, assetsCount) + let currentFetchOp = albumFetchOps(testNum, "Audios/", "Static", AUDIO_TYPE); + await checkAlbumAssetsCount(done, testNum, currentFetchOp, assetsCount); }); /** @@ -278,11 +300,11 @@ export default function albumGetFileAssetsPromiseTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_002_03', 0, async function (done) { - const testNum = 'SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_002_03'; + it("SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_002_03", 0, async function (done) { + const testNum = "SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_002_03"; let assetsCount = 1; - let currentFetchOp = albumFetchOps(testNum, 'Videos/', 'Static', VIDEO_TYPE) - await checkAlbumAssetsCount(done, testNum, currentFetchOp, assetsCount) + let currentFetchOp = albumFetchOps(testNum, "Videos/", "Static", VIDEO_TYPE); + await checkAlbumAssetsCount(done, testNum, currentFetchOp, assetsCount); }); /** @@ -293,12 +315,15 @@ export default function albumGetFileAssetsPromiseTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_002_04', 0, async function (done) { - const testNum = 'SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_002_04'; + it("SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_002_04", 0, async function (done) { + const testNum = "SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_002_04"; let assetsCount = 1; - let currentFetchOp = albumTwoTypesFetchOps(testNum, ['Pictures/', 'Videos/'], 'Static', [IMAGE_TYPE, VIDEO_TYPE]) + let currentFetchOp = albumTwoTypesFetchOps(testNum, ["Pictures/", "Videos/"], "Static", [ + IMAGE_TYPE, + VIDEO_TYPE, + ]); let albumCount = 2; - await checkAlbumAssetsCount(done, testNum, currentFetchOp, assetsCount, albumCount) + await checkAlbumAssetsCount(done, testNum, currentFetchOp, assetsCount, albumCount); }); /** @@ -309,12 +334,15 @@ export default function albumGetFileAssetsPromiseTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_002_05', 0, async function (done) { - const testNum = 'SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_002_05'; + it("SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_002_05", 0, async function (done) { + const testNum = "SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_002_05"; let assetsCount = 1; - let currentFetchOp = albumTwoTypesFetchOps(testNum, ['Pictures/', 'Audios/'], 'Static', [IMAGE_TYPE, AUDIO_TYPE],) + let currentFetchOp = albumTwoTypesFetchOps(testNum, ["Pictures/", "Audios/"], "Static", [ + IMAGE_TYPE, + AUDIO_TYPE, + ]); let albumCount = 2; - await checkAlbumAssetsCount(done, testNum, currentFetchOp, assetsCount, albumCount) + await checkAlbumAssetsCount(done, testNum, currentFetchOp, assetsCount, albumCount); }); /** @@ -325,15 +353,18 @@ export default function albumGetFileAssetsPromiseTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_002_06', 0, async function (done) { - const testNum = 'SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_002_06'; + it("SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_002_06", 0, async function (done) { + const testNum = "SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_002_06"; let assetsCount = 1; - let currentFetchOp = albumTwoTypesFetchOps(testNum, ['Videos/', 'Audios/'], 'Static', [VIDEO_TYPE, AUDIO_TYPE]) + let currentFetchOp = albumTwoTypesFetchOps(testNum, ["Videos/", "Audios/"], "Static", [ + VIDEO_TYPE, + AUDIO_TYPE, + ]); let albumCount = 2; - await checkAlbumAssetsCount(done, testNum, currentFetchOp, assetsCount, albumCount) + await checkAlbumAssetsCount(done, testNum, currentFetchOp, assetsCount, albumCount); }); - /** + /** * @tc.number : SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_002_07 * @tc.name : getFileAssets * @tc.desc : Pictures Videos Audios types album get 1 resources @@ -341,16 +372,18 @@ export default function albumGetFileAssetsPromiseTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_002_07', 0, async function (done) { - const testNum = 'SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_002_07'; + it("SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_002_07", 0, async function (done) { + const testNum = "SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_002_07"; let assetsCount = 1; - let currentFetchOp = albumThreeTypesFetchOps(testNum, ['Pictures/', 'Videos/', 'Audios/'], 'Static', - [IMAGE_TYPE, VIDEO_TYPE, AUDIO_TYPE]) + let currentFetchOp = albumThreeTypesFetchOps(testNum, ["Pictures/", "Videos/", "Audios/"], "Static", [ + IMAGE_TYPE, + VIDEO_TYPE, + AUDIO_TYPE, + ]); let albumCount = 3; - await checkAlbumAssetsCount(done, testNum, currentFetchOp, assetsCount, albumCount) + await checkAlbumAssetsCount(done, testNum, currentFetchOp, assetsCount, albumCount); }); - /** * @tc.number : SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_003_01 * @tc.name : getFileAssets @@ -359,41 +392,41 @@ export default function albumGetFileAssetsPromiseTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_003_01', 0, async function (done) { - const testNum = 'SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_003_01'; - let currentFetchOp = albumFetchOps(testNum, 'Pictures/', 'Static', IMAGE_TYPE) + it("SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_003_01", 0, async function (done) { + const testNum = "SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_003_01"; + let currentFetchOp = albumFetchOps(testNum, "Pictures/", "Static", IMAGE_TYPE); let assetsCount = 0; - await abnormalAlbumAssetsCount(done, testNum, currentFetchOp, assetsCount) + await abnormalAlbumAssetsCount(done, testNum, currentFetchOp, assetsCount); }); /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_003_02 - * @tc.name : getFileAssets - * @tc.desc : no file type image - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_003_02', 0, async function (done) { - const testNum = 'SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_003_02'; - let currentFetchOp = albumFetchOps(testNum, 'Videos/', 'Static', VIDEO_TYPE) + * @tc.number : SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_003_02 + * @tc.name : getFileAssets + * @tc.desc : no file type image + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it("SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_003_02", 0, async function (done) { + const testNum = "SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_003_02"; + let currentFetchOp = albumFetchOps(testNum, "Videos/", "Static", VIDEO_TYPE); let assetsCount = 0; - await abnormalAlbumAssetsCount(done, testNum, currentFetchOp, assetsCount) + await abnormalAlbumAssetsCount(done, testNum, currentFetchOp, assetsCount); }); /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_003_03 - * @tc.name : getFileAssets - * @tc.desc : no file type image - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_003_03', 0, async function (done) { - const testNum = 'SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_003_03'; - let currentFetchOp = albumFetchOps(testNum, 'Audios/', 'Static', AUDIO_TYPE) + * @tc.number : SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_003_03 + * @tc.name : getFileAssets + * @tc.desc : no file type image + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it("SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_003_03", 0, async function (done) { + const testNum = "SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_003_03"; + let currentFetchOp = albumFetchOps(testNum, "Audios/", "Static", AUDIO_TYPE); let assetsCount = 0; - await abnormalAlbumAssetsCount(done, testNum, currentFetchOp, assetsCount) + await abnormalAlbumAssetsCount(done, testNum, currentFetchOp, assetsCount); }); /** @@ -404,11 +437,11 @@ export default function albumGetFileAssetsPromiseTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_004_01', 0, async function (done) { - const testNum = 'SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_004_01'; + it("SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_004_01", 0, async function (done) { + const testNum = "SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_004_01"; let assetsCount = 5; - let currentFetchOp = albumFetchOps(testNum, 'Pictures/', 'Static', IMAGE_TYPE) - await checkAlbumAssetsNoOps(done, testNum, currentFetchOp, assetsCount) + let currentFetchOp = albumFetchOps(testNum, "Pictures/", "Static", IMAGE_TYPE); + await checkAlbumAssetsNoOps(done, testNum, currentFetchOp, assetsCount); }); /** @@ -419,11 +452,11 @@ export default function albumGetFileAssetsPromiseTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_004_02', 0, async function (done) { - const testNum = 'SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_004_02'; + it("SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_004_02", 0, async function (done) { + const testNum = "SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_004_02"; let assetsCount = 5; - let currentFetchOp = albumFetchOps(testNum, 'Audios/', 'Static', AUDIO_TYPE) - await checkAlbumAssetsNoOps(done, testNum, currentFetchOp, assetsCount) + let currentFetchOp = albumFetchOps(testNum, "Audios/", "Static", AUDIO_TYPE); + await checkAlbumAssetsNoOps(done, testNum, currentFetchOp, assetsCount); }); /** @@ -434,11 +467,11 @@ export default function albumGetFileAssetsPromiseTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_004_03', 0, async function (done) { - const testNum = 'SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_004_03'; + it("SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_004_03", 0, async function (done) { + const testNum = "SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_004_03"; let assetsCount = 5; - let currentFetchOp = albumFetchOps(testNum, 'Videos/', 'Static', VIDEO_TYPE) - await checkAlbumAssetsNoOps(done, testNum, currentFetchOp, assetsCount) + let currentFetchOp = albumFetchOps(testNum, "Videos/", "Static", VIDEO_TYPE); + await checkAlbumAssetsNoOps(done, testNum, currentFetchOp, assetsCount); }); }); -} \ No newline at end of file +} 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 old mode 100755 new mode 100644 index 77eb83c49ab1c65c3d3296940c8e955d1e40f4c5..2e34978486d4f3413979668bbf8213486aae3a2b --- 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 @@ -13,8 +13,8 @@ * limitations under the License. */ -import mediaLibrary from '@ohos.multimedia.mediaLibrary'; -import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'; +import mediaLibrary from "@ohos.multimedia.mediaLibrary"; +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "deccjsunit/index"; import { sleep, @@ -27,23 +27,23 @@ import { albumTwoTypesFetchOps, albumThreeTypesFetchOps, checkAlbumsCount, -} from '../../../../../../common'; +} from "../../../../../../common"; export default function albumTestCallbackTest(abilityContext) { - describe('albumTestCallbackTest', function () { + describe("albumTestCallbackTest", function () { const media = mediaLibrary.getMediaLibrary(abilityContext); beforeAll(async function () { - console.info('beforeAll case'); + console.info("beforeAll case"); }); beforeEach(function () { - console.info('beforeEach case'); + console.info("beforeEach case"); }); afterEach(async function () { - console.info('afterEach case'); - await sleep() + console.info("afterEach case"); + await sleep(); }); afterAll(function () { - console.info('afterAll case'); + console.info("afterAll case"); }); function printAlbumMessage(testNum, album) { @@ -57,14 +57,14 @@ export default function albumTestCallbackTest(abilityContext) { } const props = { - albumName: 'Static', - albumUri: 'datashare:///media/album/', - count: 5 - } + albumName: "Static", + albumUri: "datashare:///media/album/", + count: 5, + }; const checkProps = async function (done, testNum, album, relativePaths) { printAlbumMessage(testNum, album); if (album.albumId == undefined || album.coverUri == undefined) { - console.info(`${testNum}, album.albumId or album.coverUri is undefined`) + console.info(`${testNum}, album.albumId or album.coverUri is undefined`); expect(false).assertTrue(); done(); return; @@ -73,9 +73,9 @@ export default function albumTestCallbackTest(abilityContext) { expect(album.albumUri).assertEqual(props.albumUri + album.albumId); expect(album.count).assertEqual(props.count); if (Array.isArray(relativePaths)) { - let i = relativePaths.indexOf(album.relativePath) + let i = relativePaths.indexOf(album.relativePath); if (i > -1) { - relativePaths.splice(i, 1) + relativePaths.splice(i, 1); } else { expect(false).assertTrue(); done(); @@ -83,12 +83,12 @@ export default function albumTestCallbackTest(abilityContext) { } else { expect(album.relativePath).assertEqual(relativePaths); } - } + }; const checkAlbumInfo = async function (done, testNum, fetchOp, relativePaths, expectAlbumCount) { try { media.getAlbums(fetchOp, async (err, albumList) => { - if(err) { - console.info(`${testNum}, err: ${err}`) + if (err) { + console.info(`${testNum}, err: ${err}`); expect(false).assertTrue(); done(); return; @@ -100,7 +100,7 @@ export default function albumTestCallbackTest(abilityContext) { checkProps(done, testNum, album, relativePaths); done(); } else { - let count = 0 + let count = 0; for (const album of albumList) { checkProps(done, testNum, album, relativePaths); count++; @@ -111,30 +111,30 @@ export default function albumTestCallbackTest(abilityContext) { } }); } catch (error) { - console.info(`${testNum}, failed: ${error}`) + console.info(`${testNum}, failed: ${error}`); expect(false).assertTrue(); done(); } - } + }; const abnormalAlbumCount = async function (done, testNum, fetchOp) { try { media.getAlbums(fetchOp, async (err, albumList) => { - if(err) { + if (err) { expect(true).assertTrue(); done(); return; } - console.info(`${testNum}, albumList.length: ${albumList.length}`) + console.info(`${testNum}, albumList.length: ${albumList.length}`); expect(albumList.length).assertEqual(0); done(); }); } catch (error) { - console.info(`${testNum} error: ${error}`) + console.info(`${testNum} error: ${error}`); expect(false).assertTrue(); done(); } - } + }; const abnormalAlbumCommitModify = async function (done, testNum, fetchOp, newName, expectAlbumCount) { try { @@ -144,22 +144,22 @@ export default function albumTestCallbackTest(abilityContext) { const album = albumList[0]; album.albumName = newName; album.commitModify(async (error) => { - if(error) { - console.info(`${testNum}, error.message: ${error.message} error.code: ${error.code}`) + 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`) + } + console.info(`${testNum}, commitModify error`); expect(false).assertTrue(); done(); }); } catch (error) { - console.info(`${testNum}, error: ${error}`) + console.info(`${testNum}, error: ${error}`); expect(false).assertTrue(); done(); } - } + }; const albumCommitModify = async function (done, testNum, fetchOp, newName, expectAlbumCount) { try { @@ -168,25 +168,25 @@ export default function albumTestCallbackTest(abilityContext) { if (!albumCountPass) return; const album = albumList[0]; const albumId = album.albumId; - console.info(`${testNum}, album.albumName(old): ${album.albumName}`) + console.info(`${testNum}, album.albumName(old): ${album.albumName}`); const oldAlbumName = album.albumName; album.albumName = newName; album.commitModify(async () => { - let currentfetchOp = idFetchOps(testNum, albumId) + let currentfetchOp = idFetchOps(testNum, albumId); const newAlbumList = await media.getAlbums(currentfetchOp); - console.info(`${testNum}, album.albumName(new): ${newAlbumList[0].albumName}`) + 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}`) + console.info(`${testNum}, error: ${error}`); expect(false).assertTrue(); done(); } - } - + }; + // ------------------------------ 001 test start ------------------------- /** * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETALBUM_CALLBACK_001_01 @@ -197,10 +197,10 @@ export default function albumTestCallbackTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_GETALBUM_CALLBACK_001_01', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_GETALBUM_CALLBACK_001_01'; - let currentFetchOp = albumFetchOps(testNum, 'Pictures/', 'Static', IMAGE_TYPE); - let relativePaths = 'Pictures/'; + it("SUB_MEDIA_MEDIALIBRARY_GETALBUM_CALLBACK_001_01", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_GETALBUM_CALLBACK_001_01"; + let currentFetchOp = albumFetchOps(testNum, "Pictures/", "Static", IMAGE_TYPE); + let relativePaths = "Pictures/"; let expectAlbumCount = 1; await checkAlbumInfo(done, testNum, currentFetchOp, relativePaths, expectAlbumCount); }); @@ -214,10 +214,10 @@ export default function albumTestCallbackTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_GETALBUM_CALLBACK_001_02', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_GETALBUM_CALLBACK_001_02'; - let currentFetchOp = albumFetchOps(testNum, 'Videos/', 'Static', VIDEO_TYPE); - let relativePaths = 'Videos/'; + it("SUB_MEDIA_MEDIALIBRARY_GETALBUM_CALLBACK_001_02", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_GETALBUM_CALLBACK_001_02"; + let currentFetchOp = albumFetchOps(testNum, "Videos/", "Static", VIDEO_TYPE); + let relativePaths = "Videos/"; let expectAlbumCount = 1; await checkAlbumInfo(done, testNum, currentFetchOp, relativePaths, expectAlbumCount); }); @@ -231,10 +231,10 @@ export default function albumTestCallbackTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_GETALBUM_CALLBACK_001_03', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_GETALBUM_CALLBACK_001_03'; - let currentFetchOp = albumFetchOps(testNum, 'Audios/', 'Static', AUDIO_TYPE); - let relativePaths = 'Audios/'; + it("SUB_MEDIA_MEDIALIBRARY_GETALBUM_CALLBACK_001_03", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_GETALBUM_CALLBACK_001_03"; + let currentFetchOp = albumFetchOps(testNum, "Audios/", "Static", AUDIO_TYPE); + let relativePaths = "Audios/"; let expectAlbumCount = 1; await checkAlbumInfo(done, testNum, currentFetchOp, relativePaths, expectAlbumCount); }); @@ -249,10 +249,13 @@ export default function albumTestCallbackTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_GETALBUM_CALLBACK_001_04', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_GETALBUM_CALLBACK_001_04'; - let currentFetchOp = albumTwoTypesFetchOps(testNum, ['Pictures/', 'Videos/'], 'Static', [IMAGE_TYPE, VIDEO_TYPE]) - let relativePaths = ['Pictures/', 'Videos/']; + it("SUB_MEDIA_MEDIALIBRARY_GETALBUM_CALLBACK_001_04", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_GETALBUM_CALLBACK_001_04"; + let currentFetchOp = albumTwoTypesFetchOps(testNum, ["Pictures/", "Videos/"], "Static", [ + IMAGE_TYPE, + VIDEO_TYPE, + ]); + let relativePaths = ["Pictures/", "Videos/"]; let expectAlbumCount = 2; await checkAlbumInfo(done, testNum, currentFetchOp, relativePaths, expectAlbumCount); }); @@ -267,10 +270,13 @@ export default function albumTestCallbackTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_GETALBUM_CALLBACK_001_05', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_GETALBUM_CALLBACK_001_05'; - let currentFetchOp = albumTwoTypesFetchOps(testNum, ['Pictures/', 'Audios/'], 'Static', [IMAGE_TYPE, AUDIO_TYPE]) - let relativePaths = ['Pictures/', 'Audios/']; + it("SUB_MEDIA_MEDIALIBRARY_GETALBUM_CALLBACK_001_05", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_GETALBUM_CALLBACK_001_05"; + let currentFetchOp = albumTwoTypesFetchOps(testNum, ["Pictures/", "Audios/"], "Static", [ + IMAGE_TYPE, + AUDIO_TYPE, + ]); + let relativePaths = ["Pictures/", "Audios/"]; let expectAlbumCount = 2; await checkAlbumInfo(done, testNum, currentFetchOp, relativePaths, expectAlbumCount); }); @@ -285,10 +291,13 @@ export default function albumTestCallbackTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_GETALBUM_CALLBACK_001_06', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_GETALBUM_CALLBACK_001_06'; - let currentFetchOp = albumTwoTypesFetchOps(testNum, ['Videos/', 'Audios/'], 'Static', [VIDEO_TYPE, AUDIO_TYPE]) - let relativePaths = ['Videos/', 'Audios/']; + it("SUB_MEDIA_MEDIALIBRARY_GETALBUM_CALLBACK_001_06", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_GETALBUM_CALLBACK_001_06"; + let currentFetchOp = albumTwoTypesFetchOps(testNum, ["Videos/", "Audios/"], "Static", [ + VIDEO_TYPE, + AUDIO_TYPE, + ]); + let relativePaths = ["Videos/", "Audios/"]; let expectAlbumCount = 2; await checkAlbumInfo(done, testNum, currentFetchOp, relativePaths, expectAlbumCount); }); @@ -303,10 +312,14 @@ export default function albumTestCallbackTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_GETALBUM_CALLBACK_001_07', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_GETALBUM_CALLBACK_001_07'; - let currentFetchOp = albumThreeTypesFetchOps(testNum, ['Pictures/', 'Videos/', 'Audios/'], 'Static', [IMAGE_TYPE, VIDEO_TYPE, AUDIO_TYPE]) - let relativePaths = ['Pictures/', 'Videos/', 'Audios/']; + it("SUB_MEDIA_MEDIALIBRARY_GETALBUM_CALLBACK_001_07", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_GETALBUM_CALLBACK_001_07"; + let currentFetchOp = albumThreeTypesFetchOps(testNum, ["Pictures/", "Videos/", "Audios/"], "Static", [ + IMAGE_TYPE, + VIDEO_TYPE, + AUDIO_TYPE, + ]); + let relativePaths = ["Pictures/", "Videos/", "Audios/"]; let expectAlbumCount = 3; await checkAlbumInfo(done, testNum, currentFetchOp, relativePaths, expectAlbumCount); }); @@ -321,14 +334,14 @@ export default function albumTestCallbackTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_GETALBUMASSETS_CALLBACK_002_06', 0, async function (done) { + it("SUB_MEDIA_MEDIALIBRARY_GETALBUMASSETS_CALLBACK_002_06", 0, async function (done) { let fileHasArgsfetchOp = { - selections: FILEKEY.MEDIA_TYPE + ' = ?', - selectionArgs: ['666'], + selections: FILEKEY.MEDIA_TYPE + " = ?", + selectionArgs: ["666"], }; - let testNum = 'SUB_MEDIA_MEDIALIBRARY_GETALBUMASSETS_CALLBACK_002_06' + let testNum = "SUB_MEDIA_MEDIALIBRARY_GETALBUMASSETS_CALLBACK_002_06"; - await abnormalAlbumCount(done, testNum, fileHasArgsfetchOp) + await abnormalAlbumCount(done, testNum, fileHasArgsfetchOp); }); /** @@ -339,14 +352,14 @@ export default function albumTestCallbackTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_GETALBUMASSETS_CALLBACK_002_07', 0, async function (done) { + it("SUB_MEDIA_MEDIALIBRARY_GETALBUMASSETS_CALLBACK_002_07", 0, async function (done) { let fileHasArgsfetchOp = { - selections: '666' + '= ?', + selections: "666" + "= ?", selectionArgs: [VIDEO_TYPE.toString()], }; - let testNum = 'SUB_MEDIA_MEDIALIBRARY_GETALBUMASSETS_CALLBACK_002_07' + let testNum = "SUB_MEDIA_MEDIALIBRARY_GETALBUMASSETS_CALLBACK_002_07"; - await abnormalAlbumCount(done, testNum, fileHasArgsfetchOp) + await abnormalAlbumCount(done, testNum, fileHasArgsfetchOp); }); /** @@ -357,13 +370,13 @@ export default function albumTestCallbackTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_GETALBUMASSETS_CALLBACK_002_08', 0, async function (done) { + it("SUB_MEDIA_MEDIALIBRARY_GETALBUMASSETS_CALLBACK_002_08", 0, async function (done) { let fileHasArgsfetchOp = { - selections: '666' + '= ?', - selectionArgs: ['666'], + selections: "666" + "= ?", + selectionArgs: ["666"], }; - let testNum = 'SUB_MEDIA_MEDIALIBRARY_GETALBUMASSETS_CALLBACK_002_08' - await abnormalAlbumCount(done, testNum, fileHasArgsfetchOp) + let testNum = "SUB_MEDIA_MEDIALIBRARY_GETALBUMASSETS_CALLBACK_002_08"; + await abnormalAlbumCount(done, testNum, fileHasArgsfetchOp); }); // ------------------------------ 002 test end ------------------------- @@ -376,31 +389,30 @@ export default function albumTestCallbackTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_MODIFYALBUM_CALLBACK_003_01', 0, async function (done) { - const testNum = 'SUB_MEDIA_MEDIALIBRARY_MODIFYALBUM_CALLBACK_003_01'; + it("SUB_MEDIA_MEDIALIBRARY_MODIFYALBUM_CALLBACK_003_01", 0, async function (done) { + const testNum = "SUB_MEDIA_MEDIALIBRARY_MODIFYALBUM_CALLBACK_003_01"; try { - let currentFetchOp = albumFetchOps(testNum, 'Pictures/', 'DynamicCb1', IMAGE_TYPE); + let currentFetchOp = albumFetchOps(testNum, "Pictures/", "DynamicCb1", IMAGE_TYPE); const albumList = await media.getAlbums(currentFetchOp); const expectAlbumCount = 1; const albumCountPass = await checkAlbumsCount(done, testNum, albumList, expectAlbumCount); if (!albumCountPass) return; const album = albumList[0]; const albumId = album.albumId; - console.info(`${testNum}, album.albumName(old): ${album.albumName}`) - const newName = 'albumName' + new Date().getTime(); + console.info(`${testNum}, album.albumName(old): ${album.albumName}`); + const newName = "albumName" + new Date().getTime(); album.albumName = newName; album.commitModify(async () => { - let currentfetchOp = idFetchOps(testNum, albumId) + let currentfetchOp = idFetchOps(testNum, albumId); const newAlbumList = await media.getAlbums(currentfetchOp); - console.info(`${testNum}, album.albumName(new): ${newAlbumList[0].albumName}`) + console.info(`${testNum}, album.albumName(new): ${newAlbumList[0].albumName}`); expect(newAlbumList[0].albumName).assertEqual(newName); - album.albumName = 'DynamicCb1'; + album.albumName = "DynamicCb1"; await album.commitModify(); done(); }); - } catch (error) { - console.info(`${testNum}, failed error: ${error}`) + console.info(`${testNum}, failed error: ${error}`); expect(false).assertTrue(); done(); } @@ -414,12 +426,12 @@ export default function albumTestCallbackTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_MODIFYALBUM_CALLBACK_003_02', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_MODIFYALBUM_CALLBACK_003_02'; - let currentFetchOp = albumFetchOps(testNum, 'Pictures/', 'DynamicCb2', IMAGE_TYPE); - let newName = ''; + it("SUB_MEDIA_MEDIALIBRARY_MODIFYALBUM_CALLBACK_003_02", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_MODIFYALBUM_CALLBACK_003_02"; + let currentFetchOp = albumFetchOps(testNum, "Pictures/", "DynamicCb2", IMAGE_TYPE); + let newName = ""; let expectAlbumCount = 1; - await abnormalAlbumCommitModify(done, testNum, currentFetchOp, newName, expectAlbumCount) + await abnormalAlbumCommitModify(done, testNum, currentFetchOp, newName, expectAlbumCount); }); /** @@ -430,15 +442,15 @@ export default function albumTestCallbackTest(abilityContext) { * @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/', 'DynamicCb3', IMAGE_TYPE); + 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/", "DynamicCb3", IMAGE_TYPE); let newName = ""; for (var i = 0; i < 256; i++) { newName += "a"; } let expectAlbumCount = 1; - await abnormalAlbumCommitModify(done, testNum, currentFetchOp, newName, expectAlbumCount) + await abnormalAlbumCommitModify(done, testNum, currentFetchOp, newName, expectAlbumCount); }); /** @@ -449,15 +461,15 @@ export default function albumTestCallbackTest(abilityContext) { * @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); + 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) + await abnormalAlbumCommitModify(done, testNum, currentFetchOp, newName, expectAlbumCount); }); /** @@ -468,15 +480,15 @@ export default function albumTestCallbackTest(abilityContext) { * @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); + 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) + await albumCommitModify(done, testNum, currentFetchOp, newName, expectAlbumCount); }); /** @@ -487,18 +499,16 @@ export default function albumTestCallbackTest(abilityContext) { * @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); + 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) + 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 old mode 100755 new mode 100644 index 5755d4baf0219cef8c179725e608ef92aee39c52..30fc65226f48260759999b3461a1b12a1bee200f --- 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 @@ -13,8 +13,8 @@ * limitations under the License. */ -import mediaLibrary from '@ohos.multimedia.mediaLibrary'; -import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'; +import mediaLibrary from "@ohos.multimedia.mediaLibrary"; +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "deccjsunit/index"; import { sleep, @@ -27,23 +27,23 @@ import { albumTwoTypesFetchOps, albumThreeTypesFetchOps, checkAlbumsCount, -} from '../../../../../../common'; +} from "../../../../../../common"; export default function albumTestPromiseTest(abilityContext) { - describe('albumTestPromiseTest', function () { + describe("albumTestPromiseTest", function () { const media = mediaLibrary.getMediaLibrary(abilityContext); beforeAll(async function () { - console.info('beforeAll case'); + console.info("beforeAll case"); }); beforeEach(function () { - console.info('beforeEach case'); + console.info("beforeEach case"); }); afterEach(async function () { - console.info('afterEach case'); - await sleep() + console.info("afterEach case"); + await sleep(); }); afterAll(function () { - console.info('afterAll case'); + console.info("afterAll case"); }); function printAlbumMessage(testNum, album) { @@ -57,14 +57,14 @@ export default function albumTestPromiseTest(abilityContext) { } const props = { - albumName: 'Static', - albumUri: 'datashare:///media/album/', - count: 5 - } + albumName: "Static", + albumUri: "datashare:///media/album/", + count: 5, + }; const checkProps = async function (done, testNum, album, relativePaths) { printAlbumMessage(testNum, album); if (album.albumId == undefined || album.coverUri == undefined) { - console.info(`${testNum}, album.albumId or album.coverUri is undefined`) + console.info(`${testNum}, album.albumId or album.coverUri is undefined`); expect(false).assertTrue(); done(); return; @@ -73,9 +73,9 @@ export default function albumTestPromiseTest(abilityContext) { expect(album.albumUri).assertEqual(props.albumUri + album.albumId); expect(album.count).assertEqual(props.count); if (Array.isArray(relativePaths)) { - let i = relativePaths.indexOf(album.relativePath) + let i = relativePaths.indexOf(album.relativePath); if (i > -1) { - relativePaths.splice(i, 1) + relativePaths.splice(i, 1); } else { expect(false).assertTrue(); done(); @@ -83,7 +83,7 @@ export default function albumTestPromiseTest(abilityContext) { } else { expect(album.relativePath).assertEqual(relativePaths); } - } + }; const checkAlbumInfo = async function (done, testNum, fetchOp, relativePaths, expectAlbumCount = 1) { try { const albumList = await media.getAlbums(fetchOp); @@ -94,7 +94,7 @@ export default function albumTestPromiseTest(abilityContext) { checkProps(done, testNum, album, relativePaths); done(); } else { - let count = 0 + let count = 0; for (const album of albumList) { checkProps(done, testNum, album, relativePaths); count++; @@ -104,37 +104,37 @@ export default function albumTestPromiseTest(abilityContext) { done(); } } catch (error) { - console.info(`${testNum}, failed: ${error}`) + console.info(`${testNum}, failed: ${error}`); expect(false).assertTrue(); done(); } - } + }; const abnormalAlbumCount = async function (done, testNum, fetchOp) { try { const albumList = await media.getAlbums(fetchOp); - console.info(`${testNum}, albumList.length: ${albumList.length}`) + console.info(`${testNum}, albumList.length: ${albumList.length}`); expect(albumList.length).assertEqual(0); done(); } catch (error) { - console.info(`${testNum} error: ${error}`) + console.info(`${testNum} error: ${error}`); expect(false).assertTrue(); done(); } - } + }; const queryConditionAbnormal = async function (done, testNum, fetchOp) { try { - console.info(`${testNum}, fetchOp: ${JSON.stringify(fetchOp)}`) + console.info(`${testNum}, fetchOp: ${JSON.stringify(fetchOp)}`); const albumList = await media.getAlbums(fetchOp); expect(false).assertTrue(); done(); } catch (error) { - console.info(`${testNum},query condition abnormal error: ${error}`) + console.info(`${testNum},query condition abnormal error: ${error}`); expect(true).assertTrue(); done(); } - } + }; const abnormalAlbumCommitModify = async function (done, testNum, fetchOp, newName, expectAlbumCount) { try { @@ -144,40 +144,40 @@ export default function albumTestPromiseTest(abilityContext) { const album = albumList[0]; album.albumName = newName; await album.commitModify(); - console.info(`${testNum}, failed`) + console.info(`${testNum}, failed`); expect(false).assertTrue(); done(); } catch (error) { - console.info(`${testNum}, error.message: ${error.message} error.code: ${error.code}`) - expect(error.code!=undefined).assertTrue(); + console.info(`${testNum}, error.message: ${error.message} error.code: ${error.code}`); + expect(error.code != undefined).assertTrue(); done(); } - } + }; - const albumCommitModify = async function (done, testNum, fetchOp, newName, expectAlbumCount) { + 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}`) + console.info(`${testNum}, album.albumName(old): ${album.albumName}`); const oldAlbumName = album.albumName; album.albumName = newName; await album.commitModify(); - let currentfetchOp = idFetchOps(testNum, albumId) + let currentfetchOp = idFetchOps(testNum, albumId); const newAlbumList = await media.getAlbums(currentfetchOp); - console.info(`${testNum}, album.albumName(new): ${newAlbumList[0].albumName}`) + 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}`) + console.info(`${testNum}, error: ${error}`); expect(false).assertTrue(); done(); } - } + }; // ------------------------------ 001 test start ------------------------- /** * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETALBUM_PROMISE_001_01 @@ -188,10 +188,10 @@ export default function albumTestPromiseTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_GETALBUM_PROMISE_001_01', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_GETALBUM_PROMISE_001_01'; - let currentFetchOp = albumFetchOps(testNum, 'Pictures/', 'Static', IMAGE_TYPE); - let relativePaths = 'Pictures/'; + it("SUB_MEDIA_MEDIALIBRARY_GETALBUM_PROMISE_001_01", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_GETALBUM_PROMISE_001_01"; + let currentFetchOp = albumFetchOps(testNum, "Pictures/", "Static", IMAGE_TYPE); + let relativePaths = "Pictures/"; await checkAlbumInfo(done, testNum, currentFetchOp, relativePaths); }); @@ -204,10 +204,10 @@ export default function albumTestPromiseTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_GETALBUM_PROMISE_001_02', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_GETALBUM_PROMISE_001_02'; - let currentFetchOp = albumFetchOps(testNum, 'Videos/', 'Static', VIDEO_TYPE); - let relativePaths = 'Videos/'; + it("SUB_MEDIA_MEDIALIBRARY_GETALBUM_PROMISE_001_02", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_GETALBUM_PROMISE_001_02"; + let currentFetchOp = albumFetchOps(testNum, "Videos/", "Static", VIDEO_TYPE); + let relativePaths = "Videos/"; await checkAlbumInfo(done, testNum, currentFetchOp, relativePaths); }); @@ -220,10 +220,10 @@ export default function albumTestPromiseTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_GETALBUM_PROMISE_001_03', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_GETALBUM_PROMISE_001_03'; - let currentFetchOp = albumFetchOps(testNum, 'Audios/', 'Static', AUDIO_TYPE); - let relativePaths = 'Audios/'; + it("SUB_MEDIA_MEDIALIBRARY_GETALBUM_PROMISE_001_03", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_GETALBUM_PROMISE_001_03"; + let currentFetchOp = albumFetchOps(testNum, "Audios/", "Static", AUDIO_TYPE); + let relativePaths = "Audios/"; await checkAlbumInfo(done, testNum, currentFetchOp, relativePaths); }); @@ -237,10 +237,13 @@ export default function albumTestPromiseTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_GETALBUM_PROMISE_001_04', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_GETALBUM_PROMISE_001_04'; - let currentFetchOp = albumTwoTypesFetchOps(testNum, ['Pictures/', 'Videos/'], 'Static', [IMAGE_TYPE, VIDEO_TYPE]) - let relativePaths = ['Pictures/', 'Videos/']; + it("SUB_MEDIA_MEDIALIBRARY_GETALBUM_PROMISE_001_04", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_GETALBUM_PROMISE_001_04"; + let currentFetchOp = albumTwoTypesFetchOps(testNum, ["Pictures/", "Videos/"], "Static", [ + IMAGE_TYPE, + VIDEO_TYPE, + ]); + let relativePaths = ["Pictures/", "Videos/"]; let albumCount = 2; await checkAlbumInfo(done, testNum, currentFetchOp, relativePaths, albumCount); }); @@ -255,10 +258,13 @@ export default function albumTestPromiseTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_GETALBUM_PROMISE_001_05', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_GETALBUM_PROMISE_001_05'; - let currentFetchOp = albumTwoTypesFetchOps(testNum, ['Pictures/', 'Audios/'], 'Static', [IMAGE_TYPE, AUDIO_TYPE]) - let relativePaths = ['Pictures/', 'Audios/']; + it("SUB_MEDIA_MEDIALIBRARY_GETALBUM_PROMISE_001_05", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_GETALBUM_PROMISE_001_05"; + let currentFetchOp = albumTwoTypesFetchOps(testNum, ["Pictures/", "Audios/"], "Static", [ + IMAGE_TYPE, + AUDIO_TYPE, + ]); + let relativePaths = ["Pictures/", "Audios/"]; let albumCount = 2; await checkAlbumInfo(done, testNum, currentFetchOp, relativePaths, albumCount); }); @@ -273,10 +279,13 @@ export default function albumTestPromiseTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_GETALBUM_PROMISE_001_06', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_GETALBUM_PROMISE_001_06'; - let currentFetchOp = albumTwoTypesFetchOps(testNum, ['Videos/', 'Audios/'], 'Static', [VIDEO_TYPE, AUDIO_TYPE]) - let relativePaths = ['Videos/', 'Audios/']; + it("SUB_MEDIA_MEDIALIBRARY_GETALBUM_PROMISE_001_06", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_GETALBUM_PROMISE_001_06"; + let currentFetchOp = albumTwoTypesFetchOps(testNum, ["Videos/", "Audios/"], "Static", [ + VIDEO_TYPE, + AUDIO_TYPE, + ]); + let relativePaths = ["Videos/", "Audios/"]; let albumCount = 2; await checkAlbumInfo(done, testNum, currentFetchOp, relativePaths, albumCount); }); @@ -291,10 +300,14 @@ export default function albumTestPromiseTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_GETALBUM_PROMISE_001_07', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_GETALBUM_PROMISE_001_07'; - let currentFetchOp = albumThreeTypesFetchOps(testNum, ['Pictures/', 'Videos/', 'Audios/'], 'Static', [IMAGE_TYPE, VIDEO_TYPE, AUDIO_TYPE]) - let relativePaths = ['Pictures/', 'Videos/', 'Audios/']; + it("SUB_MEDIA_MEDIALIBRARY_GETALBUM_PROMISE_001_07", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_GETALBUM_PROMISE_001_07"; + let currentFetchOp = albumThreeTypesFetchOps(testNum, ["Pictures/", "Videos/", "Audios/"], "Static", [ + IMAGE_TYPE, + VIDEO_TYPE, + AUDIO_TYPE, + ]); + let relativePaths = ["Pictures/", "Videos/", "Audios/"]; let albumCount = 3; await checkAlbumInfo(done, testNum, currentFetchOp, relativePaths, albumCount); }); @@ -309,14 +322,14 @@ export default function albumTestPromiseTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_GETALBUMASSETS_PROMISE_002_06', 0, async function (done) { + it("SUB_MEDIA_MEDIALIBRARY_GETALBUMASSETS_PROMISE_002_06", 0, async function (done) { let fileHasArgsfetchOp = { - selections: FILEKEY.MEDIA_TYPE + ' = ?', - selectionArgs: ['666'], + selections: FILEKEY.MEDIA_TYPE + " = ?", + selectionArgs: ["666"], }; - let testNum = 'SUB_MEDIA_MEDIALIBRARY_GETALBUMASSETS_PROMISE_002_06' + let testNum = "SUB_MEDIA_MEDIALIBRARY_GETALBUMASSETS_PROMISE_002_06"; - await abnormalAlbumCount(done, testNum, fileHasArgsfetchOp) + await abnormalAlbumCount(done, testNum, fileHasArgsfetchOp); }); /** @@ -327,14 +340,14 @@ export default function albumTestPromiseTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_GETALBUMASSETS_PROMISE_002_07', 0, async function (done) { + it("SUB_MEDIA_MEDIALIBRARY_GETALBUMASSETS_PROMISE_002_07", 0, async function (done) { let fileHasArgsfetchOp = { - selections: '666' + '= ?', + selections: "666" + "= ?", selectionArgs: [VIDEO_TYPE.toString()], }; - let testNum = 'SUB_MEDIA_MEDIALIBRARY_GETALBUMASSETS_PROMISE_002_07' + let testNum = "SUB_MEDIA_MEDIALIBRARY_GETALBUMASSETS_PROMISE_002_07"; - await queryConditionAbnormal(done, testNum, fileHasArgsfetchOp) + await queryConditionAbnormal(done, testNum, fileHasArgsfetchOp); }); /** @@ -345,13 +358,13 @@ export default function albumTestPromiseTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_GETALBUMASSETS_PROMISE_002_08', 0, async function (done) { + it("SUB_MEDIA_MEDIALIBRARY_GETALBUMASSETS_PROMISE_002_08", 0, async function (done) { let fileHasArgsfetchOp = { - selections: '666' + '= ?', - selectionArgs: ['666'], + selections: "666" + "= ?", + selectionArgs: ["666"], }; - let testNum = 'SUB_MEDIA_MEDIALIBRARY_GETALBUMASSETS_PROMISE_002_08' - await queryConditionAbnormal(done, testNum, fileHasArgsfetchOp) + let testNum = "SUB_MEDIA_MEDIALIBRARY_GETALBUMASSETS_PROMISE_002_08"; + await queryConditionAbnormal(done, testNum, fileHasArgsfetchOp); }); // ------------------------------ 002 test end ------------------------- @@ -364,30 +377,30 @@ export default function albumTestPromiseTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_MODIFYALBUM_PROMISE_003_01', 0, async function (done) { - const testNum = 'SUB_MEDIA_MEDIALIBRARY_MODIFYALBUM_PROMISE_003_01'; + it("SUB_MEDIA_MEDIALIBRARY_MODIFYALBUM_PROMISE_003_01", 0, async function (done) { + const testNum = "SUB_MEDIA_MEDIALIBRARY_MODIFYALBUM_PROMISE_003_01"; try { - let currentFetchOp = albumFetchOps(testNum, 'Pictures/', 'DynamicPro1', IMAGE_TYPE); + let currentFetchOp = albumFetchOps(testNum, "Pictures/", "DynamicPro1", IMAGE_TYPE); const albumList = await media.getAlbums(currentFetchOp); const expectAlbumCount = 1; const albumCountPass = await checkAlbumsCount(done, testNum, albumList, expectAlbumCount); if (!albumCountPass) return; const album = albumList[0]; const albumId = album.albumId; - console.info(`${testNum}, album.albumName(old): ${album.albumName}`) - const newName = 'albumName' + new Date().getTime(); + console.info(`${testNum}, album.albumName(old): ${album.albumName}`); + const newName = "albumName" + new Date().getTime(); album.albumName = newName; await album.commitModify(); - let currentfetchOp = idFetchOps(testNum, albumId) + let currentfetchOp = idFetchOps(testNum, albumId); const newAlbumList = await media.getAlbums(currentfetchOp); - console.info(`${testNum}, album.albumName(new): ${newAlbumList[0].albumName}`) + console.info(`${testNum}, album.albumName(new): ${newAlbumList[0].albumName}`); expect(newAlbumList[0].albumName).assertEqual(newName); - album.albumName = 'DynamicPro1'; + album.albumName = "DynamicPro1"; await album.commitModify(); done(); } catch (error) { - console.info(`${testNum}, failed error: ${error}`) + console.info(`${testNum}, failed error: ${error}`); expect(false).assertTrue(); done(); } @@ -401,12 +414,12 @@ export default function albumTestPromiseTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_MODIFYALBUM_PROMISE_003_02', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_MODIFYALBUM_PROMISE_003_02'; - let currentFetchOp = albumFetchOps(testNum, 'Pictures/', 'DynamicPro2', IMAGE_TYPE); - let newName = ''; + it("SUB_MEDIA_MEDIALIBRARY_MODIFYALBUM_PROMISE_003_02", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_MODIFYALBUM_PROMISE_003_02"; + let currentFetchOp = albumFetchOps(testNum, "Pictures/", "DynamicPro2", IMAGE_TYPE); + let newName = ""; let expectAlbumCount = 1; - await abnormalAlbumCommitModify(done, testNum, currentFetchOp, newName, expectAlbumCount) + await abnormalAlbumCommitModify(done, testNum, currentFetchOp, newName, expectAlbumCount); }); /** @@ -417,15 +430,15 @@ export default function albumTestPromiseTest(abilityContext) { * @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/', 'DynamicPro3', IMAGE_TYPE); + 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/", "DynamicPro3", IMAGE_TYPE); let newName = ""; for (var i = 0; i < 256; i++) { newName += "a"; } let expectAlbumCount = 1; - await abnormalAlbumCommitModify(done, testNum, currentFetchOp, newName, expectAlbumCount) + await abnormalAlbumCommitModify(done, testNum, currentFetchOp, newName, expectAlbumCount); }); /** @@ -436,15 +449,15 @@ export default function albumTestPromiseTest(abilityContext) { * @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); + 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 < 86; i++) { newName += "中"; } let expectAlbumCount = 1; - await abnormalAlbumCommitModify(done, testNum, currentFetchOp, newName, expectAlbumCount) + await abnormalAlbumCommitModify(done, testNum, currentFetchOp, newName, expectAlbumCount); }); /** @@ -455,15 +468,15 @@ export default function albumTestPromiseTest(abilityContext) { * @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); + 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) + await albumCommitModify(done, testNum, currentFetchOp, newName, expectAlbumCount); }); /** @@ -474,15 +487,15 @@ export default function albumTestPromiseTest(abilityContext) { * @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); + 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) + await albumCommitModify(done, testNum, currentFetchOp, newName, expectAlbumCount); }); // ------------------------------ 003 test end ------------------------- @@ -495,16 +508,16 @@ export default function albumTestPromiseTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_GETALBUM_PROMISE_004_01', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_GETALBUM_PROMISE_004_01'; + it("SUB_MEDIA_MEDIALIBRARY_GETALBUM_PROMISE_004_01", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_GETALBUM_PROMISE_004_01"; try { let coverUrifetchOp = { - selections: '', + selections: "", selectionArgs: [], - order: 'date_added DESC LIMIT 0,1', + order: "date_added DESC LIMIT 0,1", }; let expectAlbumCount = 1; - let currentFetchOp = albumFetchOps(testNum, 'Pictures/', 'Static', IMAGE_TYPE); + let currentFetchOp = albumFetchOps(testNum, "Pictures/", "Static", IMAGE_TYPE); const albumList = await media.getAlbums(currentFetchOp); const albumCountPass = await checkAlbumsCount(done, testNum, albumList, expectAlbumCount); if (!albumCountPass) return; @@ -512,16 +525,16 @@ export default function albumTestPromiseTest(abilityContext) { const fetchFileResult = await album.getFileAssets(coverUrifetchOp); const asset = await fetchFileResult.getFirstObject(); if (asset == undefined) { - console.info(`${testNum} failed asset undefined`) + console.info(`${testNum} failed asset undefined`); expect(false).assertTrue(); done(); - return + return; } expect(asset.uri).assertEqual(album.coverUri); done(); } catch (error) { - console.info(`${testNum} failed error: ${error}`) + console.info(`${testNum} failed error: ${error}`); expect(false).assertTrue(); done(); } @@ -529,5 +542,3 @@ export default function albumTestPromiseTest(abilityContext) { // ------------------------------ 004 test end ------------------------- }); } - - diff --git a/multimedia/medialibrary/mediaLibrary_album/entry/src/main/module.json b/multimedia/medialibrary/mediaLibrary_album/entry/src/main/module.json old mode 100755 new mode 100644 index a1aa0cada29076a34f21189f99ad1f86dee4944a..025062ffed12b44b32db7f5f35356c9040ed9c5c --- a/multimedia/medialibrary/mediaLibrary_album/entry/src/main/module.json +++ b/multimedia/medialibrary/mediaLibrary_album/entry/src/main/module.json @@ -1,69 +1,69 @@ -{ - "module": { - "name": "phone", - "type": "entry", - "srcEntrance": "./ets/Application/AbilityStage.ts", - "description": "$string:mainability_description", - "mainElement": "MainAbility", - "deviceTypes": [ - "tablet", - "default", - "phone" - ], - "deliveryWithInstall": true, - "installationFree": false, - "uiSyntax": "ets", - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "ohos.acts.multimedia.mediaLibrary.MainAbility", - "srcEntrance": "./ets/MainAbility/MainAbility.ts", - "description": "$string:mainability_description", - "icon": "$media:icon", - "label": "$string:entry_MainAbility", - "visible": true, - "orientation": "portrait", - "skills": [ - { - "actions": [ - "action.system.home" - ], - "entities":[ - "entity.system.home" - ] - } - ] - } - ], - "requestPermissions": [ - { - "name": "ohos.permission.GET_BUNDLE_INFO", - "reason": "use ohos.permission.GET_BUNDLE_INFO" - }, - { - "name": "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED", - "reason":"use ohos.permission.GET_BUNDLE_INFO_PRIVILEGED" - }, - { - "name" : "ohos.permission.GRANT_SENSITIVE_PERMISSIONS", - "reason" : "use ohos.permission.GRANT_SENSITIVE_PERMISSIONS" - }, - { - "name" : "ohos.permission.REVOKE_SENSITIVE_PERMISSIONS", - "reason" : "use ohos.permission.REVOKE_SENSITIVE_PERMISSIONS" - }, - { - "name": "ohos.permission.MEDIA_LOCATION", - "reason":"use ohos.permission.MEDIA_LOCATION" - }, - { - "name": "ohos.permission.READ_MEDIA", - "reason":"use ohos.permission.READ_MEDIA" - }, - { - "name": "ohos.permission.WRITE_MEDIA", - "reason":"use ohos.permission.WRITE_MEDIA" - } - ] - } -} +{ + "module": { + "name": "phone", + "type": "entry", + "srcEntrance": "./ets/Application/AbilityStage.ts", + "description": "$string:phone_entry_dsc", + "mainElement": "MainAbility", + "deviceTypes": [ + "tablet", + "default", + "phone" + ], + "deliveryWithInstall": true, + "installationFree": false, + "uiSyntax": "ets", + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "com.example.myapplication.MainAbility", + "srcEntrance": "./ets/MainAbility/MainAbility.ts", + "description": "$string:phone_entry_main", + "icon": "$media:icon", + "label": "$string:entry_label", + "visible": true, + "orientation": "portrait", + "skills": [ + { + "actions": [ + "action.system.home" + ], + "entities": [ + "entity.system.home" + ] + } + ] + } + ], + "requestPermissions": [ + { + "name": "ohos.permission.GET_BUNDLE_INFO", + "reason": "use ohos.permission.GET_BUNDLE_INFO" + }, + { + "name": "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED", + "reason": "use ohos.permission.GET_BUNDLE_INFO_PRIVILEGED" + }, + { + "name": "ohos.permission.GRANT_SENSITIVE_PERMISSIONS", + "reason": "use ohos.permission.GRANT_SENSITIVE_PERMISSIONS" + }, + { + "name": "ohos.permission.REVOKE_SENSITIVE_PERMISSIONS", + "reason": "use ohos.permission.REVOKE_SENSITIVE_PERMISSIONS" + }, + { + "name": "ohos.permission.MEDIA_LOCATION", + "reason": "use ohos.permission.MEDIA_LOCATION" + }, + { + "name": "ohos.permission.READ_MEDIA", + "reason": "use ohos.permission.READ_MEDIA" + }, + { + "name": "ohos.permission.WRITE_MEDIA", + "reason": "use ohos.permission.WRITE_MEDIA" + } + ] + } +} \ No newline at end of file diff --git a/multimedia/medialibrary/mediaLibrary_album/entry/src/main/resources/base/element/string.json b/multimedia/medialibrary/mediaLibrary_album/entry/src/main/resources/base/element/string.json old mode 100755 new mode 100644 index 32237ee203edf64926964fb238fa44e396ddf577..2ae43f018e75d1140cf2c0c85a6a14fc369a0c50 --- a/multimedia/medialibrary/mediaLibrary_album/entry/src/main/resources/base/element/string.json +++ b/multimedia/medialibrary/mediaLibrary_album/entry/src/main/resources/base/element/string.json @@ -1,12 +1,32 @@ -{ - "string": [ - { - "name": "entry_MainAbility", - "value": "MediaLibraryJSTestMain" - }, - { - "name": "mainability_description", - "value": "MediaLibraryJSTestMain Ability" - } - ] - } \ No newline at end of file +{ + "string": [ + { + "name": "phone_entry_dsc", + "value": "i am an entry for phone" + }, + { + "name": "phone_entry_main", + "value": "the phone entry ability" + }, + { + "name": "entry_label", + "value": "ActsMediaLibraryTest" + }, + { + "name": "form_description", + "value": "mediaLibrary" + }, + { + "name": "serviceability_description", + "value": "mediaLibrary" + }, + { + "name": "description_application", + "value": "mediaLibrary test" + }, + { + "name": "app_name", + "value": "ActsMediaLibraryTest" + } + ] +} \ No newline at end of file diff --git a/multimedia/medialibrary/mediaLibrary_album/entry/src/main/resources/base/profile/main_pages.json b/multimedia/medialibrary/mediaLibrary_album/entry/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 index 96b478210df9884592229ae2db6f6bb7f86c14f4..ceb075cd80946aade673d707aac904fb8998bce9 --- a/multimedia/medialibrary/mediaLibrary_album/entry/src/main/resources/base/profile/main_pages.json +++ b/multimedia/medialibrary/mediaLibrary_album/entry/src/main/resources/base/profile/main_pages.json @@ -1,6 +1,5 @@ -{ - "src": [ - "pages/index/index", - "pages/second/second" - ] +{ + "src": [ + "MainAbility/pages/index/index" + ] } \ No newline at end of file diff --git a/multimedia/medialibrary/mediaLibrary_album/signature/openharmony_sx.p7b b/multimedia/medialibrary/mediaLibrary_album/signature/openharmony_sx.p7b old mode 100755 new mode 100644 index 3eb5b5db82a014ff4c9483872cad743ad49a9b6e..64b33bf079b2ab68a3f26f240d127186546b33d9 Binary files a/multimedia/medialibrary/mediaLibrary_album/signature/openharmony_sx.p7b and b/multimedia/medialibrary/mediaLibrary_album/signature/openharmony_sx.p7b differ diff --git a/multimedia/medialibrary/mediaLibrary_base/AppScope/app.json b/multimedia/medialibrary/mediaLibrary_base/AppScope/app.json old mode 100755 new mode 100644 index 5139eaad5d5fd2e2de13b4970785d6fa8ae1a4ba..803955ad0d2a5b4ce4e103816a6a917b4701286b --- a/multimedia/medialibrary/mediaLibrary_base/AppScope/app.json +++ b/multimedia/medialibrary/mediaLibrary_base/AppScope/app.json @@ -1,21 +1,21 @@ { - "app":{ - "bundleName":"ohos.acts.multimedia.mediaLibrary", - "vendor":"huawei", - "versionCode":1000000, - "versionName":"1.0.0", - "debug":false, - "icon":"$media:icon", - "label":"$string:entry_MainAbility", - "description":"$string:mainability_description", - "distributedNotificationEnabled":true, - "keepAlive":true, - "singleUser":true, - "minAPIVersion":8, - "targetAPIVersion":8, - "car":{ - "apiCompatibleVersion":8, - "singleUser":false + "app": { + "bundleName": "ohos.acts.multimedia.mediaLibrary", + "vendor": "huawei", + "versionCode": 1000000, + "versionName": "1.0.0", + "debug": false, + "icon": "$media:icon", + "label": "$string:app_name", + "description": "$string:description_application", + "distributedNotificationEnabled": true, + "keepAlive": true, + "singleUser": true, + "minAPIVersion": 9, + "targetAPIVersion": 9, + "car": { + "apiCompatibleVersion": 9, + "singleUser": false } } -} +} \ No newline at end of file diff --git a/multimedia/medialibrary/mediaLibrary_base/AppScope/resources/base/element/string.json b/multimedia/medialibrary/mediaLibrary_base/AppScope/resources/base/element/string.json old mode 100755 new mode 100644 index c1dee63527ae5e3c37f3736f6b68189e8df6f201..ee69f9a861d9dc269ed6638735d52674583498e1 --- a/multimedia/medialibrary/mediaLibrary_base/AppScope/resources/base/element/string.json +++ b/multimedia/medialibrary/mediaLibrary_base/AppScope/resources/base/element/string.json @@ -1,12 +1,8 @@ { - "string": [ + "string":[ { - "name": "entry_MainAbility", - "value": "MediaLibraryJSTestMain" - }, - { - "name": "mainability_description", - "value": "MediaLibraryJSTestMain Ability" + "name":"app_name", + "value":"ohosProject" } ] -} \ No newline at end of file +} \ No newline at end of file diff --git a/multimedia/medialibrary/mediaLibrary_base/BUILD.gn b/multimedia/medialibrary/mediaLibrary_base/BUILD.gn old mode 100755 new mode 100644 index 92707371dd4d5bda83b1fa76b09d30bee5e3c50b..6c245406c437668310a796dbb3ac0f4a847d0a43 --- a/multimedia/medialibrary/mediaLibrary_base/BUILD.gn +++ b/multimedia/medialibrary/mediaLibrary_base/BUILD.gn @@ -15,6 +15,7 @@ import("//test/xts/tools/build/suite.gni") ohos_js_hap_suite("mediaLibrary_base_hap") { hap_profile = "entry/src/main/module.json" + js_build_mode = "debug" deps = [ ":mediaLibrary_js_assets", ":mediaLibrary_resources", diff --git a/multimedia/medialibrary/mediaLibrary_base/MainAbility/MainAbility.ts b/multimedia/medialibrary/mediaLibrary_base/MainAbility/MainAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..df41851318f3385890e235a96dfbcc0441cb13f1 --- /dev/null +++ b/multimedia/medialibrary/mediaLibrary_base/MainAbility/MainAbility.ts @@ -0,0 +1,36 @@ +import Ability from '@ohos.app.ability.UIAbility' + +export default class MainAbility extends Ability { + onCreate(want, launchParam) { + // Ability is creating, initialize resources for this ability + console.log("[Demo] MainAbility onCreate") + globalThis.abilityWant = want; + } + + onDestroy() { + // Ability is destroying, release resources for this ability + console.log("[Demo] MainAbility onDestroy") + } + + async onWindowStageCreate(windowStage) { + console.log("[Demo] MainAbility onWindowStageCreate windowStage=" + windowStage) + globalThis.windowStage = windowStage + globalThis.abilityContext = this.context + windowStage.setUIContent(this.context, "MainAbility/pages/index/index", null) + } + + onWindowStageDestroy() { + //Main window is destroyed, release UI related resources + console.log("[Demo] MainAbility onWindowStageDestroy") + } + + onForeground() { + // Ability has brought to foreground + console.log("[Demo] MainAbility onForeground") + } + + onBackground() { + // Ability has back to background + console.log("[Demo] MainAbility onBackground") + } +}; \ No newline at end of file diff --git a/multimedia/medialibrary/mediaLibrary_mediafetchoptions/entry/src/main/ets/pages/index/index.ets b/multimedia/medialibrary/mediaLibrary_base/MainAbility/pages/index/index.ets similarity index 58% rename from multimedia/medialibrary/mediaLibrary_mediafetchoptions/entry/src/main/ets/pages/index/index.ets rename to multimedia/medialibrary/mediaLibrary_base/MainAbility/pages/index/index.ets index e45e49a3b7b1f7478c19dfae76022aff91a6896e..6a8c567d5a86048b1c269e4f00cc288ec136200b 100644 --- a/multimedia/medialibrary/mediaLibrary_mediafetchoptions/entry/src/main/ets/pages/index/index.ets +++ b/multimedia/medialibrary/mediaLibrary_base/MainAbility/pages/index/index.ets @@ -12,10 +12,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import file from '@system.file'; +import router from '@ohos.router'; +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' +import { Hypium } from '@ohos/hypium' +import testsuite from '../../../test/List.test' -import {Core, ExpectExtend, InstrumentLog, ReportExtend} from "deccjsunit/index" -import testsuite from "../../test/List.test.ets" @Entry @Component @@ -23,24 +24,12 @@ struct Index { aboutToAppear(){ console.info("start run testcase!!!!") - const core = Core.getInstance() - const expectExtend = new ExpectExtend({ - 'id': 'extend' - }) - core.addService('expect', expectExtend) - const reportExtend = new ReportExtend(file) - - core.addService('report', reportExtend) - core.init() - core.subscribeEvent('task', reportExtend) - const configService = core.getDefaultService('config') - console.info('parameters---->' + JSON.stringify(globalThis.abilityWant.parameters)) - globalThis.abilityWant.parameters.timeout = 70000; - configService.setConfig(globalThis.abilityWant.parameters) - console.info('testsuite()---->') - testsuite(globalThis.abilityContext) - core.execute() - console.info('core.execute()---->') + var abilityDelegator: any + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var abilityDelegatorArguments: any + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + console.info('start run testcase!!!') + Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) } build() { diff --git a/multimedia/medialibrary/mediaLibrary_base/Test.json b/multimedia/medialibrary/mediaLibrary_base/Test.json old mode 100755 new mode 100644 index 332ea17fc6ef953a7b738fb685d385f4691dc218..075d2c5c93ba252753b66ed9f4a4ed94677f2444 --- a/multimedia/medialibrary/mediaLibrary_base/Test.json +++ b/multimedia/medialibrary/mediaLibrary_base/Test.json @@ -1,10 +1,12 @@ { "description": "Configuration for mediaLibrary Tests", "driver": { - "type": "JSUnitTest", - "test-timeout": "300000", - "package": "ohos.acts.multimedia.mediaLibrary", - "shell-timeout": "600000" + "type": "OHJSUnitTest", + "test-timeout": "180000", + "bundle-name": "ohos.acts.multimedia.mediaLibrary", + "module-name": "phone", + "shell-timeout": "600000", + "testcase-timeout": 70000 }, "kits": [ { @@ -14,7 +16,10 @@ "rm -rf /storage/media/100/local/files/*", "rm -rf /data/app/el2/100/database/com.ohos.medialibrary.medialibrarydata/*", "mkdir -pv /storage/media/100/local/files/{Pictures,Videos,Audios,Documents}", - "mkdir -p /storage/media/100/local/temp" + "mkdir -p /storage/media/100/local/temp", + "power-shell wakeup", + "uinput -T -d 300 600 -m 300 600 300 100 -u 300 100", + "power-shell setmode 602" ] }, { @@ -47,8 +52,9 @@ "scanner", "sleep 10" ], - "teardown-command":[ - "hilog -b X -D 0xD002B70" + "teardown-command": [ + "hilog -b X -D 0xD002B70", + "power-shell setmode 600" ] }, { diff --git a/multimedia/medialibrary/mediaLibrary_base/entry/src/main/ets/Application/AbilityStage.ts b/multimedia/medialibrary/mediaLibrary_base/entry/src/main/ets/Application/AbilityStage.ts old mode 100755 new mode 100644 index 51cb02ba3f5c7011c1cd433d07deebd47a195704..e3fdadfebeeeb676df2ce8f78f4b59e26fae9cf0 --- a/multimedia/medialibrary/mediaLibrary_base/entry/src/main/ets/Application/AbilityStage.ts +++ b/multimedia/medialibrary/mediaLibrary_base/entry/src/main/ets/Application/AbilityStage.ts @@ -3,7 +3,7 @@ import AbilityStage from "@ohos.application.AbilityStage" export default class MyAbilityStage extends AbilityStage { onCreate() { console.log("[Demo] MyAbilityStage onCreate") - globalThis.stageOnCreateRun = 1; - globalThis.stageContext = this.context; + globalThis.stageOnCreateRun = 1; + globalThis.stageContext = this.context; } } diff --git a/multimedia/medialibrary/mediaLibrary_base/entry/src/main/ets/MainAbility/MainAbility.ts b/multimedia/medialibrary/mediaLibrary_base/entry/src/main/ets/MainAbility/MainAbility.ts old mode 100755 new mode 100644 index 2f9d6d1f23f95d9fc891fbc550cd5a589cfb6c89..f29c03aacc734d365c47927f6f1fcfc944391c39 --- a/multimedia/medialibrary/mediaLibrary_base/entry/src/main/ets/MainAbility/MainAbility.ts +++ b/multimedia/medialibrary/mediaLibrary_base/entry/src/main/ets/MainAbility/MainAbility.ts @@ -1,7 +1,20 @@ -import Ability from '@ohos.application.Ability' - +import Ability from '@ohos.app.ability.UIAbility' +import { + UiComponent, + UiDriver, + Component, + Driver, + UiWindow, + ON, + BY, + MatchPattern, + DisplayRotation, + ResizeDirection, + WindowMode, + PointerMatrix, +} from "@ohos.uitest"; export default class MainAbility extends Ability { - onCreate(want,launchParam){ + onCreate(want, launchParam) { // Ability is creating, initialize resources for this ability console.log("[Demo] MainAbility onCreate") globalThis.abilityWant = want; @@ -12,11 +25,47 @@ export default class MainAbility extends Ability { console.log("[Demo] MainAbility onDestroy") } - onWindowStageCreate(windowStage) { + async onWindowStageCreate(windowStage) { // Main window is created, set main page for this ability - console.log("[Demo] MainAbility onWindowStageCreate") + + + // var context = this.context + + // let array: Array = ["ohos.permission.MEDIA_LOCATION", "ohos.permission.READ_MEDIA", "ohos.permission.WRITE_MEDIA"]; + // //requestPermissionsFromUser会判断权限的授权状态来决定是否唤起弹窗 + // context.requestPermissionsFromUser(array).then(async function (data) { + // console.log("data type:" + JSON.stringify(data)); + // console.log("data:" + data); + // console.log("data permissions:" + data.permissions); + // console.log("data result:" + data.authResults); + // }, (err) => { + // console.error('Failed to start ability', err.code); + // }); + // console.info("getPermission 1"); + // await new Promise((res) => setTimeout(res, 200)); + + + // let driver = Driver.create(); + // console.info("getPermission 2"); + // console.info(`driver is ${JSON.stringify(driver)}`); + // await new Promise((res) => setTimeout(res, 200)); + + // let button = await driver.findComponent(ON.text("允许")); + + // while (button) { + // console.info(`button is ${JSON.stringify(button)}`); + // await new Promise((res) => setTimeout(res, 200)); + // await button.click(); + // button = await driver.findComponent(ON.text("允许")); + // } + // console.info("getPermission 3"); + + console.log("[Demo] MainAbility onWindowStageCreate windowStage=" + windowStage) + globalThis.windowStage = windowStage globalThis.abilityContext = this.context - windowStage.setUIContent(this.context, "pages/index/index", null) + windowStage.setUIContent(this.context, "MainAbility/pages/index/index", null) + console.info("getPermission 4"); + } onWindowStageDestroy() { diff --git a/multimedia/medialibrary/mediaLibrary_fileKey/entry/src/main/ets/pages/index/index.ets b/multimedia/medialibrary/mediaLibrary_base/entry/src/main/ets/MainAbility/pages/index/index.ets old mode 100755 new mode 100644 similarity index 58% rename from multimedia/medialibrary/mediaLibrary_fileKey/entry/src/main/ets/pages/index/index.ets rename to multimedia/medialibrary/mediaLibrary_base/entry/src/main/ets/MainAbility/pages/index/index.ets index e45e49a3b7b1f7478c19dfae76022aff91a6896e..c5b5c5c8cee4439dbe71bd5ce77b7862841c9650 --- a/multimedia/medialibrary/mediaLibrary_fileKey/entry/src/main/ets/pages/index/index.ets +++ b/multimedia/medialibrary/mediaLibrary_base/entry/src/main/ets/MainAbility/pages/index/index.ets @@ -12,10 +12,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import file from '@system.file'; +import router from '@ohos.router'; +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' +import { Hypium } from '@ohos/hypium' +import testsuite from '../../../test/List.test' -import {Core, ExpectExtend, InstrumentLog, ReportExtend} from "deccjsunit/index" -import testsuite from "../../test/List.test.ets" @Entry @Component @@ -23,24 +24,14 @@ struct Index { aboutToAppear(){ console.info("start run testcase!!!!") - const core = Core.getInstance() - const expectExtend = new ExpectExtend({ - 'id': 'extend' - }) - core.addService('expect', expectExtend) - const reportExtend = new ReportExtend(file) + console.info("getPermission 5"); - core.addService('report', reportExtend) - core.init() - core.subscribeEvent('task', reportExtend) - const configService = core.getDefaultService('config') - console.info('parameters---->' + JSON.stringify(globalThis.abilityWant.parameters)) - globalThis.abilityWant.parameters.timeout = 70000; - configService.setConfig(globalThis.abilityWant.parameters) - console.info('testsuite()---->') - testsuite(globalThis.abilityContext) - core.execute() - console.info('core.execute()---->') + var abilityDelegator: any + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var abilityDelegatorArguments: any + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + console.info('start run testcase!!!') + Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) } build() { diff --git a/multimedia/medialibrary/mediaLibrary_base/entry/src/main/ets/TestAbility/TestAbility.ts b/multimedia/medialibrary/mediaLibrary_base/entry/src/main/ets/TestAbility/TestAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..8028a70f8af44690b95a08bd177bca6b09f24687 --- /dev/null +++ b/multimedia/medialibrary/mediaLibrary_base/entry/src/main/ets/TestAbility/TestAbility.ts @@ -0,0 +1,50 @@ +/* + * 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 Ability from '@ohos.app.ability.UIAbility' + +export default class TestAbility extends Ability { + onCreate(want, launchParam) { + console.log('TestAbility onCreate') + } + + onDestroy() { + console.log('TestAbility onDestroy') + } + + onWindowStageCreate(windowStage) { + console.log('TestAbility onWindowStageCreate') + windowStage.loadContent("TestAbility/pages/index", (err, data) => { + if (err.code) { + console.error('Failed to load the content. Cause:' + JSON.stringify(err)); + return; + } + console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data)) + }); + + globalThis.abilityContext = this.context; + } + + onWindowStageDestroy() { + console.log('TestAbility onWindowStageDestroy') + } + + onForeground() { + console.log('TestAbility onForeground') + } + + onBackground() { + console.log('TestAbility onBackground') + } +}; \ No newline at end of file diff --git a/multimedia/medialibrary/mediaLibrary_base/entry/src/main/ets/TestAbility/pages/index.ets b/multimedia/medialibrary/mediaLibrary_base/entry/src/main/ets/TestAbility/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..b93567f962921124b282f78c8ef123965d1460c9 --- /dev/null +++ b/multimedia/medialibrary/mediaLibrary_base/entry/src/main/ets/TestAbility/pages/index.ets @@ -0,0 +1,48 @@ +/* + * 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 router from '@ohos.router'; + +@Entry +@Component +struct Index { + aboutToAppear() { + console.info('TestAbility index aboutToAppear') + } + @State message: string = 'Hello World' + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('next page') + .fontSize(20) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .width('35%') + .height('5%') + .onClick(()=>{ + }) + } + .width('100%') + } + .height('100%') + } + } \ No newline at end of file diff --git a/multimedia/medialibrary/mediaLibrary_base/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts b/multimedia/medialibrary/mediaLibrary_base/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts new file mode 100644 index 0000000000000000000000000000000000000000..a4ee2f1652b3d04ce83ece64ef70f8dfa62a2dc8 --- /dev/null +++ b/multimedia/medialibrary/mediaLibrary_base/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts @@ -0,0 +1,78 @@ +/* + * 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 TestRunner from '@ohos.application.testRunner' +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' + +var abilityDelegator = undefined +var abilityDelegatorArguments = undefined + +function translateParamsToString(parameters) { + const keySet = new Set([ + '-s class', '-s notClass', '-s suite', '-s it', + '-s level', '-s testType', '-s size', '-s timeout', + '-s dryRun' + ]) + let targetParams = ''; + for (const key in parameters) { + if (keySet.has(key)) { + targetParams = `${targetParams} ${key} ${parameters[key]}` + } + } + return targetParams.trim() +} + +async function onAbilityCreateCallback() { + console.log("onAbilityCreateCallback"); +} + +async function addAbilityMonitorCallback(err: any) { + console.info("addAbilityMonitorCallback : " + JSON.stringify(err)) +} + +export default class OpenHarmonyTestRunner implements TestRunner { + constructor() { + } + + onPrepare() { + console.info("OpenHarmonyTestRunner OnPrepare ") + } + + async onRun() { + console.log('OpenHarmonyTestRunner onRun run') + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var testAbilityName = abilityDelegatorArguments.bundleName + '.MainAbility' + let lMonitor = { + abilityName: testAbilityName, + onAbilityCreate: onAbilityCreateCallback, + }; + abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback) + var cmd = 'aa start -d 0 -a com.example.myapplication.MainAbility' + ' -b ' + abilityDelegatorArguments.bundleName + cmd += ' '+translateParamsToString(abilityDelegatorArguments.parameters) + var debug = abilityDelegatorArguments.parameters["-D"] + if (debug == 'true') + { + cmd += ' -D' + } + console.info('cmd : '+cmd) + abilityDelegator.executeShellCommand(cmd, + (err: any, d: any) => { + console.info('executeShellCommand : err : ' + JSON.stringify(err)); + console.info('executeShellCommand : data : ' + d.stdResult); + console.info('executeShellCommand : data : ' + d.exitCode); + }) + console.info('OpenHarmonyTestRunner onRun end') + } +}; \ No newline at end of file diff --git a/multimedia/medialibrary/mediaLibrary_base/entry/src/main/ets/pages/index/index.ets b/multimedia/medialibrary/mediaLibrary_base/entry/src/main/ets/pages/index/index.ets deleted file mode 100755 index 624cad290665fcd29dcd579d9582a300479e8ad7..0000000000000000000000000000000000000000 --- a/multimedia/medialibrary/mediaLibrary_base/entry/src/main/ets/pages/index/index.ets +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import file from '@system.file'; - -import {Core, ExpectExtend, InstrumentLog, ReportExtend} from "deccjsunit/index" -import testsuite from "../../test/List.test.ets" - -@Entry -@Component -struct Index { - - aboutToAppear(){ - - console.info("start run testcase!!!!") - const core = Core.getInstance() - const expectExtend = new ExpectExtend({ - 'id': 'extend' - }) - core.addService('expect', expectExtend) - const reportExtend = new ReportExtend(file) - - core.addService('report', reportExtend) - core.init() - core.subscribeEvent('task', reportExtend) - const configService = core.getDefaultService('config') - console.info('parameters---->' + JSON.stringify(globalThis.abilityWant.parameters)) - globalThis.abilityWant.parameters.timeout = 70000; - configService.setConfig(globalThis.abilityWant.parameters) - console.info('testsuite()---->') - testsuite(globalThis.abilityContext) - core.execute() - console.info('core.execute()---->') - } - - build() { - Flex({ direction:FlexDirection.Column, alignItems:ItemAlign.Center, justifyContent: FlexAlign.Center }) { - Text('Hello World') - .fontSize(50) - .fontWeight(FontWeight.Bold) - Button() { - Text('next page') - .fontSize(25) - .fontWeight(FontWeight.Bold) - }.type(ButtonType.Capsule) - .margin({ - top: 20 - }) - .backgroundColor('#0D9FFB') - .onClick(() => { - - }) - } - .width('100%') - .height('100%') - } -} \ No newline at end of file diff --git a/multimedia/medialibrary/mediaLibrary_base/entry/src/main/ets/pages/second/second.ets b/multimedia/medialibrary/mediaLibrary_base/entry/src/main/ets/pages/second/second.ets deleted file mode 100755 index 1c1c727ff11ecc97909f482c35268db87ae23bb4..0000000000000000000000000000000000000000 --- a/multimedia/medialibrary/mediaLibrary_base/entry/src/main/ets/pages/second/second.ets +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import router from '@system.router'; - -@Entry -@Component -struct Second { - private content: string = "Second Page" - - build() { - Flex({ direction: FlexDirection.Column,alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { - Text(`${this.content}`) - .fontSize(50) - .fontWeight(FontWeight.Bold) - Button() { - Text('back to index') - .fontSize(20) - .fontWeight(FontWeight.Bold) - }.type(ButtonType.Capsule) - .margin({ - top: 20 - }) - .backgroundColor('#0D9FFB') - .onClick(() => { - router.back() - }) - } - .width('100%') - .height('100%') - } -} \ No newline at end of file diff --git a/multimedia/medialibrary/mediaLibrary_base/entry/src/main/ets/test/List.test.ets b/multimedia/medialibrary/mediaLibrary_base/entry/src/main/ets/test/List.test.ets old mode 100755 new mode 100644 index 0e78d5fc4f068f548893a5172adfda1f7fd4b4ec..3b9148a4e3cfbe0ebcd665c963de2458fa306b72 --- a/multimedia/medialibrary/mediaLibrary_base/entry/src/main/ets/test/List.test.ets +++ b/multimedia/medialibrary/mediaLibrary_base/entry/src/main/ets/test/List.test.ets @@ -1,24 +1,24 @@ -/* - * 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 mediaLibraryTestCallback from './mediaLibraryTestCallback.test.ets' -import mediaLibraryTestPromise from './mediaLibraryTestPromise.test.ets' -import mediaLibraryTestPromiseOnOffTest from './mediaLibraryTestPromiseOnOff.test.ets' - -export default function testsuite(abilityContext) { - mediaLibraryTestCallback(abilityContext) - mediaLibraryTestPromise(abilityContext) - mediaLibraryTestPromiseOnOffTest(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 mediaLibraryTestCallback from './mediaLibraryTestCallback.test.ets' +import mediaLibraryTestPromise from './mediaLibraryTestPromise.test.ets' +import mediaLibraryTestPromiseOnOffTest from './mediaLibraryTestPromiseOnOff.test.ets' + +export default function testsuite() { + mediaLibraryTestCallback(globalThis.abilityContext) + mediaLibraryTestPromise(globalThis.abilityContext) + mediaLibraryTestPromiseOnOffTest(globalThis.abilityContext) +} diff --git a/multimedia/medialibrary/mediaLibrary_base/entry/src/main/ets/test/mediaLibraryTestCallback.test.ets b/multimedia/medialibrary/mediaLibrary_base/entry/src/main/ets/test/mediaLibraryTestCallback.test.ets old mode 100755 new mode 100644 index fd4b7b233fd402ef7cff13b39bcbfc64b8420f0d..b980fc42df5ed802ab4f06d922cba09b4c6e01b9 --- a/multimedia/medialibrary/mediaLibrary_base/entry/src/main/ets/test/mediaLibraryTestCallback.test.ets +++ b/multimedia/medialibrary/mediaLibrary_base/entry/src/main/ets/test/mediaLibraryTestCallback.test.ets @@ -12,9 +12,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import mediaLibrary from '@ohos.multimedia.mediaLibrary'; -import fileio from '@ohos.fileio'; -import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'; +import mediaLibrary from "@ohos.multimedia.mediaLibrary"; +import fileio from "@ohos.fileio"; +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "deccjsunit/index"; import { sleep, IMAGE_TYPE, @@ -27,43 +27,97 @@ import { fetchOps, getPermission, isNum, -} from '../../../../../../common'; - +} from "../../../../../../common"; export default function mediaLibraryTestCallback(abilityContext) { - describe('mediaLibraryTestCallback', function () { + describe("mediaLibraryTestCallback", function () { const media = mediaLibrary.getMediaLibrary(abilityContext); beforeAll(async function () { - console.info('beforeAll case'); - await getPermission(); - await checkPresetsAssets(media, 'ActsMediaLibraryBaseTest'); + console.info("beforeAll case"); + await getPermission(null, abilityContext); + await checkPresetsAssets(media, "ActsMediaLibraryBaseTest"); }); beforeEach(function () { - console.info('beforeEach case'); + console.info("beforeEach case"); }); afterEach(async function () { - console.info('afterEach case'); - await sleep(500) + console.info("afterEach case"); + await sleep(500); }); afterAll(function () { - console.info('afterAll case'); + console.info("afterAll case"); }); let imageAndVideofetchOp = { - selections: '(' + FILEKEY.RELATIVE_PATH + '= ? or ' + FILEKEY.RELATIVE_PATH + '= ?' + ') AND (' + - FILEKEY.MEDIA_TYPE + '= ? or ' + FILEKEY.MEDIA_TYPE + '= ?)', - selectionArgs: ['Videos/Static/', 'Pictures/Static/', IMAGE_TYPE.toString(), VIDEO_TYPE.toString()], + selections: + "(" + + FILEKEY.RELATIVE_PATH + + "= ? or " + + FILEKEY.RELATIVE_PATH + + "= ?" + + ") AND (" + + FILEKEY.MEDIA_TYPE + + "= ? or " + + FILEKEY.MEDIA_TYPE + + "= ?)", + selectionArgs: ["Videos/Static/", "Pictures/Static/", IMAGE_TYPE.toString(), VIDEO_TYPE.toString()], }; let imageAndVideoAndfilefetchOp = { - selections: '(' + FILEKEY.RELATIVE_PATH + '= ? or ' + FILEKEY.RELATIVE_PATH + '= ? or ' + FILEKEY.RELATIVE_PATH + '= ?' + ') AND (' + - FILEKEY.MEDIA_TYPE + '= ? or ' + FILEKEY.MEDIA_TYPE + '= ? or ' + FILEKEY.MEDIA_TYPE + '= ?)', - selectionArgs: ['Documents/Static/', 'Videos/Static/', 'Pictures/Static/', IMAGE_TYPE.toString(), VIDEO_TYPE.toString(), FILE_TYPE.toString()], + selections: + "(" + + FILEKEY.RELATIVE_PATH + + "= ? or " + + FILEKEY.RELATIVE_PATH + + "= ? or " + + FILEKEY.RELATIVE_PATH + + "= ?" + + ") AND (" + + FILEKEY.MEDIA_TYPE + + "= ? or " + + FILEKEY.MEDIA_TYPE + + "= ? or " + + FILEKEY.MEDIA_TYPE + + "= ?)", + selectionArgs: [ + "Documents/Static/", + "Videos/Static/", + "Pictures/Static/", + IMAGE_TYPE.toString(), + VIDEO_TYPE.toString(), + FILE_TYPE.toString(), + ], order: FILEKEY.DATE_ADDED + " DESC", }; let imageAndVideoAndfileAndAudiofetchOp = { - selections: '(' + FILEKEY.RELATIVE_PATH + '= ? or ' + FILEKEY.RELATIVE_PATH + '= ? or ' + FILEKEY.RELATIVE_PATH + '= ? or ' + FILEKEY.RELATIVE_PATH + '= ?' + ') AND (' + - FILEKEY.MEDIA_TYPE + '= ? or ' + FILEKEY.MEDIA_TYPE + '= ? or ' + FILEKEY.MEDIA_TYPE + '= ? or ' + FILEKEY.MEDIA_TYPE + '= ?)', - selectionArgs: ['Documents/Static/', 'Videos/Static/', 'Pictures/Static/', 'Audios/Static/', IMAGE_TYPE.toString(), VIDEO_TYPE.toString(), FILE_TYPE.toString(), AUDIO_TYPE.toString(),], + selections: + "(" + + FILEKEY.RELATIVE_PATH + + "= ? or " + + FILEKEY.RELATIVE_PATH + + "= ? or " + + FILEKEY.RELATIVE_PATH + + "= ? or " + + FILEKEY.RELATIVE_PATH + + "= ?" + + ") AND (" + + FILEKEY.MEDIA_TYPE + + "= ? or " + + FILEKEY.MEDIA_TYPE + + "= ? or " + + FILEKEY.MEDIA_TYPE + + "= ? or " + + FILEKEY.MEDIA_TYPE + + "= ?)", + selectionArgs: [ + "Documents/Static/", + "Videos/Static/", + "Pictures/Static/", + "Audios/Static/", + IMAGE_TYPE.toString(), + VIDEO_TYPE.toString(), + FILE_TYPE.toString(), + AUDIO_TYPE.toString(), + ], order: FILEKEY.DATE_ADDED + " DESC", }; @@ -76,54 +130,54 @@ export default function mediaLibraryTestCallback(abilityContext) { const props = { image: { - mimeType: 'image/*', - displayName: '01.jpg', - relativePath: 'Pictures/Static/', + mimeType: "image/*", + displayName: "01.jpg", + relativePath: "Pictures/Static/", size: 348113, mediaType: IMAGE_TYPE.toString(), - title: '01', + title: "01", width: 1279, height: 1706, orientation: 0, - duration: '0', - albumId: '1118', + duration: "0", + albumId: "1118", }, video: { - mimeType: 'video/mp4', - displayName: '01.mp4', - relativePath: 'Videos/Static/', + mimeType: "video/mp4", + displayName: "01.mp4", + relativePath: "Videos/Static/", size: 4853005, mediaType: VIDEO_TYPE.toString(), - title: '01', + title: "01", width: 1280, height: 720, orientation: 0, - duration: '10100', + duration: "10100", }, audio: { - mimeType: 'audio/mpeg', - displayName: '01.mp3', - relativePath: 'Audios/Static/', + mimeType: "audio/mpeg", + displayName: "01.mp3", + relativePath: "Audios/Static/", size: 1958311, mediaType: AUDIO_TYPE.toString(), - title: 'test', - artist: '元数据测试', + title: "test", + artist: "元数据测试", orientation: 0, - duration: '219600', + duration: "219600", }, file: { - mimeType: 'file/*', - displayName: '01.dat', - relativePath: 'Documents/Static/', + mimeType: "file/*", + displayName: "01.dat", + relativePath: "Documents/Static/", size: 10, mediaType: FILE_TYPE.toString(), - title: '01', + title: "01", width: 0, height: 0, orientation: 0, - duration: '0', - } - } + duration: "0", + }, + }; async function checkFileAssetAttr(done, testNum, fetchOps, type, count, typesArr) { try { @@ -132,15 +186,15 @@ export default function mediaLibraryTestCallback(abilityContext) { if (!checkAssetCountPass) return; fetchFileResult.getFirstObject(async (err, asset) => { if (err) { - console.info(`${testNum} err : ${err}`) + console.info(`${testNum} err : ${err}`); expect().assertFail(); done(); return; } if (count > 1) { - type = asset.mimeType.match(/[a-z]+/g)[0] + type = asset.mimeType.match(/[a-z]+/g)[0]; } - if (type == 'audio') { + if (type == "audio") { expect(asset.artist).assertEqual(props[type].artist); } if (typesArr) { @@ -160,7 +214,7 @@ export default function mediaLibraryTestCallback(abilityContext) { expect(asset.size).assertEqual(props[type].size); expect(asset.mediaType.toString()).assertEqual(props[type].mediaType); expect(asset.title.toString()).assertEqual(props[type].title); - if(type != 'audio') { + if (type != "audio") { expect(asset.width).assertEqual(props[type].width); expect(asset.height).assertEqual(props[type].height); } @@ -168,7 +222,6 @@ export default function mediaLibraryTestCallback(abilityContext) { expect(asset.duration.toString()).assertEqual(props[type].duration); done(); }); - } catch (error) { console.info(`${testNum}:: error :${error}`); expect(false).assertTrue(); @@ -180,7 +233,7 @@ export default function mediaLibraryTestCallback(abilityContext) { try { media.getPublicDirectory(dir, async (err, res) => { if (err) { - console.info(`${testNum} err : ${err}`) + console.info(`${testNum} err : ${err}`); expect().assertFail(); done(); return; @@ -188,19 +241,18 @@ export default function mediaLibraryTestCallback(abilityContext) { expect(res).assertEqual(val); done(); }); - } catch (error) { console.info(`${testNum}:: error :${error}`); expect(false).assertTrue(); done(); } - } + }; const getFileAssetsAbnormal = async (done, testNum, fetchOps) => { try { media.getFileAssets(fetchOps, async (err) => { if (err) { - console.info(`${testNum} err : ${err}`) + console.info(`${testNum} err : ${err}`); expect(true).assertTrue(); done(); return; @@ -213,12 +265,12 @@ export default function mediaLibraryTestCallback(abilityContext) { expect(true).assertTrue(); done(); } - } + }; const getFileAssetsZero = async (done, testNum, fetchOps) => { try { media.getFileAssets(fetchOps, async (err, fetchFileResult) => { if (err) { - console.info(`${testNum} err : ${err}`) + console.info(`${testNum} err : ${err}`); expect().assertFail(); done(); return; @@ -232,7 +284,7 @@ export default function mediaLibraryTestCallback(abilityContext) { expect(false).assertTrue(); done(); } - } + }; const createAssetTest = async (done, testNum, fetchOps, type, name, path) => { try { @@ -242,13 +294,13 @@ export default function mediaLibraryTestCallback(abilityContext) { let asset = await fetchFileResult.getFirstObject(); media.createAsset(type, name, path, async (err, creatAsset) => { if (err) { - console.info(`${testNum} err : ${err}`) + console.info(`${testNum} err : ${err}`); expect().assertFail(); done(); return; } - const fd = await asset.open('rw'); - const creatAssetFd = await creatAsset.open('rw'); + const fd = await asset.open("rw"); + const creatAssetFd = await creatAsset.open("rw"); await copyFile(fd, creatAssetFd); await creatAsset.close(creatAssetFd); await asset.close(fd); @@ -260,7 +312,7 @@ export default function mediaLibraryTestCallback(abilityContext) { expect(false).assertTrue(); done(); } - } + }; const createAssetSameNameTest = async (done, testNum, fetchOps, type, name, path) => { try { @@ -269,8 +321,8 @@ export default function mediaLibraryTestCallback(abilityContext) { if (!checkAssetCountPass) return; let asset = await fetchFileResult.getFirstObject(); const creatAsset = await media.createAsset(type, name, path); - const fd = await asset.open('rw'); - const creatAssetFd = await creatAsset.open('rw'); + const fd = await asset.open("rw"); + const creatAssetFd = await creatAsset.open("rw"); await copyFile(fd, creatAssetFd); await creatAsset.close(creatAssetFd); await asset.close(fd); @@ -283,7 +335,6 @@ export default function mediaLibraryTestCallback(abilityContext) { } expect(false).assertTrue(); done(); - }); } catch (error) { console.info(`${testNum}:: error :${error}`); @@ -295,7 +346,7 @@ export default function mediaLibraryTestCallback(abilityContext) { expect(false).assertTrue(); done(); } - } + }; /** * @tc.number : SUB_MEDIA_MEDIALIBRARY_CALLBACK_GETFILEASSETS_001 @@ -305,12 +356,12 @@ export default function mediaLibraryTestCallback(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_CALLBACK_GETFILEASSETS_001', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_CALLBACK_GETFILEASSETS_001'; - let currentFetchOps = fetchOps(testNum, 'Pictures/Static/', IMAGE_TYPE); - let type = 'image'; + it("SUB_MEDIA_MEDIALIBRARY_CALLBACK_GETFILEASSETS_001", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_CALLBACK_GETFILEASSETS_001"; + let currentFetchOps = fetchOps(testNum, "Pictures/Static/", IMAGE_TYPE); + let type = "image"; let count = 1; - await checkFileAssetAttr(done, testNum, currentFetchOps, type, count, null) + await checkFileAssetAttr(done, testNum, currentFetchOps, type, count, null); }); /** @@ -321,12 +372,12 @@ export default function mediaLibraryTestCallback(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_CALLBACK_GETFILEASSETS_002', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_CALLBACK_GETFILEASSETS_002'; - let currentFetchOps = fetchOps(testNum, 'Videos/Static/', VIDEO_TYPE); - let type = 'video'; + it("SUB_MEDIA_MEDIALIBRARY_CALLBACK_GETFILEASSETS_002", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_CALLBACK_GETFILEASSETS_002"; + let currentFetchOps = fetchOps(testNum, "Videos/Static/", VIDEO_TYPE); + let type = "video"; let count = 1; - await checkFileAssetAttr(done, testNum, currentFetchOps, type, count, null) + await checkFileAssetAttr(done, testNum, currentFetchOps, type, count, null); }); /** @@ -337,12 +388,12 @@ export default function mediaLibraryTestCallback(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_CALLBACK_GETFILEASSETS_003', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_CALLBACK_GETFILEASSETS_003'; - let currentFetchOps = fetchOps(testNum, 'Audios/Static/', AUDIO_TYPE); - let type = 'audio'; + it("SUB_MEDIA_MEDIALIBRARY_CALLBACK_GETFILEASSETS_003", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_CALLBACK_GETFILEASSETS_003"; + let currentFetchOps = fetchOps(testNum, "Audios/Static/", AUDIO_TYPE); + let type = "audio"; let count = 1; - await checkFileAssetAttr(done, testNum, currentFetchOps, type, count, null) + await checkFileAssetAttr(done, testNum, currentFetchOps, type, count, null); }); /** @@ -353,12 +404,12 @@ export default function mediaLibraryTestCallback(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_CALLBACK_GETFILEASSETS_004', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_CALLBACK_GETFILEASSETS_004'; - let currentFetchOps = fetchOps(testNum, 'Documents/Static/', FILE_TYPE); - let type = 'file'; + it("SUB_MEDIA_MEDIALIBRARY_CALLBACK_GETFILEASSETS_004", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_CALLBACK_GETFILEASSETS_004"; + let currentFetchOps = fetchOps(testNum, "Documents/Static/", FILE_TYPE); + let type = "file"; let count = 1; - await checkFileAssetAttr(done, testNum, currentFetchOps, type, count, null) + await checkFileAssetAttr(done, testNum, currentFetchOps, type, count, null); }); /** @@ -369,13 +420,13 @@ export default function mediaLibraryTestCallback(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_CALLBACK_GETFILEASSETS_005', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_CALLBACK_GETFILEASSETS_005'; + it("SUB_MEDIA_MEDIALIBRARY_CALLBACK_GETFILEASSETS_005", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_CALLBACK_GETFILEASSETS_005"; let currentFetchOps = imageAndVideofetchOp; - let type = 'video'; + let type = "video"; let count = 2; - let typesArr = ['image/*', 'video/mp4'] - await checkFileAssetAttr(done, testNum, currentFetchOps, type, count, typesArr) + let typesArr = ["image/*", "video/mp4"]; + await checkFileAssetAttr(done, testNum, currentFetchOps, type, count, typesArr); }); /** @@ -386,13 +437,13 @@ export default function mediaLibraryTestCallback(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_CALLBACK_GETFILEASSETS_006', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_CALLBACK_GETFILEASSETS_006'; + it("SUB_MEDIA_MEDIALIBRARY_CALLBACK_GETFILEASSETS_006", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_CALLBACK_GETFILEASSETS_006"; let currentFetchOps = imageAndVideoAndfilefetchOp; - let type = 'file'; + let type = "file"; let count = 3; - let typesArr = ['image/*', 'video/mp4', 'file/*'] - await checkFileAssetAttr(done, testNum, currentFetchOps, type, count, typesArr) + let typesArr = ["image/*", "video/mp4", "file/*"]; + await checkFileAssetAttr(done, testNum, currentFetchOps, type, count, typesArr); }); /** @@ -403,13 +454,13 @@ export default function mediaLibraryTestCallback(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_CALLBACK_GETFILEASSETS_007', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_CALLBACK_GETFILEASSETS_007'; + it("SUB_MEDIA_MEDIALIBRARY_CALLBACK_GETFILEASSETS_007", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_CALLBACK_GETFILEASSETS_007"; let currentFetchOps = imageAndVideoAndfileAndAudiofetchOp; - let type = 'audio'; + let type = "audio"; let count = 4; - let typesArr = ['image/*', 'video/mp4', 'file/*', 'audio/mpeg'] - await checkFileAssetAttr(done, testNum, currentFetchOps, type, count, typesArr) + let typesArr = ["image/*", "video/mp4", "file/*", "audio/mpeg"]; + await checkFileAssetAttr(done, testNum, currentFetchOps, type, count, typesArr); }); /** @@ -420,13 +471,13 @@ export default function mediaLibraryTestCallback(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_CALLBACK_GETFILEASSETS_008', 0, async function (done) { + it("SUB_MEDIA_MEDIALIBRARY_CALLBACK_GETFILEASSETS_008", 0, async function (done) { let currentFetchOps = { - selections: FILEKEY.MEDIA_TYPE + '= ?', + selections: FILEKEY.MEDIA_TYPE + "= ?", selectionArgs: [], }; - let testNum = 'SUB_MEDIA_MEDIALIBRARY_CALLBACK_GETFILEASSETS_008'; - await getFileAssetsZero(done, testNum, currentFetchOps) + let testNum = "SUB_MEDIA_MEDIALIBRARY_CALLBACK_GETFILEASSETS_008"; + await getFileAssetsZero(done, testNum, currentFetchOps); }); /** @@ -437,13 +488,13 @@ export default function mediaLibraryTestCallback(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_CALLBACK_GETFILEASSETS_009', 0, async function (done) { + it("SUB_MEDIA_MEDIALIBRARY_CALLBACK_GETFILEASSETS_009", 0, async function (done) { let currentFetchOps = { - selections: FILEKEY.MEDIA_TYPE + 'abc= ?', + selections: FILEKEY.MEDIA_TYPE + "abc= ?", selectionArgs: [AUDIO_TYPE.toString()], }; - let testNum = 'SUB_MEDIA_MEDIALIBRARY_CALLBACK_GETFILEASSETS_009'; - await getFileAssetsAbnormal(done, testNum, currentFetchOps) + let testNum = "SUB_MEDIA_MEDIALIBRARY_CALLBACK_GETFILEASSETS_009"; + await getFileAssetsAbnormal(done, testNum, currentFetchOps); }); /** @@ -454,13 +505,13 @@ export default function mediaLibraryTestCallback(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_CALLBACK_GETFILEASSETS_010', 0, async function (done) { + it("SUB_MEDIA_MEDIALIBRARY_CALLBACK_GETFILEASSETS_010", 0, async function (done) { let currentFetchOps = { - selections: FILEKEY.MEDIA_TYPE + '= ?', + selections: FILEKEY.MEDIA_TYPE + "= ?", selectionArgs: [111], }; - let testNum = 'SUB_MEDIA_MEDIALIBRARY_CALLBACK_GETFILEASSETS_010'; - await getFileAssetsZero(done, testNum, currentFetchOps) + let testNum = "SUB_MEDIA_MEDIALIBRARY_CALLBACK_GETFILEASSETS_010"; + await getFileAssetsZero(done, testNum, currentFetchOps); }); /** @@ -471,13 +522,13 @@ export default function mediaLibraryTestCallback(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_CALLBACK_GETFILEASSETS_011', 0, async function (done) { + it("SUB_MEDIA_MEDIALIBRARY_CALLBACK_GETFILEASSETS_011", 0, async function (done) { let currentFetchOps = { - selections: 'abc' + '= ?', + selections: "abc" + "= ?", selectionArgs: [AUDIO_TYPE.toString()], }; - let testNum = 'SUB_MEDIA_MEDIALIBRARY_CALLBACK_GETFILEASSETS_011'; - await getFileAssetsAbnormal(done, testNum, currentFetchOps) + let testNum = "SUB_MEDIA_MEDIALIBRARY_CALLBACK_GETFILEASSETS_011"; + await getFileAssetsAbnormal(done, testNum, currentFetchOps); }); /** @@ -488,11 +539,11 @@ export default function mediaLibraryTestCallback(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_CALLBACK_GETPUBLICDIRECTORY_001', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_CALLBACK_GETPUBLICDIRECTORY_001'; + it("SUB_MEDIA_MEDIALIBRARY_CALLBACK_GETPUBLICDIRECTORY_001", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_CALLBACK_GETPUBLICDIRECTORY_001"; let dir = mediaLibrary.DirectoryType.DIR_CAMERA; - let val = 'Camera/'; - await checkGetPublicDirectory(done, testNum, dir, val) + let val = "Camera/"; + await checkGetPublicDirectory(done, testNum, dir, val); }); /** @@ -503,11 +554,11 @@ export default function mediaLibraryTestCallback(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_CALLBACK_GETPUBLICDIRECTORY_002', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_CALLBACK_GETPUBLICDIRECTORY_002'; + it("SUB_MEDIA_MEDIALIBRARY_CALLBACK_GETPUBLICDIRECTORY_002", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_CALLBACK_GETPUBLICDIRECTORY_002"; let dir = mediaLibrary.DirectoryType.DIR_VIDEO; - let val = 'Videos/'; - await checkGetPublicDirectory(done, testNum, dir, val) + let val = "Videos/"; + await checkGetPublicDirectory(done, testNum, dir, val); }); /** @@ -518,11 +569,11 @@ export default function mediaLibraryTestCallback(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_CALLBACK_GETPUBLICDIRECTORY_003', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_CALLBACK_GETPUBLICDIRECTORY_003'; + it("SUB_MEDIA_MEDIALIBRARY_CALLBACK_GETPUBLICDIRECTORY_003", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_CALLBACK_GETPUBLICDIRECTORY_003"; let dir = mediaLibrary.DirectoryType.DIR_IMAGE; - let val = 'Pictures/'; - await checkGetPublicDirectory(done, testNum, dir, val) + let val = "Pictures/"; + await checkGetPublicDirectory(done, testNum, dir, val); }); /** @@ -533,11 +584,11 @@ export default function mediaLibraryTestCallback(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_CALLBACK_GETPUBLICDIRECTORY_004', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_CALLBACK_GETPUBLICDIRECTORY_004'; + it("SUB_MEDIA_MEDIALIBRARY_CALLBACK_GETPUBLICDIRECTORY_004", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_CALLBACK_GETPUBLICDIRECTORY_004"; let dir = mediaLibrary.DirectoryType.DIR_AUDIO; - let val = 'Audios/'; - await checkGetPublicDirectory(done, testNum, dir, val) + let val = "Audios/"; + await checkGetPublicDirectory(done, testNum, dir, val); }); /** @@ -548,11 +599,11 @@ export default function mediaLibraryTestCallback(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_CALLBACK_GETPUBLICDIRECTORY_005', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_CALLBACK_GETPUBLICDIRECTORY_005'; + it("SUB_MEDIA_MEDIALIBRARY_CALLBACK_GETPUBLICDIRECTORY_005", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_CALLBACK_GETPUBLICDIRECTORY_005"; let dir = mediaLibrary.DirectoryType.DIR_DOCUMENTS; - let val = 'Documents/'; - await checkGetPublicDirectory(done, testNum, dir, val) + let val = "Documents/"; + await checkGetPublicDirectory(done, testNum, dir, val); }); /** @@ -563,14 +614,14 @@ export default function mediaLibraryTestCallback(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_CALLBACK_GETPUBLICDIRECTORY_006', 0, async function (done) { + it("SUB_MEDIA_MEDIALIBRARY_CALLBACK_GETPUBLICDIRECTORY_006", 0, async function (done) { try { await media.getPublicDirectory(110); - console.info('MediaLibraryTest : getPublicDirectory 006 failed'); + console.info("MediaLibraryTest : getPublicDirectory 006 failed"); expect(false).assertTrue(); done(); } catch (error) { - console.info('MediaLibraryTest : getPublicDirectory 006 passed'); + console.info("MediaLibraryTest : getPublicDirectory 006 passed"); expect(true).assertTrue(); done(); } @@ -584,11 +635,11 @@ export default function mediaLibraryTestCallback(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_CALLBACK_GETPUBLICDIRECTORY_007', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_CALLBACK_GETPUBLICDIRECTORY_007'; + it("SUB_MEDIA_MEDIALIBRARY_CALLBACK_GETPUBLICDIRECTORY_007", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_CALLBACK_GETPUBLICDIRECTORY_007"; let dir = mediaLibrary.DirectoryType.DIR_DOWNLOAD; - let val = 'Download/'; - await checkGetPublicDirectory(done, testNum, dir, val) + let val = "Download/"; + await checkGetPublicDirectory(done, testNum, dir, val); }); /** @@ -599,13 +650,13 @@ export default function mediaLibraryTestCallback(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_CALLBACK_CREATEASSET_001', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_CALLBACK_CREATEASSET_001'; - let currentFetchOps = fetchOps(testNum, 'Pictures/Static/', IMAGE_TYPE); + it("SUB_MEDIA_MEDIALIBRARY_CALLBACK_CREATEASSET_001", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_CALLBACK_CREATEASSET_001"; + let currentFetchOps = fetchOps(testNum, "Pictures/Static/", IMAGE_TYPE); let type = IMAGE_TYPE; - let name = new Date().getTime() + '.jpg'; - let path = 'Pictures/Create/'; - await createAssetTest(done, testNum, currentFetchOps, type, name, path) + let name = new Date().getTime() + ".jpg"; + let path = "Pictures/Create/"; + await createAssetTest(done, testNum, currentFetchOps, type, name, path); }); /** @@ -616,14 +667,13 @@ export default function mediaLibraryTestCallback(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_CALLBACK_CREATEASSET_002', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_CALLBACK_CREATEASSET_002'; - let currentFetchOps = fetchOps(testNum, 'Pictures/Static/', IMAGE_TYPE); + it("SUB_MEDIA_MEDIALIBRARY_CALLBACK_CREATEASSET_002", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_CALLBACK_CREATEASSET_002"; + let currentFetchOps = fetchOps(testNum, "Pictures/Static/", IMAGE_TYPE); let type = IMAGE_TYPE; - let name = new Date().getTime() + '.jpg'; - let path = 'Pictures/Create/'; - await createAssetSameNameTest(done, testNum, currentFetchOps, type, name, path) - + let name = new Date().getTime() + ".jpg"; + let path = "Pictures/Create/"; + await createAssetSameNameTest(done, testNum, currentFetchOps, type, name, path); }); /** @@ -634,13 +684,13 @@ export default function mediaLibraryTestCallback(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_CALLBACK_CREATEASSET_003', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_CALLBACK_CREATEASSET_003'; - let currentFetchOps = fetchOps(testNum, 'Videos/Static/', VIDEO_TYPE); + it("SUB_MEDIA_MEDIALIBRARY_CALLBACK_CREATEASSET_003", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_CALLBACK_CREATEASSET_003"; + let currentFetchOps = fetchOps(testNum, "Videos/Static/", VIDEO_TYPE); let type = VIDEO_TYPE; - let name = new Date().getTime() + '.mp4'; - let path = 'Videos/Create/'; - await createAssetTest(done, testNum, currentFetchOps, type, name, path) + let name = new Date().getTime() + ".mp4"; + let path = "Videos/Create/"; + await createAssetTest(done, testNum, currentFetchOps, type, name, path); }); /** @@ -651,13 +701,13 @@ export default function mediaLibraryTestCallback(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_CALLBACK_CREATEASSET_004', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_CALLBACK_CREATEASSET_004'; - let currentFetchOps = fetchOps(testNum, 'Videos/Static/', VIDEO_TYPE); + it("SUB_MEDIA_MEDIALIBRARY_CALLBACK_CREATEASSET_004", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_CALLBACK_CREATEASSET_004"; + let currentFetchOps = fetchOps(testNum, "Videos/Static/", VIDEO_TYPE); let type = VIDEO_TYPE; - let name = new Date().getTime() + '.mp4'; - let path = 'Videos/Create/'; - await createAssetSameNameTest(done, testNum, currentFetchOps, type, name, path) + let name = new Date().getTime() + ".mp4"; + let path = "Videos/Create/"; + await createAssetSameNameTest(done, testNum, currentFetchOps, type, name, path); }); /** @@ -668,13 +718,13 @@ export default function mediaLibraryTestCallback(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_CALLBACK_CREATEASSET_005', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_CALLBACK_CREATEASSET_005'; - let currentFetchOps = fetchOps(testNum, 'Audios/Static/', AUDIO_TYPE); + it("SUB_MEDIA_MEDIALIBRARY_CALLBACK_CREATEASSET_005", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_CALLBACK_CREATEASSET_005"; + let currentFetchOps = fetchOps(testNum, "Audios/Static/", AUDIO_TYPE); let type = AUDIO_TYPE; - let name = new Date().getTime() + '.mp3'; - let path = 'Audios/Create/'; - await createAssetTest(done, testNum, currentFetchOps, type, name, path) + let name = new Date().getTime() + ".mp3"; + let path = "Audios/Create/"; + await createAssetTest(done, testNum, currentFetchOps, type, name, path); }); /** @@ -685,13 +735,13 @@ export default function mediaLibraryTestCallback(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_CALLBACK_CREATEASSET_006', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_CALLBACK_CREATEASSET_006'; - let currentFetchOps = fetchOps(testNum, 'Audios/Static/', AUDIO_TYPE); + it("SUB_MEDIA_MEDIALIBRARY_CALLBACK_CREATEASSET_006", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_CALLBACK_CREATEASSET_006"; + let currentFetchOps = fetchOps(testNum, "Audios/Static/", AUDIO_TYPE); let type = AUDIO_TYPE; - let name = new Date().getTime() + '.mp3'; - let path = 'Audios/Create/'; - await createAssetSameNameTest(done, testNum, currentFetchOps, type, name, path) + let name = new Date().getTime() + ".mp3"; + let path = "Audios/Create/"; + await createAssetSameNameTest(done, testNum, currentFetchOps, type, name, path); }); /** @@ -702,13 +752,13 @@ export default function mediaLibraryTestCallback(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_CALLBACK_CREATEASSET_007', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_CALLBACK_CREATEASSET_007'; - let currentFetchOps = fetchOps(testNum, 'Documents/Static/', FILE_TYPE); + it("SUB_MEDIA_MEDIALIBRARY_CALLBACK_CREATEASSET_007", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_CALLBACK_CREATEASSET_007"; + let currentFetchOps = fetchOps(testNum, "Documents/Static/", FILE_TYPE); let type = FILE_TYPE; - let name = new Date().getTime() + '.dat'; - let path = 'Documents/Create/'; - await createAssetTest(done, testNum, currentFetchOps, type, name, path) + let name = new Date().getTime() + ".dat"; + let path = "Documents/Create/"; + await createAssetTest(done, testNum, currentFetchOps, type, name, path); }); /** @@ -719,31 +769,30 @@ export default function mediaLibraryTestCallback(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_CALLBACK_CREATEASSET_008', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_CALLBACK_CREATEASSET_008'; - let currentFetchOps = fetchOps(testNum, 'Documents/Static/', FILE_TYPE); + it("SUB_MEDIA_MEDIALIBRARY_CALLBACK_CREATEASSET_008", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_CALLBACK_CREATEASSET_008"; + let currentFetchOps = fetchOps(testNum, "Documents/Static/", FILE_TYPE); let type = FILE_TYPE; - let name = new Date().getTime() + '.dat'; - let path = 'Documents/Create/'; - await createAssetSameNameTest(done, testNum, currentFetchOps, type, name, path) + let name = new Date().getTime() + ".dat"; + let path = "Documents/Create/"; + await createAssetSameNameTest(done, testNum, currentFetchOps, type, name, path); }); /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_CALLBACK_CREATEASSET_009 - * @tc.name : createAsset - * @tc.desc : Create File Asset image (does not exist) - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_CALLBACK_CREATEASSET_009', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_CALLBACK_CREATEASSET_009'; - let currentFetchOps = fetchOps(testNum, 'Pictures/Static/', IMAGE_TYPE); + * @tc.number : SUB_MEDIA_MEDIALIBRARY_CALLBACK_CREATEASSET_009 + * @tc.name : createAsset + * @tc.desc : Create File Asset image (does not exist) + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it("SUB_MEDIA_MEDIALIBRARY_CALLBACK_CREATEASSET_009", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_CALLBACK_CREATEASSET_009"; + let currentFetchOps = fetchOps(testNum, "Pictures/Static/", IMAGE_TYPE); let type = IMAGE_TYPE; - let name = new Date().getTime() + '.jpg'; - let path = 'Pictures/Create/Temp'; - await createAssetTest(done, testNum, currentFetchOps, type, name, path) + let name = new Date().getTime() + ".jpg"; + let path = "Pictures/Create/Temp"; + await createAssetTest(done, testNum, currentFetchOps, type, name, path); }); }); } - diff --git a/multimedia/medialibrary/mediaLibrary_base/entry/src/main/ets/test/mediaLibraryTestPromise.test.ets b/multimedia/medialibrary/mediaLibrary_base/entry/src/main/ets/test/mediaLibraryTestPromise.test.ets old mode 100755 new mode 100644 index 69a5d9b0c651abb17c26bd068bb577da901ebfa9..9cf4b7c1c5b6756bbc7b95639dc37a48fbea5928 --- a/multimedia/medialibrary/mediaLibrary_base/entry/src/main/ets/test/mediaLibraryTestPromise.test.ets +++ b/multimedia/medialibrary/mediaLibrary_base/entry/src/main/ets/test/mediaLibraryTestPromise.test.ets @@ -12,9 +12,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import mediaLibrary from '@ohos.multimedia.mediaLibrary'; -import fileio from '@ohos.fileio'; -import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'; +import mediaLibrary from "@ohos.multimedia.mediaLibrary"; +import fileio from "@ohos.fileio"; +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "deccjsunit/index"; import { sleep, IMAGE_TYPE, @@ -26,42 +26,95 @@ import { fetchOps, getPermission, isNum, -} from '../../../../../../common'; - +} from "../../../../../../common"; export default function mediaLibraryTestPromiseTest(abilityContext) { - describe('mediaLibraryTestPromiseTest', function () { + describe("mediaLibraryTestPromiseTest", function () { const media = mediaLibrary.getMediaLibrary(abilityContext); beforeAll(async function () { - console.info('beforeAll case'); - await getPermission(); + console.info("beforeAll case"); }); beforeEach(function () { - console.info('beforeEach case'); + console.info("beforeEach case"); }); afterEach(async function () { - console.info('afterEach case'); - await sleep(200) + console.info("afterEach case"); + await sleep(200); }); afterAll(function () { - console.info('afterAll case'); + console.info("afterAll case"); }); let imageAndVideofetchOp = { - selections: '(' + FILEKEY.RELATIVE_PATH + '= ? or ' + FILEKEY.RELATIVE_PATH + '= ?' + ') AND (' + - FILEKEY.MEDIA_TYPE + '= ? or ' + FILEKEY.MEDIA_TYPE + '= ?)', - selectionArgs: ['Videos/Static/', 'Pictures/Static/', IMAGE_TYPE.toString(), VIDEO_TYPE.toString()], + selections: + "(" + + FILEKEY.RELATIVE_PATH + + "= ? or " + + FILEKEY.RELATIVE_PATH + + "= ?" + + ") AND (" + + FILEKEY.MEDIA_TYPE + + "= ? or " + + FILEKEY.MEDIA_TYPE + + "= ?)", + selectionArgs: ["Videos/Static/", "Pictures/Static/", IMAGE_TYPE.toString(), VIDEO_TYPE.toString()], }; let imageAndVideoAndfilefetchOp = { - selections: '(' + FILEKEY.RELATIVE_PATH + '= ? or ' + FILEKEY.RELATIVE_PATH + '= ? or ' + FILEKEY.RELATIVE_PATH + '= ?' + ') AND (' + - FILEKEY.MEDIA_TYPE + '= ? or ' + FILEKEY.MEDIA_TYPE + '= ? or ' + FILEKEY.MEDIA_TYPE + '= ?)', - selectionArgs: ['Documents/Static/', 'Videos/Static/', 'Pictures/Static/', IMAGE_TYPE.toString(), VIDEO_TYPE.toString(), FILE_TYPE.toString()], + selections: + "(" + + FILEKEY.RELATIVE_PATH + + "= ? or " + + FILEKEY.RELATIVE_PATH + + "= ? or " + + FILEKEY.RELATIVE_PATH + + "= ?" + + ") AND (" + + FILEKEY.MEDIA_TYPE + + "= ? or " + + FILEKEY.MEDIA_TYPE + + "= ? or " + + FILEKEY.MEDIA_TYPE + + "= ?)", + selectionArgs: [ + "Documents/Static/", + "Videos/Static/", + "Pictures/Static/", + IMAGE_TYPE.toString(), + VIDEO_TYPE.toString(), + FILE_TYPE.toString(), + ], order: FILEKEY.DATE_ADDED + " DESC", }; let imageAndVideoAndfileAndAudiofetchOp = { - selections: '(' + FILEKEY.RELATIVE_PATH + '= ? or ' + FILEKEY.RELATIVE_PATH + '= ? or ' + FILEKEY.RELATIVE_PATH + '= ? or ' + FILEKEY.RELATIVE_PATH + '= ?' + ') AND (' + - FILEKEY.MEDIA_TYPE + '= ? or ' + FILEKEY.MEDIA_TYPE + '= ? or ' + FILEKEY.MEDIA_TYPE + '= ? or ' + FILEKEY.MEDIA_TYPE + '= ?)', - selectionArgs: ['Documents/Static/', 'Videos/Static/', 'Pictures/Static/', 'Audios/Static/', IMAGE_TYPE.toString(), VIDEO_TYPE.toString(), FILE_TYPE.toString(), AUDIO_TYPE.toString(),], + selections: + "(" + + FILEKEY.RELATIVE_PATH + + "= ? or " + + FILEKEY.RELATIVE_PATH + + "= ? or " + + FILEKEY.RELATIVE_PATH + + "= ? or " + + FILEKEY.RELATIVE_PATH + + "= ?" + + ") AND (" + + FILEKEY.MEDIA_TYPE + + "= ? or " + + FILEKEY.MEDIA_TYPE + + "= ? or " + + FILEKEY.MEDIA_TYPE + + "= ? or " + + FILEKEY.MEDIA_TYPE + + "= ?)", + selectionArgs: [ + "Documents/Static/", + "Videos/Static/", + "Pictures/Static/", + "Audios/Static/", + IMAGE_TYPE.toString(), + VIDEO_TYPE.toString(), + FILE_TYPE.toString(), + AUDIO_TYPE.toString(), + ], order: FILEKEY.DATE_ADDED + " DESC", }; @@ -74,54 +127,54 @@ export default function mediaLibraryTestPromiseTest(abilityContext) { const props = { image: { - mimeType: 'image/*', - displayName: '01.jpg', - relativePath: 'Pictures/Static/', + mimeType: "image/*", + displayName: "01.jpg", + relativePath: "Pictures/Static/", size: 348113, mediaType: IMAGE_TYPE.toString(), - title: '01', + title: "01", width: 1279, height: 1706, orientation: 0, - duration: '0', - albumId: '1118', + duration: "0", + albumId: "1118", }, video: { - mimeType: 'video/mp4', - displayName: '01.mp4', - relativePath: 'Videos/Static/', + mimeType: "video/mp4", + displayName: "01.mp4", + relativePath: "Videos/Static/", size: 4853005, mediaType: VIDEO_TYPE.toString(), - title: '01', + title: "01", width: 1280, height: 720, orientation: 0, - duration: '10100', + duration: "10100", }, audio: { - mimeType: 'audio/mpeg', - displayName: '01.mp3', - relativePath: 'Audios/Static/', + mimeType: "audio/mpeg", + displayName: "01.mp3", + relativePath: "Audios/Static/", size: 1958311, mediaType: AUDIO_TYPE.toString(), - title: 'test', - artist: '元数据测试', + title: "test", + artist: "元数据测试", orientation: 0, - duration: '219600', + duration: "219600", }, file: { - mimeType: 'file/*', - displayName: '01.dat', - relativePath: 'Documents/Static/', + mimeType: "file/*", + displayName: "01.dat", + relativePath: "Documents/Static/", size: 10, mediaType: FILE_TYPE.toString(), - title: '01', + title: "01", width: 0, height: 0, orientation: 0, - duration: '0', - } - } + duration: "0", + }, + }; async function checkFileAssetAttr(done, testNum, fetchOps, type, count, typesArr) { try { @@ -130,9 +183,9 @@ export default function mediaLibraryTestPromiseTest(abilityContext) { if (!checkAssetCountPass) return; let asset = await fetchFileResult.getFirstObject(); if (count > 1) { - type = asset.mimeType.match(/[a-z]+/g)[0] + type = asset.mimeType.match(/[a-z]+/g)[0]; } - if (type == 'audio') { + if (type == "audio") { expect(asset.artist).assertEqual(props[type].artist); } if (typesArr) { @@ -146,7 +199,7 @@ export default function mediaLibraryTestPromiseTest(abilityContext) { done(); return; } - if(asset.size !== props[type].size) { + if (asset.size !== props[type].size) { console.info(`${testNum}:: asset.size: props.size - ${asset.size} : ${props[type].size}`); expect(false).assertTrue(); done(); @@ -157,7 +210,7 @@ export default function mediaLibraryTestPromiseTest(abilityContext) { expect(asset.relativePath).assertEqual(props[type].relativePath); expect(asset.mediaType.toString()).assertEqual(props[type].mediaType); expect(asset.title.toString()).assertEqual(props[type].title); - if(type != 'audio') { + if (type != "audio") { expect(asset.width).assertEqual(props[type].width); expect(asset.height).assertEqual(props[type].height); } @@ -181,7 +234,7 @@ export default function mediaLibraryTestPromiseTest(abilityContext) { expect(false).assertTrue(); done(); } - } + }; const getFileAssetsAbnormal = async (done, testNum, fetchOps) => { try { @@ -193,7 +246,7 @@ export default function mediaLibraryTestPromiseTest(abilityContext) { expect(true).assertTrue(); done(); } - } + }; const getFileAssetsZero = async (done, testNum, fetchOps) => { try { let fetchFileResult = await media.getFileAssets(fetchOps); @@ -206,7 +259,7 @@ export default function mediaLibraryTestPromiseTest(abilityContext) { expect(false).assertTrue(); done(); } - } + }; const createAssetTest = async (done, testNum, fetchOps, type, name, path) => { try { @@ -215,8 +268,8 @@ export default function mediaLibraryTestPromiseTest(abilityContext) { if (!checkAssetCountPass) return; let asset = await fetchFileResult.getFirstObject(); const creatAsset = await media.createAsset(type, name, path); - const fd = await asset.open('rw'); - const creatAssetFd = await creatAsset.open('rw'); + const fd = await asset.open("rw"); + const creatAssetFd = await creatAsset.open("rw"); await copyFile(fd, creatAssetFd); await creatAsset.close(creatAssetFd); await asset.close(fd); @@ -227,7 +280,7 @@ export default function mediaLibraryTestPromiseTest(abilityContext) { expect(false).assertTrue(); done(); } - } + }; const createAssetSameNameTest = async (done, testNum, fetchOps, type, name, path) => { try { @@ -236,8 +289,8 @@ export default function mediaLibraryTestPromiseTest(abilityContext) { if (!checkAssetCountPass) return; let asset = await fetchFileResult.getFirstObject(); const creatAsset = await media.createAsset(type, name, path); - const fd = await asset.open('rw'); - const creatAssetFd = await creatAsset.open('rw'); + const fd = await asset.open("rw"); + const creatAssetFd = await creatAsset.open("rw"); await copyFile(fd, creatAssetFd); await creatAsset.close(creatAssetFd); await asset.close(fd); @@ -254,7 +307,7 @@ export default function mediaLibraryTestPromiseTest(abilityContext) { expect(false).assertTrue(); done(); } - } + }; /** * @tc.number : SUB_MEDIA_MEDIALIBRARY_PROMISE_GETMEDIALIBRAY_001 * @tc.name : getMediaLibrary @@ -263,7 +316,7 @@ export default function mediaLibraryTestPromiseTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_PROMISE_GETMEDIALIBRAY_001', 0, async function (done) { + it("SUB_MEDIA_MEDIALIBRARY_PROMISE_GETMEDIALIBRAY_001", 0, async function (done) { try { expect(media != undefined).assertTrue(); done(); @@ -282,12 +335,12 @@ export default function mediaLibraryTestPromiseTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_PROMISE_GETFILEASSETS_001', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_PROMISE_GETFILEASSETS_001'; - let currentFetchOps = fetchOps(testNum, 'Pictures/Static/', IMAGE_TYPE); - let type = 'image'; + it("SUB_MEDIA_MEDIALIBRARY_PROMISE_GETFILEASSETS_001", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_PROMISE_GETFILEASSETS_001"; + let currentFetchOps = fetchOps(testNum, "Pictures/Static/", IMAGE_TYPE); + let type = "image"; let count = 1; - await checkFileAssetAttr(done, testNum, currentFetchOps, type, count, null) + await checkFileAssetAttr(done, testNum, currentFetchOps, type, count, null); }); /** @@ -298,12 +351,12 @@ export default function mediaLibraryTestPromiseTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_PROMISE_GETFILEASSETS_002', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_PROMISE_GETFILEASSETS_002'; - let currentFetchOps = fetchOps(testNum, 'Videos/Static/', VIDEO_TYPE); - let type = 'video'; + it("SUB_MEDIA_MEDIALIBRARY_PROMISE_GETFILEASSETS_002", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_PROMISE_GETFILEASSETS_002"; + let currentFetchOps = fetchOps(testNum, "Videos/Static/", VIDEO_TYPE); + let type = "video"; let count = 1; - await checkFileAssetAttr(done, testNum, currentFetchOps, type, count, null) + await checkFileAssetAttr(done, testNum, currentFetchOps, type, count, null); }); /** @@ -314,12 +367,12 @@ export default function mediaLibraryTestPromiseTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_PROMISE_GETFILEASSETS_003', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_PROMISE_GETFILEASSETS_003'; - let currentFetchOps = fetchOps(testNum, 'Audios/Static/', AUDIO_TYPE); - let type = 'audio'; + it("SUB_MEDIA_MEDIALIBRARY_PROMISE_GETFILEASSETS_003", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_PROMISE_GETFILEASSETS_003"; + let currentFetchOps = fetchOps(testNum, "Audios/Static/", AUDIO_TYPE); + let type = "audio"; let count = 1; - await checkFileAssetAttr(done, testNum, currentFetchOps, type, count, null) + await checkFileAssetAttr(done, testNum, currentFetchOps, type, count, null); }); /** @@ -330,12 +383,12 @@ export default function mediaLibraryTestPromiseTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_PROMISE_GETFILEASSETS_004', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_PROMISE_GETFILEASSETS_004'; - let currentFetchOps = fetchOps(testNum, 'Documents/Static/', FILE_TYPE); - let type = 'file'; + it("SUB_MEDIA_MEDIALIBRARY_PROMISE_GETFILEASSETS_004", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_PROMISE_GETFILEASSETS_004"; + let currentFetchOps = fetchOps(testNum, "Documents/Static/", FILE_TYPE); + let type = "file"; let count = 1; - await checkFileAssetAttr(done, testNum, currentFetchOps, type, count, null) + await checkFileAssetAttr(done, testNum, currentFetchOps, type, count, null); }); /** @@ -346,13 +399,13 @@ export default function mediaLibraryTestPromiseTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_PROMISE_GETFILEASSETS_005', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_PROMISE_GETFILEASSETS_005'; + it("SUB_MEDIA_MEDIALIBRARY_PROMISE_GETFILEASSETS_005", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_PROMISE_GETFILEASSETS_005"; let currentFetchOps = imageAndVideofetchOp; - let type = 'video'; + let type = "video"; let count = 2; - let typesArr = ['image/*', 'video/mp4'] - await checkFileAssetAttr(done, testNum, currentFetchOps, type, count, typesArr) + let typesArr = ["image/*", "video/mp4"]; + await checkFileAssetAttr(done, testNum, currentFetchOps, type, count, typesArr); }); /** @@ -363,13 +416,13 @@ export default function mediaLibraryTestPromiseTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_PROMISE_GETFILEASSETS_006', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_PROMISE_GETFILEASSETS_006'; + it("SUB_MEDIA_MEDIALIBRARY_PROMISE_GETFILEASSETS_006", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_PROMISE_GETFILEASSETS_006"; let currentFetchOps = imageAndVideoAndfilefetchOp; - let type = 'file'; + let type = "file"; let count = 3; - let typesArr = ['image/*', 'video/mp4', 'file/*'] - await checkFileAssetAttr(done, testNum, currentFetchOps, type, count, typesArr) + let typesArr = ["image/*", "video/mp4", "file/*"]; + await checkFileAssetAttr(done, testNum, currentFetchOps, type, count, typesArr); }); /** @@ -380,13 +433,13 @@ export default function mediaLibraryTestPromiseTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_PROMISE_GETFILEASSETS_007', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_PROMISE_GETFILEASSETS_007'; + it("SUB_MEDIA_MEDIALIBRARY_PROMISE_GETFILEASSETS_007", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_PROMISE_GETFILEASSETS_007"; let currentFetchOps = imageAndVideoAndfileAndAudiofetchOp; - let type = 'audio'; + let type = "audio"; let count = 4; - let typesArr = ['image/*', 'video/mp4', 'file/*', 'audio/mpeg'] - await checkFileAssetAttr(done, testNum, currentFetchOps, type, count, typesArr) + let typesArr = ["image/*", "video/mp4", "file/*", "audio/mpeg"]; + await checkFileAssetAttr(done, testNum, currentFetchOps, type, count, typesArr); }); /** @@ -397,13 +450,13 @@ export default function mediaLibraryTestPromiseTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_PROMISE_GETFILEASSETS_008', 0, async function (done) { + it("SUB_MEDIA_MEDIALIBRARY_PROMISE_GETFILEASSETS_008", 0, async function (done) { let currentFetchOps = { - selections: FILEKEY.MEDIA_TYPE + '= ?', + selections: FILEKEY.MEDIA_TYPE + "= ?", selectionArgs: [], }; - let testNum = 'SUB_MEDIA_MEDIALIBRARY_PROMISE_GETFILEASSETS_008'; - await getFileAssetsZero(done, testNum, currentFetchOps) + let testNum = "SUB_MEDIA_MEDIALIBRARY_PROMISE_GETFILEASSETS_008"; + await getFileAssetsZero(done, testNum, currentFetchOps); }); /** @@ -414,13 +467,13 @@ export default function mediaLibraryTestPromiseTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_PROMISE_GETFILEASSETS_009', 0, async function (done) { + it("SUB_MEDIA_MEDIALIBRARY_PROMISE_GETFILEASSETS_009", 0, async function (done) { let currentFetchOps = { - selections: FILEKEY.MEDIA_TYPE + 'abc= ?', + selections: FILEKEY.MEDIA_TYPE + "abc= ?", selectionArgs: [AUDIO_TYPE.toString()], }; - let testNum = 'SUB_MEDIA_MEDIALIBRARY_PROMISE_GETFILEASSETS_009'; - await getFileAssetsAbnormal(done, testNum, currentFetchOps) + let testNum = "SUB_MEDIA_MEDIALIBRARY_PROMISE_GETFILEASSETS_009"; + await getFileAssetsAbnormal(done, testNum, currentFetchOps); }); /** @@ -431,13 +484,13 @@ export default function mediaLibraryTestPromiseTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_PROMISE_GETFILEASSETS_010', 0, async function (done) { + it("SUB_MEDIA_MEDIALIBRARY_PROMISE_GETFILEASSETS_010", 0, async function (done) { let currentFetchOps = { - selections: FILEKEY.MEDIA_TYPE + '= ?', + selections: FILEKEY.MEDIA_TYPE + "= ?", selectionArgs: [111], }; - let testNum = 'SUB_MEDIA_MEDIALIBRARY_PROMISE_GETFILEASSETS_010'; - await getFileAssetsZero(done, testNum, currentFetchOps) + let testNum = "SUB_MEDIA_MEDIALIBRARY_PROMISE_GETFILEASSETS_010"; + await getFileAssetsZero(done, testNum, currentFetchOps); }); /** @@ -448,13 +501,13 @@ export default function mediaLibraryTestPromiseTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_PROMISE_GETFILEASSETS_011', 0, async function (done) { + it("SUB_MEDIA_MEDIALIBRARY_PROMISE_GETFILEASSETS_011", 0, async function (done) { let currentFetchOps = { - selections: 'abc' + '= ?', + selections: "abc" + "= ?", selectionArgs: [AUDIO_TYPE.toString()], }; - let testNum = 'SUB_MEDIA_MEDIALIBRARY_PROMISE_GETFILEASSETS_011'; - await getFileAssetsAbnormal(done, testNum, currentFetchOps) + let testNum = "SUB_MEDIA_MEDIALIBRARY_PROMISE_GETFILEASSETS_011"; + await getFileAssetsAbnormal(done, testNum, currentFetchOps); }); /** @@ -465,11 +518,11 @@ export default function mediaLibraryTestPromiseTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_PROMISE_GETPUBLICDIRECTORY_001', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_PROMISE_GETPUBLICDIRECTORY_001'; + it("SUB_MEDIA_MEDIALIBRARY_PROMISE_GETPUBLICDIRECTORY_001", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_PROMISE_GETPUBLICDIRECTORY_001"; let dir = mediaLibrary.DirectoryType.DIR_CAMERA; - let val = 'Camera/'; - await checkGetPublicDirectory(done, testNum, dir, val) + let val = "Camera/"; + await checkGetPublicDirectory(done, testNum, dir, val); }); /** @@ -480,11 +533,11 @@ export default function mediaLibraryTestPromiseTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_PROMISE_GETPUBLICDIRECTORY_002', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_PROMISE_GETPUBLICDIRECTORY_002'; + it("SUB_MEDIA_MEDIALIBRARY_PROMISE_GETPUBLICDIRECTORY_002", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_PROMISE_GETPUBLICDIRECTORY_002"; let dir = mediaLibrary.DirectoryType.DIR_VIDEO; - let val = 'Videos/'; - await checkGetPublicDirectory(done, testNum, dir, val) + let val = "Videos/"; + await checkGetPublicDirectory(done, testNum, dir, val); }); /** @@ -495,11 +548,11 @@ export default function mediaLibraryTestPromiseTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_PROMISE_GETPUBLICDIRECTORY_003', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_PROMISE_GETPUBLICDIRECTORY_003'; + it("SUB_MEDIA_MEDIALIBRARY_PROMISE_GETPUBLICDIRECTORY_003", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_PROMISE_GETPUBLICDIRECTORY_003"; let dir = mediaLibrary.DirectoryType.DIR_IMAGE; - let val = 'Pictures/'; - await checkGetPublicDirectory(done, testNum, dir, val) + let val = "Pictures/"; + await checkGetPublicDirectory(done, testNum, dir, val); }); /** @@ -510,11 +563,11 @@ export default function mediaLibraryTestPromiseTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_PROMISE_GETPUBLICDIRECTORY_004', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_PROMISE_GETPUBLICDIRECTORY_004'; + it("SUB_MEDIA_MEDIALIBRARY_PROMISE_GETPUBLICDIRECTORY_004", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_PROMISE_GETPUBLICDIRECTORY_004"; let dir = mediaLibrary.DirectoryType.DIR_AUDIO; - let val = 'Audios/'; - await checkGetPublicDirectory(done, testNum, dir, val) + let val = "Audios/"; + await checkGetPublicDirectory(done, testNum, dir, val); }); /** @@ -525,11 +578,11 @@ export default function mediaLibraryTestPromiseTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_PROMISE_GETPUBLICDIRECTORY_005', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_PROMISE_GETPUBLICDIRECTORY_005'; + it("SUB_MEDIA_MEDIALIBRARY_PROMISE_GETPUBLICDIRECTORY_005", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_PROMISE_GETPUBLICDIRECTORY_005"; let dir = mediaLibrary.DirectoryType.DIR_DOCUMENTS; - let val = 'Documents/'; - await checkGetPublicDirectory(done, testNum, dir, val) + let val = "Documents/"; + await checkGetPublicDirectory(done, testNum, dir, val); }); /** @@ -540,14 +593,14 @@ export default function mediaLibraryTestPromiseTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_PROMISE_GETPUBLICDIRECTORY_006', 0, async function (done) { + it("SUB_MEDIA_MEDIALIBRARY_PROMISE_GETPUBLICDIRECTORY_006", 0, async function (done) { try { await media.getPublicDirectory(110); - console.info('MediaLibraryTest : getPublicDirectory 006 failed'); + console.info("MediaLibraryTest : getPublicDirectory 006 failed"); expect(false).assertTrue(); done(); } catch (error) { - console.info('MediaLibraryTest : getPublicDirectory 006 passed'); + console.info("MediaLibraryTest : getPublicDirectory 006 passed"); expect(true).assertTrue(); done(); } @@ -561,14 +614,13 @@ export default function mediaLibraryTestPromiseTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_PROMISE_GETPUBLICDIRECTORY_007', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_PROMISE_GETPUBLICDIRECTORY_007'; + it("SUB_MEDIA_MEDIALIBRARY_PROMISE_GETPUBLICDIRECTORY_007", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_PROMISE_GETPUBLICDIRECTORY_007"; let dir = mediaLibrary.DirectoryType.DIR_DOWNLOAD; - let val = 'Download/'; - await checkGetPublicDirectory(done, testNum, dir, val) + let val = "Download/"; + await checkGetPublicDirectory(done, testNum, dir, val); }); - /** * @tc.number : SUB_MEDIA_MEDIALIBRARY_PROMISE_CREATEASSET_001 * @tc.name : createAsset @@ -577,13 +629,13 @@ export default function mediaLibraryTestPromiseTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_PROMISE_CREATEASSET_001', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_PROMISE_CREATEASSET_001'; - let currentFetchOps = fetchOps(testNum, 'Pictures/Static/', IMAGE_TYPE); + it("SUB_MEDIA_MEDIALIBRARY_PROMISE_CREATEASSET_001", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_PROMISE_CREATEASSET_001"; + let currentFetchOps = fetchOps(testNum, "Pictures/Static/", IMAGE_TYPE); let type = IMAGE_TYPE; - let name = new Date().getTime() + '.jpg'; - let path = 'Pictures/Create/'; - await createAssetTest(done, testNum, currentFetchOps, type, name, path) + let name = new Date().getTime() + ".jpg"; + let path = "Pictures/Create/"; + await createAssetTest(done, testNum, currentFetchOps, type, name, path); }); /** @@ -594,14 +646,13 @@ export default function mediaLibraryTestPromiseTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_PROMISE_CREATEASSET_002', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_PROMISE_CREATEASSET_002'; - let currentFetchOps = fetchOps(testNum, 'Pictures/Static/', IMAGE_TYPE); + it("SUB_MEDIA_MEDIALIBRARY_PROMISE_CREATEASSET_002", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_PROMISE_CREATEASSET_002"; + let currentFetchOps = fetchOps(testNum, "Pictures/Static/", IMAGE_TYPE); let type = IMAGE_TYPE; - let name = new Date().getTime() + '.jpg'; - let path = 'Pictures/Create/'; - await createAssetSameNameTest(done, testNum, currentFetchOps, type, name, path) - + let name = new Date().getTime() + ".jpg"; + let path = "Pictures/Create/"; + await createAssetSameNameTest(done, testNum, currentFetchOps, type, name, path); }); /** @@ -612,13 +663,13 @@ export default function mediaLibraryTestPromiseTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_PROMISE_CREATEASSET_003', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_PROMISE_CREATEASSET_003'; - let currentFetchOps = fetchOps(testNum, 'Videos/Static/', VIDEO_TYPE); + it("SUB_MEDIA_MEDIALIBRARY_PROMISE_CREATEASSET_003", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_PROMISE_CREATEASSET_003"; + let currentFetchOps = fetchOps(testNum, "Videos/Static/", VIDEO_TYPE); let type = VIDEO_TYPE; - let name = new Date().getTime() + '.mp4'; - let path = 'Videos/Create/'; - await createAssetTest(done, testNum, currentFetchOps, type, name, path) + let name = new Date().getTime() + ".mp4"; + let path = "Videos/Create/"; + await createAssetTest(done, testNum, currentFetchOps, type, name, path); }); /** @@ -629,13 +680,13 @@ export default function mediaLibraryTestPromiseTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_PROMISE_CREATEASSET_004', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_PROMISE_CREATEASSET_004'; - let currentFetchOps = fetchOps(testNum, 'Videos/Static/', VIDEO_TYPE); + it("SUB_MEDIA_MEDIALIBRARY_PROMISE_CREATEASSET_004", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_PROMISE_CREATEASSET_004"; + let currentFetchOps = fetchOps(testNum, "Videos/Static/", VIDEO_TYPE); let type = VIDEO_TYPE; - let name = new Date().getTime() + '.mp4'; - let path = 'Videos/Create/'; - await createAssetSameNameTest(done, testNum, currentFetchOps, type, name, path) + let name = new Date().getTime() + ".mp4"; + let path = "Videos/Create/"; + await createAssetSameNameTest(done, testNum, currentFetchOps, type, name, path); }); /** @@ -646,13 +697,13 @@ export default function mediaLibraryTestPromiseTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_PROMISE_CREATEASSET_005', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_PROMISE_CREATEASSET_005'; - let currentFetchOps = fetchOps(testNum, 'Audios/Static/', AUDIO_TYPE); + it("SUB_MEDIA_MEDIALIBRARY_PROMISE_CREATEASSET_005", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_PROMISE_CREATEASSET_005"; + let currentFetchOps = fetchOps(testNum, "Audios/Static/", AUDIO_TYPE); let type = AUDIO_TYPE; - let name = new Date().getTime() + '.mp3'; - let path = 'Audios/Create/'; - await createAssetTest(done, testNum, currentFetchOps, type, name, path) + let name = new Date().getTime() + ".mp3"; + let path = "Audios/Create/"; + await createAssetTest(done, testNum, currentFetchOps, type, name, path); }); /** @@ -663,13 +714,13 @@ export default function mediaLibraryTestPromiseTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_PROMISE_CREATEASSET_006', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_PROMISE_CREATEASSET_006'; - let currentFetchOps = fetchOps(testNum, 'Audios/Static/', AUDIO_TYPE); + it("SUB_MEDIA_MEDIALIBRARY_PROMISE_CREATEASSET_006", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_PROMISE_CREATEASSET_006"; + let currentFetchOps = fetchOps(testNum, "Audios/Static/", AUDIO_TYPE); let type = AUDIO_TYPE; - let name = new Date().getTime() + '.mp3'; - let path = 'Audios/Create/'; - await createAssetSameNameTest(done, testNum, currentFetchOps, type, name, path) + let name = new Date().getTime() + ".mp3"; + let path = "Audios/Create/"; + await createAssetSameNameTest(done, testNum, currentFetchOps, type, name, path); }); /** @@ -680,13 +731,13 @@ export default function mediaLibraryTestPromiseTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_PROMISE_CREATEASSET_007', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_PROMISE_CREATEASSET_007'; - let currentFetchOps = fetchOps(testNum, 'Documents/Static/', FILE_TYPE); + it("SUB_MEDIA_MEDIALIBRARY_PROMISE_CREATEASSET_007", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_PROMISE_CREATEASSET_007"; + let currentFetchOps = fetchOps(testNum, "Documents/Static/", FILE_TYPE); let type = FILE_TYPE; - let name = new Date().getTime() + '.dat'; - let path = 'Documents/Create/'; - await createAssetTest(done, testNum, currentFetchOps, type, name, path) + let name = new Date().getTime() + ".dat"; + let path = "Documents/Create/"; + await createAssetTest(done, testNum, currentFetchOps, type, name, path); }); /** @@ -697,31 +748,30 @@ export default function mediaLibraryTestPromiseTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_PROMISE_CREATEASSET_008', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_PROMISE_CREATEASSET_008'; - let currentFetchOps = fetchOps(testNum, 'Documents/Static/', FILE_TYPE); + it("SUB_MEDIA_MEDIALIBRARY_PROMISE_CREATEASSET_008", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_PROMISE_CREATEASSET_008"; + let currentFetchOps = fetchOps(testNum, "Documents/Static/", FILE_TYPE); let type = FILE_TYPE; - let name = new Date().getTime() + '.dat'; - let path = 'Documents/Create/'; - await createAssetSameNameTest(done, testNum, currentFetchOps, type, name, path) + let name = new Date().getTime() + ".dat"; + let path = "Documents/Create/"; + await createAssetSameNameTest(done, testNum, currentFetchOps, type, name, path); }); /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_PROMISE_CREATEASSET_009 - * @tc.name : createAsset - * @tc.desc : Create File Asset image (does not exist) - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_PROMISE_CREATEASSET_009', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_PROMISE_CREATEASSET_009'; - let currentFetchOps = fetchOps(testNum, 'Pictures/Static/', IMAGE_TYPE); + * @tc.number : SUB_MEDIA_MEDIALIBRARY_PROMISE_CREATEASSET_009 + * @tc.name : createAsset + * @tc.desc : Create File Asset image (does not exist) + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it("SUB_MEDIA_MEDIALIBRARY_PROMISE_CREATEASSET_009", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_PROMISE_CREATEASSET_009"; + let currentFetchOps = fetchOps(testNum, "Pictures/Static/", IMAGE_TYPE); let type = IMAGE_TYPE; - let name = new Date().getTime() + '.jpg'; - let path = 'Pictures/Create/Temp'; - await createAssetTest(done, testNum, currentFetchOps, type, name, path) + let name = new Date().getTime() + ".jpg"; + let path = "Pictures/Create/Temp"; + await createAssetTest(done, testNum, currentFetchOps, type, name, path); }); }); } - diff --git a/multimedia/medialibrary/mediaLibrary_base/entry/src/main/ets/test/mediaLibraryTestPromiseOnOff.test.ets b/multimedia/medialibrary/mediaLibrary_base/entry/src/main/ets/test/mediaLibraryTestPromiseOnOff.test.ets old mode 100755 new mode 100644 index bf71439584c880d4688b7099e741f05bf9b16e5f..dd872407af4d1145c9e11cbf3aee2771e86feb1c --- a/multimedia/medialibrary/mediaLibrary_base/entry/src/main/ets/test/mediaLibraryTestPromiseOnOff.test.ets +++ b/multimedia/medialibrary/mediaLibrary_base/entry/src/main/ets/test/mediaLibraryTestPromiseOnOff.test.ets @@ -12,8 +12,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import mediaLibrary from '@ohos.multimedia.mediaLibrary'; -import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'; +import mediaLibrary from "@ohos.multimedia.mediaLibrary"; +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "deccjsunit/index"; import { sleep, @@ -26,37 +26,38 @@ import { albumFetchOps, getPermission, checkAlbumsCount, -} from '../../../../../../common'; +} from "../../../../../../common"; export default function mediaLibraryTestPromiseOnOffTest(abilityContext) { - describe('mediaLibraryTestPromiseOnOffTest', function () { + describe("mediaLibraryTestPromiseOnOffTest", function () { const media = mediaLibrary.getMediaLibrary(abilityContext); beforeAll(async function () { - console.info('beforeAll case'); - await getPermission(); + console.info("beforeAll case"); }); beforeEach(function () { - console.info('beforeEach case'); + console.info("beforeEach case"); }); afterEach(async function () { - console.info('afterEach case'); - await sleep() + console.info("afterEach case"); + await sleep(); }); afterAll(function () { - console.info('afterAll case'); + console.info("afterAll case"); }); const onTest = async (done, testNum, type, fetchOps) => { try { let count = 0; - media.on(type, () => { count++; }); + media.on(type, () => { + count++; + }); const fetchFileResult = await media.getFileAssets(fetchOps); let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchFileResult, 1); if (!checkAssetCountPass) return; const asset = await fetchFileResult.getFirstObject(); - asset.title = asset.title + 'changename'; + asset.title = asset.title + "changename"; await asset.commitModify(); - await sleep(1000) + await sleep(1000); expect(count > 0).assertTrue(); done(); } catch (error) { @@ -64,7 +65,7 @@ export default function mediaLibraryTestPromiseOnOffTest(abilityContext) { expect(false).assertTrue(); done(); } - } + }; const offTest = async (done, testNum, type, fetchOps) => { try { let count = 0; @@ -75,10 +76,10 @@ export default function mediaLibraryTestPromiseOnOffTest(abilityContext) { let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchFileResult, 1); if (!checkAssetCountPass) return; const asset = await fetchFileResult.getFirstObject(); - asset.title = asset.title + 'changename'; + asset.title = asset.title + "changename"; media.off(type); await asset.commitModify(); - await sleep(1000) + await sleep(1000); expect(count).assertEqual(0); done(); } catch (error) { @@ -86,8 +87,8 @@ export default function mediaLibraryTestPromiseOnOffTest(abilityContext) { expect(false).assertTrue(); done(); } - } - /** + }; + /** * @tc.number : SUB_MEDIA_MEDIALIBRARY_PROMISE_ON_001 * @tc.name : ON * @tc.desc : ON Image ASSET @@ -95,11 +96,11 @@ export default function mediaLibraryTestPromiseOnOffTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_PROMISE_ON_001', 0, async function (done) { - let type = 'imageChange' - let testNum = 'SUB_MEDIA_MEDIALIBRARY_PROMISE_ON_001'; - let currentFetchOps = fetchOps(testNum, 'Pictures/On/', IMAGE_TYPE); - await onTest(done, testNum, type, currentFetchOps) + it("SUB_MEDIA_MEDIALIBRARY_PROMISE_ON_001", 0, async function (done) { + let type = "imageChange"; + let testNum = "SUB_MEDIA_MEDIALIBRARY_PROMISE_ON_001"; + let currentFetchOps = fetchOps(testNum, "Pictures/On/", IMAGE_TYPE); + await onTest(done, testNum, type, currentFetchOps); }); /** @@ -110,11 +111,11 @@ export default function mediaLibraryTestPromiseOnOffTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_PROMISE_ON_002', 0, async function (done) { - let type = 'videoChange' - let testNum = 'SUB_MEDIA_MEDIALIBRARY_PROMISE_ON_002'; - let currentFetchOps = fetchOps(testNum, 'Videos/On/', VIDEO_TYPE); - await onTest(done, testNum, type, currentFetchOps) + it("SUB_MEDIA_MEDIALIBRARY_PROMISE_ON_002", 0, async function (done) { + let type = "videoChange"; + let testNum = "SUB_MEDIA_MEDIALIBRARY_PROMISE_ON_002"; + let currentFetchOps = fetchOps(testNum, "Videos/On/", VIDEO_TYPE); + await onTest(done, testNum, type, currentFetchOps); }); /** @@ -125,11 +126,11 @@ export default function mediaLibraryTestPromiseOnOffTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_PROMISE_ON_003', 0, async function (done) { - let type = 'audioChange' - let testNum = 'SUB_MEDIA_MEDIALIBRARY_PROMISE_ON_003'; - let currentFetchOps = fetchOps(testNum, 'Audios/On/', AUDIO_TYPE); - await onTest(done, testNum, type, currentFetchOps) + it("SUB_MEDIA_MEDIALIBRARY_PROMISE_ON_003", 0, async function (done) { + let type = "audioChange"; + let testNum = "SUB_MEDIA_MEDIALIBRARY_PROMISE_ON_003"; + let currentFetchOps = fetchOps(testNum, "Audios/On/", AUDIO_TYPE); + await onTest(done, testNum, type, currentFetchOps); }); /** @@ -140,11 +141,11 @@ export default function mediaLibraryTestPromiseOnOffTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_PROMISE_ON_004', 0, async function (done) { - let type = 'fileChange' - let testNum = 'SUB_MEDIA_MEDIALIBRARY_PROMISE_ON_004'; - let currentFetchOps = fetchOps(testNum, 'Documents/On/', FILE_TYPE); - await onTest(done, testNum, type, currentFetchOps) + it("SUB_MEDIA_MEDIALIBRARY_PROMISE_ON_004", 0, async function (done) { + let type = "fileChange"; + let testNum = "SUB_MEDIA_MEDIALIBRARY_PROMISE_ON_004"; + let currentFetchOps = fetchOps(testNum, "Documents/On/", FILE_TYPE); + await onTest(done, testNum, type, currentFetchOps); }); /** @@ -155,22 +156,22 @@ export default function mediaLibraryTestPromiseOnOffTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_PROMISE_ON_005', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_PROMISE_ON_005' + it("SUB_MEDIA_MEDIALIBRARY_PROMISE_ON_005", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_PROMISE_ON_005"; try { let count = 0; - media.on('albumChange', () => { + media.on("albumChange", () => { count++; }); - let currentFetchOps = albumFetchOps(testNum, 'Pictures/', 'OnAlbum', IMAGE_TYPE); + let currentFetchOps = albumFetchOps(testNum, "Pictures/", "OnAlbum", IMAGE_TYPE); const albumList = await media.getAlbums(currentFetchOps); const albumCountPass = await checkAlbumsCount(done, testNum, albumList, 1); if (!albumCountPass) return; const album = albumList[0]; - const oldName = album.albumName - album.albumName = album.albumName + 'changename'; + const oldName = album.albumName; + album.albumName = album.albumName + "changename"; await album.commitModify(); - await sleep(1000) + await sleep(1000); expect(count > 0).assertTrue(); album.albumName = oldName; await album.commitModify(); @@ -190,32 +191,32 @@ export default function mediaLibraryTestPromiseOnOffTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_PROMISE_ON_006', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_PROMISE_ON_006' + it("SUB_MEDIA_MEDIALIBRARY_PROMISE_ON_006", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_PROMISE_ON_006"; try { let count = 0; expect(true).assertTrue(); done(); - media.on('deviceChange', () => { - console.info('MediaLibraryTest : on 006 callback'); + media.on("deviceChange", () => { + console.info("MediaLibraryTest : on 006 callback"); count++; }); - let currentFetchOps = fetchOps(testNum, 'Documents/On/', FILE_TYPE); + let currentFetchOps = fetchOps(testNum, "Documents/On/", FILE_TYPE); const fetchFileResult = await media.getFileAssets(currentFetchOps); const asset = await fetchFileResult.getFirstObject(); - asset.title = asset.title + 'changename'; + asset.title = asset.title + "changename"; await asset.commitModify(); - await new Promise(res => { + await new Promise((res) => { setTimeout(() => { - res(true) - }, 1000) - }) + res(true); + }, 1000); + }); expect(count == 0).assertTrue(); done(); } catch (error) { console.info(`MediaLibraryTest : on 006 failed, error: ${error}`); expect(false).assertTrue(); - media.off('deviceChange'); + media.off("deviceChange"); done(); } }); @@ -228,33 +229,33 @@ export default function mediaLibraryTestPromiseOnOffTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_PROMISE_ON_007', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_PROMISE_ON_007' + it("SUB_MEDIA_MEDIALIBRARY_PROMISE_ON_007", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_PROMISE_ON_007"; try { let count = 0; expect(true).assertTrue(); done(); - media.on('remoteFileChange', () => { - console.info('MediaLibraryTest : on 007 callback'); + media.on("remoteFileChange", () => { + console.info("MediaLibraryTest : on 007 callback"); count++; }); - let currentFetchOps = fetchOps(testNum, 'Documents/On/', FILE_TYPE); + let currentFetchOps = fetchOps(testNum, "Documents/On/", FILE_TYPE); const fetchFileResult = await media.getFileAssets(currentFetchOps); const asset = await fetchFileResult.getFirstObject(); - asset.title = asset.title + 'changename'; + asset.title = asset.title + "changename"; await asset.commitModify(); - await new Promise(res => { + await new Promise((res) => { setTimeout(() => { - res(true) - }, 1000) - }) + res(true); + }, 1000); + }); expect(count == 0).assertTrue(); done(); } catch (error) { console.info(`MediaLibraryTest : on 007 failed, error: ${error}`); expect(false).assertTrue(); - media.off('remoteFileChange'); + media.off("remoteFileChange"); done(); } }); @@ -267,11 +268,11 @@ export default function mediaLibraryTestPromiseOnOffTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_PROMISE_OFF_001', 0, async function (done) { - let type = 'imageChange' - let testNum = 'SUB_MEDIA_MEDIALIBRARY_PROMISE_OFF_001'; - let currentFetchOps = fetchOps(testNum, 'Pictures/Off/', IMAGE_TYPE); - await offTest(done, testNum, type, currentFetchOps) + it("SUB_MEDIA_MEDIALIBRARY_PROMISE_OFF_001", 0, async function (done) { + let type = "imageChange"; + let testNum = "SUB_MEDIA_MEDIALIBRARY_PROMISE_OFF_001"; + let currentFetchOps = fetchOps(testNum, "Pictures/Off/", IMAGE_TYPE); + await offTest(done, testNum, type, currentFetchOps); }); /** @@ -282,11 +283,11 @@ export default function mediaLibraryTestPromiseOnOffTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_PROMISE_OFF_002', 0, async function (done) { - let type = 'videoChange' - let testNum = 'SUB_MEDIA_MEDIALIBRARY_PROMISE_OFF_002'; - let currentFetchOps = fetchOps(testNum, 'Videos/Off/', VIDEO_TYPE); - await offTest(done, testNum, type, currentFetchOps) + it("SUB_MEDIA_MEDIALIBRARY_PROMISE_OFF_002", 0, async function (done) { + let type = "videoChange"; + let testNum = "SUB_MEDIA_MEDIALIBRARY_PROMISE_OFF_002"; + let currentFetchOps = fetchOps(testNum, "Videos/Off/", VIDEO_TYPE); + await offTest(done, testNum, type, currentFetchOps); }); /** @@ -297,11 +298,11 @@ export default function mediaLibraryTestPromiseOnOffTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_PROMISE_OFF_003', 0, async function (done) { - let type = 'audioChange' - let testNum = 'SUB_MEDIA_MEDIALIBRARY_PROMISE_OFF_003'; - let currentFetchOps = fetchOps(testNum, 'Audios/Off/', AUDIO_TYPE); - await offTest(done, testNum, type, currentFetchOps) + it("SUB_MEDIA_MEDIALIBRARY_PROMISE_OFF_003", 0, async function (done) { + let type = "audioChange"; + let testNum = "SUB_MEDIA_MEDIALIBRARY_PROMISE_OFF_003"; + let currentFetchOps = fetchOps(testNum, "Audios/Off/", AUDIO_TYPE); + await offTest(done, testNum, type, currentFetchOps); }); /** @@ -312,40 +313,40 @@ export default function mediaLibraryTestPromiseOnOffTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_PROMISE_OFF_004', 0, async function (done) { - let type = 'fileChange' - let testNum = 'SUB_MEDIA_MEDIALIBRARY_PROMISE_OFF_004'; - let currentFetchOps = fetchOps(testNum, 'Documents/Off/', FILE_TYPE); - await offTest(done, testNum, type, currentFetchOps) + it("SUB_MEDIA_MEDIALIBRARY_PROMISE_OFF_004", 0, async function (done) { + let type = "fileChange"; + let testNum = "SUB_MEDIA_MEDIALIBRARY_PROMISE_OFF_004"; + let currentFetchOps = fetchOps(testNum, "Documents/Off/", FILE_TYPE); + await offTest(done, testNum, type, currentFetchOps); }); /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_PROMISE_OFF_005 - * @tc.name : off - * @tc.desc : off album - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_PROMISE_OFF_005', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_PROMISE_OFF_005' + * @tc.number : SUB_MEDIA_MEDIALIBRARY_PROMISE_OFF_005 + * @tc.name : off + * @tc.desc : off album + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it("SUB_MEDIA_MEDIALIBRARY_PROMISE_OFF_005", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_PROMISE_OFF_005"; try { let count = 0; - media.on('albumChange', () => { + media.on("albumChange", () => { count++; }); - await sleep(300) - media.off('albumChange'); - let currentFetchOps = albumFetchOps(testNum, 'Pictures/', 'OffAlbum', IMAGE_TYPE); + await sleep(300); + media.off("albumChange"); + let currentFetchOps = albumFetchOps(testNum, "Pictures/", "OffAlbum", IMAGE_TYPE); const albumList = await media.getAlbums(currentFetchOps); const albumCountPass = await checkAlbumsCount(done, testNum, albumList, 1); if (!albumCountPass) return; - const album = albumList[0] - const oldName = album.albumName - album.albumName = album.albumName + 'changename'; - await sleep(1000) + const album = albumList[0]; + const oldName = album.albumName; + album.albumName = album.albumName + "changename"; + await sleep(1000); await album.commitModify(); - await sleep(300) + await sleep(300); album.albumName = oldName; await album.commitModify(); expect(count).assertEqual(0); @@ -364,43 +365,43 @@ export default function mediaLibraryTestPromiseOnOffTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_PROMISE_OFF_006', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_PROMISE_OFF_006' + it("SUB_MEDIA_MEDIALIBRARY_PROMISE_OFF_006", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_PROMISE_OFF_006"; try { - media.on('deviceChange', () => { - console.info('MediaLibraryTest : off 006 failed'); + media.on("deviceChange", () => { + console.info("MediaLibraryTest : off 006 failed"); expect(false).assertTrue(); - media.off('deviceChange'); + media.off("deviceChange"); done(); }); - await new Promise(res => { + await new Promise((res) => { setTimeout(() => { - res(true) - }, 300) - }) - let currentFetchOps = fetchOps(testNum, 'Documents/On/', FILE_TYPE); + res(true); + }, 300); + }); + let currentFetchOps = fetchOps(testNum, "Documents/On/", FILE_TYPE); const fetchFileResult = await media.getFileAssets(currentFetchOps); const asset = await fetchFileResult.getFirstObject(); - asset.title = asset.title + 'deviceChange'; - media.off('deviceChange'); - await new Promise(res => { + asset.title = asset.title + "deviceChange"; + media.off("deviceChange"); + await new Promise((res) => { setTimeout(() => { - res(true) - }, 600) - }) + res(true); + }, 600); + }); await asset.commitModify(); - await new Promise(res => { + await new Promise((res) => { setTimeout(() => { - res(true) - }, 1000) - }) - console.info('MediaLibraryTest : off 006 passed'); + res(true); + }, 1000); + }); + console.info("MediaLibraryTest : off 006 passed"); expect(true).assertTrue(); done(); } catch (error) { console.info(`MediaLibraryTest : off 006 failed, error: ${error}`); expect(false).assertTrue(); - media.off('fileChange'); + media.off("fileChange"); done(); } }); @@ -413,44 +414,44 @@ export default function mediaLibraryTestPromiseOnOffTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_PROMISE_OFF_007', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_PROMISE_OFF_007' + it("SUB_MEDIA_MEDIALIBRARY_PROMISE_OFF_007", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_PROMISE_OFF_007"; try { - media.on('remoteFileChange', () => { - console.info('MediaLibraryTest : off 007 failed'); + media.on("remoteFileChange", () => { + console.info("MediaLibraryTest : off 007 failed"); expect(false).assertTrue(); - media.off('remoteFileChange'); + media.off("remoteFileChange"); done(); }); - await new Promise(res => { + await new Promise((res) => { setTimeout(() => { - res(true) - }, 300) - }) + res(true); + }, 300); + }); - media.off('remoteFileChange'); - let currentFetchOps = fetchOps(testNum, 'Documents/On/', FILE_TYPE); + media.off("remoteFileChange"); + let currentFetchOps = fetchOps(testNum, "Documents/On/", FILE_TYPE); const fetchFileResult = await media.getFileAssets(currentFetchOps); const asset = await fetchFileResult.getFirstObject(); - asset.title = asset.title + 'remoteFileChange'; - await new Promise(res => { + asset.title = asset.title + "remoteFileChange"; + await new Promise((res) => { setTimeout(() => { - res(true) - }, 600) - }) + res(true); + }, 600); + }); await asset.commitModify(); - await new Promise(res => { + await new Promise((res) => { setTimeout(() => { - res(true) - }, 1000) - }) - console.info('MediaLibraryTest : off 007 passed'); + res(true); + }, 1000); + }); + console.info("MediaLibraryTest : off 007 passed"); expect(true).assertTrue(); done(); } catch (error) { console.info(`MediaLibraryTest : off 007 failed, error: ${error}`); expect(false).assertTrue(); - media.off('fileChange'); + media.off("fileChange"); done(); } }); @@ -463,10 +464,10 @@ export default function mediaLibraryTestPromiseOnOffTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_PROMISE_RELEASE_001', 0, async function (done) { + it("SUB_MEDIA_MEDIALIBRARY_PROMISE_RELEASE_001", 0, async function (done) { try { await media.release(); - console.info('MediaLibraryTest : release 001 passed'); + console.info("MediaLibraryTest : release 001 passed"); expect(true).assertTrue(); done(); } catch (error) { @@ -477,5 +478,3 @@ export default function mediaLibraryTestPromiseOnOffTest(abilityContext) { }); }); } - - diff --git a/multimedia/medialibrary/mediaLibrary_base/entry/src/main/module.json b/multimedia/medialibrary/mediaLibrary_base/entry/src/main/module.json old mode 100755 new mode 100644 index 6785829959ef1d93e26aaea687a2ec9bb759d52d..025062ffed12b44b32db7f5f35356c9040ed9c5c --- a/multimedia/medialibrary/mediaLibrary_base/entry/src/main/module.json +++ b/multimedia/medialibrary/mediaLibrary_base/entry/src/main/module.json @@ -3,11 +3,11 @@ "name": "phone", "type": "entry", "srcEntrance": "./ets/Application/AbilityStage.ts", - "description": "$string:mainability_description", + "description": "$string:phone_entry_dsc", "mainElement": "MainAbility", "deviceTypes": [ - "tablet", - "default", + "tablet", + "default", "phone" ], "deliveryWithInstall": true, @@ -16,11 +16,11 @@ "pages": "$profile:main_pages", "abilities": [ { - "name": "ohos.acts.multimedia.mediaLibrary.MainAbility", + "name": "com.example.myapplication.MainAbility", "srcEntrance": "./ets/MainAbility/MainAbility.ts", - "description": "$string:mainability_description", + "description": "$string:phone_entry_main", "icon": "$media:icon", - "label": "$string:entry_MainAbility", + "label": "$string:entry_label", "visible": true, "orientation": "portrait", "skills": [ @@ -28,42 +28,42 @@ "actions": [ "action.system.home" ], - "entities":[ + "entities": [ "entity.system.home" ] } ] } ], - "requestPermissions": [ + "requestPermissions": [ { "name": "ohos.permission.GET_BUNDLE_INFO", "reason": "use ohos.permission.GET_BUNDLE_INFO" }, { "name": "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED", - "reason":"use ohos.permission.GET_BUNDLE_INFO_PRIVILEGED" + "reason": "use ohos.permission.GET_BUNDLE_INFO_PRIVILEGED" }, { - "name" : "ohos.permission.GRANT_SENSITIVE_PERMISSIONS", - "reason" : "use ohos.permission.GRANT_SENSITIVE_PERMISSIONS" + "name": "ohos.permission.GRANT_SENSITIVE_PERMISSIONS", + "reason": "use ohos.permission.GRANT_SENSITIVE_PERMISSIONS" }, { - "name" : "ohos.permission.REVOKE_SENSITIVE_PERMISSIONS", - "reason" : "use ohos.permission.REVOKE_SENSITIVE_PERMISSIONS" + "name": "ohos.permission.REVOKE_SENSITIVE_PERMISSIONS", + "reason": "use ohos.permission.REVOKE_SENSITIVE_PERMISSIONS" }, { "name": "ohos.permission.MEDIA_LOCATION", - "reason":"use ohos.permission.MEDIA_LOCATION" + "reason": "use ohos.permission.MEDIA_LOCATION" }, { "name": "ohos.permission.READ_MEDIA", - "reason":"use ohos.permission.READ_MEDIA" + "reason": "use ohos.permission.READ_MEDIA" }, { "name": "ohos.permission.WRITE_MEDIA", - "reason":"use ohos.permission.WRITE_MEDIA" + "reason": "use ohos.permission.WRITE_MEDIA" } ] } -} +} \ No newline at end of file diff --git a/multimedia/medialibrary/mediaLibrary_base/entry/src/main/resources/base/element/string.json b/multimedia/medialibrary/mediaLibrary_base/entry/src/main/resources/base/element/string.json old mode 100755 new mode 100644 index d75a3fee650de2abaabfd60f40d90d9c6a4b0b0b..2ae43f018e75d1140cf2c0c85a6a14fc369a0c50 --- a/multimedia/medialibrary/mediaLibrary_base/entry/src/main/resources/base/element/string.json +++ b/multimedia/medialibrary/mediaLibrary_base/entry/src/main/resources/base/element/string.json @@ -1,12 +1,32 @@ { "string": [ - { - "name": "entry_MainAbility", - "value": "MediaLibraryJSTestMain" - }, - { - "name": "mainability_description", - "value": "MediaLibraryJSTestMain Ability" - } + { + "name": "phone_entry_dsc", + "value": "i am an entry for phone" + }, + { + "name": "phone_entry_main", + "value": "the phone entry ability" + }, + { + "name": "entry_label", + "value": "ActsMediaLibraryTest" + }, + { + "name": "form_description", + "value": "mediaLibrary" + }, + { + "name": "serviceability_description", + "value": "mediaLibrary" + }, + { + "name": "description_application", + "value": "mediaLibrary test" + }, + { + "name": "app_name", + "value": "ActsMediaLibraryTest" + } ] - } \ No newline at end of file +} \ No newline at end of file diff --git a/multimedia/medialibrary/mediaLibrary_base/entry/src/main/resources/base/profile/main_pages.json b/multimedia/medialibrary/mediaLibrary_base/entry/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 index 6898b31d2085f478ee1ed9d933a5910cbf901d92..ceb075cd80946aade673d707aac904fb8998bce9 --- a/multimedia/medialibrary/mediaLibrary_base/entry/src/main/resources/base/profile/main_pages.json +++ b/multimedia/medialibrary/mediaLibrary_base/entry/src/main/resources/base/profile/main_pages.json @@ -1,6 +1,5 @@ { "src": [ - "pages/index/index", - "pages/second/second" + "MainAbility/pages/index/index" ] } \ No newline at end of file diff --git a/multimedia/medialibrary/mediaLibrary_base/signature/openharmony_sx.p7b b/multimedia/medialibrary/mediaLibrary_base/signature/openharmony_sx.p7b old mode 100755 new mode 100644 index 3eb5b5db82a014ff4c9483872cad743ad49a9b6e..64b33bf079b2ab68a3f26f240d127186546b33d9 Binary files a/multimedia/medialibrary/mediaLibrary_base/signature/openharmony_sx.p7b and b/multimedia/medialibrary/mediaLibrary_base/signature/openharmony_sx.p7b differ diff --git a/multimedia/medialibrary/mediaLibrary_favorite/AppScope/app.json b/multimedia/medialibrary/mediaLibrary_favorite/AppScope/app.json old mode 100755 new mode 100644 index 841282ae47b98590bdbc8aea744fbbcd178e9195..803955ad0d2a5b4ce4e103816a6a917b4701286b --- a/multimedia/medialibrary/mediaLibrary_favorite/AppScope/app.json +++ b/multimedia/medialibrary/mediaLibrary_favorite/AppScope/app.json @@ -1,21 +1,21 @@ -{ - "app":{ - "bundleName":"ohos.acts.multimedia.mediaLibrary", - "vendor":"huawei", - "versionCode":1000000, - "versionName":"1.0.0", - "debug":false, - "icon":"$media:icon", - "label":"$string:entry_MainAbility", - "description":"$string:mainability_description", - "distributedNotificationEnabled":true, - "keepAlive":true, - "singleUser":true, - "minAPIVersion":8, - "targetAPIVersion":8, - "car":{ - "apiCompatibleVersion":8, - "singleUser":false - } - } -} +{ + "app": { + "bundleName": "ohos.acts.multimedia.mediaLibrary", + "vendor": "huawei", + "versionCode": 1000000, + "versionName": "1.0.0", + "debug": false, + "icon": "$media:icon", + "label": "$string:app_name", + "description": "$string:description_application", + "distributedNotificationEnabled": true, + "keepAlive": true, + "singleUser": true, + "minAPIVersion": 9, + "targetAPIVersion": 9, + "car": { + "apiCompatibleVersion": 9, + "singleUser": false + } + } +} \ No newline at end of file diff --git a/multimedia/medialibrary/mediaLibrary_favorite/AppScope/resources/base/element/string.json b/multimedia/medialibrary/mediaLibrary_favorite/AppScope/resources/base/element/string.json old mode 100755 new mode 100644 index 9b9d5b5e10c7ce74908c32b43d24568367b46d97..ee69f9a861d9dc269ed6638735d52674583498e1 --- a/multimedia/medialibrary/mediaLibrary_favorite/AppScope/resources/base/element/string.json +++ b/multimedia/medialibrary/mediaLibrary_favorite/AppScope/resources/base/element/string.json @@ -1,12 +1,8 @@ -{ - "string": [ - { - "name": "entry_MainAbility", - "value": "MediaLibraryJSTestMain" - }, - { - "name": "mainability_description", - "value": "MediaLibraryJSTestMain Ability" - } - ] -} \ No newline at end of file +{ + "string":[ + { + "name":"app_name", + "value":"ohosProject" + } + ] +} \ No newline at end of file diff --git a/multimedia/medialibrary/mediaLibrary_favorite/BUILD.gn b/multimedia/medialibrary/mediaLibrary_favorite/BUILD.gn old mode 100755 new mode 100644 index 18389d25439db13db9103b0dcc637b9203d04920..a6163ed650ff2e9229469fd278bdae48543b782e --- a/multimedia/medialibrary/mediaLibrary_favorite/BUILD.gn +++ b/multimedia/medialibrary/mediaLibrary_favorite/BUILD.gn @@ -15,6 +15,7 @@ import("//test/xts/tools/build/suite.gni") ohos_js_hap_suite("mediaLibrary_favorite_hap") { hap_profile = "entry/src/main/module.json" + js_build_mode = "debug" deps = [ ":mediaLibrary_js_assets", ":mediaLibrary_resources", diff --git a/multimedia/medialibrary/mediaLibrary_favorite/Test.json b/multimedia/medialibrary/mediaLibrary_favorite/Test.json old mode 100755 new mode 100644 index df0a755538ecc2d4cbce6c9068d50364a30986f2..3d35651c0fcbd35c6f52368cdc99d2ce3003a49f --- a/multimedia/medialibrary/mediaLibrary_favorite/Test.json +++ b/multimedia/medialibrary/mediaLibrary_favorite/Test.json @@ -1,62 +1,68 @@ -{ - "description": "Configuration for mediaLibrary Tests", - "driver": { - "type": "JSUnitTest", - "test-timeout": "300000", - "package": "ohos.acts.multimedia.mediaLibrary", - "shell-timeout": "600000" - }, - "kits": [ - { - "type": "ShellKit", - "pre-push": [], - "run-command": [ - "rm -rf /storage/media/100/local/files/*", - "rm -rf /data/app/el2/100/database/com.ohos.medialibrary.medialibrarydata/*", - "mkdir -pv /storage/media/100/local/files/{Pictures,Videos,Audios,Documents}", - "mkdir -p /storage/media/100/local/temp" - ] - }, - { - "type": "PushKit", - "pre-push": [], - "push": [ - "./resource/medialibrary/01.jpg ->/storage/media/100/local/temp", - "./resource/medialibrary/01.mp3 ->/storage/media/100/local/temp", - "./resource/medialibrary/01.mp4 ->/storage/media/100/local/temp", - "./resource/medialibrary/01.dat ->/storage/media/100/local/temp" - ] - }, - { - "type": "ShellKit", - "run-command": [ - "mkdir -pv /storage/media/100/local/files/Pictures/{StaticPro,StaticCb}", - "mkdir -pv /storage/media/100/local/files/Videos/{StaticPro,StaticCb}", - "mkdir -pv /storage/media/100/local/files/Audios/{StaticPro,StaticCb}", - "mkdir -pv /storage/media/100/local/files/Documents/{StaticPro,StaticCb}", - "for d in {StaticPro,StaticCb}; 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 {StaticPro,StaticCb}; 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 {StaticPro,StaticCb}; 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 {StaticPro,StaticCb}; do for i in $$(seq 4); do cp /storage/media/100/local/temp/01.dat /storage/media/100/local/files/Documents/$$d/0$$i.dat; done;done;", - "chmod -R 777 /storage/media/100/local/files/*", - "chmod -R 777 /data/service/el2/100/hmdfs/account/files/*", - "hilog -Q pidoff", - "hilog -p off", - "hilog -b I", - "hilog -b D -D 0xD002B70", - "scanner", - "sleep 10" - ], - "teardown-command":[ - "hilog -b X -D 0xD002B70" - ] - }, - { - "test-file-name": [ - "ActsMediaLibraryFavoriteTest.hap" - ], - "type": "AppInstallKit", - "cleanup-apps": true - } - ] +{ + "description": "Configuration for mediaLibrary Tests", + "driver": { + "type": "OHJSUnitTest", + "test-timeout": "180000", + "bundle-name": "ohos.acts.multimedia.mediaLibrary", + "module-name": "phone", + "shell-timeout": "600000", + "testcase-timeout": 70000 + }, + "kits": [ + { + "type": "ShellKit", + "pre-push": [], + "run-command": [ + "rm -rf /storage/media/100/local/files/*", + "rm -rf /data/app/el2/100/database/com.ohos.medialibrary.medialibrarydata/*", + "mkdir -pv /storage/media/100/local/files/{Pictures,Videos,Audios,Documents}", + "mkdir -p /storage/media/100/local/temp", + "power-shell wakeup", + "uinput -T -d 300 600 -m 300 600 300 100 -u 300 100", + "power-shell setmode 602" + ] + }, + { + "type": "PushKit", + "pre-push": [], + "push": [ + "./resource/medialibrary/01.jpg ->/storage/media/100/local/temp", + "./resource/medialibrary/01.mp3 ->/storage/media/100/local/temp", + "./resource/medialibrary/01.mp4 ->/storage/media/100/local/temp", + "./resource/medialibrary/01.dat ->/storage/media/100/local/temp" + ] + }, + { + "type": "ShellKit", + "run-command": [ + "mkdir -pv /storage/media/100/local/files/Pictures/{StaticPro,StaticCb}", + "mkdir -pv /storage/media/100/local/files/Videos/{StaticPro,StaticCb}", + "mkdir -pv /storage/media/100/local/files/Audios/{StaticPro,StaticCb}", + "mkdir -pv /storage/media/100/local/files/Documents/{StaticPro,StaticCb}", + "for d in {StaticPro,StaticCb}; 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 {StaticPro,StaticCb}; 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 {StaticPro,StaticCb}; 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 {StaticPro,StaticCb}; do for i in $$(seq 4); do cp /storage/media/100/local/temp/01.dat /storage/media/100/local/files/Documents/$$d/0$$i.dat; done;done;", + "chmod -R 777 /storage/media/100/local/files/*", + "chmod -R 777 /data/service/el2/100/hmdfs/account/files/*", + "hilog -Q pidoff", + "hilog -p off", + "hilog -b I", + "hilog -b D -D 0xD002B70", + "scanner", + "sleep 10" + ], + "teardown-command": [ + "hilog -b X -D 0xD002B70", + "power-shell setmode 600" + ] + }, + { + "test-file-name": [ + "ActsMediaLibraryFavoriteTest.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + } + ] } \ No newline at end of file diff --git a/multimedia/medialibrary/mediaLibrary_favorite/entry/src/main/ets/Application/AbilityStage.ts b/multimedia/medialibrary/mediaLibrary_favorite/entry/src/main/ets/Application/AbilityStage.ts old mode 100755 new mode 100644 index 14f230e140160dc5f94ecc462304621178f4cf64..b0e0206ea9fb5ce94ef140d69510b6280969dd8e --- a/multimedia/medialibrary/mediaLibrary_favorite/entry/src/main/ets/Application/AbilityStage.ts +++ b/multimedia/medialibrary/mediaLibrary_favorite/entry/src/main/ets/Application/AbilityStage.ts @@ -1,9 +1,9 @@ -import AbilityStage from "@ohos.application.AbilityStage" - -export default class MyAbilityStage extends AbilityStage { - onCreate() { - console.log("[Demo] MyAbilityStage onCreate") - globalThis.stageOnCreateRun = 1; - globalThis.stageContext = this.context; - } -} +import AbilityStage from "@ohos.app.ability.AbilityStage" + +export default class MyAbilityStage extends AbilityStage { + onCreate() { + console.log("[Demo] MyAbilityStage onCreate") + globalThis.stageOnCreateRun = 1; + globalThis.stageContext = this.context; + } +} diff --git a/multimedia/medialibrary/mediaLibrary_favorite/entry/src/main/ets/MainAbility/MainAbility.ts b/multimedia/medialibrary/mediaLibrary_favorite/entry/src/main/ets/MainAbility/MainAbility.ts old mode 100755 new mode 100644 index 72b03d747b3e2e8bdf18ea37c54c789bebb767bb..df41851318f3385890e235a96dfbcc0441cb13f1 --- a/multimedia/medialibrary/mediaLibrary_favorite/entry/src/main/ets/MainAbility/MainAbility.ts +++ b/multimedia/medialibrary/mediaLibrary_favorite/entry/src/main/ets/MainAbility/MainAbility.ts @@ -1,36 +1,36 @@ -import Ability from '@ohos.application.Ability' - -export default class MainAbility extends Ability { - onCreate(want,launchParam){ - // Ability is creating, initialize resources for this ability - console.log("[Demo] MainAbility onCreate") - globalThis.abilityWant = want; - } - - onDestroy() { - // Ability is destroying, release resources for this ability - console.log("[Demo] MainAbility onDestroy") - } - - onWindowStageCreate(windowStage) { - // Main window is created, set main page for this ability - console.log("[Demo] MainAbility onWindowStageCreate") - globalThis.abilityContext = this.context - windowStage.setUIContent(this.context, "pages/index/index", null) - } - - onWindowStageDestroy() { - //Main window is destroyed, release UI related resources - console.log("[Demo] MainAbility onWindowStageDestroy") - } - - onForeground() { - // Ability has brought to foreground - console.log("[Demo] MainAbility onForeground") - } - - onBackground() { - // Ability has back to background - console.log("[Demo] MainAbility onBackground") - } +import Ability from '@ohos.app.ability.UIAbility' + +export default class MainAbility extends Ability { + onCreate(want, launchParam) { + // Ability is creating, initialize resources for this ability + console.log("[Demo] MainAbility onCreate") + globalThis.abilityWant = want; + } + + onDestroy() { + // Ability is destroying, release resources for this ability + console.log("[Demo] MainAbility onDestroy") + } + + async onWindowStageCreate(windowStage) { + console.log("[Demo] MainAbility onWindowStageCreate windowStage=" + windowStage) + globalThis.windowStage = windowStage + globalThis.abilityContext = this.context + windowStage.setUIContent(this.context, "MainAbility/pages/index/index", null) + } + + onWindowStageDestroy() { + //Main window is destroyed, release UI related resources + console.log("[Demo] MainAbility onWindowStageDestroy") + } + + onForeground() { + // Ability has brought to foreground + console.log("[Demo] MainAbility onForeground") + } + + onBackground() { + // Ability has back to background + console.log("[Demo] MainAbility onBackground") + } }; \ No newline at end of file diff --git a/multimedia/medialibrary/mediaLibrary_fileAsset/entry/src/main/ets/pages/index/index.ets b/multimedia/medialibrary/mediaLibrary_favorite/entry/src/main/ets/MainAbility/pages/index/index.ets old mode 100755 new mode 100644 similarity index 58% rename from multimedia/medialibrary/mediaLibrary_fileAsset/entry/src/main/ets/pages/index/index.ets rename to multimedia/medialibrary/mediaLibrary_favorite/entry/src/main/ets/MainAbility/pages/index/index.ets index 624cad290665fcd29dcd579d9582a300479e8ad7..6a8c567d5a86048b1c269e4f00cc288ec136200b --- a/multimedia/medialibrary/mediaLibrary_fileAsset/entry/src/main/ets/pages/index/index.ets +++ b/multimedia/medialibrary/mediaLibrary_favorite/entry/src/main/ets/MainAbility/pages/index/index.ets @@ -12,36 +12,24 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import file from '@system.file'; +import router from '@ohos.router'; +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' +import { Hypium } from '@ohos/hypium' +import testsuite from '../../../test/List.test' -import {Core, ExpectExtend, InstrumentLog, ReportExtend} from "deccjsunit/index" -import testsuite from "../../test/List.test.ets" @Entry @Component struct Index { aboutToAppear(){ - console.info("start run testcase!!!!") - const core = Core.getInstance() - const expectExtend = new ExpectExtend({ - 'id': 'extend' - }) - core.addService('expect', expectExtend) - const reportExtend = new ReportExtend(file) - - core.addService('report', reportExtend) - core.init() - core.subscribeEvent('task', reportExtend) - const configService = core.getDefaultService('config') - console.info('parameters---->' + JSON.stringify(globalThis.abilityWant.parameters)) - globalThis.abilityWant.parameters.timeout = 70000; - configService.setConfig(globalThis.abilityWant.parameters) - console.info('testsuite()---->') - testsuite(globalThis.abilityContext) - core.execute() - console.info('core.execute()---->') + var abilityDelegator: any + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var abilityDelegatorArguments: any + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + console.info('start run testcase!!!') + Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) } build() { diff --git a/multimedia/medialibrary/mediaLibrary_favorite/entry/src/main/ets/TestAbility/TestAbility.ts b/multimedia/medialibrary/mediaLibrary_favorite/entry/src/main/ets/TestAbility/TestAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..8028a70f8af44690b95a08bd177bca6b09f24687 --- /dev/null +++ b/multimedia/medialibrary/mediaLibrary_favorite/entry/src/main/ets/TestAbility/TestAbility.ts @@ -0,0 +1,50 @@ +/* + * 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 Ability from '@ohos.app.ability.UIAbility' + +export default class TestAbility extends Ability { + onCreate(want, launchParam) { + console.log('TestAbility onCreate') + } + + onDestroy() { + console.log('TestAbility onDestroy') + } + + onWindowStageCreate(windowStage) { + console.log('TestAbility onWindowStageCreate') + windowStage.loadContent("TestAbility/pages/index", (err, data) => { + if (err.code) { + console.error('Failed to load the content. Cause:' + JSON.stringify(err)); + return; + } + console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data)) + }); + + globalThis.abilityContext = this.context; + } + + onWindowStageDestroy() { + console.log('TestAbility onWindowStageDestroy') + } + + onForeground() { + console.log('TestAbility onForeground') + } + + onBackground() { + console.log('TestAbility onBackground') + } +}; \ No newline at end of file diff --git a/multimedia/medialibrary/mediaLibrary_favorite/entry/src/main/ets/TestAbility/pages/index.ets b/multimedia/medialibrary/mediaLibrary_favorite/entry/src/main/ets/TestAbility/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..b93567f962921124b282f78c8ef123965d1460c9 --- /dev/null +++ b/multimedia/medialibrary/mediaLibrary_favorite/entry/src/main/ets/TestAbility/pages/index.ets @@ -0,0 +1,48 @@ +/* + * 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 router from '@ohos.router'; + +@Entry +@Component +struct Index { + aboutToAppear() { + console.info('TestAbility index aboutToAppear') + } + @State message: string = 'Hello World' + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('next page') + .fontSize(20) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .width('35%') + .height('5%') + .onClick(()=>{ + }) + } + .width('100%') + } + .height('100%') + } + } \ No newline at end of file diff --git a/multimedia/medialibrary/mediaLibrary_favorite/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts b/multimedia/medialibrary/mediaLibrary_favorite/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts new file mode 100644 index 0000000000000000000000000000000000000000..a4ee2f1652b3d04ce83ece64ef70f8dfa62a2dc8 --- /dev/null +++ b/multimedia/medialibrary/mediaLibrary_favorite/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts @@ -0,0 +1,78 @@ +/* + * 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 TestRunner from '@ohos.application.testRunner' +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' + +var abilityDelegator = undefined +var abilityDelegatorArguments = undefined + +function translateParamsToString(parameters) { + const keySet = new Set([ + '-s class', '-s notClass', '-s suite', '-s it', + '-s level', '-s testType', '-s size', '-s timeout', + '-s dryRun' + ]) + let targetParams = ''; + for (const key in parameters) { + if (keySet.has(key)) { + targetParams = `${targetParams} ${key} ${parameters[key]}` + } + } + return targetParams.trim() +} + +async function onAbilityCreateCallback() { + console.log("onAbilityCreateCallback"); +} + +async function addAbilityMonitorCallback(err: any) { + console.info("addAbilityMonitorCallback : " + JSON.stringify(err)) +} + +export default class OpenHarmonyTestRunner implements TestRunner { + constructor() { + } + + onPrepare() { + console.info("OpenHarmonyTestRunner OnPrepare ") + } + + async onRun() { + console.log('OpenHarmonyTestRunner onRun run') + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var testAbilityName = abilityDelegatorArguments.bundleName + '.MainAbility' + let lMonitor = { + abilityName: testAbilityName, + onAbilityCreate: onAbilityCreateCallback, + }; + abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback) + var cmd = 'aa start -d 0 -a com.example.myapplication.MainAbility' + ' -b ' + abilityDelegatorArguments.bundleName + cmd += ' '+translateParamsToString(abilityDelegatorArguments.parameters) + var debug = abilityDelegatorArguments.parameters["-D"] + if (debug == 'true') + { + cmd += ' -D' + } + console.info('cmd : '+cmd) + abilityDelegator.executeShellCommand(cmd, + (err: any, d: any) => { + console.info('executeShellCommand : err : ' + JSON.stringify(err)); + console.info('executeShellCommand : data : ' + d.stdResult); + console.info('executeShellCommand : data : ' + d.exitCode); + }) + console.info('OpenHarmonyTestRunner onRun end') + } +}; \ No newline at end of file diff --git a/multimedia/medialibrary/mediaLibrary_favorite/entry/src/main/ets/pages/index/index.ets b/multimedia/medialibrary/mediaLibrary_favorite/entry/src/main/ets/pages/index/index.ets deleted file mode 100755 index 71bcb74b8a045a4e05dd64ed8209d3964c72a730..0000000000000000000000000000000000000000 --- a/multimedia/medialibrary/mediaLibrary_favorite/entry/src/main/ets/pages/index/index.ets +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import file from '@system.file'; - -import {Core, ExpectExtend, InstrumentLog, ReportExtend} from "deccjsunit/index" -import testsuite from "../../test/List.test.ets" - -@Entry -@Component -struct Index { - - aboutToAppear(){ - console.info("start run testcase!!!!") - const core = Core.getInstance() - const expectExtend = new ExpectExtend({ - 'id': 'extend' - }) - core.addService('expect', expectExtend) - const reportExtend = new ReportExtend(file) - - core.addService('report', reportExtend) - core.init() - core.subscribeEvent('task', reportExtend) - const configService = core.getDefaultService('config') - console.info('parameters---->' + JSON.stringify(globalThis.abilityWant.parameters)) - globalThis.abilityWant.parameters.timeout = 70000; - configService.setConfig(globalThis.abilityWant.parameters) - console.info('testsuite()---->') - testsuite(globalThis.abilityContext) - core.execute() - console.info('core.execute()---->') - } - - build() { - Flex({ direction:FlexDirection.Column, alignItems:ItemAlign.Center, justifyContent: FlexAlign.Center }) { - Text('Hello World') - .fontSize(50) - .fontWeight(FontWeight.Bold) - Button() { - Text('next page') - .fontSize(25) - .fontWeight(FontWeight.Bold) - }.type(ButtonType.Capsule) - .margin({ - top: 20 - }) - .backgroundColor('#0D9FFB') - .onClick(() => { - - }) - } - .width('100%') - .height('100%') - } -} \ No newline at end of file diff --git a/multimedia/medialibrary/mediaLibrary_favorite/entry/src/main/ets/pages/second/second.ets b/multimedia/medialibrary/mediaLibrary_favorite/entry/src/main/ets/pages/second/second.ets deleted file mode 100755 index 1f2a06b64cdadcc83027bb6797e24536a2c85757..0000000000000000000000000000000000000000 --- a/multimedia/medialibrary/mediaLibrary_favorite/entry/src/main/ets/pages/second/second.ets +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import router from '@system.router'; - -@Entry -@Component -struct Second { - private content: string = "Second Page" - - build() { - Flex({ direction: FlexDirection.Column,alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { - Text(`${this.content}`) - .fontSize(50) - .fontWeight(FontWeight.Bold) - Button() { - Text('back to index') - .fontSize(20) - .fontWeight(FontWeight.Bold) - }.type(ButtonType.Capsule) - .margin({ - top: 20 - }) - .backgroundColor('#0D9FFB') - .onClick(() => { - router.back() - }) - } - .width('100%') - .height('100%') - } -} \ No newline at end of file diff --git a/multimedia/medialibrary/mediaLibrary_favorite/entry/src/main/ets/test/List.test.ets b/multimedia/medialibrary/mediaLibrary_favorite/entry/src/main/ets/test/List.test.ets old mode 100755 new mode 100644 index 41be7d631bedb420b99c5fb4f393dd283dc03c51..accc5435b0392b88b55f445ef3a4adc0cdfd25c0 --- a/multimedia/medialibrary/mediaLibrary_favorite/entry/src/main/ets/test/List.test.ets +++ b/multimedia/medialibrary/mediaLibrary_favorite/entry/src/main/ets/test/List.test.ets @@ -15,7 +15,7 @@ import favoriteTestPromise from './favoriteTestPromise.test.ets' import favoriteTestCallback from './favoriteTestCallback.test.ets' -export default function testsuite(abilityContext) { - favoriteTestCallback(abilityContext) - favoriteTestPromise(abilityContext) +export default function testsuite() { + favoriteTestCallback(globalThis.abilityContext) + favoriteTestPromise(globalThis.abilityContext) } diff --git a/multimedia/medialibrary/mediaLibrary_favorite/entry/src/main/ets/test/favoriteTestCallback.test.ets b/multimedia/medialibrary/mediaLibrary_favorite/entry/src/main/ets/test/favoriteTestCallback.test.ets old mode 100755 new mode 100644 index 0305cba09e1c93b44bce1e63f1ccbb46d7754b75..b7d3b6f6a7f0d740c18507514c708f3e6b7dd0d9 --- a/multimedia/medialibrary/mediaLibrary_favorite/entry/src/main/ets/test/favoriteTestCallback.test.ets +++ b/multimedia/medialibrary/mediaLibrary_favorite/entry/src/main/ets/test/favoriteTestCallback.test.ets @@ -13,8 +13,8 @@ * limitations under the License. */ -import mediaLibrary from '@ohos.multimedia.mediaLibrary'; -import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'; +import mediaLibrary from "@ohos.multimedia.mediaLibrary"; +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "deccjsunit/index"; import { sleep, IMAGE_TYPE, @@ -25,25 +25,25 @@ import { nameFetchOps, checkAssetsCount, getPermission, -} from '../../../../../../common'; +} from "../../../../../../common"; export default function favoriteTestCallbackTest(abilityContext) { - describe('favoriteTestCallbackTest', function () { + describe("favoriteTestCallbackTest", function () { var media = mediaLibrary.getMediaLibrary(abilityContext); beforeAll(async function () { - console.info('beforeAll case'); - await getPermission(); - await checkPresetsAssets(media, 'ActsMediaLibraryFavoriteTest'); + console.info("beforeAll case"); + await getPermission(null, abilityContext); + await checkPresetsAssets(media, "ActsMediaLibraryFavoriteTest"); }); beforeEach(function () { - console.info('beforeEach case'); + console.info("beforeEach case"); }); afterEach(async function () { - console.info('afterEach case'); - await sleep() + console.info("afterEach case"); + await sleep(); }); afterAll(function () { - console.info('afterAll case'); + console.info("afterAll case"); }); const favoriteDefaultState = async function (done, testNum, fetchOp) { @@ -61,14 +61,14 @@ export default function favoriteTestCallbackTest(abilityContext) { } expect(isFavorite).assertEqual(false); await fetchFileResult.close(); - done() + done(); }); } catch (error) { - console.info(`${testNum} failed error: ${error}`) + console.info(`${testNum} failed error: ${error}`); expect(false).assertTrue(); done(); } - } + }; const favoriteByTrue = async function (done, testNum, fetchOp) { try { const fetchFileResult = await media.getFileAssets(fetchOp); @@ -76,8 +76,8 @@ export default function favoriteTestCallbackTest(abilityContext) { if (!checkAssetCountPass) return; const asset = await fetchFileResult.getFirstObject(); asset.favorite(true, async (err) => { - if(err) { - console.info(`${testNum} failed err: ${err}`) + if (err) { + console.info(`${testNum} failed err: ${err}`); expect(false).assertTrue(); done(); return; @@ -87,13 +87,12 @@ export default function favoriteTestCallbackTest(abilityContext) { await fetchFileResult.close(); done(); }); - } catch (error) { - console.info(`${testNum} failed error: ${error}`) + console.info(`${testNum} failed error: ${error}`); expect(false).assertTrue(); done(); } - } + }; const favoriteByFalse = async function (done, testNum, fetchOp) { try { const fetchFileResult = await media.getFileAssets(fetchOp); @@ -102,8 +101,8 @@ export default function favoriteTestCallbackTest(abilityContext) { const asset = await fetchFileResult.getFirstObject(); await asset.favorite(true); asset.favorite(false, async (err) => { - if(err) { - console.info(`${testNum} failed err: ${err}`) + if (err) { + console.info(`${testNum} failed err: ${err}`); expect(false).assertTrue(); done(); return; @@ -114,11 +113,11 @@ export default function favoriteTestCallbackTest(abilityContext) { done(); }); } catch (error) { - console.info(`${testNum} failed error: ${error}`) + console.info(`${testNum} failed error: ${error}`); expect(false).assertTrue(); done(); } - } + }; /** * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_001_01 @@ -128,10 +127,10 @@ export default function favoriteTestCallbackTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_001_01', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_001_01' - let currentFetchOp = nameFetchOps(testNum, 'Pictures/StaticCb/', '01.jpg', IMAGE_TYPE) - await favoriteDefaultState(done, testNum, currentFetchOp) + it("SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_001_01", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_001_01"; + let currentFetchOp = nameFetchOps(testNum, "Pictures/StaticCb/", "01.jpg", IMAGE_TYPE); + await favoriteDefaultState(done, testNum, currentFetchOp); }); /** @@ -142,10 +141,10 @@ export default function favoriteTestCallbackTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_001_02', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_001_02' - let currentFetchOp = nameFetchOps(testNum, 'Pictures/StaticCb/', '02.jpg', IMAGE_TYPE) - await favoriteByTrue(done, testNum, currentFetchOp) + it("SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_001_02", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_001_02"; + let currentFetchOp = nameFetchOps(testNum, "Pictures/StaticCb/", "02.jpg", IMAGE_TYPE); + await favoriteByTrue(done, testNum, currentFetchOp); }); /** @@ -156,10 +155,10 @@ export default function favoriteTestCallbackTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_001_03', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_001_03' - let currentFetchOp = nameFetchOps(testNum, 'Pictures/StaticCb/', '03.jpg', IMAGE_TYPE) - await favoriteByFalse(done, testNum, currentFetchOp) + it("SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_001_03", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_001_03"; + let currentFetchOp = nameFetchOps(testNum, "Pictures/StaticCb/", "03.jpg", IMAGE_TYPE); + await favoriteByFalse(done, testNum, currentFetchOp); }); /** @@ -170,10 +169,10 @@ export default function favoriteTestCallbackTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_002_01', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_002_01' - let currentFetchOp = nameFetchOps(testNum, 'Videos/StaticCb/', '01.mp4', VIDEO_TYPE) - await favoriteDefaultState(done, testNum, currentFetchOp) + it("SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_002_01", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_002_01"; + let currentFetchOp = nameFetchOps(testNum, "Videos/StaticCb/", "01.mp4", VIDEO_TYPE); + await favoriteDefaultState(done, testNum, currentFetchOp); }); /** @@ -184,10 +183,10 @@ export default function favoriteTestCallbackTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_002_02', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_002_02' - let currentFetchOp = nameFetchOps(testNum, 'Videos/StaticCb/', '02.mp4', VIDEO_TYPE) - await favoriteByTrue(done, testNum, currentFetchOp) + it("SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_002_02", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_002_02"; + let currentFetchOp = nameFetchOps(testNum, "Videos/StaticCb/", "02.mp4", VIDEO_TYPE); + await favoriteByTrue(done, testNum, currentFetchOp); }); /** @@ -198,10 +197,10 @@ export default function favoriteTestCallbackTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_002_03', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_002_03' - let currentFetchOp = nameFetchOps(testNum, 'Videos/StaticCb/', '03.mp4', VIDEO_TYPE) - await favoriteByFalse(done, testNum, currentFetchOp) + it("SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_002_03", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_002_03"; + let currentFetchOp = nameFetchOps(testNum, "Videos/StaticCb/", "03.mp4", VIDEO_TYPE); + await favoriteByFalse(done, testNum, currentFetchOp); }); /** @@ -212,10 +211,10 @@ export default function favoriteTestCallbackTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_003_01', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_003_01' - let currentFetchOp = nameFetchOps(testNum, 'Audios/StaticCb/', '01.mp3', AUDIO_TYPE) - await favoriteDefaultState(done, testNum, currentFetchOp) + it("SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_003_01", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_003_01"; + let currentFetchOp = nameFetchOps(testNum, "Audios/StaticCb/", "01.mp3", AUDIO_TYPE); + await favoriteDefaultState(done, testNum, currentFetchOp); }); /** @@ -226,10 +225,10 @@ export default function favoriteTestCallbackTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_003_02', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_003_02' - let currentFetchOp = nameFetchOps(testNum, 'Audios/StaticCb/', '02.mp3', AUDIO_TYPE) - await favoriteByTrue(done, testNum, currentFetchOp) + it("SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_003_02", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_003_02"; + let currentFetchOp = nameFetchOps(testNum, "Audios/StaticCb/", "02.mp3", AUDIO_TYPE); + await favoriteByTrue(done, testNum, currentFetchOp); }); /** @@ -240,10 +239,10 @@ export default function favoriteTestCallbackTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_003_03', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_003_03' - let currentFetchOp = nameFetchOps(testNum, 'Audios/StaticCb/', '03.mp3', AUDIO_TYPE) - await favoriteByFalse(done, testNum, currentFetchOp) + it("SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_003_03", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_003_03"; + let currentFetchOp = nameFetchOps(testNum, "Audios/StaticCb/", "03.mp3", AUDIO_TYPE); + await favoriteByFalse(done, testNum, currentFetchOp); }); /** @@ -254,10 +253,10 @@ export default function favoriteTestCallbackTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_004_01', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_004_01' - let currentFetchOp = nameFetchOps(testNum, 'Documents/StaticCb/', '01.dat', FILE_TYPE) - await favoriteDefaultState(done, testNum, currentFetchOp) + it("SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_004_01", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_004_01"; + let currentFetchOp = nameFetchOps(testNum, "Documents/StaticCb/", "01.dat", FILE_TYPE); + await favoriteDefaultState(done, testNum, currentFetchOp); }); /** @@ -268,10 +267,10 @@ export default function favoriteTestCallbackTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_004_02', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_004_02' - let currentFetchOp = nameFetchOps(testNum, 'Documents/StaticCb/', '02.dat', FILE_TYPE) - await favoriteByTrue(done, testNum, currentFetchOp) + it("SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_004_02", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_004_02"; + let currentFetchOp = nameFetchOps(testNum, "Documents/StaticCb/", "02.dat", FILE_TYPE); + await favoriteByTrue(done, testNum, currentFetchOp); }); /** @@ -282,10 +281,10 @@ export default function favoriteTestCallbackTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_004_03', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_004_03' - let currentFetchOp = nameFetchOps(testNum, 'Documents/StaticCb/', '03.dat', FILE_TYPE) - await favoriteByFalse(done, testNum, currentFetchOp) + it("SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_004_03", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_004_03"; + let currentFetchOp = nameFetchOps(testNum, "Documents/StaticCb/", "03.dat", FILE_TYPE); + await favoriteByFalse(done, testNum, currentFetchOp); }); }); } diff --git a/multimedia/medialibrary/mediaLibrary_favorite/entry/src/main/ets/test/favoriteTestPromise.test.ets b/multimedia/medialibrary/mediaLibrary_favorite/entry/src/main/ets/test/favoriteTestPromise.test.ets old mode 100755 new mode 100644 index b092384c62de5643c50d9d2b8164b6286d903782..412bf148277bbc7e503cd95501ea926652322f79 --- a/multimedia/medialibrary/mediaLibrary_favorite/entry/src/main/ets/test/favoriteTestPromise.test.ets +++ b/multimedia/medialibrary/mediaLibrary_favorite/entry/src/main/ets/test/favoriteTestPromise.test.ets @@ -13,8 +13,8 @@ * limitations under the License. */ -import mediaLibrary from '@ohos.multimedia.mediaLibrary'; -import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'; +import mediaLibrary from "@ohos.multimedia.mediaLibrary"; +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "deccjsunit/index"; import { sleep, IMAGE_TYPE, @@ -23,23 +23,23 @@ import { FILE_TYPE, nameFetchOps, checkAssetsCount, -} from '../../../../../../common'; +} from "../../../../../../common"; export default function favoriteTestPromiseTest(abilityContext) { - describe('favoriteTestPromiseTest', function () { + describe("favoriteTestPromiseTest", function () { var media = mediaLibrary.getMediaLibrary(abilityContext); beforeAll(async function () { - console.info('beforeAll case'); + console.info("beforeAll case"); }); beforeEach(function () { - console.info('beforeEach case'); + console.info("beforeEach case"); }); afterEach(async function () { - console.info('afterEach case'); - await sleep() + console.info("afterEach case"); + await sleep(); }); afterAll(function () { - console.info('afterAll case'); + console.info("afterAll case"); }); const favoriteDefaultState = async function (done, testNum, fetchOp) { @@ -51,13 +51,13 @@ export default function favoriteTestPromiseTest(abilityContext) { let isFavorite = await asset.isFavorite(); expect(isFavorite).assertEqual(false); await fetchFileResult.close(); - done() + done(); } catch (error) { - console.info(`${testNum} failed error: ${error}`) + console.info(`${testNum} failed error: ${error}`); expect(false).assertTrue(); done(); } - } + }; const favoriteByTrue = async function (done, testNum, fetchOp) { try { const fetchFileResult = await media.getFileAssets(fetchOp); @@ -70,11 +70,11 @@ export default function favoriteTestPromiseTest(abilityContext) { await fetchFileResult.close(); done(); } catch (error) { - console.info(`${testNum} failed error: ${error}`) + console.info(`${testNum} failed error: ${error}`); expect(false).assertTrue(); done(); } - } + }; const favoriteByFalse = async function (done, testNum, fetchOp) { try { const fetchFileResult = await media.getFileAssets(fetchOp); @@ -88,11 +88,11 @@ export default function favoriteTestPromiseTest(abilityContext) { await fetchFileResult.close(); done(); } catch (error) { - console.info(`${testNum} failed error: ${error}`) + console.info(`${testNum} failed error: ${error}`); expect(false).assertTrue(); done(); } - } + }; /** * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_001_01 @@ -102,10 +102,10 @@ export default function favoriteTestPromiseTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_001_01', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_001_01' - let currentFetchOp = nameFetchOps(testNum, 'Pictures/StaticPro/', '01.jpg', IMAGE_TYPE) - await favoriteDefaultState(done, testNum, currentFetchOp) + it("SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_001_01", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_001_01"; + let currentFetchOp = nameFetchOps(testNum, "Pictures/StaticPro/", "01.jpg", IMAGE_TYPE); + await favoriteDefaultState(done, testNum, currentFetchOp); }); /** @@ -116,10 +116,10 @@ export default function favoriteTestPromiseTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_001_02', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_001_02' - let currentFetchOp = nameFetchOps(testNum, 'Pictures/StaticPro/', '02.jpg', IMAGE_TYPE) - await favoriteByTrue(done, testNum, currentFetchOp) + it("SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_001_02", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_001_02"; + let currentFetchOp = nameFetchOps(testNum, "Pictures/StaticPro/", "02.jpg", IMAGE_TYPE); + await favoriteByTrue(done, testNum, currentFetchOp); }); /** @@ -130,10 +130,10 @@ export default function favoriteTestPromiseTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_001_03', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_001_03' - let currentFetchOp = nameFetchOps(testNum, 'Pictures/StaticPro/', '03.jpg', IMAGE_TYPE) - await favoriteByFalse(done, testNum, currentFetchOp) + it("SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_001_03", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_001_03"; + let currentFetchOp = nameFetchOps(testNum, "Pictures/StaticPro/", "03.jpg", IMAGE_TYPE); + await favoriteByFalse(done, testNum, currentFetchOp); }); /** @@ -144,10 +144,10 @@ export default function favoriteTestPromiseTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_002_01', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_002_01' - let currentFetchOp = nameFetchOps(testNum, 'Videos/StaticPro/', '01.mp4', VIDEO_TYPE) - await favoriteDefaultState(done, testNum, currentFetchOp) + it("SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_002_01", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_002_01"; + let currentFetchOp = nameFetchOps(testNum, "Videos/StaticPro/", "01.mp4", VIDEO_TYPE); + await favoriteDefaultState(done, testNum, currentFetchOp); }); /** @@ -158,10 +158,10 @@ export default function favoriteTestPromiseTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_002_02', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_002_02' - let currentFetchOp = nameFetchOps(testNum, 'Videos/StaticPro/', '02.mp4', VIDEO_TYPE) - await favoriteByTrue(done, testNum, currentFetchOp) + it("SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_002_02", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_002_02"; + let currentFetchOp = nameFetchOps(testNum, "Videos/StaticPro/", "02.mp4", VIDEO_TYPE); + await favoriteByTrue(done, testNum, currentFetchOp); }); /** @@ -172,10 +172,10 @@ export default function favoriteTestPromiseTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_002_03', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_002_03' - let currentFetchOp = nameFetchOps(testNum, 'Videos/StaticPro/', '03.mp4', VIDEO_TYPE) - await favoriteByFalse(done, testNum, currentFetchOp) + it("SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_002_03", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_002_03"; + let currentFetchOp = nameFetchOps(testNum, "Videos/StaticPro/", "03.mp4", VIDEO_TYPE); + await favoriteByFalse(done, testNum, currentFetchOp); }); /** @@ -186,10 +186,10 @@ export default function favoriteTestPromiseTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_003_01', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_003_01' - let currentFetchOp = nameFetchOps(testNum, 'Audios/StaticPro/', '01.mp3', AUDIO_TYPE) - await favoriteDefaultState(done, testNum, currentFetchOp) + it("SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_003_01", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_003_01"; + let currentFetchOp = nameFetchOps(testNum, "Audios/StaticPro/", "01.mp3", AUDIO_TYPE); + await favoriteDefaultState(done, testNum, currentFetchOp); }); /** @@ -200,10 +200,10 @@ export default function favoriteTestPromiseTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_003_02', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_003_02' - let currentFetchOp = nameFetchOps(testNum, 'Audios/StaticPro/', '02.mp3', AUDIO_TYPE) - await favoriteByTrue(done, testNum, currentFetchOp) + it("SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_003_02", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_003_02"; + let currentFetchOp = nameFetchOps(testNum, "Audios/StaticPro/", "02.mp3", AUDIO_TYPE); + await favoriteByTrue(done, testNum, currentFetchOp); }); /** @@ -214,10 +214,10 @@ export default function favoriteTestPromiseTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_003_03', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_003_03' - let currentFetchOp = nameFetchOps(testNum, 'Audios/StaticPro/', '03.mp3', AUDIO_TYPE) - await favoriteByFalse(done, testNum, currentFetchOp) + it("SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_003_03", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_003_03"; + let currentFetchOp = nameFetchOps(testNum, "Audios/StaticPro/", "03.mp3", AUDIO_TYPE); + await favoriteByFalse(done, testNum, currentFetchOp); }); /** @@ -228,10 +228,10 @@ export default function favoriteTestPromiseTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_004_01', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_004_01' - let currentFetchOp = nameFetchOps(testNum, 'Documents/StaticPro/', '01.dat', FILE_TYPE) - await favoriteDefaultState(done, testNum, currentFetchOp) + it("SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_004_01", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_004_01"; + let currentFetchOp = nameFetchOps(testNum, "Documents/StaticPro/", "01.dat", FILE_TYPE); + await favoriteDefaultState(done, testNum, currentFetchOp); }); /** @@ -242,10 +242,10 @@ export default function favoriteTestPromiseTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_004_02', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_004_02' - let currentFetchOp = nameFetchOps(testNum, 'Documents/StaticPro/', '02.dat', FILE_TYPE) - await favoriteByTrue(done, testNum, currentFetchOp) + it("SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_004_02", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_004_02"; + let currentFetchOp = nameFetchOps(testNum, "Documents/StaticPro/", "02.dat", FILE_TYPE); + await favoriteByTrue(done, testNum, currentFetchOp); }); /** @@ -256,10 +256,10 @@ export default function favoriteTestPromiseTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_004_03', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_004_03' - let currentFetchOp = nameFetchOps(testNum, 'Documents/StaticPro/', '03.dat', FILE_TYPE) - await favoriteByFalse(done, testNum, currentFetchOp) + it("SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_004_03", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_004_03"; + let currentFetchOp = nameFetchOps(testNum, "Documents/StaticPro/", "03.dat", FILE_TYPE); + await favoriteByFalse(done, testNum, currentFetchOp); }); }); } diff --git a/multimedia/medialibrary/mediaLibrary_favorite/entry/src/main/module.json b/multimedia/medialibrary/mediaLibrary_favorite/entry/src/main/module.json old mode 100755 new mode 100644 index a1aa0cada29076a34f21189f99ad1f86dee4944a..025062ffed12b44b32db7f5f35356c9040ed9c5c --- a/multimedia/medialibrary/mediaLibrary_favorite/entry/src/main/module.json +++ b/multimedia/medialibrary/mediaLibrary_favorite/entry/src/main/module.json @@ -1,69 +1,69 @@ -{ - "module": { - "name": "phone", - "type": "entry", - "srcEntrance": "./ets/Application/AbilityStage.ts", - "description": "$string:mainability_description", - "mainElement": "MainAbility", - "deviceTypes": [ - "tablet", - "default", - "phone" - ], - "deliveryWithInstall": true, - "installationFree": false, - "uiSyntax": "ets", - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "ohos.acts.multimedia.mediaLibrary.MainAbility", - "srcEntrance": "./ets/MainAbility/MainAbility.ts", - "description": "$string:mainability_description", - "icon": "$media:icon", - "label": "$string:entry_MainAbility", - "visible": true, - "orientation": "portrait", - "skills": [ - { - "actions": [ - "action.system.home" - ], - "entities":[ - "entity.system.home" - ] - } - ] - } - ], - "requestPermissions": [ - { - "name": "ohos.permission.GET_BUNDLE_INFO", - "reason": "use ohos.permission.GET_BUNDLE_INFO" - }, - { - "name": "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED", - "reason":"use ohos.permission.GET_BUNDLE_INFO_PRIVILEGED" - }, - { - "name" : "ohos.permission.GRANT_SENSITIVE_PERMISSIONS", - "reason" : "use ohos.permission.GRANT_SENSITIVE_PERMISSIONS" - }, - { - "name" : "ohos.permission.REVOKE_SENSITIVE_PERMISSIONS", - "reason" : "use ohos.permission.REVOKE_SENSITIVE_PERMISSIONS" - }, - { - "name": "ohos.permission.MEDIA_LOCATION", - "reason":"use ohos.permission.MEDIA_LOCATION" - }, - { - "name": "ohos.permission.READ_MEDIA", - "reason":"use ohos.permission.READ_MEDIA" - }, - { - "name": "ohos.permission.WRITE_MEDIA", - "reason":"use ohos.permission.WRITE_MEDIA" - } - ] - } -} +{ + "module": { + "name": "phone", + "type": "entry", + "srcEntrance": "./ets/Application/AbilityStage.ts", + "description": "$string:phone_entry_dsc", + "mainElement": "MainAbility", + "deviceTypes": [ + "tablet", + "default", + "phone" + ], + "deliveryWithInstall": true, + "installationFree": false, + "uiSyntax": "ets", + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "com.example.myapplication.MainAbility", + "srcEntrance": "./ets/MainAbility/MainAbility.ts", + "description": "$string:phone_entry_main", + "icon": "$media:icon", + "label": "$string:entry_label", + "visible": true, + "orientation": "portrait", + "skills": [ + { + "actions": [ + "action.system.home" + ], + "entities": [ + "entity.system.home" + ] + } + ] + } + ], + "requestPermissions": [ + { + "name": "ohos.permission.GET_BUNDLE_INFO", + "reason": "use ohos.permission.GET_BUNDLE_INFO" + }, + { + "name": "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED", + "reason": "use ohos.permission.GET_BUNDLE_INFO_PRIVILEGED" + }, + { + "name": "ohos.permission.GRANT_SENSITIVE_PERMISSIONS", + "reason": "use ohos.permission.GRANT_SENSITIVE_PERMISSIONS" + }, + { + "name": "ohos.permission.REVOKE_SENSITIVE_PERMISSIONS", + "reason": "use ohos.permission.REVOKE_SENSITIVE_PERMISSIONS" + }, + { + "name": "ohos.permission.MEDIA_LOCATION", + "reason": "use ohos.permission.MEDIA_LOCATION" + }, + { + "name": "ohos.permission.READ_MEDIA", + "reason": "use ohos.permission.READ_MEDIA" + }, + { + "name": "ohos.permission.WRITE_MEDIA", + "reason": "use ohos.permission.WRITE_MEDIA" + } + ] + } +} \ No newline at end of file diff --git a/multimedia/medialibrary/mediaLibrary_favorite/entry/src/main/resources/base/element/string.json b/multimedia/medialibrary/mediaLibrary_favorite/entry/src/main/resources/base/element/string.json old mode 100755 new mode 100644 index 32237ee203edf64926964fb238fa44e396ddf577..2ae43f018e75d1140cf2c0c85a6a14fc369a0c50 --- a/multimedia/medialibrary/mediaLibrary_favorite/entry/src/main/resources/base/element/string.json +++ b/multimedia/medialibrary/mediaLibrary_favorite/entry/src/main/resources/base/element/string.json @@ -1,12 +1,32 @@ -{ - "string": [ - { - "name": "entry_MainAbility", - "value": "MediaLibraryJSTestMain" - }, - { - "name": "mainability_description", - "value": "MediaLibraryJSTestMain Ability" - } - ] - } \ No newline at end of file +{ + "string": [ + { + "name": "phone_entry_dsc", + "value": "i am an entry for phone" + }, + { + "name": "phone_entry_main", + "value": "the phone entry ability" + }, + { + "name": "entry_label", + "value": "ActsMediaLibraryTest" + }, + { + "name": "form_description", + "value": "mediaLibrary" + }, + { + "name": "serviceability_description", + "value": "mediaLibrary" + }, + { + "name": "description_application", + "value": "mediaLibrary test" + }, + { + "name": "app_name", + "value": "ActsMediaLibraryTest" + } + ] +} \ No newline at end of file diff --git a/multimedia/medialibrary/mediaLibrary_favorite/entry/src/main/resources/base/profile/main_pages.json b/multimedia/medialibrary/mediaLibrary_favorite/entry/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 index 96b478210df9884592229ae2db6f6bb7f86c14f4..ceb075cd80946aade673d707aac904fb8998bce9 --- a/multimedia/medialibrary/mediaLibrary_favorite/entry/src/main/resources/base/profile/main_pages.json +++ b/multimedia/medialibrary/mediaLibrary_favorite/entry/src/main/resources/base/profile/main_pages.json @@ -1,6 +1,5 @@ -{ - "src": [ - "pages/index/index", - "pages/second/second" - ] +{ + "src": [ + "MainAbility/pages/index/index" + ] } \ No newline at end of file diff --git a/multimedia/medialibrary/mediaLibrary_favorite/signature/openharmony_sx.p7b b/multimedia/medialibrary/mediaLibrary_favorite/signature/openharmony_sx.p7b old mode 100755 new mode 100644 index 3eb5b5db82a014ff4c9483872cad743ad49a9b6e..64b33bf079b2ab68a3f26f240d127186546b33d9 Binary files a/multimedia/medialibrary/mediaLibrary_favorite/signature/openharmony_sx.p7b and b/multimedia/medialibrary/mediaLibrary_favorite/signature/openharmony_sx.p7b differ diff --git a/multimedia/medialibrary/mediaLibrary_file/AppScope/app.json b/multimedia/medialibrary/mediaLibrary_file/AppScope/app.json old mode 100755 new mode 100644 index 841282ae47b98590bdbc8aea744fbbcd178e9195..803955ad0d2a5b4ce4e103816a6a917b4701286b --- a/multimedia/medialibrary/mediaLibrary_file/AppScope/app.json +++ b/multimedia/medialibrary/mediaLibrary_file/AppScope/app.json @@ -1,21 +1,21 @@ -{ - "app":{ - "bundleName":"ohos.acts.multimedia.mediaLibrary", - "vendor":"huawei", - "versionCode":1000000, - "versionName":"1.0.0", - "debug":false, - "icon":"$media:icon", - "label":"$string:entry_MainAbility", - "description":"$string:mainability_description", - "distributedNotificationEnabled":true, - "keepAlive":true, - "singleUser":true, - "minAPIVersion":8, - "targetAPIVersion":8, - "car":{ - "apiCompatibleVersion":8, - "singleUser":false - } - } -} +{ + "app": { + "bundleName": "ohos.acts.multimedia.mediaLibrary", + "vendor": "huawei", + "versionCode": 1000000, + "versionName": "1.0.0", + "debug": false, + "icon": "$media:icon", + "label": "$string:app_name", + "description": "$string:description_application", + "distributedNotificationEnabled": true, + "keepAlive": true, + "singleUser": true, + "minAPIVersion": 9, + "targetAPIVersion": 9, + "car": { + "apiCompatibleVersion": 9, + "singleUser": false + } + } +} \ No newline at end of file diff --git a/multimedia/medialibrary/mediaLibrary_file/AppScope/resources/base/element/string.json b/multimedia/medialibrary/mediaLibrary_file/AppScope/resources/base/element/string.json old mode 100755 new mode 100644 index 9b9d5b5e10c7ce74908c32b43d24568367b46d97..ee69f9a861d9dc269ed6638735d52674583498e1 --- a/multimedia/medialibrary/mediaLibrary_file/AppScope/resources/base/element/string.json +++ b/multimedia/medialibrary/mediaLibrary_file/AppScope/resources/base/element/string.json @@ -1,12 +1,8 @@ -{ - "string": [ - { - "name": "entry_MainAbility", - "value": "MediaLibraryJSTestMain" - }, - { - "name": "mainability_description", - "value": "MediaLibraryJSTestMain Ability" - } - ] -} \ No newline at end of file +{ + "string":[ + { + "name":"app_name", + "value":"ohosProject" + } + ] +} \ No newline at end of file diff --git a/multimedia/medialibrary/mediaLibrary_file/BUILD.gn b/multimedia/medialibrary/mediaLibrary_file/BUILD.gn old mode 100755 new mode 100644 index da81808d429b23fe1b31ffbb3c48475b145b3db8..b03276f2f841ca29a805191a67e72a5764d3cb35 --- a/multimedia/medialibrary/mediaLibrary_file/BUILD.gn +++ b/multimedia/medialibrary/mediaLibrary_file/BUILD.gn @@ -15,6 +15,7 @@ import("//test/xts/tools/build/suite.gni") ohos_js_hap_suite("mediaLibrary_file_hap") { hap_profile = "entry/src/main/module.json" + js_build_mode = "debug" deps = [ ":mediaLibrary_js_assets", ":mediaLibrary_resources", diff --git a/multimedia/medialibrary/mediaLibrary_file/Test.json b/multimedia/medialibrary/mediaLibrary_file/Test.json old mode 100755 new mode 100644 index 9b655e5e0a5bc2fd03193c428d23cd3c8b926e38..12589702ab8716ce73d0b5d6debdea40b075afea --- a/multimedia/medialibrary/mediaLibrary_file/Test.json +++ b/multimedia/medialibrary/mediaLibrary_file/Test.json @@ -1,66 +1,72 @@ -{ - "description": "Configuration for mediaLibrary Tests", - "driver": { - "type": "JSUnitTest", - "test-timeout": "300000", - "package": "ohos.acts.multimedia.mediaLibrary", - "shell-timeout": "600000" - }, - "kits": [ - { - "type": "ShellKit", - "pre-push": [], - "run-command": [ - "rm -rf /storage/media/100/local/files/*", - "rm -rf /data/app/el2/100/database/com.ohos.medialibrary.medialibrarydata/*", - "mkdir -pv /storage/media/100/local/files/{Pictures,Videos,Audios,Documents}", - "mkdir -p /storage/media/100/local/temp" - ] - }, - { - "type": "PushKit", - "pre-push": [], - "push": [ - "./resource/medialibrary/01.jpg ->/storage/media/100/local/temp", - "./resource/medialibrary/01.mp3 ->/storage/media/100/local/temp", - "./resource/medialibrary/01.mp4 ->/storage/media/100/local/temp", - "./resource/medialibrary/01.dat ->/storage/media/100/local/temp" - ] - }, - { - "type": "ShellKit", - "run-command": [ - "mkdir -pv /storage/media/100/local/files/Pictures/{Static,Dynamic}", - "mkdir -pv /storage/media/100/local/files/Videos/{Static,Dynamic}", - "mkdir -pv /storage/media/100/local/files/Audios/{Static,Dynamic}", - "mkdir -pv /storage/media/100/local/files/Documents/{Static,Dynamic}", - "for d in Static; do for i in $$(seq 6); 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 6); 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 6); 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 6); do cp /storage/media/100/local/temp/01.dat /storage/media/100/local/files/Documents/$$d/0$$i.dat; done;done;", - "cp /storage/media/100/local/temp/01.jpg /storage/media/100/local/files/Pictures/Dynamic/01.jpg", - "cp /storage/media/100/local/temp/01.mp4 /storage/media/100/local/files/Videos/Dynamic/01.mp4", - "cp /storage/media/100/local/temp/01.mp3 /storage/media/100/local/files/Audios/Dynamic/01.mp3", - "cp /storage/media/100/local/temp/01.dat /storage/media/100/local/files/Documents/Dynamic/01.dat", - "chmod -R 777 /storage/media/100/local/files/*", - "chmod -R 777 /data/service/el2/100/hmdfs/account/files/*", - "hilog -Q pidoff", - "hilog -p off", - "hilog -b I", - "hilog -b D -D 0xD002B70", - "scanner", - "sleep 10" - ], - "teardown-command":[ - "hilog -b X -D 0xD002B70" - ] - }, - { - "test-file-name": [ - "ActsMediaLibraryFileTest.hap" - ], - "type": "AppInstallKit", - "cleanup-apps": true - } - ] +{ + "description": "Configuration for mediaLibrary Tests", + "driver": { + "type": "OHJSUnitTest", + "test-timeout": "180000", + "bundle-name": "ohos.acts.multimedia.mediaLibrary", + "module-name": "phone", + "shell-timeout": "600000", + "testcase-timeout": 70000 + }, + "kits": [ + { + "type": "ShellKit", + "pre-push": [], + "run-command": [ + "rm -rf /storage/media/100/local/files/*", + "rm -rf /data/app/el2/100/database/com.ohos.medialibrary.medialibrarydata/*", + "mkdir -pv /storage/media/100/local/files/{Pictures,Videos,Audios,Documents}", + "mkdir -p /storage/media/100/local/temp", + "power-shell wakeup", + "uinput -T -d 300 600 -m 300 600 300 100 -u 300 100", + "power-shell setmode 602" + ] + }, + { + "type": "PushKit", + "pre-push": [], + "push": [ + "./resource/medialibrary/01.jpg ->/storage/media/100/local/temp", + "./resource/medialibrary/01.mp3 ->/storage/media/100/local/temp", + "./resource/medialibrary/01.mp4 ->/storage/media/100/local/temp", + "./resource/medialibrary/01.dat ->/storage/media/100/local/temp" + ] + }, + { + "type": "ShellKit", + "run-command": [ + "mkdir -pv /storage/media/100/local/files/Pictures/{Static,Dynamic}", + "mkdir -pv /storage/media/100/local/files/Videos/{Static,Dynamic}", + "mkdir -pv /storage/media/100/local/files/Audios/{Static,Dynamic}", + "mkdir -pv /storage/media/100/local/files/Documents/{Static,Dynamic}", + "for d in Static; do for i in $$(seq 6); 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 6); 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 6); 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 6); do cp /storage/media/100/local/temp/01.dat /storage/media/100/local/files/Documents/$$d/0$$i.dat; done;done;", + "cp /storage/media/100/local/temp/01.jpg /storage/media/100/local/files/Pictures/Dynamic/01.jpg", + "cp /storage/media/100/local/temp/01.mp4 /storage/media/100/local/files/Videos/Dynamic/01.mp4", + "cp /storage/media/100/local/temp/01.mp3 /storage/media/100/local/files/Audios/Dynamic/01.mp3", + "cp /storage/media/100/local/temp/01.dat /storage/media/100/local/files/Documents/Dynamic/01.dat", + "chmod -R 777 /storage/media/100/local/files/*", + "chmod -R 777 /data/service/el2/100/hmdfs/account/files/*", + "hilog -Q pidoff", + "hilog -p off", + "hilog -b I", + "hilog -b D -D 0xD002B70", + "scanner", + "sleep 10" + ], + "teardown-command": [ + "hilog -b X -D 0xD002B70", + "power-shell setmode 600" + ] + }, + { + "test-file-name": [ + "ActsMediaLibraryFileTest.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + } + ] } \ No newline at end of file diff --git a/multimedia/medialibrary/mediaLibrary_file/entry/src/main/ets/Application/AbilityStage.ts b/multimedia/medialibrary/mediaLibrary_file/entry/src/main/ets/Application/AbilityStage.ts old mode 100755 new mode 100644 index 14f230e140160dc5f94ecc462304621178f4cf64..b0e0206ea9fb5ce94ef140d69510b6280969dd8e --- a/multimedia/medialibrary/mediaLibrary_file/entry/src/main/ets/Application/AbilityStage.ts +++ b/multimedia/medialibrary/mediaLibrary_file/entry/src/main/ets/Application/AbilityStage.ts @@ -1,9 +1,9 @@ -import AbilityStage from "@ohos.application.AbilityStage" - -export default class MyAbilityStage extends AbilityStage { - onCreate() { - console.log("[Demo] MyAbilityStage onCreate") - globalThis.stageOnCreateRun = 1; - globalThis.stageContext = this.context; - } -} +import AbilityStage from "@ohos.app.ability.AbilityStage" + +export default class MyAbilityStage extends AbilityStage { + onCreate() { + console.log("[Demo] MyAbilityStage onCreate") + globalThis.stageOnCreateRun = 1; + globalThis.stageContext = this.context; + } +} diff --git a/multimedia/medialibrary/mediaLibrary_file/entry/src/main/ets/MainAbility/MainAbility.ts b/multimedia/medialibrary/mediaLibrary_file/entry/src/main/ets/MainAbility/MainAbility.ts old mode 100755 new mode 100644 index 72b03d747b3e2e8bdf18ea37c54c789bebb767bb..df41851318f3385890e235a96dfbcc0441cb13f1 --- a/multimedia/medialibrary/mediaLibrary_file/entry/src/main/ets/MainAbility/MainAbility.ts +++ b/multimedia/medialibrary/mediaLibrary_file/entry/src/main/ets/MainAbility/MainAbility.ts @@ -1,36 +1,36 @@ -import Ability from '@ohos.application.Ability' - -export default class MainAbility extends Ability { - onCreate(want,launchParam){ - // Ability is creating, initialize resources for this ability - console.log("[Demo] MainAbility onCreate") - globalThis.abilityWant = want; - } - - onDestroy() { - // Ability is destroying, release resources for this ability - console.log("[Demo] MainAbility onDestroy") - } - - onWindowStageCreate(windowStage) { - // Main window is created, set main page for this ability - console.log("[Demo] MainAbility onWindowStageCreate") - globalThis.abilityContext = this.context - windowStage.setUIContent(this.context, "pages/index/index", null) - } - - onWindowStageDestroy() { - //Main window is destroyed, release UI related resources - console.log("[Demo] MainAbility onWindowStageDestroy") - } - - onForeground() { - // Ability has brought to foreground - console.log("[Demo] MainAbility onForeground") - } - - onBackground() { - // Ability has back to background - console.log("[Demo] MainAbility onBackground") - } +import Ability from '@ohos.app.ability.UIAbility' + +export default class MainAbility extends Ability { + onCreate(want, launchParam) { + // Ability is creating, initialize resources for this ability + console.log("[Demo] MainAbility onCreate") + globalThis.abilityWant = want; + } + + onDestroy() { + // Ability is destroying, release resources for this ability + console.log("[Demo] MainAbility onDestroy") + } + + async onWindowStageCreate(windowStage) { + console.log("[Demo] MainAbility onWindowStageCreate windowStage=" + windowStage) + globalThis.windowStage = windowStage + globalThis.abilityContext = this.context + windowStage.setUIContent(this.context, "MainAbility/pages/index/index", null) + } + + onWindowStageDestroy() { + //Main window is destroyed, release UI related resources + console.log("[Demo] MainAbility onWindowStageDestroy") + } + + onForeground() { + // Ability has brought to foreground + console.log("[Demo] MainAbility onForeground") + } + + onBackground() { + // Ability has back to background + console.log("[Demo] MainAbility onBackground") + } }; \ No newline at end of file diff --git a/multimedia/medialibrary/mediaLibrary_file/entry/src/main/ets/MainAbility/pages/index/index.ets b/multimedia/medialibrary/mediaLibrary_file/entry/src/main/ets/MainAbility/pages/index/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..6a8c567d5a86048b1c269e4f00cc288ec136200b --- /dev/null +++ b/multimedia/medialibrary/mediaLibrary_file/entry/src/main/ets/MainAbility/pages/index/index.ets @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import router from '@ohos.router'; +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' +import { Hypium } from '@ohos/hypium' +import testsuite from '../../../test/List.test' + + +@Entry +@Component +struct Index { + + aboutToAppear(){ + console.info("start run testcase!!!!") + var abilityDelegator: any + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var abilityDelegatorArguments: any + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + console.info('start run testcase!!!') + Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) + } + + build() { + Flex({ direction:FlexDirection.Column, alignItems:ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text('Hello World') + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('next page') + .fontSize(25) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .onClick(() => { + + }) + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/multimedia/medialibrary/mediaLibrary_file/entry/src/main/ets/TestAbility/TestAbility.ts b/multimedia/medialibrary/mediaLibrary_file/entry/src/main/ets/TestAbility/TestAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..8028a70f8af44690b95a08bd177bca6b09f24687 --- /dev/null +++ b/multimedia/medialibrary/mediaLibrary_file/entry/src/main/ets/TestAbility/TestAbility.ts @@ -0,0 +1,50 @@ +/* + * 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 Ability from '@ohos.app.ability.UIAbility' + +export default class TestAbility extends Ability { + onCreate(want, launchParam) { + console.log('TestAbility onCreate') + } + + onDestroy() { + console.log('TestAbility onDestroy') + } + + onWindowStageCreate(windowStage) { + console.log('TestAbility onWindowStageCreate') + windowStage.loadContent("TestAbility/pages/index", (err, data) => { + if (err.code) { + console.error('Failed to load the content. Cause:' + JSON.stringify(err)); + return; + } + console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data)) + }); + + globalThis.abilityContext = this.context; + } + + onWindowStageDestroy() { + console.log('TestAbility onWindowStageDestroy') + } + + onForeground() { + console.log('TestAbility onForeground') + } + + onBackground() { + console.log('TestAbility onBackground') + } +}; \ No newline at end of file diff --git a/multimedia/medialibrary/mediaLibrary_file/entry/src/main/ets/TestAbility/pages/index.ets b/multimedia/medialibrary/mediaLibrary_file/entry/src/main/ets/TestAbility/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..b93567f962921124b282f78c8ef123965d1460c9 --- /dev/null +++ b/multimedia/medialibrary/mediaLibrary_file/entry/src/main/ets/TestAbility/pages/index.ets @@ -0,0 +1,48 @@ +/* + * 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 router from '@ohos.router'; + +@Entry +@Component +struct Index { + aboutToAppear() { + console.info('TestAbility index aboutToAppear') + } + @State message: string = 'Hello World' + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('next page') + .fontSize(20) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .width('35%') + .height('5%') + .onClick(()=>{ + }) + } + .width('100%') + } + .height('100%') + } + } \ No newline at end of file diff --git a/multimedia/medialibrary/mediaLibrary_file/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts b/multimedia/medialibrary/mediaLibrary_file/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts new file mode 100644 index 0000000000000000000000000000000000000000..a4ee2f1652b3d04ce83ece64ef70f8dfa62a2dc8 --- /dev/null +++ b/multimedia/medialibrary/mediaLibrary_file/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts @@ -0,0 +1,78 @@ +/* + * 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 TestRunner from '@ohos.application.testRunner' +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' + +var abilityDelegator = undefined +var abilityDelegatorArguments = undefined + +function translateParamsToString(parameters) { + const keySet = new Set([ + '-s class', '-s notClass', '-s suite', '-s it', + '-s level', '-s testType', '-s size', '-s timeout', + '-s dryRun' + ]) + let targetParams = ''; + for (const key in parameters) { + if (keySet.has(key)) { + targetParams = `${targetParams} ${key} ${parameters[key]}` + } + } + return targetParams.trim() +} + +async function onAbilityCreateCallback() { + console.log("onAbilityCreateCallback"); +} + +async function addAbilityMonitorCallback(err: any) { + console.info("addAbilityMonitorCallback : " + JSON.stringify(err)) +} + +export default class OpenHarmonyTestRunner implements TestRunner { + constructor() { + } + + onPrepare() { + console.info("OpenHarmonyTestRunner OnPrepare ") + } + + async onRun() { + console.log('OpenHarmonyTestRunner onRun run') + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var testAbilityName = abilityDelegatorArguments.bundleName + '.MainAbility' + let lMonitor = { + abilityName: testAbilityName, + onAbilityCreate: onAbilityCreateCallback, + }; + abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback) + var cmd = 'aa start -d 0 -a com.example.myapplication.MainAbility' + ' -b ' + abilityDelegatorArguments.bundleName + cmd += ' '+translateParamsToString(abilityDelegatorArguments.parameters) + var debug = abilityDelegatorArguments.parameters["-D"] + if (debug == 'true') + { + cmd += ' -D' + } + console.info('cmd : '+cmd) + abilityDelegator.executeShellCommand(cmd, + (err: any, d: any) => { + console.info('executeShellCommand : err : ' + JSON.stringify(err)); + console.info('executeShellCommand : data : ' + d.stdResult); + console.info('executeShellCommand : data : ' + d.exitCode); + }) + console.info('OpenHarmonyTestRunner onRun end') + } +}; \ No newline at end of file diff --git a/multimedia/medialibrary/mediaLibrary_file/entry/src/main/ets/pages/index/index.ets b/multimedia/medialibrary/mediaLibrary_file/entry/src/main/ets/pages/index/index.ets deleted file mode 100755 index 71bcb74b8a045a4e05dd64ed8209d3964c72a730..0000000000000000000000000000000000000000 --- a/multimedia/medialibrary/mediaLibrary_file/entry/src/main/ets/pages/index/index.ets +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import file from '@system.file'; - -import {Core, ExpectExtend, InstrumentLog, ReportExtend} from "deccjsunit/index" -import testsuite from "../../test/List.test.ets" - -@Entry -@Component -struct Index { - - aboutToAppear(){ - console.info("start run testcase!!!!") - const core = Core.getInstance() - const expectExtend = new ExpectExtend({ - 'id': 'extend' - }) - core.addService('expect', expectExtend) - const reportExtend = new ReportExtend(file) - - core.addService('report', reportExtend) - core.init() - core.subscribeEvent('task', reportExtend) - const configService = core.getDefaultService('config') - console.info('parameters---->' + JSON.stringify(globalThis.abilityWant.parameters)) - globalThis.abilityWant.parameters.timeout = 70000; - configService.setConfig(globalThis.abilityWant.parameters) - console.info('testsuite()---->') - testsuite(globalThis.abilityContext) - core.execute() - console.info('core.execute()---->') - } - - build() { - Flex({ direction:FlexDirection.Column, alignItems:ItemAlign.Center, justifyContent: FlexAlign.Center }) { - Text('Hello World') - .fontSize(50) - .fontWeight(FontWeight.Bold) - Button() { - Text('next page') - .fontSize(25) - .fontWeight(FontWeight.Bold) - }.type(ButtonType.Capsule) - .margin({ - top: 20 - }) - .backgroundColor('#0D9FFB') - .onClick(() => { - - }) - } - .width('100%') - .height('100%') - } -} \ No newline at end of file diff --git a/multimedia/medialibrary/mediaLibrary_file/entry/src/main/ets/pages/second/second.ets b/multimedia/medialibrary/mediaLibrary_file/entry/src/main/ets/pages/second/second.ets deleted file mode 100755 index 1f2a06b64cdadcc83027bb6797e24536a2c85757..0000000000000000000000000000000000000000 --- a/multimedia/medialibrary/mediaLibrary_file/entry/src/main/ets/pages/second/second.ets +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import router from '@system.router'; - -@Entry -@Component -struct Second { - private content: string = "Second Page" - - build() { - Flex({ direction: FlexDirection.Column,alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { - Text(`${this.content}`) - .fontSize(50) - .fontWeight(FontWeight.Bold) - Button() { - Text('back to index') - .fontSize(20) - .fontWeight(FontWeight.Bold) - }.type(ButtonType.Capsule) - .margin({ - top: 20 - }) - .backgroundColor('#0D9FFB') - .onClick(() => { - router.back() - }) - } - .width('100%') - .height('100%') - } -} \ No newline at end of file diff --git a/multimedia/medialibrary/mediaLibrary_file/entry/src/main/ets/test/List.test.ets b/multimedia/medialibrary/mediaLibrary_file/entry/src/main/ets/test/List.test.ets old mode 100755 new mode 100644 index 3779151842ce3376e137b16e17f1252efc89973b..706e1ed6eedea02511d8226746b8dc305fca2f87 --- a/multimedia/medialibrary/mediaLibrary_file/entry/src/main/ets/test/List.test.ets +++ b/multimedia/medialibrary/mediaLibrary_file/entry/src/main/ets/test/List.test.ets @@ -15,7 +15,7 @@ import fileTestCallback from './fileTestCallback.test.ets' import fileTestPromise from './fileTestPromise.test.ets' -export default function testsuite(abilityContext) { - fileTestCallback(abilityContext) - fileTestPromise(abilityContext) +export default function testsuite() { + fileTestCallback(globalThis.abilityContext) + fileTestPromise(globalThis.abilityContext) } diff --git a/multimedia/medialibrary/mediaLibrary_file/entry/src/main/ets/test/fileTestCallback.test.ets b/multimedia/medialibrary/mediaLibrary_file/entry/src/main/ets/test/fileTestCallback.test.ets old mode 100755 new mode 100644 index 89b25f47fc4724fd97759a27edd014b7207aa63a..793b27457cc98411b791f6e8212e772fd1167019 --- a/multimedia/medialibrary/mediaLibrary_file/entry/src/main/ets/test/fileTestCallback.test.ets +++ b/multimedia/medialibrary/mediaLibrary_file/entry/src/main/ets/test/fileTestCallback.test.ets @@ -13,10 +13,10 @@ * limitations under the License. */ -import mediaLibrary from '@ohos.multimedia.mediaLibrary'; -import fileio from '@ohos.fileio'; +import mediaLibrary from "@ohos.multimedia.mediaLibrary"; +import fileio from "@ohos.fileio"; -import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'; +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "deccjsunit/index"; import { sleep, IMAGE_TYPE, @@ -30,26 +30,25 @@ import { fetchOps, FILEKEY, isNum, -} from '../../../../../../common'; - +} from "../../../../../../common"; export default function fileTestCallbackTest(abilityContext) { - describe('fileTestCallbackTest', function () { + describe("fileTestCallbackTest", function () { const media = mediaLibrary.getMediaLibrary(abilityContext); beforeAll(async function () { - console.info('beforeAll case'); - await getPermission(); - await checkPresetsAssets(media, 'ActsMediaLibraryFileTest') + console.info("beforeAll case"); + await getPermission(null, abilityContext); + await checkPresetsAssets(media, "ActsMediaLibraryFileTest"); }); beforeEach(function () { - console.info('beforeEach case'); + console.info("beforeEach case"); }); afterEach(async function () { - console.info('afterEach case'); - await sleep(400) + console.info("afterEach case"); + await sleep(400); }); afterAll(function () { - console.info('afterAll case'); + console.info("afterAll case"); }); async function copyFile(fd1, fd2) { @@ -68,19 +67,19 @@ export default function fileTestCallbackTest(abilityContext) { media.createAsset(type, displayName1, path, async (err, creatAsset1) => { if (err) { - console.info(`${testNum} err : ${err}`) + console.info(`${testNum} err : ${err}`); expect().assertFail(); done(); return; } - const fd = await asset.open('rw'); - const creatAssetFd1 = await creatAsset1.open('rw'); + const fd = await asset.open("rw"); + const creatAssetFd1 = await creatAsset1.open("rw"); await copyFile(fd, creatAssetFd1); await creatAsset1.close(creatAssetFd1); let displayName2 = `${new Date().getTime()}.${name}`; const creatAsset2 = await media.createAsset(type, displayName2, path); - const creatAssetFd2 = await creatAsset2.open('rw'); + const creatAssetFd2 = await creatAsset2.open("rw"); await copyFile(fd, creatAssetFd2); await creatAsset2.close(creatAssetFd2); await asset.close(fd); @@ -89,11 +88,11 @@ export default function fileTestCallbackTest(abilityContext) { done(); }); } catch (error) { - console.info(`${testNum} failed error: ${error}`) + console.info(`${testNum} failed error: ${error}`); expect(false).assertTrue(); done(); } - } + }; const checkCreatAssetProps = async (done, testNum, fetchOp, path, type, name, key, val) => { try { @@ -105,28 +104,28 @@ export default function fileTestCallbackTest(abilityContext) { media.createAsset(type, displayName, path, async (err, creatAsset) => { if (err) { - console.info(`${testNum} err : ${err}`) + console.info(`${testNum} err : ${err}`); expect().assertFail(); done(); return; } - const fd = await asset.open('rw'); - const creatAssetFd = await creatAsset.open('rw'); + const fd = await asset.open("rw"); + const creatAssetFd = await creatAsset.open("rw"); await copyFile(fd, creatAssetFd); await creatAsset.close(creatAssetFd); - if (val == 'displayName') { - val = displayName + if (val == "displayName") { + val = displayName; } expect(creatAsset[key]).assertEqual(val); done(); }); } catch (error) { - console.info(`${testNum} failed error: ${error}`) + console.info(`${testNum} failed error: ${error}`); expect(false).assertTrue(); done(); } - } + }; const checkdateModified = async (done, testNum, fetchOp) => { try { @@ -137,13 +136,13 @@ export default function fileTestCallbackTest(abilityContext) { asset.title = `title_${new Date().getTime()}`; asset.commitModify(async (err) => { if (err) { - console.info(`${testNum} err : ${err}`) + console.info(`${testNum} err : ${err}`); expect().assertFail(); done(); return; } const id = asset.id; - const idOP = { selections: FILEKEY.ID + '= ?', selectionArgs: ['' + id] }; + const idOP = { selections: FILEKEY.ID + "= ?", selectionArgs: ["" + id] }; fetchFileResult = await media.getFileAssets(idOP); let newAsset = await fetchFileResult.getFirstObject(); expect(isNum(newAsset.dateModified)).assertTrue(); @@ -151,11 +150,11 @@ export default function fileTestCallbackTest(abilityContext) { done(); }); } catch (error) { - console.info(`${testNum} failed error: ${error}`) + console.info(`${testNum} failed error: ${error}`); expect(false).assertTrue(); done(); } - } + }; // ------------------------------- image type start ---------------------------- /** @@ -166,13 +165,13 @@ export default function fileTestCallbackTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_001_01', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_001_01'; - let currentFetchOp = nameFetchOps(testNum, 'Pictures/Static/', '01.jpg', IMAGE_TYPE) - let name = 'jpg' - let path = await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_IMAGE) + 'create/' + it("SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_001_01", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_001_01"; + let currentFetchOp = nameFetchOps(testNum, "Pictures/Static/", "01.jpg", IMAGE_TYPE); + let name = "jpg"; + let path = (await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_IMAGE)) + "create/"; let type = IMAGE_TYPE; - await creatAssetTest(done, testNum, currentFetchOp, path, type, name) + await creatAssetTest(done, testNum, currentFetchOp, path, type, name); }); /** @@ -183,15 +182,15 @@ export default function fileTestCallbackTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_001_02', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_001_02'; - let currentFetchOp = nameFetchOps(testNum, 'Pictures/Static/', '02.jpg', IMAGE_TYPE) - let name = 'jpg' - let path = await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_IMAGE) + 'create/'; + it("SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_001_02", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_001_02"; + let currentFetchOp = nameFetchOps(testNum, "Pictures/Static/", "02.jpg", IMAGE_TYPE); + let name = "jpg"; + let path = (await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_IMAGE)) + "create/"; let type = IMAGE_TYPE; - let key = 'displayName'; - let val = 'displayName'; - await checkCreatAssetProps(done, testNum, currentFetchOp, path, type, name, key, val) + let key = "displayName"; + let val = "displayName"; + await checkCreatAssetProps(done, testNum, currentFetchOp, path, type, name, key, val); }); /** @@ -202,15 +201,15 @@ export default function fileTestCallbackTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_001_03', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_001_03'; - let currentFetchOp = nameFetchOps(testNum, 'Pictures/Static/', '03.jpg', IMAGE_TYPE) - let name = 'jpg' - let path = await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_IMAGE) + 'create/'; + it("SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_001_03", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_001_03"; + let currentFetchOp = nameFetchOps(testNum, "Pictures/Static/", "03.jpg", IMAGE_TYPE); + let name = "jpg"; + let path = (await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_IMAGE)) + "create/"; let type = IMAGE_TYPE; - let key = 'relativePath'; + let key = "relativePath"; let val = path; - await checkCreatAssetProps(done, testNum, currentFetchOp, path, type, name, key, val) + await checkCreatAssetProps(done, testNum, currentFetchOp, path, type, name, key, val); }); /** @@ -221,10 +220,10 @@ export default function fileTestCallbackTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_001_07', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_001_07'; - let currentFetchOp = fetchOps(testNum, 'Pictures/Dynamic/', IMAGE_TYPE) - await checkdateModified(done, testNum, currentFetchOp) + it("SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_001_07", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_001_07"; + let currentFetchOp = fetchOps(testNum, "Pictures/Dynamic/", IMAGE_TYPE); + await checkdateModified(done, testNum, currentFetchOp); }); /** @@ -235,15 +234,15 @@ export default function fileTestCallbackTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_001_08', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_001_08'; - let currentFetchOp = nameFetchOps(testNum, 'Pictures/Static/', '04.jpg', IMAGE_TYPE) - let name = 'jpg' - let path = await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_IMAGE) + 'create/'; + it("SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_001_08", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_001_08"; + let currentFetchOp = nameFetchOps(testNum, "Pictures/Static/", "04.jpg", IMAGE_TYPE); + let name = "jpg"; + let path = (await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_IMAGE)) + "create/"; let type = IMAGE_TYPE; - let key = 'mediaType'; + let key = "mediaType"; let val = IMAGE_TYPE; - await checkCreatAssetProps(done, testNum, currentFetchOp, path, type, name, key, val) + await checkCreatAssetProps(done, testNum, currentFetchOp, path, type, name, key, val); }); /** @@ -254,15 +253,15 @@ export default function fileTestCallbackTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_001_11', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_001_11'; - let currentFetchOp = nameFetchOps(testNum, 'Pictures/Static/', '05.jpg', IMAGE_TYPE) - let name = 'jpg' - let path = await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_IMAGE) + 'create/'; + it("SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_001_11", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_001_11"; + let currentFetchOp = nameFetchOps(testNum, "Pictures/Static/", "05.jpg", IMAGE_TYPE); + let name = "jpg"; + let path = (await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_IMAGE)) + "create/"; let type = IMAGE_TYPE; - let key = 'orientation'; + let key = "orientation"; let val = 0; - await checkCreatAssetProps(done, testNum, currentFetchOp, path, type, name, key, val) + await checkCreatAssetProps(done, testNum, currentFetchOp, path, type, name, key, val); }); // ------------------------------- image type end ----------------------------- @@ -276,13 +275,13 @@ export default function fileTestCallbackTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_002_01', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_002_01'; - let currentFetchOp = nameFetchOps(testNum, 'Videos/Static/', '01.mp4', VIDEO_TYPE) - let name = 'mp4' - let path = await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_VIDEO) + 'create/' + it("SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_002_01", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_002_01"; + let currentFetchOp = nameFetchOps(testNum, "Videos/Static/", "01.mp4", VIDEO_TYPE); + let name = "mp4"; + let path = (await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_VIDEO)) + "create/"; let type = VIDEO_TYPE; - await creatAssetTest(done, testNum, currentFetchOp, path, type, name) + await creatAssetTest(done, testNum, currentFetchOp, path, type, name); }); /** @@ -293,15 +292,15 @@ export default function fileTestCallbackTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_002_02', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_002_02'; - let currentFetchOp = nameFetchOps(testNum, 'Videos/Static/', '02.mp4', VIDEO_TYPE) - let name = 'mp4' - let path = await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_VIDEO) + 'create/'; + it("SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_002_02", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_002_02"; + let currentFetchOp = nameFetchOps(testNum, "Videos/Static/", "02.mp4", VIDEO_TYPE); + let name = "mp4"; + let path = (await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_VIDEO)) + "create/"; let type = VIDEO_TYPE; - let key = 'displayName'; - let val = 'displayName'; - await checkCreatAssetProps(done, testNum, currentFetchOp, path, type, name, key, val) + let key = "displayName"; + let val = "displayName"; + await checkCreatAssetProps(done, testNum, currentFetchOp, path, type, name, key, val); }); /** @@ -312,15 +311,15 @@ export default function fileTestCallbackTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_002_03', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_002_03'; - let currentFetchOp = nameFetchOps(testNum, 'Videos/Static/', '03.mp4', VIDEO_TYPE) - let name = 'mp4' - let path = await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_VIDEO) + 'create/'; + it("SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_002_03", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_002_03"; + let currentFetchOp = nameFetchOps(testNum, "Videos/Static/", "03.mp4", VIDEO_TYPE); + let name = "mp4"; + let path = (await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_VIDEO)) + "create/"; let type = VIDEO_TYPE; - let key = 'relativePath'; + let key = "relativePath"; let val = path; - await checkCreatAssetProps(done, testNum, currentFetchOp, path, type, name, key, val) + await checkCreatAssetProps(done, testNum, currentFetchOp, path, type, name, key, val); }); /** @@ -331,10 +330,10 @@ export default function fileTestCallbackTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_002_07', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_002_07'; - let currentFetchOp = fetchOps(testNum, 'Videos/Dynamic/', VIDEO_TYPE) - await checkdateModified(done, testNum, currentFetchOp) + it("SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_002_07", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_002_07"; + let currentFetchOp = fetchOps(testNum, "Videos/Dynamic/", VIDEO_TYPE); + await checkdateModified(done, testNum, currentFetchOp); }); /** @@ -345,15 +344,15 @@ export default function fileTestCallbackTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_002_08', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_002_08'; - let currentFetchOp = nameFetchOps(testNum, 'Videos/Static/', '04.mp4', VIDEO_TYPE) - let name = 'mp4' - let path = await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_VIDEO) + 'create/'; + it("SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_002_08", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_002_08"; + let currentFetchOp = nameFetchOps(testNum, "Videos/Static/", "04.mp4", VIDEO_TYPE); + let name = "mp4"; + let path = (await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_VIDEO)) + "create/"; let type = VIDEO_TYPE; - let key = 'mediaType'; + let key = "mediaType"; let val = VIDEO_TYPE; - await checkCreatAssetProps(done, testNum, currentFetchOp, path, type, name, key, val) + await checkCreatAssetProps(done, testNum, currentFetchOp, path, type, name, key, val); }); /** @@ -364,15 +363,15 @@ export default function fileTestCallbackTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_002_11', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_002_11'; - let currentFetchOp = nameFetchOps(testNum, 'Videos/Static/', '05.mp4', VIDEO_TYPE) - let name = 'mp4' - let path = await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_VIDEO) + 'create/'; + it("SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_002_11", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_002_11"; + let currentFetchOp = nameFetchOps(testNum, "Videos/Static/", "05.mp4", VIDEO_TYPE); + let name = "mp4"; + let path = (await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_VIDEO)) + "create/"; let type = VIDEO_TYPE; - let key = 'orientation'; + let key = "orientation"; let val = 0; - await checkCreatAssetProps(done, testNum, currentFetchOp, path, type, name, key, val) + await checkCreatAssetProps(done, testNum, currentFetchOp, path, type, name, key, val); }); // ------------------------------- video type end ----------------------------- @@ -385,13 +384,13 @@ export default function fileTestCallbackTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_003_01', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_003_01'; - let currentFetchOp = nameFetchOps(testNum, 'Audios/Static/', '01.mp3', AUDIO_TYPE) - let name = 'mp3' - let path = await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_AUDIO) + 'create/' + it("SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_003_01", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_003_01"; + let currentFetchOp = nameFetchOps(testNum, "Audios/Static/", "01.mp3", AUDIO_TYPE); + let name = "mp3"; + let path = (await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_AUDIO)) + "create/"; let type = AUDIO_TYPE; - await creatAssetTest(done, testNum, currentFetchOp, path, type, name) + await creatAssetTest(done, testNum, currentFetchOp, path, type, name); }); /** @@ -402,15 +401,15 @@ export default function fileTestCallbackTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_003_02', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_003_02'; - let currentFetchOp = nameFetchOps(testNum, 'Audios/Static/', '02.mp3', AUDIO_TYPE) - let name = 'mp3' - let path = await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_AUDIO) + 'create/'; + it("SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_003_02", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_003_02"; + let currentFetchOp = nameFetchOps(testNum, "Audios/Static/", "02.mp3", AUDIO_TYPE); + let name = "mp3"; + let path = (await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_AUDIO)) + "create/"; let type = AUDIO_TYPE; - let key = 'displayName'; - let val = 'displayName'; - await checkCreatAssetProps(done, testNum, currentFetchOp, path, type, name, key, val) + let key = "displayName"; + let val = "displayName"; + await checkCreatAssetProps(done, testNum, currentFetchOp, path, type, name, key, val); }); /** @@ -421,15 +420,15 @@ export default function fileTestCallbackTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_003_03', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_003_03'; - let currentFetchOp = nameFetchOps(testNum, 'Audios/Static/', '03.mp3', AUDIO_TYPE) - let name = 'mp3' - let path = await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_AUDIO) + 'create/'; + it("SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_003_03", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_003_03"; + let currentFetchOp = nameFetchOps(testNum, "Audios/Static/", "03.mp3", AUDIO_TYPE); + let name = "mp3"; + let path = (await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_AUDIO)) + "create/"; let type = AUDIO_TYPE; - let key = 'relativePath'; + let key = "relativePath"; let val = path; - await checkCreatAssetProps(done, testNum, currentFetchOp, path, type, name, key, val) + await checkCreatAssetProps(done, testNum, currentFetchOp, path, type, name, key, val); }); /** @@ -440,10 +439,10 @@ export default function fileTestCallbackTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_003_07', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_003_07'; - let currentFetchOp = fetchOps(testNum, 'Audios/Dynamic/', AUDIO_TYPE) - await checkdateModified(done, testNum, currentFetchOp) + it("SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_003_07", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_003_07"; + let currentFetchOp = fetchOps(testNum, "Audios/Dynamic/", AUDIO_TYPE); + await checkdateModified(done, testNum, currentFetchOp); }); /** @@ -454,15 +453,15 @@ export default function fileTestCallbackTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_003_08', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_003_08'; - let currentFetchOp = nameFetchOps(testNum, 'Audios/Static/', '05.mp3', AUDIO_TYPE) - let name = 'mp3' - let path = await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_AUDIO) + 'create/'; + it("SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_003_08", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_003_08"; + let currentFetchOp = nameFetchOps(testNum, "Audios/Static/", "05.mp3", AUDIO_TYPE); + let name = "mp3"; + let path = (await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_AUDIO)) + "create/"; let type = AUDIO_TYPE; - let key = 'mediaType'; + let key = "mediaType"; let val = AUDIO_TYPE; - await checkCreatAssetProps(done, testNum, currentFetchOp, path, type, name, key, val) + await checkCreatAssetProps(done, testNum, currentFetchOp, path, type, name, key, val); }); // ------------------------------- audio type end ----------------------------- @@ -476,13 +475,13 @@ export default function fileTestCallbackTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_004_01', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_004_01'; - let currentFetchOp = nameFetchOps(testNum, 'Documents/Static/', '01.dat', FILE_TYPE) - let name = 'dat' - let path = await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_DOCUMENTS) + 'create/' + it("SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_004_01", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_004_01"; + let currentFetchOp = nameFetchOps(testNum, "Documents/Static/", "01.dat", FILE_TYPE); + let name = "dat"; + let path = (await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_DOCUMENTS)) + "create/"; let type = FILE_TYPE; - await creatAssetTest(done, testNum, currentFetchOp, path, type, name) + await creatAssetTest(done, testNum, currentFetchOp, path, type, name); }); /** @@ -493,15 +492,15 @@ export default function fileTestCallbackTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_004_02', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_004_02'; - let currentFetchOp = nameFetchOps(testNum, 'Documents/Static/', '02.dat', FILE_TYPE) - let name = 'dat' - let path = await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_DOCUMENTS) + 'create/'; + it("SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_004_02", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_004_02"; + let currentFetchOp = nameFetchOps(testNum, "Documents/Static/", "02.dat", FILE_TYPE); + let name = "dat"; + let path = (await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_DOCUMENTS)) + "create/"; let type = FILE_TYPE; - let key = 'displayName'; - let val = 'displayName'; - await checkCreatAssetProps(done, testNum, currentFetchOp, path, type, name, key, val) + let key = "displayName"; + let val = "displayName"; + await checkCreatAssetProps(done, testNum, currentFetchOp, path, type, name, key, val); }); /** @@ -512,15 +511,15 @@ export default function fileTestCallbackTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_004_03', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_004_03'; - let currentFetchOp = nameFetchOps(testNum, 'Documents/Static/', '03.dat', FILE_TYPE) - let name = 'dat' - let path = await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_DOCUMENTS) + 'create/'; + it("SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_004_03", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_004_03"; + let currentFetchOp = nameFetchOps(testNum, "Documents/Static/", "03.dat", FILE_TYPE); + let name = "dat"; + let path = (await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_DOCUMENTS)) + "create/"; let type = FILE_TYPE; - let key = 'relativePath'; + let key = "relativePath"; let val = path; - await checkCreatAssetProps(done, testNum, currentFetchOp, path, type, name, key, val) + await checkCreatAssetProps(done, testNum, currentFetchOp, path, type, name, key, val); }); /** @@ -531,10 +530,10 @@ export default function fileTestCallbackTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_004_07', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_004_07'; - let currentFetchOp = fetchOps(testNum, 'Documents/Dynamic/', FILE_TYPE) - await checkdateModified(done, testNum, currentFetchOp) + it("SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_004_07", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_004_07"; + let currentFetchOp = fetchOps(testNum, "Documents/Dynamic/", FILE_TYPE); + await checkdateModified(done, testNum, currentFetchOp); }); /** @@ -545,18 +544,17 @@ export default function fileTestCallbackTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_004_08', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_004_08'; - let currentFetchOp = nameFetchOps(testNum, 'Documents/Static/', '04.dat', FILE_TYPE) - let name = 'dat' - let path = await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_DOCUMENTS) + 'create/'; + it("SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_004_08", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_004_08"; + let currentFetchOp = nameFetchOps(testNum, "Documents/Static/", "04.dat", FILE_TYPE); + let name = "dat"; + let path = (await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_DOCUMENTS)) + "create/"; let type = FILE_TYPE; - let key = 'mediaType'; + let key = "mediaType"; let val = FILE_TYPE; - await checkCreatAssetProps(done, testNum, currentFetchOp, path, type, name, key, val) + await checkCreatAssetProps(done, testNum, currentFetchOp, path, type, name, key, val); }); // ------------------------------- file type end ----------------------------- }); } - diff --git a/multimedia/medialibrary/mediaLibrary_file/entry/src/main/ets/test/fileTestPromise.test.ets b/multimedia/medialibrary/mediaLibrary_file/entry/src/main/ets/test/fileTestPromise.test.ets old mode 100755 new mode 100644 index e942265dc1a419a1dd3a73c136d97d3057794aa6..e8a20264e38f338ea2c61747cdf6c6e2eab1f889 --- a/multimedia/medialibrary/mediaLibrary_file/entry/src/main/ets/test/fileTestPromise.test.ets +++ b/multimedia/medialibrary/mediaLibrary_file/entry/src/main/ets/test/fileTestPromise.test.ets @@ -13,10 +13,10 @@ * limitations under the License. */ -import mediaLibrary from '@ohos.multimedia.mediaLibrary'; -import fileio from '@ohos.fileio'; +import mediaLibrary from "@ohos.multimedia.mediaLibrary"; +import fileio from "@ohos.fileio"; -import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'; +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "deccjsunit/index"; import { sleep, IMAGE_TYPE, @@ -28,24 +28,23 @@ import { fetchOps, FILEKEY, isNum, -} from '../../../../../../common'; - +} from "../../../../../../common"; export default function fileTestPromiseTest(abilityContext) { - describe('fileTestPromiseTest', function () { + describe("fileTestPromiseTest", function () { const media = mediaLibrary.getMediaLibrary(abilityContext); beforeAll(async function () { - console.info('beforeAll case'); + console.info("beforeAll case"); }); beforeEach(function () { - console.info('beforeEach case'); + console.info("beforeEach case"); }); afterEach(async function () { - console.info('afterEach case'); - await sleep(200) + console.info("afterEach case"); + await sleep(200); }); afterAll(function () { - console.info('afterAll case'); + console.info("afterAll case"); }); async function copyFile(fd1, fd2) { @@ -64,14 +63,14 @@ export default function fileTestPromiseTest(abilityContext) { const creatAsset1 = await media.createAsset(type, displayName1, path); - const fd = await asset.open('rw'); - const creatAssetFd1 = await creatAsset1.open('rw'); + const fd = await asset.open("rw"); + const creatAssetFd1 = await creatAsset1.open("rw"); await copyFile(fd, creatAssetFd1); await creatAsset1.close(creatAssetFd1); let displayName2 = `${new Date().getTime()}.${name}`; const creatAsset2 = await media.createAsset(type, displayName2, path); - const creatAssetFd2 = await creatAsset2.open('rw'); + const creatAssetFd2 = await creatAsset2.open("rw"); await copyFile(fd, creatAssetFd2); await creatAsset2.close(creatAssetFd2); await asset.close(fd); @@ -79,12 +78,12 @@ export default function fileTestPromiseTest(abilityContext) { console.info(`${testNum} displayName1: ${displayName1}, displayName2 :${displayName2} `); done(); } catch (error) { - console.info(`${testNum} failed error: ${error}`) + console.info(`${testNum} failed error: ${error}`); expect(false).assertTrue(); done(); } - } + }; const checkCreatAssetProps = async (done, testNum, fetchOp, path, type, name, key, val) => { try { @@ -96,24 +95,24 @@ export default function fileTestPromiseTest(abilityContext) { const creatAsset = await media.createAsset(type, displayName, path); - const fd = await asset.open('rw'); - const creatAssetFd = await creatAsset.open('rw'); + const fd = await asset.open("rw"); + const creatAssetFd = await creatAsset.open("rw"); await copyFile(fd, creatAssetFd); await creatAsset.close(creatAssetFd); - if (val == 'displayName') { - val = displayName + if (val == "displayName") { + val = displayName; } expect(creatAsset[key]).assertEqual(val); done(); } catch (error) { - console.info(`${testNum} failed error: ${error}`) + console.info(`${testNum} failed error: ${error}`); expect(false).assertTrue(); done(); } - } + }; const checkdateModified = async (done, testNum, fetchOp) => { try { @@ -125,19 +124,19 @@ export default function fileTestPromiseTest(abilityContext) { await asset.commitModify(); const id = asset.id; - const idOP = { selections: FILEKEY.ID + '= ?', selectionArgs: ['' + id] }; + const idOP = { selections: FILEKEY.ID + "= ?", selectionArgs: ["" + id] }; fetchFileResult = await media.getFileAssets(idOP); let newAsset = await fetchFileResult.getFirstObject(); expect(isNum(newAsset.dateModified)).assertTrue(); expect(newAsset.dateModified).assertEqual(asset.dateModified); done(); } catch (error) { - console.info(`${testNum} failed error: ${error}`) + console.info(`${testNum} failed error: ${error}`); expect(false).assertTrue(); done(); } - } + }; // ------------------------------- image type start ---------------------------- /** @@ -148,13 +147,13 @@ export default function fileTestPromiseTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_001_01', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_001_01'; - let currentFetchOp = nameFetchOps(testNum, 'Pictures/Static/', '01.jpg', IMAGE_TYPE) - let name = 'jpg' - let path = await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_IMAGE) + 'create/' + it("SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_001_01", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_001_01"; + let currentFetchOp = nameFetchOps(testNum, "Pictures/Static/", "01.jpg", IMAGE_TYPE); + let name = "jpg"; + let path = (await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_IMAGE)) + "create/"; let type = IMAGE_TYPE; - await creatAssetTest(done, testNum, currentFetchOp, path, type, name) + await creatAssetTest(done, testNum, currentFetchOp, path, type, name); }); /** @@ -165,15 +164,15 @@ export default function fileTestPromiseTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_001_02', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_001_02'; - let currentFetchOp = nameFetchOps(testNum, 'Pictures/Static/', '02.jpg', IMAGE_TYPE) - let name = 'jpg' - let path = await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_IMAGE) + 'create/'; + it("SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_001_02", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_001_02"; + let currentFetchOp = nameFetchOps(testNum, "Pictures/Static/", "02.jpg", IMAGE_TYPE); + let name = "jpg"; + let path = (await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_IMAGE)) + "create/"; let type = IMAGE_TYPE; - let key = 'displayName'; - let val = 'displayName'; - await checkCreatAssetProps(done, testNum, currentFetchOp, path, type, name, key, val) + let key = "displayName"; + let val = "displayName"; + await checkCreatAssetProps(done, testNum, currentFetchOp, path, type, name, key, val); }); /** @@ -184,15 +183,15 @@ export default function fileTestPromiseTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_001_03', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_001_03'; - let currentFetchOp = nameFetchOps(testNum, 'Pictures/Static/', '03.jpg', IMAGE_TYPE) - let name = 'jpg' - let path = await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_IMAGE) + 'create/'; + it("SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_001_03", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_001_03"; + let currentFetchOp = nameFetchOps(testNum, "Pictures/Static/", "03.jpg", IMAGE_TYPE); + let name = "jpg"; + let path = (await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_IMAGE)) + "create/"; let type = IMAGE_TYPE; - let key = 'relativePath'; + let key = "relativePath"; let val = path; - await checkCreatAssetProps(done, testNum, currentFetchOp, path, type, name, key, val) + await checkCreatAssetProps(done, testNum, currentFetchOp, path, type, name, key, val); }); /** @@ -203,10 +202,10 @@ export default function fileTestPromiseTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_001_07', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_001_07'; - let currentFetchOp = fetchOps(testNum, 'Pictures/Dynamic/', IMAGE_TYPE) - await checkdateModified(done, testNum, currentFetchOp) + it("SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_001_07", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_001_07"; + let currentFetchOp = fetchOps(testNum, "Pictures/Dynamic/", IMAGE_TYPE); + await checkdateModified(done, testNum, currentFetchOp); }); /** @@ -217,15 +216,15 @@ export default function fileTestPromiseTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_001_08', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_001_08'; - let currentFetchOp = nameFetchOps(testNum, 'Pictures/Static/', '04.jpg', IMAGE_TYPE) - let name = 'jpg' - let path = await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_IMAGE) + 'create/'; + it("SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_001_08", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_001_08"; + let currentFetchOp = nameFetchOps(testNum, "Pictures/Static/", "04.jpg", IMAGE_TYPE); + let name = "jpg"; + let path = (await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_IMAGE)) + "create/"; let type = IMAGE_TYPE; - let key = 'mediaType'; + let key = "mediaType"; let val = IMAGE_TYPE; - await checkCreatAssetProps(done, testNum, currentFetchOp, path, type, name, key, val) + await checkCreatAssetProps(done, testNum, currentFetchOp, path, type, name, key, val); }); /** @@ -236,15 +235,15 @@ export default function fileTestPromiseTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_001_11', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_001_11'; - let currentFetchOp = nameFetchOps(testNum, 'Pictures/Static/', '05.jpg', IMAGE_TYPE) - let name = 'jpg' - let path = await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_IMAGE) + 'create/'; + it("SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_001_11", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_001_11"; + let currentFetchOp = nameFetchOps(testNum, "Pictures/Static/", "05.jpg", IMAGE_TYPE); + let name = "jpg"; + let path = (await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_IMAGE)) + "create/"; let type = IMAGE_TYPE; - let key = 'orientation'; + let key = "orientation"; let val = 0; - await checkCreatAssetProps(done, testNum, currentFetchOp, path, type, name, key, val) + await checkCreatAssetProps(done, testNum, currentFetchOp, path, type, name, key, val); }); // ------------------------------- image type end ----------------------------- @@ -258,13 +257,13 @@ export default function fileTestPromiseTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_002_01', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_002_01'; - let currentFetchOp = nameFetchOps(testNum, 'Videos/Static/', '01.mp4', VIDEO_TYPE) - let name = 'mp4' - let path = await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_VIDEO) + 'create/' + it("SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_002_01", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_002_01"; + let currentFetchOp = nameFetchOps(testNum, "Videos/Static/", "01.mp4", VIDEO_TYPE); + let name = "mp4"; + let path = (await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_VIDEO)) + "create/"; let type = VIDEO_TYPE; - await creatAssetTest(done, testNum, currentFetchOp, path, type, name) + await creatAssetTest(done, testNum, currentFetchOp, path, type, name); }); /** @@ -275,15 +274,15 @@ export default function fileTestPromiseTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_002_02', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_002_02'; - let currentFetchOp = nameFetchOps(testNum, 'Videos/Static/', '02.mp4', VIDEO_TYPE) - let name = 'mp4' - let path = await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_VIDEO) + 'create/'; + it("SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_002_02", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_002_02"; + let currentFetchOp = nameFetchOps(testNum, "Videos/Static/", "02.mp4", VIDEO_TYPE); + let name = "mp4"; + let path = (await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_VIDEO)) + "create/"; let type = VIDEO_TYPE; - let key = 'displayName'; - let val = 'displayName'; - await checkCreatAssetProps(done, testNum, currentFetchOp, path, type, name, key, val) + let key = "displayName"; + let val = "displayName"; + await checkCreatAssetProps(done, testNum, currentFetchOp, path, type, name, key, val); }); /** @@ -294,15 +293,15 @@ export default function fileTestPromiseTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_002_03', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_002_03'; - let currentFetchOp = nameFetchOps(testNum, 'Videos/Static/', '03.mp4', VIDEO_TYPE) - let name = 'mp4' - let path = await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_VIDEO) + 'create/'; + it("SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_002_03", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_002_03"; + let currentFetchOp = nameFetchOps(testNum, "Videos/Static/", "03.mp4", VIDEO_TYPE); + let name = "mp4"; + let path = (await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_VIDEO)) + "create/"; let type = VIDEO_TYPE; - let key = 'relativePath'; + let key = "relativePath"; let val = path; - await checkCreatAssetProps(done, testNum, currentFetchOp, path, type, name, key, val) + await checkCreatAssetProps(done, testNum, currentFetchOp, path, type, name, key, val); }); /** @@ -313,10 +312,10 @@ export default function fileTestPromiseTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_002_07', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_002_07'; - let currentFetchOp = fetchOps(testNum, 'Videos/Dynamic/', VIDEO_TYPE) - await checkdateModified(done, testNum, currentFetchOp) + it("SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_002_07", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_002_07"; + let currentFetchOp = fetchOps(testNum, "Videos/Dynamic/", VIDEO_TYPE); + await checkdateModified(done, testNum, currentFetchOp); }); /** @@ -327,15 +326,15 @@ export default function fileTestPromiseTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_002_08', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_002_08'; - let currentFetchOp = nameFetchOps(testNum, 'Videos/Static/', '04.mp4', VIDEO_TYPE) - let name = 'mp4' - let path = await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_VIDEO) + 'create/'; + it("SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_002_08", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_002_08"; + let currentFetchOp = nameFetchOps(testNum, "Videos/Static/", "04.mp4", VIDEO_TYPE); + let name = "mp4"; + let path = (await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_VIDEO)) + "create/"; let type = VIDEO_TYPE; - let key = 'mediaType'; + let key = "mediaType"; let val = VIDEO_TYPE; - await checkCreatAssetProps(done, testNum, currentFetchOp, path, type, name, key, val) + await checkCreatAssetProps(done, testNum, currentFetchOp, path, type, name, key, val); }); /** @@ -346,15 +345,15 @@ export default function fileTestPromiseTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_002_11', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_002_11'; - let currentFetchOp = nameFetchOps(testNum, 'Videos/Static/', '05.mp4', VIDEO_TYPE) - let name = 'mp4' - let path = await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_VIDEO) + 'create/'; + it("SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_002_11", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_002_11"; + let currentFetchOp = nameFetchOps(testNum, "Videos/Static/", "05.mp4", VIDEO_TYPE); + let name = "mp4"; + let path = (await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_VIDEO)) + "create/"; let type = VIDEO_TYPE; - let key = 'orientation'; + let key = "orientation"; let val = 0; - await checkCreatAssetProps(done, testNum, currentFetchOp, path, type, name, key, val) + await checkCreatAssetProps(done, testNum, currentFetchOp, path, type, name, key, val); }); // ------------------------------- video type end ----------------------------- @@ -367,13 +366,13 @@ export default function fileTestPromiseTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_003_01', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_003_01'; - let currentFetchOp = nameFetchOps(testNum, 'Audios/Static/', '01.mp3', AUDIO_TYPE) - let name = 'mp3' - let path = await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_AUDIO) + 'create/' + it("SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_003_01", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_003_01"; + let currentFetchOp = nameFetchOps(testNum, "Audios/Static/", "01.mp3", AUDIO_TYPE); + let name = "mp3"; + let path = (await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_AUDIO)) + "create/"; let type = AUDIO_TYPE; - await creatAssetTest(done, testNum, currentFetchOp, path, type, name) + await creatAssetTest(done, testNum, currentFetchOp, path, type, name); }); /** @@ -384,15 +383,15 @@ export default function fileTestPromiseTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_003_02', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_003_02'; - let currentFetchOp = nameFetchOps(testNum, 'Audios/Static/', '02.mp3', AUDIO_TYPE) - let name = 'mp3' - let path = await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_AUDIO) + 'create/'; + it("SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_003_02", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_003_02"; + let currentFetchOp = nameFetchOps(testNum, "Audios/Static/", "02.mp3", AUDIO_TYPE); + let name = "mp3"; + let path = (await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_AUDIO)) + "create/"; let type = AUDIO_TYPE; - let key = 'displayName'; - let val = 'displayName'; - await checkCreatAssetProps(done, testNum, currentFetchOp, path, type, name, key, val) + let key = "displayName"; + let val = "displayName"; + await checkCreatAssetProps(done, testNum, currentFetchOp, path, type, name, key, val); }); /** @@ -403,15 +402,15 @@ export default function fileTestPromiseTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_003_03', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_003_03'; - let currentFetchOp = nameFetchOps(testNum, 'Audios/Static/', '03.mp3', AUDIO_TYPE) - let name = 'mp3' - let path = await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_AUDIO) + 'create/'; + it("SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_003_03", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_003_03"; + let currentFetchOp = nameFetchOps(testNum, "Audios/Static/", "03.mp3", AUDIO_TYPE); + let name = "mp3"; + let path = (await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_AUDIO)) + "create/"; let type = AUDIO_TYPE; - let key = 'relativePath'; + let key = "relativePath"; let val = path; - await checkCreatAssetProps(done, testNum, currentFetchOp, path, type, name, key, val) + await checkCreatAssetProps(done, testNum, currentFetchOp, path, type, name, key, val); }); /** @@ -422,10 +421,10 @@ export default function fileTestPromiseTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_003_07', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_003_07'; - let currentFetchOp = fetchOps(testNum, 'Audios/Dynamic/', AUDIO_TYPE) - await checkdateModified(done, testNum, currentFetchOp) + it("SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_003_07", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_003_07"; + let currentFetchOp = fetchOps(testNum, "Audios/Dynamic/", AUDIO_TYPE); + await checkdateModified(done, testNum, currentFetchOp); }); /** @@ -436,15 +435,15 @@ export default function fileTestPromiseTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_003_08', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_003_08'; - let currentFetchOp = nameFetchOps(testNum, 'Audios/Static/', '05.mp3', AUDIO_TYPE) - let name = 'mp3' - let path = await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_AUDIO) + 'create/'; + it("SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_003_08", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_003_08"; + let currentFetchOp = nameFetchOps(testNum, "Audios/Static/", "05.mp3", AUDIO_TYPE); + let name = "mp3"; + let path = (await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_AUDIO)) + "create/"; let type = AUDIO_TYPE; - let key = 'mediaType'; + let key = "mediaType"; let val = AUDIO_TYPE; - await checkCreatAssetProps(done, testNum, currentFetchOp, path, type, name, key, val) + await checkCreatAssetProps(done, testNum, currentFetchOp, path, type, name, key, val); }); // ------------------------------- audio type end ----------------------------- @@ -458,13 +457,13 @@ export default function fileTestPromiseTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_004_01', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_004_01'; - let currentFetchOp = nameFetchOps(testNum, 'Documents/Static/', '01.dat', FILE_TYPE) - let name = 'dat' - let path = await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_DOCUMENTS) + 'create/' + it("SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_004_01", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_004_01"; + let currentFetchOp = nameFetchOps(testNum, "Documents/Static/", "01.dat", FILE_TYPE); + let name = "dat"; + let path = (await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_DOCUMENTS)) + "create/"; let type = FILE_TYPE; - await creatAssetTest(done, testNum, currentFetchOp, path, type, name) + await creatAssetTest(done, testNum, currentFetchOp, path, type, name); }); /** @@ -475,15 +474,15 @@ export default function fileTestPromiseTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_004_02', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_004_02'; - let currentFetchOp = nameFetchOps(testNum, 'Documents/Static/', '02.dat', FILE_TYPE) - let name = 'dat' - let path = await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_DOCUMENTS) + 'create/'; + it("SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_004_02", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_004_02"; + let currentFetchOp = nameFetchOps(testNum, "Documents/Static/", "02.dat", FILE_TYPE); + let name = "dat"; + let path = (await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_DOCUMENTS)) + "create/"; let type = FILE_TYPE; - let key = 'displayName'; - let val = 'displayName'; - await checkCreatAssetProps(done, testNum, currentFetchOp, path, type, name, key, val) + let key = "displayName"; + let val = "displayName"; + await checkCreatAssetProps(done, testNum, currentFetchOp, path, type, name, key, val); }); /** @@ -494,15 +493,15 @@ export default function fileTestPromiseTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_004_03', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_004_03'; - let currentFetchOp = nameFetchOps(testNum, 'Documents/Static/', '03.dat', FILE_TYPE) - let name = 'dat' - let path = await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_DOCUMENTS) + 'create/'; + it("SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_004_03", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_004_03"; + let currentFetchOp = nameFetchOps(testNum, "Documents/Static/", "03.dat", FILE_TYPE); + let name = "dat"; + let path = (await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_DOCUMENTS)) + "create/"; let type = FILE_TYPE; - let key = 'relativePath'; + let key = "relativePath"; let val = path; - await checkCreatAssetProps(done, testNum, currentFetchOp, path, type, name, key, val) + await checkCreatAssetProps(done, testNum, currentFetchOp, path, type, name, key, val); }); /** @@ -513,10 +512,10 @@ export default function fileTestPromiseTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_004_07', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_004_07'; - let currentFetchOp = fetchOps(testNum, 'Documents/Dynamic/', FILE_TYPE) - await checkdateModified(done, testNum, currentFetchOp) + it("SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_004_07", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_004_07"; + let currentFetchOp = fetchOps(testNum, "Documents/Dynamic/", FILE_TYPE); + await checkdateModified(done, testNum, currentFetchOp); }); /** @@ -527,18 +526,17 @@ export default function fileTestPromiseTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_004_08', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_004_08'; - let currentFetchOp = nameFetchOps(testNum, 'Documents/Static/', '04.dat', FILE_TYPE) - let name = 'dat' - let path = await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_DOCUMENTS) + 'create/'; + it("SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_004_08", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_004_08"; + let currentFetchOp = nameFetchOps(testNum, "Documents/Static/", "04.dat", FILE_TYPE); + let name = "dat"; + let path = (await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_DOCUMENTS)) + "create/"; let type = FILE_TYPE; - let key = 'mediaType'; + let key = "mediaType"; let val = FILE_TYPE; - await checkCreatAssetProps(done, testNum, currentFetchOp, path, type, name, key, val) + await checkCreatAssetProps(done, testNum, currentFetchOp, path, type, name, key, val); }); // ------------------------------- file type end ----------------------------- }); } - diff --git a/multimedia/medialibrary/mediaLibrary_file/entry/src/main/module.json b/multimedia/medialibrary/mediaLibrary_file/entry/src/main/module.json old mode 100755 new mode 100644 index a1aa0cada29076a34f21189f99ad1f86dee4944a..025062ffed12b44b32db7f5f35356c9040ed9c5c --- a/multimedia/medialibrary/mediaLibrary_file/entry/src/main/module.json +++ b/multimedia/medialibrary/mediaLibrary_file/entry/src/main/module.json @@ -1,69 +1,69 @@ -{ - "module": { - "name": "phone", - "type": "entry", - "srcEntrance": "./ets/Application/AbilityStage.ts", - "description": "$string:mainability_description", - "mainElement": "MainAbility", - "deviceTypes": [ - "tablet", - "default", - "phone" - ], - "deliveryWithInstall": true, - "installationFree": false, - "uiSyntax": "ets", - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "ohos.acts.multimedia.mediaLibrary.MainAbility", - "srcEntrance": "./ets/MainAbility/MainAbility.ts", - "description": "$string:mainability_description", - "icon": "$media:icon", - "label": "$string:entry_MainAbility", - "visible": true, - "orientation": "portrait", - "skills": [ - { - "actions": [ - "action.system.home" - ], - "entities":[ - "entity.system.home" - ] - } - ] - } - ], - "requestPermissions": [ - { - "name": "ohos.permission.GET_BUNDLE_INFO", - "reason": "use ohos.permission.GET_BUNDLE_INFO" - }, - { - "name": "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED", - "reason":"use ohos.permission.GET_BUNDLE_INFO_PRIVILEGED" - }, - { - "name" : "ohos.permission.GRANT_SENSITIVE_PERMISSIONS", - "reason" : "use ohos.permission.GRANT_SENSITIVE_PERMISSIONS" - }, - { - "name" : "ohos.permission.REVOKE_SENSITIVE_PERMISSIONS", - "reason" : "use ohos.permission.REVOKE_SENSITIVE_PERMISSIONS" - }, - { - "name": "ohos.permission.MEDIA_LOCATION", - "reason":"use ohos.permission.MEDIA_LOCATION" - }, - { - "name": "ohos.permission.READ_MEDIA", - "reason":"use ohos.permission.READ_MEDIA" - }, - { - "name": "ohos.permission.WRITE_MEDIA", - "reason":"use ohos.permission.WRITE_MEDIA" - } - ] - } -} +{ + "module": { + "name": "phone", + "type": "entry", + "srcEntrance": "./ets/Application/AbilityStage.ts", + "description": "$string:phone_entry_dsc", + "mainElement": "MainAbility", + "deviceTypes": [ + "tablet", + "default", + "phone" + ], + "deliveryWithInstall": true, + "installationFree": false, + "uiSyntax": "ets", + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "com.example.myapplication.MainAbility", + "srcEntrance": "./ets/MainAbility/MainAbility.ts", + "description": "$string:phone_entry_main", + "icon": "$media:icon", + "label": "$string:entry_label", + "visible": true, + "orientation": "portrait", + "skills": [ + { + "actions": [ + "action.system.home" + ], + "entities": [ + "entity.system.home" + ] + } + ] + } + ], + "requestPermissions": [ + { + "name": "ohos.permission.GET_BUNDLE_INFO", + "reason": "use ohos.permission.GET_BUNDLE_INFO" + }, + { + "name": "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED", + "reason": "use ohos.permission.GET_BUNDLE_INFO_PRIVILEGED" + }, + { + "name": "ohos.permission.GRANT_SENSITIVE_PERMISSIONS", + "reason": "use ohos.permission.GRANT_SENSITIVE_PERMISSIONS" + }, + { + "name": "ohos.permission.REVOKE_SENSITIVE_PERMISSIONS", + "reason": "use ohos.permission.REVOKE_SENSITIVE_PERMISSIONS" + }, + { + "name": "ohos.permission.MEDIA_LOCATION", + "reason": "use ohos.permission.MEDIA_LOCATION" + }, + { + "name": "ohos.permission.READ_MEDIA", + "reason": "use ohos.permission.READ_MEDIA" + }, + { + "name": "ohos.permission.WRITE_MEDIA", + "reason": "use ohos.permission.WRITE_MEDIA" + } + ] + } +} \ No newline at end of file diff --git a/multimedia/medialibrary/mediaLibrary_file/entry/src/main/resources/base/element/string.json b/multimedia/medialibrary/mediaLibrary_file/entry/src/main/resources/base/element/string.json old mode 100755 new mode 100644 index 32237ee203edf64926964fb238fa44e396ddf577..2ae43f018e75d1140cf2c0c85a6a14fc369a0c50 --- a/multimedia/medialibrary/mediaLibrary_file/entry/src/main/resources/base/element/string.json +++ b/multimedia/medialibrary/mediaLibrary_file/entry/src/main/resources/base/element/string.json @@ -1,12 +1,32 @@ -{ - "string": [ - { - "name": "entry_MainAbility", - "value": "MediaLibraryJSTestMain" - }, - { - "name": "mainability_description", - "value": "MediaLibraryJSTestMain Ability" - } - ] - } \ No newline at end of file +{ + "string": [ + { + "name": "phone_entry_dsc", + "value": "i am an entry for phone" + }, + { + "name": "phone_entry_main", + "value": "the phone entry ability" + }, + { + "name": "entry_label", + "value": "ActsMediaLibraryTest" + }, + { + "name": "form_description", + "value": "mediaLibrary" + }, + { + "name": "serviceability_description", + "value": "mediaLibrary" + }, + { + "name": "description_application", + "value": "mediaLibrary test" + }, + { + "name": "app_name", + "value": "ActsMediaLibraryTest" + } + ] +} \ No newline at end of file diff --git a/multimedia/medialibrary/mediaLibrary_file/entry/src/main/resources/base/profile/main_pages.json b/multimedia/medialibrary/mediaLibrary_file/entry/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 index 96b478210df9884592229ae2db6f6bb7f86c14f4..ceb075cd80946aade673d707aac904fb8998bce9 --- a/multimedia/medialibrary/mediaLibrary_file/entry/src/main/resources/base/profile/main_pages.json +++ b/multimedia/medialibrary/mediaLibrary_file/entry/src/main/resources/base/profile/main_pages.json @@ -1,6 +1,5 @@ -{ - "src": [ - "pages/index/index", - "pages/second/second" - ] +{ + "src": [ + "MainAbility/pages/index/index" + ] } \ No newline at end of file diff --git a/multimedia/medialibrary/mediaLibrary_file/signature/openharmony_sx.p7b b/multimedia/medialibrary/mediaLibrary_file/signature/openharmony_sx.p7b old mode 100755 new mode 100644 index 3eb5b5db82a014ff4c9483872cad743ad49a9b6e..64b33bf079b2ab68a3f26f240d127186546b33d9 Binary files a/multimedia/medialibrary/mediaLibrary_file/signature/openharmony_sx.p7b and b/multimedia/medialibrary/mediaLibrary_file/signature/openharmony_sx.p7b differ diff --git a/multimedia/medialibrary/mediaLibrary_fileAsset/AppScope/app.json b/multimedia/medialibrary/mediaLibrary_fileAsset/AppScope/app.json old mode 100755 new mode 100644 index 5139eaad5d5fd2e2de13b4970785d6fa8ae1a4ba..803955ad0d2a5b4ce4e103816a6a917b4701286b --- a/multimedia/medialibrary/mediaLibrary_fileAsset/AppScope/app.json +++ b/multimedia/medialibrary/mediaLibrary_fileAsset/AppScope/app.json @@ -1,21 +1,21 @@ { - "app":{ - "bundleName":"ohos.acts.multimedia.mediaLibrary", - "vendor":"huawei", - "versionCode":1000000, - "versionName":"1.0.0", - "debug":false, - "icon":"$media:icon", - "label":"$string:entry_MainAbility", - "description":"$string:mainability_description", - "distributedNotificationEnabled":true, - "keepAlive":true, - "singleUser":true, - "minAPIVersion":8, - "targetAPIVersion":8, - "car":{ - "apiCompatibleVersion":8, - "singleUser":false + "app": { + "bundleName": "ohos.acts.multimedia.mediaLibrary", + "vendor": "huawei", + "versionCode": 1000000, + "versionName": "1.0.0", + "debug": false, + "icon": "$media:icon", + "label": "$string:app_name", + "description": "$string:description_application", + "distributedNotificationEnabled": true, + "keepAlive": true, + "singleUser": true, + "minAPIVersion": 9, + "targetAPIVersion": 9, + "car": { + "apiCompatibleVersion": 9, + "singleUser": false } } -} +} \ No newline at end of file diff --git a/multimedia/medialibrary/mediaLibrary_fileAsset/AppScope/resources/base/element/string.json b/multimedia/medialibrary/mediaLibrary_fileAsset/AppScope/resources/base/element/string.json old mode 100755 new mode 100644 index c1dee63527ae5e3c37f3736f6b68189e8df6f201..ee69f9a861d9dc269ed6638735d52674583498e1 --- a/multimedia/medialibrary/mediaLibrary_fileAsset/AppScope/resources/base/element/string.json +++ b/multimedia/medialibrary/mediaLibrary_fileAsset/AppScope/resources/base/element/string.json @@ -1,12 +1,8 @@ { - "string": [ + "string":[ { - "name": "entry_MainAbility", - "value": "MediaLibraryJSTestMain" - }, - { - "name": "mainability_description", - "value": "MediaLibraryJSTestMain Ability" + "name":"app_name", + "value":"ohosProject" } ] -} \ No newline at end of file +} \ No newline at end of file diff --git a/multimedia/medialibrary/mediaLibrary_fileAsset/BUILD.gn b/multimedia/medialibrary/mediaLibrary_fileAsset/BUILD.gn old mode 100755 new mode 100644 index 908b75b8ff69fed7315564e23460044d8842d0b5..e893f7ed60f7fbd7cc22eeec196418a047b2b0ea --- a/multimedia/medialibrary/mediaLibrary_fileAsset/BUILD.gn +++ b/multimedia/medialibrary/mediaLibrary_fileAsset/BUILD.gn @@ -15,6 +15,7 @@ import("//test/xts/tools/build/suite.gni") ohos_js_hap_suite("mediaLibrary_fileAsset_hap") { hap_profile = "entry/src/main/module.json" + js_build_mode = "debug" deps = [ ":mediaLibrary_js_assets", ":mediaLibrary_resources", diff --git a/multimedia/medialibrary/mediaLibrary_fileAsset/Test.json b/multimedia/medialibrary/mediaLibrary_fileAsset/Test.json old mode 100755 new mode 100644 index abbfa6e538921c5923fc3c325e5523211ee928f4..a51d870100dbb89c3b0fe09508704f247ba3cb00 --- a/multimedia/medialibrary/mediaLibrary_fileAsset/Test.json +++ b/multimedia/medialibrary/mediaLibrary_fileAsset/Test.json @@ -1,10 +1,12 @@ { "description": "Configuration for mediaLibrary Tests", "driver": { - "type": "JSUnitTest", - "test-timeout": "300000", - "package": "ohos.acts.multimedia.mediaLibrary", - "shell-timeout": "600000" + "type": "OHJSUnitTest", + "test-timeout": "180000", + "bundle-name": "ohos.acts.multimedia.mediaLibrary", + "module-name": "phone", + "shell-timeout": "600000", + "testcase-timeout": 70000 }, "kits": [ { @@ -14,7 +16,10 @@ "rm -rf /storage/media/100/local/files/*", "rm -rf /data/app/el2/100/database/com.ohos.medialibrary.medialibrarydata/*", "mkdir -pv /storage/media/100/local/files/{Pictures,Videos,Audios,Documents}", - "mkdir -p /storage/media/100/local/temp" + "mkdir -p /storage/media/100/local/temp", + "power-shell wakeup", + "uinput -T -d 300 600 -m 300 600 300 100 -u 300 100", + "power-shell setmode 602" ] }, { @@ -51,8 +56,9 @@ "scanner", "sleep 10" ], - "teardown-command":[ - "hilog -b X -D 0xD002B70" + "teardown-command": [ + "hilog -b X -D 0xD002B70", + "power-shell setmode 600" ] }, { diff --git a/multimedia/medialibrary/mediaLibrary_fileAsset/entry/src/main/ets/Application/AbilityStage.ts b/multimedia/medialibrary/mediaLibrary_fileAsset/entry/src/main/ets/Application/AbilityStage.ts old mode 100755 new mode 100644 index 51cb02ba3f5c7011c1cd433d07deebd47a195704..e3fdadfebeeeb676df2ce8f78f4b59e26fae9cf0 --- a/multimedia/medialibrary/mediaLibrary_fileAsset/entry/src/main/ets/Application/AbilityStage.ts +++ b/multimedia/medialibrary/mediaLibrary_fileAsset/entry/src/main/ets/Application/AbilityStage.ts @@ -3,7 +3,7 @@ import AbilityStage from "@ohos.application.AbilityStage" export default class MyAbilityStage extends AbilityStage { onCreate() { console.log("[Demo] MyAbilityStage onCreate") - globalThis.stageOnCreateRun = 1; - globalThis.stageContext = this.context; + globalThis.stageOnCreateRun = 1; + globalThis.stageContext = this.context; } } diff --git a/multimedia/medialibrary/mediaLibrary_fileAsset/entry/src/main/ets/MainAbility/MainAbility.ts b/multimedia/medialibrary/mediaLibrary_fileAsset/entry/src/main/ets/MainAbility/MainAbility.ts old mode 100755 new mode 100644 index 2f9d6d1f23f95d9fc891fbc550cd5a589cfb6c89..83c0cd68bb2c044c9b98d212a62851b32bd9af9a --- a/multimedia/medialibrary/mediaLibrary_fileAsset/entry/src/main/ets/MainAbility/MainAbility.ts +++ b/multimedia/medialibrary/mediaLibrary_fileAsset/entry/src/main/ets/MainAbility/MainAbility.ts @@ -1,7 +1,7 @@ import Ability from '@ohos.application.Ability' export default class MainAbility extends Ability { - onCreate(want,launchParam){ + onCreate(want, launchParam) { // Ability is creating, initialize resources for this ability console.log("[Demo] MainAbility onCreate") globalThis.abilityWant = want; @@ -12,11 +12,11 @@ export default class MainAbility extends Ability { console.log("[Demo] MainAbility onDestroy") } - onWindowStageCreate(windowStage) { - // Main window is created, set main page for this ability - console.log("[Demo] MainAbility onWindowStageCreate") + async onWindowStageCreate(windowStage) { + console.log("[Demo] MainAbility onWindowStageCreate windowStage=" + windowStage) + globalThis.windowStage = windowStage globalThis.abilityContext = this.context - windowStage.setUIContent(this.context, "pages/index/index", null) + windowStage.setUIContent(this.context, "MainAbility/pages/index/index", null) } onWindowStageDestroy() { diff --git a/multimedia/medialibrary/mediaLibrary_fileAsset/entry/src/main/ets/MainAbility/pages/index/index.ets b/multimedia/medialibrary/mediaLibrary_fileAsset/entry/src/main/ets/MainAbility/pages/index/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..6a8c567d5a86048b1c269e4f00cc288ec136200b --- /dev/null +++ b/multimedia/medialibrary/mediaLibrary_fileAsset/entry/src/main/ets/MainAbility/pages/index/index.ets @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import router from '@ohos.router'; +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' +import { Hypium } from '@ohos/hypium' +import testsuite from '../../../test/List.test' + + +@Entry +@Component +struct Index { + + aboutToAppear(){ + console.info("start run testcase!!!!") + var abilityDelegator: any + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var abilityDelegatorArguments: any + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + console.info('start run testcase!!!') + Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) + } + + build() { + Flex({ direction:FlexDirection.Column, alignItems:ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text('Hello World') + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('next page') + .fontSize(25) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .onClick(() => { + + }) + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/multimedia/medialibrary/mediaLibrary_fileAsset/entry/src/main/ets/TestAbility/TestAbility.ts b/multimedia/medialibrary/mediaLibrary_fileAsset/entry/src/main/ets/TestAbility/TestAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..8028a70f8af44690b95a08bd177bca6b09f24687 --- /dev/null +++ b/multimedia/medialibrary/mediaLibrary_fileAsset/entry/src/main/ets/TestAbility/TestAbility.ts @@ -0,0 +1,50 @@ +/* + * 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 Ability from '@ohos.app.ability.UIAbility' + +export default class TestAbility extends Ability { + onCreate(want, launchParam) { + console.log('TestAbility onCreate') + } + + onDestroy() { + console.log('TestAbility onDestroy') + } + + onWindowStageCreate(windowStage) { + console.log('TestAbility onWindowStageCreate') + windowStage.loadContent("TestAbility/pages/index", (err, data) => { + if (err.code) { + console.error('Failed to load the content. Cause:' + JSON.stringify(err)); + return; + } + console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data)) + }); + + globalThis.abilityContext = this.context; + } + + onWindowStageDestroy() { + console.log('TestAbility onWindowStageDestroy') + } + + onForeground() { + console.log('TestAbility onForeground') + } + + onBackground() { + console.log('TestAbility onBackground') + } +}; \ No newline at end of file diff --git a/multimedia/medialibrary/mediaLibrary_fileAsset/entry/src/main/ets/TestAbility/pages/index.ets b/multimedia/medialibrary/mediaLibrary_fileAsset/entry/src/main/ets/TestAbility/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..b93567f962921124b282f78c8ef123965d1460c9 --- /dev/null +++ b/multimedia/medialibrary/mediaLibrary_fileAsset/entry/src/main/ets/TestAbility/pages/index.ets @@ -0,0 +1,48 @@ +/* + * 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 router from '@ohos.router'; + +@Entry +@Component +struct Index { + aboutToAppear() { + console.info('TestAbility index aboutToAppear') + } + @State message: string = 'Hello World' + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('next page') + .fontSize(20) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .width('35%') + .height('5%') + .onClick(()=>{ + }) + } + .width('100%') + } + .height('100%') + } + } \ No newline at end of file diff --git a/multimedia/medialibrary/mediaLibrary_fileAsset/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts b/multimedia/medialibrary/mediaLibrary_fileAsset/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts new file mode 100644 index 0000000000000000000000000000000000000000..a4ee2f1652b3d04ce83ece64ef70f8dfa62a2dc8 --- /dev/null +++ b/multimedia/medialibrary/mediaLibrary_fileAsset/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts @@ -0,0 +1,78 @@ +/* + * 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 TestRunner from '@ohos.application.testRunner' +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' + +var abilityDelegator = undefined +var abilityDelegatorArguments = undefined + +function translateParamsToString(parameters) { + const keySet = new Set([ + '-s class', '-s notClass', '-s suite', '-s it', + '-s level', '-s testType', '-s size', '-s timeout', + '-s dryRun' + ]) + let targetParams = ''; + for (const key in parameters) { + if (keySet.has(key)) { + targetParams = `${targetParams} ${key} ${parameters[key]}` + } + } + return targetParams.trim() +} + +async function onAbilityCreateCallback() { + console.log("onAbilityCreateCallback"); +} + +async function addAbilityMonitorCallback(err: any) { + console.info("addAbilityMonitorCallback : " + JSON.stringify(err)) +} + +export default class OpenHarmonyTestRunner implements TestRunner { + constructor() { + } + + onPrepare() { + console.info("OpenHarmonyTestRunner OnPrepare ") + } + + async onRun() { + console.log('OpenHarmonyTestRunner onRun run') + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var testAbilityName = abilityDelegatorArguments.bundleName + '.MainAbility' + let lMonitor = { + abilityName: testAbilityName, + onAbilityCreate: onAbilityCreateCallback, + }; + abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback) + var cmd = 'aa start -d 0 -a com.example.myapplication.MainAbility' + ' -b ' + abilityDelegatorArguments.bundleName + cmd += ' '+translateParamsToString(abilityDelegatorArguments.parameters) + var debug = abilityDelegatorArguments.parameters["-D"] + if (debug == 'true') + { + cmd += ' -D' + } + console.info('cmd : '+cmd) + abilityDelegator.executeShellCommand(cmd, + (err: any, d: any) => { + console.info('executeShellCommand : err : ' + JSON.stringify(err)); + console.info('executeShellCommand : data : ' + d.stdResult); + console.info('executeShellCommand : data : ' + d.exitCode); + }) + console.info('OpenHarmonyTestRunner onRun end') + } +}; \ No newline at end of file diff --git a/multimedia/medialibrary/mediaLibrary_fileAsset/entry/src/main/ets/pages/second/second.ets b/multimedia/medialibrary/mediaLibrary_fileAsset/entry/src/main/ets/pages/second/second.ets deleted file mode 100755 index 1c1c727ff11ecc97909f482c35268db87ae23bb4..0000000000000000000000000000000000000000 --- a/multimedia/medialibrary/mediaLibrary_fileAsset/entry/src/main/ets/pages/second/second.ets +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import router from '@system.router'; - -@Entry -@Component -struct Second { - private content: string = "Second Page" - - build() { - Flex({ direction: FlexDirection.Column,alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { - Text(`${this.content}`) - .fontSize(50) - .fontWeight(FontWeight.Bold) - Button() { - Text('back to index') - .fontSize(20) - .fontWeight(FontWeight.Bold) - }.type(ButtonType.Capsule) - .margin({ - top: 20 - }) - .backgroundColor('#0D9FFB') - .onClick(() => { - router.back() - }) - } - .width('100%') - .height('100%') - } -} \ No newline at end of file diff --git a/multimedia/medialibrary/mediaLibrary_fileAsset/entry/src/main/ets/test/List.test.ets b/multimedia/medialibrary/mediaLibrary_fileAsset/entry/src/main/ets/test/List.test.ets old mode 100755 new mode 100644 index 5bc1f5a63430742345656edb5fb5b714070d3919..e97f250242f2cac8235d6dbf677d8566aa18c34b --- a/multimedia/medialibrary/mediaLibrary_fileAsset/entry/src/main/ets/test/List.test.ets +++ b/multimedia/medialibrary/mediaLibrary_fileAsset/entry/src/main/ets/test/List.test.ets @@ -1,25 +1,25 @@ -/* - * 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 fileAssetCallback2 from './fileAssetCallback2.test.ets' -import fileAssetPromise2 from './fileAssetPromise2.test.ets' -import fileAssetTestCallback from './fileAssetTestCallback.test.ets' -import fileAssetTestPromise from './fileAssetTestPromise.test.ets' -export default function testsuite(abilityContext) { - fileAssetCallback2(abilityContext) - fileAssetPromise2(abilityContext) - fileAssetTestCallback(abilityContext) - fileAssetTestPromise(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 fileAssetCallback2 from './fileAssetCallback2.test.ets' +import fileAssetPromise2 from './fileAssetPromise2.test.ets' +import fileAssetTestCallback from './fileAssetTestCallback.test.ets' +import fileAssetTestPromise from './fileAssetTestPromise.test.ets' +export default function testsuite() { + fileAssetCallback2(globalThis.abilityContext) + fileAssetPromise2(globalThis.abilityContext) + fileAssetTestCallback(globalThis.abilityContext) + fileAssetTestPromise(globalThis.abilityContext) +} 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 old mode 100755 new mode 100644 index 060e23bdc7d25fab9c1dc0e396fde2f428a4fab4..f5c6065d21b006ebea2408882185c85f5e6d9bf8 --- 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 @@ -13,9 +13,9 @@ * limitations under the License. */ -import mediaLibrary from '@ohos.multimedia.mediaLibrary'; +import mediaLibrary from "@ohos.multimedia.mediaLibrary"; -import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'; +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "deccjsunit/index"; import { sleep, @@ -25,25 +25,25 @@ import { checkAssetsCount, getPermission, nameFetchOps, -} from '../../../../../../common'; +} from "../../../../../../common"; export default function fileAssetCallback2Test(abilityContext) { - describe('fileAssetCallback2Test', function () { + describe("fileAssetCallback2Test", function () { const media = mediaLibrary.getMediaLibrary(abilityContext); beforeAll(async function () { - console.info('beforeAll case'); - await getPermission(); - await checkPresetsAssets(media, 'ActsMediaLibraryFileAssetTest') + console.info("beforeAll case"); + await getPermission(null, abilityContext); + await checkPresetsAssets(media, "ActsMediaLibraryFileAssetTest"); }); beforeEach(function () { - console.info('beforeEach case'); + console.info("beforeEach case"); }); afterEach(async function () { - console.info('afterEach case'); - await sleep() + console.info("afterEach case"); + await sleep(); }); afterAll(function () { - console.info('afterAll case'); + console.info("afterAll case"); }); const checkCommitModify = async function (done, testNum, fetchOp, prop, val) { @@ -52,19 +52,19 @@ export default function fileAssetCallback2Test(abilityContext) { let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchFileResult, 1); if (!checkAssetCountPass) return; const asset = await fetchFileResult.getFirstObject(); - const oldVal = asset[prop] + const oldVal = asset[prop]; asset[prop] = val; const id = asset.id; asset.commitModify(async (err) => { if (err) { - console.info(`${testNum} err : ${err}`) + console.info(`${testNum} err : ${err}`); expect().assertFail(); done(); return; } let currentfetchOp = { - selections: FILEKEY.ID + '= ?', - selectionArgs: [id + ''], + selections: FILEKEY.ID + "= ?", + selectionArgs: [id + ""], }; const fetchFileResultById = await media.getFileAssets(currentfetchOp); const currentAsset = await fetchFileResultById.getFirstObject(); @@ -74,13 +74,12 @@ export default function fileAssetCallback2Test(abilityContext) { await fetchFileResult.close(); done(); }); - } catch (error) { - console.info(`${testNum} error : ${error}`) + console.info(`${testNum} error : ${error}`); expect(false).assertTrue(); done(); } - } + }; const abnormalCheckCommitModify = async function (done, testNum, fetchOp, prop, val) { try { @@ -91,22 +90,21 @@ export default function fileAssetCallback2Test(abilityContext) { asset[prop] = val; asset.commitModify(async (err) => { if (err) { - console.info(`${testNum} passed : ${err}`) + console.info(`${testNum} passed : ${err}`); expect(true).assertTrue(); done(); return; } expect().assertFail(); - done(); + done(); }); - } catch (error) { - console.info(`${testNum} error : ${error}`) + console.info(`${testNum} error : ${error}`); expect(false).assertTrue(); done(); } - } - + }; + /** * @tc.number : SUB_MEDIA_MEDIALIBRARY_FILEASSET_COMMITMODIFY_CALLBACK_001 * @tc.name : commitModify @@ -115,12 +113,12 @@ export default function fileAssetCallback2Test(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_FILEASSET_COMMITMODIFY_CALLBACK_001', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_FILEASSET_COMMITMODIFY_CALLBACK_001' - let fetchOp = nameFetchOps(testNum, 'Pictures/ModifyCb/', '01.jpg', IMAGE_TYPE); - let prop = 'displayName' - let val = new Date().getTime() + '.jpg' - await checkCommitModify(done, testNum, fetchOp, prop, val) + it("SUB_MEDIA_MEDIALIBRARY_FILEASSET_COMMITMODIFY_CALLBACK_001", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_FILEASSET_COMMITMODIFY_CALLBACK_001"; + let fetchOp = nameFetchOps(testNum, "Pictures/ModifyCb/", "01.jpg", IMAGE_TYPE); + let prop = "displayName"; + let val = new Date().getTime() + ".jpg"; + await checkCommitModify(done, testNum, fetchOp, prop, val); }); /** @@ -131,12 +129,12 @@ export default function fileAssetCallback2Test(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_FILEASSET_COMMITMODIFY_CALLBACK_002', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_FILEASSET_COMMITMODIFY_CALLBACK_002' - let fetchOp = nameFetchOps(testNum, 'Pictures/ModifyCb/', '02.jpg', IMAGE_TYPE); - let prop = 'title' - let val = new Date().getTime() + 'newTitle' - await checkCommitModify(done, testNum, fetchOp, prop, val) + it("SUB_MEDIA_MEDIALIBRARY_FILEASSET_COMMITMODIFY_CALLBACK_002", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_FILEASSET_COMMITMODIFY_CALLBACK_002"; + let fetchOp = nameFetchOps(testNum, "Pictures/ModifyCb/", "02.jpg", IMAGE_TYPE); + let prop = "title"; + let val = new Date().getTime() + "newTitle"; + await checkCommitModify(done, testNum, fetchOp, prop, val); }); /** @@ -147,12 +145,12 @@ export default function fileAssetCallback2Test(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_FILEASSET_COMMITMODIFY_CALLBACK_003', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_FILEASSET_COMMITMODIFY_CALLBACK_003' - let fetchOp = nameFetchOps(testNum, 'Pictures/ModifyCb/', '03.jpg', IMAGE_TYPE); - let prop = 'relativePath' - let val = 'Pictures/Temp/' - await checkCommitModify(done, testNum, fetchOp, prop, val) + it("SUB_MEDIA_MEDIALIBRARY_FILEASSET_COMMITMODIFY_CALLBACK_003", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_FILEASSET_COMMITMODIFY_CALLBACK_003"; + let fetchOp = nameFetchOps(testNum, "Pictures/ModifyCb/", "03.jpg", IMAGE_TYPE); + let prop = "relativePath"; + let val = "Pictures/Temp/"; + await checkCommitModify(done, testNum, fetchOp, prop, val); }); /** @@ -163,13 +161,12 @@ export default function fileAssetCallback2Test(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_FILEASSET_COMMITMODIFY_CALLBACK_004', 0, async function (done) { - - let testNum = 'SUB_MEDIA_MEDIALIBRARY_FILEASSET_COMMITMODIFY_CALLBACK_004' - let fetchOp = nameFetchOps(testNum, 'Pictures/ModifyCb/', '04.jpg', IMAGE_TYPE); - let prop = 'orientation' - let val = 1 - await checkCommitModify(done, testNum, fetchOp, prop, val) + it("SUB_MEDIA_MEDIALIBRARY_FILEASSET_COMMITMODIFY_CALLBACK_004", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_FILEASSET_COMMITMODIFY_CALLBACK_004"; + let fetchOp = nameFetchOps(testNum, "Pictures/ModifyCb/", "04.jpg", IMAGE_TYPE); + let prop = "orientation"; + let val = 1; + await checkCommitModify(done, testNum, fetchOp, prop, val); }); /** @@ -180,16 +177,16 @@ export default function fileAssetCallback2Test(abilityContext) { * @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.jpg', IMAGE_TYPE); - let prop = 'displayName' + 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.jpg", IMAGE_TYPE); + let prop = "displayName"; let val = ""; for (var i = 0; i < 83; i++) { val += "中"; } val += ".jpg"; - await checkCommitModify(done, testNum, fetchOp, prop, val) + await checkCommitModify(done, testNum, fetchOp, prop, val); }); /** @@ -200,16 +197,16 @@ export default function fileAssetCallback2Test(abilityContext) { * @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.jpg', IMAGE_TYPE); - let prop = 'displayName' + 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.jpg", IMAGE_TYPE); + let prop = "displayName"; let val = ""; for (var i = 0; i < 251; i++) { val += "a"; } val += ".jpg"; - await checkCommitModify(done, testNum, fetchOp, prop, val) + await checkCommitModify(done, testNum, fetchOp, prop, val); }); /** @@ -258,16 +255,16 @@ export default function fileAssetCallback2Test(abilityContext) { * @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.jpg', IMAGE_TYPE); - let prop = 'displayName' + 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.jpg", IMAGE_TYPE); + let prop = "displayName"; let val = ""; for (var i = 0; i < 84; i++) { val += "中"; } val += ".jpg"; - await abnormalCheckCommitModify(done, testNum, fetchOp, prop, val) + await abnormalCheckCommitModify(done, testNum, fetchOp, prop, val); }); /** @@ -278,19 +275,19 @@ export default function fileAssetCallback2Test(abilityContext) { * @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.jpg', IMAGE_TYPE); - let prop = 'displayName' + 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.jpg", IMAGE_TYPE); + let prop = "displayName"; let val = ""; for (var i = 0; i < 252; i++) { val += "a"; } val += ".jpg"; - await abnormalCheckCommitModify(done, testNum, fetchOp, prop, val) + await abnormalCheckCommitModify(done, testNum, fetchOp, prop, val); }); - /** + /** * @tc.number : SUB_MEDIA_MEDIALIBRARY_FILEASSET_COMMITMODIFY_CALLBACK_011 * @tc.name : commitModify * @tc.desc : Modify title '中中....' (86) @@ -308,7 +305,7 @@ export default function fileAssetCallback2Test(abilityContext) { } await abnormalCheckCommitModify(done, testNum, fetchOp, prop, val); }); - + /** * @tc.number : SUB_MEDIA_MEDIALIBRARY_FILEASSET_COMMITMODIFY_CALLBACK_012 * @tc.name : commitModify @@ -336,13 +333,13 @@ export default function fileAssetCallback2Test(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - 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 { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_FILEASSET_ISDIRECTORY_CALLBACK_001' - let fetchOp = nameFetchOps(testNum, 'Pictures/ModifyCb/', '013.jpg', IMAGE_TYPE); + let testNum = "SUB_MEDIA_MEDIALIBRARY_FILEASSET_ISDIRECTORY_CALLBACK_001"; + let fetchOp = nameFetchOps(testNum, "Pictures/ModifyCb/", "013.jpg", IMAGE_TYPE); const fetchFileResult = await media.getFileAssets(fetchOp); const asset = await fetchFileResult.getFirstObject(); - asset.isDirectory((err, isDir) =>{ + asset.isDirectory((err, isDir) => { if (err) { console.info(`${testNum} err : ${err}`); expect().assertFail(); @@ -353,11 +350,10 @@ export default function fileAssetCallback2Test(abilityContext) { done(); }); } catch (error) { - console.info('FileAsset isDirectory 001 failed, message = ' + error); + console.info("FileAsset isDirectory 001 failed, message = " + error); expect(false).assertTrue(); done(); } }); }); } - 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 old mode 100755 new mode 100644 index 4b7db703aae1d54c8bcbd7ce8d16e249857be169..523ed6b4784eb11ae8c7ca76dbee5a170e1a4ffb --- 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 @@ -13,33 +13,27 @@ * limitations under the License. */ -import mediaLibrary from '@ohos.multimedia.mediaLibrary'; +import mediaLibrary from "@ohos.multimedia.mediaLibrary"; -import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'; +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "deccjsunit/index"; -import { - sleep, - IMAGE_TYPE, - FILEKEY, - checkAssetsCount, - nameFetchOps, -} from '../../../../../../common'; +import { sleep, IMAGE_TYPE, FILEKEY, checkAssetsCount, nameFetchOps } from "../../../../../../common"; export default function fileAssetPromise2Test(abilityContext) { - describe('fileAssetPromise2Test', function () { + describe("fileAssetPromise2Test", function () { const media = mediaLibrary.getMediaLibrary(abilityContext); beforeAll(async function () { - console.info('beforeAll case'); + console.info("beforeAll case"); }); beforeEach(function () { - console.info('beforeEach case'); + console.info("beforeEach case"); }); afterEach(async function () { - console.info('afterEach case'); - await sleep() + console.info("afterEach case"); + await sleep(); }); afterAll(function () { - console.info('afterAll case'); + console.info("afterAll case"); }); const checkCommitModify = async function (done, testNum, fetchOp, prop, val) { @@ -48,13 +42,13 @@ export default function fileAssetPromise2Test(abilityContext) { let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchFileResult, 1); if (!checkAssetCountPass) return; const asset = await fetchFileResult.getFirstObject(); - const oldVal = asset[prop] + const oldVal = asset[prop]; asset[prop] = val; const id = asset.id; await asset.commitModify(); let currentfetchOp = { - selections: FILEKEY.ID + '= ?', - selectionArgs: [id + ''], + selections: FILEKEY.ID + "= ?", + selectionArgs: [id + ""], }; const fetchFileResultById = await media.getFileAssets(currentfetchOp); const currentAsset = await fetchFileResultById.getFirstObject(); @@ -65,11 +59,11 @@ export default function fileAssetPromise2Test(abilityContext) { await fetchFileResult.close(); done(); } catch (error) { - console.info(`${testNum} error : ${error}`) + console.info(`${testNum} error : ${error}`); expect(false).assertTrue(); done(); } - } + }; const staticPropsCommitModify = async (done, testNum, fetchOp, prop, val) => { try { const fetchFileResult = await media.getFileAssets(fetchOp); @@ -78,21 +72,21 @@ export default function fileAssetPromise2Test(abilityContext) { const asset = await fetchFileResult.getFirstObject(); try { asset[prop] = val; - console.info(`${testNum} failed`) + console.info(`${testNum} failed`); expect(false).assertTrue(); done(); } catch (error) { - console.info(`${testNum} passed : ${error}`) + console.info(`${testNum} passed : ${error}`); expect(true).assertTrue(); done(); } done(); } catch (error) { - console.info(`${testNum} error : ${error}`) + console.info(`${testNum} error : ${error}`); expect(false).assertTrue(); done(); } - } + }; const abnormalCheckCommitModify = async function (done, testNum, fetchOp, prop, val) { try { @@ -106,16 +100,16 @@ export default function fileAssetPromise2Test(abilityContext) { expect().assertFail(); done(); } catch (error) { - console.info(`${testNum} passed : ${error}`) + console.info(`${testNum} passed : ${error}`); expect(true).assertTrue(); done(); } } catch (error) { - console.info(`${testNum} error : ${error}`) + console.info(`${testNum} error : ${error}`); expect(false).assertTrue(); done(); } - } + }; /** * @tc.number : SUB_MEDIA_MEDIALIBRARY_FILEASSET_COMMITMODIFY_PROMISE_001 @@ -125,12 +119,12 @@ export default function fileAssetPromise2Test(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_FILEASSET_COMMITMODIFY_PROMISE_001', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_FILEASSET_COMMITMODIFY_PROMISE_001' - let fetchOp = nameFetchOps(testNum, 'Pictures/ModifyPro/', '01.jpg', IMAGE_TYPE); - let prop = 'displayName' - let val = new Date().getTime() + '.jpg' - await checkCommitModify(done, testNum, fetchOp, prop, val) + it("SUB_MEDIA_MEDIALIBRARY_FILEASSET_COMMITMODIFY_PROMISE_001", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_FILEASSET_COMMITMODIFY_PROMISE_001"; + let fetchOp = nameFetchOps(testNum, "Pictures/ModifyPro/", "01.jpg", IMAGE_TYPE); + let prop = "displayName"; + let val = new Date().getTime() + ".jpg"; + await checkCommitModify(done, testNum, fetchOp, prop, val); }); /** @@ -141,12 +135,12 @@ export default function fileAssetPromise2Test(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_FILEASSET_COMMITMODIFY_PROMISE_002', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_FILEASSET_COMMITMODIFY_PROMISE_002' - let fetchOp = nameFetchOps(testNum, 'Pictures/ModifyPro/', '02.jpg', IMAGE_TYPE); - let prop = 'title' - let val = new Date().getTime() + 'newTitle' - await checkCommitModify(done, testNum, fetchOp, prop, val) + it("SUB_MEDIA_MEDIALIBRARY_FILEASSET_COMMITMODIFY_PROMISE_002", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_FILEASSET_COMMITMODIFY_PROMISE_002"; + let fetchOp = nameFetchOps(testNum, "Pictures/ModifyPro/", "02.jpg", IMAGE_TYPE); + let prop = "title"; + let val = new Date().getTime() + "newTitle"; + await checkCommitModify(done, testNum, fetchOp, prop, val); }); /** @@ -157,12 +151,12 @@ export default function fileAssetPromise2Test(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_FILEASSET_COMMITMODIFY_PROMISE_003', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_FILEASSET_COMMITMODIFY_PROMISE_003' - let fetchOp = nameFetchOps(testNum, 'Pictures/ModifyPro/', '03.jpg', IMAGE_TYPE); - let prop = 'relativePath' - let val = 'Pictures/Temp/' - await checkCommitModify(done, testNum, fetchOp, prop, val) + it("SUB_MEDIA_MEDIALIBRARY_FILEASSET_COMMITMODIFY_PROMISE_003", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_FILEASSET_COMMITMODIFY_PROMISE_003"; + let fetchOp = nameFetchOps(testNum, "Pictures/ModifyPro/", "03.jpg", IMAGE_TYPE); + let prop = "relativePath"; + let val = "Pictures/Temp/"; + await checkCommitModify(done, testNum, fetchOp, prop, val); }); /** @@ -173,12 +167,12 @@ export default function fileAssetPromise2Test(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_FILEASSET_COMMITMODIFY_PROMISE_004', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_FILEASSET_COMMITMODIFY_PROMISE_004' - let fetchOp = nameFetchOps(testNum, 'Pictures/ModifyPro/', '04.jpg', IMAGE_TYPE); - let prop = 'orientation' - let val = 1 - await checkCommitModify(done, testNum, fetchOp, prop, val) + it("SUB_MEDIA_MEDIALIBRARY_FILEASSET_COMMITMODIFY_PROMISE_004", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_FILEASSET_COMMITMODIFY_PROMISE_004"; + let fetchOp = nameFetchOps(testNum, "Pictures/ModifyPro/", "04.jpg", IMAGE_TYPE); + let prop = "orientation"; + let val = 1; + await checkCommitModify(done, testNum, fetchOp, prop, val); }); /** @@ -189,16 +183,16 @@ export default function fileAssetPromise2Test(abilityContext) { * @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.jpg', IMAGE_TYPE); - let prop = 'displayName' + 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.jpg", IMAGE_TYPE); + let prop = "displayName"; let val = ""; for (var i = 0; i < 83; i++) { val += "中"; } val += ".jpg"; - await checkCommitModify(done, testNum, fetchOp, prop, val) + await checkCommitModify(done, testNum, fetchOp, prop, val); }); /** @@ -209,19 +203,19 @@ export default function fileAssetPromise2Test(abilityContext) { * @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.jpg', IMAGE_TYPE); - let prop = 'displayName' + 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.jpg", IMAGE_TYPE); + let prop = "displayName"; let val = ""; for (var i = 0; i < 251; i++) { val += "a"; } val += ".jpg"; - await checkCommitModify(done, testNum, fetchOp, prop, val) + await checkCommitModify(done, testNum, fetchOp, prop, val); }); - - /** + + /** * @tc.number : SUB_MEDIA_MEDIALIBRARY_FILEASSET_COMMITMODIFY_PROMISE_007 * @tc.name : commitModify * @tc.desc : Modify title '中中....' (85) @@ -229,15 +223,15 @@ export default function fileAssetPromise2Test(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_FILEASSET_COMMITMODIFY_PROMISE_007', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_FILEASSET_COMMITMODIFY_PROMISE_007' - let fetchOp = nameFetchOps(testNum, 'Pictures/ModifyPro/', '07.jpg', IMAGE_TYPE); - let prop = 'title' + it("SUB_MEDIA_MEDIALIBRARY_FILEASSET_COMMITMODIFY_PROMISE_007", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_FILEASSET_COMMITMODIFY_PROMISE_007"; + let fetchOp = nameFetchOps(testNum, "Pictures/ModifyPro/", "07.jpg", IMAGE_TYPE); + let prop = "title"; let val = ""; for (var i = 0; i < 85; i++) { val += "中"; } - await checkCommitModify(done, testNum, fetchOp, prop, val) + await checkCommitModify(done, testNum, fetchOp, prop, val); }); /** @@ -267,16 +261,16 @@ export default function fileAssetPromise2Test(abilityContext) { * @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.jpg', IMAGE_TYPE); - let prop = 'displayName' + 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.jpg", IMAGE_TYPE); + let prop = "displayName"; let val = ""; for (var i = 0; i < 84; i++) { val += "中"; } val += ".jpg"; - await abnormalCheckCommitModify(done, testNum, fetchOp, prop, val) + await abnormalCheckCommitModify(done, testNum, fetchOp, prop, val); }); /** @@ -287,16 +281,16 @@ export default function fileAssetPromise2Test(abilityContext) { * @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.jpg', IMAGE_TYPE); - let prop = 'displayName' + 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.jpg", IMAGE_TYPE); + let prop = "displayName"; let val = ""; for (var i = 0; i < 252; i++) { val += "a"; } val += ".jpg"; - await abnormalCheckCommitModify(done, testNum, fetchOp, prop, val) + await abnormalCheckCommitModify(done, testNum, fetchOp, prop, val); }); /** @@ -345,12 +339,12 @@ export default function fileAssetPromise2Test(abilityContext) { * @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.jpg', IMAGE_TYPE); - let prop = 'uri' - let val = 'newUri' - await staticPropsCommitModify(done, testNum, fetchOp, prop, val) + 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.jpg", IMAGE_TYPE); + let prop = "uri"; + let val = "newUri"; + await staticPropsCommitModify(done, testNum, fetchOp, prop, val); }); /** @@ -361,12 +355,12 @@ export default function fileAssetPromise2Test(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - 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.jpg', IMAGE_TYPE); - let prop = 'mediaType' - let val = 'newMediaType' - await staticPropsCommitModify(done, testNum, fetchOp, prop, val) + 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.jpg", IMAGE_TYPE); + let prop = "mediaType"; + let val = "newMediaType"; + await staticPropsCommitModify(done, testNum, fetchOp, prop, val); }); /** @@ -377,21 +371,20 @@ export default function fileAssetPromise2Test(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - 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 { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_FILEASSET_ISDIRECTORY_PROMISE_001' - let fetchOp = nameFetchOps(testNum, 'Pictures/ModifyPro/', '015.jpg', IMAGE_TYPE); + let testNum = "SUB_MEDIA_MEDIALIBRARY_FILEASSET_ISDIRECTORY_PROMISE_001"; + let fetchOp = nameFetchOps(testNum, "Pictures/ModifyPro/", "015.jpg", IMAGE_TYPE); const fetchFileResult = await media.getFileAssets(fetchOp); const asset = await fetchFileResult.getFirstObject(); const isDir = await asset.isDirectory(); expect(isDir).assertEqual(false); done(); } catch (error) { - console.info('FileAsset isDirectory 001 failed, message = ' + error); + console.info("FileAsset isDirectory 001 failed, message = " + error); expect(false).assertTrue(); done(); } }); }); } - diff --git a/multimedia/medialibrary/mediaLibrary_fileAsset/entry/src/main/ets/test/fileAssetTestCallback.test.ets b/multimedia/medialibrary/mediaLibrary_fileAsset/entry/src/main/ets/test/fileAssetTestCallback.test.ets old mode 100755 new mode 100644 index 45707f4637927a9d2e151723b5ef315380de4893..980846a2d59ab45009a726f4f39956c7dadeecec --- a/multimedia/medialibrary/mediaLibrary_fileAsset/entry/src/main/ets/test/fileAssetTestCallback.test.ets +++ b/multimedia/medialibrary/mediaLibrary_fileAsset/entry/src/main/ets/test/fileAssetTestCallback.test.ets @@ -13,9 +13,9 @@ * limitations under the License. */ -import mediaLibrary from '@ohos.multimedia.mediaLibrary'; -import fileio from '@ohos.fileio'; -import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'; +import mediaLibrary from "@ohos.multimedia.mediaLibrary"; +import fileio from "@ohos.fileio"; +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "deccjsunit/index"; import { sleep, IMAGE_TYPE, @@ -26,22 +26,22 @@ import { fetchOps, isNum, fileIdFetchOps, -} from '../../../../../../common'; +} from "../../../../../../common"; export default function fileAssetTestCallbackTest(abilityContext) { - describe('fileAssetTestCallbackTest', function () { + describe("fileAssetTestCallbackTest", function () { const media = mediaLibrary.getMediaLibrary(abilityContext); beforeAll(async function () { - console.info('beforeAll case'); + console.info("beforeAll case"); }); beforeEach(function () { - console.info('beforeEach case'); + console.info("beforeEach case"); }); afterEach(async function () { - console.info('afterEach case'); - await sleep() + console.info("afterEach case"); + await sleep(); }); afterAll(function () { - console.info('afterAll case'); + console.info("afterAll case"); }); const rwOpenTest = async function (done, testNum, fetchOp, assetProps, expectCount) { @@ -53,7 +53,7 @@ export default function fileAssetTestCallbackTest(abilityContext) { if (!checkAssetCountPass) return; const dataList = await fetchFileResult.getAllObject(); asset = dataList[0]; - asset.open('rw', async (err, fd) => { + asset.open("rw", async (err, fd) => { if (err) { console.info(`${testNum} :: err: ${err}`); expect().assertFail(); @@ -65,14 +65,14 @@ export default function fileAssetTestCallbackTest(abilityContext) { let res = await fileio.read(fd, buf); expect(res.bytesRead).assertEqual(assetProps.bytesRead); asset1 = dataList[1]; - fd1 = await asset1.open('r'); + fd1 = await asset1.open("r"); expect(isNum(fd1)).assertTrue(); let buf1 = new ArrayBuffer(4096); await fileio.read(fd1, buf1); let write = await fileio.write(fd, buf1); expect(write).assertEqual(assetProps.write); - console.info(`res.bytesRead:${res.bytesRead},write:${write}`) - console.info(`fd1:${fd1},fd:${fd}`) + console.info(`res.bytesRead:${res.bytesRead},write:${write}`); + console.info(`fd1:${fd1},fd:${fd}`); await asset.close(fd); await asset1.close(fd1); await sleep(50); @@ -83,7 +83,6 @@ export default function fileAssetTestCallbackTest(abilityContext) { expect(newAsset.dateModified != asset.dateModified).assertTrue(); done(); }); - } catch (error) { console.info(`${testNum} :: error: ${error}`); await asset.close(fd); @@ -91,7 +90,7 @@ export default function fileAssetTestCallbackTest(abilityContext) { expect().assertFail(); done(); } - } + }; const rOpenTest = async function (done, testNum, fetchOp, assetProps, expectCount) { let asset; let fd; @@ -101,7 +100,7 @@ export default function fileAssetTestCallbackTest(abilityContext) { if (!checkAssetCountPass) return; const dataList = await fetchFileResult.getAllObject(); asset = dataList[0]; - asset.open('r', async (err, fd) => { + asset.open("r", async (err, fd) => { if (err) { console.info(`${testNum} :: err: ${err}`); expect().assertFail(); @@ -111,7 +110,7 @@ export default function fileAssetTestCallbackTest(abilityContext) { expect(isNum(fd)).assertTrue(); let buf = new ArrayBuffer(4096); let res = await fileio.read(fd, buf); - console.log(' bytesRead: ' + res.bytesRead) + console.log(" bytesRead: " + res.bytesRead); expect(res.bytesRead).assertEqual(assetProps.bytesRead); try { await fileio.write(fd, buf); @@ -122,20 +121,18 @@ export default function fileAssetTestCallbackTest(abilityContext) { done(); } }); - } catch (error) { console.info(`${testNum} :: error: ${error}`); expect().assertFail(); await asset.close(fd); done(); } - } + }; const wOpenTest = async function (done, testNum, fetchOp, assetProps, expectCount) { let asset, asset1; let fd, fd1; try { - let fetchFileResult = await media.getFileAssets(fetchOp); let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchFileResult, expectCount); if (!checkAssetCountPass) return; @@ -143,7 +140,7 @@ export default function fileAssetTestCallbackTest(abilityContext) { asset = dataList[0]; asset1 = dataList[1]; - asset.open('w', async (err, fd) => { + asset.open("w", async (err, fd) => { if (err) { console.info(`${testNum} :: err: ${err}`); expect().assertFail(); @@ -151,7 +148,7 @@ export default function fileAssetTestCallbackTest(abilityContext) { return; } expect(isNum(fd)).assertTrue(); - fd1 = await asset1.open('r'); + fd1 = await asset1.open("r"); let buf = new ArrayBuffer(4096); await fileio.read(fd1, buf); let write = await fileio.write(fd, buf); @@ -161,14 +158,11 @@ export default function fileAssetTestCallbackTest(abilityContext) { try { await fileio.read(fd, buf1); expect().assertFail(); - } catch (error) { expect(true).assertTrue(); - } done(); }); - } catch (error) { console.info(`${testNum} :: error: ${error}`); expect(false).assertTrue(); @@ -176,7 +170,7 @@ export default function fileAssetTestCallbackTest(abilityContext) { await asset1.close(fd1); done(); } - } + }; const closeTest = async function (done, testNum, fetchOp) { let asset; @@ -186,7 +180,7 @@ export default function fileAssetTestCallbackTest(abilityContext) { let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchFileResult, 2); if (!checkAssetCountPass) return; const asset = await fetchFileResult.getFirstObject(); - fd = await asset.open('r'); + fd = await asset.open("r"); expect(isNum(fd)).assertTrue(); asset.close(fd, async (err) => { if (err) { @@ -195,30 +189,29 @@ export default function fileAssetTestCallbackTest(abilityContext) { done(); return; } - let count = 0 + let count = 0; let buf = new ArrayBuffer(4096); try { await fileio.read(fd, buf); } catch (error) { - count++ + count++; } try { await fileio.write(fd, buf); } catch (error) { - count++ + count++; } - await sleep(1000) + await sleep(1000); expect(count).assertEqual(2); done(); }); - } catch (error) { - console.info(`${testNum} error:${error}`) + console.info(`${testNum} error:${error}`); await asset.close(fd); expect(false).assertTrue(); done(); } - } + }; /** * @tc.number : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_CALLBACK_005_01 @@ -228,15 +221,15 @@ export default function fileAssetTestCallbackTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_CALLBACK_005_01', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_CALLBACK_005_01'; + it("SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_CALLBACK_005_01", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_CALLBACK_005_01"; let assetProps = { bytesRead: 10, write: 4096, - } - let fetchOp = fetchOps(testNum, 'Documents/RW_cb/', FILE_TYPE); + }; + let fetchOp = fetchOps(testNum, "Documents/RW_cb/", FILE_TYPE); let expectCount = 2; - await rwOpenTest(done, testNum, fetchOp, assetProps, expectCount) + await rwOpenTest(done, testNum, fetchOp, assetProps, expectCount); }); /** @@ -247,15 +240,15 @@ export default function fileAssetTestCallbackTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_CALLBACK_005_02', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_CALLBACK_005_02'; + it("SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_CALLBACK_005_02", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_CALLBACK_005_02"; let assetProps = { bytesRead: 10, write: 4096, - } - let fetchOp = fetchOps(testNum, 'Documents/R_cb/', FILE_TYPE); + }; + let fetchOp = fetchOps(testNum, "Documents/R_cb/", FILE_TYPE); let expectCount = 2; - await rOpenTest(done, testNum, fetchOp, assetProps, expectCount) + await rOpenTest(done, testNum, fetchOp, assetProps, expectCount); }); /** @@ -266,14 +259,14 @@ export default function fileAssetTestCallbackTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_CALLBACK_005_03', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_CALLBACK_005_03'; + it("SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_CALLBACK_005_03", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_CALLBACK_005_03"; let assetProps = { write: 4096, - } - let fetchOp = fetchOps(testNum, 'Documents/W_cb/', FILE_TYPE); + }; + let fetchOp = fetchOps(testNum, "Documents/W_cb/", FILE_TYPE); let expectCount = 2; - await wOpenTest(done, testNum, fetchOp, assetProps, expectCount) + await wOpenTest(done, testNum, fetchOp, assetProps, expectCount); }); // //======================== FILE END ================================== @@ -287,15 +280,15 @@ export default function fileAssetTestCallbackTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_CALLBACK_005_07', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_CALLBACK_005_07'; + it("SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_CALLBACK_005_07", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_CALLBACK_005_07"; let assetProps = { bytesRead: 4096, write: 4096, - } - let fetchOp = fetchOps(testNum, 'Pictures/RW_cb/', IMAGE_TYPE); + }; + let fetchOp = fetchOps(testNum, "Pictures/RW_cb/", IMAGE_TYPE); let expectCount = 2; - await rwOpenTest(done, testNum, fetchOp, assetProps, expectCount) + await rwOpenTest(done, testNum, fetchOp, assetProps, expectCount); }); /** @@ -306,14 +299,14 @@ export default function fileAssetTestCallbackTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_CALLBACK_005_08', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_CALLBACK_005_08'; + it("SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_CALLBACK_005_08", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_CALLBACK_005_08"; let assetProps = { bytesRead: 4096, - } - let fetchOp = fetchOps(testNum, 'Pictures/R_cb/', IMAGE_TYPE); + }; + let fetchOp = fetchOps(testNum, "Pictures/R_cb/", IMAGE_TYPE); let expectCount = 2; - await rOpenTest(done, testNum, fetchOp, assetProps, expectCount) + await rOpenTest(done, testNum, fetchOp, assetProps, expectCount); }); /** @@ -324,14 +317,14 @@ export default function fileAssetTestCallbackTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_CALLBACK_005_09', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_CALLBACK_005_09'; + it("SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_CALLBACK_005_09", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_CALLBACK_005_09"; let assetProps = { write: 4096, - } - let fetchOp = fetchOps(testNum, 'Pictures/W_cb/', IMAGE_TYPE); + }; + let fetchOp = fetchOps(testNum, "Pictures/W_cb/", IMAGE_TYPE); let expectCount = 2; - await wOpenTest(done, testNum, fetchOp, assetProps, expectCount) + await wOpenTest(done, testNum, fetchOp, assetProps, expectCount); }); //======================== IMAGE END ================================== @@ -345,15 +338,15 @@ export default function fileAssetTestCallbackTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_CALLBACK_005_10', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_CALLBACK_005_10'; + it("SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_CALLBACK_005_10", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_CALLBACK_005_10"; let assetProps = { bytesRead: 4096, write: 4096, - } - let fetchOp = fetchOps(testNum, 'Audios/RW_cb/', AUDIO_TYPE); + }; + let fetchOp = fetchOps(testNum, "Audios/RW_cb/", AUDIO_TYPE); let expectCount = 2; - await rwOpenTest(done, testNum, fetchOp, assetProps, expectCount) + await rwOpenTest(done, testNum, fetchOp, assetProps, expectCount); }); /** @@ -364,14 +357,14 @@ export default function fileAssetTestCallbackTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_CALLBACK_005_11', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_CALLBACK_005_11'; + it("SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_CALLBACK_005_11", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_CALLBACK_005_11"; let assetProps = { bytesRead: 4096, - } - let fetchOp = fetchOps(testNum, 'Audios/R_cb/', AUDIO_TYPE); + }; + let fetchOp = fetchOps(testNum, "Audios/R_cb/", AUDIO_TYPE); let expectCount = 2; - await rOpenTest(done, testNum, fetchOp, assetProps, expectCount) + await rOpenTest(done, testNum, fetchOp, assetProps, expectCount); }); /** @@ -382,14 +375,14 @@ export default function fileAssetTestCallbackTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_CALLBACK_005_12', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_CALLBACK_005_12'; + it("SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_CALLBACK_005_12", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_CALLBACK_005_12"; let assetProps = { write: 4096, - } - let fetchOp = fetchOps(testNum, 'Audios/W_cb/', AUDIO_TYPE); + }; + let fetchOp = fetchOps(testNum, "Audios/W_cb/", AUDIO_TYPE); let expectCount = 2; - await wOpenTest(done, testNum, fetchOp, assetProps, expectCount) + await wOpenTest(done, testNum, fetchOp, assetProps, expectCount); }); //======================== AUDIO END ================================== @@ -403,15 +396,15 @@ export default function fileAssetTestCallbackTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_CALLBACK_005_13', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_CALLBACK_005_13'; + it("SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_CALLBACK_005_13", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_CALLBACK_005_13"; let assetProps = { bytesRead: 4096, write: 4096, - } - let fetchOp = fetchOps(testNum, 'Videos/RW_cb/', VIDEO_TYPE); + }; + let fetchOp = fetchOps(testNum, "Videos/RW_cb/", VIDEO_TYPE); let expectCount = 2; - await rwOpenTest(done, testNum, fetchOp, assetProps, expectCount) + await rwOpenTest(done, testNum, fetchOp, assetProps, expectCount); }); /** @@ -422,14 +415,14 @@ export default function fileAssetTestCallbackTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_CALLBACK_005_14', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_CALLBACK_005_14'; + it("SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_CALLBACK_005_14", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_CALLBACK_005_14"; let assetProps = { bytesRead: 4096, - } - let fetchOp = fetchOps(testNum, 'Videos/R_cb/', VIDEO_TYPE); + }; + let fetchOp = fetchOps(testNum, "Videos/R_cb/", VIDEO_TYPE); let expectCount = 2; - await rOpenTest(done, testNum, fetchOp, assetProps, expectCount) + await rOpenTest(done, testNum, fetchOp, assetProps, expectCount); }); /** @@ -440,14 +433,14 @@ export default function fileAssetTestCallbackTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_CALLBACK_005_15', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_CALLBACK_005_15'; + it("SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_CALLBACK_005_15", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_CALLBACK_005_15"; let assetProps = { write: 4096, - } - let fetchOp = fetchOps(testNum, 'Videos/W_cb/', VIDEO_TYPE); + }; + let fetchOp = fetchOps(testNum, "Videos/W_cb/", VIDEO_TYPE); let expectCount = 2; - await wOpenTest(done, testNum, fetchOp, assetProps, expectCount) + await wOpenTest(done, testNum, fetchOp, assetProps, expectCount); }); //======================== VIDEO END ================================== @@ -462,10 +455,10 @@ export default function fileAssetTestCallbackTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_CALLBACK_005_31', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_CALLBACK_005_31' - let fetchOp = fetchOps(testNum, 'Documents/openClose/', FILE_TYPE); - await closeTest(done, testNum, fetchOp) + it("SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_CALLBACK_005_31", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_CALLBACK_005_31"; + let fetchOp = fetchOps(testNum, "Documents/openClose/", FILE_TYPE); + await closeTest(done, testNum, fetchOp); }); /** @@ -476,10 +469,10 @@ export default function fileAssetTestCallbackTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_CALLBACK_005_33', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_CALLBACK_005_33' - let fetchOp = fetchOps(testNum, 'Pictures/openClose/', IMAGE_TYPE); - await closeTest(done, testNum, fetchOp) + it("SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_CALLBACK_005_33", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_CALLBACK_005_33"; + let fetchOp = fetchOps(testNum, "Pictures/openClose/", IMAGE_TYPE); + await closeTest(done, testNum, fetchOp); }); /** @@ -490,10 +483,10 @@ export default function fileAssetTestCallbackTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_CALLBACK_005_34', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_CALLBACK_005_34' - let fetchOp = fetchOps(testNum, 'Audios/openClose/', AUDIO_TYPE); - await closeTest(done, testNum, fetchOp) + it("SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_CALLBACK_005_34", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_CALLBACK_005_34"; + let fetchOp = fetchOps(testNum, "Audios/openClose/", AUDIO_TYPE); + await closeTest(done, testNum, fetchOp); }); /** @@ -504,10 +497,10 @@ export default function fileAssetTestCallbackTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_CALLBACK_005_35', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_CALLBACK_005_35' - let fetchOp = fetchOps(testNum, 'Videos/openClose/', VIDEO_TYPE); - await closeTest(done, testNum, fetchOp) + it("SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_CALLBACK_005_35", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_CALLBACK_005_35"; + let fetchOp = fetchOps(testNum, "Videos/openClose/", VIDEO_TYPE); + await closeTest(done, testNum, fetchOp); }); //======================== CLOSE BEGIN ================================ diff --git a/multimedia/medialibrary/mediaLibrary_fileAsset/entry/src/main/ets/test/fileAssetTestPromise.test.ets b/multimedia/medialibrary/mediaLibrary_fileAsset/entry/src/main/ets/test/fileAssetTestPromise.test.ets old mode 100755 new mode 100644 index 3c3b14f38cc9ab52acbe0ee526ecd2f0fa9b33b7..9da87258ca8162f3e539eb6e4594eee07e11b623 --- a/multimedia/medialibrary/mediaLibrary_fileAsset/entry/src/main/ets/test/fileAssetTestPromise.test.ets +++ b/multimedia/medialibrary/mediaLibrary_fileAsset/entry/src/main/ets/test/fileAssetTestPromise.test.ets @@ -13,9 +13,9 @@ * limitations under the License. */ -import mediaLibrary from '@ohos.multimedia.mediaLibrary'; -import fileio from '@ohos.fileio'; -import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'; +import mediaLibrary from "@ohos.multimedia.mediaLibrary"; +import fileio from "@ohos.fileio"; +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "deccjsunit/index"; import { sleep, IMAGE_TYPE, @@ -26,22 +26,22 @@ import { fetchOps, isNum, fileIdFetchOps, -} from '../../../../../../common'; +} from "../../../../../../common"; export default function fileAssetTestPromiseTest(abilityContext) { - describe('fileAssetTestPromiseTest', function () { + describe("fileAssetTestPromiseTest", function () { const media = mediaLibrary.getMediaLibrary(abilityContext); beforeAll(async function () { - console.info('beforeAll case'); + console.info("beforeAll case"); }); beforeEach(function () { - console.info('beforeEach case'); + console.info("beforeEach case"); }); afterEach(async function () { - console.info('afterEach case'); - await sleep() + console.info("afterEach case"); + await sleep(); }); afterAll(function () { - console.info('afterAll case'); + console.info("afterAll case"); }); const rwOpenTest = async function (done, testNum, fetchOp, assetProps, expectCount) { @@ -53,20 +53,20 @@ export default function fileAssetTestPromiseTest(abilityContext) { if (!checkAssetCountPass) return; const dataList = await fetchFileResult.getAllObject(); asset = dataList[0]; - fd = await asset.open('rw'); + fd = await asset.open("rw"); expect(isNum(fd)).assertTrue(); let buf = new ArrayBuffer(4096); let res = await fileio.read(fd, buf); expect(res.bytesRead).assertEqual(assetProps.bytesRead); asset1 = dataList[1]; - fd1 = await asset1.open('r'); + fd1 = await asset1.open("r"); expect(isNum(fd1)).assertTrue(); let buf1 = new ArrayBuffer(4096); await fileio.read(fd1, buf1); let write = await fileio.write(fd, buf1); expect(write).assertEqual(assetProps.write); - console.info(`res.bytesRead:${res.bytesRead},write:${write}`) - console.info(`fd1:${fd1},fd:${fd}`) + console.info(`res.bytesRead:${res.bytesRead},write:${write}`); + console.info(`fd1:${fd1},fd:${fd}`); await asset.close(fd); await asset1.close(fd1); await sleep(50); @@ -83,7 +83,7 @@ export default function fileAssetTestPromiseTest(abilityContext) { expect().assertFail(); done(); } - } + }; const rOpenTest = async function (done, testNum, fetchOp, assetProps, expectCount) { let asset; let fd; @@ -93,11 +93,11 @@ export default function fileAssetTestPromiseTest(abilityContext) { if (!checkAssetCountPass) return; const dataList = await fetchFileResult.getAllObject(); asset = dataList[0]; - fd = await asset.open('r'); + fd = await asset.open("r"); expect(isNum(fd)).assertTrue(); let buf = new ArrayBuffer(4096); let res = await fileio.read(fd, buf); - console.log(' bytesRead: ' + res.bytesRead) + console.log(" bytesRead: " + res.bytesRead); expect(res.bytesRead).assertEqual(assetProps.bytesRead); try { await fileio.write(fd, buf); @@ -113,13 +113,12 @@ export default function fileAssetTestPromiseTest(abilityContext) { await asset.close(fd); done(); } - } + }; const wOpenTest = async function (done, testNum, fetchOp, assetProps, expectCount) { let asset, asset1; let fd, fd1; try { - let fetchFileResult = await media.getFileAssets(fetchOp); let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchFileResult, expectCount); if (!checkAssetCountPass) return; @@ -127,9 +126,9 @@ export default function fileAssetTestPromiseTest(abilityContext) { asset = dataList[0]; asset1 = dataList[1]; - fd = await asset.open('w'); + fd = await asset.open("w"); expect(isNum(fd)).assertTrue(); - fd1 = await asset1.open('r'); + fd1 = await asset1.open("r"); let buf = new ArrayBuffer(4096); await fileio.read(fd1, buf); let write = await fileio.write(fd, buf); @@ -139,10 +138,8 @@ export default function fileAssetTestPromiseTest(abilityContext) { try { await fileio.read(fd, buf1); expect().assertFail(); - } catch (error) { expect(true).assertTrue(); - } done(); } catch (error) { @@ -152,7 +149,7 @@ export default function fileAssetTestPromiseTest(abilityContext) { await asset1.close(fd1); done(); } - } + }; const closeTest = async function (done, testNum, fetchOp) { let asset; @@ -162,31 +159,31 @@ export default function fileAssetTestPromiseTest(abilityContext) { let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchFileResult, 2); if (!checkAssetCountPass) return; const asset = await fetchFileResult.getFirstObject(); - fd = await asset.open('r'); + fd = await asset.open("r"); expect(isNum(fd)).assertTrue(); await asset.close(fd); - let count = 0 + let count = 0; let buf = new ArrayBuffer(4096); try { await fileio.read(fd, buf); } catch (error) { - count++ + count++; } try { await fileio.write(fd, buf); } catch (error) { - count++ + count++; } - await sleep(1000) + await sleep(1000); expect(count).assertEqual(2); done(); } catch (error) { - console.info(`${testNum} error:${error}`) + console.info(`${testNum} error:${error}`); await asset.close(fd); expect(false).assertTrue(); done(); } - } + }; /** * @tc.number : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_01 @@ -196,15 +193,15 @@ export default function fileAssetTestPromiseTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_01', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_01'; + it("SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_01", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_01"; let assetProps = { bytesRead: 10, write: 4096, - } - let fetchOp = fetchOps(testNum, 'Documents/RW/', FILE_TYPE); + }; + let fetchOp = fetchOps(testNum, "Documents/RW/", FILE_TYPE); let expectCount = 2; - await rwOpenTest(done, testNum, fetchOp, assetProps, expectCount) + await rwOpenTest(done, testNum, fetchOp, assetProps, expectCount); }); /** @@ -215,15 +212,15 @@ export default function fileAssetTestPromiseTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_02', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_02'; + it("SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_02", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_02"; let assetProps = { bytesRead: 10, write: 4096, - } - let fetchOp = fetchOps(testNum, 'Documents/R/', FILE_TYPE); + }; + let fetchOp = fetchOps(testNum, "Documents/R/", FILE_TYPE); let expectCount = 2; - await rOpenTest(done, testNum, fetchOp, assetProps, expectCount) + await rOpenTest(done, testNum, fetchOp, assetProps, expectCount); }); /** @@ -234,14 +231,14 @@ export default function fileAssetTestPromiseTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_03', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_03'; + it("SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_03", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_03"; let assetProps = { write: 4096, - } - let fetchOp = fetchOps(testNum, 'Documents/W/', FILE_TYPE); + }; + let fetchOp = fetchOps(testNum, "Documents/W/", FILE_TYPE); let expectCount = 2; - await wOpenTest(done, testNum, fetchOp, assetProps, expectCount) + await wOpenTest(done, testNum, fetchOp, assetProps, expectCount); }); // //======================== FILE END ================================== @@ -255,15 +252,15 @@ export default function fileAssetTestPromiseTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_07', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_07'; + it("SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_07", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_07"; let assetProps = { bytesRead: 4096, write: 4096, - } - let fetchOp = fetchOps(testNum, 'Pictures/RW/', IMAGE_TYPE); + }; + let fetchOp = fetchOps(testNum, "Pictures/RW/", IMAGE_TYPE); let expectCount = 2; - await rwOpenTest(done, testNum, fetchOp, assetProps, expectCount) + await rwOpenTest(done, testNum, fetchOp, assetProps, expectCount); }); /** @@ -274,14 +271,14 @@ export default function fileAssetTestPromiseTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_08', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_08'; + it("SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_08", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_08"; let assetProps = { bytesRead: 4096, - } - let fetchOp = fetchOps(testNum, 'Pictures/R/', IMAGE_TYPE); + }; + let fetchOp = fetchOps(testNum, "Pictures/R/", IMAGE_TYPE); let expectCount = 2; - await rOpenTest(done, testNum, fetchOp, assetProps, expectCount) + await rOpenTest(done, testNum, fetchOp, assetProps, expectCount); }); /** @@ -292,14 +289,14 @@ export default function fileAssetTestPromiseTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_09', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_09'; + it("SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_09", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_09"; let assetProps = { write: 4096, - } - let fetchOp = fetchOps(testNum, 'Pictures/W/', IMAGE_TYPE); + }; + let fetchOp = fetchOps(testNum, "Pictures/W/", IMAGE_TYPE); let expectCount = 2; - await wOpenTest(done, testNum, fetchOp, assetProps, expectCount) + await wOpenTest(done, testNum, fetchOp, assetProps, expectCount); }); //======================== IMAGE END ================================== @@ -313,15 +310,15 @@ export default function fileAssetTestPromiseTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_10', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_10'; + it("SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_10", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_10"; let assetProps = { bytesRead: 4096, write: 4096, - } - let fetchOp = fetchOps(testNum, 'Audios/RW/', AUDIO_TYPE); + }; + let fetchOp = fetchOps(testNum, "Audios/RW/", AUDIO_TYPE); let expectCount = 2; - await rwOpenTest(done, testNum, fetchOp, assetProps, expectCount) + await rwOpenTest(done, testNum, fetchOp, assetProps, expectCount); }); /** @@ -332,14 +329,14 @@ export default function fileAssetTestPromiseTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_11', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_11'; + it("SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_11", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_11"; let assetProps = { bytesRead: 4096, - } - let fetchOp = fetchOps(testNum, 'Audios/R/', AUDIO_TYPE); + }; + let fetchOp = fetchOps(testNum, "Audios/R/", AUDIO_TYPE); let expectCount = 2; - await rOpenTest(done, testNum, fetchOp, assetProps, expectCount) + await rOpenTest(done, testNum, fetchOp, assetProps, expectCount); }); /** @@ -350,14 +347,14 @@ export default function fileAssetTestPromiseTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_12', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_12'; + it("SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_12", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_12"; let assetProps = { write: 4096, - } - let fetchOp = fetchOps(testNum, 'Audios/W/', AUDIO_TYPE); + }; + let fetchOp = fetchOps(testNum, "Audios/W/", AUDIO_TYPE); let expectCount = 2; - await wOpenTest(done, testNum, fetchOp, assetProps, expectCount) + await wOpenTest(done, testNum, fetchOp, assetProps, expectCount); }); //======================== AUDIO END ================================== @@ -371,15 +368,15 @@ export default function fileAssetTestPromiseTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_13', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_13'; + it("SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_13", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_13"; let assetProps = { bytesRead: 4096, write: 4096, - } - let fetchOp = fetchOps(testNum, 'Videos/RW/', VIDEO_TYPE); + }; + let fetchOp = fetchOps(testNum, "Videos/RW/", VIDEO_TYPE); let expectCount = 2; - await rwOpenTest(done, testNum, fetchOp, assetProps, expectCount) + await rwOpenTest(done, testNum, fetchOp, assetProps, expectCount); }); /** @@ -390,14 +387,14 @@ export default function fileAssetTestPromiseTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_14', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_14'; + it("SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_14", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_14"; let assetProps = { bytesRead: 4096, - } - let fetchOp = fetchOps(testNum, 'Videos/R/', VIDEO_TYPE); + }; + let fetchOp = fetchOps(testNum, "Videos/R/", VIDEO_TYPE); let expectCount = 2; - await rOpenTest(done, testNum, fetchOp, assetProps, expectCount) + await rOpenTest(done, testNum, fetchOp, assetProps, expectCount); }); /** @@ -408,14 +405,14 @@ export default function fileAssetTestPromiseTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_15', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_15'; + it("SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_15", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_15"; let assetProps = { write: 4096, - } - let fetchOp = fetchOps(testNum, 'Videos/W/', VIDEO_TYPE); + }; + let fetchOp = fetchOps(testNum, "Videos/W/", VIDEO_TYPE); let expectCount = 2; - await wOpenTest(done, testNum, fetchOp, assetProps, expectCount) + await wOpenTest(done, testNum, fetchOp, assetProps, expectCount); }); //======================== VIDEO END ================================== @@ -430,10 +427,10 @@ export default function fileAssetTestPromiseTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_31', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_31' - let fetchOp = fetchOps(testNum, 'Documents/openClose/', FILE_TYPE); - await closeTest(done, testNum, fetchOp) + it("SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_31", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_31"; + let fetchOp = fetchOps(testNum, "Documents/openClose/", FILE_TYPE); + await closeTest(done, testNum, fetchOp); }); /** @@ -444,10 +441,10 @@ export default function fileAssetTestPromiseTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_33', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_33' - let fetchOp = fetchOps(testNum, 'Pictures/openClose/', IMAGE_TYPE); - await closeTest(done, testNum, fetchOp) + it("SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_33", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_33"; + let fetchOp = fetchOps(testNum, "Pictures/openClose/", IMAGE_TYPE); + await closeTest(done, testNum, fetchOp); }); /** @@ -458,10 +455,10 @@ export default function fileAssetTestPromiseTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_34', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_34' - let fetchOp = fetchOps(testNum, 'Audios/openClose/', AUDIO_TYPE); - await closeTest(done, testNum, fetchOp) + it("SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_34", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_34"; + let fetchOp = fetchOps(testNum, "Audios/openClose/", AUDIO_TYPE); + await closeTest(done, testNum, fetchOp); }); /** @@ -472,10 +469,10 @@ export default function fileAssetTestPromiseTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_35', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_35' - let fetchOp = fetchOps(testNum, 'Videos/openClose/', VIDEO_TYPE); - await closeTest(done, testNum, fetchOp) + it("SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_35", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_35"; + let fetchOp = fetchOps(testNum, "Videos/openClose/", VIDEO_TYPE); + await closeTest(done, testNum, fetchOp); }); //======================== CLOSE BEGIN ================================ diff --git a/multimedia/medialibrary/mediaLibrary_fileAsset/entry/src/main/module.json b/multimedia/medialibrary/mediaLibrary_fileAsset/entry/src/main/module.json old mode 100755 new mode 100644 index 6785829959ef1d93e26aaea687a2ec9bb759d52d..025062ffed12b44b32db7f5f35356c9040ed9c5c --- a/multimedia/medialibrary/mediaLibrary_fileAsset/entry/src/main/module.json +++ b/multimedia/medialibrary/mediaLibrary_fileAsset/entry/src/main/module.json @@ -3,11 +3,11 @@ "name": "phone", "type": "entry", "srcEntrance": "./ets/Application/AbilityStage.ts", - "description": "$string:mainability_description", + "description": "$string:phone_entry_dsc", "mainElement": "MainAbility", "deviceTypes": [ - "tablet", - "default", + "tablet", + "default", "phone" ], "deliveryWithInstall": true, @@ -16,11 +16,11 @@ "pages": "$profile:main_pages", "abilities": [ { - "name": "ohos.acts.multimedia.mediaLibrary.MainAbility", + "name": "com.example.myapplication.MainAbility", "srcEntrance": "./ets/MainAbility/MainAbility.ts", - "description": "$string:mainability_description", + "description": "$string:phone_entry_main", "icon": "$media:icon", - "label": "$string:entry_MainAbility", + "label": "$string:entry_label", "visible": true, "orientation": "portrait", "skills": [ @@ -28,42 +28,42 @@ "actions": [ "action.system.home" ], - "entities":[ + "entities": [ "entity.system.home" ] } ] } ], - "requestPermissions": [ + "requestPermissions": [ { "name": "ohos.permission.GET_BUNDLE_INFO", "reason": "use ohos.permission.GET_BUNDLE_INFO" }, { "name": "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED", - "reason":"use ohos.permission.GET_BUNDLE_INFO_PRIVILEGED" + "reason": "use ohos.permission.GET_BUNDLE_INFO_PRIVILEGED" }, { - "name" : "ohos.permission.GRANT_SENSITIVE_PERMISSIONS", - "reason" : "use ohos.permission.GRANT_SENSITIVE_PERMISSIONS" + "name": "ohos.permission.GRANT_SENSITIVE_PERMISSIONS", + "reason": "use ohos.permission.GRANT_SENSITIVE_PERMISSIONS" }, { - "name" : "ohos.permission.REVOKE_SENSITIVE_PERMISSIONS", - "reason" : "use ohos.permission.REVOKE_SENSITIVE_PERMISSIONS" + "name": "ohos.permission.REVOKE_SENSITIVE_PERMISSIONS", + "reason": "use ohos.permission.REVOKE_SENSITIVE_PERMISSIONS" }, { "name": "ohos.permission.MEDIA_LOCATION", - "reason":"use ohos.permission.MEDIA_LOCATION" + "reason": "use ohos.permission.MEDIA_LOCATION" }, { "name": "ohos.permission.READ_MEDIA", - "reason":"use ohos.permission.READ_MEDIA" + "reason": "use ohos.permission.READ_MEDIA" }, { "name": "ohos.permission.WRITE_MEDIA", - "reason":"use ohos.permission.WRITE_MEDIA" + "reason": "use ohos.permission.WRITE_MEDIA" } ] } -} +} \ No newline at end of file diff --git a/multimedia/medialibrary/mediaLibrary_fileAsset/entry/src/main/resources/base/element/string.json b/multimedia/medialibrary/mediaLibrary_fileAsset/entry/src/main/resources/base/element/string.json old mode 100755 new mode 100644 index d75a3fee650de2abaabfd60f40d90d9c6a4b0b0b..2ae43f018e75d1140cf2c0c85a6a14fc369a0c50 --- a/multimedia/medialibrary/mediaLibrary_fileAsset/entry/src/main/resources/base/element/string.json +++ b/multimedia/medialibrary/mediaLibrary_fileAsset/entry/src/main/resources/base/element/string.json @@ -1,12 +1,32 @@ { "string": [ - { - "name": "entry_MainAbility", - "value": "MediaLibraryJSTestMain" - }, - { - "name": "mainability_description", - "value": "MediaLibraryJSTestMain Ability" - } + { + "name": "phone_entry_dsc", + "value": "i am an entry for phone" + }, + { + "name": "phone_entry_main", + "value": "the phone entry ability" + }, + { + "name": "entry_label", + "value": "ActsMediaLibraryTest" + }, + { + "name": "form_description", + "value": "mediaLibrary" + }, + { + "name": "serviceability_description", + "value": "mediaLibrary" + }, + { + "name": "description_application", + "value": "mediaLibrary test" + }, + { + "name": "app_name", + "value": "ActsMediaLibraryTest" + } ] - } \ No newline at end of file +} \ No newline at end of file diff --git a/multimedia/medialibrary/mediaLibrary_fileAsset/entry/src/main/resources/base/profile/main_pages.json b/multimedia/medialibrary/mediaLibrary_fileAsset/entry/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 index 6898b31d2085f478ee1ed9d933a5910cbf901d92..ceb075cd80946aade673d707aac904fb8998bce9 --- a/multimedia/medialibrary/mediaLibrary_fileAsset/entry/src/main/resources/base/profile/main_pages.json +++ b/multimedia/medialibrary/mediaLibrary_fileAsset/entry/src/main/resources/base/profile/main_pages.json @@ -1,6 +1,5 @@ { "src": [ - "pages/index/index", - "pages/second/second" + "MainAbility/pages/index/index" ] } \ No newline at end of file diff --git a/multimedia/medialibrary/mediaLibrary_fileAsset/signature/openharmony_sx.p7b b/multimedia/medialibrary/mediaLibrary_fileAsset/signature/openharmony_sx.p7b old mode 100755 new mode 100644 index 3eb5b5db82a014ff4c9483872cad743ad49a9b6e..64b33bf079b2ab68a3f26f240d127186546b33d9 Binary files a/multimedia/medialibrary/mediaLibrary_fileAsset/signature/openharmony_sx.p7b and b/multimedia/medialibrary/mediaLibrary_fileAsset/signature/openharmony_sx.p7b differ diff --git a/multimedia/medialibrary/mediaLibrary_fileKey/AppScope/app.json b/multimedia/medialibrary/mediaLibrary_fileKey/AppScope/app.json old mode 100755 new mode 100644 index 5139eaad5d5fd2e2de13b4970785d6fa8ae1a4ba..803955ad0d2a5b4ce4e103816a6a917b4701286b --- a/multimedia/medialibrary/mediaLibrary_fileKey/AppScope/app.json +++ b/multimedia/medialibrary/mediaLibrary_fileKey/AppScope/app.json @@ -1,21 +1,21 @@ { - "app":{ - "bundleName":"ohos.acts.multimedia.mediaLibrary", - "vendor":"huawei", - "versionCode":1000000, - "versionName":"1.0.0", - "debug":false, - "icon":"$media:icon", - "label":"$string:entry_MainAbility", - "description":"$string:mainability_description", - "distributedNotificationEnabled":true, - "keepAlive":true, - "singleUser":true, - "minAPIVersion":8, - "targetAPIVersion":8, - "car":{ - "apiCompatibleVersion":8, - "singleUser":false + "app": { + "bundleName": "ohos.acts.multimedia.mediaLibrary", + "vendor": "huawei", + "versionCode": 1000000, + "versionName": "1.0.0", + "debug": false, + "icon": "$media:icon", + "label": "$string:app_name", + "description": "$string:description_application", + "distributedNotificationEnabled": true, + "keepAlive": true, + "singleUser": true, + "minAPIVersion": 9, + "targetAPIVersion": 9, + "car": { + "apiCompatibleVersion": 9, + "singleUser": false } } -} +} \ No newline at end of file diff --git a/multimedia/medialibrary/mediaLibrary_fileKey/AppScope/resources/base/element/string.json b/multimedia/medialibrary/mediaLibrary_fileKey/AppScope/resources/base/element/string.json old mode 100755 new mode 100644 index c1dee63527ae5e3c37f3736f6b68189e8df6f201..ee69f9a861d9dc269ed6638735d52674583498e1 --- a/multimedia/medialibrary/mediaLibrary_fileKey/AppScope/resources/base/element/string.json +++ b/multimedia/medialibrary/mediaLibrary_fileKey/AppScope/resources/base/element/string.json @@ -1,12 +1,8 @@ { - "string": [ + "string":[ { - "name": "entry_MainAbility", - "value": "MediaLibraryJSTestMain" - }, - { - "name": "mainability_description", - "value": "MediaLibraryJSTestMain Ability" + "name":"app_name", + "value":"ohosProject" } ] -} \ No newline at end of file +} \ No newline at end of file diff --git a/multimedia/medialibrary/mediaLibrary_fileKey/BUILD.gn b/multimedia/medialibrary/mediaLibrary_fileKey/BUILD.gn old mode 100755 new mode 100644 index c4d65b026b13b3edba2ee44737b83f9abe9cf984..4a22b8009934215a083b565b6217dfbb32db2b7f --- a/multimedia/medialibrary/mediaLibrary_fileKey/BUILD.gn +++ b/multimedia/medialibrary/mediaLibrary_fileKey/BUILD.gn @@ -15,6 +15,7 @@ import("//test/xts/tools/build/suite.gni") ohos_js_hap_suite("mediaLibrary_fileKey_hap") { hap_profile = "entry/src/main/module.json" + js_build_mode = "debug" deps = [ ":mediaLibrary_js_assets", ":mediaLibrary_resources", diff --git a/multimedia/medialibrary/mediaLibrary_fileKey/Test.json b/multimedia/medialibrary/mediaLibrary_fileKey/Test.json old mode 100755 new mode 100644 index 01c1a1fb320552b5f18f512bf062dcf7cadc807b..0f4d25a123c5ad957897ce11f5e6a1784212b2dc --- a/multimedia/medialibrary/mediaLibrary_fileKey/Test.json +++ b/multimedia/medialibrary/mediaLibrary_fileKey/Test.json @@ -1,10 +1,12 @@ { "description": "Configuration for mediaLibrary Tests", "driver": { - "type": "JSUnitTest", - "test-timeout": "300000", - "package": "ohos.acts.multimedia.mediaLibrary", - "shell-timeout": "600000" + "type": "OHJSUnitTest", + "test-timeout": "180000", + "bundle-name": "ohos.acts.multimedia.mediaLibrary", + "module-name": "phone", + "shell-timeout": "600000", + "testcase-timeout": 70000 }, "kits": [ { @@ -14,7 +16,10 @@ "rm -rf /storage/media/100/local/files/*", "rm -rf /data/app/el2/100/database/com.ohos.medialibrary.medialibrarydata/*", "mkdir -pv /storage/media/100/local/files/{Pictures,Videos,Audios,Documents}", - "mkdir -p /storage/media/100/local/temp" + "mkdir -p /storage/media/100/local/temp", + "power-shell wakeup", + "uinput -T -d 300 600 -m 300 600 300 100 -u 300 100", + "power-shell setmode 602" ] }, { @@ -43,8 +48,9 @@ "scanner", "sleep 10" ], - "teardown-command":[ - "hilog -b X -D 0xD002B70" + "teardown-command": [ + "hilog -b X -D 0xD002B70", + "power-shell setmode 600" ] }, { diff --git a/multimedia/medialibrary/mediaLibrary_fileKey/entry/src/main/ets/Application/AbilityStage.ts b/multimedia/medialibrary/mediaLibrary_fileKey/entry/src/main/ets/Application/AbilityStage.ts old mode 100755 new mode 100644 index 51cb02ba3f5c7011c1cd433d07deebd47a195704..e3fdadfebeeeb676df2ce8f78f4b59e26fae9cf0 --- a/multimedia/medialibrary/mediaLibrary_fileKey/entry/src/main/ets/Application/AbilityStage.ts +++ b/multimedia/medialibrary/mediaLibrary_fileKey/entry/src/main/ets/Application/AbilityStage.ts @@ -3,7 +3,7 @@ import AbilityStage from "@ohos.application.AbilityStage" export default class MyAbilityStage extends AbilityStage { onCreate() { console.log("[Demo] MyAbilityStage onCreate") - globalThis.stageOnCreateRun = 1; - globalThis.stageContext = this.context; + globalThis.stageOnCreateRun = 1; + globalThis.stageContext = this.context; } } diff --git a/multimedia/medialibrary/mediaLibrary_fileKey/entry/src/main/ets/MainAbility/MainAbility.ts b/multimedia/medialibrary/mediaLibrary_fileKey/entry/src/main/ets/MainAbility/MainAbility.ts old mode 100755 new mode 100644 index 2f9d6d1f23f95d9fc891fbc550cd5a589cfb6c89..83c0cd68bb2c044c9b98d212a62851b32bd9af9a --- a/multimedia/medialibrary/mediaLibrary_fileKey/entry/src/main/ets/MainAbility/MainAbility.ts +++ b/multimedia/medialibrary/mediaLibrary_fileKey/entry/src/main/ets/MainAbility/MainAbility.ts @@ -1,7 +1,7 @@ import Ability from '@ohos.application.Ability' export default class MainAbility extends Ability { - onCreate(want,launchParam){ + onCreate(want, launchParam) { // Ability is creating, initialize resources for this ability console.log("[Demo] MainAbility onCreate") globalThis.abilityWant = want; @@ -12,11 +12,11 @@ export default class MainAbility extends Ability { console.log("[Demo] MainAbility onDestroy") } - onWindowStageCreate(windowStage) { - // Main window is created, set main page for this ability - console.log("[Demo] MainAbility onWindowStageCreate") + async onWindowStageCreate(windowStage) { + console.log("[Demo] MainAbility onWindowStageCreate windowStage=" + windowStage) + globalThis.windowStage = windowStage globalThis.abilityContext = this.context - windowStage.setUIContent(this.context, "pages/index/index", null) + windowStage.setUIContent(this.context, "MainAbility/pages/index/index", null) } onWindowStageDestroy() { diff --git a/multimedia/medialibrary/mediaLibrary_fileKey/entry/src/main/ets/MainAbility/pages/index/index.ets b/multimedia/medialibrary/mediaLibrary_fileKey/entry/src/main/ets/MainAbility/pages/index/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..6a8c567d5a86048b1c269e4f00cc288ec136200b --- /dev/null +++ b/multimedia/medialibrary/mediaLibrary_fileKey/entry/src/main/ets/MainAbility/pages/index/index.ets @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import router from '@ohos.router'; +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' +import { Hypium } from '@ohos/hypium' +import testsuite from '../../../test/List.test' + + +@Entry +@Component +struct Index { + + aboutToAppear(){ + console.info("start run testcase!!!!") + var abilityDelegator: any + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var abilityDelegatorArguments: any + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + console.info('start run testcase!!!') + Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) + } + + build() { + Flex({ direction:FlexDirection.Column, alignItems:ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text('Hello World') + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('next page') + .fontSize(25) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .onClick(() => { + + }) + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/multimedia/medialibrary/mediaLibrary_fileKey/entry/src/main/ets/TestAbility/TestAbility.ts b/multimedia/medialibrary/mediaLibrary_fileKey/entry/src/main/ets/TestAbility/TestAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..8028a70f8af44690b95a08bd177bca6b09f24687 --- /dev/null +++ b/multimedia/medialibrary/mediaLibrary_fileKey/entry/src/main/ets/TestAbility/TestAbility.ts @@ -0,0 +1,50 @@ +/* + * 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 Ability from '@ohos.app.ability.UIAbility' + +export default class TestAbility extends Ability { + onCreate(want, launchParam) { + console.log('TestAbility onCreate') + } + + onDestroy() { + console.log('TestAbility onDestroy') + } + + onWindowStageCreate(windowStage) { + console.log('TestAbility onWindowStageCreate') + windowStage.loadContent("TestAbility/pages/index", (err, data) => { + if (err.code) { + console.error('Failed to load the content. Cause:' + JSON.stringify(err)); + return; + } + console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data)) + }); + + globalThis.abilityContext = this.context; + } + + onWindowStageDestroy() { + console.log('TestAbility onWindowStageDestroy') + } + + onForeground() { + console.log('TestAbility onForeground') + } + + onBackground() { + console.log('TestAbility onBackground') + } +}; \ No newline at end of file diff --git a/multimedia/medialibrary/mediaLibrary_fileKey/entry/src/main/ets/TestAbility/pages/index.ets b/multimedia/medialibrary/mediaLibrary_fileKey/entry/src/main/ets/TestAbility/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..b93567f962921124b282f78c8ef123965d1460c9 --- /dev/null +++ b/multimedia/medialibrary/mediaLibrary_fileKey/entry/src/main/ets/TestAbility/pages/index.ets @@ -0,0 +1,48 @@ +/* + * 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 router from '@ohos.router'; + +@Entry +@Component +struct Index { + aboutToAppear() { + console.info('TestAbility index aboutToAppear') + } + @State message: string = 'Hello World' + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('next page') + .fontSize(20) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .width('35%') + .height('5%') + .onClick(()=>{ + }) + } + .width('100%') + } + .height('100%') + } + } \ No newline at end of file diff --git a/multimedia/medialibrary/mediaLibrary_fileKey/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts b/multimedia/medialibrary/mediaLibrary_fileKey/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts new file mode 100644 index 0000000000000000000000000000000000000000..a4ee2f1652b3d04ce83ece64ef70f8dfa62a2dc8 --- /dev/null +++ b/multimedia/medialibrary/mediaLibrary_fileKey/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts @@ -0,0 +1,78 @@ +/* + * 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 TestRunner from '@ohos.application.testRunner' +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' + +var abilityDelegator = undefined +var abilityDelegatorArguments = undefined + +function translateParamsToString(parameters) { + const keySet = new Set([ + '-s class', '-s notClass', '-s suite', '-s it', + '-s level', '-s testType', '-s size', '-s timeout', + '-s dryRun' + ]) + let targetParams = ''; + for (const key in parameters) { + if (keySet.has(key)) { + targetParams = `${targetParams} ${key} ${parameters[key]}` + } + } + return targetParams.trim() +} + +async function onAbilityCreateCallback() { + console.log("onAbilityCreateCallback"); +} + +async function addAbilityMonitorCallback(err: any) { + console.info("addAbilityMonitorCallback : " + JSON.stringify(err)) +} + +export default class OpenHarmonyTestRunner implements TestRunner { + constructor() { + } + + onPrepare() { + console.info("OpenHarmonyTestRunner OnPrepare ") + } + + async onRun() { + console.log('OpenHarmonyTestRunner onRun run') + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var testAbilityName = abilityDelegatorArguments.bundleName + '.MainAbility' + let lMonitor = { + abilityName: testAbilityName, + onAbilityCreate: onAbilityCreateCallback, + }; + abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback) + var cmd = 'aa start -d 0 -a com.example.myapplication.MainAbility' + ' -b ' + abilityDelegatorArguments.bundleName + cmd += ' '+translateParamsToString(abilityDelegatorArguments.parameters) + var debug = abilityDelegatorArguments.parameters["-D"] + if (debug == 'true') + { + cmd += ' -D' + } + console.info('cmd : '+cmd) + abilityDelegator.executeShellCommand(cmd, + (err: any, d: any) => { + console.info('executeShellCommand : err : ' + JSON.stringify(err)); + console.info('executeShellCommand : data : ' + d.stdResult); + console.info('executeShellCommand : data : ' + d.exitCode); + }) + console.info('OpenHarmonyTestRunner onRun end') + } +}; \ No newline at end of file diff --git a/multimedia/medialibrary/mediaLibrary_fileKey/entry/src/main/ets/pages/second/second.ets b/multimedia/medialibrary/mediaLibrary_fileKey/entry/src/main/ets/pages/second/second.ets deleted file mode 100755 index 1c1c727ff11ecc97909f482c35268db87ae23bb4..0000000000000000000000000000000000000000 --- a/multimedia/medialibrary/mediaLibrary_fileKey/entry/src/main/ets/pages/second/second.ets +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import router from '@system.router'; - -@Entry -@Component -struct Second { - private content: string = "Second Page" - - build() { - Flex({ direction: FlexDirection.Column,alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { - Text(`${this.content}`) - .fontSize(50) - .fontWeight(FontWeight.Bold) - Button() { - Text('back to index') - .fontSize(20) - .fontWeight(FontWeight.Bold) - }.type(ButtonType.Capsule) - .margin({ - top: 20 - }) - .backgroundColor('#0D9FFB') - .onClick(() => { - router.back() - }) - } - .width('100%') - .height('100%') - } -} \ No newline at end of file diff --git a/multimedia/medialibrary/mediaLibrary_fileKey/entry/src/main/ets/test/List.test.ets b/multimedia/medialibrary/mediaLibrary_fileKey/entry/src/main/ets/test/List.test.ets old mode 100755 new mode 100644 index 289252e25631403992c31901df7a0211be99381f..aa5ae1507a574f32b48792c6263e6e666b93df6a --- a/multimedia/medialibrary/mediaLibrary_fileKey/entry/src/main/ets/test/List.test.ets +++ b/multimedia/medialibrary/mediaLibrary_fileKey/entry/src/main/ets/test/List.test.ets @@ -1,21 +1,21 @@ -/* - * 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 filekeyTestCallback from './filekeyTestCallback.test.ets' -import filekeyTestPromise from './filekeyTestPromise.test.ets' -export default function testsuite(abilityContext) { - filekeyTestCallback(abilityContext) - filekeyTestPromise(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 filekeyTestCallback from './filekeyTestCallback.test.ets' +import filekeyTestPromise from './filekeyTestPromise.test.ets' +export default function testsuite() { + filekeyTestCallback(globalThis.abilityContext) + filekeyTestPromise(globalThis.abilityContext) +} diff --git a/multimedia/medialibrary/mediaLibrary_fileKey/entry/src/main/ets/test/filekeyTestCallback.test.ets b/multimedia/medialibrary/mediaLibrary_fileKey/entry/src/main/ets/test/filekeyTestCallback.test.ets old mode 100755 new mode 100644 index b836d2bb486284cdc32a6cce95d61c4009986c54..95a8ed88c1f861d2bbf42474e3cd7a9a08fc59f6 --- a/multimedia/medialibrary/mediaLibrary_fileKey/entry/src/main/ets/test/filekeyTestCallback.test.ets +++ b/multimedia/medialibrary/mediaLibrary_fileKey/entry/src/main/ets/test/filekeyTestCallback.test.ets @@ -13,8 +13,8 @@ * limitations under the License. */ -import mediaLibrary from '@ohos.multimedia.mediaLibrary'; -import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'; +import mediaLibrary from "@ohos.multimedia.mediaLibrary"; +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "deccjsunit/index"; import { sleep, @@ -29,48 +29,64 @@ import { } from "../../../../../../common"; export default function filekeyTestCallbackTest(abilityContext) { - describe('filekeyTestCallbackTest', function () { + describe("filekeyTestCallbackTest", function () { const media = mediaLibrary.getMediaLibrary(abilityContext); beforeAll(async function () { - console.info('beforeAll case'); - await getPermission(); - await checkPresetsAssets(media, 'ActsMediaLibraryFileKeyTest') + console.info("beforeAll case"); + await getPermission(null, abilityContext); + await checkPresetsAssets(media, "ActsMediaLibraryFileKeyTest"); }); beforeEach(function () { - console.info('beforeEach case'); + console.info("beforeEach case"); }); afterEach(async function () { - console.info('afterEach case'); - await sleep() + console.info("afterEach case"); + await sleep(); }); afterAll(function () { - console.info('afterAll case'); + console.info("afterAll case"); }); - const { PARENT, MIME_TYPE, SIZE, DATE_ADDED, TITLE, ALBUM_NAME, DURATION, - WIDTH, HEIGHT, ORIENTATION, ALBUM_ID, ARTIST, AUDIOALBUM, DATE_MODIFIED, - DATE_TAKEN, RELATIVE_PATH, DISPLAY_NAME, MEDIA_TYPE + const { + PARENT, + MIME_TYPE, + SIZE, + DATE_ADDED, + TITLE, + ALBUM_NAME, + DURATION, + WIDTH, + HEIGHT, + ORIENTATION, + ALBUM_ID, + ARTIST, + AUDIOALBUM, + DATE_MODIFIED, + DATE_TAKEN, + RELATIVE_PATH, + DISPLAY_NAME, + MEDIA_TYPE, } = FILEKEY; async function getFileAssetsBy(done, testNum, type, fileKey) { try { - let assetOp = fetchOps(testNum, 'Pictures/ImageInfo/', IMAGE_TYPE); - if (type == 'audioAlbum' || type == 'artist' || type == 'duration') { - assetOp = fetchOps(testNum, 'Audios/Static/', AUDIO_TYPE); + let assetOp = fetchOps(testNum, "Pictures/ImageInfo/", IMAGE_TYPE); + if (type == "audioAlbum" || type == "artist" || type == "duration") { + assetOp = fetchOps(testNum, "Audios/Static/", AUDIO_TYPE); } - console.info(`${testNum} assOp : ${JSON.stringify(assetOp)}`) + console.info(`${testNum} assOp : ${JSON.stringify(assetOp)}`); let fetchFileResult = await media.getFileAssets(assetOp); let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchFileResult, 1); if (!checkAssetCountPass) return; const asset = await fetchFileResult.getFirstObject(); let Op = { - selections: fileKey + '= ?', - selectionArgs: [asset[type] + ''], + selections: fileKey + "= ?", + selectionArgs: [asset[type] + ""], }; media.getFileAssets(Op, async (err, fetchFileResult) => { if (err) { - console.info(`${testNum}, err: ${err}`) + console.info(`${testNum}, err: ${err}`); expect(false).assertTrue(); done(); return; @@ -82,7 +98,7 @@ export default function filekeyTestCallbackTest(abilityContext) { done(); }); } catch (error) { - console.info(`${testNum} error : ${error}`) + console.info(`${testNum} error : ${error}`); expect(false).assertTrue(); done(); } @@ -97,9 +113,9 @@ export default function filekeyTestCallbackTest(abilityContext) { * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_001', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_001' - await getFileAssetsBy(done, testNum, 'parent', PARENT); + it("SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_001", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_001"; + await getFileAssetsBy(done, testNum, "parent", PARENT); }); /** @@ -110,9 +126,9 @@ export default function filekeyTestCallbackTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_002', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_002' - await getFileAssetsBy(done, testNum, 'mimeType', MIME_TYPE); + it("SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_002", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_002"; + await getFileAssetsBy(done, testNum, "mimeType", MIME_TYPE); }); /** @@ -123,9 +139,9 @@ export default function filekeyTestCallbackTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_003', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_003' - await getFileAssetsBy(done, testNum, 'size', SIZE); + it("SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_003", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_003"; + await getFileAssetsBy(done, testNum, "size", SIZE); }); /** @@ -136,9 +152,9 @@ export default function filekeyTestCallbackTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_004', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_004' - await getFileAssetsBy(done, testNum, 'dateAdded', DATE_ADDED); + it("SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_004", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_004"; + await getFileAssetsBy(done, testNum, "dateAdded", DATE_ADDED); }); /** @@ -149,9 +165,9 @@ export default function filekeyTestCallbackTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_005', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_005' - await getFileAssetsBy(done, testNum, 'dateModified', DATE_MODIFIED); + it("SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_005", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_005"; + await getFileAssetsBy(done, testNum, "dateModified", DATE_MODIFIED); }); /** @@ -162,9 +178,9 @@ export default function filekeyTestCallbackTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_006', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_006' - await getFileAssetsBy(done, testNum, 'dateTaken', DATE_TAKEN); + it("SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_006", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_006"; + await getFileAssetsBy(done, testNum, "dateTaken", DATE_TAKEN); }); /** @@ -175,9 +191,9 @@ export default function filekeyTestCallbackTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_007', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_007' - await getFileAssetsBy(done, testNum, 'title', TITLE,); + it("SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_007", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_007"; + await getFileAssetsBy(done, testNum, "title", TITLE); }); /** @@ -188,9 +204,9 @@ export default function filekeyTestCallbackTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_008', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_008' - await getFileAssetsBy(done, testNum, 'duration', DURATION); + it("SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_008", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_008"; + await getFileAssetsBy(done, testNum, "duration", DURATION); }); /** @@ -201,9 +217,9 @@ export default function filekeyTestCallbackTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_009', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_009' - await getFileAssetsBy(done, testNum, 'width', WIDTH); + it("SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_009", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_009"; + await getFileAssetsBy(done, testNum, "width", WIDTH); }); /** @@ -214,9 +230,9 @@ export default function filekeyTestCallbackTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_010', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_010' - await getFileAssetsBy(done, testNum, 'height', HEIGHT); + it("SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_010", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_010"; + await getFileAssetsBy(done, testNum, "height", HEIGHT); }); /** @@ -227,9 +243,9 @@ export default function filekeyTestCallbackTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_011', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_011' - await getFileAssetsBy(done, testNum, 'orientation', ORIENTATION); + it("SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_011", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_011"; + await getFileAssetsBy(done, testNum, "orientation", ORIENTATION); }); /** @@ -240,9 +256,9 @@ export default function filekeyTestCallbackTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_012', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_012' - await getFileAssetsBy(done, testNum, 'albumId', ALBUM_ID); + it("SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_012", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_012"; + await getFileAssetsBy(done, testNum, "albumId", ALBUM_ID); }); /** @@ -253,9 +269,9 @@ export default function filekeyTestCallbackTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_014', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_014' - await getFileAssetsBy(done, testNum, 'artist', ARTIST); + it("SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_014", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_014"; + await getFileAssetsBy(done, testNum, "artist", ARTIST); }); /** @@ -266,22 +282,22 @@ export default function filekeyTestCallbackTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_015', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_015' - await getFileAssetsBy(done, testNum, 'audioAlbum', AUDIOALBUM); + it("SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_015", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_015"; + await getFileAssetsBy(done, testNum, "audioAlbum", AUDIOALBUM); }); /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_0016 - * @tc.name : getFileAssets - * @tc.desc : filekey relative_path - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_016', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_016' - await getFileAssetsBy(done, testNum, 'relativePath', RELATIVE_PATH); + * @tc.number : SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_0016 + * @tc.name : getFileAssets + * @tc.desc : filekey relative_path + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it("SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_016", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_016"; + await getFileAssetsBy(done, testNum, "relativePath", RELATIVE_PATH); }); /** @@ -292,9 +308,9 @@ export default function filekeyTestCallbackTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_017', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_017' - await getFileAssetsBy(done, testNum, 'displayName', DISPLAY_NAME); + it("SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_017", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_017"; + await getFileAssetsBy(done, testNum, "displayName", DISPLAY_NAME); }); /** @@ -305,15 +321,15 @@ export default function filekeyTestCallbackTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_018', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_018' + it("SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_018", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_FILE_KEY_CALLBACK_018"; try { - let albumName = 'ImageInfo' + let albumName = "ImageInfo"; let currentFetchOp = { - selections: RELATIVE_PATH + '= ? AND ' + ALBUM_NAME + '= ? AND ' + MEDIA_TYPE + '= ?', - selectionArgs: ['Pictures/', albumName, IMAGE_TYPE.toString()], - } - console.info(`${testNum} currentFetchOp : ${JSON.stringify(currentFetchOp)}`) + selections: RELATIVE_PATH + "= ? AND " + ALBUM_NAME + "= ? AND " + MEDIA_TYPE + "= ?", + selectionArgs: ["Pictures/", albumName, IMAGE_TYPE.toString()], + }; + console.info(`${testNum} currentFetchOp : ${JSON.stringify(currentFetchOp)}`); const albumList = await media.getAlbums(currentFetchOp); const album = albumList[0]; const albumCountPass = await checkAlbumsCount(done, testNum, albumList, 1); @@ -321,12 +337,10 @@ export default function filekeyTestCallbackTest(abilityContext) { expect(album.albumName).assertEqual(albumName); done(); } catch (error) { - console.info(`${testNum} error : ${error}`) + console.info(`${testNum} error : ${error}`); expect(false).assertTrue(); done(); } }); - }); } - diff --git a/multimedia/medialibrary/mediaLibrary_fileKey/entry/src/main/ets/test/filekeyTestPromise.test.ets b/multimedia/medialibrary/mediaLibrary_fileKey/entry/src/main/ets/test/filekeyTestPromise.test.ets old mode 100755 new mode 100644 index 58eb8d7eaaf98088d21efa78063f296d8448d246..6fddd63e11ea4232e57ba60a9eeddde83db3086e --- a/multimedia/medialibrary/mediaLibrary_fileKey/entry/src/main/ets/test/filekeyTestPromise.test.ets +++ b/multimedia/medialibrary/mediaLibrary_fileKey/entry/src/main/ets/test/filekeyTestPromise.test.ets @@ -13,9 +13,9 @@ * limitations under the License. */ -import mediaLibrary from '@ohos.multimedia.mediaLibrary'; +import mediaLibrary from "@ohos.multimedia.mediaLibrary"; -import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'; +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "deccjsunit/index"; import { sleep, @@ -25,46 +25,61 @@ import { FILEKEY, checkAssetsCount, fetchOps, -} from '../../../../../../common'; - +} from "../../../../../../common"; export default function filekeyTestPromiseTest(abilityContext) { - describe('filekeyTestPromiseTest', function () { + describe("filekeyTestPromiseTest", function () { const media = mediaLibrary.getMediaLibrary(abilityContext); beforeAll(async function () { - console.info('beforeAll case'); + console.info("beforeAll case"); }); beforeEach(function () { - console.info('beforeEach case'); + console.info("beforeEach case"); }); afterEach(async function () { - console.info('afterEach case'); - await sleep() + console.info("afterEach case"); + await sleep(); }); afterAll(function () { - console.info('afterAll case'); + console.info("afterAll case"); }); - const { PARENT, MIME_TYPE, SIZE, DATE_ADDED, TITLE, ALBUM_NAME, DURATION, - WIDTH, HEIGHT, ORIENTATION, ALBUM_ID, ARTIST, AUDIOALBUM, DATE_MODIFIED, - DATE_TAKEN, RELATIVE_PATH, DISPLAY_NAME, MEDIA_TYPE + const { + PARENT, + MIME_TYPE, + SIZE, + DATE_ADDED, + TITLE, + ALBUM_NAME, + DURATION, + WIDTH, + HEIGHT, + ORIENTATION, + ALBUM_ID, + ARTIST, + AUDIOALBUM, + DATE_MODIFIED, + DATE_TAKEN, + RELATIVE_PATH, + DISPLAY_NAME, + MEDIA_TYPE, } = FILEKEY; async function getFileAssetsBy(done, testNum, type, fileKey) { try { - let assetOp = fetchOps(testNum, 'Pictures/ImageInfo/', IMAGE_TYPE); - if (type == 'audioAlbum' || type == 'artist' || type == 'duration') { - assetOp = fetchOps(testNum, 'Audios/Static/', AUDIO_TYPE); + let assetOp = fetchOps(testNum, "Pictures/ImageInfo/", IMAGE_TYPE); + if (type == "audioAlbum" || type == "artist" || type == "duration") { + assetOp = fetchOps(testNum, "Audios/Static/", AUDIO_TYPE); } - console.info(`${testNum} assOp : ${JSON.stringify(assetOp)}`) + console.info(`${testNum} assOp : ${JSON.stringify(assetOp)}`); let fetchFileResult = await media.getFileAssets(assetOp); let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchFileResult, 1); if (!checkAssetCountPass) return; const asset = await fetchFileResult.getFirstObject(); let Op = { - selections: fileKey + '= ?', - selectionArgs: [asset[type] + ''], + selections: fileKey + "= ?", + selectionArgs: [asset[type] + ""], }; fetchFileResult = await media.getFileAssets(Op); const fetchCount = fetchFileResult.getCount(); @@ -73,7 +88,7 @@ export default function filekeyTestPromiseTest(abilityContext) { expect(firstObject[type]).assertEqual(asset[type]); done(); } catch (error) { - console.info(`${testNum} error : ${error}`) + console.info(`${testNum} error : ${error}`); expect(false).assertTrue(); done(); } @@ -88,9 +103,9 @@ export default function filekeyTestPromiseTest(abilityContext) { * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_FILE_KEY_PROMISE_001', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_FILE_KEY_PROMISE_001' - await getFileAssetsBy(done, testNum, 'parent', PARENT); + it("SUB_MEDIA_MEDIALIBRARY_FILE_KEY_PROMISE_001", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_FILE_KEY_PROMISE_001"; + await getFileAssetsBy(done, testNum, "parent", PARENT); }); /** @@ -101,9 +116,9 @@ export default function filekeyTestPromiseTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_FILE_KEY_PROMISE_002', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_FILE_KEY_PROMISE_002' - await getFileAssetsBy(done, testNum, 'mimeType', MIME_TYPE); + it("SUB_MEDIA_MEDIALIBRARY_FILE_KEY_PROMISE_002", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_FILE_KEY_PROMISE_002"; + await getFileAssetsBy(done, testNum, "mimeType", MIME_TYPE); }); /** @@ -114,9 +129,9 @@ export default function filekeyTestPromiseTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_FILE_KEY_PROMISE_003', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_FILE_KEY_PROMISE_003' - await getFileAssetsBy(done, testNum, 'size', SIZE); + it("SUB_MEDIA_MEDIALIBRARY_FILE_KEY_PROMISE_003", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_FILE_KEY_PROMISE_003"; + await getFileAssetsBy(done, testNum, "size", SIZE); }); /** @@ -127,9 +142,9 @@ export default function filekeyTestPromiseTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_FILE_KEY_PROMISE_004', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_FILE_KEY_PROMISE_004' - await getFileAssetsBy(done, testNum, 'dateAdded', DATE_ADDED); + it("SUB_MEDIA_MEDIALIBRARY_FILE_KEY_PROMISE_004", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_FILE_KEY_PROMISE_004"; + await getFileAssetsBy(done, testNum, "dateAdded", DATE_ADDED); }); /** @@ -140,9 +155,9 @@ export default function filekeyTestPromiseTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_FILE_KEY_PROMISE_005', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_FILE_KEY_PROMISE_005' - await getFileAssetsBy(done, testNum, 'dateModified', DATE_MODIFIED); + it("SUB_MEDIA_MEDIALIBRARY_FILE_KEY_PROMISE_005", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_FILE_KEY_PROMISE_005"; + await getFileAssetsBy(done, testNum, "dateModified", DATE_MODIFIED); }); /** @@ -153,9 +168,9 @@ export default function filekeyTestPromiseTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_FILE_KEY_PROMISE_006', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_FILE_KEY_PROMISE_006' - await getFileAssetsBy(done, testNum, 'dateTaken', DATE_TAKEN); + it("SUB_MEDIA_MEDIALIBRARY_FILE_KEY_PROMISE_006", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_FILE_KEY_PROMISE_006"; + await getFileAssetsBy(done, testNum, "dateTaken", DATE_TAKEN); }); /** @@ -166,9 +181,9 @@ export default function filekeyTestPromiseTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_FILE_KEY_PROMISE_007', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_FILE_KEY_PROMISE_007' - await getFileAssetsBy(done, testNum, 'title', TITLE,); + it("SUB_MEDIA_MEDIALIBRARY_FILE_KEY_PROMISE_007", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_FILE_KEY_PROMISE_007"; + await getFileAssetsBy(done, testNum, "title", TITLE); }); /** @@ -179,9 +194,9 @@ export default function filekeyTestPromiseTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_FILE_KEY_PROMISE_008', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_FILE_KEY_PROMISE_008' - await getFileAssetsBy(done, testNum, 'duration', DURATION); + it("SUB_MEDIA_MEDIALIBRARY_FILE_KEY_PROMISE_008", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_FILE_KEY_PROMISE_008"; + await getFileAssetsBy(done, testNum, "duration", DURATION); }); /** @@ -192,9 +207,9 @@ export default function filekeyTestPromiseTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_FILE_KEY_PROMISE_009', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_FILE_KEY_PROMISE_009' - await getFileAssetsBy(done, testNum, 'width', WIDTH); + it("SUB_MEDIA_MEDIALIBRARY_FILE_KEY_PROMISE_009", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_FILE_KEY_PROMISE_009"; + await getFileAssetsBy(done, testNum, "width", WIDTH); }); /** @@ -205,9 +220,9 @@ export default function filekeyTestPromiseTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_FILE_KEY_PROMISE_010', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_FILE_KEY_PROMISE_010' - await getFileAssetsBy(done, testNum, 'height', HEIGHT); + it("SUB_MEDIA_MEDIALIBRARY_FILE_KEY_PROMISE_010", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_FILE_KEY_PROMISE_010"; + await getFileAssetsBy(done, testNum, "height", HEIGHT); }); /** @@ -218,9 +233,9 @@ export default function filekeyTestPromiseTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_FILE_KEY_PROMISE_011', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_FILE_KEY_PROMISE_011' - await getFileAssetsBy(done, testNum, 'orientation', ORIENTATION); + it("SUB_MEDIA_MEDIALIBRARY_FILE_KEY_PROMISE_011", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_FILE_KEY_PROMISE_011"; + await getFileAssetsBy(done, testNum, "orientation", ORIENTATION); }); /** @@ -231,9 +246,9 @@ export default function filekeyTestPromiseTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_FILE_KEY_PROMISE_012', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_FILE_KEY_PROMISE_012' - await getFileAssetsBy(done, testNum, 'albumId', ALBUM_ID); + it("SUB_MEDIA_MEDIALIBRARY_FILE_KEY_PROMISE_012", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_FILE_KEY_PROMISE_012"; + await getFileAssetsBy(done, testNum, "albumId", ALBUM_ID); }); /** @@ -244,9 +259,9 @@ export default function filekeyTestPromiseTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_FILE_KEY_PROMISE_014', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_FILE_KEY_PROMISE_014' - await getFileAssetsBy(done, testNum, 'artist', ARTIST); + it("SUB_MEDIA_MEDIALIBRARY_FILE_KEY_PROMISE_014", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_FILE_KEY_PROMISE_014"; + await getFileAssetsBy(done, testNum, "artist", ARTIST); }); /** @@ -257,22 +272,22 @@ export default function filekeyTestPromiseTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_FILE_KEY_PROMISE_015', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_FILE_KEY_PROMISE_015' - await getFileAssetsBy(done, testNum, 'audioAlbum', AUDIOALBUM); + it("SUB_MEDIA_MEDIALIBRARY_FILE_KEY_PROMISE_015", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_FILE_KEY_PROMISE_015"; + await getFileAssetsBy(done, testNum, "audioAlbum", AUDIOALBUM); }); /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_FILE_KEY_PROMISE_016 - * @tc.name : getFileAssets - * @tc.desc : filekey relative_path - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_FILE_KEY_PROMISE_016', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_FILE_KEY_PROMISE_016' - await getFileAssetsBy(done, testNum, 'relativePath', RELATIVE_PATH); + * @tc.number : SUB_MEDIA_MEDIALIBRARY_FILE_KEY_PROMISE_016 + * @tc.name : getFileAssets + * @tc.desc : filekey relative_path + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it("SUB_MEDIA_MEDIALIBRARY_FILE_KEY_PROMISE_016", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_FILE_KEY_PROMISE_016"; + await getFileAssetsBy(done, testNum, "relativePath", RELATIVE_PATH); }); /** @@ -283,9 +298,9 @@ export default function filekeyTestPromiseTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_FILE_KEY_PROMISE_017', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_FILE_KEY_PROMISE_017' - await getFileAssetsBy(done, testNum, 'displayName', DISPLAY_NAME); + it("SUB_MEDIA_MEDIALIBRARY_FILE_KEY_PROMISE_017", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_FILE_KEY_PROMISE_017"; + await getFileAssetsBy(done, testNum, "displayName", DISPLAY_NAME); }); /** @@ -296,15 +311,15 @@ export default function filekeyTestPromiseTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_FILE_KEY_PROMISE_018', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_FILE_KEY_PROMISE_018' + it("SUB_MEDIA_MEDIALIBRARY_FILE_KEY_PROMISE_018", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_FILE_KEY_PROMISE_018"; try { - let albumName = 'ImageInfo' + let albumName = "ImageInfo"; let currentFetchOp = { - selections: RELATIVE_PATH + '= ? AND ' + ALBUM_NAME + '= ? AND ' + MEDIA_TYPE + '= ?', - selectionArgs: ['Pictures/', albumName, IMAGE_TYPE.toString()], - } - console.info(`${testNum} currentFetchOp : ${JSON.stringify(currentFetchOp)}`) + selections: RELATIVE_PATH + "= ? AND " + ALBUM_NAME + "= ? AND " + MEDIA_TYPE + "= ?", + selectionArgs: ["Pictures/", albumName, IMAGE_TYPE.toString()], + }; + console.info(`${testNum} currentFetchOp : ${JSON.stringify(currentFetchOp)}`); const albumList = await media.getAlbums(currentFetchOp); const albumCountPass = await checkAlbumsCount(done, testNum, albumList, 1); if (!albumCountPass) return; @@ -312,11 +327,10 @@ export default function filekeyTestPromiseTest(abilityContext) { expect(album.albumName).assertEqual(albumName); done(); } catch (error) { - console.info(`${testNum} error : ${error}`) + console.info(`${testNum} error : ${error}`); expect(false).assertTrue(); done(); } }); }); } - diff --git a/multimedia/medialibrary/mediaLibrary_fileKey/entry/src/main/module.json b/multimedia/medialibrary/mediaLibrary_fileKey/entry/src/main/module.json old mode 100755 new mode 100644 index 6785829959ef1d93e26aaea687a2ec9bb759d52d..025062ffed12b44b32db7f5f35356c9040ed9c5c --- a/multimedia/medialibrary/mediaLibrary_fileKey/entry/src/main/module.json +++ b/multimedia/medialibrary/mediaLibrary_fileKey/entry/src/main/module.json @@ -3,11 +3,11 @@ "name": "phone", "type": "entry", "srcEntrance": "./ets/Application/AbilityStage.ts", - "description": "$string:mainability_description", + "description": "$string:phone_entry_dsc", "mainElement": "MainAbility", "deviceTypes": [ - "tablet", - "default", + "tablet", + "default", "phone" ], "deliveryWithInstall": true, @@ -16,11 +16,11 @@ "pages": "$profile:main_pages", "abilities": [ { - "name": "ohos.acts.multimedia.mediaLibrary.MainAbility", + "name": "com.example.myapplication.MainAbility", "srcEntrance": "./ets/MainAbility/MainAbility.ts", - "description": "$string:mainability_description", + "description": "$string:phone_entry_main", "icon": "$media:icon", - "label": "$string:entry_MainAbility", + "label": "$string:entry_label", "visible": true, "orientation": "portrait", "skills": [ @@ -28,42 +28,42 @@ "actions": [ "action.system.home" ], - "entities":[ + "entities": [ "entity.system.home" ] } ] } ], - "requestPermissions": [ + "requestPermissions": [ { "name": "ohos.permission.GET_BUNDLE_INFO", "reason": "use ohos.permission.GET_BUNDLE_INFO" }, { "name": "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED", - "reason":"use ohos.permission.GET_BUNDLE_INFO_PRIVILEGED" + "reason": "use ohos.permission.GET_BUNDLE_INFO_PRIVILEGED" }, { - "name" : "ohos.permission.GRANT_SENSITIVE_PERMISSIONS", - "reason" : "use ohos.permission.GRANT_SENSITIVE_PERMISSIONS" + "name": "ohos.permission.GRANT_SENSITIVE_PERMISSIONS", + "reason": "use ohos.permission.GRANT_SENSITIVE_PERMISSIONS" }, { - "name" : "ohos.permission.REVOKE_SENSITIVE_PERMISSIONS", - "reason" : "use ohos.permission.REVOKE_SENSITIVE_PERMISSIONS" + "name": "ohos.permission.REVOKE_SENSITIVE_PERMISSIONS", + "reason": "use ohos.permission.REVOKE_SENSITIVE_PERMISSIONS" }, { "name": "ohos.permission.MEDIA_LOCATION", - "reason":"use ohos.permission.MEDIA_LOCATION" + "reason": "use ohos.permission.MEDIA_LOCATION" }, { "name": "ohos.permission.READ_MEDIA", - "reason":"use ohos.permission.READ_MEDIA" + "reason": "use ohos.permission.READ_MEDIA" }, { "name": "ohos.permission.WRITE_MEDIA", - "reason":"use ohos.permission.WRITE_MEDIA" + "reason": "use ohos.permission.WRITE_MEDIA" } ] } -} +} \ No newline at end of file diff --git a/multimedia/medialibrary/mediaLibrary_fileKey/entry/src/main/resources/base/element/string.json b/multimedia/medialibrary/mediaLibrary_fileKey/entry/src/main/resources/base/element/string.json old mode 100755 new mode 100644 index d75a3fee650de2abaabfd60f40d90d9c6a4b0b0b..2ae43f018e75d1140cf2c0c85a6a14fc369a0c50 --- a/multimedia/medialibrary/mediaLibrary_fileKey/entry/src/main/resources/base/element/string.json +++ b/multimedia/medialibrary/mediaLibrary_fileKey/entry/src/main/resources/base/element/string.json @@ -1,12 +1,32 @@ { "string": [ - { - "name": "entry_MainAbility", - "value": "MediaLibraryJSTestMain" - }, - { - "name": "mainability_description", - "value": "MediaLibraryJSTestMain Ability" - } + { + "name": "phone_entry_dsc", + "value": "i am an entry for phone" + }, + { + "name": "phone_entry_main", + "value": "the phone entry ability" + }, + { + "name": "entry_label", + "value": "ActsMediaLibraryTest" + }, + { + "name": "form_description", + "value": "mediaLibrary" + }, + { + "name": "serviceability_description", + "value": "mediaLibrary" + }, + { + "name": "description_application", + "value": "mediaLibrary test" + }, + { + "name": "app_name", + "value": "ActsMediaLibraryTest" + } ] - } \ No newline at end of file +} \ No newline at end of file diff --git a/multimedia/medialibrary/mediaLibrary_fileKey/entry/src/main/resources/base/profile/main_pages.json b/multimedia/medialibrary/mediaLibrary_fileKey/entry/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 index 6898b31d2085f478ee1ed9d933a5910cbf901d92..ceb075cd80946aade673d707aac904fb8998bce9 --- a/multimedia/medialibrary/mediaLibrary_fileKey/entry/src/main/resources/base/profile/main_pages.json +++ b/multimedia/medialibrary/mediaLibrary_fileKey/entry/src/main/resources/base/profile/main_pages.json @@ -1,6 +1,5 @@ { "src": [ - "pages/index/index", - "pages/second/second" + "MainAbility/pages/index/index" ] } \ No newline at end of file diff --git a/multimedia/medialibrary/mediaLibrary_fileKey/signature/openharmony_sx.p7b b/multimedia/medialibrary/mediaLibrary_fileKey/signature/openharmony_sx.p7b old mode 100755 new mode 100644 index 3eb5b5db82a014ff4c9483872cad743ad49a9b6e..64b33bf079b2ab68a3f26f240d127186546b33d9 Binary files a/multimedia/medialibrary/mediaLibrary_fileKey/signature/openharmony_sx.p7b and b/multimedia/medialibrary/mediaLibrary_fileKey/signature/openharmony_sx.p7b differ diff --git a/multimedia/medialibrary/mediaLibrary_fileResult/AppScope/app.json b/multimedia/medialibrary/mediaLibrary_fileResult/AppScope/app.json old mode 100755 new mode 100644 index 841282ae47b98590bdbc8aea744fbbcd178e9195..803955ad0d2a5b4ce4e103816a6a917b4701286b --- a/multimedia/medialibrary/mediaLibrary_fileResult/AppScope/app.json +++ b/multimedia/medialibrary/mediaLibrary_fileResult/AppScope/app.json @@ -1,21 +1,21 @@ -{ - "app":{ - "bundleName":"ohos.acts.multimedia.mediaLibrary", - "vendor":"huawei", - "versionCode":1000000, - "versionName":"1.0.0", - "debug":false, - "icon":"$media:icon", - "label":"$string:entry_MainAbility", - "description":"$string:mainability_description", - "distributedNotificationEnabled":true, - "keepAlive":true, - "singleUser":true, - "minAPIVersion":8, - "targetAPIVersion":8, - "car":{ - "apiCompatibleVersion":8, - "singleUser":false - } - } -} +{ + "app": { + "bundleName": "ohos.acts.multimedia.mediaLibrary", + "vendor": "huawei", + "versionCode": 1000000, + "versionName": "1.0.0", + "debug": false, + "icon": "$media:icon", + "label": "$string:app_name", + "description": "$string:description_application", + "distributedNotificationEnabled": true, + "keepAlive": true, + "singleUser": true, + "minAPIVersion": 9, + "targetAPIVersion": 9, + "car": { + "apiCompatibleVersion": 9, + "singleUser": false + } + } +} \ No newline at end of file diff --git a/multimedia/medialibrary/mediaLibrary_fileResult/AppScope/resources/base/element/string.json b/multimedia/medialibrary/mediaLibrary_fileResult/AppScope/resources/base/element/string.json old mode 100755 new mode 100644 index 9b9d5b5e10c7ce74908c32b43d24568367b46d97..ee69f9a861d9dc269ed6638735d52674583498e1 --- a/multimedia/medialibrary/mediaLibrary_fileResult/AppScope/resources/base/element/string.json +++ b/multimedia/medialibrary/mediaLibrary_fileResult/AppScope/resources/base/element/string.json @@ -1,12 +1,8 @@ -{ - "string": [ - { - "name": "entry_MainAbility", - "value": "MediaLibraryJSTestMain" - }, - { - "name": "mainability_description", - "value": "MediaLibraryJSTestMain Ability" - } - ] -} \ No newline at end of file +{ + "string":[ + { + "name":"app_name", + "value":"ohosProject" + } + ] +} \ No newline at end of file diff --git a/multimedia/medialibrary/mediaLibrary_fileResult/BUILD.gn b/multimedia/medialibrary/mediaLibrary_fileResult/BUILD.gn old mode 100755 new mode 100644 index e8f00055273373a3da246a574855e43602befca8..81a86a6ca73f117da3176d1f1542cd43baa1c2b8 --- a/multimedia/medialibrary/mediaLibrary_fileResult/BUILD.gn +++ b/multimedia/medialibrary/mediaLibrary_fileResult/BUILD.gn @@ -15,6 +15,7 @@ import("//test/xts/tools/build/suite.gni") ohos_js_hap_suite("mediaLibrary_fileResult_hap") { hap_profile = "entry/src/main/module.json" + js_build_mode = "debug" deps = [ ":mediaLibrary_js_assets", ":mediaLibrary_resources", diff --git a/multimedia/medialibrary/mediaLibrary_fileResult/Test.json b/multimedia/medialibrary/mediaLibrary_fileResult/Test.json old mode 100755 new mode 100644 index 9c666c155be836ff7dbdec102f540a5d307538db..237ead9a4ed6f287d20f8b726f7495e4e753406e --- a/multimedia/medialibrary/mediaLibrary_fileResult/Test.json +++ b/multimedia/medialibrary/mediaLibrary_fileResult/Test.json @@ -1,62 +1,68 @@ -{ - "description": "Configuration for mediaLibrary Tests", - "driver": { - "type": "JSUnitTest", - "test-timeout": "300000", - "package": "ohos.acts.multimedia.mediaLibrary", - "shell-timeout": "600000" - }, - "kits": [ - { - "type": "ShellKit", - "pre-push": [], - "run-command": [ - "rm -rf /storage/media/100/local/files/*", - "rm -rf /data/app/el2/100/database/com.ohos.medialibrary.medialibrarydata/*", - "mkdir -pv /storage/media/100/local/files/{Pictures,Videos,Audios,Documents}", - "mkdir -p /storage/media/100/local/temp" - ] - }, - { - "type": "PushKit", - "pre-push": [], - "push": [ - "./resource/medialibrary/01.jpg ->/storage/media/100/local/temp", - "./resource/medialibrary/01.mp3 ->/storage/media/100/local/temp", - "./resource/medialibrary/01.mp4 ->/storage/media/100/local/temp", - "./resource/medialibrary/01.dat ->/storage/media/100/local/temp" - ] - }, - { - "type": "ShellKit", - "run-command": [ - "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", - "mkdir -pv /storage/media/100/local/files/Documents/Static", - "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 Static; do for i in $$(seq 100); do cp /storage/media/100/local/temp/01.dat /storage/media/100/local/files/Documents/$$d/0$$i.dat; done;done;", - "chmod -R 777 /storage/media/100/local/files/*", - "chmod -R 777 /data/service/el2/100/hmdfs/account/files/*", - "hilog -Q pidoff", - "hilog -p off", - "hilog -b I", - "hilog -b D -D 0xD002B70", - "scanner", - "sleep 10" - ], - "teardown-command":[ - "hilog -b X -D 0xD002B70" - ] - }, - { - "test-file-name": [ - "ActsMediaLibraryFileResultTest.hap" - ], - "type": "AppInstallKit", - "cleanup-apps": true - } - ] +{ + "description": "Configuration for mediaLibrary Tests", + "driver": { + "type": "OHJSUnitTest", + "test-timeout": "180000", + "bundle-name": "ohos.acts.multimedia.mediaLibrary", + "module-name": "phone", + "shell-timeout": "600000", + "testcase-timeout": 70000 + }, + "kits": [ + { + "type": "ShellKit", + "pre-push": [], + "run-command": [ + "rm -rf /storage/media/100/local/files/*", + "rm -rf /data/app/el2/100/database/com.ohos.medialibrary.medialibrarydata/*", + "mkdir -pv /storage/media/100/local/files/{Pictures,Videos,Audios,Documents}", + "mkdir -p /storage/media/100/local/temp", + "power-shell wakeup", + "uinput -T -d 300 600 -m 300 600 300 100 -u 300 100", + "power-shell setmode 602" + ] + }, + { + "type": "PushKit", + "pre-push": [], + "push": [ + "./resource/medialibrary/01.jpg ->/storage/media/100/local/temp", + "./resource/medialibrary/01.mp3 ->/storage/media/100/local/temp", + "./resource/medialibrary/01.mp4 ->/storage/media/100/local/temp", + "./resource/medialibrary/01.dat ->/storage/media/100/local/temp" + ] + }, + { + "type": "ShellKit", + "run-command": [ + "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", + "mkdir -pv /storage/media/100/local/files/Documents/Static", + "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 Static; do for i in $$(seq 100); do cp /storage/media/100/local/temp/01.dat /storage/media/100/local/files/Documents/$$d/0$$i.dat; done;done;", + "chmod -R 777 /storage/media/100/local/files/*", + "chmod -R 777 /data/service/el2/100/hmdfs/account/files/*", + "hilog -Q pidoff", + "hilog -p off", + "hilog -b I", + "hilog -b D -D 0xD002B70", + "scanner", + "sleep 10" + ], + "teardown-command": [ + "hilog -b X -D 0xD002B70", + "power-shell setmode 600" + ] + }, + { + "test-file-name": [ + "ActsMediaLibraryFileResultTest.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + } + ] } \ No newline at end of file diff --git a/multimedia/medialibrary/mediaLibrary_fileResult/entry/src/main/ets/Application/AbilityStage.ts b/multimedia/medialibrary/mediaLibrary_fileResult/entry/src/main/ets/Application/AbilityStage.ts old mode 100755 new mode 100644 index 14f230e140160dc5f94ecc462304621178f4cf64..b0e0206ea9fb5ce94ef140d69510b6280969dd8e --- a/multimedia/medialibrary/mediaLibrary_fileResult/entry/src/main/ets/Application/AbilityStage.ts +++ b/multimedia/medialibrary/mediaLibrary_fileResult/entry/src/main/ets/Application/AbilityStage.ts @@ -1,9 +1,9 @@ -import AbilityStage from "@ohos.application.AbilityStage" - -export default class MyAbilityStage extends AbilityStage { - onCreate() { - console.log("[Demo] MyAbilityStage onCreate") - globalThis.stageOnCreateRun = 1; - globalThis.stageContext = this.context; - } -} +import AbilityStage from "@ohos.app.ability.AbilityStage" + +export default class MyAbilityStage extends AbilityStage { + onCreate() { + console.log("[Demo] MyAbilityStage onCreate") + globalThis.stageOnCreateRun = 1; + globalThis.stageContext = this.context; + } +} diff --git a/multimedia/medialibrary/mediaLibrary_fileResult/entry/src/main/ets/MainAbility/MainAbility.ts b/multimedia/medialibrary/mediaLibrary_fileResult/entry/src/main/ets/MainAbility/MainAbility.ts old mode 100755 new mode 100644 index 72b03d747b3e2e8bdf18ea37c54c789bebb767bb..df41851318f3385890e235a96dfbcc0441cb13f1 --- a/multimedia/medialibrary/mediaLibrary_fileResult/entry/src/main/ets/MainAbility/MainAbility.ts +++ b/multimedia/medialibrary/mediaLibrary_fileResult/entry/src/main/ets/MainAbility/MainAbility.ts @@ -1,36 +1,36 @@ -import Ability from '@ohos.application.Ability' - -export default class MainAbility extends Ability { - onCreate(want,launchParam){ - // Ability is creating, initialize resources for this ability - console.log("[Demo] MainAbility onCreate") - globalThis.abilityWant = want; - } - - onDestroy() { - // Ability is destroying, release resources for this ability - console.log("[Demo] MainAbility onDestroy") - } - - onWindowStageCreate(windowStage) { - // Main window is created, set main page for this ability - console.log("[Demo] MainAbility onWindowStageCreate") - globalThis.abilityContext = this.context - windowStage.setUIContent(this.context, "pages/index/index", null) - } - - onWindowStageDestroy() { - //Main window is destroyed, release UI related resources - console.log("[Demo] MainAbility onWindowStageDestroy") - } - - onForeground() { - // Ability has brought to foreground - console.log("[Demo] MainAbility onForeground") - } - - onBackground() { - // Ability has back to background - console.log("[Demo] MainAbility onBackground") - } +import Ability from '@ohos.app.ability.UIAbility' + +export default class MainAbility extends Ability { + onCreate(want, launchParam) { + // Ability is creating, initialize resources for this ability + console.log("[Demo] MainAbility onCreate") + globalThis.abilityWant = want; + } + + onDestroy() { + // Ability is destroying, release resources for this ability + console.log("[Demo] MainAbility onDestroy") + } + + async onWindowStageCreate(windowStage) { + console.log("[Demo] MainAbility onWindowStageCreate windowStage=" + windowStage) + globalThis.windowStage = windowStage + globalThis.abilityContext = this.context + windowStage.setUIContent(this.context, "MainAbility/pages/index/index", null) + } + + onWindowStageDestroy() { + //Main window is destroyed, release UI related resources + console.log("[Demo] MainAbility onWindowStageDestroy") + } + + onForeground() { + // Ability has brought to foreground + console.log("[Demo] MainAbility onForeground") + } + + onBackground() { + // Ability has back to background + console.log("[Demo] MainAbility onBackground") + } }; \ No newline at end of file diff --git a/multimedia/medialibrary/mediaLibrary_fileResult/entry/src/main/ets/MainAbility/pages/index/index.ets b/multimedia/medialibrary/mediaLibrary_fileResult/entry/src/main/ets/MainAbility/pages/index/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..6a8c567d5a86048b1c269e4f00cc288ec136200b --- /dev/null +++ b/multimedia/medialibrary/mediaLibrary_fileResult/entry/src/main/ets/MainAbility/pages/index/index.ets @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import router from '@ohos.router'; +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' +import { Hypium } from '@ohos/hypium' +import testsuite from '../../../test/List.test' + + +@Entry +@Component +struct Index { + + aboutToAppear(){ + console.info("start run testcase!!!!") + var abilityDelegator: any + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var abilityDelegatorArguments: any + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + console.info('start run testcase!!!') + Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) + } + + build() { + Flex({ direction:FlexDirection.Column, alignItems:ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text('Hello World') + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('next page') + .fontSize(25) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .onClick(() => { + + }) + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/multimedia/medialibrary/mediaLibrary_fileResult/entry/src/main/ets/TestAbility/TestAbility.ts b/multimedia/medialibrary/mediaLibrary_fileResult/entry/src/main/ets/TestAbility/TestAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..8028a70f8af44690b95a08bd177bca6b09f24687 --- /dev/null +++ b/multimedia/medialibrary/mediaLibrary_fileResult/entry/src/main/ets/TestAbility/TestAbility.ts @@ -0,0 +1,50 @@ +/* + * 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 Ability from '@ohos.app.ability.UIAbility' + +export default class TestAbility extends Ability { + onCreate(want, launchParam) { + console.log('TestAbility onCreate') + } + + onDestroy() { + console.log('TestAbility onDestroy') + } + + onWindowStageCreate(windowStage) { + console.log('TestAbility onWindowStageCreate') + windowStage.loadContent("TestAbility/pages/index", (err, data) => { + if (err.code) { + console.error('Failed to load the content. Cause:' + JSON.stringify(err)); + return; + } + console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data)) + }); + + globalThis.abilityContext = this.context; + } + + onWindowStageDestroy() { + console.log('TestAbility onWindowStageDestroy') + } + + onForeground() { + console.log('TestAbility onForeground') + } + + onBackground() { + console.log('TestAbility onBackground') + } +}; \ No newline at end of file diff --git a/multimedia/medialibrary/mediaLibrary_fileResult/entry/src/main/ets/TestAbility/pages/index.ets b/multimedia/medialibrary/mediaLibrary_fileResult/entry/src/main/ets/TestAbility/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..b93567f962921124b282f78c8ef123965d1460c9 --- /dev/null +++ b/multimedia/medialibrary/mediaLibrary_fileResult/entry/src/main/ets/TestAbility/pages/index.ets @@ -0,0 +1,48 @@ +/* + * 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 router from '@ohos.router'; + +@Entry +@Component +struct Index { + aboutToAppear() { + console.info('TestAbility index aboutToAppear') + } + @State message: string = 'Hello World' + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('next page') + .fontSize(20) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .width('35%') + .height('5%') + .onClick(()=>{ + }) + } + .width('100%') + } + .height('100%') + } + } \ No newline at end of file diff --git a/multimedia/medialibrary/mediaLibrary_fileResult/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts b/multimedia/medialibrary/mediaLibrary_fileResult/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts new file mode 100644 index 0000000000000000000000000000000000000000..a4ee2f1652b3d04ce83ece64ef70f8dfa62a2dc8 --- /dev/null +++ b/multimedia/medialibrary/mediaLibrary_fileResult/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts @@ -0,0 +1,78 @@ +/* + * 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 TestRunner from '@ohos.application.testRunner' +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' + +var abilityDelegator = undefined +var abilityDelegatorArguments = undefined + +function translateParamsToString(parameters) { + const keySet = new Set([ + '-s class', '-s notClass', '-s suite', '-s it', + '-s level', '-s testType', '-s size', '-s timeout', + '-s dryRun' + ]) + let targetParams = ''; + for (const key in parameters) { + if (keySet.has(key)) { + targetParams = `${targetParams} ${key} ${parameters[key]}` + } + } + return targetParams.trim() +} + +async function onAbilityCreateCallback() { + console.log("onAbilityCreateCallback"); +} + +async function addAbilityMonitorCallback(err: any) { + console.info("addAbilityMonitorCallback : " + JSON.stringify(err)) +} + +export default class OpenHarmonyTestRunner implements TestRunner { + constructor() { + } + + onPrepare() { + console.info("OpenHarmonyTestRunner OnPrepare ") + } + + async onRun() { + console.log('OpenHarmonyTestRunner onRun run') + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var testAbilityName = abilityDelegatorArguments.bundleName + '.MainAbility' + let lMonitor = { + abilityName: testAbilityName, + onAbilityCreate: onAbilityCreateCallback, + }; + abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback) + var cmd = 'aa start -d 0 -a com.example.myapplication.MainAbility' + ' -b ' + abilityDelegatorArguments.bundleName + cmd += ' '+translateParamsToString(abilityDelegatorArguments.parameters) + var debug = abilityDelegatorArguments.parameters["-D"] + if (debug == 'true') + { + cmd += ' -D' + } + console.info('cmd : '+cmd) + abilityDelegator.executeShellCommand(cmd, + (err: any, d: any) => { + console.info('executeShellCommand : err : ' + JSON.stringify(err)); + console.info('executeShellCommand : data : ' + d.stdResult); + console.info('executeShellCommand : data : ' + d.exitCode); + }) + console.info('OpenHarmonyTestRunner onRun end') + } +}; \ No newline at end of file diff --git a/multimedia/medialibrary/mediaLibrary_fileResult/entry/src/main/ets/pages/index/index.ets b/multimedia/medialibrary/mediaLibrary_fileResult/entry/src/main/ets/pages/index/index.ets deleted file mode 100755 index 71bcb74b8a045a4e05dd64ed8209d3964c72a730..0000000000000000000000000000000000000000 --- a/multimedia/medialibrary/mediaLibrary_fileResult/entry/src/main/ets/pages/index/index.ets +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import file from '@system.file'; - -import {Core, ExpectExtend, InstrumentLog, ReportExtend} from "deccjsunit/index" -import testsuite from "../../test/List.test.ets" - -@Entry -@Component -struct Index { - - aboutToAppear(){ - console.info("start run testcase!!!!") - const core = Core.getInstance() - const expectExtend = new ExpectExtend({ - 'id': 'extend' - }) - core.addService('expect', expectExtend) - const reportExtend = new ReportExtend(file) - - core.addService('report', reportExtend) - core.init() - core.subscribeEvent('task', reportExtend) - const configService = core.getDefaultService('config') - console.info('parameters---->' + JSON.stringify(globalThis.abilityWant.parameters)) - globalThis.abilityWant.parameters.timeout = 70000; - configService.setConfig(globalThis.abilityWant.parameters) - console.info('testsuite()---->') - testsuite(globalThis.abilityContext) - core.execute() - console.info('core.execute()---->') - } - - build() { - Flex({ direction:FlexDirection.Column, alignItems:ItemAlign.Center, justifyContent: FlexAlign.Center }) { - Text('Hello World') - .fontSize(50) - .fontWeight(FontWeight.Bold) - Button() { - Text('next page') - .fontSize(25) - .fontWeight(FontWeight.Bold) - }.type(ButtonType.Capsule) - .margin({ - top: 20 - }) - .backgroundColor('#0D9FFB') - .onClick(() => { - - }) - } - .width('100%') - .height('100%') - } -} \ No newline at end of file diff --git a/multimedia/medialibrary/mediaLibrary_fileResult/entry/src/main/ets/pages/second/second.ets b/multimedia/medialibrary/mediaLibrary_fileResult/entry/src/main/ets/pages/second/second.ets deleted file mode 100755 index 1f2a06b64cdadcc83027bb6797e24536a2c85757..0000000000000000000000000000000000000000 --- a/multimedia/medialibrary/mediaLibrary_fileResult/entry/src/main/ets/pages/second/second.ets +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import router from '@system.router'; - -@Entry -@Component -struct Second { - private content: string = "Second Page" - - build() { - Flex({ direction: FlexDirection.Column,alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { - Text(`${this.content}`) - .fontSize(50) - .fontWeight(FontWeight.Bold) - Button() { - Text('back to index') - .fontSize(20) - .fontWeight(FontWeight.Bold) - }.type(ButtonType.Capsule) - .margin({ - top: 20 - }) - .backgroundColor('#0D9FFB') - .onClick(() => { - router.back() - }) - } - .width('100%') - .height('100%') - } -} \ No newline at end of file diff --git a/multimedia/medialibrary/mediaLibrary_fileResult/entry/src/main/ets/test/List.test.ets b/multimedia/medialibrary/mediaLibrary_fileResult/entry/src/main/ets/test/List.test.ets old mode 100755 new mode 100644 index 46cdd507131ac056b03a72e43a0f1ee6976c0a0e..1bba9066e9224b81a44d5d477074d619a7779cc9 --- a/multimedia/medialibrary/mediaLibrary_fileResult/entry/src/main/ets/test/List.test.ets +++ b/multimedia/medialibrary/mediaLibrary_fileResult/entry/src/main/ets/test/List.test.ets @@ -15,7 +15,7 @@ import fetchFileResultPromise from './fetchFileResultPromise.test.ets' import fetchFileResultCallback from './fetchFileResultCallback.test.ets' -export default function testsuite(abilityContext) { - fetchFileResultCallback(abilityContext) - fetchFileResultPromise(abilityContext) +export default function testsuite() { + fetchFileResultCallback(globalThis.abilityContext) + fetchFileResultPromise(globalThis.abilityContext) } diff --git a/multimedia/medialibrary/mediaLibrary_fileResult/entry/src/main/ets/test/fetchFileResultCallback.test.ets b/multimedia/medialibrary/mediaLibrary_fileResult/entry/src/main/ets/test/fetchFileResultCallback.test.ets old mode 100755 new mode 100644 index 604805f84598fc574c092642a77925f643a1b9be..daceb8cbb9d8aea44fad3e8e31b66b03ab9159a2 --- a/multimedia/medialibrary/mediaLibrary_fileResult/entry/src/main/ets/test/fetchFileResultCallback.test.ets +++ b/multimedia/medialibrary/mediaLibrary_fileResult/entry/src/main/ets/test/fetchFileResultCallback.test.ets @@ -13,8 +13,8 @@ * limitations under the License. */ -import mediaLibrary from '@ohos.multimedia.mediaLibrary'; -import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'; +import mediaLibrary from "@ohos.multimedia.mediaLibrary"; +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "deccjsunit/index"; import { sleep, @@ -25,46 +25,48 @@ import { checkAssetsCount, fetchOps, getPermission, -} from '../../../../../../common'; +} from "../../../../../../common"; export default function fetchFileResultCallbackTest(abilityContext) { - describe('fetchFileResultCallbackTest', function () { + describe("fetchFileResultCallbackTest", function () { const media = mediaLibrary.getMediaLibrary(abilityContext); beforeAll(async function () { - console.info('beforeAll case'); - await getPermission(); - await checkPresetsAssets(media, 'ActsMediaLibraryFileResultTest'); + console.info("beforeAll case"); + await getPermission(null, abilityContext); + await checkPresetsAssets(media, "ActsMediaLibraryFileResultTest"); }); beforeEach(function () { - console.info('beforeEach case'); + console.info("beforeEach case"); }); afterEach(async function () { - console.info('afterEach case'); - await sleep() + console.info("afterEach case"); + await sleep(); }); afterAll(function () { - console.info('afterAll case'); + console.info("afterAll case"); }); const checkAssetCount = async function (done, testNum, fetchOp, expectCount) { try { media.getFileAssets(fetchOp, async (err, fetchFileResult) => { - let checkResult = await checkAssetsCount(done, testNum, fetchFileResult, expectCount) + let checkResult = await checkAssetsCount(done, testNum, fetchFileResult, expectCount); expect(checkResult).assertTrue(); await fetchFileResult.close(); done(); }); } catch (error) { - console.info(`${testNum} error: ${error}`) + console.info(`${testNum} error: ${error}`); expect(false).assertTrue(); done(); } - } + }; const checkGetPositionObject = async function (done, testNum, pos) { try { - let currentFetchOp = fetchOps(testNum, 'Pictures/Static/', IMAGE_TYPE, { order: FILEKEY.DATE_ADDED + " DESC" }) - console.info(`${testNum} currentFetchOp ${currentFetchOp} `) + let currentFetchOp = fetchOps(testNum, "Pictures/Static/", IMAGE_TYPE, { + order: FILEKEY.DATE_ADDED + " DESC", + }); + console.info(`${testNum} currentFetchOp ${currentFetchOp} `); let fetchFileResult = await media.getFileAssets(currentFetchOp); let expectCount = 4; @@ -81,18 +83,19 @@ export default function fetchFileResultCallbackTest(abilityContext) { fetchFileResult.close(); done(); }); - } catch (error) { console.info(`${testNum} error: ${error}`); expect(false).assertTrue(); done(); } - } + }; const checkGetAllObject = async function (done, testNum, expectCount) { try { - let currentFetchOp = fetchOps(testNum, 'Documents/Static/', FILE_TYPE, { order: FILEKEY.DATE_ADDED + ` DESC LIMIT 0,${expectCount}` }) - console.info(`${testNum} currentFetchOp ${currentFetchOp} `) + let currentFetchOp = fetchOps(testNum, "Documents/Static/", FILE_TYPE, { + order: FILEKEY.DATE_ADDED + ` DESC LIMIT 0,${expectCount}`, + }); + console.info(`${testNum} currentFetchOp ${currentFetchOp} `); let fetchFileResult = await media.getFileAssets(currentFetchOp); let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchFileResult, expectCount); @@ -112,7 +115,7 @@ export default function fetchFileResultCallbackTest(abilityContext) { expect(false).assertTrue(); done(); } - } + }; // ------------------------------ 001 test start ------------------------- /** @@ -123,12 +126,13 @@ export default function fetchFileResultCallbackTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETCOUNT_CALLBACK_001_01', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETCOUNT_CALLBACK_001_01' - let expectCount = 1 - let currentFetchOp = fetchOps(testNum, 'Documents/Static/', FILE_TYPE, - { order: FILEKEY.DATE_ADDED + " DESC LIMIT 0,1", }) - await checkAssetCount(done, testNum, currentFetchOp, expectCount) + it("SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETCOUNT_CALLBACK_001_01", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETCOUNT_CALLBACK_001_01"; + let expectCount = 1; + let currentFetchOp = fetchOps(testNum, "Documents/Static/", FILE_TYPE, { + order: FILEKEY.DATE_ADDED + " DESC LIMIT 0,1", + }); + await checkAssetCount(done, testNum, currentFetchOp, expectCount); }); /** @@ -139,12 +143,13 @@ export default function fetchFileResultCallbackTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETCOUNT_CALLBACK_001_02', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETCOUNT_CALLBACK_001_02' - let expectCount = 2 - let currentFetchOp = fetchOps(testNum, 'Documents/Static/', FILE_TYPE, - { order: FILEKEY.DATE_ADDED + " DESC LIMIT 0,2", }) - await checkAssetCount(done, testNum, currentFetchOp, expectCount) + it("SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETCOUNT_CALLBACK_001_02", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETCOUNT_CALLBACK_001_02"; + let expectCount = 2; + let currentFetchOp = fetchOps(testNum, "Documents/Static/", FILE_TYPE, { + order: FILEKEY.DATE_ADDED + " DESC LIMIT 0,2", + }); + await checkAssetCount(done, testNum, currentFetchOp, expectCount); }); /** @@ -155,12 +160,13 @@ export default function fetchFileResultCallbackTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETCOUNT_CALLBACK_001_03', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETCOUNT_CALLBACK_001_03' - let expectCount = 100 - let currentFetchOp = fetchOps(testNum, 'Documents/Static/', FILE_TYPE, - { order: FILEKEY.DATE_ADDED + " DESC LIMIT 0,100", }) - await checkAssetCount(done, testNum, currentFetchOp, expectCount) + it("SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETCOUNT_CALLBACK_001_03", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETCOUNT_CALLBACK_001_03"; + let expectCount = 100; + let currentFetchOp = fetchOps(testNum, "Documents/Static/", FILE_TYPE, { + order: FILEKEY.DATE_ADDED + " DESC LIMIT 0,100", + }); + await checkAssetCount(done, testNum, currentFetchOp, expectCount); }); /** @@ -171,11 +177,11 @@ export default function fetchFileResultCallbackTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETCOUNT_CALLBACK_001_04', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETCOUNT_CALLBACK_001_04' - let expectCount = 0 - let currentFetchOp = fetchOps(testNum, 'Documents/zeor/', FILE_TYPE) - await checkAssetCount(done, testNum, currentFetchOp, expectCount) + it("SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETCOUNT_CALLBACK_001_04", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETCOUNT_CALLBACK_001_04"; + let expectCount = 0; + let currentFetchOp = fetchOps(testNum, "Documents/zeor/", FILE_TYPE); + await checkAssetCount(done, testNum, currentFetchOp, expectCount); }); // ------------------------------ 001 test end ------------------------- @@ -189,18 +195,20 @@ export default function fetchFileResultCallbackTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETFIRSTOBJECT_CALLBACK_004', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETFIRSTOBJECT_CALLBACK_004' + it("SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETFIRSTOBJECT_CALLBACK_004", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETFIRSTOBJECT_CALLBACK_004"; try { - let currentFetchOp = fetchOps(testNum, 'Pictures/Static/', IMAGE_TYPE, { order: FILEKEY.DATE_ADDED + " DESC" }) - console.info(`${testNum} currentFetchOp ${JSON.stringify(currentFetchOp)} `) + let currentFetchOp = fetchOps(testNum, "Pictures/Static/", IMAGE_TYPE, { + order: FILEKEY.DATE_ADDED + " DESC", + }); + console.info(`${testNum} currentFetchOp ${JSON.stringify(currentFetchOp)} `); let fetchFileResult = await media.getFileAssets(currentFetchOp); let expectCount = 4; let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchFileResult, expectCount); if (!checkAssetCountPass) return; let assetList = await fetchFileResult.getAllObject(); fetchFileResult.getFirstObject(async (err, firstObject) => { - if(err) { + if (err) { console.info(`${testNum} err: ${err}`); expect(false).assertTrue(); done(); @@ -210,7 +218,6 @@ export default function fetchFileResultCallbackTest(abilityContext) { fetchFileResult.close(); done(); }); - } catch (error) { console.info(`${testNum} error: ${error}`); expect(false).assertTrue(); @@ -229,11 +236,13 @@ export default function fetchFileResultCallbackTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETNEXTOBJECT_CALLBACK_005', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETNEXTOBJECT_CALLBACK_005' + it("SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETNEXTOBJECT_CALLBACK_005", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETNEXTOBJECT_CALLBACK_005"; try { - let currentFetchOp = fetchOps(testNum, 'Pictures/Static/', IMAGE_TYPE, { order: FILEKEY.DATE_ADDED + " DESC" }) - console.info(`${testNum} currentFetchOp ${JSON.stringify(currentFetchOp)} `) + let currentFetchOp = fetchOps(testNum, "Pictures/Static/", IMAGE_TYPE, { + order: FILEKEY.DATE_ADDED + " DESC", + }); + console.info(`${testNum} currentFetchOp ${JSON.stringify(currentFetchOp)} `); let fetchFileResult = await media.getFileAssets(currentFetchOp); let expectCount = 4; @@ -241,7 +250,7 @@ export default function fetchFileResultCallbackTest(abilityContext) { if (!checkAssetCountPass) return; await fetchFileResult.getFirstObject(); fetchFileResult.getNextObject(async (err, nextObject) => { - if(err) { + if (err) { console.info(`${testNum} err: ${err}`); expect(false).assertTrue(); done(); @@ -269,11 +278,13 @@ export default function fetchFileResultCallbackTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETLASTOBJECT_CALLBACK_006', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETLASTOBJECT_CALLBACK_006' + it("SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETLASTOBJECT_CALLBACK_006", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETLASTOBJECT_CALLBACK_006"; try { - let currentFetchOp = fetchOps(testNum, 'Pictures/Static/', IMAGE_TYPE, { order: FILEKEY.DATE_ADDED + " DESC" }) - console.info(`${testNum} currentFetchOp ${JSON.stringify(currentFetchOp)} `) + let currentFetchOp = fetchOps(testNum, "Pictures/Static/", IMAGE_TYPE, { + order: FILEKEY.DATE_ADDED + " DESC", + }); + console.info(`${testNum} currentFetchOp ${JSON.stringify(currentFetchOp)} `); let fetchFileResult = await media.getFileAssets(currentFetchOp); let expectCount = 4; @@ -285,7 +296,6 @@ export default function fetchFileResultCallbackTest(abilityContext) { fetchFileResult.close(); done(); }); - } catch (error) { console.info(`${testNum} error: ${error}`); expect(false).assertTrue(); @@ -303,10 +313,10 @@ export default function fetchFileResultCallbackTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETPOSITIONOBJECT_CALLBACK_007_01', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETPOSITIONOBJECT_CALLBACK_007_01'; + it("SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETPOSITIONOBJECT_CALLBACK_007_01", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETPOSITIONOBJECT_CALLBACK_007_01"; let pos = 0; - await checkGetPositionObject(done, testNum, pos) + await checkGetPositionObject(done, testNum, pos); }); /** @@ -317,10 +327,10 @@ export default function fetchFileResultCallbackTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETPOSITIONOBJECT_CALLBACK_007_02', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETPOSITIONOBJECT_CALLBACK_007_02'; + it("SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETPOSITIONOBJECT_CALLBACK_007_02", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETPOSITIONOBJECT_CALLBACK_007_02"; let pos = 1; - await checkGetPositionObject(done, testNum, pos) + await checkGetPositionObject(done, testNum, pos); }); /** @@ -331,10 +341,10 @@ export default function fetchFileResultCallbackTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETPOSITIONOBJECT_CALLBACK_007_03', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETPOSITIONOBJECT_CALLBACK_007_03'; + it("SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETPOSITIONOBJECT_CALLBACK_007_03", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETPOSITIONOBJECT_CALLBACK_007_03"; let pos = 3; - await checkGetPositionObject(done, testNum, pos) + await checkGetPositionObject(done, testNum, pos); }); /** @@ -345,11 +355,13 @@ export default function fetchFileResultCallbackTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETPOSITIONOBJECT_CALLBACK_007_04', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETPOSITIONOBJECT_CALLBACK_007_04' + it("SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETPOSITIONOBJECT_CALLBACK_007_04", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETPOSITIONOBJECT_CALLBACK_007_04"; try { - let currentFetchOp = fetchOps(testNum, 'Pictures/Static/', IMAGE_TYPE, { order: FILEKEY.DATE_ADDED + " DESC" }) - console.info(`${testNum} currentFetchOp ${currentFetchOp} `) + let currentFetchOp = fetchOps(testNum, "Pictures/Static/", IMAGE_TYPE, { + order: FILEKEY.DATE_ADDED + " DESC", + }); + console.info(`${testNum} currentFetchOp ${currentFetchOp} `); let fetchFileResult = await media.getFileAssets(currentFetchOp); let expectCount = 4; @@ -366,7 +378,6 @@ export default function fetchFileResultCallbackTest(abilityContext) { expect(false).assertTrue(); done(); }); - } catch (error) { console.info(`${testNum} error: ${error}`); expect(false).assertTrue(); @@ -384,10 +395,10 @@ export default function fetchFileResultCallbackTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETALLOBJECT_CALLBACK_008_01', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETALLOBJECT_CALLBACK_008_01'; + it("SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETALLOBJECT_CALLBACK_008_01", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETALLOBJECT_CALLBACK_008_01"; let expectCount = 1; - await checkGetAllObject(done, testNum, expectCount) + await checkGetAllObject(done, testNum, expectCount); }); /** @@ -398,10 +409,10 @@ export default function fetchFileResultCallbackTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETALLOBJECT_CALLBACK_008_02', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETALLOBJECT_CALLBACK_008_02'; + it("SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETALLOBJECT_CALLBACK_008_02", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETALLOBJECT_CALLBACK_008_02"; let expectCount = 50; - await checkGetAllObject(done, testNum, expectCount) + await checkGetAllObject(done, testNum, expectCount); }); /** @@ -412,10 +423,10 @@ export default function fetchFileResultCallbackTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETALLOBJECT_CALLBACK_008_03', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETALLOBJECT_CALLBACK_008_03'; + it("SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETALLOBJECT_CALLBACK_008_03", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETALLOBJECT_CALLBACK_008_03"; let expectCount = 100; - await checkGetAllObject(done, testNum, expectCount) + await checkGetAllObject(done, testNum, expectCount); }); // ------------------------------ 008 test end ------------------------- }); diff --git a/multimedia/medialibrary/mediaLibrary_fileResult/entry/src/main/ets/test/fetchFileResultPromise.test.ets b/multimedia/medialibrary/mediaLibrary_fileResult/entry/src/main/ets/test/fetchFileResultPromise.test.ets old mode 100755 new mode 100644 index 4eeb8209b135ca39a05c33518f5b9ccdf9699e7e..d98a2bcaf2b687628fd213ce9f8284988b0dcb8d --- a/multimedia/medialibrary/mediaLibrary_fileResult/entry/src/main/ets/test/fetchFileResultPromise.test.ets +++ b/multimedia/medialibrary/mediaLibrary_fileResult/entry/src/main/ets/test/fetchFileResultPromise.test.ets @@ -13,53 +13,48 @@ * limitations under the License. */ -import mediaLibrary from '@ohos.multimedia.mediaLibrary'; +import mediaLibrary from "@ohos.multimedia.mediaLibrary"; -import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'; -import { - sleep, - IMAGE_TYPE, - FILE_TYPE, - FILEKEY, - checkAssetsCount, - fetchOps, -} from '../../../../../../common'; +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "deccjsunit/index"; +import { sleep, IMAGE_TYPE, FILE_TYPE, FILEKEY, checkAssetsCount, fetchOps } from "../../../../../../common"; export default function fetchFileResultPromiseTest(abilityContext) { - describe('fetchFileResultPromiseTest', function () { + describe("fetchFileResultPromiseTest", function () { const media = mediaLibrary.getMediaLibrary(abilityContext); beforeAll(async function () { - console.info('beforeAll case'); + console.info("beforeAll case"); }); beforeEach(function () { - console.info('beforeEach case'); + console.info("beforeEach case"); }); afterEach(async function () { - console.info('afterEach case'); - await sleep() + console.info("afterEach case"); + await sleep(); }); afterAll(function () { - console.info('afterAll case'); + console.info("afterAll case"); }); const checkAssetCount = async function (done, testNum, fetchOp, expectCount) { try { let fetchFileResult = await media.getFileAssets(fetchOp); - let checkResult = await checkAssetsCount(done, testNum, fetchFileResult, expectCount) + let checkResult = await checkAssetsCount(done, testNum, fetchFileResult, expectCount); expect(checkResult).assertTrue(); await fetchFileResult.close(); done(); } catch (error) { - console.info(`${testNum} error: ${error}`) + console.info(`${testNum} error: ${error}`); expect(false).assertTrue(); done(); } - } + }; const checkGetPositionObject = async function (done, testNum, pos) { try { - let currentFetchOp = fetchOps(testNum, 'Pictures/Static/', IMAGE_TYPE, { order: FILEKEY.DATE_ADDED + " DESC" }) - console.info(`${testNum} currentFetchOp ${currentFetchOp} `) + let currentFetchOp = fetchOps(testNum, "Pictures/Static/", IMAGE_TYPE, { + order: FILEKEY.DATE_ADDED + " DESC", + }); + console.info(`${testNum} currentFetchOp ${currentFetchOp} `); let fetchFileResult = await media.getFileAssets(currentFetchOp); let expectCount = 4; @@ -75,12 +70,14 @@ export default function fetchFileResultPromiseTest(abilityContext) { expect(false).assertTrue(); done(); } - } + }; const checkGetAllObject = async function (done, testNum, expectCount) { try { - let currentFetchOp = fetchOps(testNum, 'Documents/Static/', FILE_TYPE, { order: FILEKEY.DATE_ADDED + ` DESC LIMIT 0,${expectCount}` }) - console.info(`${testNum} currentFetchOp ${currentFetchOp} `) + let currentFetchOp = fetchOps(testNum, "Documents/Static/", FILE_TYPE, { + order: FILEKEY.DATE_ADDED + ` DESC LIMIT 0,${expectCount}`, + }); + console.info(`${testNum} currentFetchOp ${currentFetchOp} `); let fetchFileResult = await media.getFileAssets(currentFetchOp); let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchFileResult, expectCount); @@ -94,7 +91,7 @@ export default function fetchFileResultPromiseTest(abilityContext) { expect(false).assertTrue(); done(); } - } + }; // ------------------------------ 001 test start ------------------------- /** @@ -105,12 +102,13 @@ export default function fetchFileResultPromiseTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETCOUNT_PROMISE_001_01', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETCOUNT_PROMISE_001_01' - let expectCount = 1 - let currentFetchOp = fetchOps(testNum, 'Documents/Static/', FILE_TYPE, - { order: FILEKEY.DATE_ADDED + " DESC LIMIT 0,1", }) - await checkAssetCount(done, testNum, currentFetchOp, expectCount) + it("SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETCOUNT_PROMISE_001_01", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETCOUNT_PROMISE_001_01"; + let expectCount = 1; + let currentFetchOp = fetchOps(testNum, "Documents/Static/", FILE_TYPE, { + order: FILEKEY.DATE_ADDED + " DESC LIMIT 0,1", + }); + await checkAssetCount(done, testNum, currentFetchOp, expectCount); }); /** @@ -121,12 +119,13 @@ export default function fetchFileResultPromiseTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETCOUNT_PROMISE_001_02', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETCOUNT_PROMISE_001_02' - let expectCount = 2 - let currentFetchOp = fetchOps(testNum, 'Documents/Static/', FILE_TYPE, - { order: FILEKEY.DATE_ADDED + " DESC LIMIT 0,2", }) - await checkAssetCount(done, testNum, currentFetchOp, expectCount) + it("SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETCOUNT_PROMISE_001_02", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETCOUNT_PROMISE_001_02"; + let expectCount = 2; + let currentFetchOp = fetchOps(testNum, "Documents/Static/", FILE_TYPE, { + order: FILEKEY.DATE_ADDED + " DESC LIMIT 0,2", + }); + await checkAssetCount(done, testNum, currentFetchOp, expectCount); }); /** @@ -137,12 +136,13 @@ export default function fetchFileResultPromiseTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETCOUNT_PROMISE_001_03', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETCOUNT_PROMISE_001_03' - let expectCount = 100 - let currentFetchOp = fetchOps(testNum, 'Documents/Static/', FILE_TYPE, - { order: FILEKEY.DATE_ADDED + " DESC LIMIT 0,100", }) - await checkAssetCount(done, testNum, currentFetchOp, expectCount) + it("SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETCOUNT_PROMISE_001_03", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETCOUNT_PROMISE_001_03"; + let expectCount = 100; + let currentFetchOp = fetchOps(testNum, "Documents/Static/", FILE_TYPE, { + order: FILEKEY.DATE_ADDED + " DESC LIMIT 0,100", + }); + await checkAssetCount(done, testNum, currentFetchOp, expectCount); }); /** @@ -153,11 +153,11 @@ export default function fetchFileResultPromiseTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETCOUNT_PROMISE_001_04', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETCOUNT_PROMISE_001_04' - let expectCount = 0 - let currentFetchOp = fetchOps(testNum, 'Documents/zeor/', FILE_TYPE) - await checkAssetCount(done, testNum, currentFetchOp, expectCount) + it("SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETCOUNT_PROMISE_001_04", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETCOUNT_PROMISE_001_04"; + let expectCount = 0; + let currentFetchOp = fetchOps(testNum, "Documents/zeor/", FILE_TYPE); + await checkAssetCount(done, testNum, currentFetchOp, expectCount); }); // ------------------------------ 001 test end ------------------------- @@ -171,11 +171,11 @@ export default function fetchFileResultPromiseTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_ISAFTERLAST_PROMISE_002', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_ISAFTERLAST_PROMISE_002' + it("SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_ISAFTERLAST_PROMISE_002", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_ISAFTERLAST_PROMISE_002"; try { - let currentFetchOp = fetchOps(testNum, 'Pictures/Static/', IMAGE_TYPE); - console.info(`${testNum} currentFetchOp :${JSON.stringify(currentFetchOp)}`) + let currentFetchOp = fetchOps(testNum, "Pictures/Static/", IMAGE_TYPE); + console.info(`${testNum} currentFetchOp :${JSON.stringify(currentFetchOp)}`); let fetchFileResult = await media.getFileAssets(currentFetchOp); let expectCount = 4; let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchFileResult, expectCount); @@ -207,11 +207,11 @@ export default function fetchFileResultPromiseTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_CLOSE_PROMISE_003', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_CLOSE_PROMISE_003'; + it("SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_CLOSE_PROMISE_003", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_CLOSE_PROMISE_003"; try { let expectCount = 4; - let currentFetchOp = fetchOps(testNum, 'Pictures/Static/', IMAGE_TYPE) + let currentFetchOp = fetchOps(testNum, "Pictures/Static/", IMAGE_TYPE); let fetchFileResult = await media.getFileAssets(currentFetchOp); let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchFileResult, expectCount); if (!checkAssetCountPass) return; @@ -219,24 +219,34 @@ export default function fetchFileResultPromiseTest(abilityContext) { let count = 0; try { fetchFileResult.getCount(); - } catch { count++ } + } catch { + count++; + } try { await fetchFileResult.getFirstObject(); - } catch { count++ } + } catch { + count++; + } try { await fetchFileResult.getNextObject(); - } catch { count++ } + } catch { + count++; + } try { await fetchFileResult.getLastObject(); - } catch { count++ } + } catch { + count++; + } try { await fetchFileResult.getPositionObject(0); - } catch { count++ } - await sleep(1000) + } catch { + count++; + } + await sleep(1000); expect(count).assertEqual(5); done(); } catch (error) { - console.info(`${testNum} error:${error}`) + console.info(`${testNum} error:${error}`); expect(false).assertTrue(); done(); } @@ -253,11 +263,13 @@ export default function fetchFileResultPromiseTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETFIRSTOBJECT_PROMISE_004', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETFIRSTOBJECT_PROMISE_004' + it("SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETFIRSTOBJECT_PROMISE_004", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETFIRSTOBJECT_PROMISE_004"; try { - let currentFetchOp = fetchOps(testNum, 'Pictures/Static/', IMAGE_TYPE, { order: FILEKEY.DATE_ADDED + " DESC" }) - console.info(`${testNum} currentFetchOp ${JSON.stringify(currentFetchOp)} `) + let currentFetchOp = fetchOps(testNum, "Pictures/Static/", IMAGE_TYPE, { + order: FILEKEY.DATE_ADDED + " DESC", + }); + console.info(`${testNum} currentFetchOp ${JSON.stringify(currentFetchOp)} `); let fetchFileResult = await media.getFileAssets(currentFetchOp); let expectCount = 4; let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchFileResult, expectCount); @@ -285,11 +297,13 @@ export default function fetchFileResultPromiseTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETNEXTOBJECT_PROMISE_005', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETNEXTOBJECT_PROMISE_005' + it("SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETNEXTOBJECT_PROMISE_005", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETNEXTOBJECT_PROMISE_005"; try { - let currentFetchOp = fetchOps(testNum, 'Pictures/Static/', IMAGE_TYPE, { order: FILEKEY.DATE_ADDED + " DESC" }) - console.info(`${testNum} currentFetchOp ${JSON.stringify(currentFetchOp)} `) + let currentFetchOp = fetchOps(testNum, "Pictures/Static/", IMAGE_TYPE, { + order: FILEKEY.DATE_ADDED + " DESC", + }); + console.info(`${testNum} currentFetchOp ${JSON.stringify(currentFetchOp)} `); let fetchFileResult = await media.getFileAssets(currentFetchOp); let expectCount = 4; @@ -320,11 +334,13 @@ export default function fetchFileResultPromiseTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETLASTOBJECT_PROMISE_006', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETLASTOBJECT_PROMISE_006' + it("SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETLASTOBJECT_PROMISE_006", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETLASTOBJECT_PROMISE_006"; try { - let currentFetchOp = fetchOps(testNum, 'Pictures/Static/', IMAGE_TYPE, { order: FILEKEY.DATE_ADDED + " DESC" }) - console.info(`${testNum} currentFetchOp ${JSON.stringify(currentFetchOp)} `) + let currentFetchOp = fetchOps(testNum, "Pictures/Static/", IMAGE_TYPE, { + order: FILEKEY.DATE_ADDED + " DESC", + }); + console.info(`${testNum} currentFetchOp ${JSON.stringify(currentFetchOp)} `); let fetchFileResult = await media.getFileAssets(currentFetchOp); let expectCount = 4; @@ -352,10 +368,10 @@ export default function fetchFileResultPromiseTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETPOSITIONOBJECT_PROMISE_007_01', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETPOSITIONOBJECT_PROMISE_007_01'; + it("SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETPOSITIONOBJECT_PROMISE_007_01", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETPOSITIONOBJECT_PROMISE_007_01"; let pos = 0; - await checkGetPositionObject(done, testNum, pos) + await checkGetPositionObject(done, testNum, pos); }); /** @@ -366,10 +382,10 @@ export default function fetchFileResultPromiseTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETPOSITIONOBJECT_PROMISE_007_02', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETPOSITIONOBJECT_PROMISE_007_02'; + it("SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETPOSITIONOBJECT_PROMISE_007_02", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETPOSITIONOBJECT_PROMISE_007_02"; let pos = 1; - await checkGetPositionObject(done, testNum, pos) + await checkGetPositionObject(done, testNum, pos); }); /** @@ -380,10 +396,10 @@ export default function fetchFileResultPromiseTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETPOSITIONOBJECT_PROMISE_007_03', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETPOSITIONOBJECT_PROMISE_007_03'; + it("SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETPOSITIONOBJECT_PROMISE_007_03", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETPOSITIONOBJECT_PROMISE_007_03"; let pos = 3; - await checkGetPositionObject(done, testNum, pos) + await checkGetPositionObject(done, testNum, pos); }); /** @@ -394,11 +410,13 @@ export default function fetchFileResultPromiseTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETPOSITIONOBJECT_PROMISE_007_04', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETPOSITIONOBJECT_PROMISE_007_04' + it("SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETPOSITIONOBJECT_PROMISE_007_04", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETPOSITIONOBJECT_PROMISE_007_04"; try { - let currentFetchOp = fetchOps(testNum, 'Pictures/Static/', IMAGE_TYPE, { order: FILEKEY.DATE_ADDED + " DESC" }) - console.info(`${testNum} currentFetchOp ${currentFetchOp} `) + let currentFetchOp = fetchOps(testNum, "Pictures/Static/", IMAGE_TYPE, { + order: FILEKEY.DATE_ADDED + " DESC", + }); + console.info(`${testNum} currentFetchOp ${currentFetchOp} `); let fetchFileResult = await media.getFileAssets(currentFetchOp); let expectCount = 4; @@ -411,7 +429,7 @@ export default function fetchFileResultPromiseTest(abilityContext) { } catch (error) { console.info(`${testNum} passed error: ${error}`); expect(true).assertTrue(); - fetchFileResult.close() + fetchFileResult.close(); done(); } } catch (error) { @@ -431,10 +449,10 @@ export default function fetchFileResultPromiseTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETALLOBJECT_PROMISE_008_01', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETALLOBJECT_PROMISE_008_01'; + it("SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETALLOBJECT_PROMISE_008_01", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETALLOBJECT_PROMISE_008_01"; let expectCount = 1; - await checkGetAllObject(done, testNum, expectCount) + await checkGetAllObject(done, testNum, expectCount); }); /** @@ -445,10 +463,10 @@ export default function fetchFileResultPromiseTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETALLOBJECT_PROMISE_008_02', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETALLOBJECT_PROMISE_008_02'; + it("SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETALLOBJECT_PROMISE_008_02", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETALLOBJECT_PROMISE_008_02"; let expectCount = 50; - await checkGetAllObject(done, testNum, expectCount) + await checkGetAllObject(done, testNum, expectCount); }); /** @@ -459,12 +477,11 @@ export default function fetchFileResultPromiseTest(abilityContext) { * @tc.type : Function * @tc.level : Level 0 */ - it('SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETALLOBJECT_PROMISE_008_03', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETALLOBJECT_PROMISE_008_03'; + it("SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETALLOBJECT_PROMISE_008_03", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETALLOBJECT_PROMISE_008_03"; let expectCount = 100; - await checkGetAllObject(done, testNum, expectCount) + await checkGetAllObject(done, testNum, expectCount); }); // ------------------------------ 008 test end ------------------------- - }); } diff --git a/multimedia/medialibrary/mediaLibrary_fileResult/entry/src/main/module.json b/multimedia/medialibrary/mediaLibrary_fileResult/entry/src/main/module.json old mode 100755 new mode 100644 index a1aa0cada29076a34f21189f99ad1f86dee4944a..025062ffed12b44b32db7f5f35356c9040ed9c5c --- a/multimedia/medialibrary/mediaLibrary_fileResult/entry/src/main/module.json +++ b/multimedia/medialibrary/mediaLibrary_fileResult/entry/src/main/module.json @@ -1,69 +1,69 @@ -{ - "module": { - "name": "phone", - "type": "entry", - "srcEntrance": "./ets/Application/AbilityStage.ts", - "description": "$string:mainability_description", - "mainElement": "MainAbility", - "deviceTypes": [ - "tablet", - "default", - "phone" - ], - "deliveryWithInstall": true, - "installationFree": false, - "uiSyntax": "ets", - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "ohos.acts.multimedia.mediaLibrary.MainAbility", - "srcEntrance": "./ets/MainAbility/MainAbility.ts", - "description": "$string:mainability_description", - "icon": "$media:icon", - "label": "$string:entry_MainAbility", - "visible": true, - "orientation": "portrait", - "skills": [ - { - "actions": [ - "action.system.home" - ], - "entities":[ - "entity.system.home" - ] - } - ] - } - ], - "requestPermissions": [ - { - "name": "ohos.permission.GET_BUNDLE_INFO", - "reason": "use ohos.permission.GET_BUNDLE_INFO" - }, - { - "name": "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED", - "reason":"use ohos.permission.GET_BUNDLE_INFO_PRIVILEGED" - }, - { - "name" : "ohos.permission.GRANT_SENSITIVE_PERMISSIONS", - "reason" : "use ohos.permission.GRANT_SENSITIVE_PERMISSIONS" - }, - { - "name" : "ohos.permission.REVOKE_SENSITIVE_PERMISSIONS", - "reason" : "use ohos.permission.REVOKE_SENSITIVE_PERMISSIONS" - }, - { - "name": "ohos.permission.MEDIA_LOCATION", - "reason":"use ohos.permission.MEDIA_LOCATION" - }, - { - "name": "ohos.permission.READ_MEDIA", - "reason":"use ohos.permission.READ_MEDIA" - }, - { - "name": "ohos.permission.WRITE_MEDIA", - "reason":"use ohos.permission.WRITE_MEDIA" - } - ] - } -} +{ + "module": { + "name": "phone", + "type": "entry", + "srcEntrance": "./ets/Application/AbilityStage.ts", + "description": "$string:phone_entry_dsc", + "mainElement": "MainAbility", + "deviceTypes": [ + "tablet", + "default", + "phone" + ], + "deliveryWithInstall": true, + "installationFree": false, + "uiSyntax": "ets", + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "com.example.myapplication.MainAbility", + "srcEntrance": "./ets/MainAbility/MainAbility.ts", + "description": "$string:phone_entry_main", + "icon": "$media:icon", + "label": "$string:entry_label", + "visible": true, + "orientation": "portrait", + "skills": [ + { + "actions": [ + "action.system.home" + ], + "entities": [ + "entity.system.home" + ] + } + ] + } + ], + "requestPermissions": [ + { + "name": "ohos.permission.GET_BUNDLE_INFO", + "reason": "use ohos.permission.GET_BUNDLE_INFO" + }, + { + "name": "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED", + "reason": "use ohos.permission.GET_BUNDLE_INFO_PRIVILEGED" + }, + { + "name": "ohos.permission.GRANT_SENSITIVE_PERMISSIONS", + "reason": "use ohos.permission.GRANT_SENSITIVE_PERMISSIONS" + }, + { + "name": "ohos.permission.REVOKE_SENSITIVE_PERMISSIONS", + "reason": "use ohos.permission.REVOKE_SENSITIVE_PERMISSIONS" + }, + { + "name": "ohos.permission.MEDIA_LOCATION", + "reason": "use ohos.permission.MEDIA_LOCATION" + }, + { + "name": "ohos.permission.READ_MEDIA", + "reason": "use ohos.permission.READ_MEDIA" + }, + { + "name": "ohos.permission.WRITE_MEDIA", + "reason": "use ohos.permission.WRITE_MEDIA" + } + ] + } +} \ No newline at end of file diff --git a/multimedia/medialibrary/mediaLibrary_fileResult/entry/src/main/resources/base/element/string.json b/multimedia/medialibrary/mediaLibrary_fileResult/entry/src/main/resources/base/element/string.json old mode 100755 new mode 100644 index 32237ee203edf64926964fb238fa44e396ddf577..2ae43f018e75d1140cf2c0c85a6a14fc369a0c50 --- a/multimedia/medialibrary/mediaLibrary_fileResult/entry/src/main/resources/base/element/string.json +++ b/multimedia/medialibrary/mediaLibrary_fileResult/entry/src/main/resources/base/element/string.json @@ -1,12 +1,32 @@ -{ - "string": [ - { - "name": "entry_MainAbility", - "value": "MediaLibraryJSTestMain" - }, - { - "name": "mainability_description", - "value": "MediaLibraryJSTestMain Ability" - } - ] - } \ No newline at end of file +{ + "string": [ + { + "name": "phone_entry_dsc", + "value": "i am an entry for phone" + }, + { + "name": "phone_entry_main", + "value": "the phone entry ability" + }, + { + "name": "entry_label", + "value": "ActsMediaLibraryTest" + }, + { + "name": "form_description", + "value": "mediaLibrary" + }, + { + "name": "serviceability_description", + "value": "mediaLibrary" + }, + { + "name": "description_application", + "value": "mediaLibrary test" + }, + { + "name": "app_name", + "value": "ActsMediaLibraryTest" + } + ] +} \ No newline at end of file diff --git a/multimedia/medialibrary/mediaLibrary_fileResult/entry/src/main/resources/base/profile/main_pages.json b/multimedia/medialibrary/mediaLibrary_fileResult/entry/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 index 96b478210df9884592229ae2db6f6bb7f86c14f4..ceb075cd80946aade673d707aac904fb8998bce9 --- a/multimedia/medialibrary/mediaLibrary_fileResult/entry/src/main/resources/base/profile/main_pages.json +++ b/multimedia/medialibrary/mediaLibrary_fileResult/entry/src/main/resources/base/profile/main_pages.json @@ -1,6 +1,5 @@ -{ - "src": [ - "pages/index/index", - "pages/second/second" - ] +{ + "src": [ + "MainAbility/pages/index/index" + ] } \ No newline at end of file diff --git a/multimedia/medialibrary/mediaLibrary_fileResult/signature/openharmony_sx.p7b b/multimedia/medialibrary/mediaLibrary_fileResult/signature/openharmony_sx.p7b old mode 100755 new mode 100644 index 3eb5b5db82a014ff4c9483872cad743ad49a9b6e..64b33bf079b2ab68a3f26f240d127186546b33d9 Binary files a/multimedia/medialibrary/mediaLibrary_fileResult/signature/openharmony_sx.p7b and b/multimedia/medialibrary/mediaLibrary_fileResult/signature/openharmony_sx.p7b differ diff --git a/multimedia/medialibrary/mediaLibrary_getThumbnail/AppScope/app.json b/multimedia/medialibrary/mediaLibrary_getThumbnail/AppScope/app.json old mode 100755 new mode 100644 index 5139eaad5d5fd2e2de13b4970785d6fa8ae1a4ba..803955ad0d2a5b4ce4e103816a6a917b4701286b --- a/multimedia/medialibrary/mediaLibrary_getThumbnail/AppScope/app.json +++ b/multimedia/medialibrary/mediaLibrary_getThumbnail/AppScope/app.json @@ -1,21 +1,21 @@ { - "app":{ - "bundleName":"ohos.acts.multimedia.mediaLibrary", - "vendor":"huawei", - "versionCode":1000000, - "versionName":"1.0.0", - "debug":false, - "icon":"$media:icon", - "label":"$string:entry_MainAbility", - "description":"$string:mainability_description", - "distributedNotificationEnabled":true, - "keepAlive":true, - "singleUser":true, - "minAPIVersion":8, - "targetAPIVersion":8, - "car":{ - "apiCompatibleVersion":8, - "singleUser":false + "app": { + "bundleName": "ohos.acts.multimedia.mediaLibrary", + "vendor": "huawei", + "versionCode": 1000000, + "versionName": "1.0.0", + "debug": false, + "icon": "$media:icon", + "label": "$string:app_name", + "description": "$string:description_application", + "distributedNotificationEnabled": true, + "keepAlive": true, + "singleUser": true, + "minAPIVersion": 9, + "targetAPIVersion": 9, + "car": { + "apiCompatibleVersion": 9, + "singleUser": false } } -} +} \ No newline at end of file diff --git a/multimedia/medialibrary/mediaLibrary_getThumbnail/AppScope/resources/base/element/string.json b/multimedia/medialibrary/mediaLibrary_getThumbnail/AppScope/resources/base/element/string.json old mode 100755 new mode 100644 index c1dee63527ae5e3c37f3736f6b68189e8df6f201..ee69f9a861d9dc269ed6638735d52674583498e1 --- a/multimedia/medialibrary/mediaLibrary_getThumbnail/AppScope/resources/base/element/string.json +++ b/multimedia/medialibrary/mediaLibrary_getThumbnail/AppScope/resources/base/element/string.json @@ -1,12 +1,8 @@ { - "string": [ + "string":[ { - "name": "entry_MainAbility", - "value": "MediaLibraryJSTestMain" - }, - { - "name": "mainability_description", - "value": "MediaLibraryJSTestMain Ability" + "name":"app_name", + "value":"ohosProject" } ] -} \ No newline at end of file +} \ No newline at end of file diff --git a/multimedia/medialibrary/mediaLibrary_getThumbnail/BUILD.gn b/multimedia/medialibrary/mediaLibrary_getThumbnail/BUILD.gn old mode 100755 new mode 100644 index 0b0e46bef447604db26d89dd042c511d6ed9623f..028e642905182961f2aece3e09ac5d2be873796b --- a/multimedia/medialibrary/mediaLibrary_getThumbnail/BUILD.gn +++ b/multimedia/medialibrary/mediaLibrary_getThumbnail/BUILD.gn @@ -15,6 +15,7 @@ import("//test/xts/tools/build/suite.gni") ohos_js_hap_suite("mediaLibrary_getThumbnail_hap") { hap_profile = "entry/src/main/module.json" + js_build_mode = "debug" deps = [ ":mediaLibrary_js_assets", ":mediaLibrary_resources", diff --git a/multimedia/medialibrary/mediaLibrary_getThumbnail/Test.json b/multimedia/medialibrary/mediaLibrary_getThumbnail/Test.json old mode 100755 new mode 100644 index d534a6a90964b620e881f20bfec0c51f7eea5352..d20ef1c6b3e4353e1cdd0fa7a24a1bd232de0cbf --- a/multimedia/medialibrary/mediaLibrary_getThumbnail/Test.json +++ b/multimedia/medialibrary/mediaLibrary_getThumbnail/Test.json @@ -1,63 +1,65 @@ -{ - "description": "Configuration for mediaLibrary Tests", - "driver": { - "type": "JSUnitTest", - "test-timeout": "300000", - "package": "ohos.acts.multimedia.mediaLibrary", - "shell-timeout": "300000" - }, - "kits": [ - { - "type": "ShellKit", - "pre-push": [ - ], - "run-command": [ - "rm -rf /storage/media/100/local/files/*", - "rm -rf /data/app/el2/100/database/com.ohos.medialibrary.MediaLibraryDataA/*", - "mkdir -pv /storage/media/100/local/files/{Pictures,Videos,Audios}", - "mkdir -p /storage/media/100/local/temp" - ] - }, - { - "type": "PushKit", - "pre-push": [ - ], - "push": [ - "./resource/medialibrary/01.jpg ->/storage/media/100/local/temp", - "./resource/medialibrary/01.mp3 ->/storage/media/100/local/temp", - "./resource/medialibrary/01.mp4 ->/storage/media/100/local/temp" - ] - }, - { - "type": "ShellKit", - "run-command": [ - "mkdir -pv /storage/media/100/local/files/Pictures/Thumbnail", - "mkdir -pv /storage/media/100/local/files/Videos/Thumbnail", - "mkdir -pv /storage/media/100/local/files/Audios/Thumbnail", - - "cp /storage/media/100/local/temp/01.jpg /storage/media/100/local/files/Pictures/Thumbnail", - "cp /storage/media/100/local/temp/01.mp3 /storage/media/100/local/files/Audios/Thumbnail", - "cp /storage/media/100/local/temp/01.mp4 /storage/media/100/local/files/Videos/Thumbnail", - - "chmod -R 777 /storage/media/100/local/files/*", - "chmod -R 777 /data/service/el2/100/hmdfs/account/files/*", - "hilog -Q pidoff", - "hilog -p off", - "hilog -b I", - "hilog -b D -D 0xD002B70", - "scanner", - "sleep 10" - ], - "teardown-command":[ - "hilog -b X -D 0xD002B70" - ] - }, - { - "test-file-name": [ - "ActsMediaLibraryGetThumbnailTest.hap" - ], - "type": "AppInstallKit", - "cleanup-apps": true - } - ] -} +{ + "description": "Configuration for mediaLibrary Tests", + "driver": { + "type": "OHJSUnitTest", + "test-timeout": "180000", + "bundle-name": "ohos.acts.multimedia.mediaLibrary", + "module-name": "phone", + "shell-timeout": "600000", + "testcase-timeout": 70000 + }, + "kits": [ + { + "type": "ShellKit", + "pre-push": [], + "run-command": [ + "rm -rf /storage/media/100/local/files/*", + "rm -rf /data/app/el2/100/database/com.ohos.medialibrary.MediaLibraryDataA/*", + "mkdir -pv /storage/media/100/local/files/{Pictures,Videos,Audios}", + "mkdir -p /storage/media/100/local/temp", + "power-shell wakeup", + "uinput -T -d 300 600 -m 300 600 300 100 -u 300 100", + "power-shell setmode 602" + ] + }, + { + "type": "PushKit", + "pre-push": [], + "push": [ + "./resource/medialibrary/01.jpg ->/storage/media/100/local/temp", + "./resource/medialibrary/01.mp3 ->/storage/media/100/local/temp", + "./resource/medialibrary/01.mp4 ->/storage/media/100/local/temp" + ] + }, + { + "type": "ShellKit", + "run-command": [ + "mkdir -pv /storage/media/100/local/files/Pictures/Thumbnail", + "mkdir -pv /storage/media/100/local/files/Videos/Thumbnail", + "mkdir -pv /storage/media/100/local/files/Audios/Thumbnail", + "cp /storage/media/100/local/temp/01.jpg /storage/media/100/local/files/Pictures/Thumbnail", + "cp /storage/media/100/local/temp/01.mp3 /storage/media/100/local/files/Audios/Thumbnail", + "cp /storage/media/100/local/temp/01.mp4 /storage/media/100/local/files/Videos/Thumbnail", + "chmod -R 777 /storage/media/100/local/files/*", + "chmod -R 777 /data/service/el2/100/hmdfs/account/files/*", + "hilog -Q pidoff", + "hilog -p off", + "hilog -b I", + "hilog -b D -D 0xD002B70", + "scanner", + "sleep 10" + ], + "teardown-command": [ + "hilog -b X -D 0xD002B70", + "power-shell setmode 600" + ] + }, + { + "test-file-name": [ + "ActsMediaLibraryGetThumbnailTest.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + } + ] +} \ No newline at end of file diff --git a/multimedia/medialibrary/mediaLibrary_getThumbnail/entry/src/main/ets/Application/AbilityStage.ts b/multimedia/medialibrary/mediaLibrary_getThumbnail/entry/src/main/ets/Application/AbilityStage.ts old mode 100755 new mode 100644 index 51cb02ba3f5c7011c1cd433d07deebd47a195704..e3fdadfebeeeb676df2ce8f78f4b59e26fae9cf0 --- a/multimedia/medialibrary/mediaLibrary_getThumbnail/entry/src/main/ets/Application/AbilityStage.ts +++ b/multimedia/medialibrary/mediaLibrary_getThumbnail/entry/src/main/ets/Application/AbilityStage.ts @@ -3,7 +3,7 @@ import AbilityStage from "@ohos.application.AbilityStage" export default class MyAbilityStage extends AbilityStage { onCreate() { console.log("[Demo] MyAbilityStage onCreate") - globalThis.stageOnCreateRun = 1; - globalThis.stageContext = this.context; + globalThis.stageOnCreateRun = 1; + globalThis.stageContext = this.context; } } diff --git a/multimedia/medialibrary/mediaLibrary_getThumbnail/entry/src/main/ets/MainAbility/MainAbility.ts b/multimedia/medialibrary/mediaLibrary_getThumbnail/entry/src/main/ets/MainAbility/MainAbility.ts old mode 100755 new mode 100644 index 2f9d6d1f23f95d9fc891fbc550cd5a589cfb6c89..83c0cd68bb2c044c9b98d212a62851b32bd9af9a --- a/multimedia/medialibrary/mediaLibrary_getThumbnail/entry/src/main/ets/MainAbility/MainAbility.ts +++ b/multimedia/medialibrary/mediaLibrary_getThumbnail/entry/src/main/ets/MainAbility/MainAbility.ts @@ -1,7 +1,7 @@ import Ability from '@ohos.application.Ability' export default class MainAbility extends Ability { - onCreate(want,launchParam){ + onCreate(want, launchParam) { // Ability is creating, initialize resources for this ability console.log("[Demo] MainAbility onCreate") globalThis.abilityWant = want; @@ -12,11 +12,11 @@ export default class MainAbility extends Ability { console.log("[Demo] MainAbility onDestroy") } - onWindowStageCreate(windowStage) { - // Main window is created, set main page for this ability - console.log("[Demo] MainAbility onWindowStageCreate") + async onWindowStageCreate(windowStage) { + console.log("[Demo] MainAbility onWindowStageCreate windowStage=" + windowStage) + globalThis.windowStage = windowStage globalThis.abilityContext = this.context - windowStage.setUIContent(this.context, "pages/index/index", null) + windowStage.setUIContent(this.context, "MainAbility/pages/index/index", null) } onWindowStageDestroy() { diff --git a/multimedia/medialibrary/mediaLibrary_getThumbnail/entry/src/main/ets/MainAbility/pages/index/index.ets b/multimedia/medialibrary/mediaLibrary_getThumbnail/entry/src/main/ets/MainAbility/pages/index/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..6a8c567d5a86048b1c269e4f00cc288ec136200b --- /dev/null +++ b/multimedia/medialibrary/mediaLibrary_getThumbnail/entry/src/main/ets/MainAbility/pages/index/index.ets @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import router from '@ohos.router'; +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' +import { Hypium } from '@ohos/hypium' +import testsuite from '../../../test/List.test' + + +@Entry +@Component +struct Index { + + aboutToAppear(){ + console.info("start run testcase!!!!") + var abilityDelegator: any + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var abilityDelegatorArguments: any + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + console.info('start run testcase!!!') + Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) + } + + build() { + Flex({ direction:FlexDirection.Column, alignItems:ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text('Hello World') + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('next page') + .fontSize(25) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .onClick(() => { + + }) + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/multimedia/medialibrary/mediaLibrary_getThumbnail/entry/src/main/ets/TestAbility/TestAbility.ts b/multimedia/medialibrary/mediaLibrary_getThumbnail/entry/src/main/ets/TestAbility/TestAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..8028a70f8af44690b95a08bd177bca6b09f24687 --- /dev/null +++ b/multimedia/medialibrary/mediaLibrary_getThumbnail/entry/src/main/ets/TestAbility/TestAbility.ts @@ -0,0 +1,50 @@ +/* + * 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 Ability from '@ohos.app.ability.UIAbility' + +export default class TestAbility extends Ability { + onCreate(want, launchParam) { + console.log('TestAbility onCreate') + } + + onDestroy() { + console.log('TestAbility onDestroy') + } + + onWindowStageCreate(windowStage) { + console.log('TestAbility onWindowStageCreate') + windowStage.loadContent("TestAbility/pages/index", (err, data) => { + if (err.code) { + console.error('Failed to load the content. Cause:' + JSON.stringify(err)); + return; + } + console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data)) + }); + + globalThis.abilityContext = this.context; + } + + onWindowStageDestroy() { + console.log('TestAbility onWindowStageDestroy') + } + + onForeground() { + console.log('TestAbility onForeground') + } + + onBackground() { + console.log('TestAbility onBackground') + } +}; \ No newline at end of file diff --git a/multimedia/medialibrary/mediaLibrary_getThumbnail/entry/src/main/ets/TestAbility/pages/index.ets b/multimedia/medialibrary/mediaLibrary_getThumbnail/entry/src/main/ets/TestAbility/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..b93567f962921124b282f78c8ef123965d1460c9 --- /dev/null +++ b/multimedia/medialibrary/mediaLibrary_getThumbnail/entry/src/main/ets/TestAbility/pages/index.ets @@ -0,0 +1,48 @@ +/* + * 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 router from '@ohos.router'; + +@Entry +@Component +struct Index { + aboutToAppear() { + console.info('TestAbility index aboutToAppear') + } + @State message: string = 'Hello World' + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('next page') + .fontSize(20) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .width('35%') + .height('5%') + .onClick(()=>{ + }) + } + .width('100%') + } + .height('100%') + } + } \ No newline at end of file diff --git a/multimedia/medialibrary/mediaLibrary_getThumbnail/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts b/multimedia/medialibrary/mediaLibrary_getThumbnail/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts new file mode 100644 index 0000000000000000000000000000000000000000..a4ee2f1652b3d04ce83ece64ef70f8dfa62a2dc8 --- /dev/null +++ b/multimedia/medialibrary/mediaLibrary_getThumbnail/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts @@ -0,0 +1,78 @@ +/* + * 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 TestRunner from '@ohos.application.testRunner' +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' + +var abilityDelegator = undefined +var abilityDelegatorArguments = undefined + +function translateParamsToString(parameters) { + const keySet = new Set([ + '-s class', '-s notClass', '-s suite', '-s it', + '-s level', '-s testType', '-s size', '-s timeout', + '-s dryRun' + ]) + let targetParams = ''; + for (const key in parameters) { + if (keySet.has(key)) { + targetParams = `${targetParams} ${key} ${parameters[key]}` + } + } + return targetParams.trim() +} + +async function onAbilityCreateCallback() { + console.log("onAbilityCreateCallback"); +} + +async function addAbilityMonitorCallback(err: any) { + console.info("addAbilityMonitorCallback : " + JSON.stringify(err)) +} + +export default class OpenHarmonyTestRunner implements TestRunner { + constructor() { + } + + onPrepare() { + console.info("OpenHarmonyTestRunner OnPrepare ") + } + + async onRun() { + console.log('OpenHarmonyTestRunner onRun run') + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var testAbilityName = abilityDelegatorArguments.bundleName + '.MainAbility' + let lMonitor = { + abilityName: testAbilityName, + onAbilityCreate: onAbilityCreateCallback, + }; + abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback) + var cmd = 'aa start -d 0 -a com.example.myapplication.MainAbility' + ' -b ' + abilityDelegatorArguments.bundleName + cmd += ' '+translateParamsToString(abilityDelegatorArguments.parameters) + var debug = abilityDelegatorArguments.parameters["-D"] + if (debug == 'true') + { + cmd += ' -D' + } + console.info('cmd : '+cmd) + abilityDelegator.executeShellCommand(cmd, + (err: any, d: any) => { + console.info('executeShellCommand : err : ' + JSON.stringify(err)); + console.info('executeShellCommand : data : ' + d.stdResult); + console.info('executeShellCommand : data : ' + d.exitCode); + }) + console.info('OpenHarmonyTestRunner onRun end') + } +}; \ No newline at end of file diff --git a/multimedia/medialibrary/mediaLibrary_getThumbnail/entry/src/main/ets/pages/second/second.ets b/multimedia/medialibrary/mediaLibrary_getThumbnail/entry/src/main/ets/pages/second/second.ets deleted file mode 100755 index 1c1c727ff11ecc97909f482c35268db87ae23bb4..0000000000000000000000000000000000000000 --- a/multimedia/medialibrary/mediaLibrary_getThumbnail/entry/src/main/ets/pages/second/second.ets +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import router from '@system.router'; - -@Entry -@Component -struct Second { - private content: string = "Second Page" - - build() { - Flex({ direction: FlexDirection.Column,alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { - Text(`${this.content}`) - .fontSize(50) - .fontWeight(FontWeight.Bold) - Button() { - Text('back to index') - .fontSize(20) - .fontWeight(FontWeight.Bold) - }.type(ButtonType.Capsule) - .margin({ - top: 20 - }) - .backgroundColor('#0D9FFB') - .onClick(() => { - router.back() - }) - } - .width('100%') - .height('100%') - } -} \ No newline at end of file diff --git a/multimedia/medialibrary/mediaLibrary_getThumbnail/entry/src/main/ets/test/List.test.ets b/multimedia/medialibrary/mediaLibrary_getThumbnail/entry/src/main/ets/test/List.test.ets old mode 100755 new mode 100644 index 05c14818db425d804d2289ebadb0f90e55b41f77..67914a499f094df4c575f57685ae4a5a2bdfe684 --- a/multimedia/medialibrary/mediaLibrary_getThumbnail/entry/src/main/ets/test/List.test.ets +++ b/multimedia/medialibrary/mediaLibrary_getThumbnail/entry/src/main/ets/test/List.test.ets @@ -1,20 +1,20 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import getThumbnailPromise from './getThumbnailPromise.test.ets' -import getThumbnailCallback from './getThumbnailCallback.test.ets' -export default function testsuite(abilityContext) { - getThumbnailCallback(abilityContext) - getThumbnailPromise(abilityContext) +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import getThumbnailPromise from './getThumbnailPromise.test.ets' +import getThumbnailCallback from './getThumbnailCallback.test.ets' +export default function testsuite() { + getThumbnailCallback(globalThis.abilityContext) + getThumbnailPromise(globalThis.abilityContext) } \ No newline at end of file diff --git a/multimedia/medialibrary/mediaLibrary_getThumbnail/entry/src/main/ets/test/getThumbnailCallback.test.ets b/multimedia/medialibrary/mediaLibrary_getThumbnail/entry/src/main/ets/test/getThumbnailCallback.test.ets old mode 100755 new mode 100644 index 799c707fceef3b6cf581186e3389c9c9cb8a52df..a097846fa37978abdcded5c9c4d980aa3b14d0e8 --- a/multimedia/medialibrary/mediaLibrary_getThumbnail/entry/src/main/ets/test/getThumbnailCallback.test.ets +++ b/multimedia/medialibrary/mediaLibrary_getThumbnail/entry/src/main/ets/test/getThumbnailCallback.test.ets @@ -1,437 +1,433 @@ -/* - * Copyright (C) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import mediaLibrary from '@ohos.multimedia.mediaLibrary'; -import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'; -import image from '@ohos.multimedia.image'; - -import { - sleep, - IMAGE_TYPE, - VIDEO_TYPE, - AUDIO_TYPE, - checkPresetsAssets, - checkAssetsCount, - fetchOps, - getPermission, -} from '../../../../../../common'; -export default function getThumbnailCallback(abilityContext) { - describe('getThumbnailCallback', function () { - image.createPixelMap(new ArrayBuffer(4096), { size: { height: 1, width: 2 } }).then((pixelmap) => { }); - const media = mediaLibrary.getMediaLibrary(abilityContext); - beforeAll(async function () { - console.info('beforeAll case'); - await getPermission(); - await checkPresetsAssets(media, 'ActsMediaLibraryGetThumbnailTest'); - }); - beforeEach(function () { - console.info('beforeEach case'); - }); - afterEach(async function () { - console.info('afterEach case'); - await sleep() - }); - afterAll(function () { - console.info('afterAll case'); - }); - - async function testGetThumbnail(done, testNum, dOp, size,) { - try { - let fetchFileResult = await media.getFileAssets(dOp); - let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchFileResult, 1); - if (!checkAssetCountPass) return; - let asset = await fetchFileResult.getFirstObject(); - if (size == 'default') { - size = { width: 256, height: 256 }; - asset.getThumbnail(async (err, pixelmap) => { - await pixelmap.getImageInfo((err, info) => { - expect(info.size.width).assertEqual(size.width); - expect(info.size.height).assertEqual(size.height); - done(); - }); - }) - } else { - asset.getThumbnail(size, async (err, pixelmap) => { - await pixelmap.getImageInfo((err, info) => { - expect(info.size.width).assertEqual(size.width); - expect(info.size.height).assertEqual(size.height); - done(); - }); - }) - - } - } catch (error) { - console.info(`${testNum}:: error :${error}`); - expect(false).assertTrue(); - done(); - } - } - - async function testGetThumbnailError(done, testNum, dOp, size,) { - try { - let fetchFileResult = await media.getFileAssets(dOp); - let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchFileResult, 1); - if (!checkAssetCountPass) return; - let asset = await fetchFileResult.getFirstObject(); - asset.getThumbnail(size, async (err, pixelmap) => { - if (err) { - console.info(`${testNum}:: err :${err}`); - expect(true).assertTrue(); - done(); - return; - } - if (pixelmap == undefined) { - expect(true).assertTrue(); - done(); - } else { - const info = await pixelmap.getImageInfo(); - console.info(`${testNum} pixel width: ${info.size.width}`); - console.info(`${testNum} pixel height: ${info.size.height}`); - expect(info.size.width == size.width || info.size.height == size.height).assertFalse(); - done(); - } - }); - } catch (error) { - console.info(`${testNum}:: error :${error}`); - expect(false).assertTrue(); - done(); - } - } - - // ------------------------------ image type start ----------------------- - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_001_01 - * @tc.name : getThumbnail - * @tc.desc : getThumbnail(image) by { width: 128, height: 128 } - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_001_01', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_001_01'; - let dOp = fetchOps(testNum, 'Pictures/Thumbnail/', IMAGE_TYPE); - let size = { width: 128, height: 128 }; - await testGetThumbnail(done, testNum, dOp, size) - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_001_02 - * @tc.name : getThumbnail - * @tc.desc : getThumbnail(image) by { width: 128, height: 256 } - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_001_02', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_001_02'; - let dOp = fetchOps(testNum, 'Pictures/Thumbnail/', IMAGE_TYPE); - let size = { width: 128, height: 256 }; - await testGetThumbnail(done, testNum, dOp, size); - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_001_03 - * @tc.name : getThumbnail - * @tc.desc : getThumbnail(image) by no arg - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_001_03', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_001_03'; - let dOp = fetchOps(testNum, 'Pictures/Thumbnail/', IMAGE_TYPE); - let size = 'default'; - await testGetThumbnail(done, testNum, dOp, size,); - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_001_04 - * @tc.name : getThumbnail - * @tc.desc : getThumbnail(image) by { width: 1, height: 1 } - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_001_04', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_001_04'; - let dOp = fetchOps(testNum, 'Pictures/Thumbnail/', IMAGE_TYPE); - let size = { width: 1, height: 1 }; - await testGetThumbnail(done, testNum, dOp, size,); - }); - - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_001_05 - * @tc.name : getThumbnail - * @tc.desc : getThumbnail(image) by { width: 0, height: 0 } - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_001_05', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_001_05'; - let dOp = fetchOps(testNum, 'Pictures/Thumbnail/', IMAGE_TYPE); - let size = { width: 0, height: 0 }; - await testGetThumbnailError(done, testNum, dOp, size,); - }); - - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_001_06 - * @tc.name : getThumbnail - * @tc.desc : getThumbnail(image) by { width: -128, height: -128 } - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_001_06', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_001_06'; - let dOp = fetchOps(testNum, 'Pictures/Thumbnail/', IMAGE_TYPE); - let size = { width: -128, height: -128 }; - await testGetThumbnailError(done, testNum, dOp, size,); - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_001_07 - * @tc.name : getThumbnail - * @tc.desc : getThumbnail(image) by { width: 1024, height: 1024 } - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_001_07', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_001_07'; - let dOp = fetchOps(testNum, 'Pictures/Thumbnail/', IMAGE_TYPE); - let size = { width: 1024, height: 1024 }; - await testGetThumbnail(done, testNum, dOp, size,); - }); - // ------------------------------image type end-------------------------- - - // ------------------------------video type start ----------------------- - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_002_01 - * @tc.name : getThumbnail - * @tc.desc : getThumbnail(video) by { width: 128, height: 128 } - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_002_01', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_002_01'; - let dOp = fetchOps(testNum, 'Videos/Thumbnail/', VIDEO_TYPE); - let size = { width: 128, height: 128 }; - await testGetThumbnail(done, testNum, dOp, size) - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_002_02 - * @tc.name : getThumbnail - * @tc.desc : getThumbnail(video) by { width: 128, height: 256 } - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_002_02', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_002_02'; - let dOp = fetchOps(testNum, 'Videos/Thumbnail/', VIDEO_TYPE); - let size = { width: 128, height: 256 }; - await testGetThumbnail(done, testNum, dOp, size); - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_002_03 - * @tc.name : getThumbnail - * @tc.desc : getThumbnail(video) by no arg - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_002_03', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_002_03'; - let dOp = fetchOps(testNum, 'Videos/Thumbnail/', VIDEO_TYPE); - let size = 'default'; - await testGetThumbnail(done, testNum, dOp, size,); - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_002_04 - * @tc.name : getThumbnail - * @tc.desc : getThumbnail(video) by { width: 1, height: 1 } - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_002_04', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_002_04'; - let dOp = fetchOps(testNum, 'Videos/Thumbnail/', VIDEO_TYPE); - let size = { width: 1, height: 1 }; - await testGetThumbnail(done, testNum, dOp, size,); - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_002_05 - * @tc.name : getThumbnail - * @tc.desc : getThumbnail(video) by { width: 0, height: 0 } - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_002_05', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_002_05'; - let dOp = fetchOps(testNum, 'Videos/Thumbnail/', VIDEO_TYPE); - let size = { width: 0, height: 0 }; - await testGetThumbnailError(done, testNum, dOp, size,); - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_002_06 - * @tc.name : getThumbnail - * @tc.desc : getThumbnail(video) by { width: -128, height: -128 } - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_002_06', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_002_06'; - let dOp = fetchOps(testNum, 'Videos/Thumbnail/', VIDEO_TYPE); - let size = { width: -128, height: -128 }; - await testGetThumbnailError(done, testNum, dOp, size,); - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_002_07 - * @tc.name : getThumbnail - * @tc.desc : getThumbnail(video) by { width: 1024, height: 1024 } - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_002_07', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_002_07'; - let dOp = fetchOps(testNum, 'Videos/Thumbnail/', VIDEO_TYPE); - let size = { width: 1024, height: 1024 }; - await testGetThumbnail(done, testNum, dOp, size,); - }); - // ------------------------------video type end-------------------------- - - // ------------------------------audio type start ----------------------- - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_003_01 - * @tc.name : getThumbnail - * @tc.desc : getThumbnail(audio) by { width: 128, height: 128 } - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_003_01', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_003_01'; - let dOp = fetchOps(testNum, 'Audios/Thumbnail/', AUDIO_TYPE); - let size = { width: 128, height: 128 }; - await testGetThumbnail(done, testNum, dOp, size) - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_003_02 - * @tc.name : getThumbnail - * @tc.desc : getThumbnail(audio) by { width: 128, height: 256 } - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_003_02', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_003_02'; - let dOp = fetchOps(testNum, 'Audios/Thumbnail/', AUDIO_TYPE); - let size = { width: 128, height: 256 }; - await testGetThumbnail(done, testNum, dOp, size); - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_003_03 - * @tc.name : getThumbnail - * @tc.desc : getThumbnail(audio) by no arg - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_003_03', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_003_03'; - let dOp = fetchOps(testNum, 'Audios/Thumbnail/', AUDIO_TYPE); - let size = 'default'; - await testGetThumbnail(done, testNum, dOp, size,); - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_003_04 - * @tc.name : getThumbnail - * @tc.desc : getThumbnail(audio) by { width: 1, height: 1 } - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_003_04', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_003_04'; - let dOp = fetchOps(testNum, 'Audios/Thumbnail/', AUDIO_TYPE); - let size = { width: 1, height: 1 }; - await testGetThumbnail(done, testNum, dOp, size,); - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_003_05 - * @tc.name : getThumbnail - * @tc.desc : getThumbnail(audio) by { width: 0, height: 0 } - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_003_05', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_003_05'; - let dOp = fetchOps(testNum, 'Audios/Thumbnail/', AUDIO_TYPE); - let size = { width: 0, height: 0 }; - await testGetThumbnailError(done, testNum, dOp, size,); - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_003_06 - * @tc.name : getThumbnail - * @tc.desc : getThumbnail(audio) by { width: -128, height: -128 } - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_003_06', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_003_06'; - let dOp = fetchOps(testNum, 'Audios/Thumbnail/', AUDIO_TYPE); - let size = { width: -128, height: -128 }; - await testGetThumbnailError(done, testNum, dOp, size,); - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_003_07 - * @tc.name : getThumbnail - * @tc.desc : getThumbnail(audio) by { width: 1024, height: 1024 } - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_003_07', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_003_07'; - let dOp = fetchOps(testNum, 'Audios/Thumbnail/', AUDIO_TYPE); - let size = { width: 1024, height: 1024 }; - await testGetThumbnail(done, testNum, dOp, size,); - }); - // ------------------------------audio type end-------------------------- - }); -} - +/* + * Copyright (C) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import mediaLibrary from "@ohos.multimedia.mediaLibrary"; +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "deccjsunit/index"; +import image from "@ohos.multimedia.image"; + +import { + sleep, + IMAGE_TYPE, + VIDEO_TYPE, + AUDIO_TYPE, + checkPresetsAssets, + checkAssetsCount, + fetchOps, + getPermission, +} from "../../../../../../common"; +export default function getThumbnailCallback(abilityContext) { + describe("getThumbnailCallback", function () { + image.createPixelMap(new ArrayBuffer(4096), { size: { height: 1, width: 2 } }).then((pixelmap) => {}); + const media = mediaLibrary.getMediaLibrary(abilityContext); + beforeAll(async function () { + console.info("beforeAll case"); + await getPermission(null, abilityContext); + await checkPresetsAssets(media, "ActsMediaLibraryGetThumbnailTest"); + }); + beforeEach(function () { + console.info("beforeEach case"); + }); + afterEach(async function () { + console.info("afterEach case"); + await sleep(); + }); + afterAll(function () { + console.info("afterAll case"); + }); + + async function testGetThumbnail(done, testNum, dOp, size) { + try { + let fetchFileResult = await media.getFileAssets(dOp); + let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchFileResult, 1); + if (!checkAssetCountPass) return; + let asset = await fetchFileResult.getFirstObject(); + if (size == "default") { + size = { width: 256, height: 256 }; + asset.getThumbnail(async (err, pixelmap) => { + await pixelmap.getImageInfo((err, info) => { + expect(info.size.width).assertEqual(size.width); + expect(info.size.height).assertEqual(size.height); + done(); + }); + }); + } else { + asset.getThumbnail(size, async (err, pixelmap) => { + await pixelmap.getImageInfo((err, info) => { + expect(info.size.width).assertEqual(size.width); + expect(info.size.height).assertEqual(size.height); + done(); + }); + }); + } + } catch (error) { + console.info(`${testNum}:: error :${error}`); + expect(false).assertTrue(); + done(); + } + } + + async function testGetThumbnailError(done, testNum, dOp, size) { + try { + let fetchFileResult = await media.getFileAssets(dOp); + let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchFileResult, 1); + if (!checkAssetCountPass) return; + let asset = await fetchFileResult.getFirstObject(); + asset.getThumbnail(size, async (err, pixelmap) => { + if (err) { + console.info(`${testNum}:: err :${err}`); + expect(true).assertTrue(); + done(); + return; + } + if (pixelmap == undefined) { + expect(true).assertTrue(); + done(); + } else { + const info = await pixelmap.getImageInfo(); + console.info(`${testNum} pixel width: ${info.size.width}`); + console.info(`${testNum} pixel height: ${info.size.height}`); + expect(info.size.width == size.width || info.size.height == size.height).assertFalse(); + done(); + } + }); + } catch (error) { + console.info(`${testNum}:: error :${error}`); + expect(false).assertTrue(); + done(); + } + } + + // ------------------------------ image type start ----------------------- + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_001_01 + * @tc.name : getThumbnail + * @tc.desc : getThumbnail(image) by { width: 128, height: 128 } + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it("SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_001_01", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_001_01"; + let dOp = fetchOps(testNum, "Pictures/Thumbnail/", IMAGE_TYPE); + let size = { width: 128, height: 128 }; + await testGetThumbnail(done, testNum, dOp, size); + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_001_02 + * @tc.name : getThumbnail + * @tc.desc : getThumbnail(image) by { width: 128, height: 256 } + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it("SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_001_02", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_001_02"; + let dOp = fetchOps(testNum, "Pictures/Thumbnail/", IMAGE_TYPE); + let size = { width: 128, height: 256 }; + await testGetThumbnail(done, testNum, dOp, size); + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_001_03 + * @tc.name : getThumbnail + * @tc.desc : getThumbnail(image) by no arg + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it("SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_001_03", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_001_03"; + let dOp = fetchOps(testNum, "Pictures/Thumbnail/", IMAGE_TYPE); + let size = "default"; + await testGetThumbnail(done, testNum, dOp, size); + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_001_04 + * @tc.name : getThumbnail + * @tc.desc : getThumbnail(image) by { width: 1, height: 1 } + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it("SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_001_04", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_001_04"; + let dOp = fetchOps(testNum, "Pictures/Thumbnail/", IMAGE_TYPE); + let size = { width: 1, height: 1 }; + await testGetThumbnail(done, testNum, dOp, size); + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_001_05 + * @tc.name : getThumbnail + * @tc.desc : getThumbnail(image) by { width: 0, height: 0 } + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it("SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_001_05", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_001_05"; + let dOp = fetchOps(testNum, "Pictures/Thumbnail/", IMAGE_TYPE); + let size = { width: 0, height: 0 }; + await testGetThumbnailError(done, testNum, dOp, size); + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_001_06 + * @tc.name : getThumbnail + * @tc.desc : getThumbnail(image) by { width: -128, height: -128 } + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it("SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_001_06", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_001_06"; + let dOp = fetchOps(testNum, "Pictures/Thumbnail/", IMAGE_TYPE); + let size = { width: -128, height: -128 }; + await testGetThumbnailError(done, testNum, dOp, size); + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_001_07 + * @tc.name : getThumbnail + * @tc.desc : getThumbnail(image) by { width: 1024, height: 1024 } + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it("SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_001_07", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_001_07"; + let dOp = fetchOps(testNum, "Pictures/Thumbnail/", IMAGE_TYPE); + let size = { width: 1024, height: 1024 }; + await testGetThumbnail(done, testNum, dOp, size); + }); + // ------------------------------image type end-------------------------- + + // ------------------------------video type start ----------------------- + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_002_01 + * @tc.name : getThumbnail + * @tc.desc : getThumbnail(video) by { width: 128, height: 128 } + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it("SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_002_01", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_002_01"; + let dOp = fetchOps(testNum, "Videos/Thumbnail/", VIDEO_TYPE); + let size = { width: 128, height: 128 }; + await testGetThumbnail(done, testNum, dOp, size); + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_002_02 + * @tc.name : getThumbnail + * @tc.desc : getThumbnail(video) by { width: 128, height: 256 } + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it("SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_002_02", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_002_02"; + let dOp = fetchOps(testNum, "Videos/Thumbnail/", VIDEO_TYPE); + let size = { width: 128, height: 256 }; + await testGetThumbnail(done, testNum, dOp, size); + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_002_03 + * @tc.name : getThumbnail + * @tc.desc : getThumbnail(video) by no arg + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it("SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_002_03", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_002_03"; + let dOp = fetchOps(testNum, "Videos/Thumbnail/", VIDEO_TYPE); + let size = "default"; + await testGetThumbnail(done, testNum, dOp, size); + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_002_04 + * @tc.name : getThumbnail + * @tc.desc : getThumbnail(video) by { width: 1, height: 1 } + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it("SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_002_04", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_002_04"; + let dOp = fetchOps(testNum, "Videos/Thumbnail/", VIDEO_TYPE); + let size = { width: 1, height: 1 }; + await testGetThumbnail(done, testNum, dOp, size); + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_002_05 + * @tc.name : getThumbnail + * @tc.desc : getThumbnail(video) by { width: 0, height: 0 } + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it("SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_002_05", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_002_05"; + let dOp = fetchOps(testNum, "Videos/Thumbnail/", VIDEO_TYPE); + let size = { width: 0, height: 0 }; + await testGetThumbnailError(done, testNum, dOp, size); + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_002_06 + * @tc.name : getThumbnail + * @tc.desc : getThumbnail(video) by { width: -128, height: -128 } + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it("SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_002_06", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_002_06"; + let dOp = fetchOps(testNum, "Videos/Thumbnail/", VIDEO_TYPE); + let size = { width: -128, height: -128 }; + await testGetThumbnailError(done, testNum, dOp, size); + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_002_07 + * @tc.name : getThumbnail + * @tc.desc : getThumbnail(video) by { width: 1024, height: 1024 } + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it("SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_002_07", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_002_07"; + let dOp = fetchOps(testNum, "Videos/Thumbnail/", VIDEO_TYPE); + let size = { width: 1024, height: 1024 }; + await testGetThumbnail(done, testNum, dOp, size); + }); + // ------------------------------video type end-------------------------- + + // ------------------------------audio type start ----------------------- + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_003_01 + * @tc.name : getThumbnail + * @tc.desc : getThumbnail(audio) by { width: 128, height: 128 } + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it("SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_003_01", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_003_01"; + let dOp = fetchOps(testNum, "Audios/Thumbnail/", AUDIO_TYPE); + let size = { width: 128, height: 128 }; + await testGetThumbnail(done, testNum, dOp, size); + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_003_02 + * @tc.name : getThumbnail + * @tc.desc : getThumbnail(audio) by { width: 128, height: 256 } + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it("SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_003_02", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_003_02"; + let dOp = fetchOps(testNum, "Audios/Thumbnail/", AUDIO_TYPE); + let size = { width: 128, height: 256 }; + await testGetThumbnail(done, testNum, dOp, size); + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_003_03 + * @tc.name : getThumbnail + * @tc.desc : getThumbnail(audio) by no arg + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it("SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_003_03", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_003_03"; + let dOp = fetchOps(testNum, "Audios/Thumbnail/", AUDIO_TYPE); + let size = "default"; + await testGetThumbnail(done, testNum, dOp, size); + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_003_04 + * @tc.name : getThumbnail + * @tc.desc : getThumbnail(audio) by { width: 1, height: 1 } + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it("SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_003_04", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_003_04"; + let dOp = fetchOps(testNum, "Audios/Thumbnail/", AUDIO_TYPE); + let size = { width: 1, height: 1 }; + await testGetThumbnail(done, testNum, dOp, size); + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_003_05 + * @tc.name : getThumbnail + * @tc.desc : getThumbnail(audio) by { width: 0, height: 0 } + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it("SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_003_05", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_003_05"; + let dOp = fetchOps(testNum, "Audios/Thumbnail/", AUDIO_TYPE); + let size = { width: 0, height: 0 }; + await testGetThumbnailError(done, testNum, dOp, size); + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_003_06 + * @tc.name : getThumbnail + * @tc.desc : getThumbnail(audio) by { width: -128, height: -128 } + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it("SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_003_06", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_003_06"; + let dOp = fetchOps(testNum, "Audios/Thumbnail/", AUDIO_TYPE); + let size = { width: -128, height: -128 }; + await testGetThumbnailError(done, testNum, dOp, size); + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_003_07 + * @tc.name : getThumbnail + * @tc.desc : getThumbnail(audio) by { width: 1024, height: 1024 } + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it("SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_003_07", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_CALLBACK_003_07"; + let dOp = fetchOps(testNum, "Audios/Thumbnail/", AUDIO_TYPE); + let size = { width: 1024, height: 1024 }; + await testGetThumbnail(done, testNum, dOp, size); + }); + // ------------------------------audio type end-------------------------- + }); +} diff --git a/multimedia/medialibrary/mediaLibrary_getThumbnail/entry/src/main/ets/test/getThumbnailPromise.test.ets b/multimedia/medialibrary/mediaLibrary_getThumbnail/entry/src/main/ets/test/getThumbnailPromise.test.ets old mode 100755 new mode 100644 index eba53d96a254dadbc6d3d8cd9bb91c0da28a9561..68a8cdeda0dfe1efe70c9b543331ddfceb530c1e --- a/multimedia/medialibrary/mediaLibrary_getThumbnail/entry/src/main/ets/test/getThumbnailPromise.test.ets +++ b/multimedia/medialibrary/mediaLibrary_getThumbnail/entry/src/main/ets/test/getThumbnailPromise.test.ets @@ -1,414 +1,411 @@ -/* - * Copyright (C) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import mediaLibrary from '@ohos.multimedia.mediaLibrary'; -import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'; -import image from '@ohos.multimedia.image'; -import { - sleep, - IMAGE_TYPE, - VIDEO_TYPE, - AUDIO_TYPE, - checkAssetsCount, - fetchOps, - getPermission, -} from '../../../../../../common'; - -export default function getThumbnailPromise(abilityContext) { - describe('getThumbnailPromise', function () { - image.createPixelMap(new ArrayBuffer(4096), { size: { height: 1, width: 2 } }).then((pixelmap) => { }); - const media = mediaLibrary.getMediaLibrary(abilityContext); - beforeAll(async function () { - console.info('beforeAll case'); - await getPermission(); - }); - beforeEach(function () { - console.info('beforeEach case'); - }); - afterEach(async function () { - console.info('afterEach case'); - await sleep() - }); - afterAll(function () { - console.info('afterAll case'); - }); - - async function testGetThumbnail(done, testNum, dOp, size,) { - try { - let fetchFileResult = await media.getFileAssets(dOp); - let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchFileResult, 1); - if (!checkAssetCountPass) return; - let asset = await fetchFileResult.getFirstObject(); - console.info(`${testNum}:displayName ${asset.displayName}`) - let pixelmap; - if (size == 'default') { - size = { width: 256, height: 256 }; - pixelmap = await asset.getThumbnail() - } else { - pixelmap = await asset.getThumbnail(size) - } - let info = await pixelmap.getImageInfo(); - expect(info.size.width).assertEqual(size.width); - expect(info.size.height).assertEqual(size.height); - done(); - } catch (error) { - console.info(`${testNum}:: error :${error}`); - expect(false).assertTrue(); - done(); - } - } - - async function testGetThumbnailError(done, testNum, dOp, size,) { - try { - let fetchFileResult = await media.getFileAssets(dOp); - let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchFileResult, 1); - if (!checkAssetCountPass) return; - let asset = await fetchFileResult.getFirstObject(); - let s: mediaLibrary.Size = size; - let pixelmap = await asset.getThumbnail(s); - let info = await pixelmap.getImageInfo(); - console.info(`${testNum}:: pixel width ${info.size.width},pixel height: ${info.size.height}`); - expect(false).assertTrue(); - done(); - } catch (error) { - console.info(`${testNum}:: error :${error}`); - expect(true).assertTrue(); - done(); - } - } - - // ------------------------------ image type start ----------------------- - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_001_01 - * @tc.name : getThumbnail - * @tc.desc : getThumbnail(image) by { width: 128, height: 128 } - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_001_01', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_001_01'; - let dOp = fetchOps(testNum, 'Pictures/Thumbnail/', IMAGE_TYPE); - let size = { width: 128, height: 128 }; - await testGetThumbnail(done, testNum, dOp, size) - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_001_02 - * @tc.name : getThumbnail - * @tc.desc : getThumbnail(image) by { width: 128, height: 256 } - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_001_02', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_001_02'; - let dOp = fetchOps(testNum, 'Pictures/Thumbnail/', IMAGE_TYPE); - let size = { width: 128, height: 256 }; - await testGetThumbnail(done, testNum, dOp, size); - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_001_03 - * @tc.name : getThumbnail - * @tc.desc : getThumbnail(image) by no arg - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_001_03', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_001_03'; - let dOp = fetchOps(testNum, 'Pictures/Thumbnail/', IMAGE_TYPE); - let size = 'default'; - await testGetThumbnail(done, testNum, dOp, size,); - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_001_04 - * @tc.name : getThumbnail - * @tc.desc : getThumbnail(image) by { width: 1, height: 1 } - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_001_04', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_001_04'; - let dOp = fetchOps(testNum, 'Pictures/Thumbnail/', IMAGE_TYPE); - let size = { width: 1, height: 1 }; - await testGetThumbnail(done, testNum, dOp, size,); - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_001_05 - * @tc.name : getThumbnail - * @tc.desc : getThumbnail(image) by { width: 1024, height: 1024 } - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_001_05', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_001_05'; - let dOp = fetchOps(testNum, 'Pictures/Thumbnail/', IMAGE_TYPE); - let size = { width: 0, height: 0 }; - await testGetThumbnailError(done, testNum, dOp, size,); - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_001_06 - * @tc.name : getThumbnail - * @tc.desc : getThumbnail(image) by { width: -128, height: -128 } - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_001_06', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_001_06'; - let dOp = fetchOps(testNum, 'Pictures/Thumbnail/', IMAGE_TYPE); - let size = { width: -128, height: -128 }; - await testGetThumbnailError(done, testNum, dOp, size,); - }); - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_001_07 - * @tc.name : getThumbnail - * @tc.desc : getThumbnail(audio) by { width: 1024, height: 1024 } - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_001_07', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_001_07'; - let dOp = fetchOps(testNum, 'Pictures/Thumbnail/', IMAGE_TYPE); - let size = { width: 1024, height: 1024 }; - await testGetThumbnail(done, testNum, dOp, size,); - }); - // ------------------------------image type end-------------------------- - - // ------------------------------video type start ----------------------- - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_002_01 - * @tc.name : getThumbnail - * @tc.desc : getThumbnail(video) by { width: 128, height: 128 } - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_002_01', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_002_01'; - let dOp = fetchOps(testNum, 'Videos/Thumbnail/', VIDEO_TYPE); - let size = { width: 128, height: 128 }; - await testGetThumbnail(done, testNum, dOp, size) - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_002_02 - * @tc.name : getThumbnail - * @tc.desc : getThumbnail(video) by { width: 128, height: 256 } - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_002_02', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_002_02'; - let dOp = fetchOps(testNum, 'Videos/Thumbnail/', VIDEO_TYPE); - let size = { width: 128, height: 256 }; - await testGetThumbnail(done, testNum, dOp, size); - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_002_03 - * @tc.name : getThumbnail - * @tc.desc : getThumbnail(video) by no arg - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_002_03', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_002_03'; - let dOp = fetchOps(testNum, 'Videos/Thumbnail/', VIDEO_TYPE); - let size = 'default'; - await testGetThumbnail(done, testNum, dOp, size,); - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_002_04 - * @tc.name : getThumbnail - * @tc.desc : getThumbnail(video) by { width: 1, height: 1 } - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_002_04', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_002_04'; - let dOp = fetchOps(testNum, 'Videos/Thumbnail/', VIDEO_TYPE); - let size = { width: 1, height: 1 }; - await testGetThumbnail(done, testNum, dOp, size,); - }); - - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_002_05 - * @tc.name : getThumbnail - * @tc.desc : getThumbnail(video) by { width: 0, height: 0 } - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_002_05', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_002_05'; - let dOp = fetchOps(testNum, 'Videos/Thumbnail/', VIDEO_TYPE); - let size = { width: 0, height: 0 }; - await testGetThumbnailError(done, testNum, dOp, size,); - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_002_06 - * @tc.name : getThumbnail - * @tc.desc : getThumbnail(video) by { width: -128, height: -128 } - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_002_06', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_002_06'; - let dOp = fetchOps(testNum, 'Videos/Thumbnail/', VIDEO_TYPE); - let size = { width: -128, height: -128 }; - await testGetThumbnailError(done, testNum, dOp, size,); - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_002_07 - * @tc.name : getThumbnail - * @tc.desc : getThumbnail(video) by { width: 1024, height: 1024 } - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_002_07', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_002_07'; - let dOp = fetchOps(testNum, 'Videos/Thumbnail/', VIDEO_TYPE); - let size = { width: 1024, height: 1024 }; - await testGetThumbnail(done, testNum, dOp, size,); - }); - // ------------------------------video type end-------------------------- - - // ------------------------------audio type start ----------------------- - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_003_01 - * @tc.name : getThumbnail - * @tc.desc : getThumbnail(audio) by { width: 128, height: 128 } - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_003_01', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_003_01'; - let dOp = fetchOps(testNum, 'Audios/Thumbnail/', AUDIO_TYPE); - let size = { width: 128, height: 128 }; - await testGetThumbnail(done, testNum, dOp, size) - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_003_02 - * @tc.name : getThumbnail - * @tc.desc : getThumbnail(audio) by { width: 128, height: 256 } - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_003_02', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_003_02'; - let dOp = fetchOps(testNum, 'Audios/Thumbnail/', AUDIO_TYPE); - let size = { width: 128, height: 256 }; - await testGetThumbnail(done, testNum, dOp, size); - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_003_03 - * @tc.name : getThumbnail - * @tc.desc : getThumbnail(audio) by no arg - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_003_03', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_003_03'; - let dOp = fetchOps(testNum, 'Audios/Thumbnail/', AUDIO_TYPE); - let size = 'default'; - await testGetThumbnail(done, testNum, dOp, size,); - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_003_04 - * @tc.name : getThumbnail - * @tc.desc : getThumbnail(audio) by { width: 1, height: 1 } - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_003_04', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_003_04'; - let dOp = fetchOps(testNum, 'Audios/Thumbnail/', AUDIO_TYPE); - let size = { width: 1, height: 1 }; - await testGetThumbnail(done, testNum, dOp, size,); - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_003_05 - * @tc.name : getThumbnail - * @tc.desc : getThumbnail(audio) by { width: 0, height: 0 } - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_003_05', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_003_05'; - let dOp = fetchOps(testNum, 'Audios/Thumbnail/', AUDIO_TYPE); - let size = { width: 0, height: 0 }; - await testGetThumbnailError(done, testNum, dOp, size,); - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_003_06 - * @tc.name : getThumbnail - * @tc.desc : getThumbnail(audio) by { width: -128, height: -128 } - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_003_06', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_003_06'; - let dOp = fetchOps(testNum, 'Audios/Thumbnail/', AUDIO_TYPE); - let size = { width: -128, height: -128 }; - await testGetThumbnailError(done, testNum, dOp, size,); - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_003_07 - * @tc.name : getThumbnail - * @tc.desc : getThumbnail(audio) by { width: 1024, height: 1024 } - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_003_07', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_003_07'; - let dOp = fetchOps(testNum, 'Audios/Thumbnail/', AUDIO_TYPE); - let size = { width: 1024, height: 1024 }; - await testGetThumbnail(done, testNum, dOp, size,); - }); - // ------------------------------audio type end-------------------------- - }); -} - +/* + * Copyright (C) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import mediaLibrary from "@ohos.multimedia.mediaLibrary"; +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "deccjsunit/index"; +import image from "@ohos.multimedia.image"; +import { + sleep, + IMAGE_TYPE, + VIDEO_TYPE, + AUDIO_TYPE, + checkAssetsCount, + fetchOps, + getPermission, +} from "../../../../../../common"; + +export default function getThumbnailPromise(abilityContext) { + describe("getThumbnailPromise", function () { + image.createPixelMap(new ArrayBuffer(4096), { size: { height: 1, width: 2 } }).then((pixelmap) => {}); + const media = mediaLibrary.getMediaLibrary(abilityContext); + beforeAll(async function () { + console.info("beforeAll case"); + }); + beforeEach(function () { + console.info("beforeEach case"); + }); + afterEach(async function () { + console.info("afterEach case"); + await sleep(); + }); + afterAll(function () { + console.info("afterAll case"); + }); + + async function testGetThumbnail(done, testNum, dOp, size) { + try { + let fetchFileResult = await media.getFileAssets(dOp); + let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchFileResult, 1); + if (!checkAssetCountPass) return; + let asset = await fetchFileResult.getFirstObject(); + console.info(`${testNum}:displayName ${asset.displayName}`); + let pixelmap; + if (size == "default") { + size = { width: 256, height: 256 }; + pixelmap = await asset.getThumbnail(); + } else { + pixelmap = await asset.getThumbnail(size); + } + let info = await pixelmap.getImageInfo(); + expect(info.size.width).assertEqual(size.width); + expect(info.size.height).assertEqual(size.height); + done(); + } catch (error) { + console.info(`${testNum}:: error :${error}`); + expect(false).assertTrue(); + done(); + } + } + + async function testGetThumbnailError(done, testNum, dOp, size) { + try { + let fetchFileResult = await media.getFileAssets(dOp); + let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchFileResult, 1); + if (!checkAssetCountPass) return; + let asset = await fetchFileResult.getFirstObject(); + let s: mediaLibrary.Size = size; + let pixelmap = await asset.getThumbnail(s); + let info = await pixelmap.getImageInfo(); + console.info(`${testNum}:: pixel width ${info.size.width},pixel height: ${info.size.height}`); + expect(false).assertTrue(); + done(); + } catch (error) { + console.info(`${testNum}:: error :${error}`); + expect(true).assertTrue(); + done(); + } + } + + // ------------------------------ image type start ----------------------- + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_001_01 + * @tc.name : getThumbnail + * @tc.desc : getThumbnail(image) by { width: 128, height: 128 } + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it("SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_001_01", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_001_01"; + let dOp = fetchOps(testNum, "Pictures/Thumbnail/", IMAGE_TYPE); + let size = { width: 128, height: 128 }; + await testGetThumbnail(done, testNum, dOp, size); + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_001_02 + * @tc.name : getThumbnail + * @tc.desc : getThumbnail(image) by { width: 128, height: 256 } + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it("SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_001_02", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_001_02"; + let dOp = fetchOps(testNum, "Pictures/Thumbnail/", IMAGE_TYPE); + let size = { width: 128, height: 256 }; + await testGetThumbnail(done, testNum, dOp, size); + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_001_03 + * @tc.name : getThumbnail + * @tc.desc : getThumbnail(image) by no arg + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it("SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_001_03", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_001_03"; + let dOp = fetchOps(testNum, "Pictures/Thumbnail/", IMAGE_TYPE); + let size = "default"; + await testGetThumbnail(done, testNum, dOp, size); + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_001_04 + * @tc.name : getThumbnail + * @tc.desc : getThumbnail(image) by { width: 1, height: 1 } + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it("SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_001_04", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_001_04"; + let dOp = fetchOps(testNum, "Pictures/Thumbnail/", IMAGE_TYPE); + let size = { width: 1, height: 1 }; + await testGetThumbnail(done, testNum, dOp, size); + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_001_05 + * @tc.name : getThumbnail + * @tc.desc : getThumbnail(image) by { width: 1024, height: 1024 } + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it("SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_001_05", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_001_05"; + let dOp = fetchOps(testNum, "Pictures/Thumbnail/", IMAGE_TYPE); + let size = { width: 0, height: 0 }; + await testGetThumbnailError(done, testNum, dOp, size); + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_001_06 + * @tc.name : getThumbnail + * @tc.desc : getThumbnail(image) by { width: -128, height: -128 } + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it("SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_001_06", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_001_06"; + let dOp = fetchOps(testNum, "Pictures/Thumbnail/", IMAGE_TYPE); + let size = { width: -128, height: -128 }; + await testGetThumbnailError(done, testNum, dOp, size); + }); + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_001_07 + * @tc.name : getThumbnail + * @tc.desc : getThumbnail(audio) by { width: 1024, height: 1024 } + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it("SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_001_07", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_001_07"; + let dOp = fetchOps(testNum, "Pictures/Thumbnail/", IMAGE_TYPE); + let size = { width: 1024, height: 1024 }; + await testGetThumbnail(done, testNum, dOp, size); + }); + // ------------------------------image type end-------------------------- + + // ------------------------------video type start ----------------------- + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_002_01 + * @tc.name : getThumbnail + * @tc.desc : getThumbnail(video) by { width: 128, height: 128 } + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it("SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_002_01", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_002_01"; + let dOp = fetchOps(testNum, "Videos/Thumbnail/", VIDEO_TYPE); + let size = { width: 128, height: 128 }; + await testGetThumbnail(done, testNum, dOp, size); + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_002_02 + * @tc.name : getThumbnail + * @tc.desc : getThumbnail(video) by { width: 128, height: 256 } + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it("SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_002_02", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_002_02"; + let dOp = fetchOps(testNum, "Videos/Thumbnail/", VIDEO_TYPE); + let size = { width: 128, height: 256 }; + await testGetThumbnail(done, testNum, dOp, size); + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_002_03 + * @tc.name : getThumbnail + * @tc.desc : getThumbnail(video) by no arg + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it("SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_002_03", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_002_03"; + let dOp = fetchOps(testNum, "Videos/Thumbnail/", VIDEO_TYPE); + let size = "default"; + await testGetThumbnail(done, testNum, dOp, size); + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_002_04 + * @tc.name : getThumbnail + * @tc.desc : getThumbnail(video) by { width: 1, height: 1 } + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it("SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_002_04", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_002_04"; + let dOp = fetchOps(testNum, "Videos/Thumbnail/", VIDEO_TYPE); + let size = { width: 1, height: 1 }; + await testGetThumbnail(done, testNum, dOp, size); + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_002_05 + * @tc.name : getThumbnail + * @tc.desc : getThumbnail(video) by { width: 0, height: 0 } + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it("SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_002_05", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_002_05"; + let dOp = fetchOps(testNum, "Videos/Thumbnail/", VIDEO_TYPE); + let size = { width: 0, height: 0 }; + await testGetThumbnailError(done, testNum, dOp, size); + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_002_06 + * @tc.name : getThumbnail + * @tc.desc : getThumbnail(video) by { width: -128, height: -128 } + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it("SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_002_06", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_002_06"; + let dOp = fetchOps(testNum, "Videos/Thumbnail/", VIDEO_TYPE); + let size = { width: -128, height: -128 }; + await testGetThumbnailError(done, testNum, dOp, size); + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_002_07 + * @tc.name : getThumbnail + * @tc.desc : getThumbnail(video) by { width: 1024, height: 1024 } + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it("SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_002_07", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_002_07"; + let dOp = fetchOps(testNum, "Videos/Thumbnail/", VIDEO_TYPE); + let size = { width: 1024, height: 1024 }; + await testGetThumbnail(done, testNum, dOp, size); + }); + // ------------------------------video type end-------------------------- + + // ------------------------------audio type start ----------------------- + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_003_01 + * @tc.name : getThumbnail + * @tc.desc : getThumbnail(audio) by { width: 128, height: 128 } + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it("SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_003_01", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_003_01"; + let dOp = fetchOps(testNum, "Audios/Thumbnail/", AUDIO_TYPE); + let size = { width: 128, height: 128 }; + await testGetThumbnail(done, testNum, dOp, size); + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_003_02 + * @tc.name : getThumbnail + * @tc.desc : getThumbnail(audio) by { width: 128, height: 256 } + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it("SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_003_02", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_003_02"; + let dOp = fetchOps(testNum, "Audios/Thumbnail/", AUDIO_TYPE); + let size = { width: 128, height: 256 }; + await testGetThumbnail(done, testNum, dOp, size); + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_003_03 + * @tc.name : getThumbnail + * @tc.desc : getThumbnail(audio) by no arg + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it("SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_003_03", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_003_03"; + let dOp = fetchOps(testNum, "Audios/Thumbnail/", AUDIO_TYPE); + let size = "default"; + await testGetThumbnail(done, testNum, dOp, size); + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_003_04 + * @tc.name : getThumbnail + * @tc.desc : getThumbnail(audio) by { width: 1, height: 1 } + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it("SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_003_04", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_003_04"; + let dOp = fetchOps(testNum, "Audios/Thumbnail/", AUDIO_TYPE); + let size = { width: 1, height: 1 }; + await testGetThumbnail(done, testNum, dOp, size); + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_003_05 + * @tc.name : getThumbnail + * @tc.desc : getThumbnail(audio) by { width: 0, height: 0 } + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it("SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_003_05", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_003_05"; + let dOp = fetchOps(testNum, "Audios/Thumbnail/", AUDIO_TYPE); + let size = { width: 0, height: 0 }; + await testGetThumbnailError(done, testNum, dOp, size); + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_003_06 + * @tc.name : getThumbnail + * @tc.desc : getThumbnail(audio) by { width: -128, height: -128 } + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it("SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_003_06", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_003_06"; + let dOp = fetchOps(testNum, "Audios/Thumbnail/", AUDIO_TYPE); + let size = { width: -128, height: -128 }; + await testGetThumbnailError(done, testNum, dOp, size); + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_003_07 + * @tc.name : getThumbnail + * @tc.desc : getThumbnail(audio) by { width: 1024, height: 1024 } + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it("SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_003_07", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_003_07"; + let dOp = fetchOps(testNum, "Audios/Thumbnail/", AUDIO_TYPE); + let size = { width: 1024, height: 1024 }; + await testGetThumbnail(done, testNum, dOp, size); + }); + // ------------------------------audio type end-------------------------- + }); +} diff --git a/multimedia/medialibrary/mediaLibrary_getThumbnail/entry/src/main/module.json b/multimedia/medialibrary/mediaLibrary_getThumbnail/entry/src/main/module.json old mode 100755 new mode 100644 index 6785829959ef1d93e26aaea687a2ec9bb759d52d..025062ffed12b44b32db7f5f35356c9040ed9c5c --- a/multimedia/medialibrary/mediaLibrary_getThumbnail/entry/src/main/module.json +++ b/multimedia/medialibrary/mediaLibrary_getThumbnail/entry/src/main/module.json @@ -3,11 +3,11 @@ "name": "phone", "type": "entry", "srcEntrance": "./ets/Application/AbilityStage.ts", - "description": "$string:mainability_description", + "description": "$string:phone_entry_dsc", "mainElement": "MainAbility", "deviceTypes": [ - "tablet", - "default", + "tablet", + "default", "phone" ], "deliveryWithInstall": true, @@ -16,11 +16,11 @@ "pages": "$profile:main_pages", "abilities": [ { - "name": "ohos.acts.multimedia.mediaLibrary.MainAbility", + "name": "com.example.myapplication.MainAbility", "srcEntrance": "./ets/MainAbility/MainAbility.ts", - "description": "$string:mainability_description", + "description": "$string:phone_entry_main", "icon": "$media:icon", - "label": "$string:entry_MainAbility", + "label": "$string:entry_label", "visible": true, "orientation": "portrait", "skills": [ @@ -28,42 +28,42 @@ "actions": [ "action.system.home" ], - "entities":[ + "entities": [ "entity.system.home" ] } ] } ], - "requestPermissions": [ + "requestPermissions": [ { "name": "ohos.permission.GET_BUNDLE_INFO", "reason": "use ohos.permission.GET_BUNDLE_INFO" }, { "name": "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED", - "reason":"use ohos.permission.GET_BUNDLE_INFO_PRIVILEGED" + "reason": "use ohos.permission.GET_BUNDLE_INFO_PRIVILEGED" }, { - "name" : "ohos.permission.GRANT_SENSITIVE_PERMISSIONS", - "reason" : "use ohos.permission.GRANT_SENSITIVE_PERMISSIONS" + "name": "ohos.permission.GRANT_SENSITIVE_PERMISSIONS", + "reason": "use ohos.permission.GRANT_SENSITIVE_PERMISSIONS" }, { - "name" : "ohos.permission.REVOKE_SENSITIVE_PERMISSIONS", - "reason" : "use ohos.permission.REVOKE_SENSITIVE_PERMISSIONS" + "name": "ohos.permission.REVOKE_SENSITIVE_PERMISSIONS", + "reason": "use ohos.permission.REVOKE_SENSITIVE_PERMISSIONS" }, { "name": "ohos.permission.MEDIA_LOCATION", - "reason":"use ohos.permission.MEDIA_LOCATION" + "reason": "use ohos.permission.MEDIA_LOCATION" }, { "name": "ohos.permission.READ_MEDIA", - "reason":"use ohos.permission.READ_MEDIA" + "reason": "use ohos.permission.READ_MEDIA" }, { "name": "ohos.permission.WRITE_MEDIA", - "reason":"use ohos.permission.WRITE_MEDIA" + "reason": "use ohos.permission.WRITE_MEDIA" } ] } -} +} \ No newline at end of file diff --git a/multimedia/medialibrary/mediaLibrary_getThumbnail/entry/src/main/resources/base/element/string.json b/multimedia/medialibrary/mediaLibrary_getThumbnail/entry/src/main/resources/base/element/string.json old mode 100755 new mode 100644 index d75a3fee650de2abaabfd60f40d90d9c6a4b0b0b..2ae43f018e75d1140cf2c0c85a6a14fc369a0c50 --- a/multimedia/medialibrary/mediaLibrary_getThumbnail/entry/src/main/resources/base/element/string.json +++ b/multimedia/medialibrary/mediaLibrary_getThumbnail/entry/src/main/resources/base/element/string.json @@ -1,12 +1,32 @@ { "string": [ - { - "name": "entry_MainAbility", - "value": "MediaLibraryJSTestMain" - }, - { - "name": "mainability_description", - "value": "MediaLibraryJSTestMain Ability" - } + { + "name": "phone_entry_dsc", + "value": "i am an entry for phone" + }, + { + "name": "phone_entry_main", + "value": "the phone entry ability" + }, + { + "name": "entry_label", + "value": "ActsMediaLibraryTest" + }, + { + "name": "form_description", + "value": "mediaLibrary" + }, + { + "name": "serviceability_description", + "value": "mediaLibrary" + }, + { + "name": "description_application", + "value": "mediaLibrary test" + }, + { + "name": "app_name", + "value": "ActsMediaLibraryTest" + } ] - } \ No newline at end of file +} \ No newline at end of file diff --git a/multimedia/medialibrary/mediaLibrary_getThumbnail/entry/src/main/resources/base/profile/main_pages.json b/multimedia/medialibrary/mediaLibrary_getThumbnail/entry/src/main/resources/base/profile/main_pages.json old mode 100755 new mode 100644 index 6898b31d2085f478ee1ed9d933a5910cbf901d92..ceb075cd80946aade673d707aac904fb8998bce9 --- a/multimedia/medialibrary/mediaLibrary_getThumbnail/entry/src/main/resources/base/profile/main_pages.json +++ b/multimedia/medialibrary/mediaLibrary_getThumbnail/entry/src/main/resources/base/profile/main_pages.json @@ -1,6 +1,5 @@ { "src": [ - "pages/index/index", - "pages/second/second" + "MainAbility/pages/index/index" ] } \ No newline at end of file diff --git a/multimedia/medialibrary/mediaLibrary_getThumbnail/signature/openharmony_sx.p7b b/multimedia/medialibrary/mediaLibrary_getThumbnail/signature/openharmony_sx.p7b old mode 100755 new mode 100644 index 3eb5b5db82a014ff4c9483872cad743ad49a9b6e..64b33bf079b2ab68a3f26f240d127186546b33d9 Binary files a/multimedia/medialibrary/mediaLibrary_getThumbnail/signature/openharmony_sx.p7b and b/multimedia/medialibrary/mediaLibrary_getThumbnail/signature/openharmony_sx.p7b differ diff --git a/multimedia/medialibrary/mediaLibrary_mediafetchoptions/AppScope/app.json b/multimedia/medialibrary/mediaLibrary_mediafetchoptions/AppScope/app.json index 5139eaad5d5fd2e2de13b4970785d6fa8ae1a4ba..803955ad0d2a5b4ce4e103816a6a917b4701286b 100644 --- a/multimedia/medialibrary/mediaLibrary_mediafetchoptions/AppScope/app.json +++ b/multimedia/medialibrary/mediaLibrary_mediafetchoptions/AppScope/app.json @@ -1,21 +1,21 @@ { - "app":{ - "bundleName":"ohos.acts.multimedia.mediaLibrary", - "vendor":"huawei", - "versionCode":1000000, - "versionName":"1.0.0", - "debug":false, - "icon":"$media:icon", - "label":"$string:entry_MainAbility", - "description":"$string:mainability_description", - "distributedNotificationEnabled":true, - "keepAlive":true, - "singleUser":true, - "minAPIVersion":8, - "targetAPIVersion":8, - "car":{ - "apiCompatibleVersion":8, - "singleUser":false + "app": { + "bundleName": "ohos.acts.multimedia.mediaLibrary", + "vendor": "huawei", + "versionCode": 1000000, + "versionName": "1.0.0", + "debug": false, + "icon": "$media:icon", + "label": "$string:app_name", + "description": "$string:description_application", + "distributedNotificationEnabled": true, + "keepAlive": true, + "singleUser": true, + "minAPIVersion": 9, + "targetAPIVersion": 9, + "car": { + "apiCompatibleVersion": 9, + "singleUser": false } } -} +} \ No newline at end of file diff --git a/multimedia/medialibrary/mediaLibrary_mediafetchoptions/AppScope/resources/base/element/string.json b/multimedia/medialibrary/mediaLibrary_mediafetchoptions/AppScope/resources/base/element/string.json index c1dee63527ae5e3c37f3736f6b68189e8df6f201..ee69f9a861d9dc269ed6638735d52674583498e1 100644 --- a/multimedia/medialibrary/mediaLibrary_mediafetchoptions/AppScope/resources/base/element/string.json +++ b/multimedia/medialibrary/mediaLibrary_mediafetchoptions/AppScope/resources/base/element/string.json @@ -1,12 +1,8 @@ { - "string": [ + "string":[ { - "name": "entry_MainAbility", - "value": "MediaLibraryJSTestMain" - }, - { - "name": "mainability_description", - "value": "MediaLibraryJSTestMain Ability" + "name":"app_name", + "value":"ohosProject" } ] -} \ No newline at end of file +} \ No newline at end of file diff --git a/multimedia/medialibrary/mediaLibrary_mediafetchoptions/BUILD.gn b/multimedia/medialibrary/mediaLibrary_mediafetchoptions/BUILD.gn index 45fae924f4e70d51e06d6017155c2b0e4f22a217..7b5f777c28b313b36e86e12e7989e5747a0cc29a 100644 --- a/multimedia/medialibrary/mediaLibrary_mediafetchoptions/BUILD.gn +++ b/multimedia/medialibrary/mediaLibrary_mediafetchoptions/BUILD.gn @@ -15,6 +15,7 @@ import("//test/xts/tools/build/suite.gni") ohos_js_hap_suite("mediaLibrary_mediafetchoptions_hap") { hap_profile = "entry/src/main/module.json" + js_build_mode = "debug" deps = [ ":mediaLibrary_js_assets", ":mediaLibrary_resources", diff --git a/multimedia/medialibrary/mediaLibrary_mediafetchoptions/Test.json b/multimedia/medialibrary/mediaLibrary_mediafetchoptions/Test.json index 5d30421e19b4e136267e51c946d88a6a4855e2dc..9a05a5d38b58556e571622e696c5fa3190e880b8 100644 --- a/multimedia/medialibrary/mediaLibrary_mediafetchoptions/Test.json +++ b/multimedia/medialibrary/mediaLibrary_mediafetchoptions/Test.json @@ -1,10 +1,12 @@ { "description": "Configuration for mediaLibrary Tests", "driver": { - "type": "JSUnitTest", - "test-timeout": "300000", - "package": "ohos.acts.multimedia.mediaLibrary", - "shell-timeout": "600000" + "type": "OHJSUnitTest", + "test-timeout": "180000", + "bundle-name": "ohos.acts.multimedia.mediaLibrary", + "module-name": "phone", + "shell-timeout": "600000", + "testcase-timeout": 70000 }, "kits": [ { @@ -14,7 +16,10 @@ "rm -rf /storage/media/100/local/files/*", "rm -rf /data/app/el2/100/database/com.ohos.medialibrary.medialibrarydata/*", "mkdir -pv /storage/media/100/local/files/{Pictures,Videos,Audios,Documents}", - "mkdir -p /storage/media/100/local/temp" + "mkdir -p /storage/media/100/local/temp", + "power-shell wakeup", + "uinput -T -d 300 600 -m 300 600 300 100 -u 300 100", + "power-shell setmode 602" ] }, { @@ -47,8 +52,9 @@ "scanner", "sleep 10" ], - "teardown-command":[ - "hilog -b X -D 0xD002B70" + "teardown-command": [ + "hilog -b X -D 0xD002B70", + "power-shell setmode 600" ] }, { diff --git a/multimedia/medialibrary/mediaLibrary_mediafetchoptions/entry/src/main/ets/Application/AbilityStage.ts b/multimedia/medialibrary/mediaLibrary_mediafetchoptions/entry/src/main/ets/Application/AbilityStage.ts index 51cb02ba3f5c7011c1cd433d07deebd47a195704..e3fdadfebeeeb676df2ce8f78f4b59e26fae9cf0 100644 --- a/multimedia/medialibrary/mediaLibrary_mediafetchoptions/entry/src/main/ets/Application/AbilityStage.ts +++ b/multimedia/medialibrary/mediaLibrary_mediafetchoptions/entry/src/main/ets/Application/AbilityStage.ts @@ -3,7 +3,7 @@ import AbilityStage from "@ohos.application.AbilityStage" export default class MyAbilityStage extends AbilityStage { onCreate() { console.log("[Demo] MyAbilityStage onCreate") - globalThis.stageOnCreateRun = 1; - globalThis.stageContext = this.context; + globalThis.stageOnCreateRun = 1; + globalThis.stageContext = this.context; } } diff --git a/multimedia/medialibrary/mediaLibrary_mediafetchoptions/entry/src/main/ets/MainAbility/MainAbility.ts b/multimedia/medialibrary/mediaLibrary_mediafetchoptions/entry/src/main/ets/MainAbility/MainAbility.ts index 2f9d6d1f23f95d9fc891fbc550cd5a589cfb6c89..83c0cd68bb2c044c9b98d212a62851b32bd9af9a 100644 --- a/multimedia/medialibrary/mediaLibrary_mediafetchoptions/entry/src/main/ets/MainAbility/MainAbility.ts +++ b/multimedia/medialibrary/mediaLibrary_mediafetchoptions/entry/src/main/ets/MainAbility/MainAbility.ts @@ -1,7 +1,7 @@ import Ability from '@ohos.application.Ability' export default class MainAbility extends Ability { - onCreate(want,launchParam){ + onCreate(want, launchParam) { // Ability is creating, initialize resources for this ability console.log("[Demo] MainAbility onCreate") globalThis.abilityWant = want; @@ -12,11 +12,11 @@ export default class MainAbility extends Ability { console.log("[Demo] MainAbility onDestroy") } - onWindowStageCreate(windowStage) { - // Main window is created, set main page for this ability - console.log("[Demo] MainAbility onWindowStageCreate") + async onWindowStageCreate(windowStage) { + console.log("[Demo] MainAbility onWindowStageCreate windowStage=" + windowStage) + globalThis.windowStage = windowStage globalThis.abilityContext = this.context - windowStage.setUIContent(this.context, "pages/index/index", null) + windowStage.setUIContent(this.context, "MainAbility/pages/index/index", null) } onWindowStageDestroy() { diff --git a/multimedia/medialibrary/mediaLibrary_mediafetchoptions/entry/src/main/ets/MainAbility/pages/index/index.ets b/multimedia/medialibrary/mediaLibrary_mediafetchoptions/entry/src/main/ets/MainAbility/pages/index/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..6a8c567d5a86048b1c269e4f00cc288ec136200b --- /dev/null +++ b/multimedia/medialibrary/mediaLibrary_mediafetchoptions/entry/src/main/ets/MainAbility/pages/index/index.ets @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import router from '@ohos.router'; +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' +import { Hypium } from '@ohos/hypium' +import testsuite from '../../../test/List.test' + + +@Entry +@Component +struct Index { + + aboutToAppear(){ + console.info("start run testcase!!!!") + var abilityDelegator: any + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var abilityDelegatorArguments: any + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + console.info('start run testcase!!!') + Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) + } + + build() { + Flex({ direction:FlexDirection.Column, alignItems:ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text('Hello World') + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('next page') + .fontSize(25) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .onClick(() => { + + }) + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/multimedia/medialibrary/mediaLibrary_mediafetchoptions/entry/src/main/ets/TestAbility/TestAbility.ts b/multimedia/medialibrary/mediaLibrary_mediafetchoptions/entry/src/main/ets/TestAbility/TestAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..8028a70f8af44690b95a08bd177bca6b09f24687 --- /dev/null +++ b/multimedia/medialibrary/mediaLibrary_mediafetchoptions/entry/src/main/ets/TestAbility/TestAbility.ts @@ -0,0 +1,50 @@ +/* + * 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 Ability from '@ohos.app.ability.UIAbility' + +export default class TestAbility extends Ability { + onCreate(want, launchParam) { + console.log('TestAbility onCreate') + } + + onDestroy() { + console.log('TestAbility onDestroy') + } + + onWindowStageCreate(windowStage) { + console.log('TestAbility onWindowStageCreate') + windowStage.loadContent("TestAbility/pages/index", (err, data) => { + if (err.code) { + console.error('Failed to load the content. Cause:' + JSON.stringify(err)); + return; + } + console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data)) + }); + + globalThis.abilityContext = this.context; + } + + onWindowStageDestroy() { + console.log('TestAbility onWindowStageDestroy') + } + + onForeground() { + console.log('TestAbility onForeground') + } + + onBackground() { + console.log('TestAbility onBackground') + } +}; \ No newline at end of file diff --git a/multimedia/medialibrary/mediaLibrary_mediafetchoptions/entry/src/main/ets/TestAbility/pages/index.ets b/multimedia/medialibrary/mediaLibrary_mediafetchoptions/entry/src/main/ets/TestAbility/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..b93567f962921124b282f78c8ef123965d1460c9 --- /dev/null +++ b/multimedia/medialibrary/mediaLibrary_mediafetchoptions/entry/src/main/ets/TestAbility/pages/index.ets @@ -0,0 +1,48 @@ +/* + * 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 router from '@ohos.router'; + +@Entry +@Component +struct Index { + aboutToAppear() { + console.info('TestAbility index aboutToAppear') + } + @State message: string = 'Hello World' + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('next page') + .fontSize(20) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .width('35%') + .height('5%') + .onClick(()=>{ + }) + } + .width('100%') + } + .height('100%') + } + } \ No newline at end of file diff --git a/multimedia/medialibrary/mediaLibrary_mediafetchoptions/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts b/multimedia/medialibrary/mediaLibrary_mediafetchoptions/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts new file mode 100644 index 0000000000000000000000000000000000000000..a4ee2f1652b3d04ce83ece64ef70f8dfa62a2dc8 --- /dev/null +++ b/multimedia/medialibrary/mediaLibrary_mediafetchoptions/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts @@ -0,0 +1,78 @@ +/* + * 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 TestRunner from '@ohos.application.testRunner' +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' + +var abilityDelegator = undefined +var abilityDelegatorArguments = undefined + +function translateParamsToString(parameters) { + const keySet = new Set([ + '-s class', '-s notClass', '-s suite', '-s it', + '-s level', '-s testType', '-s size', '-s timeout', + '-s dryRun' + ]) + let targetParams = ''; + for (const key in parameters) { + if (keySet.has(key)) { + targetParams = `${targetParams} ${key} ${parameters[key]}` + } + } + return targetParams.trim() +} + +async function onAbilityCreateCallback() { + console.log("onAbilityCreateCallback"); +} + +async function addAbilityMonitorCallback(err: any) { + console.info("addAbilityMonitorCallback : " + JSON.stringify(err)) +} + +export default class OpenHarmonyTestRunner implements TestRunner { + constructor() { + } + + onPrepare() { + console.info("OpenHarmonyTestRunner OnPrepare ") + } + + async onRun() { + console.log('OpenHarmonyTestRunner onRun run') + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var testAbilityName = abilityDelegatorArguments.bundleName + '.MainAbility' + let lMonitor = { + abilityName: testAbilityName, + onAbilityCreate: onAbilityCreateCallback, + }; + abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback) + var cmd = 'aa start -d 0 -a com.example.myapplication.MainAbility' + ' -b ' + abilityDelegatorArguments.bundleName + cmd += ' '+translateParamsToString(abilityDelegatorArguments.parameters) + var debug = abilityDelegatorArguments.parameters["-D"] + if (debug == 'true') + { + cmd += ' -D' + } + console.info('cmd : '+cmd) + abilityDelegator.executeShellCommand(cmd, + (err: any, d: any) => { + console.info('executeShellCommand : err : ' + JSON.stringify(err)); + console.info('executeShellCommand : data : ' + d.stdResult); + console.info('executeShellCommand : data : ' + d.exitCode); + }) + console.info('OpenHarmonyTestRunner onRun end') + } +}; \ No newline at end of file diff --git a/multimedia/medialibrary/mediaLibrary_mediafetchoptions/entry/src/main/ets/pages/second/second.ets b/multimedia/medialibrary/mediaLibrary_mediafetchoptions/entry/src/main/ets/pages/second/second.ets deleted file mode 100644 index 1c1c727ff11ecc97909f482c35268db87ae23bb4..0000000000000000000000000000000000000000 --- a/multimedia/medialibrary/mediaLibrary_mediafetchoptions/entry/src/main/ets/pages/second/second.ets +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import router from '@system.router'; - -@Entry -@Component -struct Second { - private content: string = "Second Page" - - build() { - Flex({ direction: FlexDirection.Column,alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { - Text(`${this.content}`) - .fontSize(50) - .fontWeight(FontWeight.Bold) - Button() { - Text('back to index') - .fontSize(20) - .fontWeight(FontWeight.Bold) - }.type(ButtonType.Capsule) - .margin({ - top: 20 - }) - .backgroundColor('#0D9FFB') - .onClick(() => { - router.back() - }) - } - .width('100%') - .height('100%') - } -} \ No newline at end of file diff --git a/multimedia/medialibrary/mediaLibrary_mediafetchoptions/entry/src/main/ets/test/List.test.ets b/multimedia/medialibrary/mediaLibrary_mediafetchoptions/entry/src/main/ets/test/List.test.ets index 30869c780b32d0f9ded432716328c187a521966f..4c74f24aa93f0bef83856f2bb1bd59b948be4042 100644 --- a/multimedia/medialibrary/mediaLibrary_mediafetchoptions/entry/src/main/ets/test/List.test.ets +++ b/multimedia/medialibrary/mediaLibrary_mediafetchoptions/entry/src/main/ets/test/List.test.ets @@ -1,21 +1,21 @@ -/* - * 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 mediafetchoptionsCallback from './mediafetchoptionsCallback.test.ets' -import mediafetchoptionsPromise from './mediafetchoptionsPromise.test.ets' -export default function testsuite(abilityContext) { - mediafetchoptionsCallback(abilityContext) - mediafetchoptionsPromise(abilityContext) -} +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import mediafetchoptionsCallback from './mediafetchoptionsCallback.test.ets' +import mediafetchoptionsPromise from './mediafetchoptionsPromise.test.ets' +export default function testsuite() { + mediafetchoptionsCallback(globalThis.abilityContext) + mediafetchoptionsPromise(globalThis.abilityContext) +} diff --git a/multimedia/medialibrary/mediaLibrary_mediafetchoptions/entry/src/main/ets/test/mediafetchoptionsCallback.test.ets b/multimedia/medialibrary/mediaLibrary_mediafetchoptions/entry/src/main/ets/test/mediafetchoptionsCallback.test.ets index 971362f3ce5929d5f9c991560205738d74b687d2..4ae9f450a198e960ea3ec5dec4ff5735ede7ea50 100644 --- a/multimedia/medialibrary/mediaLibrary_mediafetchoptions/entry/src/main/ets/test/mediafetchoptionsCallback.test.ets +++ b/multimedia/medialibrary/mediaLibrary_mediafetchoptions/entry/src/main/ets/test/mediafetchoptionsCallback.test.ets @@ -1,149 +1,147 @@ -/* - * Copyright (C) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import mediaLibrary from '@ohos.multimedia.mediaLibrary'; - -import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'; - -import { - sleep, - IMAGE_TYPE, - AUDIO_TYPE, - VIDEO_TYPE, - FILE_TYPE, - checkPresetsAssets, - checkAssetsCount, - fetchOps, - getPermission, -} from '../../../../../../common'; - -export default function mediafetchoptionsCallback(abilityContext) { - describe('mediafetchoptionsCallback', function () { - const media = mediaLibrary.getMediaLibrary(abilityContext); - beforeAll(async function () { - console.info('beforeAll case'); - await getPermission(); - await checkPresetsAssets(media, 'ActsMediaLibraryMediafetchoptionsTest'); - }); - beforeEach(function () { - console.info('beforeEach case'); - }); - afterEach(async function () { - console.info('afterEach case'); - await sleep() - }); - afterAll(function () { - console.info('afterAll case'); - }); - const serachUri = async (done, testNum, fetchOp, type) => { - try { - const fetchFileResult = await media.getFileAssets(fetchOp); - let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchFileResult, 2); - if (!checkAssetCountPass) return; - let firstObject = await fetchFileResult.getFirstObject(); - const id = firstObject.id; - const uri = firstObject.uri; - const serachUri = `datashare:///media/${type}/${id}`; - console.info(`${testNum} :uri ${uri};serachUri${serachUri})`) - - let serchfetchOp = { - uri: serachUri.toString(), - selections: '', - selectionArgs: [], - }; - - media.getFileAssets(serchfetchOp, async (err, result) => { - if (err) { - console.info(`${testNum}, err: ${err}`) - expect(false).assertTrue(); - done(); - return; - } - checkAssetCountPass = await checkAssetsCount(done, testNum, result, 1); - if (!checkAssetCountPass) return; - let asset = await result.getFirstObject(); - expect(asset.uri).assertEqual(serachUri); - expect(asset.id).assertEqual(id); - done(); - }); - - } catch (error) { - console.info(`${testNum} failed error: ${error}`) - expect(false).assertTrue(); - done(); - } - } - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_ASSET_URI_CALLBACK_001 - * @tc.name : uri - * @tc.desc : serach image asset by uri - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_ASSET_URI_CALLBACK_001', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_ASSET_URI_CALLBACK_001'; - let currentFetchOp = fetchOps(testNum, 'Pictures/Static/', IMAGE_TYPE); - let type = 'image'; - await serachUri(done, testNum, currentFetchOp, type); - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_ASSET_URI_CALLBACK_002 - * @tc.name : uri - * @tc.desc : serach audio asset by uri - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_ASSET_URI_CALLBACK_002', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_ASSET_URI_CALLBACK_002'; - let currentFetchOp = fetchOps(testNum, 'Audios/Static/', AUDIO_TYPE); - let type = 'audio'; - await serachUri(done, testNum, currentFetchOp, type); - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_ASSET_URI_CALLBACK_003 - * @tc.name : uri - * @tc.desc : serach video asset by uri - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_ASSET_URI_CALLBACK_003', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_ASSET_URI_CALLBACK_003'; - let currentFetchOp = fetchOps(testNum, 'Videos/Static/', VIDEO_TYPE); - let type = 'video'; - await serachUri(done, testNum, currentFetchOp, type); - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_ASSET_URI_CALLBACK_004 - * @tc.name : uri - * @tc.desc : serach file asset by uri - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_ASSET_URI_CALLBACK_004', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_ASSET_URI_CALLBACK_004'; - let currentFetchOp = fetchOps(testNum, 'Documents/Static/', FILE_TYPE); - let type = 'file'; - await serachUri(done, testNum, currentFetchOp, type); - }); - }); -} - +/* + * Copyright (C) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import mediaLibrary from "@ohos.multimedia.mediaLibrary"; + +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "deccjsunit/index"; + +import { + sleep, + IMAGE_TYPE, + AUDIO_TYPE, + VIDEO_TYPE, + FILE_TYPE, + checkPresetsAssets, + checkAssetsCount, + fetchOps, + getPermission, +} from "../../../../../../common"; + +export default function mediafetchoptionsCallback(abilityContext) { + describe("mediafetchoptionsCallback", function () { + const media = mediaLibrary.getMediaLibrary(abilityContext); + beforeAll(async function () { + console.info("beforeAll case"); + await getPermission(null, abilityContext); + await checkPresetsAssets(media, "ActsMediaLibraryMediafetchoptionsTest"); + }); + beforeEach(function () { + console.info("beforeEach case"); + }); + afterEach(async function () { + console.info("afterEach case"); + await sleep(); + }); + afterAll(function () { + console.info("afterAll case"); + }); + const serachUri = async (done, testNum, fetchOp, type) => { + try { + const fetchFileResult = await media.getFileAssets(fetchOp); + let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchFileResult, 2); + if (!checkAssetCountPass) return; + let firstObject = await fetchFileResult.getFirstObject(); + const id = firstObject.id; + const uri = firstObject.uri; + const serachUri = `datashare:///media/${type}/${id}`; + console.info(`${testNum} :uri ${uri};serachUri${serachUri})`); + + let serchfetchOp = { + uri: serachUri.toString(), + selections: "", + selectionArgs: [], + }; + + media.getFileAssets(serchfetchOp, async (err, result) => { + if (err) { + console.info(`${testNum}, err: ${err}`); + expect(false).assertTrue(); + done(); + return; + } + checkAssetCountPass = await checkAssetsCount(done, testNum, result, 1); + if (!checkAssetCountPass) return; + let asset = await result.getFirstObject(); + expect(asset.uri).assertEqual(serachUri); + expect(asset.id).assertEqual(id); + done(); + }); + } catch (error) { + console.info(`${testNum} failed error: ${error}`); + expect(false).assertTrue(); + done(); + } + }; + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_ASSET_URI_CALLBACK_001 + * @tc.name : uri + * @tc.desc : serach image asset by uri + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it("SUB_MEDIA_MEDIALIBRARY_ASSET_URI_CALLBACK_001", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_ASSET_URI_CALLBACK_001"; + let currentFetchOp = fetchOps(testNum, "Pictures/Static/", IMAGE_TYPE); + let type = "image"; + await serachUri(done, testNum, currentFetchOp, type); + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_ASSET_URI_CALLBACK_002 + * @tc.name : uri + * @tc.desc : serach audio asset by uri + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it("SUB_MEDIA_MEDIALIBRARY_ASSET_URI_CALLBACK_002", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_ASSET_URI_CALLBACK_002"; + let currentFetchOp = fetchOps(testNum, "Audios/Static/", AUDIO_TYPE); + let type = "audio"; + await serachUri(done, testNum, currentFetchOp, type); + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_ASSET_URI_CALLBACK_003 + * @tc.name : uri + * @tc.desc : serach video asset by uri + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it("SUB_MEDIA_MEDIALIBRARY_ASSET_URI_CALLBACK_003", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_ASSET_URI_CALLBACK_003"; + let currentFetchOp = fetchOps(testNum, "Videos/Static/", VIDEO_TYPE); + let type = "video"; + await serachUri(done, testNum, currentFetchOp, type); + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_ASSET_URI_CALLBACK_004 + * @tc.name : uri + * @tc.desc : serach file asset by uri + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it("SUB_MEDIA_MEDIALIBRARY_ASSET_URI_CALLBACK_004", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_ASSET_URI_CALLBACK_004"; + let currentFetchOp = fetchOps(testNum, "Documents/Static/", FILE_TYPE); + let type = "file"; + await serachUri(done, testNum, currentFetchOp, type); + }); + }); +} diff --git a/multimedia/medialibrary/mediaLibrary_mediafetchoptions/entry/src/main/ets/test/mediafetchoptionsPromise.test.ets b/multimedia/medialibrary/mediaLibrary_mediafetchoptions/entry/src/main/ets/test/mediafetchoptionsPromise.test.ets index 5b59b9f8cb3406a830cd904e784b6046fdbc914c..9c3ec7b8a4acce43238693377350df8b12042ef8 100644 --- a/multimedia/medialibrary/mediaLibrary_mediafetchoptions/entry/src/main/ets/test/mediafetchoptionsPromise.test.ets +++ b/multimedia/medialibrary/mediaLibrary_mediafetchoptions/entry/src/main/ets/test/mediafetchoptionsPromise.test.ets @@ -1,229 +1,228 @@ -/* - * Copyright (C) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import mediaLibrary from '@ohos.multimedia.mediaLibrary'; - -import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'; - -import { - sleep, - IMAGE_TYPE, - AUDIO_TYPE, - VIDEO_TYPE, - FILE_TYPE, - FILEKEY, - checkAssetsCount, - fetchOps, -} from '../../../../../../common'; - -export default function mediafetchoptionsPromise(abilityContext) { - describe('mediafetchoptionsPromise', function () { - const media = mediaLibrary.getMediaLibrary(abilityContext); - beforeAll(async function () { - console.info('beforeAll case'); - }); - beforeEach(function () { - console.info('beforeEach case'); - }); - afterEach(async function () { - console.info('afterEach case'); - await sleep() - }); - afterAll(function () { - console.info('afterAll case'); - }); - - const serachUri = async (done, testNum, fetchOp, type) => { - try { - const fetchFileResult = await media.getFileAssets(fetchOp); - let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchFileResult, 2); - if (!checkAssetCountPass) return; - let firstObject = await fetchFileResult.getFirstObject(); - const id = firstObject.id; - const uri = firstObject.uri; - const serachUri = `datashare:///media/${type}/${id}`; - console.info(`${testNum} :uri ${uri};serachUri${serachUri})`) - - let serchfetchOp = { - uri: serachUri.toString(), - selections: '', - selectionArgs: [], - }; - - const result = await media.getFileAssets(serchfetchOp); - checkAssetCountPass = await checkAssetsCount(done, testNum, result, 1); - if (!checkAssetCountPass) return; - - let asset = await result.getFirstObject(); - expect(asset.uri).assertEqual(serachUri); - expect(asset.id).assertEqual(id); - done(); - } catch (error) { - console.info(`${testNum} failed error: ${error}`) - expect(false).assertTrue(); - done(); - } - } - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_ASSET_URI_PROMISE_001 - * @tc.name : uri - * @tc.desc : serach image asset by uri - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_ASSET_URI_PROMISE_001', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_ASSET_URI_PROMISE_001'; - let currentFetchOp = fetchOps(testNum, 'Pictures/Static/', IMAGE_TYPE); - let type = 'image'; - await serachUri(done, testNum, currentFetchOp, type); - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_ASSET_URI_PROMISE_002 - * @tc.name : uri - * @tc.desc : serach audio asset by uri - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_ASSET_URI_PROMISE_002', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_ASSET_URI_PROMISE_002'; - let currentFetchOp = fetchOps(testNum, 'Audios/Static/', AUDIO_TYPE); - let type = 'audio'; - await serachUri(done, testNum, currentFetchOp, type); - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_ASSET_URI_PROMISE_003 - * @tc.name : uri - * @tc.desc : serach video asset by uri - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_ASSET_URI_PROMISE_003', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_ASSET_URI_PROMISE_003'; - let currentFetchOp = fetchOps(testNum, 'Videos/Static/', VIDEO_TYPE); - let type = 'video'; - await serachUri(done, testNum, currentFetchOp, type); - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_ASSET_URI_PROMISE_004 - * @tc.name : uri - * @tc.desc : serach file asset by uri - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_ASSET_URI_PROMISE_004', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_ASSET_URI_PROMISE_004'; - let currentFetchOp = fetchOps(testNum, 'Documents/Static/', FILE_TYPE); - let type = 'file'; - await serachUri(done, testNum, currentFetchOp, type); - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_ASSET_NETWORKID_PROMISE_005 - * @tc.name : uri - * @tc.desc : serach image asset by networkId = '',assetsCount = 2 - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_ASSET_NETWORKID_PROMISE_005', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_ASSET_NETWORKID_PROMISE_005'; - try { - const currentFetchOps = { - selections: FILEKEY.RELATIVE_PATH + '= ? AND ' + FILEKEY.MEDIA_TYPE + '=?', - selectionArgs: ['Pictures/Static/', IMAGE_TYPE.toString()], - networkId: '' - }; - const fetchFileResult = await media.getFileAssets(currentFetchOps); - let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchFileResult, 2); - - expect(checkAssetCountPass).assertTrue(); - done(); - } catch (error) { - console.info(`${testNum} failed error: ${error}`) - expect(false).assertTrue(); - done(); - } - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_ASSET_NETWORKID_PROMISE_006 - * @tc.name : uri - * @tc.desc : serach image asset by networkId = '93db533035b33a1ca118a2759c1fbb8654ce57061430effaf0b51bbe03388b8b' - * assetsCount = 0 - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_ASSET_NETWORKID_PROMISE_006', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_ASSET_NETWORKID_PROMISE_006'; - try { - const currentFetchOps = { - selections: FILEKEY.RELATIVE_PATH + '= ? AND ' + FILEKEY.MEDIA_TYPE + '=?', - selectionArgs: ['Pictures/Static/', IMAGE_TYPE.toString()], - networkId: '93db533035b33a1ca118a2759c1fbb8654ce57061430effaf0b51bbe03388b8b' - }; - try { - const fetchFileResult = await media.getFileAssets(currentFetchOps); - expect(false).assertTrue(); - done(); - } catch (err) { - expect(true).assertTrue(); - done(); - } - } catch (error) { - console.info(`${testNum} failed error: ${error}`) - expect(false).assertTrue(); - done(); - } - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_ASSET_EXTENDARGS_PROMISE_007 - * @tc.name : uri - * @tc.desc : serach image asset by extendArgs - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_ASSET_EXTENDARGS_PROMISE_007', 0, async function (done) { - let testNum = 'SUB_MEDIA_MEDIALIBRARY_ASSET_EXTENDARGS_PROMISE_007'; - try { - const currentFetchOps = { - selections: FILEKEY.RELATIVE_PATH + '= ? AND ' + FILEKEY.MEDIA_TYPE + '=?', - selectionArgs: ['Pictures/Static/', IMAGE_TYPE.toString()], - extendArgs: '' - }; - const fetchFileResult = await media.getFileAssets(currentFetchOps); - let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchFileResult, 2); - - expect(checkAssetCountPass).assertTrue(); - done(); - } catch (error) { - console.info(`${testNum} failed error: ${error}`) - expect(false).assertTrue(); - done(); - } - }); - }); -} - +/* + * Copyright (C) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import mediaLibrary from "@ohos.multimedia.mediaLibrary"; + +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "deccjsunit/index"; + +import { + sleep, + IMAGE_TYPE, + AUDIO_TYPE, + VIDEO_TYPE, + FILE_TYPE, + FILEKEY, + checkAssetsCount, + fetchOps, +} from "../../../../../../common"; + +export default function mediafetchoptionsPromise(abilityContext) { + describe("mediafetchoptionsPromise", function () { + const media = mediaLibrary.getMediaLibrary(abilityContext); + beforeAll(async function () { + console.info("beforeAll case"); + }); + beforeEach(function () { + console.info("beforeEach case"); + }); + afterEach(async function () { + console.info("afterEach case"); + await sleep(); + }); + afterAll(function () { + console.info("afterAll case"); + }); + + const serachUri = async (done, testNum, fetchOp, type) => { + try { + const fetchFileResult = await media.getFileAssets(fetchOp); + let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchFileResult, 2); + if (!checkAssetCountPass) return; + let firstObject = await fetchFileResult.getFirstObject(); + const id = firstObject.id; + const uri = firstObject.uri; + const serachUri = `datashare:///media/${type}/${id}`; + console.info(`${testNum} :uri ${uri};serachUri${serachUri})`); + + let serchfetchOp = { + uri: serachUri.toString(), + selections: "", + selectionArgs: [], + }; + + const result = await media.getFileAssets(serchfetchOp); + checkAssetCountPass = await checkAssetsCount(done, testNum, result, 1); + if (!checkAssetCountPass) return; + + let asset = await result.getFirstObject(); + expect(asset.uri).assertEqual(serachUri); + expect(asset.id).assertEqual(id); + done(); + } catch (error) { + console.info(`${testNum} failed error: ${error}`); + expect(false).assertTrue(); + done(); + } + }; + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_ASSET_URI_PROMISE_001 + * @tc.name : uri + * @tc.desc : serach image asset by uri + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it("SUB_MEDIA_MEDIALIBRARY_ASSET_URI_PROMISE_001", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_ASSET_URI_PROMISE_001"; + let currentFetchOp = fetchOps(testNum, "Pictures/Static/", IMAGE_TYPE); + let type = "image"; + await serachUri(done, testNum, currentFetchOp, type); + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_ASSET_URI_PROMISE_002 + * @tc.name : uri + * @tc.desc : serach audio asset by uri + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it("SUB_MEDIA_MEDIALIBRARY_ASSET_URI_PROMISE_002", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_ASSET_URI_PROMISE_002"; + let currentFetchOp = fetchOps(testNum, "Audios/Static/", AUDIO_TYPE); + let type = "audio"; + await serachUri(done, testNum, currentFetchOp, type); + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_ASSET_URI_PROMISE_003 + * @tc.name : uri + * @tc.desc : serach video asset by uri + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it("SUB_MEDIA_MEDIALIBRARY_ASSET_URI_PROMISE_003", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_ASSET_URI_PROMISE_003"; + let currentFetchOp = fetchOps(testNum, "Videos/Static/", VIDEO_TYPE); + let type = "video"; + await serachUri(done, testNum, currentFetchOp, type); + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_ASSET_URI_PROMISE_004 + * @tc.name : uri + * @tc.desc : serach file asset by uri + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it("SUB_MEDIA_MEDIALIBRARY_ASSET_URI_PROMISE_004", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_ASSET_URI_PROMISE_004"; + let currentFetchOp = fetchOps(testNum, "Documents/Static/", FILE_TYPE); + let type = "file"; + await serachUri(done, testNum, currentFetchOp, type); + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_ASSET_NETWORKID_PROMISE_005 + * @tc.name : uri + * @tc.desc : serach image asset by networkId = '',assetsCount = 2 + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it("SUB_MEDIA_MEDIALIBRARY_ASSET_NETWORKID_PROMISE_005", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_ASSET_NETWORKID_PROMISE_005"; + try { + const currentFetchOps = { + selections: FILEKEY.RELATIVE_PATH + "= ? AND " + FILEKEY.MEDIA_TYPE + "=?", + selectionArgs: ["Pictures/Static/", IMAGE_TYPE.toString()], + networkId: "", + }; + const fetchFileResult = await media.getFileAssets(currentFetchOps); + let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchFileResult, 2); + + expect(checkAssetCountPass).assertTrue(); + done(); + } catch (error) { + console.info(`${testNum} failed error: ${error}`); + expect(false).assertTrue(); + done(); + } + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_ASSET_NETWORKID_PROMISE_006 + * @tc.name : uri + * @tc.desc : serach image asset by networkId = '93db533035b33a1ca118a2759c1fbb8654ce57061430effaf0b51bbe03388b8b' + * assetsCount = 0 + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it("SUB_MEDIA_MEDIALIBRARY_ASSET_NETWORKID_PROMISE_006", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_ASSET_NETWORKID_PROMISE_006"; + try { + const currentFetchOps = { + selections: FILEKEY.RELATIVE_PATH + "= ? AND " + FILEKEY.MEDIA_TYPE + "=?", + selectionArgs: ["Pictures/Static/", IMAGE_TYPE.toString()], + networkId: "93db533035b33a1ca118a2759c1fbb8654ce57061430effaf0b51bbe03388b8b", + }; + try { + const fetchFileResult = await media.getFileAssets(currentFetchOps); + expect(false).assertTrue(); + done(); + } catch (err) { + expect(true).assertTrue(); + done(); + } + } catch (error) { + console.info(`${testNum} failed error: ${error}`); + expect(false).assertTrue(); + done(); + } + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_ASSET_EXTENDARGS_PROMISE_007 + * @tc.name : uri + * @tc.desc : serach image asset by extendArgs + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it("SUB_MEDIA_MEDIALIBRARY_ASSET_EXTENDARGS_PROMISE_007", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_ASSET_EXTENDARGS_PROMISE_007"; + try { + const currentFetchOps = { + selections: FILEKEY.RELATIVE_PATH + "= ? AND " + FILEKEY.MEDIA_TYPE + "=?", + selectionArgs: ["Pictures/Static/", IMAGE_TYPE.toString()], + extendArgs: "", + }; + const fetchFileResult = await media.getFileAssets(currentFetchOps); + let checkAssetCountPass = await checkAssetsCount(done, testNum, fetchFileResult, 2); + + expect(checkAssetCountPass).assertTrue(); + done(); + } catch (error) { + console.info(`${testNum} failed error: ${error}`); + expect(false).assertTrue(); + done(); + } + }); + }); +} diff --git a/multimedia/medialibrary/mediaLibrary_mediafetchoptions/entry/src/main/module.json b/multimedia/medialibrary/mediaLibrary_mediafetchoptions/entry/src/main/module.json index 6785829959ef1d93e26aaea687a2ec9bb759d52d..025062ffed12b44b32db7f5f35356c9040ed9c5c 100644 --- a/multimedia/medialibrary/mediaLibrary_mediafetchoptions/entry/src/main/module.json +++ b/multimedia/medialibrary/mediaLibrary_mediafetchoptions/entry/src/main/module.json @@ -3,11 +3,11 @@ "name": "phone", "type": "entry", "srcEntrance": "./ets/Application/AbilityStage.ts", - "description": "$string:mainability_description", + "description": "$string:phone_entry_dsc", "mainElement": "MainAbility", "deviceTypes": [ - "tablet", - "default", + "tablet", + "default", "phone" ], "deliveryWithInstall": true, @@ -16,11 +16,11 @@ "pages": "$profile:main_pages", "abilities": [ { - "name": "ohos.acts.multimedia.mediaLibrary.MainAbility", + "name": "com.example.myapplication.MainAbility", "srcEntrance": "./ets/MainAbility/MainAbility.ts", - "description": "$string:mainability_description", + "description": "$string:phone_entry_main", "icon": "$media:icon", - "label": "$string:entry_MainAbility", + "label": "$string:entry_label", "visible": true, "orientation": "portrait", "skills": [ @@ -28,42 +28,42 @@ "actions": [ "action.system.home" ], - "entities":[ + "entities": [ "entity.system.home" ] } ] } ], - "requestPermissions": [ + "requestPermissions": [ { "name": "ohos.permission.GET_BUNDLE_INFO", "reason": "use ohos.permission.GET_BUNDLE_INFO" }, { "name": "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED", - "reason":"use ohos.permission.GET_BUNDLE_INFO_PRIVILEGED" + "reason": "use ohos.permission.GET_BUNDLE_INFO_PRIVILEGED" }, { - "name" : "ohos.permission.GRANT_SENSITIVE_PERMISSIONS", - "reason" : "use ohos.permission.GRANT_SENSITIVE_PERMISSIONS" + "name": "ohos.permission.GRANT_SENSITIVE_PERMISSIONS", + "reason": "use ohos.permission.GRANT_SENSITIVE_PERMISSIONS" }, { - "name" : "ohos.permission.REVOKE_SENSITIVE_PERMISSIONS", - "reason" : "use ohos.permission.REVOKE_SENSITIVE_PERMISSIONS" + "name": "ohos.permission.REVOKE_SENSITIVE_PERMISSIONS", + "reason": "use ohos.permission.REVOKE_SENSITIVE_PERMISSIONS" }, { "name": "ohos.permission.MEDIA_LOCATION", - "reason":"use ohos.permission.MEDIA_LOCATION" + "reason": "use ohos.permission.MEDIA_LOCATION" }, { "name": "ohos.permission.READ_MEDIA", - "reason":"use ohos.permission.READ_MEDIA" + "reason": "use ohos.permission.READ_MEDIA" }, { "name": "ohos.permission.WRITE_MEDIA", - "reason":"use ohos.permission.WRITE_MEDIA" + "reason": "use ohos.permission.WRITE_MEDIA" } ] } -} +} \ No newline at end of file diff --git a/multimedia/medialibrary/mediaLibrary_mediafetchoptions/entry/src/main/resources/base/element/string.json b/multimedia/medialibrary/mediaLibrary_mediafetchoptions/entry/src/main/resources/base/element/string.json index d75a3fee650de2abaabfd60f40d90d9c6a4b0b0b..2ae43f018e75d1140cf2c0c85a6a14fc369a0c50 100644 --- a/multimedia/medialibrary/mediaLibrary_mediafetchoptions/entry/src/main/resources/base/element/string.json +++ b/multimedia/medialibrary/mediaLibrary_mediafetchoptions/entry/src/main/resources/base/element/string.json @@ -1,12 +1,32 @@ { "string": [ - { - "name": "entry_MainAbility", - "value": "MediaLibraryJSTestMain" - }, - { - "name": "mainability_description", - "value": "MediaLibraryJSTestMain Ability" - } + { + "name": "phone_entry_dsc", + "value": "i am an entry for phone" + }, + { + "name": "phone_entry_main", + "value": "the phone entry ability" + }, + { + "name": "entry_label", + "value": "ActsMediaLibraryTest" + }, + { + "name": "form_description", + "value": "mediaLibrary" + }, + { + "name": "serviceability_description", + "value": "mediaLibrary" + }, + { + "name": "description_application", + "value": "mediaLibrary test" + }, + { + "name": "app_name", + "value": "ActsMediaLibraryTest" + } ] - } \ No newline at end of file +} \ No newline at end of file diff --git a/multimedia/medialibrary/mediaLibrary_mediafetchoptions/entry/src/main/resources/base/profile/main_pages.json b/multimedia/medialibrary/mediaLibrary_mediafetchoptions/entry/src/main/resources/base/profile/main_pages.json index 6898b31d2085f478ee1ed9d933a5910cbf901d92..ceb075cd80946aade673d707aac904fb8998bce9 100644 --- a/multimedia/medialibrary/mediaLibrary_mediafetchoptions/entry/src/main/resources/base/profile/main_pages.json +++ b/multimedia/medialibrary/mediaLibrary_mediafetchoptions/entry/src/main/resources/base/profile/main_pages.json @@ -1,6 +1,5 @@ { "src": [ - "pages/index/index", - "pages/second/second" + "MainAbility/pages/index/index" ] } \ No newline at end of file diff --git a/multimedia/medialibrary/mediaLibrary_mediafetchoptions/signature/openharmony_sx.p7b b/multimedia/medialibrary/mediaLibrary_mediafetchoptions/signature/openharmony_sx.p7b index 3eb5b5db82a014ff4c9483872cad743ad49a9b6e..64b33bf079b2ab68a3f26f240d127186546b33d9 100644 Binary files a/multimedia/medialibrary/mediaLibrary_mediafetchoptions/signature/openharmony_sx.p7b and b/multimedia/medialibrary/mediaLibrary_mediafetchoptions/signature/openharmony_sx.p7b differ diff --git a/multimedia/medialibrary/mediaLibrary_trash/AppScope/app.json b/multimedia/medialibrary/mediaLibrary_trash/AppScope/app.json index 5139eaad5d5fd2e2de13b4970785d6fa8ae1a4ba..803955ad0d2a5b4ce4e103816a6a917b4701286b 100644 --- a/multimedia/medialibrary/mediaLibrary_trash/AppScope/app.json +++ b/multimedia/medialibrary/mediaLibrary_trash/AppScope/app.json @@ -1,21 +1,21 @@ { - "app":{ - "bundleName":"ohos.acts.multimedia.mediaLibrary", - "vendor":"huawei", - "versionCode":1000000, - "versionName":"1.0.0", - "debug":false, - "icon":"$media:icon", - "label":"$string:entry_MainAbility", - "description":"$string:mainability_description", - "distributedNotificationEnabled":true, - "keepAlive":true, - "singleUser":true, - "minAPIVersion":8, - "targetAPIVersion":8, - "car":{ - "apiCompatibleVersion":8, - "singleUser":false + "app": { + "bundleName": "ohos.acts.multimedia.mediaLibrary", + "vendor": "huawei", + "versionCode": 1000000, + "versionName": "1.0.0", + "debug": false, + "icon": "$media:icon", + "label": "$string:app_name", + "description": "$string:description_application", + "distributedNotificationEnabled": true, + "keepAlive": true, + "singleUser": true, + "minAPIVersion": 9, + "targetAPIVersion": 9, + "car": { + "apiCompatibleVersion": 9, + "singleUser": false } } -} +} \ No newline at end of file diff --git a/multimedia/medialibrary/mediaLibrary_trash/AppScope/resources/base/element/string.json b/multimedia/medialibrary/mediaLibrary_trash/AppScope/resources/base/element/string.json index c1dee63527ae5e3c37f3736f6b68189e8df6f201..ee69f9a861d9dc269ed6638735d52674583498e1 100644 --- a/multimedia/medialibrary/mediaLibrary_trash/AppScope/resources/base/element/string.json +++ b/multimedia/medialibrary/mediaLibrary_trash/AppScope/resources/base/element/string.json @@ -1,12 +1,8 @@ { - "string": [ + "string":[ { - "name": "entry_MainAbility", - "value": "MediaLibraryJSTestMain" - }, - { - "name": "mainability_description", - "value": "MediaLibraryJSTestMain Ability" + "name":"app_name", + "value":"ohosProject" } ] -} \ No newline at end of file +} \ No newline at end of file diff --git a/multimedia/medialibrary/mediaLibrary_trash/BUILD.gn b/multimedia/medialibrary/mediaLibrary_trash/BUILD.gn index 42b7cdb55ae78ef97565b020cee8ab4492d9814e..f328ea2a9ec87ea66c4d3e43c49a8a08a77d4ee1 100644 --- a/multimedia/medialibrary/mediaLibrary_trash/BUILD.gn +++ b/multimedia/medialibrary/mediaLibrary_trash/BUILD.gn @@ -15,6 +15,7 @@ import("//test/xts/tools/build/suite.gni") ohos_js_hap_suite("mediaLibrary_trash_js_hap") { hap_profile = "entry/src/main/module.json" + js_build_mode = "debug" deps = [ ":mediaLibrary_js_assets", ":mediaLibrary_resources", diff --git a/multimedia/medialibrary/mediaLibrary_trash/Test.json b/multimedia/medialibrary/mediaLibrary_trash/Test.json index d280edcc6ac329138c06573a89642faa4f212885..2bc6fceea1d27f22c8183b91371c2c71b4f9e89d 100644 --- a/multimedia/medialibrary/mediaLibrary_trash/Test.json +++ b/multimedia/medialibrary/mediaLibrary_trash/Test.json @@ -1,27 +1,30 @@ { "description": "Configuration for mediaLibrary Tests", "driver": { - "type": "JSUnitTest", - "test-timeout": "300000", - "package": "ohos.acts.multimedia.mediaLibrary", - "shell-timeout": "600000" + "type": "OHJSUnitTest", + "test-timeout": "180000", + "bundle-name": "ohos.acts.multimedia.mediaLibrary", + "module-name": "phone", + "shell-timeout": "600000", + "testcase-timeout": 70000 }, "kits": [ { "type": "ShellKit", - "pre-push": [ - ], + "pre-push": [], "run-command": [ "rm -rf /storage/media/100/local/files/*", "rm -rf /data/app/el2/100/database/com.ohos.medialibrary.MediaLibraryDataA/*", "mkdir -pv /storage/media/100/local/files/{Pictures,Videos,Audios,Documents}", - "mkdir -p /storage/media/100/local/temp" + "mkdir -p /storage/media/100/local/temp", + "power-shell wakeup", + "uinput -T -d 300 600 -m 300 600 300 100 -u 300 100", + "power-shell setmode 602" ] }, { "type": "PushKit", - "pre-push": [ - ], + "pre-push": [], "push": [ "./resource/medialibrary/01.jpg ->/storage/media/100/local/temp", "./resource/medialibrary/01.mp3 ->/storage/media/100/local/temp", @@ -36,12 +39,10 @@ "mkdir -pv /storage/media/100/local/files/Videos/{trash,trashCb}", "mkdir -pv /storage/media/100/local/files/Audios/{trash,trashCb}", "mkdir -pv /storage/media/100/local/files/Documents/{trash,trashCb}", - "for d in trash trashCb; 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 trash trashCb; 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 trash trashCb; do for i in $$(seq 3); do cp /storage/media/100/local/temp/01.mp4 /storage/media/100/local/files/Videos/$$d/0$$i.mp4; done;done;", "for d in trash trashCb; do for i in $$(seq 3); do cp /storage/media/100/local/temp/01.dat /storage/media/100/local/files/Documents/$$d/0$$i.dat; done;done;", - "chmod -R 777 /storage/media/100/local/files/*", "chmod -R 777 /data/service/el2/100/hmdfs/account/files/*", "hilog -Q pidoff", @@ -51,8 +52,9 @@ "scanner", "sleep 10" ], - "teardown-command":[ - "hilog -b X -D 0xD002B70" + "teardown-command": [ + "hilog -b X -D 0xD002B70", + "power-shell setmode 600" ] }, { @@ -63,4 +65,4 @@ "cleanup-apps": true } ] -} +} \ No newline at end of file diff --git a/multimedia/medialibrary/mediaLibrary_trash/entry/src/main/ets/Application/AbilityStage.ts b/multimedia/medialibrary/mediaLibrary_trash/entry/src/main/ets/Application/AbilityStage.ts index 51cb02ba3f5c7011c1cd433d07deebd47a195704..e3fdadfebeeeb676df2ce8f78f4b59e26fae9cf0 100644 --- a/multimedia/medialibrary/mediaLibrary_trash/entry/src/main/ets/Application/AbilityStage.ts +++ b/multimedia/medialibrary/mediaLibrary_trash/entry/src/main/ets/Application/AbilityStage.ts @@ -3,7 +3,7 @@ import AbilityStage from "@ohos.application.AbilityStage" export default class MyAbilityStage extends AbilityStage { onCreate() { console.log("[Demo] MyAbilityStage onCreate") - globalThis.stageOnCreateRun = 1; - globalThis.stageContext = this.context; + globalThis.stageOnCreateRun = 1; + globalThis.stageContext = this.context; } } diff --git a/multimedia/medialibrary/mediaLibrary_trash/entry/src/main/ets/MainAbility/MainAbility.ts b/multimedia/medialibrary/mediaLibrary_trash/entry/src/main/ets/MainAbility/MainAbility.ts index 2f9d6d1f23f95d9fc891fbc550cd5a589cfb6c89..83c0cd68bb2c044c9b98d212a62851b32bd9af9a 100644 --- a/multimedia/medialibrary/mediaLibrary_trash/entry/src/main/ets/MainAbility/MainAbility.ts +++ b/multimedia/medialibrary/mediaLibrary_trash/entry/src/main/ets/MainAbility/MainAbility.ts @@ -1,7 +1,7 @@ import Ability from '@ohos.application.Ability' export default class MainAbility extends Ability { - onCreate(want,launchParam){ + onCreate(want, launchParam) { // Ability is creating, initialize resources for this ability console.log("[Demo] MainAbility onCreate") globalThis.abilityWant = want; @@ -12,11 +12,11 @@ export default class MainAbility extends Ability { console.log("[Demo] MainAbility onDestroy") } - onWindowStageCreate(windowStage) { - // Main window is created, set main page for this ability - console.log("[Demo] MainAbility onWindowStageCreate") + async onWindowStageCreate(windowStage) { + console.log("[Demo] MainAbility onWindowStageCreate windowStage=" + windowStage) + globalThis.windowStage = windowStage globalThis.abilityContext = this.context - windowStage.setUIContent(this.context, "pages/index/index", null) + windowStage.setUIContent(this.context, "MainAbility/pages/index/index", null) } onWindowStageDestroy() { diff --git a/multimedia/medialibrary/mediaLibrary_trash/entry/src/main/ets/MainAbility/pages/index/index.ets b/multimedia/medialibrary/mediaLibrary_trash/entry/src/main/ets/MainAbility/pages/index/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..6a8c567d5a86048b1c269e4f00cc288ec136200b --- /dev/null +++ b/multimedia/medialibrary/mediaLibrary_trash/entry/src/main/ets/MainAbility/pages/index/index.ets @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import router from '@ohos.router'; +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' +import { Hypium } from '@ohos/hypium' +import testsuite from '../../../test/List.test' + + +@Entry +@Component +struct Index { + + aboutToAppear(){ + console.info("start run testcase!!!!") + var abilityDelegator: any + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var abilityDelegatorArguments: any + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + console.info('start run testcase!!!') + Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) + } + + build() { + Flex({ direction:FlexDirection.Column, alignItems:ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text('Hello World') + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('next page') + .fontSize(25) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .onClick(() => { + + }) + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/multimedia/medialibrary/mediaLibrary_trash/entry/src/main/ets/TestAbility/TestAbility.ts b/multimedia/medialibrary/mediaLibrary_trash/entry/src/main/ets/TestAbility/TestAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..8028a70f8af44690b95a08bd177bca6b09f24687 --- /dev/null +++ b/multimedia/medialibrary/mediaLibrary_trash/entry/src/main/ets/TestAbility/TestAbility.ts @@ -0,0 +1,50 @@ +/* + * 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 Ability from '@ohos.app.ability.UIAbility' + +export default class TestAbility extends Ability { + onCreate(want, launchParam) { + console.log('TestAbility onCreate') + } + + onDestroy() { + console.log('TestAbility onDestroy') + } + + onWindowStageCreate(windowStage) { + console.log('TestAbility onWindowStageCreate') + windowStage.loadContent("TestAbility/pages/index", (err, data) => { + if (err.code) { + console.error('Failed to load the content. Cause:' + JSON.stringify(err)); + return; + } + console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data)) + }); + + globalThis.abilityContext = this.context; + } + + onWindowStageDestroy() { + console.log('TestAbility onWindowStageDestroy') + } + + onForeground() { + console.log('TestAbility onForeground') + } + + onBackground() { + console.log('TestAbility onBackground') + } +}; \ No newline at end of file diff --git a/multimedia/medialibrary/mediaLibrary_trash/entry/src/main/ets/TestAbility/pages/index.ets b/multimedia/medialibrary/mediaLibrary_trash/entry/src/main/ets/TestAbility/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..b93567f962921124b282f78c8ef123965d1460c9 --- /dev/null +++ b/multimedia/medialibrary/mediaLibrary_trash/entry/src/main/ets/TestAbility/pages/index.ets @@ -0,0 +1,48 @@ +/* + * 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 router from '@ohos.router'; + +@Entry +@Component +struct Index { + aboutToAppear() { + console.info('TestAbility index aboutToAppear') + } + @State message: string = 'Hello World' + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('next page') + .fontSize(20) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .width('35%') + .height('5%') + .onClick(()=>{ + }) + } + .width('100%') + } + .height('100%') + } + } \ No newline at end of file diff --git a/multimedia/medialibrary/mediaLibrary_trash/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts b/multimedia/medialibrary/mediaLibrary_trash/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts new file mode 100644 index 0000000000000000000000000000000000000000..a4ee2f1652b3d04ce83ece64ef70f8dfa62a2dc8 --- /dev/null +++ b/multimedia/medialibrary/mediaLibrary_trash/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts @@ -0,0 +1,78 @@ +/* + * 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 TestRunner from '@ohos.application.testRunner' +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' + +var abilityDelegator = undefined +var abilityDelegatorArguments = undefined + +function translateParamsToString(parameters) { + const keySet = new Set([ + '-s class', '-s notClass', '-s suite', '-s it', + '-s level', '-s testType', '-s size', '-s timeout', + '-s dryRun' + ]) + let targetParams = ''; + for (const key in parameters) { + if (keySet.has(key)) { + targetParams = `${targetParams} ${key} ${parameters[key]}` + } + } + return targetParams.trim() +} + +async function onAbilityCreateCallback() { + console.log("onAbilityCreateCallback"); +} + +async function addAbilityMonitorCallback(err: any) { + console.info("addAbilityMonitorCallback : " + JSON.stringify(err)) +} + +export default class OpenHarmonyTestRunner implements TestRunner { + constructor() { + } + + onPrepare() { + console.info("OpenHarmonyTestRunner OnPrepare ") + } + + async onRun() { + console.log('OpenHarmonyTestRunner onRun run') + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var testAbilityName = abilityDelegatorArguments.bundleName + '.MainAbility' + let lMonitor = { + abilityName: testAbilityName, + onAbilityCreate: onAbilityCreateCallback, + }; + abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback) + var cmd = 'aa start -d 0 -a com.example.myapplication.MainAbility' + ' -b ' + abilityDelegatorArguments.bundleName + cmd += ' '+translateParamsToString(abilityDelegatorArguments.parameters) + var debug = abilityDelegatorArguments.parameters["-D"] + if (debug == 'true') + { + cmd += ' -D' + } + console.info('cmd : '+cmd) + abilityDelegator.executeShellCommand(cmd, + (err: any, d: any) => { + console.info('executeShellCommand : err : ' + JSON.stringify(err)); + console.info('executeShellCommand : data : ' + d.stdResult); + console.info('executeShellCommand : data : ' + d.exitCode); + }) + console.info('OpenHarmonyTestRunner onRun end') + } +}; \ No newline at end of file diff --git a/multimedia/medialibrary/mediaLibrary_trash/entry/src/main/ets/pages/index/index.ets b/multimedia/medialibrary/mediaLibrary_trash/entry/src/main/ets/pages/index/index.ets deleted file mode 100644 index b15b989b903b686d0e3766c5662235d1695b0193..0000000000000000000000000000000000000000 --- a/multimedia/medialibrary/mediaLibrary_trash/entry/src/main/ets/pages/index/index.ets +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import file from '@system.file'; - -import {Core, ExpectExtend, InstrumentLog, ReportExtend} from "deccjsunit/index" -import testsuite from "../../test/List.test.ets" - - -@Entry -@Component -struct Index { - - aboutToAppear(){ - console.info("start run testcase!!!!") - const core = Core.getInstance() - const expectExtend = new ExpectExtend({ - 'id': 'extend' - }) - core.addService('expect', expectExtend) - const reportExtend = new ReportExtend(file) - - core.addService('report', reportExtend) - core.init() - core.subscribeEvent('task', reportExtend) - const configService = core.getDefaultService('config') - console.info('parameters---->' + JSON.stringify(globalThis.abilityWant.parameters)) - globalThis.abilityWant.parameters.timeout = 70000; - configService.setConfig(globalThis.abilityWant.parameters) - console.info('testsuite()---->') - testsuite(globalThis.abilityContext) - core.execute() - console.info('core.execute()---->') - } - - build() { - Flex({ direction:FlexDirection.Column, alignItems:ItemAlign.Center, justifyContent: FlexAlign.Center }) { - Text('Hello World') - .fontSize(50) - .fontWeight(FontWeight.Bold) - Button() { - Text('next page') - .fontSize(25) - .fontWeight(FontWeight.Bold) - }.type(ButtonType.Capsule) - .margin({ - top: 20 - }) - .backgroundColor('#0D9FFB') - .onClick(() => { - - }) - } - .width('100%') - .height('100%') - } -} \ No newline at end of file diff --git a/multimedia/medialibrary/mediaLibrary_trash/entry/src/main/ets/pages/second/second.ets b/multimedia/medialibrary/mediaLibrary_trash/entry/src/main/ets/pages/second/second.ets deleted file mode 100644 index 1c1c727ff11ecc97909f482c35268db87ae23bb4..0000000000000000000000000000000000000000 --- a/multimedia/medialibrary/mediaLibrary_trash/entry/src/main/ets/pages/second/second.ets +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import router from '@system.router'; - -@Entry -@Component -struct Second { - private content: string = "Second Page" - - build() { - Flex({ direction: FlexDirection.Column,alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { - Text(`${this.content}`) - .fontSize(50) - .fontWeight(FontWeight.Bold) - Button() { - Text('back to index') - .fontSize(20) - .fontWeight(FontWeight.Bold) - }.type(ButtonType.Capsule) - .margin({ - top: 20 - }) - .backgroundColor('#0D9FFB') - .onClick(() => { - router.back() - }) - } - .width('100%') - .height('100%') - } -} \ No newline at end of file diff --git a/multimedia/medialibrary/mediaLibrary_trash/entry/src/main/ets/test/List.test.ets b/multimedia/medialibrary/mediaLibrary_trash/entry/src/main/ets/test/List.test.ets index 273d2768b008ab334ab2019892815840ee94cbf4..857f4453ceb7142b0ce8a0b93131d8e49ac39a3a 100644 --- a/multimedia/medialibrary/mediaLibrary_trash/entry/src/main/ets/test/List.test.ets +++ b/multimedia/medialibrary/mediaLibrary_trash/entry/src/main/ets/test/List.test.ets @@ -1,20 +1,20 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import trashPromise from './trashPromise.test.ets' -import trashCallback from './trashCallback.test.ets' -export default function testsuite(abilityContext) { - trashCallback(abilityContext) - trashPromise(abilityContext) +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import trashPromise from './trashPromise.test.ets' +import trashCallback from './trashCallback.test.ets' +export default function testsuite() { + trashCallback(globalThis.abilityContext) + trashPromise(globalThis.abilityContext) } \ No newline at end of file diff --git a/multimedia/medialibrary/mediaLibrary_trash/entry/src/main/ets/test/trashCallback.test.ets b/multimedia/medialibrary/mediaLibrary_trash/entry/src/main/ets/test/trashCallback.test.ets index c62e658fa3158d1cd77640ff93dbd1e61520e67c..b53a2749d751799a68211cea50cc8b49a6d9430e 100644 --- a/multimedia/medialibrary/mediaLibrary_trash/entry/src/main/ets/test/trashCallback.test.ets +++ b/multimedia/medialibrary/mediaLibrary_trash/entry/src/main/ets/test/trashCallback.test.ets @@ -1,416 +1,416 @@ -/* - * Copyright (C) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import mediaLibrary from "@ohos.multimedia.mediaLibrary"; -import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "deccjsunit/index"; -import { - sleep, - IMAGE_TYPE, - AUDIO_TYPE, - VIDEO_TYPE, - FILE_TYPE, - fetchOps, - getPermission, - albumFetchOps, - fileIdFetchOps, - checkPresetsAssets, -} from "../../../../../../common"; - -export default function trashCallback(abilityContext) { - describe("trashCallback", function () { - beforeAll(async function () { - await getPermission(); - console.info("beforeAll case"); - await checkPresetsAssets(media, 'ActsMediaLibraryTrashJsTest'); - }); - beforeEach(function () { - console.info("beforeEach case"); - }); - afterEach(async function () { - console.info("afterEach case"); - await sleep; - }); - afterAll(async function () { - console.info("afterAll case"); - }); - - const media = mediaLibrary.getMediaLibrary(abilityContext); - - async function setTrash(done, testNum, databasefFetchOps, ablumFetchOps, noAlbum) { - try { - // database info - let databaseFetchFileResult = await media.getFileAssets(databasefFetchOps); - let count = databaseFetchFileResult.getCount(); - //album info - if (!noAlbum) { - let albumList = await media.getAlbums(ablumFetchOps); - let album = albumList[0]; - let albumFetchFileResult = await album.getFileAssets(); - let albumFilesCount = albumFetchFileResult.getCount(); - expect(albumFilesCount).assertEqual(count); - } - // file info - let asset = await databaseFetchFileResult.getFirstObject(); - let id = asset.id; - let istrash = await asset.isTrash(); - expect(istrash).assertFalse(); - // 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 - databaseFetchFileResult = await media.getFileAssets(databasefFetchOps); - let databaseCount = databaseFetchFileResult.getCount(); - - expect(databaseCount).assertEqual(count - 1); - //album info - if (!noAlbum) { - let albumList = await media.getAlbums(ablumFetchOps); - let album = albumList[0]; - let albumFetchFileResult = await album.getFileAssets(); - let albumFilesCount = albumFetchFileResult.getCount(); - expect(albumFilesCount).assertEqual(count - 1); - } - let assetOpts = fileIdFetchOps(id); - let trashAssetResult = await media.getFileAssets(assetOpts); - let afterTrashAssetConut = trashAssetResult.getCount(); - expect(afterTrashAssetConut).assertEqual(0); - 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) { - try { - let databaseFetchFileResult = await media.getFileAssets(databasefFetchOps); - let count = databaseFetchFileResult.getCount(); - let asset = await databaseFetchFileResult.getFirstObject(); - let id = asset.id; - await asset.trash(true); - - let istrash = await asset.isTrash(); - if (!istrash) { - console.info(`${testNum} istrash failed: ${istrash}`); - expect(istrash).assertFalse(); - return; - } - 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 { - databaseFetchFileResult = await media.getFileAssets(databasefFetchOps); - let databaseCount = databaseFetchFileResult.getCount(); - expect(databaseCount).assertEqual(count); - //album info - if (!noAlbum) { - let albumList = await media.getAlbums(ablumFetchOps); - let album = albumList[0]; - let albumFetchFileResult = await album.getFileAssets(); - let albumFilesCount = albumFetchFileResult.getCount(); - expect(albumFilesCount).assertEqual(count); - } - // asset after trash Conut - let assetOpts = fileIdFetchOps(testNum, id); - let recoveryAssetResult = await media.getFileAssets(assetOpts); - let afterRecoveryAssetConut = recoveryAssetResult.getCount(); - expect(afterRecoveryAssetConut).assertEqual(1); - let recoveryAsset = await recoveryAssetResult.getFirstObject(); - let recoveryAssetState = await recoveryAsset.isTrash(); - expect(recoveryAssetState).assertFalse(); - 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 trashError(done, testNum, databasefFetchOps, value) { - try { - let databaseFetchFileResult = await media.getFileAssets(databasefFetchOps); - let asset = await databaseFetchFileResult.getFirstObject(); - let count = databaseFetchFileResult.getCount(); - console.info(`${testNum}count:${count}`); - try { - asset.trash(value, async (err) => { - if (err) { - console.info(`${testNum} err: ${err}`); - expect(false).assertTrue(); - done(); - return; - } - expect(false).assertTrue(); - done(); - }); - } catch (error) { - console.info(`${testNum} error: ${error}`); - let databaseFetchFileResult = await media.getFileAssets(databasefFetchOps); - let count2 = databaseFetchFileResult.getCount(); - expect(count).assertEqual(count2); - done(); - } - } catch (error) { - console.info(`${testNum} error: ${error}`); - expect(false).assertTrue(); - done(); - } - } - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_TRASH_CALLBACK_01_001 - * @tc.name : trash - * @tc.desc : image asset Trash by true - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it("SUB_MEDIA_MEDIALIBRARY_TRASH_CALLBACK_01_001", 0, async function (done) { - let testNum = "SUB_MEDIA_MEDIALIBRARY_TRASH_CALLBACK_01_001"; - let rOps = fetchOps(testNum, "Pictures/trashCb/", IMAGE_TYPE); - let aOps = albumFetchOps(testNum, "Pictures/", "trashCb", IMAGE_TYPE); - let noAlbum = false; - await setTrash(done, testNum, rOps, aOps, noAlbum); - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_TRASH_CALLBACK_01_002 - * @tc.name : trash - * @tc.desc : video asset Trash by true - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it("SUB_MEDIA_MEDIALIBRARY_TRASH_CALLBACK_01_002", 0, async function (done) { - let testNum = "SUB_MEDIA_MEDIALIBRARY_TRASH_CALLBACK_01_002"; - let rOps = fetchOps(testNum, "Videos/trashCb/", VIDEO_TYPE); - let aOps = albumFetchOps(testNum, "Videos/", "trashCb", VIDEO_TYPE); - let noAlbum = false; - await setTrash(done, testNum, rOps, aOps, noAlbum); - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_TRASH_CALLBACK_01_003 - * @tc.name : trash - * @tc.desc : audio asset Trash by true - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it("SUB_MEDIA_MEDIALIBRARY_TRASH_CALLBACK_01_003", 0, async function (done) { - let testNum = "SUB_MEDIA_MEDIALIBRARY_TRASH_CALLBACK_01_003"; - let rOps = fetchOps(testNum, "Audios/trashCb/", AUDIO_TYPE); - let aOps = albumFetchOps(testNum, "Audios/", "trashCb", AUDIO_TYPE); - let noAlbum = false; - await setTrash(done, testNum, rOps, aOps, noAlbum); - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_TRASH_CALLBACK_01_004 - * @tc.name : trash - * @tc.desc : file asset Trash by true - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it("SUB_MEDIA_MEDIALIBRARY_TRASH_CALLBACK_01_004", 0, async function (done) { - let testNum = "SUB_MEDIA_MEDIALIBRARY_TRASH_CALLBACK_01_004"; - let rOps = fetchOps(testNum, "Documents/trashCb/", FILE_TYPE); - let aOps = albumFetchOps(testNum, "Documents/", "trashCb", FILE_TYPE); - let noAlbum = true; - await setTrash(done, testNum, rOps, aOps, noAlbum); - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_TRASH_ERROR_CALLBACK_02_001 - * @tc.name : trash - * @tc.desc : image asset Trash by 1 - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 3 - */ - it("SUB_MEDIA_MEDIALIBRARY_TRASH_ERROR_CALLBACK_02_001", 0, async function (done) { - let testNum = "SUB_MEDIA_MEDIALIBRARY_TRASH_ERROR_CALLBACK_02_001"; - let rOps = fetchOps(testNum, "Pictures/trashCb/", IMAGE_TYPE); - let value = 1; - await trashError(done, testNum, rOps, value); - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_TRASH_ERROR_CALLBACK_02_002 - * @tc.name : trash - * @tc.desc : image asset Trash by 'abc' - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 3 - */ - it("SUB_MEDIA_MEDIALIBRARY_TRASH_ERROR_CALLBACK_02_002", 0, async function (done) { - let testNum = "SUB_MEDIA_MEDIALIBRARY_TRASH_ERROR_CALLBACK_02_002"; - let rOps = fetchOps(testNum, "Pictures/trashCb/", IMAGE_TYPE); - let value = "abc"; - await trashError(done, testNum, rOps, value); - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_TRASH_ERROR_CALLBACK_02_003 - * @tc.name : trash - * @tc.desc : image asset Trash by {a:10} - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 3 - */ - it("SUB_MEDIA_MEDIALIBRARY_TRASH_ERROR_CALLBACK_02_003", 0, async function (done) { - let testNum = "SUB_MEDIA_MEDIALIBRARY_TRASH_ERROR_CALLBACK_02_003"; - let rOps = fetchOps(testNum, "Pictures/trashCb/", IMAGE_TYPE); - let value = { a: 10 }; - await trashError(done, testNum, rOps, value); - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_TRASH_ERROR_CALLBACK_02_004 - * @tc.name : trash - * @tc.desc : image asset Trash by undefined - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 3 - */ - it("SUB_MEDIA_MEDIALIBRARY_TRASH_ERROR_CALLBACK_02_004", 0, async function (done) { - let testNum = "SUB_MEDIA_MEDIALIBRARY_TRASH_ERROR_CALLBACK_02_004"; - let rOps = fetchOps(testNum, "Pictures/trashCb/", IMAGE_TYPE); - let value = undefined; - await trashError(done, testNum, rOps, value); - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_TRASH_ERROR_CALLBACK_02_005 - * @tc.name : trash - * @tc.desc : image asset Trash by null - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 3 - */ - it("SUB_MEDIA_MEDIALIBRARY_TRASH_ERROR_CALLBACK_02_005", 0, async function (done) { - let testNum = "SUB_MEDIA_MEDIALIBRARY_TRASH_ERROR_CALLBACK_02_005"; - let rOps = fetchOps(testNum, "Pictures/trashCb/", IMAGE_TYPE); - let value = null; - await trashError(done, testNum, rOps, value); - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_TRASH_RECOVERY_CALLBACK_03_001 - * @tc.name : trash - * @tc.desc : image asset Trash by false - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it("SUB_MEDIA_MEDIALIBRARY_TRASH_RECOVERY_CALLBACK_03_001", 0, async function (done) { - let testNum = "SUB_MEDIA_MEDIALIBRARY_TRASH_RECOVERY_CALLBACK_03_001"; - let rOps = fetchOps(testNum, "Pictures/trash/", IMAGE_TYPE); - let aOps = albumFetchOps(testNum, "Pictures/", "trash", IMAGE_TYPE); - let noAlbum = false; - await recovery(done, testNum, rOps, aOps, noAlbum); - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_TRASH_RECOVERY_CALLBACK_03_002 - * @tc.name : trash - * @tc.desc : video asset Trash by false - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it("SUB_MEDIA_MEDIALIBRARY_TRASH_RECOVERY_CALLBACK_03_002", 0, async function (done) { - let testNum = "SUB_MEDIA_MEDIALIBRARY_TRASH_RECOVERY_CALLBACK_03_002"; - let rOps = fetchOps(testNum, "Videos/trash/", VIDEO_TYPE); - let aOps = albumFetchOps(testNum, "Videos/", "trash", VIDEO_TYPE); - let noAlbum = false; - await recovery(done, testNum, rOps, aOps, noAlbum); - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_TRASH_RECOVERY_CALLBACK_03_003 - * @tc.name : trash - * @tc.desc : audio asset Trash by false - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it("SUB_MEDIA_MEDIALIBRARY_TRASH_RECOVERY_CALLBACK_03_003", 0, async function (done) { - let testNum = "SUB_MEDIA_MEDIALIBRARY_TRASH_RECOVERY_CALLBACK_03_003"; - let rOps = fetchOps(testNum, "Audios/trash/", AUDIO_TYPE); - let aOps = albumFetchOps(testNum, "Audios/", "trash", AUDIO_TYPE); - let noAlbum = false; - await recovery(done, testNum, rOps, aOps, noAlbum); - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_TRASH_RECOVERY_CALLBACK_03_004 - * @tc.name : trash - * @tc.desc : file asset Trash by false - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it("SUB_MEDIA_MEDIALIBRARY_TRASH_RECOVERY_CALLBACK_03_004", 0, async function (done) { - let testNum = "SUB_MEDIA_MEDIALIBRARY_TRASH_RECOVERY_CALLBACK_03_004"; - let rOps = fetchOps(testNum, "Documents/trash/", FILE_TYPE); - let aOps = albumFetchOps(testNum, "Documents/", "trash", FILE_TYPE); - let noAlbum = true; - await recovery(done, testNum, rOps, aOps, noAlbum); - }); - }); -} +/* + * Copyright (C) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import mediaLibrary from "@ohos.multimedia.mediaLibrary"; +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "deccjsunit/index"; +import { + sleep, + IMAGE_TYPE, + AUDIO_TYPE, + VIDEO_TYPE, + FILE_TYPE, + fetchOps, + getPermission, + albumFetchOps, + fileIdFetchOps, + checkPresetsAssets, +} from "../../../../../../common"; + +export default function trashCallback(abilityContext) { + describe("trashCallback", function () { + beforeAll(async function () { + await getPermission(null, abilityContext); + console.info("beforeAll case"); + await checkPresetsAssets(media, "ActsMediaLibraryTrashJsTest"); + }); + beforeEach(function () { + console.info("beforeEach case"); + }); + afterEach(async function () { + console.info("afterEach case"); + await sleep(); + }); + afterAll(async function () { + console.info("afterAll case"); + }); + + const media = mediaLibrary.getMediaLibrary(abilityContext); + + async function setTrash(done, testNum, databasefFetchOps, ablumFetchOps, noAlbum) { + try { + // database info + let databaseFetchFileResult = await media.getFileAssets(databasefFetchOps); + let count = databaseFetchFileResult.getCount(); + //album info + if (!noAlbum) { + let albumList = await media.getAlbums(ablumFetchOps); + let album = albumList[0]; + let albumFetchFileResult = await album.getFileAssets(); + let albumFilesCount = albumFetchFileResult.getCount(); + expect(albumFilesCount).assertEqual(count); + } + // file info + let asset = await databaseFetchFileResult.getFirstObject(); + let id = asset.id; + let istrash = await asset.isTrash(); + expect(istrash).assertFalse(); + // 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 + databaseFetchFileResult = await media.getFileAssets(databasefFetchOps); + let databaseCount = databaseFetchFileResult.getCount(); + + expect(databaseCount).assertEqual(count - 1); + //album info + if (!noAlbum) { + let albumList = await media.getAlbums(ablumFetchOps); + let album = albumList[0]; + let albumFetchFileResult = await album.getFileAssets(); + let albumFilesCount = albumFetchFileResult.getCount(); + expect(albumFilesCount).assertEqual(count - 1); + } + let assetOpts = fileIdFetchOps(id); + let trashAssetResult = await media.getFileAssets(assetOpts); + let afterTrashAssetConut = trashAssetResult.getCount(); + expect(afterTrashAssetConut).assertEqual(0); + 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) { + try { + let databaseFetchFileResult = await media.getFileAssets(databasefFetchOps); + let count = databaseFetchFileResult.getCount(); + let asset = await databaseFetchFileResult.getFirstObject(); + let id = asset.id; + await asset.trash(true); + + let istrash = await asset.isTrash(); + if (!istrash) { + console.info(`${testNum} istrash failed: ${istrash}`); + expect(istrash).assertFalse(); + return; + } + 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 { + databaseFetchFileResult = await media.getFileAssets(databasefFetchOps); + let databaseCount = databaseFetchFileResult.getCount(); + expect(databaseCount).assertEqual(count); + //album info + if (!noAlbum) { + let albumList = await media.getAlbums(ablumFetchOps); + let album = albumList[0]; + let albumFetchFileResult = await album.getFileAssets(); + let albumFilesCount = albumFetchFileResult.getCount(); + expect(albumFilesCount).assertEqual(count); + } + // asset after trash Conut + let assetOpts = fileIdFetchOps(testNum, id); + let recoveryAssetResult = await media.getFileAssets(assetOpts); + let afterRecoveryAssetConut = recoveryAssetResult.getCount(); + expect(afterRecoveryAssetConut).assertEqual(1); + let recoveryAsset = await recoveryAssetResult.getFirstObject(); + let recoveryAssetState = await recoveryAsset.isTrash(); + expect(recoveryAssetState).assertFalse(); + 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 trashError(done, testNum, databasefFetchOps, value) { + try { + let databaseFetchFileResult = await media.getFileAssets(databasefFetchOps); + let asset = await databaseFetchFileResult.getFirstObject(); + let count = databaseFetchFileResult.getCount(); + console.info(`${testNum}count:${count}`); + try { + asset.trash(value, async (err) => { + if (err) { + console.info(`${testNum} err: ${err}`); + expect(false).assertTrue(); + done(); + return; + } + expect(false).assertTrue(); + done(); + }); + } catch (error) { + console.info(`${testNum} error: ${error}`); + let databaseFetchFileResult = await media.getFileAssets(databasefFetchOps); + let count2 = databaseFetchFileResult.getCount(); + expect(count).assertEqual(count2); + done(); + } + } catch (error) { + console.info(`${testNum} error: ${error}`); + expect(false).assertTrue(); + done(); + } + } + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_TRASH_CALLBACK_01_001 + * @tc.name : trash + * @tc.desc : image asset Trash by true + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it("SUB_MEDIA_MEDIALIBRARY_TRASH_CALLBACK_01_001", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_TRASH_CALLBACK_01_001"; + let rOps = fetchOps(testNum, "Pictures/trashCb/", IMAGE_TYPE); + let aOps = albumFetchOps(testNum, "Pictures/", "trashCb", IMAGE_TYPE); + let noAlbum = false; + await setTrash(done, testNum, rOps, aOps, noAlbum); + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_TRASH_CALLBACK_01_002 + * @tc.name : trash + * @tc.desc : video asset Trash by true + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it("SUB_MEDIA_MEDIALIBRARY_TRASH_CALLBACK_01_002", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_TRASH_CALLBACK_01_002"; + let rOps = fetchOps(testNum, "Videos/trashCb/", VIDEO_TYPE); + let aOps = albumFetchOps(testNum, "Videos/", "trashCb", VIDEO_TYPE); + let noAlbum = false; + await setTrash(done, testNum, rOps, aOps, noAlbum); + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_TRASH_CALLBACK_01_003 + * @tc.name : trash + * @tc.desc : audio asset Trash by true + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it("SUB_MEDIA_MEDIALIBRARY_TRASH_CALLBACK_01_003", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_TRASH_CALLBACK_01_003"; + let rOps = fetchOps(testNum, "Audios/trashCb/", AUDIO_TYPE); + let aOps = albumFetchOps(testNum, "Audios/", "trashCb", AUDIO_TYPE); + let noAlbum = false; + await setTrash(done, testNum, rOps, aOps, noAlbum); + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_TRASH_CALLBACK_01_004 + * @tc.name : trash + * @tc.desc : file asset Trash by true + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it("SUB_MEDIA_MEDIALIBRARY_TRASH_CALLBACK_01_004", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_TRASH_CALLBACK_01_004"; + let rOps = fetchOps(testNum, "Documents/trashCb/", FILE_TYPE); + let aOps = albumFetchOps(testNum, "Documents/", "trashCb", FILE_TYPE); + let noAlbum = true; + await setTrash(done, testNum, rOps, aOps, noAlbum); + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_TRASH_ERROR_CALLBACK_02_001 + * @tc.name : trash + * @tc.desc : image asset Trash by 1 + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 3 + */ + it("SUB_MEDIA_MEDIALIBRARY_TRASH_ERROR_CALLBACK_02_001", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_TRASH_ERROR_CALLBACK_02_001"; + let rOps = fetchOps(testNum, "Pictures/trashCb/", IMAGE_TYPE); + let value = 1; + await trashError(done, testNum, rOps, value); + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_TRASH_ERROR_CALLBACK_02_002 + * @tc.name : trash + * @tc.desc : image asset Trash by 'abc' + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 3 + */ + it("SUB_MEDIA_MEDIALIBRARY_TRASH_ERROR_CALLBACK_02_002", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_TRASH_ERROR_CALLBACK_02_002"; + let rOps = fetchOps(testNum, "Pictures/trashCb/", IMAGE_TYPE); + let value = "abc"; + await trashError(done, testNum, rOps, value); + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_TRASH_ERROR_CALLBACK_02_003 + * @tc.name : trash + * @tc.desc : image asset Trash by {a:10} + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 3 + */ + it("SUB_MEDIA_MEDIALIBRARY_TRASH_ERROR_CALLBACK_02_003", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_TRASH_ERROR_CALLBACK_02_003"; + let rOps = fetchOps(testNum, "Pictures/trashCb/", IMAGE_TYPE); + let value = { a: 10 }; + await trashError(done, testNum, rOps, value); + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_TRASH_ERROR_CALLBACK_02_004 + * @tc.name : trash + * @tc.desc : image asset Trash by undefined + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 3 + */ + it("SUB_MEDIA_MEDIALIBRARY_TRASH_ERROR_CALLBACK_02_004", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_TRASH_ERROR_CALLBACK_02_004"; + let rOps = fetchOps(testNum, "Pictures/trashCb/", IMAGE_TYPE); + let value = undefined; + await trashError(done, testNum, rOps, value); + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_TRASH_ERROR_CALLBACK_02_005 + * @tc.name : trash + * @tc.desc : image asset Trash by null + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 3 + */ + it("SUB_MEDIA_MEDIALIBRARY_TRASH_ERROR_CALLBACK_02_005", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_TRASH_ERROR_CALLBACK_02_005"; + let rOps = fetchOps(testNum, "Pictures/trashCb/", IMAGE_TYPE); + let value = null; + await trashError(done, testNum, rOps, value); + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_TRASH_RECOVERY_CALLBACK_03_001 + * @tc.name : trash + * @tc.desc : image asset Trash by false + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it("SUB_MEDIA_MEDIALIBRARY_TRASH_RECOVERY_CALLBACK_03_001", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_TRASH_RECOVERY_CALLBACK_03_001"; + let rOps = fetchOps(testNum, "Pictures/trash/", IMAGE_TYPE); + let aOps = albumFetchOps(testNum, "Pictures/", "trash", IMAGE_TYPE); + let noAlbum = false; + await recovery(done, testNum, rOps, aOps, noAlbum); + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_TRASH_RECOVERY_CALLBACK_03_002 + * @tc.name : trash + * @tc.desc : video asset Trash by false + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it("SUB_MEDIA_MEDIALIBRARY_TRASH_RECOVERY_CALLBACK_03_002", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_TRASH_RECOVERY_CALLBACK_03_002"; + let rOps = fetchOps(testNum, "Videos/trash/", VIDEO_TYPE); + let aOps = albumFetchOps(testNum, "Videos/", "trash", VIDEO_TYPE); + let noAlbum = false; + await recovery(done, testNum, rOps, aOps, noAlbum); + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_TRASH_RECOVERY_CALLBACK_03_003 + * @tc.name : trash + * @tc.desc : audio asset Trash by false + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it("SUB_MEDIA_MEDIALIBRARY_TRASH_RECOVERY_CALLBACK_03_003", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_TRASH_RECOVERY_CALLBACK_03_003"; + let rOps = fetchOps(testNum, "Audios/trash/", AUDIO_TYPE); + let aOps = albumFetchOps(testNum, "Audios/", "trash", AUDIO_TYPE); + let noAlbum = false; + await recovery(done, testNum, rOps, aOps, noAlbum); + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_TRASH_RECOVERY_CALLBACK_03_004 + * @tc.name : trash + * @tc.desc : file asset Trash by false + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it("SUB_MEDIA_MEDIALIBRARY_TRASH_RECOVERY_CALLBACK_03_004", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_TRASH_RECOVERY_CALLBACK_03_004"; + let rOps = fetchOps(testNum, "Documents/trash/", FILE_TYPE); + let aOps = albumFetchOps(testNum, "Documents/", "trash", FILE_TYPE); + let noAlbum = true; + await recovery(done, testNum, rOps, aOps, noAlbum); + }); + }); +} diff --git a/multimedia/medialibrary/mediaLibrary_trash/entry/src/main/ets/test/trashPromise.test.ets b/multimedia/medialibrary/mediaLibrary_trash/entry/src/main/ets/test/trashPromise.test.ets index 65efe07957d8b55b0fdd36977ff80376b5c14c03..ff1dc325574e6763eed3bbc7ca8b093e66fa729d 100644 --- a/multimedia/medialibrary/mediaLibrary_trash/entry/src/main/ets/test/trashPromise.test.ets +++ b/multimedia/medialibrary/mediaLibrary_trash/entry/src/main/ets/test/trashPromise.test.ets @@ -1,365 +1,365 @@ -/* - * Copyright (C) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import mediaLibrary from "@ohos.multimedia.mediaLibrary"; -import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "deccjsunit/index"; -import { - sleep, - IMAGE_TYPE, - AUDIO_TYPE, - VIDEO_TYPE, - FILE_TYPE, - fetchOps, - fileIdFetchOps, - albumFetchOps, -} from "../../../../../../common"; - -export default function trashPromise(abilityContext) { - describe("trashPromise", function () { - 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 media = mediaLibrary.getMediaLibrary(abilityContext); - async function setTrash(done, testNum, databasefFetchOps, ablumFetchOps, noAlbum = false) { - try { - // database info - let databaseFetchFileResult = await media.getFileAssets(databasefFetchOps); - let count = databaseFetchFileResult.getCount(); - - //album info - if (!noAlbum) { - var albumList = await media.getAlbums(ablumFetchOps); - var album = albumList[0]; - var albumFetchFileResult = await album.getFileAssets(); - var albumFilesCount = albumFetchFileResult.getCount(); - expect(albumFilesCount).assertEqual(count); - } - - // file info - let asset = await databaseFetchFileResult.getFirstObject(); - let id = asset.id; - let istrash = await asset.isTrash(); - expect(istrash).assertFalse(); - // trash operation - await asset.trash(true); - istrash = await asset.isTrash(); - console.info(`${testNum} istrash: ${istrash}`); - databaseFetchFileResult = await media.getFileAssets(databasefFetchOps); - let databaseCount = databaseFetchFileResult.getCount(); - expect(databaseCount).assertEqual(count - 1); - //album info - if (!noAlbum) { - var albumList = await media.getAlbums(ablumFetchOps); - var album = albumList[0]; - var albumFetchFileResult = await album.getFileAssets(); - var albumFilesCount = albumFetchFileResult.getCount(); - expect(databaseCount).assertEqual(count - 1); - } - - // asset after trash Conut - let assetOpts = fileIdFetchOps(id); - let trashAssetResult = await media.getFileAssets(assetOpts); - let afterTrashAssetConut = trashAssetResult.getCount(); - expect(afterTrashAssetConut).assertEqual(0); - await asset.trash(false); - done(); - } catch (error) { - console.info(`${testNum} error: ${error}`); - expect(false).assertTrue(); - done(); - } - } - - async function trashError(done, testNum, databasefFetchOps, value) { - try { - let databaseFetchFileResult = await media.getFileAssets(databasefFetchOps); - let asset = await databaseFetchFileResult.getFirstObject(); - let count = databaseFetchFileResult.getCount(); - try { - await asset.trash(value); - expect(false).assertTrue(); - done(); - } catch (error) { - console.info(`${testNum} error: ${error}`); - let databaseFetchFileResult = await media.getFileAssets(databasefFetchOps); - let count2 = databaseFetchFileResult.getCount(); - expect(count).assertEqual(count2); - done(); - } - } catch (error) { - console.info(`${testNum} error: ${error}`); - expect(false).assertTrue(); - done(); - } - } - - async function recovery(done, testNum, databasefFetchOps, ablumFetchOps, noAlbum) { - try { - let databaseFetchFileResult = await media.getFileAssets(databasefFetchOps); - let count = databaseFetchFileResult.getCount(); - let asset = await databaseFetchFileResult.getFirstObject(); - let id = asset.id; - await asset.trash(true); - - let istrash = await asset.isTrash(); - if (!istrash) { - console.info(`${testNum} istrash failed: ${istrash}`); - expect(istrash).assertFalse(); - return; - } - await asset.trash(false); - - databaseFetchFileResult = await media.getFileAssets(databasefFetchOps); - let databaseCount = databaseFetchFileResult.getCount(); - expect(databaseCount).assertEqual(count); - //album info - if (!noAlbum) { - let albumList = await media.getAlbums(ablumFetchOps); - let album = albumList[0]; - let albumFetchFileResult = await album.getFileAssets(); - let albumFilesCount = albumFetchFileResult.getCount(); - expect(albumFilesCount).assertEqual(count); - } - - // asset after trash Conut - let assetOpts = fileIdFetchOps(testNum, id); - let recoveryAssetResult = await media.getFileAssets(assetOpts); - let afterRecoveryAssetConut = recoveryAssetResult.getCount(); - expect(afterRecoveryAssetConut).assertEqual(1); - let recoveryAsset = await recoveryAssetResult.getFirstObject(); - let recoveryAssetState = await recoveryAsset.isTrash(); - expect(recoveryAssetState).assertFalse(); - - done(); - } catch (error) { - console.info(`${testNum} error: ${error}`); - expect(false).assertTrue(); - done(); - } - } - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_TRASH_PROMISE_01_001 - * @tc.name : trash - * @tc.desc : image asset Trash by true - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it("SUB_MEDIA_MEDIALIBRARY_TRASH_PROMISE_01_001", 0, async function (done) { - let testNum = "SUB_MEDIA_MEDIALIBRARY_TRASH_PROMISE_01_001"; - let rOps = fetchOps(testNum, "Pictures/trash/", IMAGE_TYPE); - let aOps = albumFetchOps(testNum, "Pictures/", "trash", IMAGE_TYPE); - let noAlbum = false; - await setTrash(done, testNum, rOps, aOps, noAlbum); - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_TRASH_PROMISE_01_002 - * @tc.name : trash - * @tc.desc : video asset Trash by true - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it("SUB_MEDIA_MEDIALIBRARY_TRASH_PROMISE_01_002", 0, async function (done) { - let testNum = "SUB_MEDIA_MEDIALIBRARY_TRASH_PROMISE_01_002"; - let rOps = fetchOps(testNum, "Videos/trash/", VIDEO_TYPE); - let aOps = albumFetchOps(testNum, "Videos/", "trash", VIDEO_TYPE); - let noAlbum = false; - await setTrash(done, testNum, rOps, aOps, noAlbum); - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_TRASH_PROMISE_01_003 - * @tc.name : trash - * @tc.desc : audio asset Trash by true - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it("SUB_MEDIA_MEDIALIBRARY_TRASH_PROMISE_01_003", 0, async function (done) { - let testNum = "SUB_MEDIA_MEDIALIBRARY_TRASH_PROMISE_01_003"; - let rOps = fetchOps(testNum, "Audios/trash/", AUDIO_TYPE); - let aOps = albumFetchOps(testNum, "Audios/", "trash", AUDIO_TYPE); - let noAlbum = false; - await setTrash(done, testNum, rOps, aOps, noAlbum); - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_TRASH_PROMISE_01_004 - * @tc.name : trash - * @tc.desc : file asset Trash by true - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it("SUB_MEDIA_MEDIALIBRARY_TRASH_PROMISE_01_004", 0, async function (done) { - let testNum = "SUB_MEDIA_MEDIALIBRARY_TRASH_PROMISE_01_004"; - let rOps = fetchOps(testNum, "Documents/trash/", FILE_TYPE); - let aOps = albumFetchOps(testNum, "Documents/", "trash", FILE_TYPE); - let noAlbum = true; - await setTrash(done, testNum, rOps, aOps, noAlbum); - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_TRASH_ERROR_PROMISE_02_001 - * @tc.name : trash - * @tc.desc : image asset Trash by 1 - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 3 - */ - it("SUB_MEDIA_MEDIALIBRARY_TRASH_ERROR_PROMISE_02_001", 0, async function (done) { - let testNum = "SUB_MEDIA_MEDIALIBRARY_TRASH_ERROR_PROMISE_02_001"; - let rOps = fetchOps(testNum, "Pictures/trash/", IMAGE_TYPE); - let value = 1; - await trashError(done, testNum, rOps, value); - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_TRASH_ERROR_PROMISE_02_002 - * @tc.name : trash - * @tc.desc : image asset Trash by 'abc' - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 3 - */ - it("SUB_MEDIA_MEDIALIBRARY_TRASH_ERROR_PROMISE_02_002", 0, async function (done) { - let testNum = "SUB_MEDIA_MEDIALIBRARY_TRASH_ERROR_PROMISE_02_002"; - let rOps = fetchOps(testNum, "Pictures/trash/", IMAGE_TYPE); - let value = "abc"; - await trashError(done, testNum, rOps, value); - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_TRASH_ERROR_PROMISE_02_003 - * @tc.name : trash - * @tc.desc : image asset Trash by {a:10} - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 3 - */ - it("SUB_MEDIA_MEDIALIBRARY_TRASH_ERROR_PROMISE_02_003", 0, async function (done) { - let testNum = "SUB_MEDIA_MEDIALIBRARY_TRASH_ERROR_PROMISE_02_003"; - let rOps = fetchOps(testNum, "Pictures/trash/", IMAGE_TYPE); - let value = { a: 10 }; - await trashError(done, testNum, rOps, value); - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_TRASH_ERROR_PROMISE_02_004 - * @tc.name : trash - * @tc.desc : image asset Trash by undefined - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 3 - */ - it("SUB_MEDIA_MEDIALIBRARY_TRASH_ERROR_PROMISE_02_004", 0, async function (done) { - let testNum = "SUB_MEDIA_MEDIALIBRARY_TRASH_ERROR_PROMISE_02_004"; - let rOps = fetchOps(testNum, "Pictures/trash/", IMAGE_TYPE); - let value = undefined; - await trashError(done, testNum, rOps, value); - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_TRASH_ERROR_PROMISE_02_005 - * @tc.name : trash - * @tc.desc : image asset Trash by null - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 3 - */ - it("SUB_MEDIA_MEDIALIBRARY_TRASH_ERROR_PROMISE_02_005", 0, async function (done) { - let testNum = "SUB_MEDIA_MEDIALIBRARY_TRASH_ERROR_PROMISE_02_005"; - let rOps = fetchOps(testNum, "Pictures/trash/", IMAGE_TYPE); - let value = null; - await trashError(done, testNum, rOps, value); - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_TRASH_RECOVERY_PROMISE_03_001 - * @tc.name : trash - * @tc.desc : image asset Trash by false - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it("SUB_MEDIA_MEDIALIBRARY_TRASH_RECOVERY_PROMISE_03_001", 0, async function (done) { - let testNum = "SUB_MEDIA_MEDIALIBRARY_TRASH_RECOVERY_PROMISE_03_001"; - let rOps = fetchOps(testNum, "Pictures/trash/", IMAGE_TYPE); - let aOps = albumFetchOps(testNum, "Pictures/", "trash", IMAGE_TYPE); - let noAlbum = false; - await recovery(done, testNum, rOps, aOps, noAlbum); - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_TRASH_RECOVERY_PROMISE_03_002 - * @tc.name : trash - * @tc.desc : video asset Trash by false - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it("SUB_MEDIA_MEDIALIBRARY_TRASH_RECOVERY_PROMISE_03_002", 0, async function (done) { - let testNum = "SUB_MEDIA_MEDIALIBRARY_TRASH_RECOVERY_PROMISE_03_002"; - let rOps = fetchOps(testNum, "Videos/trash/", VIDEO_TYPE); - let aOps = albumFetchOps(testNum, "Videos/", "trash", VIDEO_TYPE); - let noAlbum = false; - await recovery(done, testNum, rOps, aOps, noAlbum); - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_TRASH_RECOVERY_PROMISE_03_003 - * @tc.name : trash - * @tc.desc : audio asset Trash by false - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it("SUB_MEDIA_MEDIALIBRARY_TRASH_RECOVERY_PROMISE_03_003", 0, async function (done) { - let testNum = "SUB_MEDIA_MEDIALIBRARY_TRASH_RECOVERY_PROMISE_03_003"; - let rOps = fetchOps(testNum, "Audios/trash/", AUDIO_TYPE); - let aOps = albumFetchOps(testNum, "Audios/", "trash", AUDIO_TYPE); - let noAlbum = false; - await recovery(done, testNum, rOps, aOps, noAlbum); - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_TRASH_RECOVERY_PROMISE_03_004 - * @tc.name : trash - * @tc.desc : file asset Trash by false - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it("SUB_MEDIA_MEDIALIBRARY_TRASH_RECOVERY_PROMISE_03_004", 0, async function (done) { - let testNum = "SUB_MEDIA_MEDIALIBRARY_TRASH_RECOVERY_PROMISE_03_004"; - let rOps = fetchOps(testNum, "Documents/trash/", FILE_TYPE); - let aOps = albumFetchOps(testNum, "Documents/", "trash", FILE_TYPE); - let noAlbum = true; - await recovery(done, testNum, rOps, aOps, noAlbum); - }); - }); -} +/* + * Copyright (C) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import mediaLibrary from "@ohos.multimedia.mediaLibrary"; +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "deccjsunit/index"; +import { + sleep, + IMAGE_TYPE, + AUDIO_TYPE, + VIDEO_TYPE, + FILE_TYPE, + fetchOps, + fileIdFetchOps, + albumFetchOps, +} from "../../../../../../common"; + +export default function trashPromise(abilityContext) { + describe("trashPromise", function () { + 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 media = mediaLibrary.getMediaLibrary(abilityContext); + async function setTrash(done, testNum, databasefFetchOps, ablumFetchOps, noAlbum = false) { + try { + // database info + let databaseFetchFileResult = await media.getFileAssets(databasefFetchOps); + let count = databaseFetchFileResult.getCount(); + + //album info + if (!noAlbum) { + var albumList = await media.getAlbums(ablumFetchOps); + var album = albumList[0]; + var albumFetchFileResult = await album.getFileAssets(); + var albumFilesCount = albumFetchFileResult.getCount(); + expect(albumFilesCount).assertEqual(count); + } + + // file info + let asset = await databaseFetchFileResult.getFirstObject(); + let id = asset.id; + let istrash = await asset.isTrash(); + expect(istrash).assertFalse(); + // trash operation + await asset.trash(true); + istrash = await asset.isTrash(); + console.info(`${testNum} istrash: ${istrash}`); + databaseFetchFileResult = await media.getFileAssets(databasefFetchOps); + let databaseCount = databaseFetchFileResult.getCount(); + expect(databaseCount).assertEqual(count - 1); + //album info + if (!noAlbum) { + var albumList = await media.getAlbums(ablumFetchOps); + var album = albumList[0]; + var albumFetchFileResult = await album.getFileAssets(); + var albumFilesCount = albumFetchFileResult.getCount(); + expect(databaseCount).assertEqual(count - 1); + } + + // asset after trash Conut + let assetOpts = fileIdFetchOps(id); + let trashAssetResult = await media.getFileAssets(assetOpts); + let afterTrashAssetConut = trashAssetResult.getCount(); + expect(afterTrashAssetConut).assertEqual(0); + await asset.trash(false); + done(); + } catch (error) { + console.info(`${testNum} error: ${error}`); + expect(false).assertTrue(); + done(); + } + } + + async function trashError(done, testNum, databasefFetchOps, value) { + try { + let databaseFetchFileResult = await media.getFileAssets(databasefFetchOps); + let asset = await databaseFetchFileResult.getFirstObject(); + let count = databaseFetchFileResult.getCount(); + try { + await asset.trash(value); + expect(false).assertTrue(); + done(); + } catch (error) { + console.info(`${testNum} error: ${error}`); + let databaseFetchFileResult = await media.getFileAssets(databasefFetchOps); + let count2 = databaseFetchFileResult.getCount(); + expect(count).assertEqual(count2); + done(); + } + } catch (error) { + console.info(`${testNum} error: ${error}`); + expect(false).assertTrue(); + done(); + } + } + + async function recovery(done, testNum, databasefFetchOps, ablumFetchOps, noAlbum) { + try { + let databaseFetchFileResult = await media.getFileAssets(databasefFetchOps); + let count = databaseFetchFileResult.getCount(); + let asset = await databaseFetchFileResult.getFirstObject(); + let id = asset.id; + await asset.trash(true); + + let istrash = await asset.isTrash(); + if (!istrash) { + console.info(`${testNum} istrash failed: ${istrash}`); + expect(istrash).assertFalse(); + return; + } + await asset.trash(false); + + databaseFetchFileResult = await media.getFileAssets(databasefFetchOps); + let databaseCount = databaseFetchFileResult.getCount(); + expect(databaseCount).assertEqual(count); + //album info + if (!noAlbum) { + let albumList = await media.getAlbums(ablumFetchOps); + let album = albumList[0]; + let albumFetchFileResult = await album.getFileAssets(); + let albumFilesCount = albumFetchFileResult.getCount(); + expect(albumFilesCount).assertEqual(count); + } + + // asset after trash Conut + let assetOpts = fileIdFetchOps(testNum, id); + let recoveryAssetResult = await media.getFileAssets(assetOpts); + let afterRecoveryAssetConut = recoveryAssetResult.getCount(); + expect(afterRecoveryAssetConut).assertEqual(1); + let recoveryAsset = await recoveryAssetResult.getFirstObject(); + let recoveryAssetState = await recoveryAsset.isTrash(); + expect(recoveryAssetState).assertFalse(); + + done(); + } catch (error) { + console.info(`${testNum} error: ${error}`); + expect(false).assertTrue(); + done(); + } + } + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_TRASH_PROMISE_01_001 + * @tc.name : trash + * @tc.desc : image asset Trash by true + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it("SUB_MEDIA_MEDIALIBRARY_TRASH_PROMISE_01_001", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_TRASH_PROMISE_01_001"; + let rOps = fetchOps(testNum, "Pictures/trash/", IMAGE_TYPE); + let aOps = albumFetchOps(testNum, "Pictures/", "trash", IMAGE_TYPE); + let noAlbum = false; + await setTrash(done, testNum, rOps, aOps, noAlbum); + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_TRASH_PROMISE_01_002 + * @tc.name : trash + * @tc.desc : video asset Trash by true + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it("SUB_MEDIA_MEDIALIBRARY_TRASH_PROMISE_01_002", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_TRASH_PROMISE_01_002"; + let rOps = fetchOps(testNum, "Videos/trash/", VIDEO_TYPE); + let aOps = albumFetchOps(testNum, "Videos/", "trash", VIDEO_TYPE); + let noAlbum = false; + await setTrash(done, testNum, rOps, aOps, noAlbum); + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_TRASH_PROMISE_01_003 + * @tc.name : trash + * @tc.desc : audio asset Trash by true + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it("SUB_MEDIA_MEDIALIBRARY_TRASH_PROMISE_01_003", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_TRASH_PROMISE_01_003"; + let rOps = fetchOps(testNum, "Audios/trash/", AUDIO_TYPE); + let aOps = albumFetchOps(testNum, "Audios/", "trash", AUDIO_TYPE); + let noAlbum = false; + await setTrash(done, testNum, rOps, aOps, noAlbum); + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_TRASH_PROMISE_01_004 + * @tc.name : trash + * @tc.desc : file asset Trash by true + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it("SUB_MEDIA_MEDIALIBRARY_TRASH_PROMISE_01_004", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_TRASH_PROMISE_01_004"; + let rOps = fetchOps(testNum, "Documents/trash/", FILE_TYPE); + let aOps = albumFetchOps(testNum, "Documents/", "trash", FILE_TYPE); + let noAlbum = true; + await setTrash(done, testNum, rOps, aOps, noAlbum); + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_TRASH_ERROR_PROMISE_02_001 + * @tc.name : trash + * @tc.desc : image asset Trash by 1 + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 3 + */ + it("SUB_MEDIA_MEDIALIBRARY_TRASH_ERROR_PROMISE_02_001", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_TRASH_ERROR_PROMISE_02_001"; + let rOps = fetchOps(testNum, "Pictures/trash/", IMAGE_TYPE); + let value = 1; + await trashError(done, testNum, rOps, value); + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_TRASH_ERROR_PROMISE_02_002 + * @tc.name : trash + * @tc.desc : image asset Trash by 'abc' + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 3 + */ + it("SUB_MEDIA_MEDIALIBRARY_TRASH_ERROR_PROMISE_02_002", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_TRASH_ERROR_PROMISE_02_002"; + let rOps = fetchOps(testNum, "Pictures/trash/", IMAGE_TYPE); + let value = "abc"; + await trashError(done, testNum, rOps, value); + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_TRASH_ERROR_PROMISE_02_003 + * @tc.name : trash + * @tc.desc : image asset Trash by {a:10} + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 3 + */ + it("SUB_MEDIA_MEDIALIBRARY_TRASH_ERROR_PROMISE_02_003", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_TRASH_ERROR_PROMISE_02_003"; + let rOps = fetchOps(testNum, "Pictures/trash/", IMAGE_TYPE); + let value = { a: 10 }; + await trashError(done, testNum, rOps, value); + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_TRASH_ERROR_PROMISE_02_004 + * @tc.name : trash + * @tc.desc : image asset Trash by undefined + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 3 + */ + it("SUB_MEDIA_MEDIALIBRARY_TRASH_ERROR_PROMISE_02_004", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_TRASH_ERROR_PROMISE_02_004"; + let rOps = fetchOps(testNum, "Pictures/trash/", IMAGE_TYPE); + let value = undefined; + await trashError(done, testNum, rOps, value); + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_TRASH_ERROR_PROMISE_02_005 + * @tc.name : trash + * @tc.desc : image asset Trash by null + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 3 + */ + it("SUB_MEDIA_MEDIALIBRARY_TRASH_ERROR_PROMISE_02_005", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_TRASH_ERROR_PROMISE_02_005"; + let rOps = fetchOps(testNum, "Pictures/trash/", IMAGE_TYPE); + let value = null; + await trashError(done, testNum, rOps, value); + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_TRASH_RECOVERY_PROMISE_03_001 + * @tc.name : trash + * @tc.desc : image asset Trash by false + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it("SUB_MEDIA_MEDIALIBRARY_TRASH_RECOVERY_PROMISE_03_001", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_TRASH_RECOVERY_PROMISE_03_001"; + let rOps = fetchOps(testNum, "Pictures/trash/", IMAGE_TYPE); + let aOps = albumFetchOps(testNum, "Pictures/", "trash", IMAGE_TYPE); + let noAlbum = false; + await recovery(done, testNum, rOps, aOps, noAlbum); + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_TRASH_RECOVERY_PROMISE_03_002 + * @tc.name : trash + * @tc.desc : video asset Trash by false + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it("SUB_MEDIA_MEDIALIBRARY_TRASH_RECOVERY_PROMISE_03_002", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_TRASH_RECOVERY_PROMISE_03_002"; + let rOps = fetchOps(testNum, "Videos/trash/", VIDEO_TYPE); + let aOps = albumFetchOps(testNum, "Videos/", "trash", VIDEO_TYPE); + let noAlbum = false; + await recovery(done, testNum, rOps, aOps, noAlbum); + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_TRASH_RECOVERY_PROMISE_03_003 + * @tc.name : trash + * @tc.desc : audio asset Trash by false + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it("SUB_MEDIA_MEDIALIBRARY_TRASH_RECOVERY_PROMISE_03_003", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_TRASH_RECOVERY_PROMISE_03_003"; + let rOps = fetchOps(testNum, "Audios/trash/", AUDIO_TYPE); + let aOps = albumFetchOps(testNum, "Audios/", "trash", AUDIO_TYPE); + let noAlbum = false; + await recovery(done, testNum, rOps, aOps, noAlbum); + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_TRASH_RECOVERY_PROMISE_03_004 + * @tc.name : trash + * @tc.desc : file asset Trash by false + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it("SUB_MEDIA_MEDIALIBRARY_TRASH_RECOVERY_PROMISE_03_004", 0, async function (done) { + let testNum = "SUB_MEDIA_MEDIALIBRARY_TRASH_RECOVERY_PROMISE_03_004"; + let rOps = fetchOps(testNum, "Documents/trash/", FILE_TYPE); + let aOps = albumFetchOps(testNum, "Documents/", "trash", FILE_TYPE); + let noAlbum = true; + await recovery(done, testNum, rOps, aOps, noAlbum); + }); + }); +} diff --git a/multimedia/medialibrary/mediaLibrary_trash/entry/src/main/module.json b/multimedia/medialibrary/mediaLibrary_trash/entry/src/main/module.json index 6785829959ef1d93e26aaea687a2ec9bb759d52d..025062ffed12b44b32db7f5f35356c9040ed9c5c 100644 --- a/multimedia/medialibrary/mediaLibrary_trash/entry/src/main/module.json +++ b/multimedia/medialibrary/mediaLibrary_trash/entry/src/main/module.json @@ -3,11 +3,11 @@ "name": "phone", "type": "entry", "srcEntrance": "./ets/Application/AbilityStage.ts", - "description": "$string:mainability_description", + "description": "$string:phone_entry_dsc", "mainElement": "MainAbility", "deviceTypes": [ - "tablet", - "default", + "tablet", + "default", "phone" ], "deliveryWithInstall": true, @@ -16,11 +16,11 @@ "pages": "$profile:main_pages", "abilities": [ { - "name": "ohos.acts.multimedia.mediaLibrary.MainAbility", + "name": "com.example.myapplication.MainAbility", "srcEntrance": "./ets/MainAbility/MainAbility.ts", - "description": "$string:mainability_description", + "description": "$string:phone_entry_main", "icon": "$media:icon", - "label": "$string:entry_MainAbility", + "label": "$string:entry_label", "visible": true, "orientation": "portrait", "skills": [ @@ -28,42 +28,42 @@ "actions": [ "action.system.home" ], - "entities":[ + "entities": [ "entity.system.home" ] } ] } ], - "requestPermissions": [ + "requestPermissions": [ { "name": "ohos.permission.GET_BUNDLE_INFO", "reason": "use ohos.permission.GET_BUNDLE_INFO" }, { "name": "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED", - "reason":"use ohos.permission.GET_BUNDLE_INFO_PRIVILEGED" + "reason": "use ohos.permission.GET_BUNDLE_INFO_PRIVILEGED" }, { - "name" : "ohos.permission.GRANT_SENSITIVE_PERMISSIONS", - "reason" : "use ohos.permission.GRANT_SENSITIVE_PERMISSIONS" + "name": "ohos.permission.GRANT_SENSITIVE_PERMISSIONS", + "reason": "use ohos.permission.GRANT_SENSITIVE_PERMISSIONS" }, { - "name" : "ohos.permission.REVOKE_SENSITIVE_PERMISSIONS", - "reason" : "use ohos.permission.REVOKE_SENSITIVE_PERMISSIONS" + "name": "ohos.permission.REVOKE_SENSITIVE_PERMISSIONS", + "reason": "use ohos.permission.REVOKE_SENSITIVE_PERMISSIONS" }, { "name": "ohos.permission.MEDIA_LOCATION", - "reason":"use ohos.permission.MEDIA_LOCATION" + "reason": "use ohos.permission.MEDIA_LOCATION" }, { "name": "ohos.permission.READ_MEDIA", - "reason":"use ohos.permission.READ_MEDIA" + "reason": "use ohos.permission.READ_MEDIA" }, { "name": "ohos.permission.WRITE_MEDIA", - "reason":"use ohos.permission.WRITE_MEDIA" + "reason": "use ohos.permission.WRITE_MEDIA" } ] } -} +} \ No newline at end of file diff --git a/multimedia/medialibrary/mediaLibrary_trash/entry/src/main/resources/base/element/string.json b/multimedia/medialibrary/mediaLibrary_trash/entry/src/main/resources/base/element/string.json index d75a3fee650de2abaabfd60f40d90d9c6a4b0b0b..2ae43f018e75d1140cf2c0c85a6a14fc369a0c50 100644 --- a/multimedia/medialibrary/mediaLibrary_trash/entry/src/main/resources/base/element/string.json +++ b/multimedia/medialibrary/mediaLibrary_trash/entry/src/main/resources/base/element/string.json @@ -1,12 +1,32 @@ { "string": [ - { - "name": "entry_MainAbility", - "value": "MediaLibraryJSTestMain" - }, - { - "name": "mainability_description", - "value": "MediaLibraryJSTestMain Ability" - } + { + "name": "phone_entry_dsc", + "value": "i am an entry for phone" + }, + { + "name": "phone_entry_main", + "value": "the phone entry ability" + }, + { + "name": "entry_label", + "value": "ActsMediaLibraryTest" + }, + { + "name": "form_description", + "value": "mediaLibrary" + }, + { + "name": "serviceability_description", + "value": "mediaLibrary" + }, + { + "name": "description_application", + "value": "mediaLibrary test" + }, + { + "name": "app_name", + "value": "ActsMediaLibraryTest" + } ] - } \ No newline at end of file +} \ No newline at end of file diff --git a/multimedia/medialibrary/mediaLibrary_trash/entry/src/main/resources/base/profile/main_pages.json b/multimedia/medialibrary/mediaLibrary_trash/entry/src/main/resources/base/profile/main_pages.json index 6898b31d2085f478ee1ed9d933a5910cbf901d92..ceb075cd80946aade673d707aac904fb8998bce9 100644 --- a/multimedia/medialibrary/mediaLibrary_trash/entry/src/main/resources/base/profile/main_pages.json +++ b/multimedia/medialibrary/mediaLibrary_trash/entry/src/main/resources/base/profile/main_pages.json @@ -1,6 +1,5 @@ { "src": [ - "pages/index/index", - "pages/second/second" + "MainAbility/pages/index/index" ] } \ No newline at end of file diff --git a/multimedia/medialibrary/mediaLibrary_trash/signature/openharmony_sx.p7b b/multimedia/medialibrary/mediaLibrary_trash/signature/openharmony_sx.p7b index 3eb5b5db82a014ff4c9483872cad743ad49a9b6e..64b33bf079b2ab68a3f26f240d127186546b33d9 100644 Binary files a/multimedia/medialibrary/mediaLibrary_trash/signature/openharmony_sx.p7b and b/multimedia/medialibrary/mediaLibrary_trash/signature/openharmony_sx.p7b differ