Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
64d588d6
X
Xts Acts
项目概览
OpenHarmony
/
Xts Acts
1 年多 前同步成功
通知
9
Star
22
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
X
Xts Acts
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
64d588d6
编写于
10月 25, 2022
作者:
I
inter515
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add xts
Signed-off-by:
N
inter515
<
ry.renyi@huawei.com
>
上级
859fa276
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
1829 addition
and
1296 deletion
+1829
-1296
bundlemanager/bundle_standard/bundlemanager/actsbundlemanagerstagetest/entry/src/main/ets/test/GetBundleInfoForSelf.test.ets
...est/entry/src/main/ets/test/GetBundleInfoForSelf.test.ets
+339
-103
bundlemanager/bundle_standard/bundlemanager/actsbundlemanagerstagetest/entry/src/main/ets/test/GetSecondModule.test.ets
...tagetest/entry/src/main/ets/test/GetSecondModule.test.ets
+75
-0
bundlemanager/bundle_standard/bundlemanager/actsbundlemanagerstagetest/entry/src/main/ets/test/List.test.ets
...dlemanagerstagetest/entry/src/main/ets/test/List.test.ets
+2
-0
bundlemanager/bundle_standard/bundlemanager/actsbundlemanagerstagetest/entry/src/main/ets/test/Utils.ets
...sbundlemanagerstagetest/entry/src/main/ets/test/Utils.ets
+30
-0
bundlemanager/bundle_standard/bundlemanager/actsbundlemanagerstagetest/entry/src/main/module.json
...ger/actsbundlemanagerstagetest/entry/src/main/module.json
+145
-2
bundlemanager/bundle_standard/bundlemanager/sceneProject/bmsstagedemoone/entry/src/main/resources/base/profile/form_config.json
...ne/entry/src/main/resources/base/profile/form_config.json
+0
-4
bundlemanager/bundle_standard/bundlemanager/sceneProject/bmsstagedemotwo/entry/src/main/resources/base/profile/form_config.json
...wo/entry/src/main/resources/base/profile/form_config.json
+0
-4
bundlemanager/zlib/actszipfileandunzipfiletest/src/main/js/test/actszipfileandunzipfiletest.test.js
...test/src/main/js/test/actszipfileandunzipfiletest.test.js
+1238
-1183
未找到文件。
bundlemanager/bundle_standard/bundlemanager/actsbundlemanagerstagetest/entry/src/main/ets/test/GetBundleInfoForSelf.test.ets
浏览文件 @
64d588d6
...
...
@@ -14,6 +14,7 @@
*/
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";
...
...
@@ -25,6 +26,7 @@ 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 () {
...
...
@@ -186,24 +188,25 @@ export default function getBundleInfoForSelf() {
* @tc.desc: Test getBundleInfoForSelf with hapModuleInfo flag(by promise).
*/
it('getBundleInfoForSelfModulePro', 0, async function (done) {
bundle.getBundleInfoForSelf(bundle.BundleFlag.GET_BUNDLE_INFO_WITH_HAP_MODULE).then(data => {
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("
");
// expect(data.hapModulesInfo[0].iconId).assertEqual
(0);
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(
"MainAbility"
);
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(
1
);
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);
...
...
@@ -230,18 +233,19 @@ export default function getBundleInfoForSelf() {
expect(data.appInfo).assertEqual(null);
expect(data.hapModulesInfo.length).assertEqual(1);
expect(data.hapModulesInfo[0].name).assertEqual("testModule");
// expect(data.hapModulesInfo[0].icon).assertEqual("
");
// expect(data.hapModulesInfo[0].iconId).assertEqual
(0);
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(
"MainAbility"
);
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(
1
);
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);
...
...
@@ -259,14 +263,14 @@ export default function getBundleInfoForSelf() {
* @tc.desc: Test getBundleInfoForSelf with ability flag(by promise).
*/
it('getBundleInfoForSelfAbilityPro', 0, async function (done) {
bundle.getBundleInfoForSelf(
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]));
checkCommonBundleInfo(data);
checkCommonHapModuleInfo(data);
expect(data.appInfo).assertEqual(null);
expect(data.hapModulesInfo[0].abilitiesInfo.length).assertEqual(
2
);
expect(data.hapModulesInfo[0].abilitiesInfo.length).assertEqual(
3
);
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");
...
...
@@ -280,20 +284,24 @@ export default function getBundleInfoForSelf() {
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(2);
expect(data.hapModulesInfo[0].abilitiesInfo[0].launchType).assertEqual(
0
);
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(
1
);
expect(data.hapModulesInfo[0].abilitiesInfo[0].deviceTypes.length).assertEqual(
2
);
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(0);
expect(data.hapModulesInfo[0].abilitiesInfo[0].supportWindowModes[1]).assertEqual(1);
expect(data.hapModulesInfo[0].abilitiesInfo[0].supportWindowModes[2]).assertEqual(2);
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);
...
...
@@ -301,7 +309,11 @@ export default function getBundleInfoForSelf() {
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[2].name).assertEqual("ohos.acts.bundle.stage.test.MainAbility2");
expect(data.hapModulesInfo[0].abilitiesInfo[2].launchType).assertEqual(bundle.LaunchType.SPECIFIED);
checkCommonAbilityInfo(data.hapModulesInfo[0].abilitiesInfo[1])
checkCommonAbilityInfo(data.hapModulesInfo[0].abilitiesInfo[2])
expect(data.hapModulesInfo[0].extensionAbilitiesInfo.length).assertEqual(0);
expect(data.hapModulesInfo[0].metadata.length).assertEqual(0);
expect(data.reqPermissionDetails.length).assertEqual(0);
...
...
@@ -329,7 +341,7 @@ export default function getBundleInfoForSelf() {
checkCommonBundleInfo(data);
checkCommonHapModuleInfo(data);
expect(data.appInfo).assertEqual(null);
expect(data.hapModulesInfo[0].abilitiesInfo.length).assertEqual(
2
);
expect(data.hapModulesInfo[0].abilitiesInfo.length).assertEqual(
3
);
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");
...
...
@@ -343,20 +355,24 @@ export default function getBundleInfoForSelf() {
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(2);
expect(data.hapModulesInfo[0].abilitiesInfo[0].launchType).assertEqual(
0
);
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(
1
);
expect(data.hapModulesInfo[0].abilitiesInfo[0].deviceTypes.length).assertEqual(
2
);
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(0);
expect(data.hapModulesInfo[0].abilitiesInfo[0].supportWindowModes[1]).assertEqual(1);
expect(data.hapModulesInfo[0].abilitiesInfo[0].supportWindowModes[2]).assertEqual(2);
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);
...
...
@@ -364,7 +380,11 @@ export default function getBundleInfoForSelf() {
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[2].name).assertEqual("ohos.acts.bundle.stage.test.MainAbility2");
expect(data.hapModulesInfo[0].abilitiesInfo[2].launchType).assertEqual(bundle.LaunchType.SPECIFIED);
checkCommonAbilityInfo(data.hapModulesInfo[0].abilitiesInfo[1])
checkCommonAbilityInfo(data.hapModulesInfo[0].abilitiesInfo[2])
expect(data.hapModulesInfo[0].extensionAbilitiesInfo.length).assertEqual(0);
expect(data.hapModulesInfo[0].metadata.length).assertEqual(0);
expect(data.reqPermissionDetails.length).assertEqual(0);
...
...
@@ -381,7 +401,7 @@ export default function getBundleInfoForSelf() {
* @tc.desc: Test getBundleInfoForSelf with extensionAbility flag(by promise).
*/
it('getBundleInfoForSelfExtensionPro', 0, async function (done) {
bundle.getBundleInfoForSelf(
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));
...
...
@@ -389,35 +409,106 @@ export default function getBundleInfoForSelf() {
checkCommonHapModuleInfo(data);
expect(data.appInfo).assertEqual(null);
expect(data.hapModulesInfo[0].abilitiesInfo.length).assertEqual(0);
expect(data.hapModulesInfo[0].extensionAbilitiesInfo.length).assertEqual(2);
expect(data.hapModulesInfo[0].extensionAbilitiesInfo[0].bundleName).assertEqual(BUNDLE_NAME);
expect(data.hapModulesInfo[0].extensionAbilitiesInfo[0].moduleName).assertEqual("testModule");
expect(data.hapModulesInfo[0].extensionAbilitiesInfo[0].name).assertEqual("Form");
expect(data.hapModulesInfo[0].extensionAbilitiesInfo[0].labelId).assertLarger(0);
expect(data.hapModulesInfo[0].extensionAbilitiesInfo[0].descriptionId).assertLarger(0);
expect(data.hapModulesInfo[0].extensionAbilitiesInfo[0].iconId).assertLarger(0);
expect(data.hapModulesInfo[0].extensionAbilitiesInfo[0].isVisible).assertTrue();
expect(data.hapModulesInfo[0].extensionAbilitiesInfo[0].extensionAbilityType).assertEqual(0);
expect(data.hapModulesInfo[0].extensionAbilitiesInfo[0].permissions.length).assertEqual(0);
expect(data.hapModulesInfo[0].extensionAbilitiesInfo[0].applicationInfo).assertEqual(null);
expect(data.hapModulesInfo[0].extensionAbilitiesInfo[0].metadata.length).assertEqual(0);
expect(data.hapModulesInfo[0].extensionAbilitiesInfo[0].enabled).assertTrue();
expect(data.hapModulesInfo[0].extensionAbilitiesInfo[0].readPermission).assertEqual("");
expect(data.hapModulesInfo[0].extensionAbilitiesInfo[0].writePermission).assertEqual("");
expect(data.hapModulesInfo[0].extensionAbilitiesInfo[1].bundleName).assertEqual(BUNDLE_NAME);
expect(data.hapModulesInfo[0].extensionAbilitiesInfo[1].moduleName).assertEqual("testModule");
expect(data.hapModulesInfo[0].extensionAbilitiesInfo[1].name).assertEqual("Form1");
expect(data.hapModulesInfo[0].extensionAbilitiesInfo[0].labelId).assertLarger(0);
expect(data.hapModulesInfo[0].extensionAbilitiesInfo[1].descriptionId).assertLarger(0);
expect(data.hapModulesInfo[0].extensionAbilitiesInfo[1].iconId).assertLarger(0);
expect(data.hapModulesInfo[0].extensionAbilitiesInfo[1].isVisible).assertTrue();
expect(data.hapModulesInfo[0].extensionAbilitiesInfo[1].extensionAbilityType).assertEqual(0);
expect(data.hapModulesInfo[0].extensionAbilitiesInfo[1].permissions.length).assertEqual(0);
expect(data.hapModulesInfo[0].extensionAbilitiesInfo[1].applicationInfo).assertEqual(null);
expect(data.hapModulesInfo[0].extensionAbilitiesInfo[1].metadata.length).assertEqual(0);
expect(data.hapModulesInfo[0].extensionAbilitiesInfo[1].enabled).assertTrue();
expect(data.hapModulesInfo[0].extensionAbilitiesInfo[1].readPermission).assertEqual("");
expect(data.hapModulesInfo[0].extensionAbilitiesInfo[1].writePermission).assertEqual("");
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);
...
...
@@ -444,37 +535,105 @@ export default function getBundleInfoForSelf() {
checkCommonHapModuleInfo(data);
expect(data.appInfo).assertEqual(null);
expect(data.hapModulesInfo[0].abilitiesInfo.length).assertEqual(0);
expect(data.hapModulesInfo[0].extensionAbilitiesInfo.length).assertEqual(2);
expect(data.hapModulesInfo[0].abilitiesInfo.length).assertEqual(0);
expect(data.hapModulesInfo[0].extensionAbilitiesInfo.length).assertEqual(2);
expect(data.hapModulesInfo[0].extensionAbilitiesInfo[0].bundleName).assertEqual(BUNDLE_NAME);
expect(data.hapModulesInfo[0].extensionAbilitiesInfo[0].moduleName).assertEqual("testModule");
expect(data.hapModulesInfo[0].extensionAbilitiesInfo[0].name).assertEqual("Form");
expect(data.hapModulesInfo[0].extensionAbilitiesInfo[0].labelId).assertLarger(0);
expect(data.hapModulesInfo[0].extensionAbilitiesInfo[0].descriptionId).assertLarger(0);
expect(data.hapModulesInfo[0].extensionAbilitiesInfo[0].iconId).assertLarger(0);
expect(data.hapModulesInfo[0].extensionAbilitiesInfo[0].isVisible).assertTrue();
expect(data.hapModulesInfo[0].extensionAbilitiesInfo[0].extensionAbilityType).assertEqual(0);
expect(data.hapModulesInfo[0].extensionAbilitiesInfo[0].permissions.length).assertEqual(0);
expect(data.hapModulesInfo[0].extensionAbilitiesInfo[0].applicationInfo).assertEqual(null);
expect(data.hapModulesInfo[0].extensionAbilitiesInfo[0].metadata.length).assertEqual(0);
expect(data.hapModulesInfo[0].extensionAbilitiesInfo[0].enabled).assertTrue();
expect(data.hapModulesInfo[0].extensionAbilitiesInfo[0].readPermission).assertEqual("");
expect(data.hapModulesInfo[0].extensionAbilitiesInfo[0].writePermission).assertEqual("");
expect(data.hapModulesInfo[0].extensionAbilitiesInfo[1].bundleName).assertEqual(BUNDLE_NAME);
expect(data.hapModulesInfo[0].extensionAbilitiesInfo[1].moduleName).assertEqual("testModule");
expect(data.hapModulesInfo[0].extensionAbilitiesInfo[1].name).assertEqual("Form1");
expect(data.hapModulesInfo[0].extensionAbilitiesInfo[1].labelId).assertLarger(0);
expect(data.hapModulesInfo[0].extensionAbilitiesInfo[1].descriptionId).assertLarger(0);
expect(data.hapModulesInfo[0].extensionAbilitiesInfo[1].iconId).assertLarger(0);
expect(data.hapModulesInfo[0].extensionAbilitiesInfo[1].isVisible).assertTrue();
expect(data.hapModulesInfo[0].extensionAbilitiesInfo[1].extensionAbilityType).assertEqual(0);
expect(data.hapModulesInfo[0].extensionAbilitiesInfo[1].permissions.length).assertEqual(0);
expect(data.hapModulesInfo[0].extensionAbilitiesInfo[1].applicationInfo).assertEqual(null);
expect(data.hapModulesInfo[0].extensionAbilitiesInfo[1].metadata.length).assertEqual(0);
expect(data.hapModulesInfo[0].extensionAbilitiesInfo[1].enabled).assertTrue();
expect(data.hapModulesInfo[0].extensionAbilitiesInfo[1].readPermission).assertEqual("");
expect(data.hapModulesInfo[0].extensionAbilitiesInfo[1].writePermission).assertEqual("");
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);
...
...
@@ -490,21 +649,28 @@ export default function getBundleInfoForSelf() {
* @tc.desc: Test getBundleInfoForSelf with permission flag(by promise).
*/
it('getBundleInfoForSelfPermissionPro', 0, async function (done) {
bundle.getBundleInfoForSelf(
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(
1
);
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("inuse");
expect(data.permissionGrantStates[0]).assertEqual(0);
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 => {
...
...
@@ -526,15 +692,21 @@ export default function getBundleInfoForSelf() {
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(1);
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("inuse");
expect(data.permissionGrantStates[0]).assertEqual(0);
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();
...
...
@@ -547,7 +719,7 @@ export default function getBundleInfoForSelf() {
* @tc.desc: Test getBundleInfoForSelf with metadata flag(by promise).
*/
it('getBundleInfoForSelfMetaPro', 0, async function (done) {
bundle.getBundleInfoForSelf(
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));
...
...
@@ -605,7 +777,7 @@ export default function getBundleInfoForSelf() {
* @tc.desc: Test getBundleInfoForSelf with signatureInfo flag(by promise).
*/
it('getBundleInfoForSelfSigPro', 0, async function (done) {
bundle.getBundleInfoForSelf(
await
bundle.getBundleInfoForSelf(
bundle.BundleFlag.GET_BUNDLE_INFO_WITH_SIGNATURE_INFO).then(data => {
console.info("SigPro" + JSON.stringify(data.signatureInfo));
checkCommonBundleInfo(data);
...
...
@@ -650,7 +822,7 @@ export default function getBundleInfoForSelf() {
* @tc.desc: Test getBundleInfoForSelf with disable flag(by promise).
*/
it('getBundleInfoForSelfDisPro', 0, async function (done) {
bundle.getBundleInfoForSelf(bundle.BundleFlag.GET_BUNDLE_INFO_WITH_DISABLE).then(data => {
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);
...
...
@@ -686,6 +858,69 @@ export default function getBundleInfoForSelf() {
})
})
/*
* @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);
...
...
@@ -731,15 +966,16 @@ export default function getBundleInfoForSelf() {
function checkCommonHapModuleInfo(data) {
expect(data.hapModulesInfo.length).assertEqual(1);
expect(data.hapModulesInfo[0].name).assertEqual("testModule");
// expect(data.hapModulesInfo[0].icon).assertEqual("
");
// expect(data.hapModulesInfo[0].iconId).assertEqual
(0);
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(
"MainAbility"
);
expect(data.hapModulesInfo[0].deviceTypes.length).assertEqual(
1
);
expect(data.hapModulesInfo[0].mainElementName).assertEqual(
ABILITY_NAME
);
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);
...
...
@@ -759,20 +995,20 @@ export default function getBundleInfoForSelf() {
expect(data.isVisible).assertTrue();
expect(data.type).assertEqual(1);
expect(data.orientation).assertEqual(2);
expect(data.launchType).assertEqual(0);
expect(data.permissions.length).assertEqual(0);
expect(data.readPermission).assertEqual("");
expect(data.writePermission).assertEqual("");
expect(data.uri).assertEqual("");
expect(data.deviceTypes.length).assertEqual(
1
);
expect(data.deviceTypes.length).assertEqual(
2
);
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(
0
);
expect(data.supportWindowModes[1]).assertEqual(
1
);
expect(data.supportWindowModes[2]).assertEqual(
2
);
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);
...
...
bundlemanager/bundle_standard/bundlemanager/actsbundlemanagerstagetest/entry/src/main/ets/test/GetSecondModule.test.ets
0 → 100644
浏览文件 @
64d588d6
/*
* 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();
})
})
}
bundlemanager/bundle_standard/bundlemanager/actsbundlemanagerstagetest/entry/src/main/ets/test/List.test.ets
浏览文件 @
64d588d6
...
...
@@ -16,9 +16,11 @@
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
bundlemanager/bundle_standard/bundlemanager/actsbundlemanagerstagetest/entry/src/main/ets/test/Utils.ets
0 → 100644
浏览文件 @
64d588d6
/**
* 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...`)
})
}
}
bundlemanager/bundle_standard/bundlemanager/actsbundlemanagerstagetest/entry/src/main/module.json
浏览文件 @
64d588d6
...
...
@@ -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,6 +68,18 @@
"icon"
:
"$media:icon"
,
"label"
:
"$string:entry_label"
,
"visible"
:
true
,
"launchType"
:
"standard"
,
"orientation"
:
"portrait"
,
"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"
:
"portrait"
,
"skills"
:
[]
}
...
...
@@ -119,12 +133,141 @@
"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"
...
...
bundlemanager/bundle_standard/bundlemanager/sceneProject/bmsstagedemoone/entry/src/main/resources/base/profile/form_config.json
浏览文件 @
64d588d6
...
...
@@ -2,7 +2,6 @@
"forms"
:
[
{
"isDefault"
:
true
,
"src"
:
"./js/widget/pages/index/index"
,
"scheduledUpdateTime"
:
"10:30"
,
"defaultDimension"
:
"2*2"
,
"name"
:
"widget"
,
...
...
@@ -21,7 +20,6 @@
},
{
"isDefault"
:
true
,
"src"
:
"./js/widget1/pages/index/index"
,
"scheduledUpdateTime"
:
"10:30"
,
"defaultDimension"
:
"2*2"
,
"name"
:
"widget1"
,
...
...
@@ -41,7 +39,6 @@
},
{
"isDefault"
:
true
,
"src"
:
"./js/widget2/pages/index/index"
,
"scheduledUpdateTime"
:
"10:30"
,
"defaultDimension"
:
"2*2"
,
"name"
:
"widget2"
,
...
...
@@ -60,7 +57,6 @@
},
{
"isDefault"
:
true
,
"src"
:
"./js/widget3/pages/index/index"
,
"scheduledUpdateTime"
:
"10:30"
,
"defaultDimension"
:
"2*2"
,
"name"
:
"widget3"
,
...
...
bundlemanager/bundle_standard/bundlemanager/sceneProject/bmsstagedemotwo/entry/src/main/resources/base/profile/form_config.json
浏览文件 @
64d588d6
...
...
@@ -2,7 +2,6 @@
"forms"
:
[
{
"isDefault"
:
true
,
"src"
:
"./js/widget/pages/index/index"
,
"scheduledUpdateTime"
:
"10:30"
,
"defaultDimension"
:
"2*2"
,
"name"
:
"widget"
,
...
...
@@ -21,7 +20,6 @@
},
{
"isDefault"
:
true
,
"src"
:
"./js/widget1/pages/index/index"
,
"scheduledUpdateTime"
:
"10:30"
,
"defaultDimension"
:
"2*2"
,
"name"
:
"widget1"
,
...
...
@@ -41,7 +39,6 @@
},
{
"isDefault"
:
true
,
"src"
:
"./js/widget2/pages/index/index"
,
"scheduledUpdateTime"
:
"10:30"
,
"defaultDimension"
:
"2*2"
,
"name"
:
"widget2"
,
...
...
@@ -60,7 +57,6 @@
},
{
"isDefault"
:
true
,
"src"
:
"./js/widget3/pages/index/index"
,
"scheduledUpdateTime"
:
"10:30"
,
"defaultDimension"
:
"2*2"
,
"name"
:
"widget3"
,
...
...
bundlemanager/zlib/actszipfileandunzipfiletest/src/main/js/test/actszipfileandunzipfiletest.test.js
浏览文件 @
64d588d6
...
...
@@ -21,1226 +21,1281 @@ 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==================
"
);
})
/*
* @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==================
"
);
})
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_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==================
"
);
var
path
=
dir
+
"
/SUB_BMS_TOOL_ZLIB_0077.txt
"
;
var
zipDest
=
dir
+
"
/SUB_BMS_TOOL_ZLIB_0077.zip
"
;
var
fd
=
fileio
.
openSync
(
path
,
0o100
|
0o2
,
0o666
);
fileio
.
write
(
fd
,
infos
).
then
(
function
(
number
)
{
console
.
info
(
"
SUB_BMS_TOOL_ZLIB_0077 write data to file successfully :
"
+
number
);
var
options
=
{};
options
.
level
=
zlib
.
CompressLevel
.
COMPRESS_LEVEL_DEFAULT_COMPRESSION
;
console
.
info
(
"
SUB_BMS_TOOL_ZLIB_0077 start compressFile
"
);
zlib
.
compressFile
(
path
,
zipDest
,
options
).
then
((
data
)
=>
{
console
.
log
(
"
SUB_BMS_TOOL_ZLIB_0077 data:
"
+
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
(
null
);
done
();
}).
catch
((
err
)
=>
{
console
.
log
(
"
SUB_BMS_TOOL_ZLIB_0077 zipFile fail:
"
+
err
);
expect
(
data
).
assertFail
();
})
}).
catch
(
function
(
err
)
{
console
.
info
(
"
SUB_BMS_TOOL_ZLIB_0077 write data to file failed with error:
"
+
err
);
expect
(
err
).
assertFail
();
done
();
});
console
.
log
(
"
==================SUB_BMS_TOOL_ZLIB_0077 end==================
"
);
})
/*
* @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: 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
"
var
options
=
{};
options
.
level
=
zlib
.
CompressLevel
.
COMPRESS_LEVEL_NO_COMPRESSION
;
zlib
.
compressFile
(
path
,
zipDest
,
options
).
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:
"
+
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: 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==================
"
);
var
path
=
dir
+
"
/SUB_BMS_TOOL_ZLIB_0087.txt
"
;
var
zipDest
=
dir
+
"
/SUB_BMS_TOOL_ZLIB_0087.zip
"
var
unzipdir
=
dir
+
"
/SUB_BMS_TOOL_ZLIB_0087
"
;
var
finalFile
=
unzipdir
+
"
/SUB_BMS_TOOL_ZLIB_0087.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
(
"
SUB_BMS_TOOL_ZLIB_0087 write data to file successfully:
"
+
number
);
zlib
.
compressFile
(
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
(
null
);
fileio
.
mkdir
(
unzipdir
).
then
(
function
()
{
console
.
info
(
"
SUB_BMS_TOOL_ZLIB_0087 mkdir successfully
"
);
zlib
.
decompressFile
(
zipDest
,
unzipdir
,
options
).
then
(
data
=>
{
console
.
log
(
"
SUB_BMS_TOOL_ZLIB_0087 data:
"
+
data
);
var
zipStat
=
fileio
.
statSync
(
finalFile
);
var
isFile
=
zipStat
.
isFile
();
expect
(
isFile
).
assertTrue
();
expect
(
data
).
assertEqual
(
null
);
done
();
}).
catch
(
err
=>
{
console
.
log
(
"
decomepressFile fail:
"
+
err
);
expect
(
err
).
assertFail
();
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==================
"
);
})
}).
catch
(
function
(
error
)
{
console
.
info
(
"
SUB_BMS_TOOL_ZLIB_0087 mkdir failed with error:
"
+
error
);
expect
(
error
).
assertFail
();
done
();
});
}).
catch
(
err
=>
{
console
.
log
(
"
compress fail:
"
+
err
);
expect
(
err
).
assertFail
();
done
();
})
}).
catch
(
function
(
err
)
{
console
.
info
(
"
SUB_BMS_TOOL_ZLIB_0087 write data to file failed with error:
"
+
err
);
expect
(
err
).
assertFail
();
done
();
});
console
.
log
(
"
==================SUB_BMS_TOOL_ZLIB_0087 end==================
"
);
})
/*
* @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
"
;
var
options
=
{};
options
.
strategy
=
zlib
.
CompressStrategy
.
COMPRESS_STRATEGY_FIXED
;
fileio
.
mkdir
(
unzipdir
).
then
(
function
()
{
console
.
info
(
"
SUB_BMS_TOOL_ZLIB_0088 mkdir successfully
"
);
zlib
.
decompressFile
(
zipDest
,
unzipdir
,
options
).
then
(
data
=>
{
console
.
log
(
"
SUB_BMS_TOOL_ZLIB_0088 data:
"
+
data
);
expect
(
data
).
assertEqual
(
null
);
done
();
}).
catch
(
err
=>
{
console
.
log
(
"
decompress fail:
"
+
err
);
expect
(
err
.
code
).
assertEqual
(
SRC_FILE_INVALID
);
done
();
})
}).
catch
(
function
(
error
)
{
console
.
info
(
"
SUB_BMS_TOOL_ZLIB_0088 mkdir failed with error:
"
+
error
);
expect
(
error
).
assertFail
();
done
();
});
console
.
log
(
"
==================SUB_BMS_TOOL_ZLIB_0088 end==================
"
);
})
})
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录