diff --git a/aafwk/aafwk_standard/amszipfileunzipfilest/entry/src/main/js/test/ContextJsunit.test.js b/aafwk/aafwk_standard/amszipfileunzipfilest/entry/src/main/js/test/ContextJsunit.test.js index 904a969650e0871632dc4ebdc2020abb6a719107..4ac3fe3d6eae12ca6b855ea6960af18886e2963c 100644 --- a/aafwk/aafwk_standard/amszipfileunzipfilest/entry/src/main/js/test/ContextJsunit.test.js +++ b/aafwk/aafwk_standard/amszipfileunzipfilest/entry/src/main/js/test/ContextJsunit.test.js @@ -1892,4 +1892,49 @@ it('FWK_ZipFile_5100', 0, async function (done) { console.log("==================FWK_ZipFile_5100 end=================="); }) +/* +* @tc.number: FWK_ZipFile_5200 +* @tc.name: zipFile +* @tc.desc: strategy.COMPRESS_STRATEGY_FIXED +*/ +it('FWK_ZipFile_5200', 0, async function (done) { + console.log("==================FWK_ZipFile_5200 start=================="); + var src = "/data/test/ceshi.txt"; + var zipDest = "/data/testA/ceshi.zip"; + var unzipDir = "/data/testA/"; + var unzipDest = "/data/testA/ceshi.txt"; + + try{ + var options = {}; + options.strategy = zlib.CompressStrategy.COMPRESS_STRATEGY_FIXED, + await zlib.zipFile(src, zipDest, options, + (err, data) => { + var zipStat = fileio.statSync(zipDest); + var isFile = zipStat.isFile(); + expect(isFile).assertTrue(); + var srcSize = fileio.statSync(src).size; + var destSize = zipStat.size; + expect(srcSize>destSize).assertTrue(); + expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK); + + zlib.unzipFile(zipDest, unzipDir, options, + (err, data) => { + var unzipStat = fileio.statSync(unzipDest); + var isFile = unzipStat.isFile(); + expect(isFile).assertTrue(); + var destSize = unzipStat.size; + var originSize = fileio.statSync(src).size; + var result = (originSize == destSize); + expect(result).assertTrue(); + expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK); + done(); + }) + }); + } catch(err) { + console.error('FWK_ZipFile_5200 err:' + err); + done(); + } + console.log("==================FWK_ZipFile_5200 end=================="); +}) + }) diff --git a/appexecfwk/bundle_standard/bundlemanager/actsbmsgetinfostest/entry/src/main/js/test/ActsBmsFormsInfoTest.test.js b/appexecfwk/bundle_standard/bundlemanager/actsbmsgetinfostest/entry/src/main/js/test/ActsBmsFormsInfoTest.test.js index 256b04107ea8aa06d93796aefb9d0c78627254ac..65725fc0620cf1a716916e36a26c89aef37c9deb 100644 --- a/appexecfwk/bundle_standard/bundlemanager/actsbmsgetinfostest/entry/src/main/js/test/ActsBmsFormsInfoTest.test.js +++ b/appexecfwk/bundle_standard/bundlemanager/actsbmsgetinfostest/entry/src/main/js/test/ActsBmsFormsInfoTest.test.js @@ -1786,7 +1786,7 @@ describe('ActsBmsFormsInfoTest', function () { expect(typeof dataInfo.description).assertEqual('string'); expect(typeof dataInfo.descriptionId).assertEqual('number'); expect(typeof dataInfo.type).assertEqual('number'); - expect(typeof dataInfo.colorMode).assertEqual('number'); + expect(dataInfo.colorMode).assertEqual(bundle.ColorMode.LIGHT_MODE); expect(typeof dataInfo.defaultFlag).assertEqual('boolean'); expect(typeof dataInfo.jsComponentName).assertEqual('string'); expect(typeof dataInfo.formVisibleNotify).assertEqual('boolean'); diff --git a/appexecfwk/bundle_standard/bundlemanager/actsbmsgetinfostest/entry/src/main/js/test/ActsBmsQueryAbilityByWant.test.js b/appexecfwk/bundle_standard/bundlemanager/actsbmsgetinfostest/entry/src/main/js/test/ActsBmsQueryAbilityByWant.test.js index c5432fcbca5fb3a6a98efdead615322ba44c3843..86e5b204afc07c1525d7abab4e304920a058172c 100644 --- a/appexecfwk/bundle_standard/bundlemanager/actsbmsgetinfostest/entry/src/main/js/test/ActsBmsQueryAbilityByWant.test.js +++ b/appexecfwk/bundle_standard/bundlemanager/actsbmsgetinfostest/entry/src/main/js/test/ActsBmsQueryAbilityByWant.test.js @@ -39,7 +39,8 @@ describe('ActsBmsQueryAbilityByWant', function () { action: ['action.system.home'], entities: ['entity.system.home'], bundleName: BUNDLE_NAME1 - }, 132, 0, (err, data) => { + }, bundle.BundleFlag.GET_ABILITY_INFO_WITH_APPLICATION|bundle.BundleFlag.GET_ABILITY_INFO_SYSTEMAPP_ONLY, + 0, (err, data) => { if (err) { console.log('bms_queryAbilityByWant_0100 test query system app err is ' + err) expect(err).assertEqual(1); @@ -51,6 +52,9 @@ describe('ActsBmsQueryAbilityByWant', function () { isKeepData: false } , (err, data) => { + expect(err.code).assertEqual(0); + expect(data.status).assertEqual(0); + expect(data.statusMessage).assertEqual('SUCCESS'); done(); }); } @@ -78,8 +82,9 @@ describe('ActsBmsQueryAbilityByWant', function () { { action: ['action.system.home'], entities: ['entity.system.home'] - } - , 132, 0).then(data => { + }, + bundle.BundleFlag.GET_ABILITY_INFO_WITH_APPLICATION|bundle.BundleFlag.GET_ABILITY_INFO_SYSTEMAPP_ONLY, + 0).then(data => { for(let i = 0; i < data.length; ++i) { var jsondata = JSON.stringify(data[i]); console.log('bms_queryAbilityByWant_0200 test query system app ' + jsondata) @@ -89,6 +94,8 @@ describe('ActsBmsQueryAbilityByWant', function () { } ).catch(err => { console.log('bms_queryAbilityByWant_0200 test query system app err is ' + err) + expect(err).assertFail() + done(); }) }) diff --git a/appexecfwk/bundle_standard/bundlemanager/actsbundlemanagertest/entry/src/main/js/test/ExampleJsunit.test.js b/appexecfwk/bundle_standard/bundlemanager/actsbundlemanagertest/entry/src/main/js/test/ExampleJsunit.test.js index 1fa35037ed18f4571493cb63722477a41d3302e5..c51c64cfd0164878c357d2116557ce8ae6171e28 100644 --- a/appexecfwk/bundle_standard/bundlemanager/actsbundlemanagertest/entry/src/main/js/test/ExampleJsunit.test.js +++ b/appexecfwk/bundle_standard/bundlemanager/actsbundlemanagertest/entry/src/main/js/test/ExampleJsunit.test.js @@ -84,7 +84,8 @@ describe('ActsBundleManagerTest', function () { getInfo(); }); async function getInfo() { - var datainfo = await demo.getBundleInfo(NAME1, demo.BundleFlag.GET_BUNDLE_WITH_ABILITIES) + var datainfo = await demo.getBundleInfo(NAME1, + demo.BundleFlag.GET_BUNDLE_WITH_ABILITIES|demo.BundleFlag.GET_BUNDLE_WITH_REQUESTED_PERMISSION) expect(datainfo.name).assertEqual(NAME1) expect(datainfo.vendor).assertEqual("example") expect(datainfo.versionCode).assertEqual(VERSIONCODE1) @@ -100,8 +101,11 @@ describe('ActsBundleManagerTest', function () { expect(datainfo.appInfo.systemApp).assertEqual(true) expect(datainfo.appInfo.supportedModes).assertEqual(0) expect(datainfo.updateTime).assertLarger(0) - expect(datainfo.reqPermissions.length).assertEqual(0) - expect(datainfo.reqPermissionDetails.length).assertEqual(0) + expect(datainfo.reqPermissions[0]).assertEqual("com.permission.PERMISSION_A") + expect(datainfo.reqPermissionDetails[0].name).assertEqual("com.permission.PERMISSION_A") + expect(datainfo.reqPermissionDetails[0].reason).assertEqual("Need PERMISSION_A") + expect(datainfo.reqPermissionDetails[0].usedScene.abilities[0]).assertEqual(NAME1 + ".MainAbility") + expect(datainfo.reqPermissionDetails[0].usedScene.when).assertEqual("always") expect(datainfo.compatibleVersion).assertEqual(5) expect(datainfo.targetVersion).assertEqual(5) expect(datainfo.isCompressNativeLibs).assertEqual(false) @@ -455,7 +459,9 @@ describe('ActsBundleManagerTest', function () { getInfo(); }); async function getInfo() { - await demo.getApplicationInfo(NAME1, demo.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION, 0).then(datainfo => { + await demo.getApplicationInfo(NAME1, + demo.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION|demo.BundleFlag.GET_APPLICATION_INFO_WITH_METADATA, + 0).then(datainfo => { expect(typeof datainfo).assertEqual(OBJECT) console.info("getApplicationInfo success:" + JSON.stringify(datainfo)) expect(datainfo.moduleSourceDirs.length).assertLarger(0) @@ -472,6 +478,9 @@ describe('ActsBundleManagerTest', function () { expect(datainfo.process).assertEqual("") expect(datainfo.enabled).assertEqual(true) expect(datainfo.flags).assertEqual(0) + expect(datainfo.metaData.entry[0].name).assertEqual("metaDataName") + expect(datainfo.metaData.entry[0].value).assertEqual("metaDataValue") + expect(datainfo.metaData.entry[0].extra).assertEqual("$string:app_name") expect(datainfo.moduleSourceDirs.length).assertLarger(0) for (var j = 0; j < datainfo.moduleInfos; j++) { expect(datainfo.moduleInfos[j].moduleName).assertEqual("entry") @@ -2142,6 +2151,7 @@ describe('ActsBundleManagerTest', function () { expect(datainfo.moduleName).assertEqual("entry") expect(datainfo.bundleName).assertEqual(NAME1) expect(datainfo.type).assertEqual(1) + expect(datainfo.subType).assertEqual(demo.AbilitySubType.UNSPECIFIED) expect(datainfo.orientation).assertEqual(0) expect(datainfo.launchMode).assertEqual(demo.LaunchMode.STANDARD) expect(datainfo.permissions[0]).assertEqual("com.permission.BMS_PERMISSION_CAMERA") @@ -2245,60 +2255,92 @@ describe('ActsBundleManagerTest', function () { */ it('queryAbilityByWant_0300', 0, async function (done) { let installData = await demo.getBundleInstaller() - installData.install([PATH + BMSJSTEST4, PATH + BMSJSTEST5, PATH + BMSJSTEST6], { + installData.install([PATH + BMSJSTEST4], { userId: 0, installFlag: 0, isKeepData: false }, async (err, data) => { - expect(err.code).assertEqual(-1); - expect(data.status).assertEqual(3); - expect(data.statusMessage).assertEqual('STATUS_INSTALL_FAILURE_INVALID'); - getInfo(); + expect(data.status).assertEqual(0); + installData.install([PATH + BMSJSTEST5], { + userId: 0, + installFlag: 0, + isKeepData: false + }, async (err, data) => { + expect(data.status).assertEqual(0); + installData.install([PATH + BMSJSTEST6], { + userId: 0, + installFlag: 0, + isKeepData: false + }, async (err, data) => { + expect(data.status).assertEqual(0); + getInfo(); + }); + }); }); async function getInfo() { demo.queryAbilityByWant( { - "bundleName": "com.example.myapplication4", - "abilityName": "com.example.myapplication.MainAbility", + entities: ['entity.system.home','entitiesentities'] }, 4, 0).then(data => { + let queryResultCount = 0; for (let i = 0, len = data.length; i < len; i++) { var datainfo = data[i]; - expect(datainfo.name).assertEqual("com.example.myapplication.MainAbility") - expect(datainfo.label).assertEqual("$string:app_name") - expect(datainfo.description).assertEqual("$string:mainability_description") - expect(datainfo.icon).assertEqual("$media:icon") - expect(datainfo.moduleName).assertEqual("entry") - expect(datainfo.bundleName).assertEqual(NAME3) - expect(datainfo.applicationInfo.name).assertEqual(NAME3) - expect(datainfo.applicationInfo.description).assertEqual("$string:mainability_description") - expect(datainfo.applicationInfo.descriptionId >= 0).assertTrue() - expect(datainfo.applicationInfo.icon).assertEqual("$media:icon") - expect(datainfo.applicationInfo.iconId >= 0).assertTrue() - expect(datainfo.applicationInfo.label).assertEqual("$string:app_name") - expect(datainfo.applicationInfo.labelId >= 0).assertTrue() - expect(datainfo.applicationInfo.systemApp).assertEqual(true) - expect(datainfo.applicationInfo.supportedModes).assertEqual(0) - expect(datainfo.applicationInfo.enabled).assertEqual(true) - for (var j = 0; j < datainfo.applicationInfo.moduleInfos; j++) { - expect(datainfo.applicationInfo.moduleInfos[j].moduleName).assertEqual("entry") + if (datainfo.bundleName == NAME3){ + expect(datainfo.name).assertEqual("com.example.myapplication.MainAbility") + expect(datainfo.label).assertEqual("$string:app_name") + expect(datainfo.description).assertEqual("$string:mainability_description") + expect(datainfo.icon).assertEqual("$media:icon") + expect(datainfo.moduleName).assertEqual("entry") + expect(datainfo.bundleName).assertEqual(NAME3) + expect(datainfo.applicationInfo.name).assertEqual(NAME3) + expect(datainfo.applicationInfo.description).assertEqual("$string:mainability_description") + expect(datainfo.applicationInfo.descriptionId >= 0).assertTrue() + expect(datainfo.applicationInfo.icon).assertEqual("$media:icon") + expect(datainfo.applicationInfo.iconId >= 0).assertTrue() + expect(datainfo.applicationInfo.label).assertEqual("$string:app_name") + expect(datainfo.applicationInfo.labelId >= 0).assertTrue() + expect(datainfo.applicationInfo.systemApp).assertEqual(true) + expect(datainfo.applicationInfo.supportedModes).assertEqual(0) + expect(datainfo.orientation).assertEqual(2) + expect(datainfo.applicationInfo.enabled).assertEqual(true) + for (var j = 0; j < datainfo.applicationInfo.moduleInfos; j++) { + expect(datainfo.applicationInfo.moduleInfos[j].moduleName).assertEqual("entry") + } + queryResultCount++ + } + if (datainfo.bundleName == NAME4){ + expect(datainfo.name).assertEqual("com.example.myapplication.MainAbility") + expect(datainfo.bundleName).assertEqual(NAME4) + expect(datainfo.orientation).assertEqual(3) + queryResultCount++ + } + if (datainfo.bundleName == NAME5){ + expect(datainfo.name).assertEqual("com.example.myapplication.MainAbility") + expect(datainfo.bundleName).assertEqual(NAME5) + expect(datainfo.orientation).assertEqual(0) + queryResultCount++ } } + expect(queryResultCount).assertEqual(3) }) installData.uninstall(NAME3, { userId: 0, installFlag: 0, isKeepData: false }, (err, data) => { + expect(data.status).assertEqual(0); installData.uninstall(NAME4, { userId: 0, installFlag: 0, isKeepData: false }, (err, data) => { + expect(data.status).assertEqual(0); installData.uninstall(NAME5, { userId: 0, installFlag: 0, isKeepData: false }, (err, data) => { + expect(data.status).assertEqual(0); done(); }); }); diff --git a/appexecfwk/bundle_standard/bundlemanager/sceneProject/bmssceneone/src/main/config.json b/appexecfwk/bundle_standard/bundlemanager/sceneProject/bmssceneone/src/main/config.json index e1ae1bdcc8cf7b91d843a8cab044b5034df10d1f..bc5ac40ec870392187b152e457356bc8d5280743 100644 --- a/appexecfwk/bundle_standard/bundlemanager/sceneProject/bmssceneone/src/main/config.json +++ b/appexecfwk/bundle_standard/bundlemanager/sceneProject/bmssceneone/src/main/config.json @@ -77,7 +77,31 @@ "name": "com.permission.BMS_PERMISSION_CAMERA", "description": "BMS_PERMISSION_CAMERA permission in detail", "label": "BMS_PERMISSION_CAMERA permission" + }, + { + "name": "com.permission.PERMISSION_A", + "grantMode": "system_grant", + "availableScope": ["signature"] + } + ], + "reqPermissions": [ + { + "name": "com.permission.PERMISSION_A", + "reason": "Need PERMISSION_A", + "usedScene": { + "ability": [ + "com.example.myapplication1.MainAbility" + ], + "when": "always" + } } - ] + ], + "metaData":{ + "customizeData":[{ + "name":"metaDataName", + "value":"metaDataValue", + "extra":"$string:app_name" + }] + } } } \ No newline at end of file