diff --git a/bundlemanager/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/config.json b/bundlemanager/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/config.json index 0cf1741aecd6afa0b3ecbc8eda76df2ba0c223e0..5d435b45624ef84ed6c007c6e761bc41f6f06c7c 100644 --- a/bundlemanager/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/config.json +++ b/bundlemanager/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/config.json @@ -20,7 +20,7 @@ "mainAbility": "com.open.harmony.packagemag.MainAbility", "deviceType": [ "default", - "default" + "tablet" ], "reqPermissions": [ { @@ -52,6 +52,7 @@ } ], "visible": true, + "orientation": "unspecified", "srcPath": "MainAbility", "name": ".MainAbility", "srcLanguage": "ets", @@ -81,6 +82,28 @@ "srcLanguage": "ets", "description": "$string:description_serviceability", "type": "service" + }, + { + "name": ".DataAbility", + "srcLanguage": "ets", + "srcPath": "MainAbility", + "icon": "$media:icon", + "description": "$string:DataAbility_desc", + "type": "data", + "uri": "dataability://com.open.harmony.packagemag.DataAbility" + }, + { + "orientation": "followRecent", + "formsEnabled": false, + "name": ".FollowRecentAbility", + "srcLanguage": "ets", + "srcPath": "MainAbility", + "icon": "$media:icon", + "description": "$string:PageAbility1_desc", + "label": "$string:PageAbility1_label", + "type": "page", + "visible": true, + "launchType": "standard" } ], "js": [ diff --git a/bundlemanager/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/test/GetBundleInfoForSelf.test.ets b/bundlemanager/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/test/GetBundleInfoForSelf.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..1c31fb2af27129e86ac6880e58cca662f477ed8a --- /dev/null +++ b/bundlemanager/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/test/GetBundleInfoForSelf.test.ets @@ -0,0 +1,55 @@ +/** + * 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 impligetProfileByAbilityEmptyAbilityCalled. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import bundle from '@ohos.bundle.bundleManager'; +import util from "./Utils"; +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "hypium/index" + +export default function getBundleInfoForSelf() { + describe('getBundleInfoForSelf', function () { + + /* + * @tc.number: SUB_BMS_APPINFO_QUERY_0124 + * @tc.name: getBundleInfoForSelfAbilityPro + * @tc.desc: Test getBundleInfoForSelf with ability flag(by promise). + */ + it('getBundleInfoForSelfAbilityPro', 0, async function (done) { + await bundle.getBundleInfoForSelf( + bundle.BundleFlag.GET_BUNDLE_INFO_WITH_HAP_MODULE | bundle.BundleFlag.GET_BUNDLE_INFO_WITH_ABILITY + ).then(data => { + console.info("AbilityPro" + JSON.stringify(data.hapModulesInfo[0].abilitiesInfo[0])); + expect(data.hapModulesInfo[0].abilitiesInfo.length).assertEqual(5); + expect(data.hapModulesInfo[0].abilitiesInfo[0].type).assertEqual(bundle.AbilityType.DATA); + expect(data.hapModulesInfo[0].abilitiesInfo[0].orientation).assertEqual(bundle.DisplayOrientation.UNSPECIFIED); + expect(data.hapModulesInfo[0].abilitiesInfo[1].type).assertEqual(bundle.AbilityType.PAGE); + expect(data.hapModulesInfo[0].abilitiesInfo[1].orientation).assertEqual(bundle.DisplayOrientation.FOLLOW_RECENT); + expect(data.hapModulesInfo[0].abilitiesInfo[2].type).assertEqual(bundle.AbilityType.PAGE); + expect(data.hapModulesInfo[0].abilitiesInfo[2].orientation).assertEqual(bundle.DisplayOrientation.UNSPECIFIED); + expect(data.hapModulesInfo[0].abilitiesInfo[3].type).assertEqual(bundle.AbilityType.SERVICE); + expect(data.hapModulesInfo[0].abilitiesInfo[3].orientation).assertEqual(bundle.DisplayOrientation.UNSPECIFIED); + expect(data.hapModulesInfo[0].abilitiesInfo[4].type).assertEqual(bundle.AbilityType.PAGE); + expect(data.hapModulesInfo[0].abilitiesInfo[4].orientation).assertEqual(bundle.DisplayOrientation.UNSPECIFIED); + console.info("AbilityPro11" + JSON.stringify(data.hapModulesInfo[0].abilitiesInfo[0])); + done(); + }).catch(err => { + console.info("getBundleInfoForSelf fail" + JSON.stringify(err)); + expect(err).assertFail(); + done(); + }) + }) + + + }) +} \ No newline at end of file diff --git a/bundlemanager/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/test/List.test.ets b/bundlemanager/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/test/List.test.ets index 809d6f10171db39479f3d6c6dcccfde3400038f8..c4f4e6fe9aea259cc4415fbdc97df9d2158617f8 100644 --- a/bundlemanager/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/test/List.test.ets +++ b/bundlemanager/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/test/List.test.ets @@ -29,8 +29,10 @@ import getWindowPorperties from './getWindowProperties.test.ets'; import GetSecondModuleTest from './GetSecondModule.test.ets'; import GetInfoSync from './GetInfoSync.test.ets'; import GetResourceTest from './GetResourceTest.test.ets'; +import getBundleInfoForSelf from './GetBundleInfoForSelf.test.ets'; export default function testsuite() { + getBundleInfoForSelf(); getBundleArchiveInfo(); queryExtensionAbilityInfos(); getAbilityIcon(); diff --git a/bundlemanager/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/resources/base/element/string.json b/bundlemanager/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/resources/base/element/string.json index 3dd3c58496028df7163ebb7db29b5cad38e92488..d119a7113e39e0583e7e90bd4da9bf497b572534 100644 --- a/bundlemanager/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/resources/base/element/string.json +++ b/bundlemanager/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/resources/base/element/string.json @@ -27,6 +27,18 @@ { "name": "entry_description", "value": "entry_description" + }, + { + "name": "PageAbility1_desc", + "value": "description" + }, + { + "name": "PageAbility1_label", + "value": "label" + }, + { + "name": "DataAbility_desc", + "value": "hap sample empty provider" } ] } \ No newline at end of file diff --git a/bundlemanager/bundle_standard/bundlemanager/actsbundlemanagerstagetest/entry/src/main/ets/test/GetBundleInfoForSelf.test.ets b/bundlemanager/bundle_standard/bundlemanager/actsbundlemanagerstagetest/entry/src/main/ets/test/GetBundleInfoForSelf.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..6e32dc87d53a02db2db6193900d215805b78cc1b --- /dev/null +++ b/bundlemanager/bundle_standard/bundlemanager/actsbundlemanagerstagetest/entry/src/main/ets/test/GetBundleInfoForSelf.test.ets @@ -0,0 +1,1098 @@ +/** + * 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 impligetProfileByAbilityEmptyAbilityCalled. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import bundle from '@ohos.bundle.bundleManager'; +import util from "./Utils"; +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "@ohos/hypium" + +const BUNDLE_NAME = "ohos.acts.bundle.stage.test"; +const VENDOR = "huawei"; +const MODULE_NAME = "testModule"; +const SOURCE_DIR = "/data/app/el1/bundle/public/ohos.acts.bundle.stage.test/testModule"; +const ABILITY_NAME = "ohos.acts.bundle.stage.test.MainAbility"; +const ABILITY_NAME1 = "ohos.acts.bundle.stage.test.MainAbility1"; +const APPID = "ohos.acts.bundle.stage.test_BNtg4JBClbl92Rgc3jm/RfcAdrHXaM8F0QO" + +"iwVEhnV5ebE5jNIYnAx+weFRT3QTyUjRNdhmc2aAzWyi+5t5CoBM="; +const FINGERPRINT = "8E93863FC32EE238060BF69A9B37E2608FFFB21F93C862DD511CBAC9F30024B5"; +const PARAM_ERROR_CODE = 401; + +export default function getBundleInfoForSelf() { + describe('getBundleInfoForSelf', function () { + /* + * @tc.number: SUB_BMS_APPINFO_QUERY_0118 + * @tc.name: getBundleInfoForSelfPro + * @tc.desc: Test getBundleInfoForSelf with default flag(by promise). + */ + it('getBundleInfoForSelfPro', 0, async function (done) { + await bundle.getBundleInfoForSelf(bundle.BundleFlag.GET_BUNDLE_INFO_DEFAULT).then(data => { + console.info("getBundleInfoForSelfPro" + JSON.stringify(data)); + expect(data.name).assertEqual(BUNDLE_NAME); + expect(data.vendor).assertEqual(VENDOR); + expect(data.versionCode).assertEqual(1000000); + expect(data.versionName).assertEqual("1.0.0"); + expect(data.minCompatibleVersionCode).assertEqual(1000000); + expect(data.targetVersion).assertEqual(8); + expect(data.installTime).assertLarger(0); + expect(data.updateTime).assertLarger(0); + expect(data.appInfo).assertEqual(null); + expect(data.hapModulesInfo.length).assertEqual(0); + expect(data.reqPermissionDetails.length).assertEqual(0); + expect(data.permissionGrantStates.length).assertEqual(0); + expect(data.signatureInfo).assertEqual(null); + done(); + }).catch(err => { + console.info("getBundleInfoForSelf fail" + JSON.stringify(err)); + expect(err).assertFail(); + done(); + }) + }) + + /* + * @tc.number: SUB_BMS_APPINFO_QUERY_0119 + * @tc.name: getBundleInfoForSelfCal + * @tc.desc: Test getBundleInfoForSelf with default flag(by callback). + */ + it('getBundleInfoForSelfCal', 0, async function (done) { + bundle.getBundleInfoForSelf(bundle.BundleFlag.GET_BUNDLE_INFO_DEFAULT, (err, data) => { + console.info("getBundleInfoForSelfCal" + JSON.stringify(data)); + expect(data.name).assertEqual(BUNDLE_NAME); + expect(data.vendor).assertEqual(VENDOR); + expect(data.versionCode).assertEqual(1000000); + expect(data.versionName).assertEqual("1.0.0"); + expect(data.minCompatibleVersionCode).assertEqual(1000000); + expect(data.targetVersion).assertEqual(8); + expect(data.installTime).assertLarger(0); + expect(data.updateTime).assertLarger(0); + expect(data.appInfo).assertEqual(null); + expect(data.hapModulesInfo.length).assertEqual(0); + expect(data.reqPermissionDetails.length).assertEqual(0); + expect(data.permissionGrantStates.length).assertEqual(0); + expect(data.signatureInfo).assertEqual(null); + expect(err).assertEqual(null); + done(); + }) + }) + + /* + * @tc.number: SUB_BMS_APPINFO_QUERY_0120 + * @tc.name: getBundleInfoForSelfApplicationPro + * @tc.desc: Test getBundleInfoForSelf with application flag(by promise). + */ + it('getBundleInfoForSelfApplicationPro', 0, async function (done) { + await bundle.getBundleInfoForSelf(bundle.BundleFlag.GET_BUNDLE_INFO_WITH_APPLICATION).then(data => { + console.info("getBundleInfoForSelfApplicationPro" + JSON.stringify(data.appInfo)); + checkCommonBundleInfo(data); + expect(data.appInfo.name).assertEqual(BUNDLE_NAME); + expect(data.appInfo.description).assertEqual("$string:description_application"); + expect(data.appInfo.descriptionId).assertLarger(0); + expect(data.appInfo.enabled).assertTrue(); + expect(data.appInfo.label).assertEqual("$string:app_name"); + expect(data.appInfo.labelId).assertLarger(0); + expect(data.appInfo.icon).assertEqual("$media:icon"); + expect(data.appInfo.iconId).assertLarger(0); + expect(data.appInfo.process).assertEqual(BUNDLE_NAME); + expect(data.appInfo.entryDir).assertEqual(SOURCE_DIR); + expect(data.appInfo.codePath).assertEqual("/data/app/el1/bundle/public/ohos.acts.bundle.stage.test"); + expect(data.appInfo.removable).assertTrue(0); + expect(data.appInfo.accessTokenId).assertLarger(0); + expect(data.appInfo.uid).assertLarger(0); + expect(data.appInfo.iconResource.bundleName).assertEqual(BUNDLE_NAME); + expect(data.appInfo.iconResource.moduleName).assertEqual("testModule"); + expect(data.appInfo.iconResource.id).assertEqual(data.appInfo.iconId); + expect(data.appInfo.labelResource.bundleName).assertEqual(BUNDLE_NAME); + expect(data.appInfo.labelResource.moduleName).assertEqual("testModule"); + expect(data.appInfo.labelResource.id).assertEqual(data.appInfo.labelId); + expect(data.appInfo.descriptionResource.bundleName).assertEqual(BUNDLE_NAME); + expect(data.appInfo.descriptionResource.moduleName).assertEqual("testModule"); + expect(data.appInfo.descriptionResource.id).assertEqual(data.appInfo.descriptionId); + expect(data.appInfo.appDistributionType).assertEqual("os_integration"); + expect(data.appInfo.appProvisionType).assertEqual("release"); + expect(data.appInfo.permissions.length).assertEqual(0); + expect(JSON.stringify(data.appInfo.metadata)).assertEqual("{}"); + expect(data.hapModulesInfo.length).assertEqual(0); + expect(data.reqPermissionDetails.length).assertEqual(0); + expect(data.permissionGrantStates.length).assertEqual(0); + expect(data.signatureInfo).assertEqual(null); + done(); + }).catch(err => { + console.info("getBundleInfoForSelf fail" + JSON.stringify(err)); + expect(err).assertFail(); + done(); + }) + }) + + /* + * @tc.number: SUB_BMS_APPINFO_QUERY_0121 + * @tc.name: getBundleInfoForSelfApplicationCal + * @tc.desc: Test getBundleInfoForSelf with application flag(by callback). + */ + it('getBundleInfoForSelfApplicationCal', 0, async function (done) { + bundle.getBundleInfoForSelf(bundle.BundleFlag.GET_BUNDLE_INFO_WITH_APPLICATION, (err, data) => { + console.info("ApplicationCal" + JSON.stringify(data.appInfo)); + for (let i in data.appInfo) { + console.info("name" + JSON.stringify(i)); + console.info("name" + JSON.stringify(data.appInfo[i])); + } + checkCommonBundleInfo(data); + expect(data.appInfo.name).assertEqual(BUNDLE_NAME); + expect(data.appInfo.description).assertEqual("$string:description_application"); + expect(data.appInfo.descriptionId).assertLarger(0); + expect(data.appInfo.enabled).assertTrue(); + expect(data.appInfo.label).assertEqual("$string:app_name"); + expect(data.appInfo.labelId).assertLarger(0); + expect(data.appInfo.icon).assertEqual("$media:icon"); + expect(data.appInfo.iconId).assertLarger(0); + expect(data.appInfo.process).assertEqual(BUNDLE_NAME); + expect(data.appInfo.entryDir).assertEqual(SOURCE_DIR); + expect(data.appInfo.codePath).assertEqual("/data/app/el1/bundle/public/ohos.acts.bundle.stage.test"); + expect(data.appInfo.removable).assertTrue(0); + expect(data.appInfo.accessTokenId).assertLarger(0); + expect(data.appInfo.uid).assertLarger(0); + expect(data.appInfo.iconResource.bundleName).assertEqual(BUNDLE_NAME); + expect(data.appInfo.iconResource.moduleName).assertEqual("testModule"); + expect(data.appInfo.iconResource.id).assertEqual(data.appInfo.iconId); + expect(data.appInfo.labelResource.bundleName).assertEqual(BUNDLE_NAME); + expect(data.appInfo.labelResource.moduleName).assertEqual("testModule"); + expect(data.appInfo.labelResource.id).assertEqual(data.appInfo.labelId); + expect(data.appInfo.descriptionResource.bundleName).assertEqual(BUNDLE_NAME); + expect(data.appInfo.descriptionResource.moduleName).assertEqual("testModule"); + expect(data.appInfo.descriptionResource.id).assertEqual(data.appInfo.descriptionId); + expect(data.appInfo.appDistributionType).assertEqual("os_integration"); + expect(data.appInfo.appProvisionType).assertEqual("release"); + expect(data.appInfo.permissions.length).assertEqual(0); + expect(JSON.stringify(data.appInfo.metadata)).assertEqual("{}"); + expect(data.hapModulesInfo.length).assertEqual(0); + expect(data.reqPermissionDetails.length).assertEqual(0); + expect(data.permissionGrantStates.length).assertEqual(0); + expect(data.signatureInfo).assertEqual(null); + expect(err).assertEqual(null); + done(); + }) + }) + + /* + * @tc.number: SUB_BMS_APPINFO_QUERY_0122 + * @tc.name: getBundleInfoForSelfModulePro + * @tc.desc: Test getBundleInfoForSelf with hapModuleInfo flag(by promise). + */ + it('getBundleInfoForSelfModulePro', 0, async function (done) { + await bundle.getBundleInfoForSelf(bundle.BundleFlag.GET_BUNDLE_INFO_WITH_HAP_MODULE).then(data => { + console.info("ModulePro" + JSON.stringify(data.hapModulesInfo[0])); + checkCommonBundleInfo(data); + expect(data.appInfo).assertEqual(null); + expect(data.hapModulesInfo.length).assertEqual(1); + expect(data.hapModulesInfo[0].name).assertEqual("testModule"); + expect(data.hapModulesInfo[0].icon).assertEqual("$media:icon"); + expect(data.hapModulesInfo[0].iconId).assertLarger(0); + expect(data.hapModulesInfo[0].label).assertEqual("$string:entry_label"); + expect(data.hapModulesInfo[0].labelId).assertLarger(0); + expect(data.hapModulesInfo[0].description).assertEqual("$string:testModule_entry_dsc"); + expect(data.hapModulesInfo[0].descriptionId).assertLarger(0); + expect(data.hapModulesInfo[0].mainElementName).assertEqual(ABILITY_NAME); + expect(data.hapModulesInfo[0].abilitiesInfo.length).assertEqual(0); + expect(data.hapModulesInfo[0].extensionAbilitiesInfo.length).assertEqual(0); + expect(data.hapModulesInfo[0].metadata.length).assertEqual(0); + expect(data.hapModulesInfo[0].deviceTypes.length).assertEqual(2); + expect(data.hapModulesInfo[0].deviceTypes[0]).assertEqual("default"); + expect(data.hapModulesInfo[0].deviceTypes[1]).assertEqual("tablet"); + expect(data.hapModulesInfo[0].installationFree).assertFalse(); + expect(data.hapModulesInfo[0].hashValue).assertEqual(""); + expect(data.hapModulesInfo[0].moduleSourceDir).assertEqual(SOURCE_DIR); + expect(data.reqPermissionDetails.length).assertEqual(0); + expect(data.permissionGrantStates.length).assertEqual(0); + expect(data.signatureInfo).assertEqual(null); + done(); + }).catch(err => { + console.info("getBundleInfoForSelf fail" + JSON.stringify(err)); + expect(err).assertFail(); + done(); + }) + }) + + /* + * @tc.number: SUB_BMS_APPINFO_QUERY_0123 + * @tc.name: getBundleInfoForSelfModuleCal + * @tc.desc: Test getBundleInfoForSelf with hapModuleInfo flag(by callback). + */ + it('getBundleInfoForSelfModuleCal', 0, async function (done) { + bundle.getBundleInfoForSelf(bundle.BundleFlag.GET_BUNDLE_INFO_WITH_HAP_MODULE, (err, data) => { + console.info("getBundleInfoForSelfPro" + JSON.stringify(data.hapModulesInfo)); + checkCommonBundleInfo(data); + expect(data.appInfo).assertEqual(null); + expect(data.hapModulesInfo.length).assertEqual(1); + expect(data.hapModulesInfo[0].name).assertEqual("testModule"); + expect(data.hapModulesInfo[0].icon).assertEqual("$media:icon"); + expect(data.hapModulesInfo[0].iconId).assertLarger(0); + expect(data.hapModulesInfo[0].label).assertEqual("$string:entry_label"); + expect(data.hapModulesInfo[0].labelId).assertLarger(0); + expect(data.hapModulesInfo[0].description).assertEqual("$string:testModule_entry_dsc"); + expect(data.hapModulesInfo[0].descriptionId).assertLarger(0); + expect(data.hapModulesInfo[0].mainElementName).assertEqual(ABILITY_NAME); + expect(data.hapModulesInfo[0].abilitiesInfo.length).assertEqual(0); + expect(data.hapModulesInfo[0].extensionAbilitiesInfo.length).assertEqual(0); + expect(data.hapModulesInfo[0].metadata.length).assertEqual(0); + expect(data.hapModulesInfo[0].deviceTypes.length).assertEqual(2); + expect(data.hapModulesInfo[0].deviceTypes[0]).assertEqual("default"); + expect(data.hapModulesInfo[0].deviceTypes[1]).assertEqual("tablet"); + expect(data.hapModulesInfo[0].installationFree).assertFalse(); + expect(data.hapModulesInfo[0].hashValue).assertEqual(""); + expect(data.hapModulesInfo[0].moduleSourceDir).assertEqual(SOURCE_DIR); + expect(data.reqPermissionDetails.length).assertEqual(0); + expect(data.permissionGrantStates.length).assertEqual(0); + expect(data.signatureInfo).assertEqual(null); + expect(err).assertEqual(null); + done(); + }) + }) + + /* + * @tc.number: SUB_BMS_APPINFO_QUERY_0124 + * @tc.name: getBundleInfoForSelfAbilityPro + * @tc.desc: Test getBundleInfoForSelf with ability flag(by promise). + */ + it('getBundleInfoForSelfAbilityPro', 0, async function (done) { + await bundle.getBundleInfoForSelf( + bundle.BundleFlag.GET_BUNDLE_INFO_WITH_HAP_MODULE | bundle.BundleFlag.GET_BUNDLE_INFO_WITH_ABILITY + ).then(data => { + for (let count = 0; count < 11; count++) { + console.info(count + "AbilityPro::" + JSON.stringify(data.hapModulesInfo[0].abilitiesInfo[count])); + } + checkCommonBundleInfo(data); + checkCommonHapModuleInfo(data); + expect(data.appInfo).assertEqual(null); + expect(data.hapModulesInfo[0].abilitiesInfo.length).assertEqual(11); + expect(data.hapModulesInfo[0].abilitiesInfo[0].bundleName).assertEqual(BUNDLE_NAME); + expect(data.hapModulesInfo[0].abilitiesInfo[0].moduleName).assertEqual("testModule"); + expect(data.hapModulesInfo[0].abilitiesInfo[0].name).assertEqual("ohos.acts.bundle.stage.test.MainAbility"); + expect(data.hapModulesInfo[0].abilitiesInfo[0].label).assertEqual("$string:entry_label"); + expect(data.hapModulesInfo[0].abilitiesInfo[0].labelId).assertLarger(0); + expect(data.hapModulesInfo[0].abilitiesInfo[0].description).assertEqual("$string:testModule_entry_main"); + expect(data.hapModulesInfo[0].abilitiesInfo[0].descriptionId).assertLarger(0); + expect(data.hapModulesInfo[0].abilitiesInfo[0].icon).assertEqual("$media:icon"); + expect(data.hapModulesInfo[0].abilitiesInfo[0].iconId).assertLarger(0); + expect(data.hapModulesInfo[0].abilitiesInfo[0].process).assertEqual(""); + expect(data.hapModulesInfo[0].abilitiesInfo[0].isVisible).assertTrue(); + expect(data.hapModulesInfo[0].abilitiesInfo[0].type).assertEqual(1); + expect(data.hapModulesInfo[0].abilitiesInfo[0].orientation).assertEqual(bundle.DisplayOrientation.PORTRAIT); + expect(data.hapModulesInfo[0].abilitiesInfo[0].launchType).assertEqual(bundle.LaunchType.SINGLETON); + expect(data.hapModulesInfo[0].abilitiesInfo[0].permissions.length).assertEqual(0); + expect(data.hapModulesInfo[0].abilitiesInfo[0].readPermission).assertEqual(""); + expect(data.hapModulesInfo[0].abilitiesInfo[0].writePermission).assertEqual(""); + expect(data.hapModulesInfo[0].abilitiesInfo[0].uri).assertEqual(""); + expect(data.hapModulesInfo[0].abilitiesInfo[0].deviceTypes.length).assertEqual(2); + console.info("AbilityPro" + JSON.stringify(data.hapModulesInfo[0].abilitiesInfo[0].deviceTypes[0])); + console.info("AbilityPro" + JSON.stringify(data.hapModulesInfo[0].abilitiesInfo[0].deviceTypes[1])); + expect(data.hapModulesInfo[0].abilitiesInfo[0].deviceTypes[0]).assertEqual("default"); + expect(data.hapModulesInfo[0].abilitiesInfo[0].deviceTypes[1]).assertEqual("tablet"); + expect(data.hapModulesInfo[0].abilitiesInfo[0].applicationInfo).assertEqual(null); + expect(data.hapModulesInfo[0].abilitiesInfo[0].metadata.length).assertEqual(0); + expect(data.hapModulesInfo[0].abilitiesInfo[0].enabled).assertTrue(); + expect(data.hapModulesInfo[0].abilitiesInfo[0].supportWindowModes.length).assertEqual(3); + expect(data.hapModulesInfo[0].abilitiesInfo[0].supportWindowModes[0]) + .assertEqual(bundle.SupportWindowMode.FULL_SCREEN); + expect(data.hapModulesInfo[0].abilitiesInfo[0].supportWindowModes[1]) + .assertEqual(bundle.SupportWindowMode.SPLIT); + expect(data.hapModulesInfo[0].abilitiesInfo[0].supportWindowModes[2]) + .assertEqual(bundle.SupportWindowMode.FLOATING); + expect(data.hapModulesInfo[0].abilitiesInfo[0].windowSize.maxWindowRatio).assertEqual(0); + expect(data.hapModulesInfo[0].abilitiesInfo[0].windowSize.minWindowRatio).assertEqual(0); + expect(data.hapModulesInfo[0].abilitiesInfo[0].windowSize.maxWindowWidth).assertEqual(0); + expect(data.hapModulesInfo[0].abilitiesInfo[0].windowSize.minWindowWidth).assertEqual(0); + expect(data.hapModulesInfo[0].abilitiesInfo[0].windowSize.maxWindowHeight).assertEqual(0); + expect(data.hapModulesInfo[0].abilitiesInfo[0].windowSize.minWindowHeight).assertEqual(0); + expect(data.hapModulesInfo[0].abilitiesInfo[1].name).assertEqual("ohos.acts.bundle.stage.test.MainAbility1"); + expect(data.hapModulesInfo[0].abilitiesInfo[1].launchType).assertEqual(bundle.LaunchType.STANDARD); + expect(data.hapModulesInfo[0].abilitiesInfo[1].orientation).assertEqual(bundle.DisplayOrientation.LANDSCAPE); + expect(data.hapModulesInfo[0].abilitiesInfo[2].name).assertEqual("ohos.acts.bundle.stage.test.MainAbility10"); + expect(data.hapModulesInfo[0].abilitiesInfo[2].orientation).assertEqual(bundle.DisplayOrientation.LOCKED); + expect(data.hapModulesInfo[0].abilitiesInfo[3].name).assertEqual("ohos.acts.bundle.stage.test.MainAbility2"); + expect(data.hapModulesInfo[0].abilitiesInfo[3].launchType).assertEqual(bundle.LaunchType.SPECIFIED); + expect(data.hapModulesInfo[0].abilitiesInfo[3].orientation) + .assertEqual(bundle.DisplayOrientation.LANDSCAPE_INVERTED); + expect(data.hapModulesInfo[0].abilitiesInfo[4].name).assertEqual("ohos.acts.bundle.stage.test.MainAbility3"); + expect(data.hapModulesInfo[0].abilitiesInfo[4].orientation) + .assertEqual(bundle.DisplayOrientation.PORTRAIT_INVERTED); + expect(data.hapModulesInfo[0].abilitiesInfo[5].name).assertEqual("ohos.acts.bundle.stage.test.MainAbility4"); + expect(data.hapModulesInfo[0].abilitiesInfo[5].orientation) + .assertEqual(bundle.DisplayOrientation.AUTO_ROTATION); + expect(data.hapModulesInfo[0].abilitiesInfo[6].name).assertEqual("ohos.acts.bundle.stage.test.MainAbility5"); + expect(data.hapModulesInfo[0].abilitiesInfo[6].orientation) + .assertEqual(bundle.DisplayOrientation.AUTO_ROTATION_LANDSCAPE); + expect(data.hapModulesInfo[0].abilitiesInfo[7].name).assertEqual("ohos.acts.bundle.stage.test.MainAbility6"); + expect(data.hapModulesInfo[0].abilitiesInfo[7].orientation) + .assertEqual(bundle.DisplayOrientation.AUTO_ROTATION_PORTRAIT); + expect(data.hapModulesInfo[0].abilitiesInfo[8].name).assertEqual("ohos.acts.bundle.stage.test.MainAbility7"); + expect(data.hapModulesInfo[0].abilitiesInfo[8].orientation) + .assertEqual(bundle.DisplayOrientation.AUTO_ROTATION_RESTRICTED); + expect(data.hapModulesInfo[0].abilitiesInfo[9].name).assertEqual("ohos.acts.bundle.stage.test.MainAbility8"); + expect(data.hapModulesInfo[0].abilitiesInfo[9].orientation) + .assertEqual(bundle.DisplayOrientation.AUTO_ROTATION_LANDSCAPE_RESTRICTED); + expect(data.hapModulesInfo[0].abilitiesInfo[10].name).assertEqual("ohos.acts.bundle.stage.test.MainAbility9"); + expect(data.hapModulesInfo[0].abilitiesInfo[10].orientation) + .assertEqual(bundle.DisplayOrientation.AUTO_ROTATION_PORTRAIT_RESTRICTED); + checkCommonAbilityInfo(data.hapModulesInfo[0].abilitiesInfo[1]) + checkCommonAbilityInfo(data.hapModulesInfo[0].abilitiesInfo[2]) + checkCommonAbilityInfo(data.hapModulesInfo[0].abilitiesInfo[3]) + checkCommonAbilityInfo(data.hapModulesInfo[0].abilitiesInfo[4]) + checkCommonAbilityInfo(data.hapModulesInfo[0].abilitiesInfo[5]) + checkCommonAbilityInfo(data.hapModulesInfo[0].abilitiesInfo[6]) + checkCommonAbilityInfo(data.hapModulesInfo[0].abilitiesInfo[7]) + checkCommonAbilityInfo(data.hapModulesInfo[0].abilitiesInfo[8]) + checkCommonAbilityInfo(data.hapModulesInfo[0].abilitiesInfo[9]) + checkCommonAbilityInfo(data.hapModulesInfo[0].abilitiesInfo[10]) + expect(data.hapModulesInfo[0].extensionAbilitiesInfo.length).assertEqual(0); + expect(data.hapModulesInfo[0].metadata.length).assertEqual(0); + expect(data.reqPermissionDetails.length).assertEqual(0); + expect(data.permissionGrantStates.length).assertEqual(0); + expect(data.signatureInfo).assertEqual(null); + done(); + }).catch(err => { + console.info("getBundleInfoForSelf fail" + JSON.stringify(err)); + expect(err).assertFail(); + done(); + }) + }) + + /* + * @tc.number: SUB_BMS_APPINFO_QUERY_0125 + * @tc.name: getBundleInfoForSelfAbilityCal + * @tc.desc: Test getBundleInfoForSelf with ability flag(by callback). + */ + it('getBundleInfoForSelfAbilityCal', 0, async function (done) { + bundle.getBundleInfoForSelf( + bundle.BundleFlag.GET_BUNDLE_INFO_WITH_HAP_MODULE | bundle.BundleFlag.GET_BUNDLE_INFO_WITH_ABILITY, + (err, data) => { + console.info("AbilityCal" + JSON.stringify(data.hapModulesInfo[0].abilitiesInfo[0])); + checkCommonBundleInfo(data); + checkCommonHapModuleInfo(data); + expect(data.appInfo).assertEqual(null); + expect(data.hapModulesInfo[0].abilitiesInfo.length).assertEqual(11); + expect(data.hapModulesInfo[0].abilitiesInfo[0].bundleName).assertEqual(BUNDLE_NAME); + expect(data.hapModulesInfo[0].abilitiesInfo[0].moduleName).assertEqual("testModule"); + expect(data.hapModulesInfo[0].abilitiesInfo[0].name).assertEqual("ohos.acts.bundle.stage.test.MainAbility"); + expect(data.hapModulesInfo[0].abilitiesInfo[0].label).assertEqual("$string:entry_label"); + expect(data.hapModulesInfo[0].abilitiesInfo[0].labelId).assertLarger(0); + expect(data.hapModulesInfo[0].abilitiesInfo[0].description).assertEqual("$string:testModule_entry_main"); + expect(data.hapModulesInfo[0].abilitiesInfo[0].descriptionId).assertLarger(0); + expect(data.hapModulesInfo[0].abilitiesInfo[0].icon).assertEqual("$media:icon"); + expect(data.hapModulesInfo[0].abilitiesInfo[0].iconId).assertLarger(0); + expect(data.hapModulesInfo[0].abilitiesInfo[0].process).assertEqual(""); + expect(data.hapModulesInfo[0].abilitiesInfo[0].isVisible).assertTrue(); + expect(data.hapModulesInfo[0].abilitiesInfo[0].type).assertEqual(1); + expect(data.hapModulesInfo[0].abilitiesInfo[0].orientation).assertEqual(bundle.DisplayOrientation.PORTRAIT); + expect(data.hapModulesInfo[0].abilitiesInfo[0].launchType).assertEqual(bundle.LaunchType.SINGLETON); + expect(data.hapModulesInfo[0].abilitiesInfo[0].permissions.length).assertEqual(0); + expect(data.hapModulesInfo[0].abilitiesInfo[0].readPermission).assertEqual(""); + expect(data.hapModulesInfo[0].abilitiesInfo[0].writePermission).assertEqual(""); + expect(data.hapModulesInfo[0].abilitiesInfo[0].uri).assertEqual(""); + expect(data.hapModulesInfo[0].abilitiesInfo[0].deviceTypes.length).assertEqual(2); + console.info("AbilityPro" + JSON.stringify(data.hapModulesInfo[0].abilitiesInfo[0].deviceTypes[0])); + console.info("AbilityPro" + JSON.stringify(data.hapModulesInfo[0].abilitiesInfo[0].deviceTypes[1])); + expect(data.hapModulesInfo[0].abilitiesInfo[0].deviceTypes[0]).assertEqual("default"); + expect(data.hapModulesInfo[0].abilitiesInfo[0].deviceTypes[1]).assertEqual("tablet"); + expect(data.hapModulesInfo[0].abilitiesInfo[0].applicationInfo).assertEqual(null); + expect(data.hapModulesInfo[0].abilitiesInfo[0].metadata.length).assertEqual(0); + expect(data.hapModulesInfo[0].abilitiesInfo[0].enabled).assertTrue(); + expect(data.hapModulesInfo[0].abilitiesInfo[0].supportWindowModes.length).assertEqual(3); + expect(data.hapModulesInfo[0].abilitiesInfo[0].supportWindowModes[0]) + .assertEqual(bundle.SupportWindowMode.FULL_SCREEN); + expect(data.hapModulesInfo[0].abilitiesInfo[0].supportWindowModes[1]) + .assertEqual(bundle.SupportWindowMode.SPLIT); + expect(data.hapModulesInfo[0].abilitiesInfo[0].supportWindowModes[2]) + .assertEqual(bundle.SupportWindowMode.FLOATING); + expect(data.hapModulesInfo[0].abilitiesInfo[0].windowSize.maxWindowRatio).assertEqual(0); + expect(data.hapModulesInfo[0].abilitiesInfo[0].windowSize.minWindowRatio).assertEqual(0); + expect(data.hapModulesInfo[0].abilitiesInfo[0].windowSize.maxWindowWidth).assertEqual(0); + expect(data.hapModulesInfo[0].abilitiesInfo[0].windowSize.minWindowWidth).assertEqual(0); + expect(data.hapModulesInfo[0].abilitiesInfo[0].windowSize.maxWindowHeight).assertEqual(0); + expect(data.hapModulesInfo[0].abilitiesInfo[0].windowSize.minWindowHeight).assertEqual(0); + expect(data.hapModulesInfo[0].abilitiesInfo[1].name).assertEqual("ohos.acts.bundle.stage.test.MainAbility1"); + expect(data.hapModulesInfo[0].abilitiesInfo[1].launchType).assertEqual(bundle.LaunchType.STANDARD); + expect(data.hapModulesInfo[0].abilitiesInfo[1].orientation).assertEqual(bundle.DisplayOrientation.LANDSCAPE); + expect(data.hapModulesInfo[0].abilitiesInfo[2].name).assertEqual("ohos.acts.bundle.stage.test.MainAbility10"); + expect(data.hapModulesInfo[0].abilitiesInfo[2].orientation).assertEqual(bundle.DisplayOrientation.LOCKED); + expect(data.hapModulesInfo[0].abilitiesInfo[3].name).assertEqual("ohos.acts.bundle.stage.test.MainAbility2"); + expect(data.hapModulesInfo[0].abilitiesInfo[3].launchType).assertEqual(bundle.LaunchType.SPECIFIED); + expect(data.hapModulesInfo[0].abilitiesInfo[3].orientation) + .assertEqual(bundle.DisplayOrientation.LANDSCAPE_INVERTED); + expect(data.hapModulesInfo[0].abilitiesInfo[4].name).assertEqual("ohos.acts.bundle.stage.test.MainAbility3"); + expect(data.hapModulesInfo[0].abilitiesInfo[4].orientation) + .assertEqual(bundle.DisplayOrientation.PORTRAIT_INVERTED); + expect(data.hapModulesInfo[0].abilitiesInfo[5].name).assertEqual("ohos.acts.bundle.stage.test.MainAbility4"); + expect(data.hapModulesInfo[0].abilitiesInfo[5].orientation) + .assertEqual(bundle.DisplayOrientation.AUTO_ROTATION); + expect(data.hapModulesInfo[0].abilitiesInfo[6].name).assertEqual("ohos.acts.bundle.stage.test.MainAbility5"); + expect(data.hapModulesInfo[0].abilitiesInfo[6].orientation) + .assertEqual(bundle.DisplayOrientation.AUTO_ROTATION_LANDSCAPE); + expect(data.hapModulesInfo[0].abilitiesInfo[7].name).assertEqual("ohos.acts.bundle.stage.test.MainAbility6"); + expect(data.hapModulesInfo[0].abilitiesInfo[7].orientation) + .assertEqual(bundle.DisplayOrientation.AUTO_ROTATION_PORTRAIT); + expect(data.hapModulesInfo[0].abilitiesInfo[8].name).assertEqual("ohos.acts.bundle.stage.test.MainAbility7"); + expect(data.hapModulesInfo[0].abilitiesInfo[8].orientation) + .assertEqual(bundle.DisplayOrientation.AUTO_ROTATION_RESTRICTED); + expect(data.hapModulesInfo[0].abilitiesInfo[9].name).assertEqual("ohos.acts.bundle.stage.test.MainAbility8"); + expect(data.hapModulesInfo[0].abilitiesInfo[9].orientation) + .assertEqual(bundle.DisplayOrientation.AUTO_ROTATION_LANDSCAPE_RESTRICTED); + expect(data.hapModulesInfo[0].abilitiesInfo[10].name).assertEqual("ohos.acts.bundle.stage.test.MainAbility9"); + expect(data.hapModulesInfo[0].abilitiesInfo[10].orientation) + .assertEqual(bundle.DisplayOrientation.AUTO_ROTATION_PORTRAIT_RESTRICTED); + checkCommonAbilityInfo(data.hapModulesInfo[0].abilitiesInfo[1]) + checkCommonAbilityInfo(data.hapModulesInfo[0].abilitiesInfo[2]) + checkCommonAbilityInfo(data.hapModulesInfo[0].abilitiesInfo[3]) + checkCommonAbilityInfo(data.hapModulesInfo[0].abilitiesInfo[4]) + checkCommonAbilityInfo(data.hapModulesInfo[0].abilitiesInfo[5]) + checkCommonAbilityInfo(data.hapModulesInfo[0].abilitiesInfo[6]) + checkCommonAbilityInfo(data.hapModulesInfo[0].abilitiesInfo[7]) + checkCommonAbilityInfo(data.hapModulesInfo[0].abilitiesInfo[8]) + checkCommonAbilityInfo(data.hapModulesInfo[0].abilitiesInfo[9]) + checkCommonAbilityInfo(data.hapModulesInfo[0].abilitiesInfo[10]) + expect(data.hapModulesInfo[0].extensionAbilitiesInfo.length).assertEqual(0); + expect(data.hapModulesInfo[0].metadata.length).assertEqual(0); + expect(data.reqPermissionDetails.length).assertEqual(0); + expect(data.permissionGrantStates.length).assertEqual(0); + expect(data.signatureInfo).assertEqual(null); + expect(err).assertEqual(null); + done(); + }) + }) + + /* + * @tc.number: SUB_BMS_APPINFO_QUERY_0126 + * @tc.name: getBundleInfoForSelfExtensionPro + * @tc.desc: Test getBundleInfoForSelf with extensionAbility flag(by promise). + */ + it('getBundleInfoForSelfExtensionPro', 0, async function (done) { + await bundle.getBundleInfoForSelf( + bundle.BundleFlag.GET_BUNDLE_INFO_WITH_HAP_MODULE | bundle.BundleFlag.GET_BUNDLE_INFO_WITH_EXTENSION_ABILITY + ).then(data => { + console.info("ExtensionPro" + JSON.stringify(data.hapModulesInfo[0].extensionAbilitiesInfo)); + checkCommonBundleInfo(data); + checkCommonHapModuleInfo(data); + expect(data.appInfo).assertEqual(null); + expect(data.hapModulesInfo[0].abilitiesInfo.length).assertEqual(0); + let extensionList = data.hapModulesInfo[0].extensionAbilitiesInfo + expect(extensionList.length).assertEqual(13); + let count = 0; + for (let i = 0;i < 13; i++) { + switch (extensionList[i].name) { + case "Form": + console.info("Form" + JSON.stringify(extensionList[i].extensionAbilityType)); + expect(extensionList[i].bundleName).assertEqual(BUNDLE_NAME); + expect(extensionList[i].moduleName).assertEqual("testModule"); + expect(extensionList[i].name).assertEqual("Form"); + expect(extensionList[i].labelId).assertLarger(0); + expect(extensionList[i].descriptionId).assertLarger(0); + expect(extensionList[i].iconId).assertLarger(0); + expect(extensionList[i].isVisible).assertTrue(); + expect(extensionList[i].extensionAbilityType).assertEqual(bundle.ExtensionAbilityType.FORM); + expect(extensionList[i].permissions.length).assertEqual(0); + expect(extensionList[i].applicationInfo).assertEqual(null); + expect(extensionList[i].metadata.length).assertEqual(0); + expect(extensionList[i].enabled).assertTrue(); + expect(extensionList[i].readPermission).assertEqual(""); + expect(extensionList[i].writePermission).assertEqual(""); + count = count + 1; + break; + case "Form1": + console.info("Form" + JSON.stringify(extensionList[i].extensionAbilityType)); + expect(extensionList[i].bundleName).assertEqual(BUNDLE_NAME); + expect(extensionList[i].moduleName).assertEqual("testModule"); + expect(extensionList[i].name).assertEqual("Form1"); + expect(extensionList[i].labelId).assertLarger(0); + expect(extensionList[i].descriptionId).assertLarger(0); + expect(extensionList[i].iconId).assertLarger(0); + expect(extensionList[i].isVisible).assertTrue(); + expect(extensionList[i].extensionAbilityType).assertEqual(bundle.ExtensionAbilityType.FORM); + expect(extensionList[i].permissions.length).assertEqual(0); + expect(extensionList[i].applicationInfo).assertEqual(null); + expect(extensionList[i].metadata.length).assertEqual(0); + expect(extensionList[i].enabled).assertTrue(); + expect(extensionList[i].readPermission).assertEqual(""); + expect(extensionList[i].writePermission).assertEqual(""); + count = count + 2; + break; + case 'workScheduler': + console.info("Form" + JSON.stringify(extensionList[i].extensionAbilityType)); + expect(extensionList[i].extensionAbilityType).assertEqual(bundle.ExtensionAbilityType.WORK_SCHEDULER) + count = count + 3; + break; + case 'inputMethod': + console.info("Form" + JSON.stringify(extensionList[i].extensionAbilityType)); + expect(extensionList[i].extensionAbilityType).assertEqual(bundle.ExtensionAbilityType.INPUT_METHOD) + count = count + 4; + break; + case 'accessibility': + console.info("Form" + JSON.stringify(extensionList[i].extensionAbilityType)); + expect(extensionList[i].extensionAbilityType).assertEqual(bundle.ExtensionAbilityType.ACCESSIBILITY) + count = count + 5; + break; + case 'fileShare': + console.info("Form" + JSON.stringify(extensionList[i].extensionAbilityType)); + expect(extensionList[i].extensionAbilityType).assertEqual(bundle.ExtensionAbilityType.FILE_SHARE) + count = count + 6; + break; + case 'staticSubscriber': + console.info("Form" + JSON.stringify(extensionList[i].extensionAbilityType)); + expect(extensionList[i].extensionAbilityType).assertEqual(bundle.ExtensionAbilityType.STATIC_SUBSCRIBER) + count = count + 7; + break; + case 'wallpaper': + console.info("Form" + JSON.stringify(extensionList[i].extensionAbilityType)); + expect(extensionList[i].extensionAbilityType).assertEqual(bundle.ExtensionAbilityType.WALLPAPER) + count = count + 8; + break; + case 'backup': + console.info("Form" + JSON.stringify(extensionList[i].extensionAbilityType)); + expect(extensionList[i].extensionAbilityType).assertEqual(bundle.ExtensionAbilityType.BACKUP) + count = count + 9; + break; + case 'window': + console.info("Form" + JSON.stringify(extensionList[i].extensionAbilityType)); + expect(extensionList[i].extensionAbilityType).assertEqual(bundle.ExtensionAbilityType.WINDOW) + count = count + 10; + break; + case 'enterpriseAdmin': + console.info("Form" + JSON.stringify(extensionList[i].extensionAbilityType)); + expect(extensionList[i].extensionAbilityType).assertEqual(bundle.ExtensionAbilityType.ENTERPRISE_ADMIN) + count = count + 11; + break; + case 'thumbnail': + console.info("Form" + JSON.stringify(extensionList[i].extensionAbilityType)); + expect(extensionList[i].extensionAbilityType).assertEqual(bundle.ExtensionAbilityType.THUMBNAIL) + count = count + 12; + break; + case 'preview': + console.info("Form" + JSON.stringify(extensionList[i].extensionAbilityType)); + expect(extensionList[i].extensionAbilityType).assertEqual(bundle.ExtensionAbilityType.PREVIEW) + count = count + 13; + break; + } + console.info("count" + JSON.stringify(count)); + } + expect(count).assertEqual(91); + expect(data.hapModulesInfo[0].metadata.length).assertEqual(0); + expect(data.reqPermissionDetails.length).assertEqual(0); + expect(data.permissionGrantStates.length).assertEqual(0); + expect(data.signatureInfo).assertEqual(null); + done(); + }).catch(err => { + console.info("getBundleInfoForSelf fail" + JSON.stringify(err)); + expect(err).assertFail(); + done(); + }) + }) + + /* + * @tc.number: SUB_BMS_APPINFO_QUERY_0127 + * @tc.name: getBundleInfoForSelfExtensionCal + * @tc.desc: Test getBundleInfoForSelf with extensionAbility flag(by callback). + */ + it('getBundleInfoForSelfExtensionCal', 0, async function (done) { + bundle.getBundleInfoForSelf( + bundle.BundleFlag.GET_BUNDLE_INFO_WITH_HAP_MODULE | bundle.BundleFlag.GET_BUNDLE_INFO_WITH_EXTENSION_ABILITY, + (err, data) => { + console.info("ExtensionCal" + JSON.stringify(data.hapModulesInfo[0].extensionAbilitiesInfo)); + checkCommonBundleInfo(data); + checkCommonHapModuleInfo(data); + expect(data.appInfo).assertEqual(null); + expect(data.hapModulesInfo[0].abilitiesInfo.length).assertEqual(0); + let extensionList = data.hapModulesInfo[0].extensionAbilitiesInfo + let count = 0; + for (let i = 0;i < 13; i++) { + switch (extensionList[i].name) { + case "Form": + console.info("Form" + JSON.stringify(extensionList[i].extensionAbilityType)); + expect(extensionList[i].bundleName).assertEqual(BUNDLE_NAME); + expect(extensionList[i].moduleName).assertEqual("testModule"); + expect(extensionList[i].name).assertEqual("Form"); + expect(extensionList[i].labelId).assertLarger(0); + expect(extensionList[i].descriptionId).assertLarger(0); + expect(extensionList[i].iconId).assertLarger(0); + expect(extensionList[i].isVisible).assertTrue(); + expect(extensionList[i].extensionAbilityType).assertEqual(bundle.ExtensionAbilityType.FORM); + expect(extensionList[i].permissions.length).assertEqual(0); + expect(extensionList[i].applicationInfo).assertEqual(null); + expect(extensionList[i].metadata.length).assertEqual(0); + expect(extensionList[i].enabled).assertTrue(); + expect(extensionList[i].readPermission).assertEqual(""); + expect(extensionList[i].writePermission).assertEqual(""); + count = count + 1; + break; + case "Form1": + console.info("Form" + JSON.stringify(extensionList[i].extensionAbilityType)); + expect(extensionList[i].bundleName).assertEqual(BUNDLE_NAME); + expect(extensionList[i].moduleName).assertEqual("testModule"); + expect(extensionList[i].name).assertEqual("Form1"); + expect(extensionList[i].labelId).assertLarger(0); + expect(extensionList[i].descriptionId).assertLarger(0); + expect(extensionList[i].iconId).assertLarger(0); + expect(extensionList[i].isVisible).assertTrue(); + expect(extensionList[i].extensionAbilityType).assertEqual(bundle.ExtensionAbilityType.FORM); + expect(extensionList[i].permissions.length).assertEqual(0); + expect(extensionList[i].applicationInfo).assertEqual(null); + expect(extensionList[i].metadata.length).assertEqual(0); + expect(extensionList[i].enabled).assertTrue(); + expect(extensionList[i].readPermission).assertEqual(""); + expect(extensionList[i].writePermission).assertEqual(""); + count = count + 2; + break; + case 'workScheduler': + console.info("Form" + JSON.stringify(extensionList[i].extensionAbilityType)); + expect(extensionList[i].extensionAbilityType).assertEqual(bundle.ExtensionAbilityType.WORK_SCHEDULER) + count = count + 3; + break; + case 'inputMethod': + console.info("Form" + JSON.stringify(extensionList[i].extensionAbilityType)); + expect(extensionList[i].extensionAbilityType).assertEqual(bundle.ExtensionAbilityType.INPUT_METHOD) + count = count + 4; + break; + case 'accessibility': + console.info("Form" + JSON.stringify(extensionList[i].extensionAbilityType)); + expect(extensionList[i].extensionAbilityType).assertEqual(bundle.ExtensionAbilityType.ACCESSIBILITY) + count = count + 5; + break; + case 'fileShare': + console.info("Form" + JSON.stringify(extensionList[i].extensionAbilityType)); + expect(extensionList[i].extensionAbilityType).assertEqual(bundle.ExtensionAbilityType.FILE_SHARE) + count = count + 6; + break; + case 'staticSubscriber': + console.info("Form" + JSON.stringify(extensionList[i].extensionAbilityType)); + expect(extensionList[i].extensionAbilityType).assertEqual(bundle.ExtensionAbilityType.STATIC_SUBSCRIBER) + count = count + 7; + break; + case 'wallpaper': + console.info("Form" + JSON.stringify(extensionList[i].extensionAbilityType)); + expect(extensionList[i].extensionAbilityType).assertEqual(bundle.ExtensionAbilityType.WALLPAPER) + count = count + 8; + break; + case 'backup': + console.info("Form" + JSON.stringify(extensionList[i].extensionAbilityType)); + expect(extensionList[i].extensionAbilityType).assertEqual(bundle.ExtensionAbilityType.BACKUP) + count = count + 9; + break; + case 'window': + console.info("Form" + JSON.stringify(extensionList[i].extensionAbilityType)); + expect(extensionList[i].extensionAbilityType).assertEqual(bundle.ExtensionAbilityType.WINDOW) + count = count + 10; + break; + case 'enterpriseAdmin': + console.info("Form" + JSON.stringify(extensionList[i].extensionAbilityType)); + expect(extensionList[i].extensionAbilityType).assertEqual(bundle.ExtensionAbilityType.ENTERPRISE_ADMIN) + count = count + 11; + break; + case 'thumbnail': + console.info("Form" + JSON.stringify(extensionList[i].extensionAbilityType)); + expect(extensionList[i].extensionAbilityType).assertEqual(bundle.ExtensionAbilityType.THUMBNAIL) + count = count + 12; + break; + case 'preview': + console.info("Form" + JSON.stringify(extensionList[i].extensionAbilityType)); + expect(extensionList[i].extensionAbilityType).assertEqual(bundle.ExtensionAbilityType.PREVIEW) + count = count + 13; + break; + } + console.info("count" + JSON.stringify(count)); + } + expect(count).assertEqual(91); + expect(data.hapModulesInfo[0].metadata.length).assertEqual(0); + expect(data.reqPermissionDetails.length).assertEqual(0); + expect(data.permissionGrantStates.length).assertEqual(0); + expect(data.signatureInfo).assertEqual(null); + expect(err).assertEqual(null); + expect(bundle.ExtensionAbilityType.UNSPECIFIED).assertEqual(255); + done(); + }) + }) + + /* + * @tc.number: SUB_BMS_APPINFO_QUERY_0128 + * @tc.name: getBundleInfoForSelfPermissionPro + * @tc.desc: Test getBundleInfoForSelf with permission flag(by promise). + */ + it('getBundleInfoForSelfPermissionPro', 0, async function (done) { + await bundle.getBundleInfoForSelf( + bundle.BundleFlag.GET_BUNDLE_INFO_WITH_REQUESTED_PERMISSION).then(data => { + console.info("PermissionPro" + JSON.stringify(data.reqPermissionDetails)); + console.info("PermissionPro" + JSON.stringify(data.permissionGrantStates)); + checkCommonBundleInfo(data); + expect(data.appInfo).assertEqual(null); + expect(data.hapModulesInfo.length).assertEqual(0); + expect(data.reqPermissionDetails.length).assertEqual(2); + expect(data.reqPermissionDetails[0].name).assertEqual("ohos.permission.GET_BUNDLE_INFO"); + expect(data.reqPermissionDetails[0].reason).assertEqual("$string:permission_reason"); + expect(data.reqPermissionDetails[0].reasonId).assertLarger(0); + expect(data.reqPermissionDetails[0].usedScene.abilities.length).assertEqual(1); + expect(data.reqPermissionDetails[0].usedScene.abilities[0]).assertEqual("MainAbility"); + expect(data.reqPermissionDetails[0].usedScene.when).assertEqual("always"); + expect(data.permissionGrantStates[0]).assertEqual(bundle.PermissionGrantState.PERMISSION_GRANTED); + expect(data.reqPermissionDetails[1].name).assertEqual("ohos.permission.READ_CALENDAR"); + expect(data.reqPermissionDetails[1].reason).assertEqual("$string:permission_reason"); + expect(data.reqPermissionDetails[1].reasonId).assertLarger(0); + expect(data.reqPermissionDetails[1].usedScene.abilities.length).assertEqual(1); + expect(data.reqPermissionDetails[1].usedScene.abilities[0]).assertEqual("MainAbility"); + expect(data.reqPermissionDetails[1].usedScene.when).assertEqual("inuse"); + expect(data.permissionGrantStates[1]).assertEqual(bundle.PermissionGrantState.PERMISSION_DENIED); + expect(data.signatureInfo).assertEqual(null); + done(); + }).catch(err => { + console.info("getBundleInfoForSelf fail" + JSON.stringify(err)); + expect(err).assertFail(); + done(); + }) + }) + + /* + * @tc.number: SUB_BMS_APPINFO_QUERY_0129 + * @tc.name: getBundleInfoForSelfPermissionCal + * @tc.desc: Test getBundleInfoForSelf with permission flag(by callback). + */ + it('getBundleInfoForSelfPermissionCal', 0, async function (done) { + bundle.getBundleInfoForSelf( + bundle.BundleFlag.GET_BUNDLE_INFO_WITH_REQUESTED_PERMISSION, (err, data) => { + console.info("PermissionPro" + JSON.stringify(data.reqPermissionDetails)); + console.info("PermissionPro" + JSON.stringify(data.permissionGrantStates)); + checkCommonBundleInfo(data); + expect(data.appInfo).assertEqual(null); + expect(data.reqPermissionDetails.length).assertEqual(2); + expect(data.reqPermissionDetails[0].name).assertEqual("ohos.permission.GET_BUNDLE_INFO"); + expect(data.reqPermissionDetails[0].reason).assertEqual("$string:permission_reason"); + expect(data.reqPermissionDetails[0].reasonId).assertLarger(0); + expect(data.reqPermissionDetails[0].usedScene.abilities.length).assertEqual(1); + expect(data.reqPermissionDetails[0].usedScene.abilities[0]).assertEqual("MainAbility"); + expect(data.reqPermissionDetails[0].usedScene.when).assertEqual("always"); + expect(data.permissionGrantStates[0]).assertEqual(bundle.PermissionGrantState.PERMISSION_GRANTED); + expect(data.reqPermissionDetails[1].name).assertEqual("ohos.permission.READ_CALENDAR"); + expect(data.reqPermissionDetails[1].reason).assertEqual("$string:permission_reason"); + expect(data.reqPermissionDetails[1].reasonId).assertLarger(0); + expect(data.reqPermissionDetails[1].usedScene.abilities.length).assertEqual(1); + expect(data.reqPermissionDetails[1].usedScene.abilities[0]).assertEqual("MainAbility"); + expect(data.reqPermissionDetails[1].usedScene.when).assertEqual("inuse"); + expect(data.permissionGrantStates[1]).assertEqual(bundle.PermissionGrantState.PERMISSION_DENIED); + expect(data.signatureInfo).assertEqual(null); + expect(err).assertEqual(null); + done(); + }) + }) + + /* + * @tc.number: SUB_BMS_APPINFO_QUERY_0130 + * @tc.name: getBundleInfoForSelfMetaPro + * @tc.desc: Test getBundleInfoForSelf with metadata flag(by promise). + */ + it('getBundleInfoForSelfMetaPro', 0, async function (done) { + await bundle.getBundleInfoForSelf( + bundle.BundleFlag.GET_BUNDLE_INFO_WITH_HAP_MODULE | bundle.BundleFlag.GET_BUNDLE_INFO_WITH_METADATA) + .then(data => { + console.info("MetaPro" + JSON.stringify(data.hapModulesInfo[0].metadata)); + checkCommonBundleInfo(data); + checkCommonHapModuleInfo(data); + expect(data.appInfo).assertEqual(null); + expect(data.hapModulesInfo[0].abilitiesInfo.length).assertEqual(0); + expect(data.hapModulesInfo[0].extensionAbilitiesInfo.length).assertEqual(0); + expect(data.hapModulesInfo[0].metadata.length).assertEqual(1); + expect(data.hapModulesInfo[0].metadata[0].name).assertEqual("MetaData1"); + expect(data.hapModulesInfo[0].metadata[0].value).assertEqual("MetaDataValue"); + expect(data.hapModulesInfo[0].metadata[0].resource).assertEqual("$profile:shortcuts_config"); + expect(data.reqPermissionDetails.length).assertEqual(0); + expect(data.permissionGrantStates.length).assertEqual(0); + expect(data.signatureInfo).assertEqual(null); + done(); + }) + .catch(err => { + console.info("getBundleInfoForSelf fail" + JSON.stringify(err)); + expect(err).assertFail(); + done(); + }) + }) + + /* + * @tc.number: SUB_BMS_APPINFO_QUERY_0131 + * @tc.name: getBundleInfoForSelfMetaCal + * @tc.desc: Test getBundleInfoForSelf with metadata flag(by callback). + */ + it('getBundleInfoForSelfMetaCal', 0, async function (done) { + bundle.getBundleInfoForSelf( + bundle.BundleFlag.GET_BUNDLE_INFO_WITH_HAP_MODULE | bundle.BundleFlag.GET_BUNDLE_INFO_WITH_METADATA, + (err, data) => { + console.info("MetaPro" + JSON.stringify(data.hapModulesInfo[0].metadata)); + checkCommonBundleInfo(data); + checkCommonHapModuleInfo(data); + expect(data.appInfo).assertEqual(null); + expect(data.hapModulesInfo[0].abilitiesInfo.length).assertEqual(0); + expect(data.hapModulesInfo[0].extensionAbilitiesInfo.length).assertEqual(0); + expect(data.hapModulesInfo[0].metadata.length).assertEqual(1); + expect(data.hapModulesInfo[0].metadata[0].name).assertEqual("MetaData1"); + expect(data.hapModulesInfo[0].metadata[0].value).assertEqual("MetaDataValue"); + expect(data.hapModulesInfo[0].metadata[0].resource).assertEqual("$profile:shortcuts_config"); + expect(data.reqPermissionDetails.length).assertEqual(0); + expect(data.permissionGrantStates.length).assertEqual(0); + expect(data.signatureInfo).assertEqual(null); + expect(err).assertEqual(null); + done(); + }) + }) + + /* + * @tc.number: SUB_BMS_APPINFO_QUERY_0132 + * @tc.name: getBundleInfoForSelfSigPro + * @tc.desc: Test getBundleInfoForSelf with signatureInfo flag(by promise). + */ + it('getBundleInfoForSelfSigPro', 0, async function (done) { + await bundle.getBundleInfoForSelf( + bundle.BundleFlag.GET_BUNDLE_INFO_WITH_SIGNATURE_INFO).then(data => { + console.info("SigPro" + JSON.stringify(data.signatureInfo)); + checkCommonBundleInfo(data); + expect(data.appInfo).assertEqual(null); + expect(data.hapModulesInfo.length).assertEqual(0); + expect(data.reqPermissionDetails.length).assertEqual(0); + expect(data.permissionGrantStates.length).assertEqual(0); + expect(data.signatureInfo.appId).assertEqual(APPID); + expect(data.signatureInfo.fingerprint).assertEqual(FINGERPRINT); + done(); + }).catch(err => { + console.info("getBundleInfoForSelf fail" + JSON.stringify(err)); + expect(err).assertFail(); + done(); + }) + }) + + /* + * @tc.number: SUB_BMS_APPINFO_QUERY_0133 + * @tc.name: getBundleInfoForSelfSigCal + * @tc.desc: Test getBundleInfoForSelf with signatureInfo flag(by callback). + */ + it('getBundleInfoForSelfSigCal', 0, async function (done) { + bundle.getBundleInfoForSelf( + bundle.BundleFlag.GET_BUNDLE_INFO_WITH_SIGNATURE_INFO, (err, data) => { + console.info("SigCal" + JSON.stringify(data.signatureInfo)); + checkCommonBundleInfo(data); + expect(data.appInfo).assertEqual(null); + expect(data.hapModulesInfo.length).assertEqual(0); + expect(data.reqPermissionDetails.length).assertEqual(0); + expect(data.permissionGrantStates.length).assertEqual(0); + expect(data.signatureInfo.appId).assertEqual(APPID); + expect(data.signatureInfo.fingerprint).assertEqual(FINGERPRINT); + expect(err).assertEqual(null); + done(); + }) + }) + + /* + * @tc.number: SUB_BMS_APPINFO_QUERY_0134 + * @tc.name: getBundleInfoForSelfDisPro + * @tc.desc: Test getBundleInfoForSelf with disable flag(by promise). + */ + it('getBundleInfoForSelfDisPro', 0, async function (done) { + await bundle.getBundleInfoForSelf(bundle.BundleFlag.GET_BUNDLE_INFO_WITH_DISABLE).then(data => { + console.info("DisPro" + JSON.stringify(data)); + checkCommonBundleInfo(data); + expect(data.appInfo).assertEqual(null); + expect(data.hapModulesInfo.length).assertEqual(0); + expect(data.reqPermissionDetails.length).assertEqual(0); + expect(data.permissionGrantStates.length).assertEqual(0); + expect(data.signatureInfo).assertEqual(null); + done(); + }).catch(err => { + console.info("getBundleInfoForSelf fail" + JSON.stringify(err)); + expect(err).assertFail(); + done(); + }) + }) + + /* + * @tc.number: SUB_BMS_APPINFO_QUERY_0135 + * @tc.name: getBundleInfoForSelfDisCal + * @tc.desc: Test getBundleInfoForSelf with disable flag(by callback). + */ + it('getBundleInfoForSelfDisCal', 0, async function (done) { + bundle.getBundleInfoForSelf( + bundle.BundleFlag.GET_BUNDLE_INFO_WITH_DISABLE, (err, data) => { + console.info("DisCal" + JSON.stringify(data)); + checkCommonBundleInfo(data); + expect(data.appInfo).assertEqual(null); + expect(data.hapModulesInfo.length).assertEqual(0); + expect(data.reqPermissionDetails.length).assertEqual(0); + expect(data.permissionGrantStates.length).assertEqual(0); + expect(data.signatureInfo).assertEqual(null); + expect(err).assertEqual(null); + done(); + }) + }) + + /* + * @tc.number: SUB_BMS_APPINFO_QUERY_0136 + * @tc.name: getBundleInfoForSelfParamErrPro + * @tc.desc: Test getBundleInfoForSelf with error param(by promise). + */ + it('getBundleInfoForSelfParamErrPro', 0, async function (done) { + try { + await bundle.getBundleInfoForSelf(null).then(data => { + console.info("ParamErrPro null success " + JSON.stringify(data)); + expect(data).assertFail(); + }).catch(err => { + console.info("ParamErrPro null fail1 " + JSON.stringify(err)); + expect(err).assertFail(); + }) + } catch (err) { + console.info("ParamErrPro null fail2 " + JSON.stringify(err)); + expect(err.code).assertEqual(PARAM_ERROR_CODE); + } + try { + await bundle.getBundleInfoForSelf(undefined).then(data => { + console.info("ParamErrPro undefined success " + JSON.stringify(data)); + expect(data).assertFail(); + }).catch(err => { + console.info("ParamErrPro undefined fail1 " + JSON.stringify(err)); + expect(err).assertFail(); + }) + } catch (err) { + console.info("ParamErrPro undefined fail2 " + JSON.stringify(err)); + expect(err.code).assertEqual(PARAM_ERROR_CODE); + done(); + } + }) + + /* + * @tc.number: SUB_BMS_APPINFO_QUERY_0137 + * @tc.name: getBundleInfoForSelfParamErrCal + * @tc.desc: Test getBundleInfoForSelf with error param(by callback). + */ + it('getBundleInfoForSelfParamErrCal', 0, async function (done) { + try { + bundle.getBundleInfoForSelf(null, (err, data) => { + console.info("ParamErrCal null success " + JSON.stringify(data)); + console.info("ParamErrCal null success " + JSON.stringify(err)); + expect(data).assertFail(); + }) + } catch (err) { + console.info("ParamErrCal null fail2 " + JSON.stringify(err)); + expect(err.code).assertEqual(PARAM_ERROR_CODE); + } + await util.sleep(200); + try { + bundle.getBundleInfoForSelf(undefined, (err, data) => { + console.info("ParamErrCal undefined success " + JSON.stringify(data)); + console.info("ParamErrCal undefined success " + JSON.stringify(err)); + expect(data).assertFail(); + }) + } catch (err) { + console.info("ParamErrCal undefined fail2 " + JSON.stringify(err)); + expect(err.code).assertEqual(PARAM_ERROR_CODE); + done(); + } + }) + + function checkCommonBundleInfo(data) { + expect(data.name).assertEqual(BUNDLE_NAME); + expect(data.vendor).assertEqual(VENDOR); + expect(data.versionCode).assertEqual(1000000); + expect(data.versionName).assertEqual("1.0.0"); + expect(data.minCompatibleVersionCode).assertEqual(1000000); + expect(data.targetVersion).assertEqual(8); + expect(data.installTime).assertLarger(0); + expect(data.updateTime).assertLarger(0); + console.info("checkCommonBundleInfo end"); + } + + function checkCommonApplicationInfo(data) { + expect(data.appInfo.name).assertEqual(BUNDLE_NAME); + expect(data.appInfo.description).assertEqual("$string:description_application"); + expect(data.appInfo.descriptionId).assertLarger(0); + expect(data.appInfo.enabled).assertTrue(); + expect(data.appInfo.label).assertEqual("$string:app_name"); + expect(data.appInfo.labelId).assertLarger(0); + expect(data.appInfo.icon).assertEqual("$media:icon"); + expect(data.appInfo.iconId).assertLarger(0); + expect(data.appInfo.process).assertEqual(BUNDLE_NAME); + expect(data.appInfo.entryDir).assertEqual(SOURCE_DIR); + expect(data.appInfo.codePath).assertEqual("/data/app/el1/bundle/public/ohos.acts.bundle.stage.test"); + expect(data.appInfo.removable).assertTrue(0); + expect(data.appInfo.accessTokenId).assertLarger(0); + expect(data.appInfo.uid).assertLarger(0); + expect(data.appInfo.iconResource.bundleName).assertEqual(BUNDLE_NAME); + expect(data.appInfo.iconResource.moduleName).assertEqual("testModule"); + expect(data.appInfo.iconResource.id).assertEqual(data.appInfo.iconId); + expect(data.appInfo.labelResource.bundleName).assertEqual(BUNDLE_NAME); + expect(data.appInfo.labelResource.moduleName).assertEqual("testModule"); + expect(data.appInfo.labelResource.id).assertEqual(data.appInfo.labelId); + expect(data.appInfo.descriptionResource.bundleName).assertEqual(BUNDLE_NAME); + expect(data.appInfo.descriptionResource.moduleName).assertEqual("testModule"); + expect(data.appInfo.descriptionResource.id).assertEqual(data.appInfo.descriptionId); + expect(data.appInfo.appDistributionType).assertEqual("os_integration"); + expect(data.appInfo.appProvisionType).assertEqual("release"); + expect(JSON.stringify(data.appInfo.metadata)).assertEqual("{}"); + console.info("checkCommonApplicationInfo end"); + } + + function checkCommonHapModuleInfo(data) { + expect(data.hapModulesInfo.length).assertEqual(1); + expect(data.hapModulesInfo[0].name).assertEqual("testModule"); + expect(data.hapModulesInfo[0].icon).assertEqual("$media:icon"); + expect(data.hapModulesInfo[0].iconId).assertLarger(0); + expect(data.hapModulesInfo[0].label).assertEqual("$string:entry_label"); + expect(data.hapModulesInfo[0].labelId).assertLarger(0); + expect(data.hapModulesInfo[0].description).assertEqual("$string:testModule_entry_dsc"); + expect(data.hapModulesInfo[0].descriptionId).assertLarger(0); + expect(data.hapModulesInfo[0].mainElementName).assertEqual(ABILITY_NAME); + expect(data.hapModulesInfo[0].deviceTypes.length).assertEqual(2); + console.info("checkComm" + JSON.stringify(data.hapModulesInfo[0].deviceTypes[0])); + console.info("checkComm" + JSON.stringify(data.hapModulesInfo[0].deviceTypes[1])); + expect(data.hapModulesInfo[0].deviceTypes[0]).assertEqual("default"); + expect(data.hapModulesInfo[0].deviceTypes[1]).assertEqual("tablet"); + expect(data.hapModulesInfo[0].installationFree).assertFalse(); + expect(data.hapModulesInfo[0].hashValue).assertEqual(""); + expect(data.hapModulesInfo[0].moduleSourceDir).assertEqual(SOURCE_DIR); + console.info("checkCommonHapModuleInfo end"); + } + + function checkCommonAbilityInfo(data) { + expect(data.bundleName).assertEqual(BUNDLE_NAME); + expect(data.moduleName).assertEqual("testModule"); + expect(data.label).assertEqual("$string:entry_label"); + expect(data.labelId).assertLarger(0); + expect(data.description).assertEqual("$string:testModule_entry_main"); + expect(data.descriptionId).assertLarger(0); + expect(data.icon).assertEqual("$media:icon"); + expect(data.iconId).assertLarger(0); + expect(data.process).assertEqual(""); + expect(data.isVisible).assertTrue(); + expect(data.type).assertEqual(1); + expect(data.permissions.length).assertEqual(0); + expect(data.readPermission).assertEqual(""); + expect(data.writePermission).assertEqual(""); + expect(data.uri).assertEqual(""); + expect(data.deviceTypes.length).assertEqual(2); + console.info("checkComm" + JSON.stringify(data.deviceTypes[0])); + console.info("checkComm" + JSON.stringify(data.deviceTypes[1])); + expect(data.deviceTypes[0]).assertEqual("default"); + expect(data.deviceTypes[1]).assertEqual("tablet"); + expect(data.applicationInfo).assertEqual(null); + expect(data.metadata.length).assertEqual(0); + expect(data.enabled).assertTrue(); + expect(data.supportWindowModes.length).assertEqual(3); + expect(data.supportWindowModes[0]).assertEqual(bundle.SupportWindowMode.FULL_SCREEN); + expect(data.supportWindowModes[1]).assertEqual(bundle.SupportWindowMode.SPLIT); + expect(data.supportWindowModes[2]).assertEqual(bundle.SupportWindowMode.FLOATING); + expect(data.windowSize.maxWindowRatio).assertEqual(0); + expect(data.windowSize.minWindowRatio).assertEqual(0); + expect(data.windowSize.maxWindowWidth).assertEqual(0); + expect(data.windowSize.minWindowWidth).assertEqual(0); + expect(data.windowSize.maxWindowHeight).assertEqual(0); + expect(data.windowSize.minWindowHeight).assertEqual(0); + console.info("checkCommonAbilityInfo end"); + } + }) +} \ No newline at end of file diff --git a/bundlemanager/bundle_standard/bundlemanager/actsbundlemanagerstagetest/entry/src/main/ets/test/GetSecondModule.test.ets b/bundlemanager/bundle_standard/bundlemanager/actsbundlemanagerstagetest/entry/src/main/ets/test/GetSecondModule.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..2c00ddfe087ca3b355594ad553bbb810e3af1830 --- /dev/null +++ b/bundlemanager/bundle_standard/bundlemanager/actsbundlemanagerstagetest/entry/src/main/ets/test/GetSecondModule.test.ets @@ -0,0 +1,75 @@ +/* + * 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 bundle from '@ohos.bundle.bundleManager'; +import { describe, beforeAll, it, expect } from '@ohos/hypium' + +export default function GetSecondModuleTest() { + describe('getSecondModuleTest', function () { + + /** + * @tc.number SUB_BMS_APPINFO_QUERY_0138 + * @tc.name GetSecondModuleTest + * @tc.desc Test the bundleManager secondary module + */ + it('GetSecondModuleTest', 0, async function (done) { + let bundleInfo = await bundle.getBundleInfoForSelf( + bundle.BundleFlag.GET_BUNDLE_INFO_WITH_APPLICATION | + bundle.BundleFlag.GET_BUNDLE_INFO_WITH_SIGNATURE_INFO | + bundle.BundleFlag.GET_BUNDLE_INFO_WITH_HAP_MODULE | + bundle.BundleFlag.GET_BUNDLE_INFO_WITH_METADATA | + bundle.BundleFlag.GET_BUNDLE_INFO_WITH_EXTENSION_ABILITY | + bundle.BundleFlag.GET_BUNDLE_INFO_WITH_ABILITY | + bundle.BundleFlag.GET_BUNDLE_INFO_WITH_REQUESTED_PERMISSION) + let applicationInfoTest: bundle.ApplicationInfo = bundleInfo.appInfo; + expect(typeof (applicationInfoTest.name)).assertEqual('string'); + let metadataTest: bundle.Metadata = bundleInfo.hapModulesInfo[0].metadata[0]; + expect(typeof (metadataTest.name)).assertEqual('string'); + let bundleInfoTest: bundle.BundleInfo = bundleInfo; + expect(typeof (bundleInfoTest.name)).assertEqual('string'); + let usedSceneTest: bundle.UsedScene = bundleInfo.reqPermissionDetails[0].usedScene + expect(typeof (usedSceneTest.abilities[0])).assertEqual('string'); + let reqPermissionDetailsTest: bundle.ReqPermissionDetail = bundleInfo.reqPermissionDetails[0] + expect(typeof (reqPermissionDetailsTest.name)).assertEqual('string'); + let signatureInfoTest: bundle.SignatureInfo = bundleInfo.signatureInfo; + expect(typeof (signatureInfoTest.appId)).assertEqual('string'); + let hapModuleInfoTest: bundle.HapModuleInfo = bundleInfo.hapModulesInfo[0]; + expect(typeof (hapModuleInfoTest.name)).assertEqual('string'); + let abilityInfoTest: bundle.AbilityInfo = bundleInfo.hapModulesInfo[0].abilitiesInfo[0]; + expect(typeof (abilityInfoTest.bundleName)).assertEqual('string'); + let windowSizeTest: bundle.WindowSize = bundleInfo.hapModulesInfo[0].abilitiesInfo[0].windowSize; + expect(windowSizeTest.maxWindowRatio).assertEqual(0); + let extensionAbilityInfoTest: bundle.ExtensionAbilityInfo = bundleInfo.hapModulesInfo[0].extensionAbilitiesInfo[0]; + expect(typeof (extensionAbilityInfoTest.bundleName)).assertEqual('string'); + let elementNameExample = { + deviceId: "123456789", + bundleName: "bundleName", + moduleName:"moduleName", + abilityName: "abilityName", + uri:"uri", + shortName:"shortName" + } + let elementNameTest: bundle.ElementName = elementNameExample; + expect(elementNameTest.deviceId).assertEqual("123456789"); + expect(elementNameTest.bundleName).assertEqual("bundleName"); + expect(elementNameTest.moduleName).assertEqual("moduleName"); + expect(elementNameTest.abilityName).assertEqual("abilityName"); + expect(elementNameTest.uri).assertEqual("uri"); + expect(elementNameTest.shortName).assertEqual("shortName"); + done(); + }) + }) + +} diff --git a/bundlemanager/bundle_standard/bundlemanager/actsbundlemanagerstagetest/entry/src/main/ets/test/List.test.ets b/bundlemanager/bundle_standard/bundlemanager/actsbundlemanagerstagetest/entry/src/main/ets/test/List.test.ets index 9f75ecfa43762ceaab1ac9c2b3211e1908e8d02e..ee7616939c7338a8484de889769785e02e9861d5 100755 --- a/bundlemanager/bundle_standard/bundlemanager/actsbundlemanagerstagetest/entry/src/main/ets/test/List.test.ets +++ b/bundlemanager/bundle_standard/bundlemanager/actsbundlemanagerstagetest/entry/src/main/ets/test/List.test.ets @@ -15,8 +15,12 @@ import getProfileByAbility from './GetProfileByAbility.test.ets'; import getProfileByExtensionAbility from './GetProfileByExtensionAbility.test.ets'; +import getBundleInfoForSelf from './GetBundleInfoForSelf.test.ets'; +import getSecondModuleTest from './GetSecondModule.test.ets'; export default function testsuite() { getProfileByAbility(); getProfileByExtensionAbility(); + getBundleInfoForSelf(); + getSecondModuleTest(); } \ No newline at end of file diff --git a/bundlemanager/bundle_standard/bundlemanager/actsbundlemanagerstagetest/entry/src/main/ets/test/Utils.ets b/bundlemanager/bundle_standard/bundlemanager/actsbundlemanagerstagetest/entry/src/main/ets/test/Utils.ets new file mode 100644 index 0000000000000000000000000000000000000000..f3b5fe7f6934788d3560d3170931643879f18d4c --- /dev/null +++ b/bundlemanager/bundle_standard/bundlemanager/actsbundlemanagerstagetest/entry/src/main/ets/test/Utils.ets @@ -0,0 +1,30 @@ +/** + * 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. + */ + +export default class Utils { + static sleep(time) { + return new Promise((resolve, reject) => { + setTimeout((data) => { + resolve(data) + }, time) + }).then(() => { + console.info(`sleep ${time} over...`) + }) + } +} + + + + diff --git a/bundlemanager/bundle_standard/bundlemanager/actsbundlemanagerstagetest/entry/src/main/module.json b/bundlemanager/bundle_standard/bundlemanager/actsbundlemanagerstagetest/entry/src/main/module.json index 137f1427c10fed320b2d86371e522bbcf2978f6e..91ecfa07a1f6dd2aa839a7c32e46105d57a8c31b 100755 --- a/bundlemanager/bundle_standard/bundlemanager/actsbundlemanagerstagetest/entry/src/main/module.json +++ b/bundlemanager/bundle_standard/bundlemanager/actsbundlemanagerstagetest/entry/src/main/module.json @@ -4,9 +4,10 @@ "type": "entry", "srcEntrance": "./ets/Application/AbilityStage.ts", "description": "$string:testModule_entry_dsc", - "mainElement": "MainAbility", + "mainElement": "ohos.acts.bundle.stage.test.MainAbility", "deviceTypes": [ - "default" + "default", + "tablet" ], "deliveryWithInstall": true, "installationFree": false, @@ -20,6 +21,7 @@ "icon": "$media:icon", "label": "$string:entry_label", "visible": true, + "launchType": "singleton", "orientation": "portrait", "skills": [ { @@ -66,7 +68,107 @@ "icon": "$media:icon", "label": "$string:entry_label", "visible": true, - "orientation": "portrait", + "launchType": "standard", + "orientation": "landscape", + "skills": [] + }, + { + "name": "ohos.acts.bundle.stage.test.MainAbility2", + "srcEntrance": "./ets/MainAbility/MainAbility.ts", + "description": "$string:testModule_entry_main", + "icon": "$media:icon", + "label": "$string:entry_label", + "visible": true, + "launchType": "specified", + "orientation": "landscape_inverted", + "skills": [] + }, + { + "name": "ohos.acts.bundle.stage.test.MainAbility3", + "srcEntrance": "./ets/MainAbility/MainAbility.ts", + "description": "$string:testModule_entry_main", + "icon": "$media:icon", + "label": "$string:entry_label", + "visible": true, + "launchType": "specified", + "orientation": "portrait_inverted", + "skills": [] + }, + { + "name": "ohos.acts.bundle.stage.test.MainAbility4", + "srcEntrance": "./ets/MainAbility/MainAbility.ts", + "description": "$string:testModule_entry_main", + "icon": "$media:icon", + "label": "$string:entry_label", + "visible": true, + "launchType": "specified", + "orientation": "auto_rotation", + "skills": [] + }, + { + "name": "ohos.acts.bundle.stage.test.MainAbility5", + "srcEntrance": "./ets/MainAbility/MainAbility.ts", + "description": "$string:testModule_entry_main", + "icon": "$media:icon", + "label": "$string:entry_label", + "visible": true, + "launchType": "specified", + "orientation": "auto_rotation_landscape", + "skills": [] + }, + { + "name": "ohos.acts.bundle.stage.test.MainAbility6", + "srcEntrance": "./ets/MainAbility/MainAbility.ts", + "description": "$string:testModule_entry_main", + "icon": "$media:icon", + "label": "$string:entry_label", + "visible": true, + "launchType": "specified", + "orientation": "auto_rotation_portrait", + "skills": [] + }, + { + "name": "ohos.acts.bundle.stage.test.MainAbility7", + "srcEntrance": "./ets/MainAbility/MainAbility.ts", + "description": "$string:testModule_entry_main", + "icon": "$media:icon", + "label": "$string:entry_label", + "visible": true, + "launchType": "specified", + "orientation": "auto_rotation_restricted", + "skills": [] + }, + { + "name": "ohos.acts.bundle.stage.test.MainAbility8", + "srcEntrance": "./ets/MainAbility/MainAbility.ts", + "description": "$string:testModule_entry_main", + "icon": "$media:icon", + "label": "$string:entry_label", + "visible": true, + "launchType": "specified", + "orientation": "auto_rotation_landscape_restricted", + "skills": [] + }, + { + "name": "ohos.acts.bundle.stage.test.MainAbility9", + "srcEntrance": "./ets/MainAbility/MainAbility.ts", + "description": "$string:testModule_entry_main", + "icon": "$media:icon", + "label": "$string:entry_label", + "visible": true, + "launchType": "specified", + "orientation": "auto_rotation_portrait_restricted", + "skills": [] + }, + { + "name": "ohos.acts.bundle.stage.test.MainAbility10", + "srcEntrance": "./ets/MainAbility/MainAbility.ts", + "description": "$string:testModule_entry_main", + "icon": "$media:icon", + "label": "$string:entry_label", + "visible": true, + "launchType": "specified", + "orientation": "locked", "skills": [] } ], @@ -76,6 +178,7 @@ "descriptionId": 16777219, "icon": "$media:icon", "iconId": 16777225, + "label": "$string:entry_label", "metadata": [ { "name": "ohos.extension.form", @@ -113,11 +216,158 @@ "descriptionId": 16777219, "icon": "$media:icon", "iconId": 16777225, + "label": "$string:entry_label", "name": "Form1", "srcEntrance": "./ets/FormAbility/FormAbility.ts", "type": "form", "visible": true + }, + { + "description": "$string:form_description", + "descriptionId": 16777219, + "icon": "$media:icon", + "iconId": 16777225, + "label": "$string:entry_label", + "name": "workScheduler", + "srcEntrance": "./ets/FormAbility/FormAbility.ts", + "type": "workScheduler", + "visible": true + }, + { + "description": "$string:form_description", + "descriptionId": 16777219, + "icon": "$media:icon", + "iconId": 16777225, + "label": "$string:entry_label", + "name": "inputMethod", + "srcEntrance": "./ets/FormAbility/FormAbility.ts", + "type": "inputMethod", + "visible": true + }, + { + "description": "$string:form_description", + "descriptionId": 16777219, + "icon": "$media:icon", + "iconId": 16777225, + "label": "$string:entry_label", + "name": "accessibility", + "srcEntrance": "./ets/FormAbility/FormAbility.ts", + "type": "accessibility", + "visible": true + }, + { + "description": "$string:form_description", + "descriptionId": 16777219, + "icon": "$media:icon", + "iconId": 16777225, + "label": "$string:entry_label", + "name": "fileShare", + "srcEntrance": "./ets/FormAbility/FormAbility.ts", + "type": "fileShare", + "visible": true + }, + { + "description": "$string:form_description", + "descriptionId": 16777219, + "icon": "$media:icon", + "iconId": 16777225, + "label": "$string:entry_label", + "name": "staticSubscriber", + "srcEntrance": "./ets/FormAbility/FormAbility.ts", + "type": "staticSubscriber", + "visible": true + }, + { + "description": "$string:form_description", + "descriptionId": 16777219, + "icon": "$media:icon", + "iconId": 16777225, + "label": "$string:entry_label", + "name": "wallpaper", + "srcEntrance": "./ets/FormAbility/FormAbility.ts", + "type": "wallpaper", + "visible": true + }, + { + "description": "$string:form_description", + "descriptionId": 16777219, + "icon": "$media:icon", + "iconId": 16777225, + "label": "$string:entry_label", + "name": "backup", + "srcEntrance": "./ets/FormAbility/FormAbility.ts", + "type": "backup", + "visible": true + }, + { + "description": "$string:form_description", + "descriptionId": 16777219, + "icon": "$media:icon", + "iconId": 16777225, + "label": "$string:entry_label", + "name": "window", + "srcEntrance": "./ets/FormAbility/FormAbility.ts", + "type": "window", + "visible": true + }, + { + "description": "$string:form_description", + "descriptionId": 16777219, + "icon": "$media:icon", + "iconId": 16777225, + "label": "$string:entry_label", + "name": "enterpriseAdmin", + "srcEntrance": "./ets/FormAbility/FormAbility.ts", + "type": "enterpriseAdmin", + "visible": true + }, + { + "description": "$string:form_description", + "descriptionId": 16777219, + "icon": "$media:icon", + "iconId": 16777225, + "label": "$string:entry_label", + "name": "thumbnail", + "srcEntrance": "./ets/FormAbility/FormAbility.ts", + "type": "thumbnail", + "visible": true + }, + { + "description": "$string:form_description", + "descriptionId": 16777219, + "icon": "$media:icon", + "iconId": 16777225, + "label": "$string:entry_label", + "name": "preview", + "srcEntrance": "./ets/FormAbility/FormAbility.ts", + "type": "preview", + "visible": true + } + ], + "requestPermissions": [ + { + "name": "ohos.permission.GET_BUNDLE_INFO", + "reason": "$string:permission_reason", + "usedScene": { + "abilities": ["MainAbility"], + "when": "always" } + }, + { + "name": "ohos.permission.READ_CALENDAR", + "reason": "$string:permission_reason", + "usedScene": { + "abilities": ["MainAbility"], + "when": "inuse" + } + } + ], + "metadata": [ + { + "name": "MetaData1", + "value": "MetaDataValue", + "resource": "$profile:shortcuts_config" + } ] } } diff --git a/bundlemanager/bundle_standard/bundlemanager/actsbundlemanagerstagetest/entry/src/main/resources/base/element/string.json b/bundlemanager/bundle_standard/bundlemanager/actsbundlemanagerstagetest/entry/src/main/resources/base/element/string.json index aba81fb881f10cb0ee17a27e82b79cc0ffc7d13e..a4e9ba5b8d282aa4e86eb9389bf7c535226fd1c4 100755 --- a/bundlemanager/bundle_standard/bundlemanager/actsbundlemanagerstagetest/entry/src/main/resources/base/element/string.json +++ b/bundlemanager/bundle_standard/bundlemanager/actsbundlemanagerstagetest/entry/src/main/resources/base/element/string.json @@ -35,6 +35,10 @@ { "name": "form_FormAbility_label", "value": "form_label" + }, + { + "name": "permission_reason", + "value": "Need permission" } ] } diff --git a/bundlemanager/zlib/actszipfileandunzipfiletest/src/main/js/test/actszipfileandunzipfiletest.test.js b/bundlemanager/zlib/actszipfileandunzipfiletest/src/main/js/test/actszipfileandunzipfiletest.test.js index 82bd6f6a63ac898939a816e3715b34b14beae9f7..e3912b0da43c95575f3ab796f5c6cdf85ac28d05 100644 --- a/bundlemanager/zlib/actszipfileandunzipfiletest/src/main/js/test/actszipfileandunzipfiletest.test.js +++ b/bundlemanager/zlib/actszipfileandunzipfiletest/src/main/js/test/actszipfileandunzipfiletest.test.js @@ -20,1079 +20,1282 @@ import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from var dir = ""; var infos = ""; +var SRC_FILE_INVALID = 900001; + export default function ActsZlibTest() { -describe('ActsZlibTest', function () { - beforeEach(async (done) => { - var context = featureAbility.getContext(); - context.getCacheDir((err, data) => { - console.info('ActsZlibTest successful. Data:' + JSON.stringify(data)); - dir = data; - var objectone = "com.example.amsZipfileUnzipfileST.MainAbility/com.example.amsZipfileUnzipfileST/"; - var objecttwo = "com.example.amsZipfileUnzipfileST.MainAbility/com.example.amsZipfileUnzipfileST/zipunzip"; - var objectthree ="com.example.amsZipfileUnzipfileST.MainAbility/ActsZlibTest/example.amsZipfileUnzipfileST"; - infos =dir + objectone + objecttwo + objectthree; - done(); - }) - }); + describe('ActsZlibTest', function () { + beforeEach(async (done) => { + var context = featureAbility.getContext(); + context.getCacheDir((err, data) => { + console.info('ActsZlibTest successful. Data:' + JSON.stringify(data)); + dir = data; + var objectone = "com.example.amsZipfileUnzipfileST.MainAbility/com.example.amsZipfileUnzipfileST/"; + var objecttwo = "com.example.amsZipfileUnzipfileST.MainAbility/com.example.amsZipfileUnzipfileST/zipunzip"; + var objectthree = "com.example.amsZipfileUnzipfileST.MainAbility/ActsZlibTest/example.amsZipfileUnzipfileST"; + infos = dir + objectone + objecttwo + objectthree; + done(); + }) + }); -/* -* @tc.number: ACTS_ZipFile_0100 -* @tc.name: zipFile -* @tc.desc: inFile is empty -*/ -it('ACTS_ZipFile_0100', 0, async function (done) { - console.log("==================ACTS_ZipFile_0100 start=================="); - var path =""; - var zipDest = dir + "/ACTS_ZipFile_0100.zip" - var options = {}; - options.level = zlib.CompressLevel.COMPRESS_LEVEL_NO_COMPRESSION; - zlib.zipFile(path, zipDest, options).then((data) => { - console.log("ACTS_ZipFile_0100 data: " + data); - expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_ERRNO); - done(); - }).catch((err) => { - console.log("ACTS_ZipFile_0100 zipFile fail: " + err); - expect(err).assertEqual(zlib.ErrorCode.ERROR_CODE_ERRNO); - done(); - }) - console.log("==================ACTS_ZipFile_0100 end=================="); - }) + /* + * @tc.number: ACTS_ZipFile_0100 + * @tc.name: zipFile + * @tc.desc: inFile is empty + */ + it('ACTS_ZipFile_0100', 0, async function (done) { + console.log("==================ACTS_ZipFile_0100 start=================="); + var path = ""; + var zipDest = dir + "/ACTS_ZipFile_0100.zip" + var options = {}; + options.level = zlib.CompressLevel.COMPRESS_LEVEL_NO_COMPRESSION; + zlib.zipFile(path, zipDest, options).then((data) => { + console.log("ACTS_ZipFile_0100 data: " + data); + expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_ERRNO); + done(); + }).catch((err) => { + console.log("ACTS_ZipFile_0100 zipFile fail: " + err); + expect(err).assertEqual(zlib.ErrorCode.ERROR_CODE_ERRNO); + done(); + }) + console.log("==================ACTS_ZipFile_0100 end=================="); + }) -/* -* @tc.number: ACTS_ZipFile_0200 -* @tc.name: zipFile -* @tc.desc: inFile doesn't exist -*/ -it('ACTS_ZipFile_0200', 0, async function (done) { - console.log("==================ACTS_ZipFile_0200 start=================="); - var path = dir + "/ACTS_ZipFile_9999900.txt"; - var src = dir + "/ACTS_ZipFile_999991100.txt"; - var fd = fileio.openSync(path, 0o100 | 0o2, 0o666); - fileio.write(fd, infos).then(function (number) { - console.info("ACTS_ZipFile_0200 write data to file successfully:" + number); - var options = {}; - options.level = zlib.CompressLevel.COMPRESS_LEVEL_DEFAULT_COMPRESSION; - zlib.zipFile(src, dir, options).then((data) => { - console.log("ACTS_ZipFile_0200 data: " + data); - expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_ERRNO); - done(); - }).catch((err) => { - console.log("ACTS_ZipFile_0200 zipFile fail: " + err); - expect(err).assertEqual(zlib.ErrorCode.ERROR_CODE_ERRNO); - done(); - }) - }).catch(function (err) { - console.info("ACTS_ZipFile_0200 write data to file failed with error:" + err); - expect(err).assertFail(); - done(); - }); - console.log("==================ACTS_ZipFile_0200 end=================="); - }) + /* + * @tc.number: ACTS_ZipFile_0200 + * @tc.name: zipFile + * @tc.desc: inFile doesn't exist + */ + it('ACTS_ZipFile_0200', 0, async function (done) { + console.log("==================ACTS_ZipFile_0200 start=================="); + var path = dir + "/ACTS_ZipFile_9999900.txt"; + var src = dir + "/ACTS_ZipFile_999991100.txt"; + var fd = fileio.openSync(path, 0o100 | 0o2, 0o666); + fileio.write(fd, infos).then(function (number) { + console.info("ACTS_ZipFile_0200 write data to file successfully:" + number); + var options = {}; + options.level = zlib.CompressLevel.COMPRESS_LEVEL_DEFAULT_COMPRESSION; + zlib.zipFile(src, dir, options).then((data) => { + console.log("ACTS_ZipFile_0200 data: " + data); + expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_ERRNO); + done(); + }).catch((err) => { + console.log("ACTS_ZipFile_0200 zipFile fail: " + err); + expect(err).assertEqual(zlib.ErrorCode.ERROR_CODE_ERRNO); + done(); + }) + }).catch(function (err) { + console.info("ACTS_ZipFile_0200 write data to file failed with error:" + err); + expect(err).assertFail(); + done(); + }); + console.log("==================ACTS_ZipFile_0200 end=================="); + }) -/* -* @tc.number: ACTS_ZipFile_0300 -* @tc.name: zipFile -* @tc.desc: output file not specified -*/ -it('ACTS_ZipFile_0300', 0, async function (done) { - console.log("==================ACTS_ZipFile_0300 start=================="); - var path = dir + "/ACTS_ZipFile_0300.txt"; - var zipDest =""; - var fd = fileio.openSync(path, 0o100 | 0o2, 0o666); - fileio.write(fd, infos).then(function (number) { - console.info("ACTS_ZipFile_0300 write data to file successfully:" + number); - var options = {}; - options.level = zlib.CompressLevel.COMPRESS_LEVEL_DEFAULT_COMPRESSION; - zlib.zipFile(path, zipDest, options).then((data) => { - console.log("ACTS_ZipFile_0300 data: " + data); - expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_ERRNO); - done(); - }).catch((err) => { - console.log("ACTS_ZipFile_0300 zipFile fail: " + err); - expect(err).assertEqual(zlib.ErrorCode.ERROR_CODE_ERRNO); - done(); - }) - }).catch(function (err) { - console.info("ACTS_ZipFile_0300 write data to file failed with error:" + err); - expect(err).assertFail(); - done(); - }); - console.log("==================ACTS_ZipFile_0300 end=================="); - }) + /* + * @tc.number: ACTS_ZipFile_0300 + * @tc.name: zipFile + * @tc.desc: output file not specified + */ + it('ACTS_ZipFile_0300', 0, async function (done) { + console.log("==================ACTS_ZipFile_0300 start=================="); + var path = dir + "/ACTS_ZipFile_0300.txt"; + var zipDest = ""; + var fd = fileio.openSync(path, 0o100 | 0o2, 0o666); + fileio.write(fd, infos).then(function (number) { + console.info("ACTS_ZipFile_0300 write data to file successfully:" + number); + var options = {}; + options.level = zlib.CompressLevel.COMPRESS_LEVEL_DEFAULT_COMPRESSION; + zlib.zipFile(path, zipDest, options).then((data) => { + console.log("ACTS_ZipFile_0300 data: " + data); + expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_ERRNO); + done(); + }).catch((err) => { + console.log("ACTS_ZipFile_0300 zipFile fail: " + err); + expect(err).assertEqual(zlib.ErrorCode.ERROR_CODE_ERRNO); + done(); + }) + }).catch(function (err) { + console.info("ACTS_ZipFile_0300 write data to file failed with error:" + err); + expect(err).assertFail(); + done(); + }); + console.log("==================ACTS_ZipFile_0300 end=================="); + }) -/* -* @tc.number: ACTS_ZipFile_0400 -* @tc.name: zipFile -* @tc.desc: The output file is a directory that does not exist -*/ -it('ACTS_ZipFile_0400', 0, async function (done) { - console.log("==================ACTS_ZipFile_0400 start=================="); - var path = dir + "/ACTS_ZipFile_0400.txt"; - var zipDest ="/ACTS_ZipFile_0400.zip"; - var fd = fileio.openSync(path, 0o100 | 0o2, 0o666); - fileio.write(fd, infos).then(function (number) { - console.info("ACTS_ZipFile_0400 write data to file successfully:" + number); - var options = {}; - options.level = zlib.CompressLevel.COMPRESS_LEVEL_DEFAULT_COMPRESSION; - zlib.zipFile(path, zipDest, options).then((data) => { - console.log("ACTS_ZipFile_0400 data: " + data); - expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_ERRNO); - done(); - }).catch((err) => { - console.log("ACTS_ZipFile_0400 zipFile fail: " + err); - expect(err).assertEqual(zlib.ErrorCode.ERROR_CODE_ERRNO); - done(); - }) - }).catch(function (err) { - console.info("ACTS_ZipFile_0400 write data to file failed with error:" + err); - expect(err).assertFail(); - done(); - }); - console.log("==================ACTS_ZipFile_0400 end=================="); - }) + /* + * @tc.number: ACTS_ZipFile_0400 + * @tc.name: zipFile + * @tc.desc: The output file is a directory that does not exist + */ + it('ACTS_ZipFile_0400', 0, async function (done) { + console.log("==================ACTS_ZipFile_0400 start=================="); + var path = dir + "/ACTS_ZipFile_0400.txt"; + var zipDest = "/ACTS_ZipFile_0400.zip"; + var fd = fileio.openSync(path, 0o100 | 0o2, 0o666); + fileio.write(fd, infos).then(function (number) { + console.info("ACTS_ZipFile_0400 write data to file successfully:" + number); + var options = {}; + options.level = zlib.CompressLevel.COMPRESS_LEVEL_DEFAULT_COMPRESSION; + zlib.zipFile(path, zipDest, options).then((data) => { + console.log("ACTS_ZipFile_0400 data: " + data); + expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_ERRNO); + done(); + }).catch((err) => { + console.log("ACTS_ZipFile_0400 zipFile fail: " + err); + expect(err).assertEqual(zlib.ErrorCode.ERROR_CODE_ERRNO); + done(); + }) + }).catch(function (err) { + console.info("ACTS_ZipFile_0400 write data to file failed with error:" + err); + expect(err).assertFail(); + done(); + }); + console.log("==================ACTS_ZipFile_0400 end=================="); + }) -/* -* @tc.number: ACTS_ZipFile_2200 -* @tc.name: zipFile -* @tc.desc: COMPRESS_LEVEL_NO_COMPRESSION, -*/ -it('ACTS_ZipFile_2200', 0, async function (done) { - console.log("==================ACTS_ZipFile_2200 start=================="); - var path = dir + "/ACTS_ZipFile_2200.txt"; - var zipDest = dir + "/ACTS_ZipFile_2200.zip" - var unzipdir = dir + "/ACTS_ZipFile_2200"; - var unzipresultfile = unzipdir + "/ACTS_ZipFile_2200.txt"; - var options = {}; - options.level = zlib.CompressLevel.COMPRESS_LEVEL_NO_COMPRESSION; - var fd = fileio.openSync(path, 0o100 | 0o2, 0o666); - fileio.write(fd, infos).then(function (number) { - console.info("ACTS_ZipFile_2200 write data to file secondlly successfully:" + number); - zlib.zipFile(path, zipDest, options).then((data) => { - var zipStat = fileio.statSync(zipDest); - var isFile = zipStat.isFile(); - expect(isFile).assertTrue(); - var srcSize = fileio.statSync(path).size; - var destSize = zipStat.size; - expect(srcSize > destSize).assertTrue(); - expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK); - fileio.mkdir(unzipdir).then(function () { - console.info("ACTS_ZipFile_2200 mkdir successfully"); - zlib.unzipFile(zipDest, unzipdir, options).then((data) => { - var unzipStat = fileio.statSync(unzipresultfile); - var isFile = unzipStat.isFile(); - expect(isFile).assertTrue(); - var destSize = unzipStat.size; - var originSize = fileio.statSync(path).size; - var result = (originSize == destSize); - expect(result).assertTrue(); - expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK); - console.error('ACTS_ZipFile_2200 unzipFile'); - done(); - }).catch((err) => { - console.log("ACTS_ZipFile_2200 err: " + err); - expect(err).assertFail(); - done(); - }) - }).catch(function (error) { - console.info("ACTS_ZipFile_2200 mkdir failed with error:" + error); - expect(error).assertFail(); - done(); + /* + * @tc.number: ACTS_ZipFile_2200 + * @tc.name: zipFile + * @tc.desc: COMPRESS_LEVEL_NO_COMPRESSION, + */ + it('ACTS_ZipFile_2200', 0, async function (done) { + console.log("==================ACTS_ZipFile_2200 start=================="); + var path = dir + "/ACTS_ZipFile_2200.txt"; + var zipDest = dir + "/ACTS_ZipFile_2200.zip" + var unzipdir = dir + "/ACTS_ZipFile_2200"; + var unzipresultfile = unzipdir + "/ACTS_ZipFile_2200.txt"; + var options = {}; + options.level = zlib.CompressLevel.COMPRESS_LEVEL_NO_COMPRESSION; + var fd = fileio.openSync(path, 0o100 | 0o2, 0o666); + fileio.write(fd, infos).then(function (number) { + console.info("ACTS_ZipFile_2200 write data to file secondlly successfully:" + number); + zlib.zipFile(path, zipDest, options).then((data) => { + var zipStat = fileio.statSync(zipDest); + var isFile = zipStat.isFile(); + expect(isFile).assertTrue(); + var srcSize = fileio.statSync(path).size; + var destSize = zipStat.size; + expect(srcSize > destSize).assertTrue(); + expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK); + fileio.mkdir(unzipdir).then(function () { + console.info("ACTS_ZipFile_2200 mkdir successfully"); + zlib.unzipFile(zipDest, unzipdir, options).then((data) => { + var unzipStat = fileio.statSync(unzipresultfile); + var isFile = unzipStat.isFile(); + expect(isFile).assertTrue(); + var destSize = unzipStat.size; + var originSize = fileio.statSync(path).size; + var result = (originSize == destSize); + expect(result).assertTrue(); + expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK); + console.error('ACTS_ZipFile_2200 unzipFile'); + done(); + }).catch((err) => { + console.log("ACTS_ZipFile_2200 err: " + err); + expect(err).assertFail(); + done(); + }) + }).catch(function (error) { + console.info("ACTS_ZipFile_2200 mkdir failed with error:" + error); + expect(error).assertFail(); + done(); + }); + }).catch((err) => { + console.log("zipFile fail: " + err); + expect(err).assertFail(); + done(); + }) + }).catch(function (err) { + console.info("ACTS_ZipFile_2200 write data to file failed with error:" + err); + expect(err).assertFail(); + done(); + }); + console.log("==================ACTS_ZipFile_2200 end=================="); }); - }).catch((err) => { - console.log("zipFile fail: " + err); - expect(err).assertFail(); - done(); - }) - }).catch(function (err) { - console.info("ACTS_ZipFile_2200 write data to file failed with error:" + err); - expect(err).assertFail(); - done(); - }); - console.log("==================ACTS_ZipFile_2200 end=================="); - }); -/* -* @tc.number: ACTS_ZipFile_2300 -* @tc.name: zipFile -* @tc.desc: COMPRESS_LEVEL_BEST_SPEED, -*/ -it('ACTS_ZipFile_2300', 0, async function (done) { - console.log("==================ACTS_ZipFile_2300 start=================="); - var path = dir + "/ACTS_ZipFile_2300.txt"; - var zipDest = dir + "/ACTS_ZipFile_2300.zip" - var unzipdir = dir + "/ACTS_ZipFile_2300"; - var unzipresultfile = unzipdir + "/ACTS_ZipFile_2300.txt"; - var options = {}; - options.level = zlib.CompressLevel.COMPRESS_LEVEL_BEST_SPEED; - var fd = fileio.openSync(path, 0o100 | 0o2, 0o666); - fileio.write(fd, infos).then(function (number) { - console.info("ACTS_ZipFile_2300 write data to file successfully:" + number); - zlib.zipFile(path, zipDest, options).then((data) => { - var zipStat = fileio.statSync(zipDest); - var isFile = zipStat.isFile(); - expect(isFile).assertTrue(); - var srcSize = fileio.statSync(path).size; - var destSize = zipStat.size; - expect(srcSize > destSize).assertTrue(); - expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK); - fileio.mkdir(unzipdir).then(function () { - console.info("ACTS_ZipFile_2300 mkdir successfully"); - zlib.unzipFile(zipDest, unzipdir, options).then((data) => { - var unzipStat = fileio.statSync(unzipresultfile); - var isFile = unzipStat.isFile(); - expect(isFile).assertTrue(); - var destSize = unzipStat.size; - var originSize = fileio.statSync(path).size; - var result = (originSize == destSize); - expect(result).assertTrue(); - expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK); - console.error('ACTS_ZipFile_2300 unzipFile'); - done(); - }).catch((err) => { - console.log("ACTS_ZipFile_2300 err: " + err); - expect(err).assertFail(); - done(); - }) - }).catch(function (error) { - console.info("ACTS_ZipFile_2300 mkdir failed with error:" + error); - expect(error).assertFail(); - done(); - }); - }).catch((err) => { - console.log("zipFile fail: " + err); - expect(err).assertFail(); - done(); - }) - }).catch(function (err) { - console.info("ACTS_ZipFile_2300 write data to file failed with error:" + err); - expect(err).assertFail(); - done(); - }); - console.log("==================ACTS_ZipFile_2300 end=================="); - }) + /* + * @tc.number: ACTS_ZipFile_2300 + * @tc.name: zipFile + * @tc.desc: COMPRESS_LEVEL_BEST_SPEED, + */ + it('ACTS_ZipFile_2300', 0, async function (done) { + console.log("==================ACTS_ZipFile_2300 start=================="); + var path = dir + "/ACTS_ZipFile_2300.txt"; + var zipDest = dir + "/ACTS_ZipFile_2300.zip" + var unzipdir = dir + "/ACTS_ZipFile_2300"; + var unzipresultfile = unzipdir + "/ACTS_ZipFile_2300.txt"; + var options = {}; + options.level = zlib.CompressLevel.COMPRESS_LEVEL_BEST_SPEED; + var fd = fileio.openSync(path, 0o100 | 0o2, 0o666); + fileio.write(fd, infos).then(function (number) { + console.info("ACTS_ZipFile_2300 write data to file successfully:" + number); + zlib.zipFile(path, zipDest, options).then((data) => { + var zipStat = fileio.statSync(zipDest); + var isFile = zipStat.isFile(); + expect(isFile).assertTrue(); + var srcSize = fileio.statSync(path).size; + var destSize = zipStat.size; + expect(srcSize > destSize).assertTrue(); + expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK); + fileio.mkdir(unzipdir).then(function () { + console.info("ACTS_ZipFile_2300 mkdir successfully"); + zlib.unzipFile(zipDest, unzipdir, options).then((data) => { + var unzipStat = fileio.statSync(unzipresultfile); + var isFile = unzipStat.isFile(); + expect(isFile).assertTrue(); + var destSize = unzipStat.size; + var originSize = fileio.statSync(path).size; + var result = (originSize == destSize); + expect(result).assertTrue(); + expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK); + console.error('ACTS_ZipFile_2300 unzipFile'); + done(); + }).catch((err) => { + console.log("ACTS_ZipFile_2300 err: " + err); + expect(err).assertFail(); + done(); + }) + }).catch(function (error) { + console.info("ACTS_ZipFile_2300 mkdir failed with error:" + error); + expect(error).assertFail(); + done(); + }); + }).catch((err) => { + console.log("zipFile fail: " + err); + expect(err).assertFail(); + done(); + }) + }).catch(function (err) { + console.info("ACTS_ZipFile_2300 write data to file failed with error:" + err); + expect(err).assertFail(); + done(); + }); + console.log("==================ACTS_ZipFile_2300 end=================="); + }) -/* -* @tc.number: ACTS_ZipFile_2400 -* @tc.name: zipFile -* @tc.desc: COMPRESS_LEVEL_BEST_COMPRESSION, -*/ -it('ACTS_ZipFile_2400', 0, async function (done) { - console.log("==================ACTS_ZipFile_2400 start=================="); - var path = dir + "/ACTS_ZipFile_2400.txt"; - var zipDest = dir + "/ACTS_ZipFile_2400.zip" - var unzipdir = dir + "/ACTS_ZipFile_2400"; - var unzipresultfile = unzipdir + "/ACTS_ZipFile_2400.txt"; - var options = {}; - options.level = zlib.CompressLevel.COMPRESS_LEVEL_BEST_COMPRESSION; - var fd = fileio.openSync(path, 0o100 | 0o2, 0o666); - fileio.write(fd, infos).then(function (number) { - console.info("ACTS_ZipFile_2400 write data to file successfully:" + number); - zlib.zipFile(path, zipDest, options).then((data) => { - var zipStat = fileio.statSync(zipDest); - var isFile = zipStat.isFile(); - expect(isFile).assertTrue(); - var srcSize = fileio.statSync(path).size; - var destSize = zipStat.size; - expect(srcSize > destSize).assertTrue(); - expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK); - fileio.mkdir(unzipdir).then(function () { - console.info("ACTS_ZipFile_2400 mkdir successfully"); - zlib.unzipFile(zipDest, unzipdir, options).then((data) => { - var unzipStat = fileio.statSync(unzipresultfile); - var isFile = unzipStat.isFile(); - expect(isFile).assertTrue(); - var destSize = unzipStat.size; - var originSize = fileio.statSync(path).size; - var result = (originSize == destSize); - expect(result).assertTrue(); - expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK); - console.error('ACTS_ZipFile_2400 unzipFile'); - done(); - }).catch((err) => { - console.log("ACTS_ZipFile_2400 err: " + err); - expect(err).assertFail(); - done(); - }) - }).catch(function (error) { - console.info("ACTS_ZipFile_2400 mkdir failed with error:" + error); - expect(error).assertFail(); - done(); + /* + * @tc.number: ACTS_ZipFile_2400 + * @tc.name: zipFile + * @tc.desc: COMPRESS_LEVEL_BEST_COMPRESSION, + */ + it('ACTS_ZipFile_2400', 0, async function (done) { + console.log("==================ACTS_ZipFile_2400 start=================="); + var path = dir + "/ACTS_ZipFile_2400.txt"; + var zipDest = dir + "/ACTS_ZipFile_2400.zip" + var unzipdir = dir + "/ACTS_ZipFile_2400"; + var unzipresultfile = unzipdir + "/ACTS_ZipFile_2400.txt"; + var options = {}; + options.level = zlib.CompressLevel.COMPRESS_LEVEL_BEST_COMPRESSION; + var fd = fileio.openSync(path, 0o100 | 0o2, 0o666); + fileio.write(fd, infos).then(function (number) { + console.info("ACTS_ZipFile_2400 write data to file successfully:" + number); + zlib.zipFile(path, zipDest, options).then((data) => { + var zipStat = fileio.statSync(zipDest); + var isFile = zipStat.isFile(); + expect(isFile).assertTrue(); + var srcSize = fileio.statSync(path).size; + var destSize = zipStat.size; + expect(srcSize > destSize).assertTrue(); + expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK); + fileio.mkdir(unzipdir).then(function () { + console.info("ACTS_ZipFile_2400 mkdir successfully"); + zlib.unzipFile(zipDest, unzipdir, options).then((data) => { + var unzipStat = fileio.statSync(unzipresultfile); + var isFile = unzipStat.isFile(); + expect(isFile).assertTrue(); + var destSize = unzipStat.size; + var originSize = fileio.statSync(path).size; + var result = (originSize == destSize); + expect(result).assertTrue(); + expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK); + console.error('ACTS_ZipFile_2400 unzipFile'); + done(); + }).catch((err) => { + console.log("ACTS_ZipFile_2400 err: " + err); + expect(err).assertFail(); + done(); + }) + }).catch(function (error) { + console.info("ACTS_ZipFile_2400 mkdir failed with error:" + error); + expect(error).assertFail(); + done(); + }); + }).catch((err) => { + console.log("zipFile fail: " + err); + expect(err).assertFail(); + done(); + }) + }).catch(function (err) { + console.info("ACTS_ZipFile_2400 write data to file failed with error:" + err); + expect(err).assertFail(); + done(); + }); + console.log("==================ACTS_ZipFile_2400 end=================="); }); - }).catch((err) => { - console.log("zipFile fail: " + err); - expect(err).assertFail(); - done(); - }) - }).catch(function (err) { - console.info("ACTS_ZipFile_2400 write data to file failed with error:" + err); - expect(err).assertFail(); - done(); - }); - console.log("==================ACTS_ZipFile_2400 end=================="); - }); -/* -* @tc.number: ACTS_ZipFile_2500 -* @tc.name: zipFile -* @tc.desc: COMPRESS_LEVEL_DEFAULT_COMPRESSION, -*/ -it('ACTS_ZipFile_2500', 0, async function (done) { - console.log("==================ACTS_ZipFile_2500 start=================="); - var path = dir + "/ACTS_ZipFile_2500.txt"; - var zipDest = dir + "/ACTS_ZipFile_2500.zip" - var unzipdir = dir + "/ACTS_ZipFile_2500"; - var unzipresultfile = unzipdir + "/ACTS_ZipFile_2500.txt"; - var options = {}; - options.level = zlib.CompressLevel.COMPRESS_LEVEL_DEFAULT_COMPRESSION; - var fd = fileio.openSync(path, 0o100 | 0o2, 0o666); - fileio.write(fd, infos).then(function (number) { - console.info("ACTS_ZipFile_2500 write data to file successfully:" + number); - zlib.zipFile(path, zipDest, options).then((data) => { - var zipStat = fileio.statSync(zipDest); - var isFile = zipStat.isFile(); - expect(isFile).assertTrue(); - var srcSize = fileio.statSync(path).size; - var destSize = zipStat.size; - expect(srcSize > destSize).assertTrue(); - expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK); - fileio.mkdir(unzipdir).then(function () { - console.info("ACTS_ZipFile_2500 mkdir successfully"); - zlib.unzipFile(zipDest, unzipdir, options).then((data) => { - var unzipStat = fileio.statSync(unzipresultfile); - var isFile = unzipStat.isFile(); - expect(isFile).assertTrue(); - var destSize = unzipStat.size; - var originSize = fileio.statSync(path).size; - var result = (originSize == destSize); - expect(result).assertTrue(); - expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK); - console.error('ACTS_ZipFile_2500 unzipFile'); - done(); - }).catch((err) => { - console.log("ACTS_ZipFile_2500 err: " + err); - expect(err).assertFail(); - done() - }) - }).catch(function (error) { - console.info("ACTS_ZipFile_2500 mkdir failed with error:" + error); - expect(error).assertFail(); - done(); + /* + * @tc.number: ACTS_ZipFile_2500 + * @tc.name: zipFile + * @tc.desc: COMPRESS_LEVEL_DEFAULT_COMPRESSION, + */ + it('ACTS_ZipFile_2500', 0, async function (done) { + console.log("==================ACTS_ZipFile_2500 start=================="); + var path = dir + "/ACTS_ZipFile_2500.txt"; + var zipDest = dir + "/ACTS_ZipFile_2500.zip" + var unzipdir = dir + "/ACTS_ZipFile_2500"; + var unzipresultfile = unzipdir + "/ACTS_ZipFile_2500.txt"; + var options = {}; + options.level = zlib.CompressLevel.COMPRESS_LEVEL_DEFAULT_COMPRESSION; + var fd = fileio.openSync(path, 0o100 | 0o2, 0o666); + fileio.write(fd, infos).then(function (number) { + console.info("ACTS_ZipFile_2500 write data to file successfully:" + number); + zlib.zipFile(path, zipDest, options).then((data) => { + var zipStat = fileio.statSync(zipDest); + var isFile = zipStat.isFile(); + expect(isFile).assertTrue(); + var srcSize = fileio.statSync(path).size; + var destSize = zipStat.size; + expect(srcSize > destSize).assertTrue(); + expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK); + fileio.mkdir(unzipdir).then(function () { + console.info("ACTS_ZipFile_2500 mkdir successfully"); + zlib.unzipFile(zipDest, unzipdir, options).then((data) => { + var unzipStat = fileio.statSync(unzipresultfile); + var isFile = unzipStat.isFile(); + expect(isFile).assertTrue(); + var destSize = unzipStat.size; + var originSize = fileio.statSync(path).size; + var result = (originSize == destSize); + expect(result).assertTrue(); + expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK); + console.error('ACTS_ZipFile_2500 unzipFile'); + done(); + }).catch((err) => { + console.log("ACTS_ZipFile_2500 err: " + err); + expect(err).assertFail(); + done() + }) + }).catch(function (error) { + console.info("ACTS_ZipFile_2500 mkdir failed with error:" + error); + expect(error).assertFail(); + done(); + }); + }).catch((err) => { + console.log("zipFile fail: " + err); + expect(err).assertFail(); + done(); + }) + }).catch(function (err) { + console.info("ACTS_ZipFile_2500 write data to file failed with error:" + err); + expect(err).assertFail(); + done(); + }); + console.log("==================ACTS_ZipFile_2500 end=================="); }); - }).catch((err) => { - console.log("zipFile fail: " + err); - expect(err).assertFail(); - done(); - }) - }).catch(function (err) { - console.info("ACTS_ZipFile_2500 write data to file failed with error:" + err); - expect(err).assertFail(); - done(); - }); - console.log("==================ACTS_ZipFile_2500 end=================="); - }); -/* -* @tc.number: ACTS_ZipFile_2600 -* @tc.name: zipFile -* @tc.desc: MEM_LEVEL_MIN_MEMLEVEL,, -*/ -it('ACTS_ZipFile_2600', 0, async function (done) { - console.log("==================ACTS_ZipFile_2600 start=================="); - var path = dir + "/ACTS_ZipFile_2600.txt"; - var zipDest = dir + "/ACTS_ZipFile_2600.zip" - var unzipdir = dir + "/ACTS_ZipFile_2600"; - var unzipresultfile = unzipdir + "/ACTS_ZipFile_2600.txt"; - var options = {}; - options.memLevel = zlib.MemLevel.MEM_LEVEL_MIN; - var fd = fileio.openSync(path, 0o100 | 0o2, 0o666); - fileio.write(fd, infos).then(function (number) { - console.info("ACTS_ZipFile_2600 write data to file successfully:" + number); - zlib.zipFile(path, zipDest, options).then((data) => { - var zipStat = fileio.statSync(zipDest); - var isFile = zipStat.isFile(); - expect(isFile).assertTrue(); - var srcSize = fileio.statSync(path).size; - var destSize = zipStat.size; - expect(srcSize > destSize).assertTrue(); - expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK); - fileio.mkdir(unzipdir).then(function () { - console.info("ACTS_ZipFile_2600 mkdir successfully"); - zlib.unzipFile(zipDest, unzipdir, options).then((data) => { - var unzipStat = fileio.statSync(unzipresultfile); - var isFile = unzipStat.isFile(); - expect(isFile).assertTrue(); - var destSize = unzipStat.size; - var originSize = fileio.statSync(path).size; - var result = (originSize == destSize); - expect(result).assertTrue(); - expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK); - console.error('ACTS_ZipFile_2600 unzipFile'); - done(); - }).catch((err) => { - console.log("ACTS_ZipFile_2600 err: " + err); - expect(err).assertFail(); - done(); - }) - }).catch(function (error) { - console.info("ACTS_ZipFile_2600 mkdir failed with error:" + error); - expect(error).assertFail(); - done(); + /* + * @tc.number: ACTS_ZipFile_2600 + * @tc.name: zipFile + * @tc.desc: MEM_LEVEL_MIN_MEMLEVEL,, + */ + it('ACTS_ZipFile_2600', 0, async function (done) { + console.log("==================ACTS_ZipFile_2600 start=================="); + var path = dir + "/ACTS_ZipFile_2600.txt"; + var zipDest = dir + "/ACTS_ZipFile_2600.zip" + var unzipdir = dir + "/ACTS_ZipFile_2600"; + var unzipresultfile = unzipdir + "/ACTS_ZipFile_2600.txt"; + var options = {}; + options.memLevel = zlib.MemLevel.MEM_LEVEL_MIN; + var fd = fileio.openSync(path, 0o100 | 0o2, 0o666); + fileio.write(fd, infos).then(function (number) { + console.info("ACTS_ZipFile_2600 write data to file successfully:" + number); + zlib.zipFile(path, zipDest, options).then((data) => { + var zipStat = fileio.statSync(zipDest); + var isFile = zipStat.isFile(); + expect(isFile).assertTrue(); + var srcSize = fileio.statSync(path).size; + var destSize = zipStat.size; + expect(srcSize > destSize).assertTrue(); + expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK); + fileio.mkdir(unzipdir).then(function () { + console.info("ACTS_ZipFile_2600 mkdir successfully"); + zlib.unzipFile(zipDest, unzipdir, options).then((data) => { + var unzipStat = fileio.statSync(unzipresultfile); + var isFile = unzipStat.isFile(); + expect(isFile).assertTrue(); + var destSize = unzipStat.size; + var originSize = fileio.statSync(path).size; + var result = (originSize == destSize); + expect(result).assertTrue(); + expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK); + console.error('ACTS_ZipFile_2600 unzipFile'); + done(); + }).catch((err) => { + console.log("ACTS_ZipFile_2600 err: " + err); + expect(err).assertFail(); + done(); + }) + }).catch(function (error) { + console.info("ACTS_ZipFile_2600 mkdir failed with error:" + error); + expect(error).assertFail(); + done(); + }); + }).catch((err) => { + console.log("zipFile fail: " + err); + expect(err).assertFail(); + done(); + }) + }).catch(function (err) { + console.info("ACTS_ZipFile_2600 write data to file failed with error:" + err); + expect(err).assertFail(); + done(); + }); + console.log("==================ACTS_ZipFile_2600 end=================="); }); - }).catch((err) => { - console.log("zipFile fail: " + err); - expect(err).assertFail(); - done(); - }) - }).catch(function (err) { - console.info("ACTS_ZipFile_2600 write data to file failed with error:" + err); - expect(err).assertFail(); - done(); - }); - console.log("==================ACTS_ZipFile_2600 end=================="); - }); -/* -* @tc.number: ACTS_ZipFile_2700 -* @tc.name: zipFile -* @tc.desc: MEM_LEVEL_MAX_MEMLEVEL,, -*/ -it('ACTS_ZipFile_2700', 0, async function (done) { - console.log("==================ACTS_ZipFile_2700 start=================="); - var path = dir + "/ACTS_ZipFile_2700.txt"; - var zipDest = dir + "/ACTS_ZipFile_2700.zip" - var unzipdir = dir + "/ACTS_ZipFile_2700"; - var unzipresultfile = unzipdir + "/ACTS_ZipFile_2700.txt"; - var options = {}; - options.memLevel = zlib.MemLevel.MEM_LEVEL_MAX; - var fd = fileio.openSync(path, 0o100 | 0o2, 0o666); - fileio.write(fd, infos).then(function (number) { - console.info("ACTS_ZipFile_2700 write data to file successfully:" + number); - zlib.zipFile(path, zipDest, options).then((data) => { - var zipStat = fileio.statSync(zipDest); - var isFile = zipStat.isFile(); - expect(isFile).assertTrue(); - var srcSize = fileio.statSync(path).size; - var destSize = zipStat.size; - expect(srcSize > destSize).assertTrue(); - expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK); - fileio.mkdir(unzipdir).then(function () { - console.info("ACTS_ZipFile_2700 mkdir successfully"); - zlib.unzipFile(zipDest, unzipdir, options).then((data) => { - var unzipStat = fileio.statSync(unzipresultfile); - var isFile = unzipStat.isFile(); - expect(isFile).assertTrue(); - var destSize = unzipStat.size; - var originSize = fileio.statSync(path).size; - var result = (originSize == destSize); - expect(result).assertTrue(); - expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK); - console.error('ACTS_ZipFile_2700 unzipFile'); - done(); - }).catch((err) => { - console.log("ACTS_ZipFile_2700 err: " + err); - expect(err).assertFail(); - done(); - }) - }).catch(function (error) { - console.info("ACTS_ZipFile_2700 mkdir failed with error:" + error); - expect(error).assertFail(); - done(); + /* + * @tc.number: ACTS_ZipFile_2700 + * @tc.name: zipFile + * @tc.desc: MEM_LEVEL_MAX_MEMLEVEL,, + */ + it('ACTS_ZipFile_2700', 0, async function (done) { + console.log("==================ACTS_ZipFile_2700 start=================="); + var path = dir + "/ACTS_ZipFile_2700.txt"; + var zipDest = dir + "/ACTS_ZipFile_2700.zip" + var unzipdir = dir + "/ACTS_ZipFile_2700"; + var unzipresultfile = unzipdir + "/ACTS_ZipFile_2700.txt"; + var options = {}; + options.memLevel = zlib.MemLevel.MEM_LEVEL_MAX; + var fd = fileio.openSync(path, 0o100 | 0o2, 0o666); + fileio.write(fd, infos).then(function (number) { + console.info("ACTS_ZipFile_2700 write data to file successfully:" + number); + zlib.zipFile(path, zipDest, options).then((data) => { + var zipStat = fileio.statSync(zipDest); + var isFile = zipStat.isFile(); + expect(isFile).assertTrue(); + var srcSize = fileio.statSync(path).size; + var destSize = zipStat.size; + expect(srcSize > destSize).assertTrue(); + expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK); + fileio.mkdir(unzipdir).then(function () { + console.info("ACTS_ZipFile_2700 mkdir successfully"); + zlib.unzipFile(zipDest, unzipdir, options).then((data) => { + var unzipStat = fileio.statSync(unzipresultfile); + var isFile = unzipStat.isFile(); + expect(isFile).assertTrue(); + var destSize = unzipStat.size; + var originSize = fileio.statSync(path).size; + var result = (originSize == destSize); + expect(result).assertTrue(); + expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK); + console.error('ACTS_ZipFile_2700 unzipFile'); + done(); + }).catch((err) => { + console.log("ACTS_ZipFile_2700 err: " + err); + expect(err).assertFail(); + done(); + }) + }).catch(function (error) { + console.info("ACTS_ZipFile_2700 mkdir failed with error:" + error); + expect(error).assertFail(); + done(); + }); + }).catch((err) => { + console.log("zipFile fail: " + err); + expect(err).assertFail(); + done(); + }) + }).catch(function (err) { + console.info("ACTS_ZipFile_2700 write data to file failed with error:" + err); + expect(err).assertFail(); + done(); + }); + console.log("==================ACTS_ZipFile_2700 end=================="); }); - }).catch((err) => { - console.log("zipFile fail: " + err); - expect(err).assertFail(); - done(); - }) - }).catch(function (err) { - console.info("ACTS_ZipFile_2700 write data to file failed with error:" + err); - expect(err).assertFail(); - done(); - }); - console.log("==================ACTS_ZipFile_2700 end=================="); - }); -/* -* @tc.number: ACTS_ZipFile_2800 -* @tc.name: zipFile -* @tc.desc: MEM_LEVEL_DEFAULT_MEMLEVEL,, -*/ -it('ACTS_ZipFile_2800', 0, async function (done) { - console.log("==================ACTS_ZipFile_2800 start=================="); - var path = dir + "/ACTS_ZipFile_2800.txt"; - var zipDest = dir + "/ACTS_ZipFile_2800.zip" - var unzipdir = dir + "/ACTS_ZipFile_2800"; - var unzipresultfile = unzipdir + "/ACTS_ZipFile_2800.txt"; - var options = {}; - options.memLevel = zlib.MemLevel.MEM_LEVEL_DEFAULT; - var fd = fileio.openSync(path, 0o100 | 0o2, 0o666); - fileio.write(fd, infos).then(function (number) { - console.info("ACTS_ZipFile_2800 write data to file successfully:" + number); - zlib.zipFile(path, zipDest, options).then((data) => { - var zipStat = fileio.statSync(zipDest); - var isFile = zipStat.isFile(); - expect(isFile).assertTrue(); - var srcSize = fileio.statSync(path).size; - var destSize = zipStat.size; - expect(srcSize > destSize).assertTrue(); - expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK); - fileio.mkdir(unzipdir).then(function () { - console.info("ACTS_ZipFile_2800 mkdir successfully"); - zlib.unzipFile(zipDest, unzipdir, options).then((data) => { - var unzipStat = fileio.statSync(unzipresultfile); - var isFile = unzipStat.isFile(); - expect(isFile).assertTrue(); - var destSize = unzipStat.size; - var originSize = fileio.statSync(path).size; - var result = (originSize == destSize); - expect(result).assertTrue(); - expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK); - console.error('ACTS_ZipFile_2800 unzipFile'); - done(); - }).catch((err) => { - console.log("ACTS_ZipFile_2800 err: " + err); - expect(err).assertFail(); - done(); - }) - }).catch(function (error) { - console.info("ACTS_ZipFile_2800 mkdir failed with error:" + error); - expect(error).assertFail(); - done(); + /* + * @tc.number: ACTS_ZipFile_2800 + * @tc.name: zipFile + * @tc.desc: MEM_LEVEL_DEFAULT_MEMLEVEL,, + */ + it('ACTS_ZipFile_2800', 0, async function (done) { + console.log("==================ACTS_ZipFile_2800 start=================="); + var path = dir + "/ACTS_ZipFile_2800.txt"; + var zipDest = dir + "/ACTS_ZipFile_2800.zip" + var unzipdir = dir + "/ACTS_ZipFile_2800"; + var unzipresultfile = unzipdir + "/ACTS_ZipFile_2800.txt"; + var options = {}; + options.memLevel = zlib.MemLevel.MEM_LEVEL_DEFAULT; + var fd = fileio.openSync(path, 0o100 | 0o2, 0o666); + fileio.write(fd, infos).then(function (number) { + console.info("ACTS_ZipFile_2800 write data to file successfully:" + number); + zlib.zipFile(path, zipDest, options).then((data) => { + var zipStat = fileio.statSync(zipDest); + var isFile = zipStat.isFile(); + expect(isFile).assertTrue(); + var srcSize = fileio.statSync(path).size; + var destSize = zipStat.size; + expect(srcSize > destSize).assertTrue(); + expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK); + fileio.mkdir(unzipdir).then(function () { + console.info("ACTS_ZipFile_2800 mkdir successfully"); + zlib.unzipFile(zipDest, unzipdir, options).then((data) => { + var unzipStat = fileio.statSync(unzipresultfile); + var isFile = unzipStat.isFile(); + expect(isFile).assertTrue(); + var destSize = unzipStat.size; + var originSize = fileio.statSync(path).size; + var result = (originSize == destSize); + expect(result).assertTrue(); + expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK); + console.error('ACTS_ZipFile_2800 unzipFile'); + done(); + }).catch((err) => { + console.log("ACTS_ZipFile_2800 err: " + err); + expect(err).assertFail(); + done(); + }) + }).catch(function (error) { + console.info("ACTS_ZipFile_2800 mkdir failed with error:" + error); + expect(error).assertFail(); + done(); + }); + }).catch((err) => { + console.log("zipFile fail: " + err); + expect(err).assertFail(); + done(); + }) + }).catch(function (err) { + console.info("ACTS_ZipFile_2800 write data to file failed with error:" + err); + expect(err).assertFail(); + done(); + }); + console.log("==================ACTS_ZipFile_2800 end=================="); }); - }).catch((err) => { - console.log("zipFile fail: " + err); - expect(err).assertFail(); - done(); - }) - }).catch(function (err) { - console.info("ACTS_ZipFile_2800 write data to file failed with error:" + err); - expect(err).assertFail(); - done(); - }); - console.log("==================ACTS_ZipFile_2800 end=================="); - }); -/* -* @tc.number: ACTS_ZipFile_2900 -* @tc.name: zipFile -* @tc.desc: COMPRESS_STRATEGY_DEFAULT_STRATEGY,, -*/ -it('ACTS_ZipFile_2900', 0, async function (done) { - console.log("==================ACTS_ZipFile_2900 start=================="); - var path = dir + "/ACTS_ZipFile_2900.txt"; - var zipDest = dir + "/ACTS_ZipFile_2900.zip" - var unzipdir = dir + "/ACTS_ZipFile_2900"; - var unzipresultfile = unzipdir + "/ACTS_ZipFile_2900.txt"; - var options = {}; - options.strategy = zlib.CompressStrategy.COMPRESS_STRATEGY_DEFAULT_STRATEGY; - var fd = fileio.openSync(path, 0o100 | 0o2, 0o666); - fileio.write(fd, infos).then(function (number) { - console.info("ACTS_ZipFile_2900 write data to file successfully:" + number); - zlib.zipFile(path, zipDest, options).then((data) => { - var zipStat = fileio.statSync(zipDest); - var isFile = zipStat.isFile(); - expect(isFile).assertTrue(); - var srcSize = fileio.statSync(path).size; - var destSize = zipStat.size; - expect(srcSize > destSize).assertTrue(); - expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK); - fileio.mkdir(unzipdir).then(function () { - console.info("ACTS_ZipFile_2900 mkdir successfully"); - zlib.unzipFile(zipDest, unzipdir, options).then((data) => { - var unzipStat = fileio.statSync(unzipresultfile); - var isFile = unzipStat.isFile(); - expect(isFile).assertTrue(); - var destSize = unzipStat.size; - var originSize = fileio.statSync(path).size; - var result = (originSize == destSize); - expect(result).assertTrue(); - expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK); - console.error('ACTS_ZipFile_2900 unzipFile'); - done(); - }).catch((err) => { - console.log("ACTS_ZipFile_2900 err: " + err); - expect(err).assertFail(); - done(); - }) - }).catch(function (error) { - console.info("ACTS_ZipFile_2900 mkdir failed with error:" + error); - expect(error).assertFail(); - done(); - }); - }).catch((err) => { - console.log("zipFile fail: " + err); - expect(err).assertFail(); - done(); - }) - }).catch(function (err) { - console.info("ACTS_ZipFile_2900 write data to file failed with error:" + err); - expect(err).assertFail(); - done(); - }); - console.log("==================ACTS_ZipFile_2900 end=================="); - }); + /* + * @tc.number: ACTS_ZipFile_2900 + * @tc.name: zipFile + * @tc.desc: COMPRESS_STRATEGY_DEFAULT_STRATEGY,, + */ + it('ACTS_ZipFile_2900', 0, async function (done) { + console.log("==================ACTS_ZipFile_2900 start=================="); + var path = dir + "/ACTS_ZipFile_2900.txt"; + var zipDest = dir + "/ACTS_ZipFile_2900.zip" + var unzipdir = dir + "/ACTS_ZipFile_2900"; + var unzipresultfile = unzipdir + "/ACTS_ZipFile_2900.txt"; + var options = {}; + options.strategy = zlib.CompressStrategy.COMPRESS_STRATEGY_DEFAULT_STRATEGY; + var fd = fileio.openSync(path, 0o100 | 0o2, 0o666); + fileio.write(fd, infos).then(function (number) { + console.info("ACTS_ZipFile_2900 write data to file successfully:" + number); + zlib.zipFile(path, zipDest, options).then((data) => { + var zipStat = fileio.statSync(zipDest); + var isFile = zipStat.isFile(); + expect(isFile).assertTrue(); + var srcSize = fileio.statSync(path).size; + var destSize = zipStat.size; + expect(srcSize > destSize).assertTrue(); + expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK); + fileio.mkdir(unzipdir).then(function () { + console.info("ACTS_ZipFile_2900 mkdir successfully"); + zlib.unzipFile(zipDest, unzipdir, options).then((data) => { + var unzipStat = fileio.statSync(unzipresultfile); + var isFile = unzipStat.isFile(); + expect(isFile).assertTrue(); + var destSize = unzipStat.size; + var originSize = fileio.statSync(path).size; + var result = (originSize == destSize); + expect(result).assertTrue(); + expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK); + console.error('ACTS_ZipFile_2900 unzipFile'); + done(); + }).catch((err) => { + console.log("ACTS_ZipFile_2900 err: " + err); + expect(err).assertFail(); + done(); + }) + }).catch(function (error) { + console.info("ACTS_ZipFile_2900 mkdir failed with error:" + error); + expect(error).assertFail(); + done(); + }); + }).catch((err) => { + console.log("zipFile fail: " + err); + expect(err).assertFail(); + done(); + }) + }).catch(function (err) { + console.info("ACTS_ZipFile_2900 write data to file failed with error:" + err); + expect(err).assertFail(); + done(); + }); + console.log("==================ACTS_ZipFile_2900 end=================="); + }); -/* -* @tc.number: ACTS_ZipFile_3000 -* @tc.name: zipFile -* @tc.desc: COMPRESS_STRATEGY_FILTERED,, -*/ -it('ACTS_ZipFile_3000', 0, async function (done) { - console.log("==================ACTS_ZipFile_3000 start=================="); - var path = dir + "/ACTS_ZipFile_3000.txt"; - var zipDest = dir + "/ACTS_ZipFile_3000.zip" - var unzipdir = dir + "/ACTS_ZipFile_3000"; - var unzipresultfile = unzipdir + "/ACTS_ZipFile_3000.txt"; - var options = {}; - options.strategy = zlib.CompressStrategy.COMPRESS_STRATEGY_FILTERED; - var fd = fileio.openSync(path, 0o100 | 0o2, 0o666); - fileio.write(fd, infos).then(function (number) { - console.info("ACTS_ZipFile_3000 write data to file successfully:" + number); - zlib.zipFile(path, zipDest, options).then((data) => { - var zipStat = fileio.statSync(zipDest); - var isFile = zipStat.isFile(); - expect(isFile).assertTrue(); - var srcSize = fileio.statSync(path).size; - var destSize = zipStat.size; - expect(srcSize > destSize).assertTrue(); - expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK); - fileio.mkdir(unzipdir).then(function () { - console.info("ACTS_ZipFile_3000 mkdir successfully"); - zlib.unzipFile(zipDest, unzipdir, options).then((data) => { - var unzipStat = fileio.statSync(unzipresultfile); - var isFile = unzipStat.isFile(); - expect(isFile).assertTrue(); - var destSize = unzipStat.size; - var originSize = fileio.statSync(path).size; - var result = (originSize == destSize); - expect(result).assertTrue(); - expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK); - console.error('ACTS_ZipFile_3000 unzipFile'); - done(); - }).catch((err) => { - console.log("ACTS_ZipFile_3000 err: " + err); - expect(err).assertFail(); - done(); - }) - }).catch(function (error) { - console.info("ACTS_ZipFile_3000 mkdir failed with error:" + error); - expect(error).assertFail(); - done(); + /* + * @tc.number: ACTS_ZipFile_3000 + * @tc.name: zipFile + * @tc.desc: COMPRESS_STRATEGY_FILTERED,, + */ + it('ACTS_ZipFile_3000', 0, async function (done) { + console.log("==================ACTS_ZipFile_3000 start=================="); + var path = dir + "/ACTS_ZipFile_3000.txt"; + var zipDest = dir + "/ACTS_ZipFile_3000.zip" + var unzipdir = dir + "/ACTS_ZipFile_3000"; + var unzipresultfile = unzipdir + "/ACTS_ZipFile_3000.txt"; + var options = {}; + options.strategy = zlib.CompressStrategy.COMPRESS_STRATEGY_FILTERED; + var fd = fileio.openSync(path, 0o100 | 0o2, 0o666); + fileio.write(fd, infos).then(function (number) { + console.info("ACTS_ZipFile_3000 write data to file successfully:" + number); + zlib.zipFile(path, zipDest, options).then((data) => { + var zipStat = fileio.statSync(zipDest); + var isFile = zipStat.isFile(); + expect(isFile).assertTrue(); + var srcSize = fileio.statSync(path).size; + var destSize = zipStat.size; + expect(srcSize > destSize).assertTrue(); + expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK); + fileio.mkdir(unzipdir).then(function () { + console.info("ACTS_ZipFile_3000 mkdir successfully"); + zlib.unzipFile(zipDest, unzipdir, options).then((data) => { + var unzipStat = fileio.statSync(unzipresultfile); + var isFile = unzipStat.isFile(); + expect(isFile).assertTrue(); + var destSize = unzipStat.size; + var originSize = fileio.statSync(path).size; + var result = (originSize == destSize); + expect(result).assertTrue(); + expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK); + console.error('ACTS_ZipFile_3000 unzipFile'); + done(); + }).catch((err) => { + console.log("ACTS_ZipFile_3000 err: " + err); + expect(err).assertFail(); + done(); + }) + }).catch(function (error) { + console.info("ACTS_ZipFile_3000 mkdir failed with error:" + error); + expect(error).assertFail(); + done(); + }); + }).catch((err) => { + console.log("zipFile fail: " + err); + expect(err).assertFail(); + done(); + }) + }).catch(function (err) { + console.info("ACTS_ZipFile_3000 write data to file failed with error:" + err); + expect(err).assertFail(); + done(); + }); + console.log("==================ACTS_ZipFile_3000 end=================="); }); - }).catch((err) => { - console.log("zipFile fail: " + err); - expect(err).assertFail(); - done(); - }) - }).catch(function (err) { - console.info("ACTS_ZipFile_3000 write data to file failed with error:" + err); - expect(err).assertFail(); - done(); - }); - console.log("==================ACTS_ZipFile_3000 end=================="); - }); -/* -* @tc.number: ACTS_ZipFile_3100 -* @tc.name: zipFile -* @tc.desc: COMPRESS_STRATEGY_HUFFMAN_ONLY,, -*/ -it('ACTS_ZipFile_3100', 0, async function (done) { - console.log("==================ACTS_ZipFile_3100 start=================="); - var path = dir + "/ACTS_ZipFile_3100.txt"; - var zipDest = dir + "/ACTS_ZipFile_3100.zip" - var unzipdir = dir + "/ACTS_ZipFile_3100"; - var unzipresultfile = unzipdir + "/ACTS_ZipFile_3100.txt"; - var options = {}; - options.strategy = zlib.CompressStrategy.COMPRESS_STRATEGY_HUFFMAN_ONLY; - var fd = fileio.openSync(path, 0o100 | 0o2, 0o666); - fileio.write(fd, infos).then(function (number) { - console.info("ACTS_ZipFile_3100 write data to file successfully:" + number); - zlib.zipFile(path, zipDest, options).then((data) => { - var zipStat = fileio.statSync(zipDest); - var isFile = zipStat.isFile(); - expect(isFile).assertTrue(); - var srcSize = fileio.statSync(path).size; - var destSize = zipStat.size; - expect(srcSize > destSize).assertTrue(); - expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK); - fileio.mkdir(unzipdir).then(function () { - console.info("ACTS_ZipFile_3100 mkdir successfully"); - zlib.unzipFile(zipDest, unzipdir, options).then((data) => { - var unzipStat = fileio.statSync(unzipresultfile); - var isFile = unzipStat.isFile(); - expect(isFile).assertTrue(); - var destSize = unzipStat.size; - var originSize = fileio.statSync(path).size; - var result = (originSize == destSize); - expect(result).assertTrue(); - expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK); - console.error('ACTS_ZipFile_3100 unzipFile'); - done(); - }).catch((err) => { - console.log("ACTS_ZipFile_3100 err: " + err); - expect(err).assertFail(); - done(); - }) - }).catch(function (error) { - console.info("ACTS_ZipFile_3100 mkdir failed with error:" + error); - expect(error).assertFail(); - done(); + /* + * @tc.number: ACTS_ZipFile_3100 + * @tc.name: zipFile + * @tc.desc: COMPRESS_STRATEGY_HUFFMAN_ONLY,, + */ + it('ACTS_ZipFile_3100', 0, async function (done) { + console.log("==================ACTS_ZipFile_3100 start=================="); + var path = dir + "/ACTS_ZipFile_3100.txt"; + var zipDest = dir + "/ACTS_ZipFile_3100.zip" + var unzipdir = dir + "/ACTS_ZipFile_3100"; + var unzipresultfile = unzipdir + "/ACTS_ZipFile_3100.txt"; + var options = {}; + options.strategy = zlib.CompressStrategy.COMPRESS_STRATEGY_HUFFMAN_ONLY; + var fd = fileio.openSync(path, 0o100 | 0o2, 0o666); + fileio.write(fd, infos).then(function (number) { + console.info("ACTS_ZipFile_3100 write data to file successfully:" + number); + zlib.zipFile(path, zipDest, options).then((data) => { + var zipStat = fileio.statSync(zipDest); + var isFile = zipStat.isFile(); + expect(isFile).assertTrue(); + var srcSize = fileio.statSync(path).size; + var destSize = zipStat.size; + expect(srcSize > destSize).assertTrue(); + expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK); + fileio.mkdir(unzipdir).then(function () { + console.info("ACTS_ZipFile_3100 mkdir successfully"); + zlib.unzipFile(zipDest, unzipdir, options).then((data) => { + var unzipStat = fileio.statSync(unzipresultfile); + var isFile = unzipStat.isFile(); + expect(isFile).assertTrue(); + var destSize = unzipStat.size; + var originSize = fileio.statSync(path).size; + var result = (originSize == destSize); + expect(result).assertTrue(); + expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK); + console.error('ACTS_ZipFile_3100 unzipFile'); + done(); + }).catch((err) => { + console.log("ACTS_ZipFile_3100 err: " + err); + expect(err).assertFail(); + done(); + }) + }).catch(function (error) { + console.info("ACTS_ZipFile_3100 mkdir failed with error:" + error); + expect(error).assertFail(); + done(); + }); + }).catch((err) => { + console.log("zipFile fail: " + err); + expect(err).assertFail(); + done(); + }) + }).catch(function (err) { + console.info("ACTS_ZipFile_3100 write data to file failed with error:" + err); + expect(err).assertFail(); + done(); + }); + console.log("==================ACTS_ZipFile_3100 end=================="); }); - }).catch((err) => { - console.log("zipFile fail: " + err); - expect(err).assertFail(); - done(); - }) - }).catch(function (err) { - console.info("ACTS_ZipFile_3100 write data to file failed with error:" + err); - expect(err).assertFail(); - done(); - }); - console.log("==================ACTS_ZipFile_3100 end=================="); - }); -/* -* @tc.number: ACTS_ZipFile_3200 -* @tc.name: zipFile -* @tc.desc: COMPRESS_STRATEGY_RLE,, -*/ -it('ACTS_ZipFile_3200', 0, async function (done) { - console.log("==================ACTS_ZipFile_3200 start=================="); - var path = dir + "/ACTS_ZipFile_3200.txt"; - var zipDest = dir + "/ACTS_ZipFile_3200.zip"; - var unzipdir = dir + "/ACTS_ZipFile_3200"; - var unzipresultfile = unzipdir + "/ACTS_ZipFile_3200.txt"; - var options = {}; - options.strategy = zlib.CompressStrategy.COMPRESS_STRATEGY_RLE; - var fd = fileio.openSync(path, 0o100 | 0o2, 0o666); - fileio.write(fd, infos).then(function (number) { - console.info("ACTS_ZipFile_3200 write data to file successfully:" + number); - zlib.zipFile(path, zipDest, options).then((data) => { - var zipStat = fileio.statSync(zipDest); - var isFile = zipStat.isFile(); - expect(isFile).assertTrue(); - var srcSize = fileio.statSync(path).size; - var destSize = zipStat.size; - expect(srcSize > destSize).assertTrue(); - expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK); - fileio.mkdir(unzipdir).then(function () { - console.info("ACTS_ZipFile_3200 mkdir successfully"); - zlib.unzipFile(zipDest, unzipdir, options).then((data) => { - var unzipStat = fileio.statSync(unzipresultfile); - var isFile = unzipStat.isFile(); - expect(isFile).assertTrue(); - var destSize = unzipStat.size; - var originSize = fileio.statSync(path).size; - var result = (originSize == destSize); - expect(result).assertTrue(); - expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK); - console.error('ACTS_ZipFile_3200 unzipFile'); - done(); - }).catch((err) => { - console.log("ACTS_ZipFile_3200 err: " + err);done(); - expect(err).assertFail(); - done(); - }) - }).catch(function (error) { - console.info("ACTS_ZipFile_3200 mkdir failed with error:" + error); - expect(error).assertFail(); - done(); + /* + * @tc.number: ACTS_ZipFile_3200 + * @tc.name: zipFile + * @tc.desc: COMPRESS_STRATEGY_RLE,, + */ + it('ACTS_ZipFile_3200', 0, async function (done) { + console.log("==================ACTS_ZipFile_3200 start=================="); + var path = dir + "/ACTS_ZipFile_3200.txt"; + var zipDest = dir + "/ACTS_ZipFile_3200.zip"; + var unzipdir = dir + "/ACTS_ZipFile_3200"; + var unzipresultfile = unzipdir + "/ACTS_ZipFile_3200.txt"; + var options = {}; + options.strategy = zlib.CompressStrategy.COMPRESS_STRATEGY_RLE; + var fd = fileio.openSync(path, 0o100 | 0o2, 0o666); + fileio.write(fd, infos).then(function (number) { + console.info("ACTS_ZipFile_3200 write data to file successfully:" + number); + zlib.zipFile(path, zipDest, options).then((data) => { + var zipStat = fileio.statSync(zipDest); + var isFile = zipStat.isFile(); + expect(isFile).assertTrue(); + var srcSize = fileio.statSync(path).size; + var destSize = zipStat.size; + expect(srcSize > destSize).assertTrue(); + expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK); + fileio.mkdir(unzipdir).then(function () { + console.info("ACTS_ZipFile_3200 mkdir successfully"); + zlib.unzipFile(zipDest, unzipdir, options).then((data) => { + var unzipStat = fileio.statSync(unzipresultfile); + var isFile = unzipStat.isFile(); + expect(isFile).assertTrue(); + var destSize = unzipStat.size; + var originSize = fileio.statSync(path).size; + var result = (originSize == destSize); + expect(result).assertTrue(); + expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK); + console.error('ACTS_ZipFile_3200 unzipFile'); + done(); + }).catch((err) => { + console.log("ACTS_ZipFile_3200 err: " + err); + done(); + expect(err).assertFail(); + done(); + }) + }).catch(function (error) { + console.info("ACTS_ZipFile_3200 mkdir failed with error:" + error); + expect(error).assertFail(); + done(); + }); + }).catch((err) => { + console.log("zipFile fail: " + err); + expect(err).assertFail(); + done(); + }) + }).catch(function (err) { + console.info("ACTS_ZipFile_3200 write data to file failed with error:" + err); + expect(err).assertFail(); + done(); + }); + console.log("==================ACTS_ZipFile_3200 end=================="); }); - }).catch((err) => { - console.log("zipFile fail: " + err); - expect(err).assertFail(); - done(); - }) - }).catch(function (err) { - console.info("ACTS_ZipFile_3200 write data to file failed with error:" + err); - expect(err).assertFail(); - done(); - }); - console.log("==================ACTS_ZipFile_3200 end=================="); - }); -/* -* @tc.number: ACTS_ZipFile_3300 -* @tc.name: zipFile -* @tc.desc: COMPRESS_STRATEGY_FIXED,, -*/ -it('ACTS_ZipFile_3300', 0, async function (done) { - console.log("==================ACTS_ZipFile_3300 start=================="); - var path = dir + "/ACTS_ZipFile_3300.txt"; - var zipDest = dir + "/ACTS_ZipFile_3300.zip" - var unzipdir = dir + "/ACTS_ZipFile_3300"; - var unzipresultfile = unzipdir + "/ACTS_ZipFile_3300.txt"; - var options = {}; - options.strategy = zlib.CompressStrategy.COMPRESS_STRATEGY_FIXED; - var fd = fileio.openSync(path, 0o100 | 0o2, 0o666); - fileio.write(fd, infos).then(function (number) { - console.info("ACTS_ZipFile_3300 write data to file successfully:" + number); - zlib.zipFile(path, zipDest, options).then((data) => { - var zipStat = fileio.statSync(zipDest); - var isFile = zipStat.isFile(); - expect(isFile).assertTrue(); - var srcSize = fileio.statSync(path).size; - var destSize = zipStat.size; - expect(srcSize > destSize).assertTrue(); - expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK); - fileio.mkdir(unzipdir).then(function () { - console.info("ACTS_ZipFile_3300 mkdir successfully"); - zlib.unzipFile(zipDest, unzipdir, options).then((data) => { - var unzipStat = fileio.statSync(unzipresultfile); - var isFile = unzipStat.isFile(); - expect(isFile).assertTrue(); - var destSize = unzipStat.size; - var originSize = fileio.statSync(path).size; - var result = (originSize == destSize); - expect(result).assertTrue(); - expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK); - console.error('ACTS_ZipFile_3300 unzipFile'); - done(); - }).catch((err) => { - console.log("ACTS_ZipFile_3300 err: " + err); - expect(err).assertFail(); - done(); - }) - }).catch(function (error) { - console.info("ACTS_ZipFile_3300 mkdir failed with error:" + error); - expect(error).assertFail(); - done(); + /* + * @tc.number: ACTS_ZipFile_3300 + * @tc.name: zipFile + * @tc.desc: COMPRESS_STRATEGY_FIXED,, + */ + it('ACTS_ZipFile_3300', 0, async function (done) { + console.log("==================ACTS_ZipFile_3300 start=================="); + var path = dir + "/ACTS_ZipFile_3300.txt"; + var zipDest = dir + "/ACTS_ZipFile_3300.zip" + var unzipdir = dir + "/ACTS_ZipFile_3300"; + var unzipresultfile = unzipdir + "/ACTS_ZipFile_3300.txt"; + var options = {}; + options.strategy = zlib.CompressStrategy.COMPRESS_STRATEGY_FIXED; + var fd = fileio.openSync(path, 0o100 | 0o2, 0o666); + fileio.write(fd, infos).then(function (number) { + console.info("ACTS_ZipFile_3300 write data to file successfully:" + number); + zlib.zipFile(path, zipDest, options).then((data) => { + var zipStat = fileio.statSync(zipDest); + var isFile = zipStat.isFile(); + expect(isFile).assertTrue(); + var srcSize = fileio.statSync(path).size; + var destSize = zipStat.size; + expect(srcSize > destSize).assertTrue(); + expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK); + fileio.mkdir(unzipdir).then(function () { + console.info("ACTS_ZipFile_3300 mkdir successfully"); + zlib.unzipFile(zipDest, unzipdir, options).then((data) => { + var unzipStat = fileio.statSync(unzipresultfile); + var isFile = unzipStat.isFile(); + expect(isFile).assertTrue(); + var destSize = unzipStat.size; + var originSize = fileio.statSync(path).size; + var result = (originSize == destSize); + expect(result).assertTrue(); + expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK); + console.error('ACTS_ZipFile_3300 unzipFile'); + done(); + }).catch((err) => { + console.log("ACTS_ZipFile_3300 err: " + err); + expect(err).assertFail(); + done(); + }) + }).catch(function (error) { + console.info("ACTS_ZipFile_3300 mkdir failed with error:" + error); + expect(error).assertFail(); + done(); + }); + }).catch((err) => { + console.log("zipFile fail: " + err); + expect(err).assertFail(); + done(); + }) + }).catch(function (err) { + console.info("ACTS_ZipFile_3300 write data to file failed with error:" + err); + expect(err).assertFail(); + done(); + }); + console.log("==================ACTS_ZipFile_3300 end=================="); }); - }).catch((err) => { - console.log("zipFile fail: " + err); - expect(err).assertFail(); - done(); - }) - }).catch(function (err) { - console.info("ACTS_ZipFile_3300 write data to file failed with error:" + err); - expect(err).assertFail(); - done(); - }); - console.log("==================ACTS_ZipFile_3300 end=================="); - }); -/* -* @tc.number: ACTS_ZipFile_3500 -* @tc.name: zipFile -* @tc.desc: INPUT_FILE_NOT_EXIST,, -*/ -it('ACTS_ZipFile_3500', 0, async function (done) { - console.log("==================ACTS_ZipFile_3500 start=================="); - var path = dir + "/ACTS_ZipFile_3500.txt"; - var src = dir + "/ACTS_ZipFile_9900.txt"; - var unzipdir = dir + "/ACTS_ZipFile_3500"; - var options = {}; - options.strategy = zlib.CompressStrategy.COMPRESS_STRATEGY_FILTERED; - var fd = fileio.openSync(path, 0o100 | 0o2, 0o666); - fileio.write(fd, infos).then(function (number) { - console.info("ACTS_ZipFile_3500 write successfully:" + number); - zlib.zipFile(src, dir, options).then((data) => { - console.log("ACTS_ZipFile_3500 data: " + data); - expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_ERRNO); - done(); - }).catch((err) => { - console.log("ACTS_ZipFile_3500 err: " + err); - expect(err).assertEqual(zlib.ErrorCode.ERROR_CODE_ERRNO); - done(); - }); - }).catch(function (err) { - console.info("ACTS_ZipFile_3500 write data to file failed with error:" + err); - expect(err).assertFail(); - done(); - }); - console.log("==================ACTS_ZipFile_3500 end =================="); - }) + /* + * @tc.number: ACTS_ZipFile_3500 + * @tc.name: zipFile + * @tc.desc: INPUT_FILE_NOT_EXIST,, + */ + it('ACTS_ZipFile_3500', 0, async function (done) { + console.log("==================ACTS_ZipFile_3500 start=================="); + var path = dir + "/ACTS_ZipFile_3500.txt"; + var src = dir + "/ACTS_ZipFile_9900.txt"; + var unzipdir = dir + "/ACTS_ZipFile_3500"; + var options = {}; + options.strategy = zlib.CompressStrategy.COMPRESS_STRATEGY_FILTERED; + var fd = fileio.openSync(path, 0o100 | 0o2, 0o666); + fileio.write(fd, infos).then(function (number) { + console.info("ACTS_ZipFile_3500 write successfully:" + number); + zlib.zipFile(src, dir, options).then((data) => { + console.log("ACTS_ZipFile_3500 data: " + data); + expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_ERRNO); + done(); + }).catch((err) => { + console.log("ACTS_ZipFile_3500 err: " + err); + expect(err).assertEqual(zlib.ErrorCode.ERROR_CODE_ERRNO); + done(); + }); + }).catch(function (err) { + console.info("ACTS_ZipFile_3500 write data to file failed with error:" + err); + expect(err).assertFail(); + done(); + }); + console.log("==================ACTS_ZipFile_3500 end =================="); + }) -/* -* @tc.number: ACTS_ZipFile_3600 -* @tc.name: zipFile -* @tc.desc: INPUT_FILE_NULL,, -*/ -it('ACTS_ZipFile_3600', 0, async function (done) { - console.log("==================ACTS_ZipFile_3600 start=================="); - var path = dir + "/ACTS_ZipFile_3600.txt"; - var zipDest = ""; - var options = {}; - options.strategy = zlib.CompressStrategy.COMPRESS_STRATEGY_FILTERED; - var fd = fileio.openSync(path, 0o100 | 0o2, 0o666); - fileio.write(fd, infos).then(function (number) { - console.info("ACTS_ZipFile_3600 write data to file successfully:" + number); - zlib.zipFile(path, zipDest, options).then((data) => { - console.log("ACTS_ZipFile_3600 data: " + data); - expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_ERRNO); - done(); - }).catch((err) => { - console.log("ACTS_ZipFile_3600 err: " + err); - expect(err).assertEqual(zlib.ErrorCode.ERROR_CODE_ERRNO); - done(); - }); - }).catch(function (err) { - console.info("ACTS_ZipFile_3600 write data to file failed with error:" + err); - expect(err).assertFail(); - done(); - }); - console.log("==================ACTS_ZipFile_3600 end ==================") - }) + /* + * @tc.number: ACTS_ZipFile_3600 + * @tc.name: zipFile + * @tc.desc: INPUT_FILE_NULL,, + */ + it('ACTS_ZipFile_3600', 0, async function (done) { + console.log("==================ACTS_ZipFile_3600 start=================="); + var path = dir + "/ACTS_ZipFile_3600.txt"; + var zipDest = ""; + var options = {}; + options.strategy = zlib.CompressStrategy.COMPRESS_STRATEGY_FILTERED; + var fd = fileio.openSync(path, 0o100 | 0o2, 0o666); + fileio.write(fd, infos).then(function (number) { + console.info("ACTS_ZipFile_3600 write data to file successfully:" + number); + zlib.zipFile(path, zipDest, options).then((data) => { + console.log("ACTS_ZipFile_3600 data: " + data); + expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_ERRNO); + done(); + }).catch((err) => { + console.log("ACTS_ZipFile_3600 err: " + err); + expect(err).assertEqual(zlib.ErrorCode.ERROR_CODE_ERRNO); + done(); + }); + }).catch(function (err) { + console.info("ACTS_ZipFile_3600 write data to file failed with error:" + err); + expect(err).assertFail(); + done(); + }); + console.log("==================ACTS_ZipFile_3600 end ==================") + }) -/* -* @tc.number: ACTS_ZipFile_4500 -* @tc.name: zipFile -* @tc.desc: COMPRESS_STRATEGY_FILTERED_CALLBACK,, -*/ -it('ACTS_ZipFile_4500', 0, async function (done) { - console.log("==================ACTS_ZipFile_4500 start=================="); - var path = dir + "/ACTS_ZipFile_4500.txt"; - var zipDest = dir + "/ACTS_ZipFile_4500.zip" - var unzipDest = dir + "/ACTS_ZipFile_9900.zip" - var unzipdir = dir + "/ACTS_ZipFile_4500"; - var zipdir = dir + "/ACTS_ZipFile_9900"; - var options = {}; - options.strategy = zlib.CompressStrategy.COMPRESS_STRATEGY_FILTERED; - var fd = fileio.openSync(path, 0o100 | 0o2, 0o666); - fileio.write(fd, infos).then(function (number) { - console.info("ACTS_ZipFile_4500 write data to file successfully:" + number); - zlib.zipFile(path, zipDest, options).then((data) => { - var zipStat = fileio.statSync(zipDest); - var isFile = zipStat.isFile(); - expect(isFile).assertTrue(); - var srcSize = fileio.statSync(path).size; - var destSize = zipStat.size; - expect(srcSize > destSize).assertTrue(); - expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK); - fileio.mkdir(unzipdir).then(function () { - console.info("ACTS_ZipFile_4500 mkdir successfully"); - zlib.unzipFile(unzipDest, zipdir, options).then((data) => { - console.log("ACTS_ZipFile_4500 data: " + data); - expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_ERRNO); - done(); + /* + * @tc.number: ACTS_ZipFile_4500 + * @tc.name: zipFile + * @tc.desc: COMPRESS_STRATEGY_FILTERED_CALLBACK,, + */ + it('ACTS_ZipFile_4500', 0, async function (done) { + console.log("==================ACTS_ZipFile_4500 start=================="); + var path = dir + "/ACTS_ZipFile_4500.txt"; + var zipDest = dir + "/ACTS_ZipFile_4500.zip" + var unzipDest = dir + "/ACTS_ZipFile_9900.zip" + var unzipdir = dir + "/ACTS_ZipFile_4500"; + var zipdir = dir + "/ACTS_ZipFile_9900"; + var options = {}; + options.strategy = zlib.CompressStrategy.COMPRESS_STRATEGY_FILTERED; + var fd = fileio.openSync(path, 0o100 | 0o2, 0o666); + fileio.write(fd, infos).then(function (number) { + console.info("ACTS_ZipFile_4500 write data to file successfully:" + number); + zlib.zipFile(path, zipDest, options).then((data) => { + var zipStat = fileio.statSync(zipDest); + var isFile = zipStat.isFile(); + expect(isFile).assertTrue(); + var srcSize = fileio.statSync(path).size; + var destSize = zipStat.size; + expect(srcSize > destSize).assertTrue(); + expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK); + fileio.mkdir(unzipdir).then(function () { + console.info("ACTS_ZipFile_4500 mkdir successfully"); + zlib.unzipFile(unzipDest, zipdir, options).then((data) => { + console.log("ACTS_ZipFile_4500 data: " + data); + expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_ERRNO); + done(); + }).catch((err) => { + console.log("ACTS_ZipFile_4500 err: " + err); + expect(err).assertEqual(zlib.ErrorCode.ERROR_CODE_ERRNO); + done(); + }) + }).catch(function (error) { + console.info("ACTS_ZipFile_4500 mkdir failed with error:" + error); + expect(error).assertFail(); + done(); + }); + }).catch((err) => { + console.log("ACTS_ZipFile_4500 zipFile fail: " + err); + expect(err).assertEqual(zlib.ErrorCode.ERROR_CODE_ERRNO); + done(); + }) + }).catch(function (err) { + console.info("ACTS_ZipFile_4500 write data to file failed with error:" + err); + expect(err).assertFail(); + done(); + }); + console.log("==================ACTS_ZipFile_4500 end=================="); + }) + + /* + * @tc.number: ACTS_ZipFile_4900 + * @tc.name: zipFile + * @tc.desc: COMPRESS_STRATEGY_FILTERED_PROMISE, + */ + it('ACTS_ZipFile_4900', 0, async function (done) { + console.log("==================ACTS_ZipFile_4900 start=================="); + var path = dir + "/ACTS_ZipFile_4900.txt"; + var zipDest = dir + "/ACTS_ZipFile_4900.zip" + var unzipDest = dir + "/ACTS_ZipFile_4900.zip" + var unzipdir = dir + "/ACTS_ZipFile_4900"; + var zipdir = dir + "/ACTS_ZipFile_4900"; + var options = {}; + options.strategy = zlib.CompressStrategy.COMPRESS_STRATEGY_FILTERED; + var fd = fileio.openSync(path, 0o100 | 0o2, 0o666); + fileio.write(fd, infos).then(function (number) { + console.info("ACTS_ZipFile_4900 write data to file successfully:" + number); + zlib.zipFile(path, zipDest, options).then(data => { + var zipStat = fileio.statSync(zipDest); + var isFile = zipStat.isFile(); + expect(isFile).assertTrue(); + var srcSize = fileio.statSync(path).size; + var destSize = zipStat.size; + expect(srcSize > destSize).assertTrue(); + expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK); + fileio.mkdir(unzipdir).then(function () { + console.info("ACTS_ZipFile_4900 mkdir successfully"); + zlib.unzipFile(unzipDest, zipdir, options).then(data => { + console.log("ACTS_ZipFile_4900 data: " + data); + expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK); + done(); + }).catch(err => { + console.log("ACTS_ZipFile_4900 err: " + err); + expect(err).assertFail(); + done(); + }) + }).catch(function (error) { + console.info("ACTS_ZipFile_4900 mkdir failed with error:" + error); + expect(error).assertFail(); + done(); + }); + }).catch(err => { + console.log("ACTS_ZipFile_4900 zipFile fail: " + err); + expect(err).assertFail(); + done(); + }) + }).catch(function (err) { + console.info("ACTS_ZipFile_4900 write data to file failed with error:" + err); + expect(err).assertFail(); + done(); + }); + console.log("==================ACTS_ZipFile_4900 end=================="); + }) + + /* + * @tc.number: ACTS_ZipFile_5000 + * @tc.name: zipFile + * @tc.desc: COMPRESS_STRATEGY_FIXED, + */ + it('ACTS_ZipFile_5000', 0, async function (done) { + console.log("==================ACTS_ZipFile_5000 start=================="); + var path = dir + "/ACTS_ZipFile_5000.txt"; + var zipDest = dir + "/ACTS_ZipFile_5000.zip" + var unzipdir = dir + "/ACTS_ZipFile_5000"; + var options = {}; + options.strategy = zlib.CompressStrategy.COMPRESS_STRATEGY_FIXED; + var fd = fileio.openSync(path, 0o100 | 0o2, 0o666); + fileio.write(fd, infos).then(function (number) { + console.info("ACTS_ZipFile_5000 write data to file successfully:" + number); + zlib.zipFile(path, zipDest, options).then(data => { + var zipStat = fileio.statSync(zipDest); + var isFile = zipStat.isFile(); + expect(isFile).assertTrue(); + var srcSize = fileio.statSync(path).size; + var destSize = zipStat.size; + expect(srcSize > destSize).assertTrue(); + expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK); + fileio.mkdir(unzipdir).then(function () { + console.info("ACTS_ZipFile_5000 mkdir successfully"); + zlib.unzipFile(zipDest, unzipdir, options).then(data => { + console.log("ACTS_ZipFile_5000 data: " + data); + expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK); + done(); + }).catch(err => { + console.log("unzipFile fail: " + err); + expect(err).assertFail(); + done(); + }) + }).catch(function (error) { + console.info("ACTS_ZipFile_5000 mkdir failed with error:" + error); + expect(error).assertFail(); + done(); + }); + }).catch(err => { + console.log("zipFile fail: " + err); + expect(err).assertFail(); + done(); + }) + }).catch(function (err) { + console.info("ACTS_ZipFile_5000 write data to file failed with error:" + err); + expect(err).assertFail(); + done(); + }); + console.log("==================ACTS_ZipFile_5000 end=================="); + }) + + /* + * @tc.number: SUB_BMS_TOOL_ZLIB_0076 + * @tc.name: compressFile success + * @tc.desc: inFile and out file is valid + */ + it('SUB_BMS_TOOL_ZLIB_0077', 0, async function (done) { + console.log("==================ACTS_compressFile_0100 start=================="); + let path1 = dir + "/SUB_BMS_TOOL_ZLIB_00771.txt"; + let zipDest1 = dir + "/SUB_BMS_TOOL_ZLIB_00771.zip"; + let path2 = dir + "/SUB_BMS_TOOL_ZLIB_00772.txt"; + let zipDest2 = dir + "/SUB_BMS_TOOL_ZLIB_00772.zip"; + let fd = fileio.openSync(path1, 0o100 | 0o2, 0o666); + await fileio.write(fd, infos).then(function (number) { + console.info("SUB_BMS_TOOL_ZLIB_0077 write data to file successfully :" + number); + }).catch(function (err) { + console.info("SUB_BMS_TOOL_ZLIB_0077 write data to file failed with error:" + err); + expect(err).assertFail(); + }); + console.info("SUB_BMS_TOOL_ZLIB_0077 start compressFile"); + await zlib.compressFile(path1, zipDest1, { + level: zlib.CompressLevel.COMPRESS_LEVEL_DEFAULT_COMPRESSION + }).then((data) => { + console.info("SUB_BMS_TOOL_ZLIB_0077 data: " + JSON.stringify(data)); + let zipStat = fileio.statSync(zipDest1); + let isFile = zipStat.isFile(); + expect(isFile).assertTrue(); + let srcSize = fileio.statSync(path1).size; + let destSize = zipStat.size; + expect(srcSize > destSize).assertTrue(); + expect(data).assertEqual(null); }).catch((err) => { - console.log("ACTS_ZipFile_4500 err: " + err); - expect(err).assertEqual(zlib.ErrorCode.ERROR_CODE_ERRNO); - done(); + console.info("SUB_BMS_TOOL_ZLIB_0077 data: " + JSON.stringify(err)); + expect(err).assertFail(); }) - }).catch(function (error) { - console.info("ACTS_ZipFile_4500 mkdir failed with error:" + error); - expect(error).assertFail(); - done(); - }); - }).catch((err) => { - console.log("ACTS_ZipFile_4500 zipFile fail: " + err); - expect(err).assertEqual(zlib.ErrorCode.ERROR_CODE_ERRNO); - done(); - }) - }).catch(function (err) { - console.info("ACTS_ZipFile_4500 write data to file failed with error:" + err); - expect(err).assertFail(); - done(); - }); - console.log("==================ACTS_ZipFile_4500 end=================="); - }) + let fd2 = fileio.openSync(path2, 0o100 | 0o2, 0o666); + await fileio.write(fd2, infos).then(function (number) { + console.info("SUB_BMS_TOOL_ZLIB_0077 write data to file successfully :" + number); + }).catch(function (err) { + console.info("SUB_BMS_TOOL_ZLIB_0077 write data to file failed with error:" + err); + expect(err).assertFail(); + }); + zlib.compressFile(path2, zipDest2, { + level: zlib.CompressLevel.COMPRESS_LEVEL_DEFAULT_COMPRESSION + }, (err, data) => { + console.info("SUB_BMS_TOOL_ZLIB_0077 data2: " + JSON.stringify(data)); + console.info("SUB_BMS_TOOL_ZLIB_0077 err2: " + JSON.stringify(err)); + let zipStat = fileio.statSync(zipDest2); + let isFile = zipStat.isFile(); + expect(isFile).assertTrue(); + let srcSize = fileio.statSync(path2).size; + let destSize = zipStat.size; + expect(srcSize > destSize).assertTrue(); + expect(data).assertEqual(undefined); + expect(err).assertEqual(null); + done(); + }) + }) + + /* + * @tc.number: SUB_BMS_TOOL_ZLIB_0077 + * @tc.name: compressFile src file is invalid + * @tc.desc: inFile is not exist + */ + it('SUB_BMS_TOOL_ZLIB_0078', 0, async function (done) { + console.log("==================SUB_BMS_TOOL_ZLIB_0078 start=================="); + var path = "nonexist.txt"; + var zipDest = dir + "/SUB_BMS_TOOL_ZLIB_0078.zip" + await zlib.compressFile(path, zipDest, { + level: zlib.CompressLevel.COMPRESS_LEVEL_NO_COMPRESSION + }).then((data) => { + console.log("SUB_BMS_TOOL_ZLIB_0078 invalid src file success!") + expect(data).assertFail(); + done(); + }).catch((err) => { + console.log("SUB_BMS_TOOL_ZLIB_0078 zipFile fail: " + JSON.stringify(err)); + expect(err.code).assertEqual(SRC_FILE_INVALID); + done(); + }) + console.log("==================SUB_BMS_TOOL_ZLIB_0078 end=================="); + }) + + /* + * @tc.number: SUB_BMS_TOOL_ZLIB_0077 + * @tc.name: decompressFile success + * @tc.desc: inFile and out file is valid + */ + it('SUB_BMS_TOOL_ZLIB_0087', 0, async function (done) { + console.log("==================SUB_BMS_TOOL_ZLIB_0087 start=================="); + let path = dir + "/SUB_BMS_TOOL_ZLIB_0087.txt"; + let zipDest1 = dir + "/SUB_BMS_TOOL_ZLIB_00871.zip" + let zipDest2 = dir + "/SUB_BMS_TOOL_ZLIB_00872.zip" + let unzipdir1 = dir + "/SUB_BMS_TOOL_ZLIB_00871"; + let unzipdir2 = dir + "/SUB_BMS_TOOL_ZLIB_00872"; + let finalFile1 = unzipdir1 + "/SUB_BMS_TOOL_ZLIB_0087.txt"; + let finalFile2 = unzipdir2 + "/SUB_BMS_TOOL_ZLIB_0087.txt"; + let fd = fileio.openSync(path, 0o100 | 0o2, 0o666); + await fileio.write(fd, infos).then(function (number) { + console.info("SUB_BMS_TOOL_ZLIB_0087 write data to file success " + JSON.stringify(number)); + }).catch(function (err) { + console.info("SUB_BMS_TOOL_ZLIB_0087 write data to file failed with error:" + err); + expect(err).assertFail(); + }); + await zlib.compressFile(path, zipDest1, { + level: zlib.CompressLevel.COMPRESS_LEVEL_DEFAULT_COMPRESSION + }).then(data => { + console.info("compressFile success " + JSON.stringify(data)); + let zipStat = fileio.statSync(zipDest1); + let isFile = zipStat.isFile(); + expect(isFile).assertTrue(); + let srcSize = fileio.statSync(path).size; + let destSize = zipStat.size; + expect(srcSize > destSize).assertTrue(); + expect(data).assertEqual(null); + }).catch(err => { + console.info("compressFile fail " + JSON.stringify(err)); + expect(err).assertFail(); + }) + await zlib.compressFile(path, zipDest2, { + level: zlib.CompressLevel.COMPRESS_LEVEL_DEFAULT_COMPRESSION + }).then(data => { + console.info("compressFile success " + JSON.stringify(data)); + let zipStat = fileio.statSync(zipDest2); + let isFile = zipStat.isFile(); + expect(isFile).assertTrue(); + let srcSize = fileio.statSync(path).size; + let destSize = zipStat.size; + expect(srcSize > destSize).assertTrue(); + expect(data).assertEqual(null); + }).catch(err => { + console.info("compressFile fail " + JSON.stringify(err)); + expect(err).assertFail(); + }) + await fileio.mkdir(unzipdir1).then(function () { + console.info("SUB_BMS_TOOL_ZLIB_0087 mkdir successfully"); + }).catch(function (error) { + console.info("SUB_BMS_TOOL_ZLIB_0087 mkdir failed with error:" + error); + expect(error).assertFail(); + }); + await zlib.decompressFile(zipDest1, unzipdir1, { + level: zlib.CompressLevel.COMPRESS_LEVEL_DEFAULT_COMPRESSION + }).then(data => { + console.info("decompressFile success1 " + JSON.stringify(data)); + let zipStat = fileio.statSync(finalFile1); + let isFile = zipStat.isFile(); + expect(isFile).assertTrue(); + expect(data).assertEqual(null); + }).catch(err => { + console.info("decompressFile fail1 " + JSON.stringify(err)); + expect(err).assertFail(); + }) + await fileio.mkdir(unzipdir2).then(function () { + console.info("SUB_BMS_TOOL_ZLIB_0087 mkdir successfully"); + }).catch(function (error) { + console.info("SUB_BMS_TOOL_ZLIB_0087 mkdir failed with error:" + error); + expect(error).assertFail(); + }); + zlib.decompressFile(zipDest2, unzipdir2, { + level: zlib.CompressLevel.COMPRESS_LEVEL_DEFAULT_COMPRESSION + }, (err, data) => { + console.info("decompressFile success2 " + JSON.stringify(data)); + console.info("decompressFile success2 " + JSON.stringify(err)); + let zipStat = fileio.statSync(finalFile2); + let isFile = zipStat.isFile(); + expect(isFile).assertTrue(); + expect(data).assertEqual(undefined); + expect(err).assertEqual(null); + done(); + }) + }) + + /* + * @tc.number: ACTS_decompressFile_0200 + * @tc.name: decompressFile src file invalid + * @tc.desc: inFile is empty + */ + it('SUB_BMS_TOOL_ZLIB_0088', 0, async function (done) { + console.log("==================SUB_BMS_TOOL_ZLIB_0088 start=================="); + var zipDest = dir + "/noneexist.zip" + var unzipdir = dir + "/SUB_BMS_TOOL_ZLIB_0088"; + await fileio.mkdir(unzipdir).then(function () { + console.info("SUB_BMS_TOOL_ZLIB_0088 mkdir successfully"); + }).catch(function (error) { + console.info("SUB_BMS_TOOL_ZLIB_0088 mkdir failed with error:" + error); + expect(error).assertFail(); + }); + await zlib.decompressFile(zipDest, unzipdir, { + strategy: zlib.CompressStrategy.COMPRESS_STRATEGY_FIXED + }).then(data => { + console.log("SUB_BMS_TOOL_ZLIB_0088 data: " + data); + expect(data).assertFail(null); + done(); + }).catch(err => { + console.log("decompress fail: " + JSON.stringify(err)); + expect(err.code).assertEqual(SRC_FILE_INVALID); + done(); + }) + console.log("==================SUB_BMS_TOOL_ZLIB_0088 end=================="); + }) -/* -* @tc.number: ACTS_ZipFile_4900 -* @tc.name: zipFile -* @tc.desc: COMPRESS_STRATEGY_FILTERED_PROMISE, -*/ -it('ACTS_ZipFile_4900', 0, async function (done) { - console.log("==================ACTS_ZipFile_4900 start=================="); - var path = dir + "/ACTS_ZipFile_4900.txt"; - var zipDest = dir + "/ACTS_ZipFile_4900.zip" - var unzipDest = dir + "/ACTS_ZipFile_4900.zip" - var unzipdir = dir + "/ACTS_ZipFile_4900"; - var zipdir = dir + "/ACTS_ZipFile_4900"; - var options = {}; - options.strategy = zlib.CompressStrategy.COMPRESS_STRATEGY_FILTERED; - var fd = fileio.openSync(path, 0o100 | 0o2, 0o666); - fileio.write(fd, infos).then(function (number) { - console.info("ACTS_ZipFile_4900 write data to file successfully:" + number); - zlib.zipFile(path, zipDest, options).then(data => { - var zipStat = fileio.statSync(zipDest); - var isFile = zipStat.isFile(); - expect(isFile).assertTrue(); - var srcSize = fileio.statSync(path).size; - var destSize = zipStat.size; - expect(srcSize > destSize).assertTrue(); - expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK); - fileio.mkdir(unzipdir).then(function () { - console.info("ACTS_ZipFile_4900 mkdir successfully"); - zlib.unzipFile(unzipDest, zipdir, options).then(data => { - console.log("ACTS_ZipFile_4900 data: " + data); - expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK); - done(); - }).catch(err => { - console.log("ACTS_ZipFile_4900 err: " + err); - expect(err).assertFail(); - done(); - }) - }).catch(function (error) { - console.info("ACTS_ZipFile_4900 mkdir failed with error:" + error); - expect(error).assertFail(); - done(); - }); - }).catch(err => { - console.log("ACTS_ZipFile_4900 zipFile fail: " + err); - expect(err).assertFail(); - done(); - }) - }).catch(function (err) { - console.info("ACTS_ZipFile_4900 write data to file failed with error:" + err); - expect(err).assertFail(); - done(); - }); - console.log("==================ACTS_ZipFile_4900 end=================="); -}) - -/* -* @tc.number: ACTS_ZipFile_5000 -* @tc.name: zipFile -* @tc.desc: COMPRESS_STRATEGY_FIXED, -*/ -it('ACTS_ZipFile_5000', 0, async function (done) { - console.log("==================ACTS_ZipFile_5000 start=================="); - var path = dir + "/ACTS_ZipFile_5000.txt"; - var zipDest = dir + "/ACTS_ZipFile_5000.zip" - var unzipdir = dir + "/ACTS_ZipFile_5000"; - var options = {}; - options.strategy = zlib.CompressStrategy.COMPRESS_STRATEGY_FIXED; - var fd = fileio.openSync(path, 0o100 | 0o2, 0o666); - fileio.write(fd, infos).then(function (number) { - console.info("ACTS_ZipFile_5000 write data to file successfully:" + number); - zlib.zipFile(path, zipDest, options).then(data => { - var zipStat = fileio.statSync(zipDest); - var isFile = zipStat.isFile(); - expect(isFile).assertTrue(); - var srcSize = fileio.statSync(path).size; - var destSize = zipStat.size; - expect(srcSize > destSize).assertTrue(); - expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK); - fileio.mkdir(unzipdir).then(function () { - console.info("ACTS_ZipFile_5000 mkdir successfully"); - zlib.unzipFile(zipDest, unzipdir, options).then(data => { - console.log("ACTS_ZipFile_5000 data: " + data); - expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK); - done(); - }).catch(err => { - console.log("unzipFile fail: " + err); - expect(err).assertFail(); - done(); - }) - }).catch(function (error) { - console.info("ACTS_ZipFile_5000 mkdir failed with error:" + error); - expect(error).assertFail(); - done(); - }); - }).catch(err => { - console.log("zipFile fail: " + err); - expect(err).assertFail(); - done(); - }) - }).catch(function (err) { - console.info("ACTS_ZipFile_5000 write data to file failed with error:" + err); - expect(err).assertFail(); - done(); - }); - console.log("==================ACTS_ZipFile_5000 end=================="); }) -}) } diff --git a/bundlemanager/zlib/actszlibtest/ActsZlibTest.cpp b/bundlemanager/zlib/actszlibtest/ActsZlibTest.cpp index c52fea3865fa443dcd537d1170a5fd199f787772..985927bb230d6ee25e64aba6c3f544816da07080 100644 --- a/bundlemanager/zlib/actszlibtest/ActsZlibTest.cpp +++ b/bundlemanager/zlib/actszlibtest/ActsZlibTest.cpp @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -38,9 +39,12 @@ static int SIX = 6; static int EIGHT = 8; static int GARBAGE_LEN = strlen(GARBAGE); static unsigned BUFFER_SIZE = 8192; +std::mutex gzMutex_; +std::mutex puMutex_; static unsigned pull(void *desc, unsigned char **buf) { + std::lock_guard lock(puMutex_); static unsigned int next = 0; static unsigned char dat[] = {0x63, 0, 2, 0}; @@ -53,12 +57,14 @@ static unsigned pull(void *desc, unsigned char **buf) static int push(void *desc, unsigned char *buf, unsigned len) { + std::lock_guard lock(puMutex_); buf += len; return desc != nullptr; /* force error if desc not null */ } static int TestGzPrintf(gzFile file, const char *format, ...) { + std::lock_guard lock(gzMutex_); va_list va; int ret;