diff --git a/storage/storagefilemanagerjstest/signature/openharmony_sx.p7b b/storage/storagefilemanagerjstest/signature/openharmony_sx.p7b index 9be1e98fa4c0c28ca997ed660112fa16b194f0f5..1fa42c55eceafebe1aad98c326e0210953e7d232 100644 Binary files a/storage/storagefilemanagerjstest/signature/openharmony_sx.p7b and b/storage/storagefilemanagerjstest/signature/openharmony_sx.p7b differ diff --git a/storage/storagefilemanagerjstest/src/main/config.json b/storage/storagefilemanagerjstest/src/main/config.json index ff67126dedbb7d42af23d1a1578a0cc7e300f5a9..4063ca213f6be9d94debd99f40c1cca6db06e737 100644 --- a/storage/storagefilemanagerjstest/src/main/config.json +++ b/storage/storagefilemanagerjstest/src/main/config.json @@ -1,61 +1,85 @@ { "app": { - "bundleName": "ohos.acts.storage.filemanager", - "vendor": "example", - "version": { - "code": 1000000, - "name": "1.0.0" - }, "apiVersion": { - "compatible": 4, - "target": 5 - } + "compatible": 6, + "target": 7 + }, + "vendor": "example", + "bundleName": "ohos.acts.storage.filemanager", + "version": { + "code": 1000000, + "name": "1.0.0" + } + }, + "deviceConfig": { + "default": { + "debug": true + } }, - "deviceConfig": {}, "module": { - "package": "ohos.acts.storage.filemanager", - "name": ".MyApplication", - "deviceType": [ - "phone" - ], - "distro": { - "deliveryWithInstall": true, - "moduleName": "entry", - "moduleType": "entry", - "installationFree": true - }, - "abilities": [ - { - "skills": [ + "abilities": [ { - "entities": [ - "entity.system.home" - ], - "actions": [ - "action.system.home" - ] + "iconId": 16777218, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "visible": true, + "icon": "$media:icon", + "name": "ohos.acts.storage.filemanager.MainAbility", + "description": "$string:mainability_description", + "label": "$string:app_name", + "type": "page", + "homeAbility": true, + "launchType": "standard" } - ], - "name": "ohos.acts.storage.filemanager.MainAbility", - "icon": "$media:icon", - "description": "$string:mainability_description", - "label": "$string:app_name", - "type": "page", - "launchType": "standard", - "visible": true - } - ], - "js": [ - { - "pages": [ - "pages/index/index" - ], - "name": "default", - "window": { - "designWidth": 720, - "autoDesignWidth": false + ], + "deviceType": [ + "phone", + "tablet", + "tv", + "wearable" + ], + "reqPermissions": [ + { + "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.READ_MEDIA", + "reason" : "use ohos.permission.READ_MEDIA" } - } - ] + ], + "mainAbility": "ohos.acts.storage.filemanager.MainAbility", + "distro": { + "moduleType": "entry", + "installationFree": false, + "deliveryWithInstall": true, + "moduleName": "entry" + }, + "package": "ohos.acts.storage.filemanager", + "name": ".MyApplication", + "js": [ + { + "pages": [ + "pages/index/index" + ], + "name": "default", + "window": { + "designWidth": 720, + "autoDesignWidth": true + } + } + ] } } \ No newline at end of file diff --git a/storage/storagefilemanagerjstest/src/main/js/default/test/filemanager.test.js b/storage/storagefilemanagerjstest/src/main/js/default/test/filemanager.test.js index e2ad87d59cf496efbb7b362ecb9d1f0c5cbe37ed..4bb19a5197ba93608709c16f83adc7b8f447ba7c 100644 --- a/storage/storagefilemanagerjstest/src/main/js/default/test/filemanager.test.js +++ b/storage/storagefilemanagerjstest/src/main/js/default/test/filemanager.test.js @@ -14,12 +14,9 @@ */ import filemanager from '@ohos.filemanager'; -import { - describe, - it, - expect -} -from 'deccjsunit/index' +import {describe,it,expect,beforeAll}from 'deccjsunit/index'; +import abilityAccessCtrl from '@ohos.abilityAccessCtrl'; +import bundle from '@ohos.bundle'; // getRoot() interface, when the parameter is "local", the returned data and the data contrast, return the same data is correct const ROOTFILE = [ @@ -36,8 +33,19 @@ let AUDIO_ROOT = ""; let IMAGE_ALBUM = ""; let LOG_ = "FMS_XTS_TEXT: "; let LENGTH = 0; +let tokenID = null; describe("filemanager_test", function () { + beforeAll(async function (){ + let appInfo = await bundle.getApplicationInfo('ohos.acts.storage.filemanager', 0, 100); + tokenID = appInfo.accessTokenId; + let atManager = abilityAccessCtrl.createAtManager(); + let result = await atManager.grantUserGrantedPermission(tokenID, "ohos.permission.READ_MEDIA",1); + console.log("tokenID:" + tokenID + "-result:" + result); + let result1 = await atManager.verifyAccessToken(tokenID, "ohos.permission.READ_MEDIA"); + console.log("tokenID:" + tokenID + "-result:" + result1); + }); + /** * @tc.number SUB_DF_FILEMANAGER_GET_ROOT_0000 * @tc.name filemanager_test_get_root_async_000 @@ -172,7 +180,7 @@ describe("filemanager_test", function () { "name":1 } } - await filemanager.getRoot(options) + await filemanager.getRoot(options); } catch (error) { console.log("filemanager_test_get_root_async_004 has failed for " + error); expect(error.message == "GetRoot func get dev para fails").assertTrue(); @@ -194,7 +202,6 @@ describe("filemanager_test", function () { let path = IMAGE_ROOT; let fileInfos = await filemanager.listFile(path, "image"); expect(Array.isArray(fileInfos)).assertTrue(); - console.log(JSON.stringify(fileInfos)) for (let i = 0; i < fileInfos.length; i++) { if (fileInfos[i].name == "image") { console.log(JSON.stringify(fileInfos[i]))