提交 c87759c3 编写于 作者: K kirl.liu

Zip function test code change

Signed-off-by: Nkirl.liu <kirl.liu@huawei.com>
上级 28aa6075
......@@ -20,6 +20,7 @@ group("aafwk_standard") {
"abilitymanager:actsabilitymanagertest",
"actsabilitydistributetest:ActsAbilityDistributeTest",
"actsabilitydistributetest:ActsAbilityDistributeTest",
"amsZipfileUnzipfileST:ActsZlibTest",
"amsabilitymanager/amsMissionSnapshotTest:ActsAmsMissionSnapshotTest",
"amsabilitymanager/amsMissionSnapshotTestSingleton:ActsAmsMissionSnapshotTestSingleton",
"amsabilitymanager/amsMissionSnapshotTestSingletonS:ActsAmsMissionSnapshotTestSingletonS",
......@@ -42,7 +43,6 @@ group("aafwk_standard") {
"amsmultiapp/amsmultiapptester:ActsAmsMultiAppTester",
"amsmultiapp/amsmultidataabilityclone:ActsAmsMultiDataAbilityClone",
"amsmultiapp/amsmultidataabilityself:ActsAmsMultiDataAbilitySelf",
"amszipfileunzipfilest:ActsAmsZipfileUnzipfileSTest",
"context:context",
"featureability:featureability",
"formmanager:formmanager",
......
*.iml
.gradle
/local.properties
/.idea/caches
/.idea/libraries
/.idea/modules.xml
/.idea/workspace.xml
/.idea/navEditor.xml
/.idea/assetWizardSettings.xml
.DS_Store
/build
/captures
.externalNativeBuild
/entry/.preview
.cxx
/node_modules
# Default ignored files
/shelf/
/workspace.xml
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<bytecodeTargetLevel target="11" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="GradleMigrationSettings" migrationVersion="1" />
<component name="GradleSettings">
<option name="linkedExternalProjectsSettings">
<GradleProjectSettings>
<option name="testRunner" value="PLATFORM" />
<option name="distributionType" value="LOCAL" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="gradleHome" value="E:\DevEco Studio 3.0.0.800\tools\gradle" />
<option name="gradleJvm" value="#JAVA_INTERNAL" />
<option name="modules">
<set>
<option value="$PROJECT_DIR$" />
<option value="$PROJECT_DIR$/entry" />
</set>
</option>
<option name="resolveModulePerSourceSet" value="false" />
<option name="useQualifiedModuleNames" value="false" />
</GradleProjectSettings>
</option>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RemoteRepositoriesConfiguration">
<remote-repository>
<option name="id" value="central" />
<option name="name" value="Maven Central repository" />
<option name="url" value="https://repo1.maven.org/maven2" />
</remote-repository>
<remote-repository>
<option name="id" value="jboss.community" />
<option name="name" value="JBoss Community repository" />
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
</remote-repository>
<remote-repository>
<option name="id" value="maven2" />
<option name="name" value="maven2" />
<option name="url" value="https://developer.huawei.com/repo/" />
</remote-repository>
<remote-repository>
<option name="id" value="maven" />
<option name="name" value="maven" />
<option name="url" value="https://repo.huaweicloud.com/repository/maven/" />
</remote-repository>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK" />
</project>
\ No newline at end of file
# Copyright (c) 2021 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("ActsZlibTest") {
hap_profile = "./entry/src/main/config.json"
deps = [
":hjs_demo_js_assets",
":hjs_demo_resources",
]
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "ActsZlibTest"
}
ohos_js_assets("hjs_demo_js_assets") {
source_dir = "./entry/src/main/js/default"
}
ohos_resources("hjs_demo_resources") {
sources = [ "./entry/src/main/js/resources" ]
hap_profile = "./entry/src/main/config.json"
}
{
"description": "Configuration for hjunit demo Tests",
"driver": {
"type": "JSUnitTest",
"test-timeout": "60000",
"package": "com.example.amsZipfileUnzipfileST",
"shell-timeout": "60000"
},
"kits": [
{
"test-file-name": [
"ActsZlibTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
{
"app": {
"bundleName": "com.example.amsZipfileUnzipfileST",
"vendor": "example",
"version": {
"code": 1000000,
"name": "1.0.0"
}
},
"deviceConfig": {},
"module": {
"package": "com.example.amsZipfileUnzipfileST",
"name": ".MyApplication",
"mainAbility": "com.example.amsZipfileUnzipfileST.MainAbility",
"deviceType": [
"phone",
"tablet",
"tv",
"wearable"
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "entry",
"moduleType": "entry",
"installationFree": false
},
"abilities": [
{
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"visible": true,
"name": "com.example.amsZipfileUnzipfileST.MainAbility",
"icon": "$media:icon",
"description": "$string:mainability_description",
"label": "$string:entry_MainAbility",
"type": "page",
"launchType": "standard"
}
],
"js": [
{
"pages": [
"pages/index/index"
],
"name": "default",
"window": {
"designWidth": 720,
"autoDesignWidth": true
}
}
],
"reqPermissions": [
{
"name":"ohos.permission.GET_BUNDLE_INFO_PRIVILEGED",
"reason":"need use ohos.permission.GET_BUNDLE_INFO_PRIVILEGED"
},
{
"name":"ohos.permission.INSTALL_BUNDLE",
"reason":"need use ohos.permission.INSTALL_BUNDLE"
},
{
"name":"ohos.permission.GET_BUNDLE_INFO",
"reason":"need use ohos.permission.GET_BUNDLE_INFO"
},
{
"name":" ohos.permission.MANAGE_MISSIONS",
"reason":"need use ohos.permission.MANAGE_MISSIONS"
},
{
"name":"ohos.permission.CHANGE_ABILITY_ENABLED_STATE",
"reason":"need use ohos.permission.CHANGE_ABILITY_ENABLED_STATE"
},
{
"name":"ohos.permission.REMOVE_CACHE_FILES",
"reason":"need use ohos.permission.REMOVE_CACHE_FILES"
},
{
"name":"ohos.permission.LISTEN_BUNDLE_CHANGE",
"reason":"need use ohos.permission.LISTEN_BUNDLE_CHANGE"
}
]
}
}
\ No newline at end of file
/*
* 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 {
onCreate() {
console.info('AceApplication onCreate');
},
onDestroy() {
console.info('AceApplication onDestroy');
}
};
{
"strings": {
"hello": "Hello",
"world": "World"
}
}
\ No newline at end of file
{
"strings": {
"hello": "您好",
"world": "世界"
}
}
\ No newline at end of file
.container {
flex-direction: column;
justify-content: center;
align-items: center;
width: 100%;
height: 100%;
}
.title {
font-size: 40px;
color: #000000;
opacity: 0.9;
}
@media screen and (device-type: tablet) and (orientation: landscape) {
.title {
font-size: 100px;
}
}
@media screen and (device-type: wearable) {
.title {
font-size: 28px;
color: #FFFFFF;
}
}
@media screen and (device-type: tv) {
.container {
background-image: url("/common/images/Wallpaper.png");
background-size: cover;
background-repeat: no-repeat;
background-position: center;
}
.title {
font-size: 100px;
color: #FFFFFF;
}
}
@media screen and (device-type: phone) and (orientation: landscape) {
.title {
font-size: 60px;
}
}
<div class="container">
<text class="title">
{{ $t('strings.hello') }} {{ title }}
</text>
</div>
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import file from '@system.file'
import {Core, ExpectExtend, ReportExtend} from 'deccjsunit/index'
const injecttRef = Object.getPrototypeOf(global) || global
injecttRef.regeneratorRuntime = require('@babel/runtime/regenerator')
export default{
data: {
title: ""
},
onInit() {
this.title = this.$t('strings.world');
},
onShow() {
console.info('onShow finish')
const core = Core.getInstance()
const expectExtend = new ExpectExtend({
'id': 'extend'
})
core.addService('expect', expectExtend)
core.init()
const configService = core.getDefaultService('config')
configService.setConfig(this)
require('../../../test/List.test.js')
core.execute()
},
onReady() {
},
}
{
"string": [
{
"name": "entry_MainAbility",
"value": "entry_MainAbility"
},
{
"name": "mainability_description",
"value": "JS_Empty Ability"
}
]
}
\ No newline at end of file
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import zlib from '@ohos.zlib'
import fileio from '@ohos.fileio'
import file from '@system.file'
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
describe('ActsZlibTest', function () {
/*
* @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_3400 start==================");
let dirfirst = "/data/accounts/account_0/appdata"
let dirsecond =dirfirst + "/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST"
let dir = dirsecond + "/com.example.amsZipfileUnzipfileST.MainAbility/files";
let path = "";
var zipDest = dir + "/ACTS_ZipFile_0100.zip"
var options = {};
options.flush = zlib.FlushType.FLUSH_TYPE_NO_FLUSH;
await zlib.zipFile(path, dir, options,
(err, data) => {
console.log("ACTS_ZipFile_0100 data: " + data);
expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_ERRNO);
done();
});
})
/*
* @tc.number: ACTS_ZipFile_0200
* @tc.name: zipFile
* @tc.desc: inFile doesn't exist
*/
it('ACTS_ZipFile_0200', 0, async function (done) {
console.log("==================FWK_ZipFile_0600 start==================");
let dirfirst = "/data/accounts/account_0/appdata"
let dirsecond =dirfirst + "/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST"
let dir = dirsecond + "/com.example.amsZipfileUnzipfileST.MainAbility/files";
let src = dir + "/ACTS_ZipFile_100000.txt";
let path = dir + "/ACTS_ZipFile_9900.txt";
var zipDest = dir + "/ACTS_ZipFile_6600.zip"
let infos = path + dir;
let unzipdirfirst = "/data/accounts/account_0/appdata";
let unzipdirsecond = unzipdirfirst + "/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST"
let unzipdir =unzipdirsecond + "/com.example.amsZipfileUnzipfileST.MainAbility/files/ACTS_ZipFile_0200";
let unzipresultfile = unzipdir + "/ACTS_ZipFile_0200.txt";
let 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);
}).catch(function (err) {
console.info("ACTS_ZipFile_0200 write data to file failed with error:" + err);
});
var options = {};
options.flush = zlib.FlushType.FLUSH_TYPE_NO_FLUSH;
await zlib.zipFile(src, dir, options,
(err, data) => {
console.log("ACTS_ZipFile_0200 data: " + data);
expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_ERRNO);
done();
});
})
/*
* @tc.number: ACTS_ZipFile_0300
* @tc.name: zipFile
* @tc.desc: output file not specified
*/
it('ACTS_ZipFile_0300', 0, async function (done) {
console.log("==================FWK_ZipFile_0600 start==================");
let dirfirst = "/data/accounts/account_0/appdata"
let dirsecond =dirfirst + "/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST"
let dir = dirsecond + "/com.example.amsZipfileUnzipfileST.MainAbility/files";
let path = dir + "/ACTS_ZipFile_0300.txt";
var zipDest = ""
let infos = path + dir;
let unzipdirfirst = "/data/accounts/account_0/appdata";
let unzipdirsecond = unzipdirfirst + "/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST"
let unzipdir =unzipdirsecond + "/com.example.amsZipfileUnzipfileST.MainAbility/files/ACTS_ZipFile_0300";
let unzipresultfile = unzipdir + "/ACTS_ZipFile_0300.txt";
let 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);
}).catch(function (err) {
console.info("ACTS_ZipFile_0300 write data to file failed with error:" + err);
});
var options = {};
options.flush = zlib.FlushType.FLUSH_TYPE_NO_FLUSH;
await zlib.zipFile(path, zipDest, options,
(err, data) => {
console.log("ACTS_ZipFile_0300 data: " + data);
expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_ERRNO);
done();
});
})
/*
* @tc.number: ACTS_ZipFile_0400
* @tc.name: zipFile
* @tc.desc: The ouput file is a directory that does not exist
*/
it('ACTS_ZipFile_0400', 0, async function (done) {
console.log("==================FWK_ZipFile_0600 start==================");
let dirfirst = "/data/accounts/account_0/appdata"
let dirsecond =dirfirst + "/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST"
let dir = dirsecond + "/com.example.amsZipfileUnzipfileST.MainAbility/files";
let path = dir + "/ACTS_ZipFile_0400.txt";
var zipDest = "/ACTS_ZipFile_0400.zip"
let infos = path + dir;
let unzipdirfirst = "/data/accounts/account_0/appdata";
let unzipdirsecond = unzipdirfirst + "/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST"
let unzipdir =unzipdirsecond + "/com.example.amsZipfileUnzipfileST.MainAbility/files/ACTS_ZipFile_0400";
let unzipresultfile = unzipdir + "/ACTS_ZipFile_0400.txt";
let 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);
}).catch(function (err) {
console.info("ACTS_ZipFile_0400 write data to file failed with error:" + err);
});
var options = {};
options.flush = zlib.FlushType.FLUSH_TYPE_NO_FLUSH;
await zlib.zipFile(path, zipDest, options,
(err, data) => {
console.log("ACTS_ZipFile_0400 data: " + data);
expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_ERRNO);
done();
});
})
/*
* @tc.number: ACTS_ZipFile_0500
* @tc.name: zipFile
* @tc.desc: FlushType.FLUSH_TYPE_NO_FLUSH
*/
it('ACTS_ZipFile_0500', 0, async function (done) {
console.log("==================FWK_ZipFile_0600 start==================");
let dirfirst = "/data/accounts/account_0/appdata"
let dirsecond =dirfirst + "/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST"
let dir = dirsecond + "/com.example.amsZipfileUnzipfileST.MainAbility/files";
let path = dir + "/ACTS_ZipFile_0500.txt";a
var zipDest = dir + "/ACTS_ZipFile_0500.zip"
let infos = path + dir;
let unzipdirfirst = "/data/accounts/account_0/appdata";
let unzipdirsecond = unzipdirfirst + "/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST"
let unzipdir =unzipdirsecond + "/com.example.amsZipfileUnzipfileST.MainAbility/files/ACTS_ZipFile_0500";
let unzipresultfile = unzipdir + "/ACTS_ZipFile_0500.txt";
let fd = fileio.openSync(path, 0o100 | 0o2, 0o666);
fileio.write(fd, infos).then(function (number) {
console.info("ACTS_ZipFile_0500 write data to file successfully:" + number);
}).catch(function (err) {
console.info("ACTS_ZipFile_0500 write data to file failed with error:" + err);
});
try {
var options = {};
options.flush = zlib.FlushType.FLUSH_TYPE_NO_FLUSH;
await zlib.zipFile(path, zipDest, options,
(err, 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_0500 mkdir successfully");
}).catch(function (error) {
console.info("ACTS_ZipFile_0500 mkdir failed with error:" + error);
});
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_0500 unzipFile');
done();
}).catch((err) => {
console.log("ACTS_ZipFile_0500 err: " + err);
done();
})
done();
});
} catch (err) {
console.error('ACTS_ZipFile_0500 err:' + err);
done();
}
console.log("==================ACTS_ZipFile_0500 end==================");
})
/*
* @tc.number: ACTS_ZipFile_0600
* @tc.name: zipFile
* @tc.desc: FlushType.FLUSH_TYPE_NO_FLUSH
*/
it('ACTS_ZipFile_0600', 0, async function (done) {
console.log("==================FWK_ZipFile_0600 start==================");
let dirfirst = "/data/accounts/account_0/appdata"
let dirsecond =dirfirst + "/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST"
let dir = dirsecond + "/com.example.amsZipfileUnzipfileST.MainAbility/files";
let path = dir + "/ACTS_ZipFile_0600.txt";
var zipDest = dir + "/ACTS_ZipFile_0600.zip"
let infos = path + dir;
let unzipdirfirst = "/data/accounts/account_0/appdata";
let unzipdirsecond = unzipdirfirst + "/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST"
let unzipdir =unzipdirsecond + "/com.example.amsZipfileUnzipfileST.MainAbility/files/ACTS_ZipFile_0600";
let unzipresultfile = unzipdir + "/ACTS_ZipFile_0600.txt";
let fd = fileio.openSync(path, 0o100 | 0o2, 0o666);
fileio.write(fd, infos).then(function (number) {
console.info("ACTS_ZipFile_0600 write data to file successfully:" + number);
}).catch(function (err) {
console.info("ACTS_ZipFile_0600 write data to file failed with error:" + err);
});
try {
var options = {};
options.flush = zlib.FlushType.FLUSH_TYPE_NO_FLUSH;
await zlib.zipFile(path, zipDest, options,
(err, 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_0600 mkdir successfully");
}).catch(function (error) {
console.info("ACTS_ZipFile_0600 mkdir failed with error:" + error);
});
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_0600 unzipFile');
done();
}).catch((err) => {
console.log("ACTS_ZipFile_0600 err: " + err);
done();
})
done();
});
} catch (err) {
console.error('ACTS_ZipFile_0600 err:' + err);
done();
}
console.log("==================ACTS_ZipFile_0600 end==================");
})
/*
* @tc.number: ACTS_ZipFile_0700
* @tc.name: zipFile
* @tc.desc: FlushType.FLUSH_TYPE_SYNC_FLUSH
*/
it('ACTS_ZipFile_0700', 0, async function (done) {
console.log("==================ACTS_ZipFile_0700 start==================");
let dirfirst = "/data/accounts/account_0/appdata"
let dirsecond =dirfirst + "/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST"
let dir = dirsecond + "/com.example.amsZipfileUnzipfileST.MainAbility/files";
let path = dir + "/ACTS_ZipFile_0700.txt";
var zipDest = dir + "/ACTS_ZipFile_0700.zip"
let infos = path + dir;
let unzipdirfirst = "/data/accounts/account_0/appdata";
let unzipdirsecond = unzipdirfirst + "/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST"
let unzipdir =unzipdirsecond + "/com.example.amsZipfileUnzipfileST.MainAbility/files/ACTS_ZipFile_0700";
let unzipresultfile = unzipdir + "/ACTS_ZipFile_0700.txt";
let fd = fileio.openSync(path, 0o100 | 0o2, 0o666);
fileio.write(fd, infos).then(function (number) {
console.info("ACTS_ZipFile_0700 write data to file successfully:" + number);
}).catch(function (err) {
console.info("ACTS_ZipFile_0700 write data to file failed with error:" + err);
});
try {
var options = {};
options.flush = zlib.FlushType.FLUSH_TYPE_SYNC_FLUSH;
await zlib.zipFile(path, zipDest, options,
(err, 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_0700 mkdir successfully");
}).catch(function (error) {
console.info("ACTS_ZipFile_0700 mkdir failed with error:" + error);
});
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_0700 unzipFile');
done();
}).catch((err) => {
console.log("ACTS_ZipFile_0700 err: " + err);
done();
})
done();
});
} catch (err) {
console.error('ACTS_ZipFile_0700 err:' + err);
done();
}
console.log("==================ACTS_ZipFile_0700 end==================");
})
/*
* @tc.number: ACTS_ZipFile_0800
* @tc.name: zipFile
* @tc.desc: FlushType.FLUSH_TYPE_FULL_FLUSH
*/
it('ACTS_ZipFile_0800', 0, async function (done) {
console.log("==================ACTS_ZipFile_0800 start==================");
let dirfirst = "/data/accounts/account_0/appdata"
let dirsecond =dirfirst + "/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST"
let dir = dirsecond + "/com.example.amsZipfileUnzipfileST.MainAbility/files";
let path = dir + "/ACTS_ZipFile_0800.txt";
var zipDest = dir + "/ACTS_ZipFile_0800.zip"
let infos = path + dir;
let unzipdirfirst = "/data/accounts/account_0/appdata";
let unzipdirsecond = unzipdirfirst + "/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST"
let unzipdir =unzipdirsecond + "/com.example.amsZipfileUnzipfileST.MainAbility/files/ACTS_ZipFile_0800";
let unzipresultfile = unzipdir + "/ACTS_ZipFile_0800.txt";
let fd = fileio.openSync(path, 0o100 | 0o2, 0o666);
fileio.write(fd, infos).then(function (number) {
console.info("ACTS_ZipFile_0800 write data to file successfully:" + number);
}).catch(function (err) {
console.info("ACTS_ZipFile_0800 write data to file failed with error:" + err);
});
try {
var options = {};
options.flush = zlib.FlushType.FLUSH_TYPE_FULL_FLUSH;
await zlib.zipFile(path, zipDest, options,
(err, 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_0800 mkdir successfully");
}).catch(function (error) {
console.info("ACTS_ZipFile_0800 mkdir failed with error:" + error);
});
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_0800 unzipFile');
done();
}).catch((err) => {
console.log("ACTS_ZipFile_0800 err: " + err);
done();
})
done();
});
} catch (err) {
console.error('ACTS_ZipFile_0800 err:' + err);
done();
}
console.log("==================ACTS_ZipFile_0800 end==================");
})
/*
* @tc.number: ACTS_ZipFile_0900
* @tc.name: zipFile
* @tc.desc: FlushType.FLUSH_TYPE_FINISH
*/
it('ACTS_ZipFile_0900', 0, async function (done) {
console.log("==================ACTS_ZipFile_0900 start==================");
let dirfirst = "/data/accounts/account_0/appdata"
let dirsecond =dirfirst + "/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST"
let dir = dirsecond + "/com.example.amsZipfileUnzipfileST.MainAbility/files";
let path = dir + "/ACTS_ZipFile_0900.txt";
var zipDest = dir + "/ACTS_ZipFile_0900.zip"
let infos = path + dir;
let unzipdirfirst = "/data/accounts/account_0/appdata";
let unzipdirsecond = unzipdirfirst + "/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST"
let unzipdir =unzipdirsecond + "/com.example.amsZipfileUnzipfileST.MainAbility/files/ACTS_ZipFile_0900";
let unzipresultfile = unzipdir + "/ACTS_ZipFile_0900.txt";
let fd = fileio.openSync(path, 0o100 | 0o2, 0o666);
fileio.write(fd, infos).then(function (number) {
console.info("ACTS_ZipFile_0900 write data to file successfully:" + number);
}).catch(function (err) {
console.info("ACTS_ZipFile_0900 write data to file failed with error:" + err);
});
try {
var options = {};
options.flush = zlib.FlushType.FLUSH_TYPE_FINISH;
await zlib.zipFile(path, zipDest, options,
(err, 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_0900 mkdir successfully");
}).catch(function (error) {
console.info("ACTS_ZipFile_0900 mkdir failed with error:" + error);
});
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_0900 unzipFile');
done();
}).catch((err) => {
console.log("ACTS_ZipFile_0900 err: " + err);
done();
})
done();
});
} catch (err) {
console.error('ACTS_ZipFile_0900 err:' + err);
done();
}
console.log("==================ACTS_ZipFile_0900 end==================");
})
/*
* @tc.number: ACTS_ZipFile_1000
* @tc.name: zipFile
* @tc.desc: FlushType.FLUSH_TYPE_BLOCK
*/
it('ACTS_ZipFile_1000', 0, async function (done) {
console.log("==================ACTS_ZipFile_1000 start==================");
let dirfirst = "/data/accounts/account_0/appdata"
let dirsecond =dirfirst + "/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST"
let dir = dirsecond + "/com.example.amsZipfileUnzipfileST.MainAbility/files";
let path = dir + "/ACTS_ZipFile_1000.txt";
var zipDest = dir + "/ACTS_ZipFile_1000.zip"
let infos = path + dir;
let unzipdirfirst = "/data/accounts/account_0/appdata";
let unzipdirsecond = unzipdirfirst + "/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST"
let unzipdir =unzipdirsecond + "/com.example.amsZipfileUnzipfileST.MainAbility/files/ACTS_ZipFile_1000";
let unzipresultfile = unzipdir + "/ACTS_ZipFile_1000.txt";
let fd = fileio.openSync(path, 0o100 | 0o2, 0o666);
fileio.write(fd, infos).then(function (number) {
console.info("ACTS_ZipFile_1000 write data to file successfully:" + number);
}).catch(function (err) {
console.info("ACTS_ZipFile_1000 write data to file failed with error:" + err);
});
try {
var options = {};
options.flush = zlib.FlushType.FLUSH_TYPE_BLOCK;
await zlib.zipFile(path, zipDest, options,
(err, 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_1000 mkdir successfully");
}).catch(function (error) {
console.info("ACTS_ZipFile_1000 mkdir failed with error:" + error);
});
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_1000 unzipFile');
done();
}).catch((err) => {
console.log("ACTS_ZipFile_1000 err: " + err);
done();
})
done();
});
} catch (err) {
console.error('ACTS_ZipFile_1000 err:' + err);
done();
}
console.log("==================ACTS_ZipFile_1000 end==================");
})
/*
* @tc.number: ACTS_ZipFile_1100
* @tc.name: zipFile
* @tc.desc: FlushType.FLUSH_TYPE_TREES
*/
it('ACTS_ZipFile_1100', 0, async function (done) {
console.log("==================ACTS_ZipFile_1100 start==================");
let dirfirst = "/data/accounts/account_0/appdata"
let dirsecond =dirfirst + "/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST"
let dir = dirsecond + "/com.example.amsZipfileUnzipfileST.MainAbility/files";
let path = dir + "/ACTS_ZipFile_1100.txt";
var zipDest = dir + "/ACTS_ZipFile_1100.zip"
let infos = path + dir;
let unzipdirfirst = "/data/accounts/account_0/appdata";
let unzipdirsecond = unzipdirfirst + "/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST"
let unzipdir =unzipdirsecond + "/com.example.amsZipfileUnzipfileST.MainAbility/files/ACTS_ZipFile_1100";
let unzipresultfile = unzipdir + "/ACTS_ZipFile_1100.txt";
let fd = fileio.openSync(path, 0o100 | 0o2, 0o666);
fileio.write(fd, infos).then(function (number) {
console.info("ACTS_ZipFile_1100 write data to file successfully:" + number);
}).catch(function (err) {
console.info("ACTS_ZipFile_1100 write data to file failed with error:" + err);
});
try {
var options = {};
options.flush = zlib.FlushType.FLUSH_TYPE_TREES;
await zlib.zipFile(path, zipDest, options,
(err, 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_1100 mkdir successfully");
}).catch(function (error) {
console.info("ACTS_ZipFile_1100 mkdir failed with error:" + error);
});
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_1100 unzipFile');
done();
}).catch((err) => {
console.log("ACTS_ZipFile_1100 err: " + err);
done();
})
done();
});
} catch (err) {
console.error('ACTS_ZipFile_1100 err:' + err);
done();
}
console.log("==================ACTS_ZipFile_1100 end==================");
})
/*
* @tc.number: ACTS_ZipFile_1200
* @tc.name: zipFile
* @tc.desc: FlushType.FLUSH_TYPE_NO_FLUSH
*/
it('ACTS_ZipFile_1200', 0, async function (done) {
console.log("==================ACTS_ZipFile_1200 start==================");
let dirfirst = "/data/accounts/account_0/appdata"
let dirsecond =dirfirst + "/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST"
let dir = dirsecond + "/com.example.amsZipfileUnzipfileST.MainAbility/files";
let path = dir + "/ACTS_ZipFile_1200.txt";
var zipDest = dir + "/ACTS_ZipFile_1200.zip"
let infos = path + dir;
let unzipdirfirst = "/data/accounts/account_0/appdata";
let unzipdirsecond = unzipdirfirst + "/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST"
let unzipdir =unzipdirsecond + "/com.example.amsZipfileUnzipfileST.MainAbility/files/ACTS_ZipFile_1200";
let unzipresultfile = unzipdir + "/ACTS_ZipFile_1200.txt";
let fd = fileio.openSync(path, 0o100 | 0o2, 0o666);
fileio.write(fd, infos).then(function (number) {
console.info("ACTS_ZipFile_1200 write data to file successfully:" + number);
}).catch(function (err) {
console.info("ACTS_ZipFile_1200 write data to file failed with error:" + err);
});
try {
var options = {};
options.flush = zlib.FlushType.FLUSH_TYPE_NO_FLUSH;
await zlib.zipFile(path, zipDest, options,
(err, 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_1200 mkdir successfully");
}).catch(function (error) {
console.info("ACTS_ZipFile_1200 mkdir failed with error:" + error);
});
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_1200 unzipFile');
done();
}).catch((err) => {
console.log("ACTS_ZipFile_1200 err: " + err);
done();
})
done();
});
} catch (err) {
console.error('ACTS_ZipFile_1200 err:' + err);
done();
}
console.log("==================ACTS_ZipFile_1200 end==================");
})
/*
* @tc.number: ACTS_ZipFile_1300
* @tc.name: zipFile
* @tc.desc: FlushType.FLUSH_TYPE_PARTIAL_FLUSH
*/
it('ACTS_ZipFile_1300', 0, async function (done) {
console.log("==================ACTS_ZipFile_1300 start==================");
let dirfirst = "/data/accounts/account_0/appdata"
let dirsecond =dirfirst + "/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST"
let dir = dirsecond + "/com.example.amsZipfileUnzipfileST.MainAbility/files";
let path = dir + "/ACTS_ZipFile_1300.txt";
var zipDest = dir + "/ACTS_ZipFile_1300.zip"
let infos = path + dir;
let unzipdirfirst = "/data/accounts/account_0/appdata";
let unzipdirsecond = unzipdirfirst + "/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST"
let unzipdir =unzipdirsecond + "/com.example.amsZipfileUnzipfileST.MainAbility/files/ACTS_ZipFile_1300";
let unzipresultfile = unzipdir + "/ACTS_ZipFile_1300.txt";
let fd = fileio.openSync(path, 0o100 | 0o2, 0o666);
fileio.write(fd, infos).then(function (number) {
console.info("ACTS_ZipFile_1300 write data to file successfully:" + number);
}).catch(function (err) {
console.info("ACTS_ZipFile_1300 write data to file failed with error:" + err);
});
try {
var options = {};
options.flush = zlib.FlushType.FLUSH_TYPE_PARTIAL_FLUSH;
await zlib.zipFile(path, zipDest, options,
(err, 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_1300 mkdir successfully");
}).catch(function (error) {
console.info("ACTS_ZipFile_1300 mkdir failed with error:" + error);
});
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_1300 unzipFile');
done();
}).catch((err) => {
console.log("ACTS_ZipFile_1300 err: " + err);
done();
})
done();
});
} catch (err) {
console.error('ACTS_ZipFile_1300 err:' + err);
done();
}
console.log("==================ACTS_ZipFile_1300 end==================");
})
/*
* @tc.number: ACTS_ZipFile_1400
* @tc.name: zipFile
* @tc.desc: FlushType.FLUSH_TYPE_SYNC_FLUSH
*/
it('ACTS_ZipFile_1400', 0, async function (done) {
console.log("==================ACTS_ZipFile_1400 start==================");
let dirfirst = "/data/accounts/account_0/appdata"
let dirsecond =dirfirst + "/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST"
let dir = dirsecond + "/com.example.amsZipfileUnzipfileST.MainAbility/files";
let path = dir + "/ACTS_ZipFile_1400.txt";
var zipDest = dir + "/ACTS_ZipFile_1400.zip"
let infos = path + dir;
let unzipdirfirst = "/data/accounts/account_0/appdata";
let unzipdirsecond = unzipdirfirst + "/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST"
let unzipdir =unzipdirsecond + "/com.example.amsZipfileUnzipfileST.MainAbility/files/ACTS_ZipFile_1400";
let unzipresultfile = unzipdir + "/ACTS_ZipFile_1400.txt";
let fd = fileio.openSync(path, 0o100 | 0o2, 0o666);
fileio.write(fd, infos).then(function (number) {
console.info("ACTS_ZipFile_1400 write data to file successfully:" + number);
}).catch(function (err) {
console.info("ACTS_ZipFile_1400 write data to file failed with error:" + err);
});
try {
var options = {};
options.flush = zlib.FlushType.FLUSH_TYPE_SYNC_FLUSH;
await zlib.zipFile(path, zipDest, options,
(err, 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_1400 mkdir successfully");
}).catch(function (error) {
console.info("ACTS_ZipFile_1400 mkdir failed with error:" + error);
});
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_1400 unzipFile');
done();
}).catch((err) => {
console.log("ACTS_ZipFile_1400 err: " + err);
done();
})
done();
});
} catch (err) {
console.error('ACTS_ZipFile_1400 err:' + err);
done();
}
console.log("==================ACTS_ZipFile_1400 end==================");
})
/*
* @tc.number: ACTS_ZipFile_1500
* @tc.name: zipFile
* @tc.desc: FlushType.FLUSH_TYPE_FULL_FLUSH
*/
it('ACTS_ZipFile_1500', 0, async function (done) {
console.log("==================ACTS_ZipFile_1500 start==================");
let dirfirst = "/data/accounts/account_0/appdata"
let dirsecond =dirfirst + "/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST"
let dir = dirsecond + "/com.example.amsZipfileUnzipfileST.MainAbility/files";
let path = dir + "/ACTS_ZipFile_1500.txt";
var zipDest = dir + "/ACTS_ZipFile_1500.zip"
let infos = path + dir;
let unzipdirfirst = "/data/accounts/account_0/appdata";
let unzipdirsecond = unzipdirfirst + "/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST"
let unzipdir =unzipdirsecond + "/com.example.amsZipfileUnzipfileST.MainAbility/files/ACTS_ZipFile_1500";
let unzipresultfile = unzipdir + "/ACTS_ZipFile_1500.txt";
let fd = fileio.openSync(path, 0o100 | 0o2, 0o666);
fileio.write(fd, infos).then(function (number) {
console.info("ACTS_ZipFile_1500 write data to file successfully:" + number);
}).catch(function (err) {
console.info("ACTS_ZipFile_1500 write data to file failed with error:" + err);
});
try {
var options = {};
options.flush = zlib.FlushType.FLUSH_TYPE_FULL_FLUSH;
await zlib.zipFile(path, zipDest, options,
(err, 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_1500 mkdir successfully");
}).catch(function (error) {
console.info("ACTS_ZipFile_1500 mkdir failed with error:" + error);
});
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_1500 unzipFile');
done();
}).catch((err) => {
console.log("ACTS_ZipFile_1500 err: " + err);
done();
})
done();
});
} catch (err) {
console.error('ACTS_ZipFile_1500 err:' + err);
done();
}
console.log("==================ACTS_ZipFile_1500 end==================");
})
/*
* @tc.number: ACTS_ZipFile_1600
* @tc.name: zipFile
* @tc.desc: FlushType.FLUSH_TYPE_FINISH
*/
it('ACTS_ZipFile_1600', 0, async function (done) {
console.log("==================ACTS_ZipFile_1600 start==================");
let dirfirst = "/data/accounts/account_0/appdata"
let dirsecond =dirfirst + "/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST"
let dir = dirsecond + "/com.example.amsZipfileUnzipfileST.MainAbility/files";
let path = dir + "/ACTS_ZipFile_1600.txt";
var zipDest = dir + "/ACTS_ZipFile_1600.zip"
let infos = path + dir;
let unzipdirfirst = "/data/accounts/account_0/appdata";
let unzipdirsecond = unzipdirfirst + "/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST"
let unzipdir =unzipdirsecond + "/com.example.amsZipfileUnzipfileST.MainAbility/files/ACTS_ZipFile_1600";
let unzipresultfile = unzipdir + "/ACTS_ZipFile_1600.txt";
let fd = fileio.openSync(path, 0o100 | 0o2, 0o666);
fileio.write(fd, infos).then(function (number) {
console.info("ACTS_ZipFile_1600 write data to file successfully:" + number);
}).catch(function (err) {
console.info("ACTS_ZipFile_1600 write data to file failed with error:" + err);
});
try {
var options = {};
options.flush = zlib.FlushType.FLUSH_TYPE_FINISH;
await zlib.zipFile(path, zipDest, options,
(err, 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_1600 mkdir successfully");
}).catch(function (error) {
console.info("ACTS_ZipFile_1600 mkdir failed with error:" + error);
});
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_1600 unzipFile');
done();
}).catch((err) => {
console.log("ACTS_ZipFile_1600 err: " + err);
done();
})
done();
});
} catch (err) {
console.error('ACTS_ZipFile_1600 err:' + err);
done();
}
console.log("==================ACTS_ZipFile_1600 end==================");
})
/*
* @tc.number: ACTS_ZipFile_1700
* @tc.name: zipFile
* @tc.desc: FlushType.FLUSH_TYPE_BLOCK
*/
it('ACTS_ZipFile_1700', 0, async function (done) {
console.log("==================ACTS_ZipFile_1700 start==================");
let dirfirst = "/data/accounts/account_0/appdata"
let dirsecond =dirfirst + "/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST"
let dir = dirsecond + "/com.example.amsZipfileUnzipfileST.MainAbility/files";
let path = dir + "/ACTS_ZipFile_1700.txt";
var zipDest = dir + "/ACTS_ZipFile_1700.zip"
let infos = path + dir;
let unzipdirfirst = "/data/accounts/account_0/appdata";
let unzipdirsecond = unzipdirfirst + "/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST"
let unzipdir =unzipdirsecond + "/com.example.amsZipfileUnzipfileST.MainAbility/files/ACTS_ZipFile_1700";
let unzipresultfile = unzipdir + "/ACTS_ZipFile_1700.txt";
let fd = fileio.openSync(path, 0o100 | 0o2, 0o666);
fileio.write(fd, infos).then(function (number) {
console.info("ACTS_ZipFile_1700 write data to file successfully:" + number);
}).catch(function (err) {
console.info("ACTS_ZipFile_1700 write data to file failed with error:" + err);
});
try {
var options = {};
options.flush = zlib.FlushType.FLUSH_TYPE_BLOCK;
await zlib.zipFile(path, zipDest, options,
(err, 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_1700 mkdir successfully");
}).catch(function (error) {
console.info("ACTS_ZipFile_1700 mkdir failed with error:" + error);
});
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_1700 unzipFile');
done();
}).catch((err) => {
console.log("ACTS_ZipFile_1700 err: " + err);
done();
})
done();
});
} catch (err) {
console.error('ACTS_ZipFile_1700 err:' + err);
done();
}
console.log("==================ACTS_ZipFile_1700 end==================");
})
/*
* @tc.number: ACTS_ZipFile_1800
* @tc.name: zipFile
* @tc.desc: FlushType.FLUSH_TYPE_TREES
*/
it('ACTS_ZipFile_1800', 0, async function (done) {
console.log("==================FWK_ZipFile_0600 start==================");
let dirfirst = "/data/accounts/account_0/appdata"
let dirsecond =dirfirst + "/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST"
let dir = dirsecond + "/com.example.amsZipfileUnzipfileST.MainAbility/files";
let path = dir + "/ACTS_ZipFile_1800.txt";
var zipDest = dir + "/ACTS_ZipFile_1800.zip"
let infos = path + dir;
let unzipdirfirst = "/data/accounts/account_0/appdata";
let unzipdirsecond = unzipdirfirst + "/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST"
let unzipdir =unzipdirsecond + "/com.example.amsZipfileUnzipfileST.MainAbility/files/ACTS_ZipFile_1800";
let unzipresultfile = unzipdir + "/ACTS_ZipFile_1800.txt";
let fd = fileio.openSync(path, 0o100 | 0o2, 0o666);
fileio.write(fd, infos).then(function (number) {
console.info("ACTS_ZipFile_1800 write data to file successfully:" + number);
}).catch(function (err) {
console.info("ACTS_ZipFile_1800 write data to file failed with error:" + err);
});
try {
var options = {};
options.flush = zlib.FlushType.FLUSH_TYPE_TREES;
await zlib.zipFile(path, zipDest, options,
(err, 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_1800 mkdir successfully");
}).catch(function (error) {
console.info("ACTS_ZipFile_1800 mkdir failed with error:" + error);
});
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_1800 unzipFile');
done();
}).catch((err) => {
console.log("ACTS_ZipFile_1800 err: " + err);
done();
})
done();
});
} catch (err) {
console.error('ACTS_ZipFile_1800 err:' + err);
done();
}
console.log("==================ACTS_ZipFile_1800 end==================");
})
/*
* @tc.number: ACTS_ZipFile_1900
* @tc.name: zipFile
* @tc.desc: chunkSize: 64,
*/
it('ACTS_ZipFile_1900', 0, async function (done) {
console.log("==================ACTS_ZipFile_1900 start==================");
let dirfirst = "/data/accounts/account_0/appdata"
let dirsecond =dirfirst + "/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST"
let dir = dirsecond + "/com.example.amsZipfileUnzipfileST.MainAbility/files";
let path = dir + "/ACTS_ZipFile_1900.txt";
var zipDest = dir + "/ACTS_ZipFile_1900.zip";
let infos = path + dir;
let unzipdirfirst = "/data/accounts/account_0/appdata";
let unzipdirsecond = unzipdirfirst + "/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST"
let unzipdir =unzipdirsecond + "/com.example.amsZipfileUnzipfileST.MainAbility/files/ACTS_ZipFile_1900";
let unzipresultfile = unzipdir + "/ACTS_ZipFile_1900.txt";
let fd = fileio.openSync(path, 0o100 | 0o2, 0o666);
fileio.write(fd, infos).then(function (number) {
console.info("ACTS_ZipFile_1900 write data to file successfully:" + number);
}).catch(function (err) {
console.info("ACTS_ZipFile_1900 write data to file failed with error:" + err);
});
try {
var options = {
chunkSize: 64,
};
await zlib.zipFile(path, zipDest, options,
(err, 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_1900 mkdir successfully");
}).catch(function (error) {
console.info("ACTS_ZipFile_1900 mkdir failed with error:" + error);
});
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_1900 unzipFile');
done();
}).catch((err) => {
console.log("ACTS_ZipFile_1900 err: " + err);
done();
})
done();
});
} catch (err) {
console.error('ACTS_ZipFile_1900 err:' + err);
done();
}
console.log("==================ACTS_ZipFile_1900 end==================");
})
/*
* @tc.number: ACTS_ZipFile_2000
* @tc.name: zipFile
* @tc.desc: chunkSize: 1024,
*/
it('ACTS_ZipFile_2000', 0, async function (done) {
console.log("==================ACTS_ZipFile_2000 start==================");
let dirfirst = "/data/accounts/account_0/appdata"
let dirsecond =dirfirst + "/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST"
let dir = dirsecond + "/com.example.amsZipfileUnzipfileST.MainAbility/files";
let path = dir + "/ACTS_ZipFile_2000.txt";
var zipDest = dir + "/ACTS_ZipFile_2000.zip"
let infos = path + dir;
let unzipdirfirst = "/data/accounts/account_0/appdata";
let unzipdirsecond = unzipdirfirst + "/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST"
let unzipdir =unzipdirsecond + "/com.example.amsZipfileUnzipfileST.MainAbility/files/ACTS_ZipFile_2000";
let unzipresultfile = unzipdir + "/ACTS_ZipFile_2000.txt";
let fd = fileio.openSync(path, 0o100 | 0o2, 0o666);
fileio.write(fd, infos).then(function (number) {
console.info("ACTS_ZipFile_2000 write data to file successfully:" + number);
}).catch(function (err) {
console.info("ACTS_ZipFile_2000 write data to file failed with error:" + err);
});
try {
var options = {
chunkSize: 1024,
};
await zlib.zipFile(path, zipDest, options,
(err, 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_2000 mkdir successfully");
}).catch(function (error) {
console.info("ACTS_ZipFile_2000 mkdir failed with error:" + error);
});
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_2000 unzipFile');
done();
}).catch((err) => {
console.log("ACTS_ZipFile_2000 err: " + err);
done();
})
done();
});
} catch (err) {
console.error('ACTS_ZipFile_2000 err:' + err);
done();
}
console.log("==================ACTS_ZipFile_2000 end==================");
})
/*
* @tc.number: ACTS_ZipFile_2100
* @tc.name: zipFile
* @tc.desc: chunkSize: 999,
*/
it('ACTS_ZipFile_2100', 0, async function (done) {
console.log("==================ACTS_ZipFile_2100 start==================");
let dirfirst = "/data/accounts/account_0/appdata"
let dirsecond =dirfirst + "/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST"
let dir = dirsecond + "/com.example.amsZipfileUnzipfileST.MainAbility/files";
let path = dir + "/ACTS_ZipFile_2100.txt";
var zipDest = dir + "/ACTS_ZipFile_2100.zip"
let infos = path + dir;
let unzipdirfirst = "/data/accounts/account_0/appdata";
let unzipdirsecond = unzipdirfirst + "/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST"
let unzipdir =unzipdirsecond + "/com.example.amsZipfileUnzipfileST.MainAbility/files/ACTS_ZipFile_2100";
let unzipresultfile = unzipdir + "/ACTS_ZipFile_2100.txt";
let fd = fileio.openSync(path, 0o100 | 0o2, 0o666);
fileio.write(fd, infos).then(function (number) {
console.info("ACTS_ZipFile_2100 write data to file successfully:" + number);
}).catch(function (err) {
console.info("ACTS_ZipFile_2100 write data to file failed with error:" + err);
});
try {
var options = {
chunkSize: 999,
};
await zlib.zipFile(path, zipDest, options,
(err, 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_2100 mkdir successfully");
}).catch(function (error) {
console.info("ACTS_ZipFile_2100 mkdir failed with error:" + error);
});
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_2100 unzipFile');
done();
}).catch((err) => {
console.log("ACTS_ZipFile_2100 err: " + err);
done();
})
done();
});
} catch (err) {
console.error('ACTS_ZipFile_2100 err:' + err);
done();
}
console.log("==================ACTS_ZipFile_2100 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==================");
let dirfirst = "/data/accounts/account_0/appdata"
let dirsecond =dirfirst + "/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST"
let dir = dirsecond + "/com.example.amsZipfileUnzipfileST.MainAbility/files";
let path = dir + "/ACTS_ZipFile_2200.txt";
var zipDest = dir + "/ACTS_ZipFile_2200.zip"
let infos = path + dir;
let unzipdirfirst = "/data/accounts/account_0/appdata";
let unzipdirsecond = unzipdirfirst + "/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST"
let unzipdir =unzipdirsecond + "/com.example.amsZipfileUnzipfileST.MainAbility/files/ACTS_ZipFile_2200";
let unzipresultfile = unzipdir + "/ACTS_ZipFile_2200.txt";
let fd = fileio.openSync(path, 0o100 | 0o2, 0o666);
fileio.write(fd, infos).then(function (number) {
console.info("ACTS_ZipFile_2200 write data to file successfully:" + number);
}).catch(function (err) {
console.info("ACTS_ZipFile_2200 write data to file failed with error:" + err);
});
try {
var options = {};
options.level = zlib.CompressLevel.COMPRESS_LEVEL_NO_COMPRESSION;
await zlib.zipFile(path, zipDest, options,
(err, 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");
}).catch(function (error) {
console.info("ACTS_ZipFile_2200 mkdir failed with error:" + error);
});
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);
done();
})
done();
});
} catch (err) {
console.error('ACTS_ZipFile_2200 err:' + err);
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==================");
let dirfirst = "/data/accounts/account_0/appdata"
let dirsecond =dirfirst + "/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST"
let dir = dirsecond + "/com.example.amsZipfileUnzipfileST.MainAbility/files";
let path = dir + "/ACTS_ZipFile_2300.txt";
var zipDest = dir + "/ACTS_ZipFile_2300.zip"
let infos = path + dir;
let unzipdirfirst = "/data/accounts/account_0/appdata";
let unzipdirsecond = unzipdirfirst + "/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST"
let unzipdir =unzipdirsecond + "/com.example.amsZipfileUnzipfileST.MainAbility/files/ACTS_ZipFile_2300";
let unzipresultfile = unzipdir + "/ACTS_ZipFile_2300.txt";
let 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);
}).catch(function (err) {
console.info("ACTS_ZipFile_2300 write data to file failed with error:" + err);
});
try {
var options = {};
options.level = zlib.CompressLevel.COMPRESS_LEVEL_BEST_SPEED;
await zlib.zipFile(path, zipDest, options,
(err, 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");
}).catch(function (error) {
console.info("ACTS_ZipFile_2300 mkdir failed with error:" + error);
});
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);
done();
})
done();
});
} catch (err) {
console.error('ACTS_ZipFile_2300 err:' + err);
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==================");
let dirfirst = "/data/accounts/account_0/appdata"
let dirsecond =dirfirst + "/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST"
let dir = dirsecond + "/com.example.amsZipfileUnzipfileST.MainAbility/files";
let path = dir + "/ACTS_ZipFile_2400.txt";
var zipDest = dir + "/ACTS_ZipFile_2400.zip"
let infos = path + dir;
let unzipdirfirst = "/data/accounts/account_0/appdata";
let unzipdirsecond = unzipdirfirst + "/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST"
let unzipdir =unzipdirsecond + "/com.example.amsZipfileUnzipfileST.MainAbility/files/ACTS_ZipFile_2400";
let unzipresultfile = unzipdir + "/ACTS_ZipFile_2400.txt";
let 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);
}).catch(function (err) {
console.info("ACTS_ZipFile_2400 write data to file failed with error:" + err);
});
try {
var options = {};
options.level = zlib.CompressLevel.COMPRESS_LEVEL_BEST_COMPRESSION;
await zlib.zipFile(path, zipDest, options,
(err, 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");
}).catch(function (error) {
console.info("ACTS_ZipFile_2400 mkdir failed with error:" + error);
});
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);
done();
})
done();
});
} catch (err) {
console.error('ACTS_ZipFile_2400 err:' + err);
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==================");
let dirfirst = "/data/accounts/account_0/appdata"
let dirsecond =dirfirst + "/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST"
let dir = dirsecond + "/com.example.amsZipfileUnzipfileST.MainAbility/files";
let path = dir + "/ACTS_ZipFile_2500.txt";
var zipDest = dir + "/ACTS_ZipFile_2500.zip"
let infos = path + dir;
let unzipdirfirst = "/data/accounts/account_0/appdata";
let unzipdirsecond = unzipdirfirst + "/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST"
let unzipdir =unzipdirsecond + "/com.example.amsZipfileUnzipfileST.MainAbility/files/ACTS_ZipFile_2500";
let unzipresultfile = unzipdir + "/ACTS_ZipFile_2500.txt";
let 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);
}).catch(function (err) {
console.info("ACTS_ZipFile_2500 write data to file failed with error:" + err);
});
try {
var options = {};
options.level = zlib.CompressLevel.COMPRESS_LEVEL_DEFAULT_COMPRESSION;
await zlib.zipFile(path, zipDest, options,
(err, 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");
}).catch(function (error) {
console.info("ACTS_ZipFile_2500 mkdir failed with error:" + error);
});
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);
done();
})
done();
});
} catch (err) {
console.error('ACTS_ZipFile_2500 err:' + err);
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==================");
let dirfirst = "/data/accounts/account_0/appdata"
let dirsecond =dirfirst + "/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST"
let dir = dirsecond + "/com.example.amsZipfileUnzipfileST.MainAbility/files";
let path = dir + "/ACTS_ZipFile_2600.txt";
var zipDest = dir + "/ACTS_ZipFile_2600.zip"
let infos = path + dir;
let unzipdirfirst = "/data/accounts/account_0/appdata";
let unzipdirsecond = unzipdirfirst + "/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST"
let unzipdir =unzipdirsecond + "/com.example.amsZipfileUnzipfileST.MainAbility/files/ACTS_ZipFile_2600";
let unzipresultfile = unzipdir + "/ACTS_ZipFile_2600.txt";
let 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);
}).catch(function (err) {
console.info("ACTS_ZipFile_2600 write data to file failed with error:" + err);
});
try {
var options = {};
options.memLevel = zlib.MemLevel.MEM_LEVEL_MIN_MEMLEVEL;
await zlib.zipFile(path, zipDest, options,
(err, 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");
}).catch(function (error) {
console.info("ACTS_ZipFile_2600 mkdir failed with error:" + error);
});
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);
done();
})
done();
});
} catch (err) {
console.error('ACTS_ZipFile_2600 err:' + err);
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==================");
let dirfirst = "/data/accounts/account_0/appdata"
let dirsecond =dirfirst + "/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST"
let dir = dirsecond + "/com.example.amsZipfileUnzipfileST.MainAbility/files";
let path = dir + "/ACTS_ZipFile_2700.txt";
var zipDest = dir + "/ACTS_ZipFile_2700.zip"
let infos = path + dir;
let unzipdirfirst = "/data/accounts/account_0/appdata";
let unzipdirsecond = unzipdirfirst + "/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST"
let unzipdir =unzipdirsecond + "/com.example.amsZipfileUnzipfileST.MainAbility/files/ACTS_ZipFile_2700";
let unzipresultfile = unzipdir + "/ACTS_ZipFile_2700.txt";
let 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);
}).catch(function (err) {
console.info("ACTS_ZipFile_2700 write data to file failed with error:" + err);
});
try {
var options = {};
options.memLevel = zlib.MemLevel.MEM_LEVEL_MAX_MEMLEVEL;
await zlib.zipFile(path, zipDest, options,
(err, 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");
}).catch(function (error) {
console.info("ACTS_ZipFile_2700 mkdir failed with error:" + error);
});
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);
done();
})
done();
});
} catch (err) {
console.error('ACTS_ZipFile_2700 err:' + err);
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==================");
let dirfirst = "/data/accounts/account_0/appdata"
let dirsecond =dirfirst + "/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST"
let dir = dirsecond + "/com.example.amsZipfileUnzipfileST.MainAbility/files";
let path = dir + "/ACTS_ZipFile_2800.txt";
var zipDest = dir + "/ACTS_ZipFile_2800.zip"
let infos = path + dir;
let unzipdirfirst = "/data/accounts/account_0/appdata";
let unzipdirsecond = unzipdirfirst + "/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST"
let unzipdir =unzipdirsecond + "/com.example.amsZipfileUnzipfileST.MainAbility/files/ACTS_ZipFile_2800";
let unzipresultfile = unzipdir + "/ACTS_ZipFile_2800.txt";
let 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);
}).catch(function (err) {
console.info("ACTS_ZipFile_2800 write data to file failed with error:" + err);
});
try {
var options = {};
options.memLevel = zlib.MemLevel.MEM_LEVEL_DEFAULT_MEMLEVEL;
await zlib.zipFile(path, zipDest, options,
(err, 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");
}).catch(function (error) {
console.info("ACTS_ZipFile_2800 mkdir failed with error:" + error);
});
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);
done();
})
done();
});
} catch (err) {
console.error('ACTS_ZipFile_2800 err:' + err);
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==================");
let dirfirst = "/data/accounts/account_0/appdata"
let dirsecond =dirfirst + "/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST"
let dir = dirsecond + "/com.example.amsZipfileUnzipfileST.MainAbility/files";
let path = dir + "/ACTS_ZipFile_2900.txt";
var zipDest = dir + "/ACTS_ZipFile_2900.zip"
let infos = path + dir;
let unzipdirfirst = "/data/accounts/account_0/appdata";
let unzipdirsecond = unzipdirfirst + "/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST"
let unzipdir =unzipdirsecond + "/com.example.amsZipfileUnzipfileST.MainAbility/files/ACTS_ZipFile_2900";
let unzipresultfile = unzipdir + "/ACTS_ZipFile_2900.txt";
let 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);
}).catch(function (err) {
console.info("ACTS_ZipFile_2900 write data to file failed with error:" + err);
});
try {
var options = {};
options.strategy = zlib.CompressStrategy.COMPRESS_STRATEGY_DEFAULT_STRATEGY;
await zlib.zipFile(path, zipDest, options,
(err, 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");
}).catch(function (error) {
console.info("ACTS_ZipFile_2900 mkdir failed with error:" + error);
});
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);
done();
})
done();
});
} catch (err) {
console.error('ACTS_ZipFile_2900 err:' + err);
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==================");
let dirfirst = "/data/accounts/account_0/appdata"
let dirsecond =dirfirst + "/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST"
let dir = dirsecond + "/com.example.amsZipfileUnzipfileST.MainAbility/files";
let path = dir + "/ACTS_ZipFile_3000.txt";
var zipDest = dir + "/ACTS_ZipFile_3000.zip"
let infos = path + dir;
let unzipdirfirst = "/data/accounts/account_0/appdata";
let unzipdirsecond = unzipdirfirst + "/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST"
let unzipdir =unzipdirsecond + "/com.example.amsZipfileUnzipfileST.MainAbility/files/ACTS_ZipFile_3000";
let unzipresultfile = unzipdir + "/ACTS_ZipFile_3000.txt";
let 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);
}).catch(function (err) {
console.info("ACTS_ZipFile_3000 write data to file failed with error:" + err);
});
try {
var options = {};
options.strategy = zlib.CompressStrategy.COMPRESS_STRATEGY_FILTERED;
await zlib.zipFile(path, zipDest, options,
(err, 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");
}).catch(function (error) {
console.info("ACTS_ZipFile_3000 mkdir failed with error:" + error);
});
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);
done();
})
done();
});
} catch (err) {
console.error('ACTS_ZipFile_3000 err:' + err);
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==================");
let dirfirst = "/data/accounts/account_0/appdata"
let dirsecond =dirfirst + "/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST"
let dir = dirsecond + "/com.example.amsZipfileUnzipfileST.MainAbility/files";
let path = dir + "/ACTS_ZipFile_3100.txt";
var zipDest = dir + "/ACTS_ZipFile_3100.zip"
let infos = path + dir;
let unzipdirfirst = "/data/accounts/account_0/appdata";
let unzipdirsecond = unzipdirfirst + "/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST"
let unzipdir =unzipdirsecond + "/com.example.amsZipfileUnzipfileST.MainAbility/files/ACTS_ZipFile_3100";
let unzipresultfile = unzipdir + "/ACTS_ZipFile_3100.txt";
let 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);
}).catch(function (err) {
console.info("ACTS_ZipFile_3100 write data to file failed with error:" + err);
});
try {
var options = {};
options.strategy = zlib.CompressStrategy.COMPRESS_STRATEGY_HUFFMAN_ONLY;
await zlib.zipFile(path, zipDest, options,
(err, 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");
}).catch(function (error) {
console.info("ACTS_ZipFile_3100 mkdir failed with error:" + error);
});
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);
done();
})
done();
});
} catch (err) {
console.error('ACTS_ZipFile_3100 err:' + err);
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==================");
let dirfirst = "/data/accounts/account_0/appdata"
let dirsecond =dirfirst + "/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST"
let dir = dirsecond + "/com.example.amsZipfileUnzipfileST.MainAbility/files";
let path = dir + "/ACTS_ZipFile_3200.txt";
var zipDest = dir + "/ACTS_ZipFile_3200.zip"
let infos = path + dir;
let unzipdirfirst = "/data/accounts/account_0/appdata";
let unzipdirsecond = unzipdirfirst + "/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST"
let unzipdir =unzipdirsecond + "/com.example.amsZipfileUnzipfileST.MainAbility/files/ACTS_ZipFile_3200";
let unzipresultfile = unzipdir + "/ACTS_ZipFile_3200.txt";
let 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);
}).catch(function (err) {
console.info("ACTS_ZipFile_3200 write data to file failed with error:" + err);
});
try {
var options = {};
options.strategy = zlib.CompressStrategy.COMPRESS_STRATEGY_RLE;
await zlib.zipFile(path, zipDest, options,
(err, 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");
}).catch(function (error) {
console.info("ACTS_ZipFile_3200 mkdir failed with error:" + error);
});
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();
})
done();
});
} catch (err) {
console.error('ACTS_ZipFile_3200 err:' + err);
done();
}
console.log("==================ACTS_ZipFile_3200 end==================");
})
/*
* @tc.number: ACTS_ZipFile_3300
* @tc.name: zipFile
* @tc.desc: COMPRESS_STRATEGY_FILTERED,,
*/
it('ACTS_ZipFile_3300', 0, async function (done) {
console.log("==================ACTS_ZipFile_3300 start==================");
let dirfirst = "/data/accounts/account_0/appdata"
let dirsecond =dirfirst + "/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST"
let dir = dirsecond + "/com.example.amsZipfileUnzipfileST.MainAbility/files";
let path = dir + "/ACTS_ZipFile_3300.txt";
var zipDest = dir + "/ACTS_ZipFile_3300.zip"
let infos = path + dir;
let unzipdirfirst = "/data/accounts/account_0/appdata";
let unzipdirsecond = unzipdirfirst + "/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST"
let unzipdir =unzipdirsecond + "/com.example.amsZipfileUnzipfileST.MainAbility/files/ACTS_ZipFile_3300";
let unzipresultfile = unzipdir + "/ACTS_ZipFile_3300.txt";
let 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);
}).catch(function (err) {
console.info("ACTS_ZipFile_3300 write data to file failed with error:" + err);
});
try {
var options = {};
options.strategy = zlib.CompressStrategy.COMPRESS_STRATEGY_FILTERED;
await zlib.zipFile(path, zipDest, options,
(err, 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");
}).catch(function (error) {
console.info("ACTS_ZipFile_3300 mkdir failed with error:" + error);
});
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);
done();
})
done();
});
} catch (err) {
console.error('ACTS_ZipFile_3300 err:' + err);
done();
}
console.log("==================ACTS_ZipFile_3300 end==================");
})
/*
* @tc.number: ACTS_ZipFile_3400
* @tc.name: zipFile
* @tc.desc: FLUSH_TYPE_NO_FLUSH,,
*/
it('ACTS_ZipFile_3400', 0, async function (done) {
console.log("==================ACTS_ZipFile_3400 start==================");
let dirfirst = "/data/accounts/account_0/appdata"
let dirsecond =dirfirst + "/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST"
let dir = dirsecond + "/com.example.amsZipfileUnzipfileST.MainAbility/files";
let path = "";
var zipDest = dir + "/ACTS_ZipFile_3400.zip"
var options = {};
options.flush = zlib.FlushType.FLUSH_TYPE_NO_FLUSH;
zlib.zipFile(path, dir, options).then((data) => {
console.log("ACTS_ZipFile_3400 data: " + data);
expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_ERRNO);
done();
}).catch((err) => {
console.log("ACTS_ZipFile_3400 err: " + err);
done();
});
console.log("==================ACTS_ZipFile_3400 end ==================");
})
/*
* @tc.number: ACTS_ZipFile_3500
* @tc.name: zipFile
* @tc.desc: FLUSH_TYPE_NO_FLUSH,,
*/
it('ACTS_ZipFile_3500', 0, async function (done) {
console.log("==================ACTS_ZipFile_3500 start==================");
let dirfirst = "/data/accounts/account_0/appdata"
let dirsecond =dirfirst + "/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST"
let dir = dirsecond + "/com.example.amsZipfileUnzipfileST.MainAbility/files";
let path = dir + "/ACTS_ZipFile_3500.txt";
let src = dir + "/ACTS_ZipFile_5500.txt";
var zipDest = dir + "/ACTS_ZipFile_3500.zip"
let infos = path + dir;
let unzipdirfirst = "/data/accounts/account_0/appdata";
let unzipdirsecond = unzipdirfirst + "/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST"
let unzipdir =unzipdirsecond + "/com.example.amsZipfileUnzipfileST.MainAbility/files/ACTS_ZipFile_3500";
let unzipresultfile = unzipdir + "/ACTS_ZipFile_3500.txt";
let fd = fileio.openSync(path, 0o100 | 0o2, 0o666);
fileio.write(fd, infos).then(function (number) {
console.info("ACTS_ZipFile_3500 write data to file successfully:" + number);
}).catch(function (err) {
console.info("ACTS_ZipFile_3500 write data to file failed with error:" + err);
});
var options = {};
zlib.zipFile(src, dir, options).then((data) => {
console.log("zipFilePromise_3500 data: " + data);
expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_ERRNO);
done();
}).catch((err) => {
console.log("zipFilePromise_3500 err: " + err);
done();
});
console.log("==================zipFilePromise_3500 end ==================");
})
/*
* @tc.number: ACTS_ZipFile_3600
* @tc.name: zipFile
* @tc.desc: FLUSH_TYPE_NO_FLUSH,,
*/
it('ACTS_ZipFile_3600', 0, async function (done) {
console.log("==================ACTS_ZipFile_3600 start==================");
let dirfirst = "/data/accounts/account_0/appdata"
let dirsecond =dirfirst + "/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST"
let dir = dirsecond + "/com.example.amsZipfileUnzipfileST.MainAbility/files";
let path = dir + "/ACTS_ZipFile_3600.txt";
var zipDest = "";
let infos = path + dir;
let unzipdirfirst = "/data/accounts/account_0/appdata";
let unzipdirsecond = unzipdirfirst + "/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST"
let unzipdir =unzipdirsecond + "/com.example.amsZipfileUnzipfileST.MainAbility/files/ACTS_ZipFile_3600";
let unzipresultfile = unzipdir + "/ACTS_ZipFile_3600.txt";
let 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);
}).catch(function (err) {
console.info("ACTS_ZipFile_3600 write data to file failed with error:" + err);
});
var options = {};
zlib.zipFile(path, zipDest, options).then((data) => {
console.log("zipFilePromise_3600 data: " + data);
expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_ERRNO);
done();
}).catch((err) => {
console.log("zipFilePromise_3600 err: " + err);
done();
});
console.log("==================zipFilePromise_3600 end ==================")
})
/*
* @tc.number: ACTS_ZipFile_3700
* @tc.name: zipFile
* @tc.desc: FLUSH_TYPE_NO_FLUSH,,
*/
it('ACTS_ZipFile_3700', 0, async function (done) {
console.log("==================ACTS_ZipFile_3700 start==================");
let dirfirst = "/data/accounts/account_0/appdata"
let dirsecond =dirfirst + "/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST"
let dir = dirsecond + "/com.example.amsZipfileUnzipfileST.MainAbility/files";
let path = dir + "/ACTS_ZipFile_3700.txt";
var zipDest = dir + "/ACTS_ZipFile_3700.zip";
var src = dir + "/ACTS_ZipFile_6600.zip";
let infos = path + dir;
let unzipresultfilefirst = "/data/accounts/account_0/appdata";
let unzipresultfilersecond = unzipresultfilefirst + "/com.example.amsZipfileUnzipfileST";
let unzipresultfilerThrid = unzipresultfilersecond+"/com.example.amsZipfileUnzipfileST";
let unzipresult=unzipresultfilerThrid+"/com.example.amsZipfileUnzipfileST.MainAbility/files/ACTS_ZipFile_9200";
let unzipdirfirst = "/data/accounts/account_0/appdata";
let unzipdirsecond = unzipdirfirst + "/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST"
let unzipdir =unzipdirsecond + "/com.example.amsZipfileUnzipfileST.MainAbility/files/ACTS_ZipFile_3700";
let fd = fileio.openSync(path, 0o100 | 0o2, 0o666);
fileio.write(fd, infos).then(function (number) {
console.info("ACTS_ZipFile_3700 write data to file successfully:" + number);
}).catch(function (err) {
console.info("ACTS_ZipFile_3700 write data to file failed with error:" + err);
});
var options = {};
options.flush = zlib.FlushType.FLUSH_TYPE_NO_FLUSH;
zlib.zipFile(src, unzipresultfile, options).then((data) => {
console.log("zipFilePromise_3700 data: " + data);
expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_ERRNO);
done();
}).catch((err) => {
console.log("zipFilePromise_3700 err: " + err);
done();
});
console.log("==================zipFilePromise_3700 end ==================");
fileio.mkdir(unzipdir).then(function () {
console.info("ACTS_ZipFile_3700 mkdir successfully");
}).catch(function (error) {
console.info("ACTS_ZipFile_3700 mkdir failed with error:" + error);
});
})
/*
* @tc.number: ACTS_ZipFile_3800
* @tc.name: zipFile
* @tc.desc: FLUSH_TYPE_NO_FLUSH,,
*/
it('ACTS_ZipFile_3800', 0, async function (done) {
console.log("==================ACTS_ZipFile_3800 start==================");
let dirfirst = "/data/accounts/account_0/appdata"
let dirsecond =dirfirst + "/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST"
let dir = dirsecond + "/com.example.amsZipfileUnzipfileST.MainAbility/files";
let path = dir + "/ACTS_ZipFile_3800.txt";
var zipDest = dir + "/ACTS_ZipFile_3800.zip"
let infos = path + dir;
let unzipdirfirst = "/data/accounts/account_0/appdata";
let unzipdirsecond = unzipdirfirst + "/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST"
let unzipdir =unzipdirsecond + "/com.example.amsZipfileUnzipfileST.MainAbility/files/ACTS_ZipFile_3800";
let unzipresultfile = unzipdir + "/ACTS_ZipFile_3800.txt";
let fd = fileio.openSync(path, 0o100 | 0o2, 0o666);
fileio.write(fd, infos).then(function (number) {
console.info("ACTS_ZipFile_3800 write data to file successfully:" + number);
}).catch(function (err) {
console.info("ACTS_ZipFile_3800 write data to file failed with error:" + err);
});
try {
var options = {};
options.flush = zlib.FlushType.FLUSH_TYPE_NO_FLUSH;
await zlib.zipFile(path, zipDest, options,
(err, 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_3800 mkdir successfully");
}).catch(function (error) {
console.info("ACTS_ZipFile_3800 mkdir failed with error:" + error);
});
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_3800 unzipFile');
done();
}).catch((err) => {
console.log("ACTS_ZipFile_3800 err: " + err);
done();
})
done();
});
} catch (err) {
console.error('ACTS_ZipFile_3800 err:' + err);
done();
}
console.log("==================ACTS_ZipFile_3800 end==================");
})
/*
* @tc.number: ACTS_ZipFile_3900
* @tc.name: zipFile
* @tc.desc: FLUSH_TYPE_NO_FLUSH,,
*/
it('ACTS_ZipFile_3900', 0, async function (done) {
console.log("==================ACTS_ZipFile_3900 start==================");
let dirfirst = "/data/accounts/account_0/appdata"
let dirsecond =dirfirst + "/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST"
let dir = dirsecond + "/com.example.amsZipfileUnzipfileST.MainAbility/files";
let path = dir + "/ACTS_ZipFile_3900.txt";
var zipDest = dir + "/ACTS_ZipFile_3900.zip"
let infos = path + dir;
let unzipdirfirst = "/data/accounts/account_0/appdata";
let unzipdirsecond = unzipdirfirst + "/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST"
let unzipdir =unzipdirsecond + "/com.example.amsZipfileUnzipfileST.MainAbility/files/ACTS_ZipFile_3900";
let unzipresultfile = unzipdir + "/ACTS_ZipFile_3900.txt";
let fd = fileio.openSync(path, 0o100 | 0o2, 0o666);
fileio.write(fd, infos).then(function (number) {
console.info("ACTS_ZipFile_3900 write data to file successfully:" + number);
}).catch(function (err) {
console.info("ACTS_ZipFile_3900 write data to file failed with error:" + err);
});
try {
var options = {};
options.flush = zlib.FlushType.FLUSH_TYPE_NO_FLUSH;
await zlib.zipFile(path, zipDest, options,
(err, 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_3900 mkdir successfully");
}).catch(function (error) {
console.info("ACTS_ZipFile_3900 mkdir failed with error:" + error);
});
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_3900 unzipFile');
done();
}).catch((err) => {
console.log("ACTS_ZipFile_3900 err: " + err);
done();
})
done();
});
} catch (err) {
console.error('ACTS_ZipFile_3900 err:' + err);
done();
}
console.log("==================ACTS_ZipFile_3900 end==================");
})
/*
* @tc.number: ACTS_ZipFile_4000
* @tc.name: zipFile
* @tc.desc: FLUSH_TYPE_NO_FLUSH,,
*/
it('ACTS_ZipFile_4000', 0, async function (done) {
console.log("==================FWK_ZipFile_0600 start==================");
let dirfirst = "/data/accounts/account_0/appdata"
let dirsecond =dirfirst + "/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST"
let dir = dirsecond + "/com.example.amsZipfileUnzipfileST.MainAbility/files";
let path = dir + "/ACTS_ZipFile_4000.txt";
var zipDest = dir + "/ACTS_ZipFile_4000.zip"
let infos = path + dir;
let unzipdirfirst = "/data/accounts/account_0/appdata";
let unzipdirsecond = unzipdirfirst + "/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST"
let unzipdir =unzipdirsecond + "/com.example.amsZipfileUnzipfileST.MainAbility/files/ACTS_ZipFile_4000";
let unzipresultfile = unzipdir + "/ACTS_ZipFile_4000.txt";
let fd = fileio.openSync(path, 0o100 | 0o2, 0o666);
fileio.write(fd, infos).then(function (number) {
console.info("ACTS_ZipFile_4000 write data to file successfully:" + number);
}).catch(function (err) {
console.info("ACTS_ZipFile_4000 write data to file failed with error:" + err);
});
try {
var options = {};
options.flush = zlib.FlushType.FLUSH_TYPE_NO_FLUSH;
await zlib.zipFile(path, zipDest, options,
(err, 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_4000 mkdir successfully");
}).catch(function (error) {
console.info("ACTS_ZipFile_4000 mkdir failed with error:" + error);
});
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_4000 unzipFile');
done();
}).catch((err) => {
console.log("ACTS_ZipFile_4000 err: " + err);
done();
})
done();
});
} catch (err) {
console.error('ACTS_ZipFile_0500 err:' + err);
done();
}
console.log("==================ACTS_ZipFile_4000 end==================");
})
/*
* @tc.number: ACTS_ZipFile_4100
* @tc.name: zipFile
* @tc.desc: FLUSH_TYPE_NO_FLUSH,,
*/
it('ACTS_ZipFile_4100', 0, async function (done) {
console.log("==================ACTS_ZipFile_4100 start==================");
let dirfirst = "/data/accounts/account_0/appdata"
let dirsecond =dirfirst + "/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST"
let dir = dirsecond + "/com.example.amsZipfileUnzipfileST.MainAbility/files";
let path = dir + "/ACTS_ZipFile_4100.txt";
var zipDest = dir + "/ACTS_ZipFile_4100.zip"
let infos = path + dir;
let unzipdirfirst = "/data/accounts/account_0/appdata";
let unzipdirsecond = unzipdirfirst + "/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST"
let unzipdir =unzipdirsecond + "/com.example.amsZipfileUnzipfileST.MainAbility/files/ACTS_ZipFile_4100";
let unzipresultfile = unzipdir + "/ACTS_ZipFile_4100.txt";
let fd = fileio.openSync(path, 0o100 | 0o2, 0o666);
fileio.write(fd, infos).then(function (number) {
console.info("ACTS_ZipFile_4100 write data to file successfully:" + number);
}).catch(function (err) {
console.info("ACTS_ZipFile_4100 write data to file failed with error:" + err);
});
try {
var options = {};
options.flush = zlib.FlushType.FLUSH_TYPE_NO_FLUSH;
await zlib.zipFile(path, zipDest, options,
(err, 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_4100 mkdir successfully");
}).catch(function (error) {
console.info("ACTS_ZipFile_4100 mkdir failed with error:" + error);
});
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_4100 unzipFile');
done();
}).catch((err) => {
console.log("ACTS_ZipFile_4100 err: " + err);
done();
})
done();
});
} catch (err) {
console.error('ACTS_ZipFile_4100 err:' + err);
done();
}
console.log("==================ACTS_ZipFile_4100 end==================");
})
/*
* @tc.number: ACTS_ZipFile_4200
* @tc.name: zipFile
* @tc.desc: FLUSH_TYPE_NO_FLUSH,,
*/
it('ACTS_ZipFile_4200', 0, async function (done) {
console.log("==================ACTS_ZipFile_4200 start==================");
let dirfirst = "/data/accounts/account_0/appdata"
let dirsecond =dirfirst + "/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST"
let dir = dirsecond + "/com.example.amsZipfileUnzipfileST.MainAbility/files";
let src = dir + "/ACTS_ZipFile_100000.txt";
let path = dir + "/ACTS_ZipFile_9900.txt";
var zipDest = dir + "/ACTS_ZipFile_4200.zip"
let infos = path + dir;
let unzipdirfirst = "/data/accounts/account_0/appdata";
let unzipdirsecond = unzipdirfirst + "/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST"
let unzipdir =unzipdirsecond + "/com.example.amsZipfileUnzipfileST.MainAbility/files/ACTS_ZipFile_4200";
let unzipresultfile = unzipdir + "/ACTS_ZipFile_4200.txt";
let 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);
}).catch(function (err) {
console.info("ACTS_ZipFile_0200 write data to file failed with error:" + err);
});
var options = {};
options.flush = zlib.FlushType.FLUSH_TYPE_NO_FLUSH;
await zlib.zipFile(src, dir, options,
(err, data) => {
console.log("ACTS_ZipFile_4200 data: " + data);
expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_ERRNO);
done();
});
})
/*
* @tc.number: ACTS_ZipFile_4300
* @tc.name: zipFile
* @tc.desc: FLUSH_TYPE_NO_FLUSH,,
*/
it('ACTS_ZipFile_4300', 0, async function (done) {
console.log("==================ACTS_ZipFile_4300 start==================");
let dirfirst = "/data/accounts/account_0/appdata"
let dirsecond =dirfirst + "/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST"
let dir = dirsecond + "/com.example.amsZipfileUnzipfileST.MainAbility/files";
var zipDest = dir + "/ACTS_ZipFile_4300.zip"
var options = {};
options.flush = zlib.FlushType.FLUSH_TYPE_NO_FLUSH;
await zlib.unzipFile(dir, zipDest, options,
(err, data) => {
console.log("ACTS_ZipFile_4300 data: " + data);
expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_ERRNO);
done();
});
})
/*
* @tc.number: ACTS_ZipFile_4400
* @tc.name: zipFile
* @tc.desc: FLUSH_TYPE_NO_FLUSH,,
*/
it('ACTS_ZipFile_4400', 0, async function (done) {
console.log("==================ACTS_ZipFile_4400 start==================");
let dirfirst = "/data/accounts/account_0/appdata"
let dirsecond =dirfirst + "/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST"
let dir = dirsecond + "/com.example.amsZipfileUnzipfileST.MainAbility/files";
let path = dir + "/ACTS_ZipFile_4400.txt";
var zipDest = dir + "/ACTS_ZipFile_4400.zip"
let infos = path + dir;
let unzipdirfirst = "/data/accounts/account_0/appdata";
let unzipdirsecond = unzipdirfirst + "/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST"
let unzipdir =unzipdirsecond + "/com.example.amsZipfileUnzipfileST.MainAbility/files/ACTS_ZipFile_4400";
let unzipresultfile = unzipdir + "/ACTS_ZipFile_4400.txt";
let fd = fileio.openSync(path, 0o100 | 0o2, 0o666);
fileio.write(fd, infos).then(function (number) {
console.info("ACTS_ZipFile_4400 write data to file successfully:" + number);
}).catch(function (err) {
console.info("ACTS_ZipFile_4400 write data to file failed with error:" + err);
});
var options = {};
options.flush = zlib.FlushType.FLUSH_TYPE_PARTIAL_FLUSH;
zlib.unzipFile(path, zipDest, options,
(err, data) => {
console.log("FWK_ZipFile_4400 data: " + data);
expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_ERRNO);
done();
});
})
/*
* @tc.number: ACTS_ZipFile_4500
* @tc.name: zipFile
* @tc.desc: FLUSH_TYPE_NO_FLUSH,,
*/
it('ACTS_ZipFile_4500', 0, async function (done) {
console.log("==================ACTS_ZipFile_5000 start==================");
let dirfirst = "/data/accounts/account_0/appdata"
let dirsecond =dirfirst + "/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST"
let dir = dirsecond + "/com.example.amsZipfileUnzipfileST.MainAbility/files";
let path = dir + "/ACTS_ZipFile_4500.txt";
var zipDest = dir + "/ACTS_ZipFile_4500.zip"
var unzipDest = dir + "/ACTS_ZipFile_9900.zip"
let infos = path + dir;
let unzipdirfirst = "/data/accounts/account_0/appdata";
let unzipdirsecond = unzipdirfirst + "/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST"
let unzipdir =unzipdirsecond + "/com.example.amsZipfileUnzipfileST.MainAbility/files/ACTS_ZipFile_4500";
let zipdirfirst = "/data/accounts/account_0/appdata";
let zipdirsecond = zipdirfirst + "/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST"
let zipdir =zipdirsecond + "/com.example.amsZipfileUnzipfileST.MainAbility/files/ACTS_ZipFile_9900";
let unzipresultfile = unzipdir + "/ACTS_ZipFile_4500.txt";
let 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);
}).catch(function (err) {
console.info("ACTS_ZipFile_4500 write data to file failed with error:" + err);
});
var options = {};
options.strategy = zlib.CompressStrategy.COMPRESS_STRATEGY_FILTERED;
await zlib.zipFile(path, zipDest, options,
(err, 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");
}).catch(function (error) {
console.info("ACTS_ZipFile_4500 mkdir failed with error:" + error);
});
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);
done();
})
done();
})
})
/*
* @tc.number: ACTS_ZipFile_4600
* @tc.name: zipFile
* @tc.desc: FLUSH_TYPE_NO_FLUSH,,
*/
it('ACTS_ZipFile_4600', 0, async function (done) {
console.log("==================ACTS_ZipFile_4600 start==================");
let dirfirst = "/data/accounts/account_0/appdata"
let dirsecond =dirfirst + "/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST"
let dir = dirsecond + "/com.example.amsZipfileUnzipfileST.MainAbility/files";
let path = "";
var zipDest = dir + "/ACTS_ZipFile_4600.txt";
let infos = path + dir;
var options = {};
options.flush = zlib.FlushType.FLUSH_TYPE_NO_FLUSH;
await zlib.unzipFile(path, dir, options,
(err, data) => {
console.log("ACTS_ZipFile_4600 data: " + data);
expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_ERRNO);
done();
});
})
/*
* @tc.number: ACTS_ZipFile_4700
* @tc.name: zipFile
* @tc.desc: FLUSH_TYPE_NO_FLUSH,,
*/
it('ACTS_ZipFile_4700', 0, async function (done) {
console.log("==================ACTS_ZipFile_4700 start==================");
let dirfirst = "/data/accounts/account_0/appdata"
let dirsecond =dirfirst + "/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST"
let dir = dirsecond + "/com.example.amsZipfileUnzipfileST.MainAbility/files";
var zipDest = dir + "/ACTS_ZipFile_4700.zip"
var options = {};
options.flush = zlib.FlushType.FLUSH_TYPE_NO_FLUSH;
await zlib.unzipFile(dir, zipDest, options,
(err, data) => {
console.log("ACTS_ZipFile_4700 data: " + data);
expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_ERRNO);
done();
});
})
/*
* @tc.number: ACTS_ZipFile_4800
* @tc.name: zipFile
* @tc.desc: FLUSH_TYPE_NO_FLUSH,,
*/
it('ACTS_ZipFile_4800', 0, async function (done) {
console.log("==================ACTS_ZipFile_4800 start==================");
let dirfirst = "/data/accounts/account_0/appdata"
let dirsecond =dirfirst + "/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST"
let dir = dirsecond + "/com.example.amsZipfileUnzipfileST.MainAbility/files";
let path = dir + "/ACTS_ZipFile_4800.txt";
var zipDest = dir + "/ACTS_ZipFile_4800.zip"
let infos = path + dir;
let unzipdirfirst = "/data/accounts/account_0/appdata";
let unzipdirsecond = unzipdirfirst + "/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST"
let unzipdir =unzipdirsecond + "/com.example.amsZipfileUnzipfileST.MainAbility/files/ACTS_ZipFile_4800";
let unzipresultfile = unzipdir + "/ACTS_ZipFile_4800.txt";
let fd = fileio.openSync(path, 0o100 | 0o2, 0o666);
fileio.write(fd, infos).then(function (number) {
console.info("ACTS_ZipFile_4800 write data to file successfully:" + number);
}).catch(function (err) {
console.info("ACTS_ZipFile_4800 write data to file failed with error:" + err);
});
var options = {};
options.flush = zlib.FlushType.FLUSH_TYPE_PARTIAL_FLUSH;
zlib.unzipFile(path, zipDest, options,
(err, data) => {
console.log("ACTS_ZipFile_4800 data: " + data);
expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_ERRNO);
done();
});
})
/*
* @tc.number: ACTS_ZipFile_4900
* @tc.name: zipFile
* @tc.desc: FLUSH_TYPE_NO_FLUSH,,
*/
it('ACTS_ZipFile_4900', 0, async function (done) {
console.log("==================ACTS_ZipFile_4900 start==================");
let dirfirst = "/data/accounts/account_0/appdata"
let dirsecond =dirfirst + "/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST"
let dir = dirsecond + "/com.example.amsZipfileUnzipfileST.MainAbility/files";
let path = dir + "/ACTS_ZipFile_4900.txt";
var zipDest = dir + "/ACTS_ZipFile_4900.zip"
var unzipDest = dir + "/ACTS_ZipFile_4900.zip"
let infos = path + dir;
let unzipdirfirst = "/data/accounts/account_0/appdata";
let unzipdirsecond = unzipdirfirst + "/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST"
let unzipdir =unzipdirsecond + "/com.example.amsZipfileUnzipfileST.MainAbility/files/ACTS_ZipFile_4900";
let zipdirfirst = "/data/accounts/account_0/appdata";
let zipdirsecond = zipdirfirst + "/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST"
let zipdir =zipdirsecond + "/com.example.amsZipfileUnzipfileST.MainAbility/files/ACTS_ZipFile_9800";
let unzipresultfile = zipdir + "/ACTS_ZipFile_4900.txt";
let 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);
}).catch(function (err) {
console.info("ACTS_ZipFile_4900 write data to file failed with error:" + err);
});
var options = {};
options.strategy = zlib.CompressStrategy.COMPRESS_STRATEGY_FILTERED;
await zlib.zipFile(path, zipDest, options,
(err, 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");
}).catch(function (error) {
console.info("ACTS_ZipFile_4900 mkdir failed with error:" + error);
});
zlib.unzipFile(unzipDest, zipdir, options,
(err, data) => {
console.log("ACTS_ZipFile_4900 data: " + data);
expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_ERRNO);
done();
});
})
})
})
/*
* 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.
*/
require('./ContextJsunit.test.js')
{
"description": "Configuration for hjunit demo Tests",
"driver": {
"type": "JSUnitTest",
"test-timeout": "120000",
"package": "com.example.amsZipfileUnzipfileST",
"shell-timeout": "600000"
},
"kits": [
{
"test-file-name": [
"ActsAmsZipfileUnzipfileSTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
},
{
"type": "ShellKit",
"run-command": [
"remount",
"mkdir /data/test"
]
},
{
"type": "PushKit",
"push": [
"./resource/appexecfwk/ceshi.txt->/data/test/ceshi.txt",
"./resource/appexecfwk/ceshitwo.zip->/data/test/ceshitwo.zip",
"./resource/appexecfwk/ceshitwo.txt->/data/test/ceshitwo.txt"
]
},
{
"type": "ShellKit",
"run-command": [
"remount",
"mkdir /data/testA"
]
},
{
"type": "ShellKit",
"run-command": [
"chmod 777 /data/testA/*"
]
},
{
"type": "ShellKit",
"run-command": [
"chmod 777 /data/test/*"
]
},
{
"type": "ShellKit",
"run-command": [
"remount",
"mkdir /data/testb"
]
},
{
"type": "ShellKit",
"run-command": [
"chmod 777 /data/testb/*"
]
}
]
}
.container {
flex-direction: column;
justify-content: center;
align-items: center;
}
.title {
font-size: 100px;
}
{
"string": [
{
"name": "app_name",
"value": "amsZipfileUnzipfileST"
},
{
"name": "mainability_description",
"value": "JS_Phone_Empty Feature Ability"
},
{
"name": "serviceability_description",
"value": "JS_Phone_Empty Feature Ability"
}
]
}
\ No newline at end of file
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import zlib from '@ohos.zlib'
import fileio from '@ohos.fileio'
import file from '@system.file'
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
describe('ZlibTest', function () {
/*
* @tc.number: FWK_ZipFile_0100
* @tc.name: zipFile
* @tc.desc: inFile is empty
*/
it('FWK_ZipFile_0100', 0, async function (done) {
console.log("==================FWK_ZipFile_0100 start==================");
var src = "";
var dest = "/data/testA/";
var options = {}
zlib.zipFile(src, dest, options,
(err, data) => {
console.log("zipFileCallback_0100 data: " + data);
expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_STREAM_ERROR);
done();
});
})
/*
* @tc.number: FWK_ZipFile_0200
* @tc.name: zipFile
* @tc.desc: inFile doesn't exist
*/
it('FWK_ZipFile_0200', 0, async function (done) {
console.log("==================FWK_ZipFile_0200 start==================");
var src = "/data/test/notExist.txt";
var dest = "/data/testA/";
var options = {}
zlib.zipFile(src, dest, options,
(err, data) => {
console.log("zipFileCallBack_0200 data: " + data);
expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_STREAM_ERROR);
done();
});
})
/*
* @tc.number: FWK_ZipFile_0300
* @tc.name: zipFile
* @tc.desc: output file not specified
*/
it('FWK_ZipFile_0300', 0, async function (done) {
console.log("==================FWK_ZipFile_0300 start==================");
var src = "/data/test/ceshi.txt";
var dest = "";
var options = {}
zlib.zipFile(src, dest, options,
(err, data) => {
console.log("zipFileCallBack_0300 data: " + data);
expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_STREAM_ERROR);
done();
});
})
/*
* @tc.number: FWK_ZipFile_0400
* @tc.name: zipFile
* @tc.desc: The ouput file is a directory that does not exist
*/
it('FWK_ZipFile_0400', 0, async function (done) {
console.log("==================FWK_ZipFile_0400 start==================");
var src = "/data/test/ceshi.txt";
var dest = "/data/notExist/";
var options = {}
zlib.zipFile(src, dest, options,
(err, data) => {
console.log("zipFileCallBack_0400 data: " + data);
expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_STREAM_ERROR);
done();
});
})
/*
* @tc.number: FWK_ZipFile_0500
* @tc.name: zipFile
* @tc.desc: FlushType.FLUSH_TYPE_NO_FLUSH
*/
it('FWK_ZipFile_0500', 0, async function (done) {
console.log("==================FWK_ZipFile_0500 start==================");
var src = "/data/test/ceshi.txt";
var zipDest = "/data/testA/ceshi.zip";
var unzipDir = "/data/testA/";
var unzipDest = "/data/testA/ceshi.txt";
try {
var options = {};
options.flush = zlib.FlushType.FLUSH_TYPE_NO_FLUSH;
await zlib.zipFile(src, zipDest, options,
(err, data) => {
var zipStat = fileio.statSync(zipDest);
var isFile = zipStat.isFile();
expect(isFile).assertTrue();
var srcSize = fileio.statSync(src).size;
var destSize = zipStat.size;
expect(srcSize>destSize).assertTrue();
expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK);
zlib.unzipFile(zipDest, unzipDir, options,
(err, data) => {
var unzipStat = fileio.statSync(unzipDest);
var isFile = unzipStat.isFile();
expect(isFile).assertTrue();
var destSize = unzipStat.size;
var originSize = fileio.statSync(src).size;
var result = (originSize == destSize);
expect(result).assertTrue();
expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK);
done();
})
});
} catch(err) {
console.error('FWK_ZipFile_0500 err:' + err);
done();
}
console.log("==================FWK_ZipFile_0500 end==================");
})
/*
* @tc.number: FWK_ZipFile_0600
* @tc.name: zipFile
* @tc.desc: FlushType.FLUSH_TYPE_NO_FLUSH
*/
it('FWK_ZipFile_0600', 0, async function (done) {
console.log("==================FWK_ZipFile_0600 start==================");
var src = "/data/test/ceshi.txt";
var zipDest = "/data/testA/ceshi.zip";
var unzipDir = "/data/testA/";
var unzipDest = "/data/testA/ceshi.txt";
try {
var options = {};
options.flush = zlib.FlushType.FLUSH_TYPE_NO_FLUSH,
await zlib.zipFile(src, zipDest, options,
(err, data) => {
var zipStat = fileio.statSync(zipDest);
var isFile = zipStat.isFile();
expect(isFile).assertTrue();
var srcSize = fileio.statSync(src).size;
var destSize = zipStat.size;
expect(srcSize>destSize).assertTrue();
expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK);
zlib.unzipFile(zipDest, unzipDir, options,
(err, data) => {
var unzipStat = fileio.statSync(unzipDest);
var isFile = unzipStat.isFile();
expect(isFile).assertTrue();
var destSize = unzipStat.size;
var originSize = fileio.statSync(src).size;
var result = (originSize == destSize);
expect(result).assertTrue();
expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK);
done();
})
});
} catch(err) {
console.error('FWK_ZipFile_0500 err:' + err);
done();
}
console.log("==================FWK_ZipFile_0600 end==================");
})
/*
* @tc.number: FWK_ZipFile_0700
* @tc.name: zipFile
* @tc.desc: zipFile
*/
it('FWK_ZipFile_0700', 0, async function (done) {
console.log("==================FWK_ZipFile_0700 start==================");
var src = "/data/test/ceshi.txt";
var zipDest = "/data/testA/ceshi.zip";
var unzipDir = "/data/testA/";
var unzipDest = "/data/testA/ceshi.txt";
try{
var options = {};
options.flush = zlib.FlushType.FLUSH_TYPE_SYNC_FLUSH,
await zlib.zipFile(src, zipDest, options,
(err, data) => {
var zipStat = fileio.statSync(zipDest);
var isFile = zipStat.isFile();
expect(isFile).assertTrue();
var srcSize = fileio.statSync(src).size;
var destSize = zipStat.size;
expect(srcSize>destSize).assertTrue();
expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK);
zlib.unzipFile(zipDest, unzipDir, options,
(err, data) => {
var unzipStat = fileio.statSync(unzipDest);
var isFile = unzipStat.isFile();
expect(isFile).assertTrue();
var destSize = unzipStat.size;
var originSize = fileio.statSync(src).size;
var result = (originSize == destSize);
expect(result).assertTrue();
expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK);
done();
})
});
} catch(err) {
console.error('FWK_ZipFile_0500 err:' + err);
done();
}
console.log("==================FWK_ZipFile_0700 end==================");
})
/*
* @tc.number: FWK_ZipFile_0800
* @tc.name: zipFile
* @tc.desc: FlushType.FLUSH_TYPE_FULL_FLUSH
*/
it('FWK_ZipFile_0800', 0, async function (done) {
console.log("==================FWK_ZipFile_0800 start==================");
var src = "/data/test/ceshi.txt";
var zipDest = "/data/testA/ceshi.zip";
var unzipDir = "/data/testA/";
var unzipDest = "/data/testA/ceshi.txt";
try{
var options = {};
options.flush = zlib.FlushType.FLUSH_TYPE_FULL_FLUSH,
await zlib.zipFile(src, zipDest, options,
(err, data) => {
var zipStat = fileio.statSync(zipDest);
var isFile = zipStat.isFile();
expect(isFile).assertTrue();
var srcSize = fileio.statSync(src).size;
var destSize = zipStat.size;
expect(srcSize>destSize).assertTrue();
expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK);
zlib.unzipFile(zipDest, unzipDir, options,
(err, data) => {
var unzipStat = fileio.statSync(unzipDest);
var isFile = unzipStat.isFile();
expect(isFile).assertTrue();
var destSize = unzipStat.size;
var originSize = fileio.statSync(src).size;
var result = (originSize == destSize);
expect(result).assertTrue();
expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK);
done();
})
});
} catch(err) {
console.error('FWK_ZipFile_0500 err:' + err);
done();
}
console.log("==================FWK_ZipFile_0800 end==================");
})
/*
* @tc.number: FWK_ZipFile_0900
* @tc.name: zipFile
* @tc.desc: zipFile
*/
it('FWK_ZipFile_0900', 0, async function (done) {
console.log("==================FWK_ZipFile_0900 start==================");
var src = "/data/test/ceshi.txt";
var zipDest = "/data/testA/ceshi.zip";
var unzipDir = "/data/testA/";
var unzipDest = "/data/testA/ceshi.txt";
try{
var options = {};
options.flush = zlib.FlushType.FLUSH_TYPE_FINISH,
await zlib.zipFile(src, zipDest, options,
(err, data) => {
var zipStat = fileio.statSync(zipDest);
var isFile = zipStat.isFile();
expect(isFile).assertTrue();
var srcSize = fileio.statSync(src).size;
var destSize = zipStat.size;
expect(srcSize>destSize).assertTrue();
expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK);
zlib.unzipFile(zipDest, unzipDir, options,
(err, data) => {
var unzipStat = fileio.statSync(unzipDest);
var isFile = unzipStat.isFile();
expect(isFile).assertTrue();
var destSize = unzipStat.size;
var originSize = fileio.statSync(src).size;
var result = (originSize == destSize);
expect(result).assertTrue();
expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK);
done();
})
});
} catch(err) {
console.error('FWK_ZipFile_0500 err:' + err);
done();
}
console.log("==================FWK_ZipFile_0900 end==================");
})
/*
* @tc.number: FWK_ZipFile_1000
* @tc.name: zipFile
* @tc.desc: FlushType.FLUSH_TYPE_BLOCK
*/
it('FWK_ZipFile_1000', 0, async function (done) {
console.log("==================FWK_ZipFile_1000 start==================");
var src = "/data/test/ceshi.txt";
var zipDest = "/data/testA/ceshi.zip";
var unzipDir = "/data/testA/";
var unzipDest = "/data/testA/ceshi.txt";
try{
var options = {};
options.flush = zlib.FlushType.FLUSH_TYPE_BLOCK,
await zlib.zipFile(src, zipDest, options,
(err, data) => {
var zipStat = fileio.statSync(zipDest);
var isFile = zipStat.isFile();
expect(isFile).assertTrue();
var srcSize = fileio.statSync(src).size;
var destSize = zipStat.size;
expect(srcSize>destSize).assertTrue();
expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK);
zlib.unzipFile(zipDest, unzipDir, options,
(err, data) => {
var unzipStat = fileio.statSync(unzipDest);
var isFile = unzipStat.isFile();
expect(isFile).assertTrue();
var destSize = unzipStat.size;
var originSize = fileio.statSync(src).size;
var result = (originSize == destSize);
expect(result).assertTrue();
expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK);
done();
})
});
} catch(err) {
console.error('FWK_ZipFile_0500 err:' + err);
done();
}
console.log("==================FWK_ZipFile_1000 end==================");
})
/*
* @tc.number: FWK_ZipFile_1100
* @tc.name: zipFile
* @tc.desc: FlushType.FLUSH_TYPE_TREES
*/
it('FWK_ZipFile_1100', 0, async function (done) {
console.log("==================FWK_ZipFile_1100 start==================");
var src = "/data/test/ceshi.txt";
var zipDest = "/data/testA/ceshi.zip";
var unzipDir = "/data/testA/";
var unzipDest = "/data/testA/ceshi.txt";
try{
var options = {};
options.flush = zlib.FlushType.FLUSH_TYPE_TREES,
await zlib.zipFile(src, zipDest, options,
(err, data) => {
var zipStat = fileio.statSync(zipDest);
var isFile = zipStat.isFile();
expect(isFile).assertTrue();
var srcSize = fileio.statSync(src).size;
var destSize = zipStat.size;
expect(srcSize>destSize).assertTrue();
expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK);
zlib.unzipFile(zipDest, unzipDir, options,
(err, data) => {
var unzipStat = fileio.statSync(unzipDest);
var isFile = unzipStat.isFile();
expect(isFile).assertTrue();
var destSize = unzipStat.size;
var originSize = fileio.statSync(src).size;
var result = (originSize == destSize);
expect(result).assertTrue();
expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK);
done();
})
});
} catch(err) {
console.error('FWK_ZipFile_0500 err:' + err);
done();
}
console.log("==================FWK_ZipFile_1100 end==================");
sleep(10);
})
/*
* @tc.number: FWK_ZipFile_1200
* @tc.name: zipFile
* @tc.desc: FlushType.FLUSH_TYPE_NO_FLUSH
*/
it('FWK_ZipFile_1200', 0, async function (done) {
console.log("==================FWK_ZipFile_1200 start==================");
var src = "/data/test/ceshi.txt";
var zipDest = "/data/testA/ceshi.zip";
var unzipDir = "/data/testA/";
var unzipDest = "/data/testA/ceshi.txt";
try{
var options = {};
options.flush = zlib.FlushType.FLUSH_TYPE_NO_FLUSH,
await zlib.zipFile(src, zipDest, options,
(err, data) => {
var zipStat = fileio.statSync(zipDest);
var isFile = zipStat.isFile();
expect(isFile).assertTrue();
var srcSize = fileio.statSync(src).size;
var destSize = zipStat.size;
expect(srcSize>destSize).assertTrue();
expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK);
zlib.unzipFile(zipDest, unzipDir, options,
(err, data) => {
var unzipStat = fileio.statSync(unzipDest);
var isFile = unzipStat.isFile();
expect(isFile).assertTrue();
var destSize = unzipStat.size;
var originSize = fileio.statSync(src).size;
var result = (originSize == destSize);
expect(result).assertTrue();
expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK);
done();
})
});
} catch(err) {
console.error('FWK_ZipFile_0500 err:' + err);
done();
}
console.log("==================FWK_ZipFile_1200 end==================");
sleep(10);
})
/*
* @tc.number: FWK_ZipFile_1300
* @tc.name: zipFile
* @tc.desc: FlushType.FLUSH_TYPE_PARTIAL_FLUSH
*/
it('FWK_ZipFile_1300', 0, async function (done) {
console.log("==================FWK_ZipFile_1300 start==================");
var src = "/data/test/ceshi.txt";
var zipDest = "/data/testA/ceshi.zip";
var unzipDir = "/data/testA/";
var unzipDest = "/data/testA/ceshi.txt";
try{
var options = {};
options.flush = zlib.FlushType.FLUSH_TYPE_PARTIAL_FLUSH,
await zlib.zipFile(src, zipDest, options,
(err, data) => {
var zipStat = fileio.statSync(zipDest);
var isFile = zipStat.isFile();
expect(isFile).assertTrue();
var srcSize = fileio.statSync(src).size;
var destSize = zipStat.size;
expect(srcSize>destSize).assertTrue();
expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK);
zlib.unzipFile(zipDest, unzipDir, options,
(err, data) => {
var unzipStat = fileio.statSync(unzipDest);
var isFile = unzipStat.isFile();
expect(isFile).assertTrue();
var destSize = unzipStat.size;
var originSize = fileio.statSync(src).size;
var result = (originSize == destSize);
expect(result).assertTrue();
expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK);
done();
})
});
} catch(err) {
console.error('FWK_ZipFile_0500 err:' + err);
done();
}
console.log("==================FWK_ZipFile_1300 end==================");
})
/*
* @tc.number: FWK_ZipFile_1400
* @tc.name: zipFile
* @tc.desc: FlushType.FLUSH_TYPE_SYNC_FLUSH
*/
it('FWK_ZipFile_1400', 0, async function (done) {
console.log("==================FWK_ZipFile_1400 start==================");
var src = "/data/test/ceshi.txt";
var zipDest = "/data/testA/ceshi.zip";
var unzipDir = "/data/testA/";
var unzipDest = "/data/testA/ceshi.txt";
try{
var options = {};
options.flush = zlib.FlushType.FLUSH_TYPE_SYNC_FLUSH,
await zlib.zipFile(src, zipDest, options,
(err, data) => {
var zipStat = fileio.statSync(zipDest);
var isFile = zipStat.isFile();
expect(isFile).assertTrue();
var srcSize = fileio.statSync(src).size;
var destSize = zipStat.size;
expect(srcSize>destSize).assertTrue();
expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK);
zlib.unzipFile(zipDest, unzipDir, options,
(err, data) => {
var unzipStat = fileio.statSync(unzipDest);
var isFile = unzipStat.isFile();
expect(isFile).assertTrue();
var destSize = unzipStat.size;
var originSize = fileio.statSync(src).size;
var result = (originSize == destSize);
expect(result).assertTrue();
expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK);
done();
})
});
} catch(err) {
console.error('FWK_ZipFile_0500 err:' + err);
done();
}
console.log("==================FWK_ZipFile_1400 end==================");
})
/*
* @tc.number: FWK_ZipFile_1500
* @tc.name: zipFile
* @tc.desc: FlushType.FLUSH_TYPE_FULL_FLUSH
*/
it('FWK_ZipFile_1500', 0, async function (done) {
console.log("==================FWK_ZipFile_1500 start==================");
var src = "/data/test/ceshi.txt";
var zipDest = "/data/testA/ceshi.zip";
var unzipDir = "/data/testA/";
var unzipDest = "/data/testA/ceshi.txt";
try{
var options = {};
options.flush = zlib.FlushType.FLUSH_TYPE_FULL_FLUSH,
await zlib.zipFile(src, zipDest, options,
(err, data) => {
var zipStat = fileio.statSync(zipDest);
var isFile = zipStat.isFile();
expect(isFile).assertTrue();
var srcSize = fileio.statSync(src).size;
var destSize = zipStat.size;
expect(srcSize>destSize).assertTrue();
expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK);
zlib.unzipFile(zipDest, unzipDir, options,
(err, data) => {
var unzipStat = fileio.statSync(unzipDest);
var isFile = unzipStat.isFile();
expect(isFile).assertTrue();
var destSize = unzipStat.size;
var originSize = fileio.statSync(src).size;
var result = (originSize == destSize);
expect(result).assertTrue();
expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK);
done();
})
});
} catch(err) {
console.error('FWK_ZipFile_0500 err:' + err);
done();
}
console.log("==================FWK_ZipFile_1500 end==================");
})
/*
* @tc.number: FWK_ZipFile_1600
* @tc.name: zipFile
* @tc.desc: FlushType.FLUSH_TYPE_FINISH
*/
it('FWK_ZipFile_1600', 0, async function (done) {
console.log("==================FWK_ZipFile_1600 start==================");
var src = "/data/test/ceshi.txt";
var zipDest = "/data/testA/ceshi.zip";
var unzipDir = "/data/testA/";
var unzipDest = "/data/testA/ceshi.txt";
try{
var options = {};
options.flush = zlib.FlushType.FLUSH_TYPE_FINISH,
await zlib.zipFile(src, zipDest, options,
(err, data) => {
var zipStat = fileio.statSync(zipDest);
var isFile = zipStat.isFile();
expect(isFile).assertTrue();
var srcSize = fileio.statSync(src).size;
var destSize = zipStat.size;
expect(srcSize>destSize).assertTrue();
expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK);
zlib.unzipFile(zipDest, unzipDir, options,
(err, data) => {
var unzipStat = fileio.statSync(unzipDest);
var isFile = unzipStat.isFile();
expect(isFile).assertTrue();
var destSize = unzipStat.size;
var originSize = fileio.statSync(src).size;
var result = (originSize == destSize);
expect(result).assertTrue();
expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK);
done();
})
});
} catch(err) {
console.error('FWK_ZipFile_0500 err:' + err);
done();
}
console.log("==================FWK_ZipFile_1600 end==================");
})
/*
* @tc.number: FWK_ZipFile_1700
* @tc.name: zipFile
* @tc.desc: zipFile
*/
it('FWK_ZipFile_1700', 0, async function (done) {
console.log("==================FWK_ZipFile_1700 start==================");
var src = "/data/test/ceshi.txt";
var zipDest = "/data/testA/ceshi.zip";
var unzipDir = "/data/testA/";
var unzipDest = "/data/testA/ceshi.txt";
try{
var options = {};
options.flush = zlib.FlushType.FLUSH_TYPE_BLOCK,
await zlib.zipFile(src, zipDest, options,
(err, data) => {
var zipStat = fileio.statSync(zipDest);
var isFile = zipStat.isFile();
expect(isFile).assertTrue();
var srcSize = fileio.statSync(src).size;
var destSize = zipStat.size;
expect(srcSize>destSize).assertTrue();
expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK);
zlib.unzipFile(zipDest, unzipDir, options,
(err, data) => {
var unzipStat = fileio.statSync(unzipDest);
var isFile = unzipStat.isFile();
expect(isFile).assertTrue();
var destSize = unzipStat.size;
var originSize = fileio.statSync(src).size;
var result = (originSize == destSize);
expect(result).assertTrue();
expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK);
done();
})
});
} catch(err) {
console.error('FWK_ZipFile_0500 err:' + err);
done();
}
console.log("==================FWK_ZipFile_1700 end==================");
})
/*
* @tc.number: FWK_ZipFile_1800
* @tc.name: zipFile
* @tc.desc: FlushType.FLUSH_TYPE_TREES
*/
it('FWK_ZipFile_1800', 0, async function (done) {
console.log("==================FWK_ZipFile_1800 start==================");
var src = "/data/test/ceshi.txt";
var zipDest = "/data/testA/ceshi.zip";
var unzipDir = "/data/testA/";
var unzipDest = "/data/testA/ceshi.txt";
try{
var options = {};
options.flush = zlib.FlushType.FLUSH_TYPE_TREES,
await zlib.zipFile(src, zipDest, options,
(err, data) => {
var zipStat = fileio.statSync(zipDest);
var isFile = zipStat.isFile();
expect(isFile).assertTrue();
var srcSize = fileio.statSync(src).size;
var destSize = zipStat.size;
expect(srcSize>destSize).assertTrue();
expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK);
zlib.unzipFile(zipDest, unzipDir, options,
(err, data) => {
var unzipStat = fileio.statSync(unzipDest);
var isFile = unzipStat.isFile();
expect(isFile).assertTrue();
var destSize = unzipStat.size;
var originSize = fileio.statSync(src).size;
var result = (originSize == destSize);
expect(result).assertTrue();
expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK);
done();
})
});
} catch(err) {
console.error('FWK_ZipFile_0500 err:' + err);
done();
}
console.log("==================FWK_ZipFile_1800 end==================");
})
/*
* @tc.number: FWK_ZipFile_1900
* @tc.name: zipFile
* @tc.desc: chunkSize:64
*/
it('FWK_ZipFile_1900', 0, async function (done) {
console.log("==================FWK_ZipFile_1900 start==================");
var src = "/data/test/ceshi.txt";
var zipDest = "/data/testA/ceshi.zip";
var unzipDir = "/data/testA/";
var unzipDest = "/data/testA/ceshi.txt";
try{
var options = {
chunkSize:64,
};
await zlib.zipFile(src, zipDest, options,
(err, data) => {
var zipStat = fileio.statSync(zipDest);
var isFile = zipStat.isFile();
expect(isFile).assertTrue();
var srcSize = fileio.statSync(src).size;
var destSize = zipStat.size;
expect(srcSize>destSize).assertTrue();
expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK);
zlib.unzipFile(zipDest, unzipDir, options,
(err, data) => {
var unzipStat = fileio.statSync(unzipDest);
var isFile = unzipStat.isFile();
expect(isFile).assertTrue();
var destSize = unzipStat.size;
var originSize = fileio.statSync(src).size;
var result = (originSize == destSize);
expect(result).assertTrue();
expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK);
done();
})
});
} catch(err) {
console.error('FWK_ZipFile_0500 err:' + err);
done();
}
console.log("==================FWK_ZipFile_1900 end==================");
})
/*
* @tc.number: FWK_ZipFile_2000
* @tc.name: zipFile
* @tc.desc: chunkSize:1024
*/
it('FWK_ZipFile_2000', 0, async function (done) {
console.log("==================FWK_ZipFile_2000 start==================");
var src = "/data/test/ceshi.txt";
var zipDest = "/data/testA/ceshi.zip";
var unzipDir = "/data/testA/";
var unzipDest = "/data/testA/ceshi.txt";
try{
var options = {
chunkSize:1024,
};
await zlib.zipFile(src, zipDest, options,
(err, data) => {
var zipStat = fileio.statSync(zipDest);
var isFile = zipStat.isFile();
expect(isFile).assertTrue();
var srcSize = fileio.statSync(src).size;
var destSize = zipStat.size;
expect(srcSize>destSize).assertTrue();
expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK);
zlib.unzipFile(zipDest, unzipDir, options,
(err, data) => {
var unzipStat = fileio.statSync(unzipDest);
var isFile = unzipStat.isFile();
expect(isFile).assertTrue();
var destSize = unzipStat.size;
var originSize = fileio.statSync(src).size;
var result = (originSize == destSize);
expect(result).assertTrue();
expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK);
done();
})
});
} catch(err) {
console.error('FWK_ZipFile_0500 err:' + err);
done();
}
console.log("==================FWK_ZipFile_2000 end==================");
})
/*
* @tc.number: FWK_ZipFile_2100
* @tc.name: zipFile
* @tc.desc: chunkSize:999
*/
it('FWK_ZipFile_2100', 0, async function (done) {
console.log("==================FWK_ZipFile_2100 start==================");
var src = "/data/test/ceshi.txt";
var zipDest = "/data/testA/ceshi.zip";
var unzipDir = "/data/testA/";
var unzipDest = "/data/testA/ceshi.txt";
try{
var options = {
chunkSize:999,
};
await zlib.zipFile(src, zipDest, options,
(err, data) => {
var zipStat = fileio.statSync(zipDest);
var isFile = zipStat.isFile();
expect(isFile).assertTrue();
var srcSize = fileio.statSync(src).size;
var destSize = zipStat.size;
expect(srcSize>destSize).assertTrue();
expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK);
zlib.unzipFile(zipDest, unzipDir, options,
(err, data) => {
var unzipStat = fileio.statSync(unzipDest);
var isFile = unzipStat.isFile();
expect(isFile).assertTrue();
var destSize = unzipStat.size;
var originSize = fileio.statSync(src).size;
var result = (originSize == destSize);
expect(result).assertTrue();
expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK);
done();
})
});
} catch(err) {
console.error('FWK_ZipFile_0500 err:' + err);
done();
}
console.log("==================FWK_ZipFile_2100 end==================");
})
/*
* @tc.number: FWK_ZipFile_2200
* @tc.name: zipFile
* @tc.desc: level.COMPRESS_LEVEL_NO_COMPRESSION
*/
it('FWK_ZipFile_2200', 0, async function (done) {
console.log("==================FWK_ZipFile_2200 start==================");
var src = "/data/test/ceshi.txt";
var zipDest = "/data/testA/ceshi.zip";
var unzipDir = "/data/testA/";
var unzipDest = "/data/testA/ceshi.txt";
try{
var options = {};
options.level = zlib.CompressLevel.COMPRESS_LEVEL_NO_COMPRESSION ,
await zlib.zipFile(src, zipDest, options,
(err, data) => {
var zipStat = fileio.statSync(zipDest);
var isFile = zipStat.isFile();
expect(isFile).assertTrue();
var srcSize = fileio.statSync(src).size;
var destSize = zipStat.size;
expect(srcSize>destSize).assertTrue();
expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK);
zlib.unzipFile(zipDest, unzipDir, options,
(err, data) => {
var unzipStat = fileio.statSync(unzipDest);
var isFile = unzipStat.isFile();
expect(isFile).assertTrue();
var destSize = unzipStat.size;
var originSize = fileio.statSync(src).size;
var result = (originSize == destSize);
expect(result).assertTrue();
expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK);
done();
})
});
} catch(err) {
console.error('FWK_ZipFile_0500 err:' + err);
done();
}
console.log("==================FWK_ZipFile_2200 end==================");
})
/*
* @tc.number: FWK_ZipFile_2300
* @tc.name: zipFile
* @tc.desc: level.COMPRESS_LEVEL_BEST_SPEED
*/
it('FWK_ZipFile_2300', 0, async function (done) {
console.log("==================FWK_ZipFile_2300 start==================");
var src = "/data/test/ceshi.txt";
var zipDest = "/data/testA/ceshi.zip";
var unzipDir = "/data/testA/";
var unzipDest = "/data/testA/ceshi.txt";
try{
var options = {};
options.level = zlib.CompressLevel.COMPRESS_LEVEL_BEST_SPEED,
await zlib.zipFile(src, zipDest, options,
(err, data) => {
var zipStat = fileio.statSync(zipDest);
var isFile = zipStat.isFile();
expect(isFile).assertTrue();
var srcSize = fileio.statSync(src).size;
var destSize = zipStat.size;
expect(srcSize>destSize).assertTrue();
expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK);
zlib.unzipFile(zipDest, unzipDir, options,
(err, data) => {
var unzipStat = fileio.statSync(unzipDest);
var isFile = unzipStat.isFile();
expect(isFile).assertTrue();
var destSize = unzipStat.size;
var originSize = fileio.statSync(src).size;
var result = (originSize == destSize);
expect(result).assertTrue();
expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK);
done();
})
});
} catch(err) {
console.error('FWK_ZipFile_0500 err:' + err);
done();
}
console.log("==================FWK_ZipFile_2300 end==================");
})
/*
* @tc.number: FWK_ZipFile_2400
* @tc.name: zipFile
* @tc.desc: level.COMPRESS_LEVEL_BEST_COMPRESSION
*/
it('FWK_ZipFile_2400', 0, async function (done) {
console.log("==================FWK_ZipFile_2400 start==================");
var src = "/data/test/ceshi.txt";
var zipDest = "/data/testA/ceshi.zip";
var unzipDir = "/data/testA/";
var unzipDest = "/data/testA/ceshi.txt";
try{
var options = {};
options.level = zlib.CompressLevel.COMPRESS_LEVEL_BEST_COMPRESSION,
await zlib.zipFile(src, zipDest, options,
(err, data) => {
var zipStat = fileio.statSync(zipDest);
var isFile = zipStat.isFile();
expect(isFile).assertTrue();
var srcSize = fileio.statSync(src).size;
var destSize = zipStat.size;
expect(srcSize>destSize).assertTrue();
expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK);
zlib.unzipFile(zipDest, unzipDir, options,
(err, data) => {
var unzipStat = fileio.statSync(unzipDest);
var isFile = unzipStat.isFile();
expect(isFile).assertTrue();
var destSize = unzipStat.size;
var originSize = fileio.statSync(src).size;
var result = (originSize == destSize);
expect(result).assertTrue();
expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK);
done();
})
});
} catch(err) {
console.error('FWK_ZipFile_0500 err:' + err);
done();
}
console.log("==================FWK_ZipFile_2400 end==================");
})
/*
* @tc.number: FWK_ZipFile_2500
* @tc.name: zipFile
* @tc.desc: level.COMPRESS_LEVEL_DEFAULT_COMPRESSION
*/
it('FWK_ZipFile_2500', 0, async function (done) {
console.log("==================FWK_ZipFile_2500 start==================");
var src = "/data/test/ceshi.txt";
var zipDest = "/data/testA/ceshi.zip";
var unzipDir = "/data/testA/";
var unzipDest = "/data/testA/ceshi.txt";
try{
var options = {};
options.level = zlib.CompressLevel.COMPRESS_LEVEL_DEFAULT_COMPRESSION,
await zlib.zipFile(src, zipDest, options,
(err, data) => {
var zipStat = fileio.statSync(zipDest);
var isFile = zipStat.isFile();
expect(isFile).assertTrue();
var srcSize = fileio.statSync(src).size;
var destSize = zipStat.size;
expect(srcSize>destSize).assertTrue();
expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK);
zlib.unzipFile(zipDest, unzipDir, options,
(err, data) => {
var unzipStat = fileio.statSync(unzipDest);
var isFile = unzipStat.isFile();
expect(isFile).assertTrue();
var destSize = unzipStat.size;
var originSize = fileio.statSync(src).size;
var result = (originSize == destSize);
expect(result).assertTrue();
expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK);
done();
})
});
} catch(err) {
console.error('FWK_ZipFile_0500 err:' + err);
done();
}
console.log("==================FWK_ZipFile_2500 end==================");
})
/*
* @tc.number: FWK_ZipFile_2600
* @tc.name: zipFile
* @tc.desc: memlevel.MEM_LEVEL_MIN_MEMLEVEL
*/
it('FWK_ZipFile_2600', 0, async function (done) {
console.log("==================FWK_ZipFile_2600 start==================");
var src = "/data/test/ceshi.txt";
var zipDest = "/data/testA/ceshi.zip";
var unzipDir = "/data/testA/";
var unzipDest = "/data/testA/ceshi.txt";
try{
var options = {};
options.memlevel = zlib.MemLevel.MEM_LEVEL_MIN_MEMLEVEL,
await zlib.zipFile(src, zipDest, options,
(err, data) => {
var zipStat = fileio.statSync(zipDest);
var isFile = zipStat.isFile();
expect(isFile).assertTrue();
var srcSize = fileio.statSync(src).size;
var destSize = zipStat.size;
expect(srcSize>destSize).assertTrue();
expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK);
zlib.unzipFile(zipDest, unzipDir, options,
(err, data) => {
var unzipStat = fileio.statSync(unzipDest);
var isFile = unzipStat.isFile();
expect(isFile).assertTrue();
var destSize = unzipStat.size;
var originSize = fileio.statSync(src).size;
var result = (originSize == destSize);
expect(result).assertTrue();
expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK);
done();
})
});
} catch(err) {
console.error('FWK_ZipFile_0500 err:' + err);
done();
}
console.log("==================FWK_ZipFile_2600 end==================");
})
/*
* @tc.number: FWK_ZipFile_2700
* @tc.name: zipFile
* @tc.desc: memlevel.MEM_LEVEL_MAX_MEMLEVEL
*/
it('FWK_ZipFile_2700', 0, async function (done) {
console.log("==================FWK_ZipFile_2700 start==================");
var src = "/data/test/ceshi.txt";
var zipDest = "/data/testA/ceshi.zip";
var unzipDir = "/data/testA/";
var unzipDest = "/data/testA/ceshi.txt";
try{
var options = {};
options.memlevel = zlib.MemLevel.MEM_LEVEL_MAX_MEMLEVEL,
await zlib.zipFile(src, zipDest, options,
(err, data) => {
var zipStat = fileio.statSync(zipDest);
var isFile = zipStat.isFile();
expect(isFile).assertTrue();
var srcSize = fileio.statSync(src).size;
var destSize = zipStat.size;
expect(srcSize>destSize).assertTrue();
expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK);
zlib.unzipFile(zipDest, unzipDir, options,
(err, data) => {
var unzipStat = fileio.statSync(unzipDest);
var isFile = unzipStat.isFile();
expect(isFile).assertTrue();
var destSize = unzipStat.size;
var originSize = fileio.statSync(src).size;
var result = (originSize == destSize);
expect(result).assertTrue();
expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK);
done();
})
});
} catch(err) {
console.error('FWK_ZipFile_0500 err:' + err);
done();
}
console.log("==================FWK_ZipFile_2700 end==================");
})
/*
* @tc.number: FWK_ZipFile_2800
* @tc.name: zipFile
* @tc.desc: memlevel.MEM_LEVEL_DEFAULT_MEMLEVEL
*/
it('FWK_ZipFile_2800', 0, async function (done) {
console.log("==================FWK_ZipFile_2800 start==================");
var src = "/data/test/ceshi.txt";
var zipDest = "/data/testA/ceshi.zip";
var unzipDir = "/data/testA/";
var unzipDest = "/data/testA/ceshi.txt";
try{
var options = {};
options.memlevel = zlib.MemLevel.MEM_LEVEL_DEFAULT_MEMLEVEL,
await zlib.zipFile(src, zipDest, options,
(err, data) => {
var zipStat = fileio.statSync(zipDest);
var isFile = zipStat.isFile();
expect(isFile).assertTrue();
var srcSize = fileio.statSync(src).size;
var destSize = zipStat.size;
expect(srcSize>destSize).assertTrue();
expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK);
zlib.unzipFile(zipDest, unzipDir, options,
(err, data) => {
var unzipStat = fileio.statSync(unzipDest);
var isFile = unzipStat.isFile();
expect(isFile).assertTrue();
var destSize = unzipStat.size;
var originSize = fileio.statSync(src).size;
var result = (originSize == destSize);
expect(result).assertTrue();
expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK);
done();
})
});
} catch(err) {
console.error('FWK_ZipFile_0500 err:' + err);
done();
}
console.log("==================FWK_ZipFile_2800 end==================");
})
/*
* @tc.number: FWK_ZipFile_2900
* @tc.name: zipFile
* @tc.desc: strategy.COMPRESS_STRATEGY_DEFAULT_STRATEGY
*/
it('FWK_ZipFile_2900', 0, async function (done) {
console.log("==================FWK_ZipFile_2900 start==================");
var src = "/data/test/ceshi.txt";
var zipDest = "/data/testA/ceshi.zip";
var unzipDir = "/data/testA/";
var unzipDest = "/data/testA/ceshi.txt";
try{
var options = {};
options.strategy = zlib.CompressStrategy.COMPRESS_STRATEGY_DEFAULT_STRATEGY,
await zlib.zipFile(src, zipDest, options,
(err, data) => {
var zipStat = fileio.statSync(zipDest);
var isFile = zipStat.isFile();
expect(isFile).assertTrue();
var srcSize = fileio.statSync(src).size;
var destSize = zipStat.size;
expect(srcSize>destSize).assertTrue();
expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK);
zlib.unzipFile(zipDest, unzipDir, options,
(err, data) => {
var unzipStat = fileio.statSync(unzipDest);
var isFile = unzipStat.isFile();
expect(isFile).assertTrue();
var destSize = unzipStat.size;
var originSize = fileio.statSync(src).size;
var result = (originSize == destSize);
expect(result).assertTrue();
expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK);
done();
})
});
} catch(err) {
console.error('FWK_ZipFile_0500 err:' + err);
done();
}
console.log("==================FWK_ZipFile_2900 end==================");
})
/*
* @tc.number: FWK_ZipFile_3000
* @tc.name: zipFile
* @tc.desc: strategy.COMPRESS_STRATEGY_FILTERED
*/
it('FWK_ZipFile_3000', 0, async function (done) {
console.log("==================FWK_ZipFile_3000 start==================");
var src = "/data/test/ceshi.txt";
var zipDest = "/data/testA/ceshi.zip";
var unzipDir = "/data/testA/";
var unzipDest = "/data/testA/ceshi.txt";
try{
var options = {};
options.strategy = zlib.CompressStrategy.COMPRESS_STRATEGY_FILTERED,
await zlib.zipFile(src, zipDest, options,
(err, data) => {
var zipStat = fileio.statSync(zipDest);
var isFile = zipStat.isFile();
expect(isFile).assertTrue();
var srcSize = fileio.statSync(src).size;
var destSize = zipStat.size;
expect(srcSize>destSize).assertTrue();
expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK);
zlib.unzipFile(zipDest, unzipDir, options,
(err, data) => {
var unzipStat = fileio.statSync(unzipDest);
var isFile = unzipStat.isFile();
expect(isFile).assertTrue();
var destSize = unzipStat.size;
var originSize = fileio.statSync(src).size;
var result = (originSize == destSize);
expect(result).assertTrue();
expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK);
done();
})
});
} catch(err) {
console.error('FWK_ZipFile_0500 err:' + err);
done();
}
console.log("==================FWK_ZipFile_3000 end==================");
})
/*
* @tc.number: FWK_ZipFile_3100
* @tc.name: zipFile
* @tc.desc: strategy.COMPRESS_STRATEGY_HUFFMAN_ONLY
*/
it('FWK_ZipFile_3100', 0, async function (done) {
console.log("==================FWK_ZipFile_3100 start==================");
var src = "/data/test/ceshi.txt";
var zipDest = "/data/testA/ceshi.zip";
var unzipDir = "/data/testA/";
var unzipDest = "/data/testA/ceshi.txt";
try{
var options = {};
options.strategy = zlib.CompressStrategy.COMPRESS_STRATEGY_HUFFMAN_ONLY,
await zlib.zipFile(src, zipDest, options,
(err, data) => {
var zipStat = fileio.statSync(zipDest);
var isFile = zipStat.isFile();
expect(isFile).assertTrue();
var srcSize = fileio.statSync(src).size;
var destSize = zipStat.size;
expect(srcSize>destSize).assertTrue();
expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK);
zlib.unzipFile(zipDest, unzipDir, options,
(err, data) => {
var unzipStat = fileio.statSync(unzipDest);
var isFile = unzipStat.isFile();
expect(isFile).assertTrue();
var destSize = unzipStat.size;
var originSize = fileio.statSync(src).size;
var result = (originSize == destSize);
expect(result).assertTrue();
expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK);
done();
})
});
} catch(err) {
console.error('FWK_ZipFile_0500 err:' + err);
done();
}
console.log("==================FWK_ZipFile_3100 end==================");
})
/*
* @tc.number: FWK_ZipFile_3200
* @tc.name: zipFile
* @tc.desc: strategy.COMPRESS_STRATEGY_RLE
*/
it('FWK_ZipFile_3200', 0, async function (done) {
console.log("==================FWK_ZipFile_3200 start==================");
var src = "/data/test/ceshi.txt";
var zipDest = "/data/testA/ceshi.zip";
var unzipDir = "/data/testA/";
var unzipDest = "/data/testA/ceshi.txt";
try{
var options = {};
options.strategy = zlib.CompressStrategy.COMPRESS_STRATEGY_RLE,
await zlib.zipFile(src, zipDest, options,
(err, data) => {
var zipStat = fileio.statSync(zipDest);
var isFile = zipStat.isFile();
expect(isFile).assertTrue();
var srcSize = fileio.statSync(src).size;
var destSize = zipStat.size;
expect(srcSize>destSize).assertTrue();
expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK);
zlib.unzipFile(zipDest, unzipDir, options,
(err, data) => {
var unzipStat = fileio.statSync(unzipDest);
var isFile = unzipStat.isFile();
expect(isFile).assertTrue();
var destSize = unzipStat.size;
var originSize = fileio.statSync(src).size;
var result = (originSize == destSize);
expect(result).assertTrue();
expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK);
done();
})
});
} catch(err) {
console.error('FWK_ZipFile_0500 err:' + err);
done();
}
console.log("==================FWK_ZipFile_3200 end==================");
})
/*
* @tc.number: FWK_ZipFile_3300
* @tc.name: zipFile
* @tc.desc: strategy.COMPRESS_STRATEGY_HUFFMAN_ONLY
*/
it('FWK_ZipFile_3300', 0, async function (done) {
console.log("==================FWK_ZipFile_3300 start==================");
var src = "/data/test/ceshi.txt";
var zipDest = "/data/testA/ceshi.zip";
var unzipDir = "/data/testA/";
var unzipDest = "/data/testA/ceshi.txt";
try{
var options = {};
options.strategy = zlib.CompressStrategy.COMPRESS_STRATEGY_FILTERED,
await zlib.zipFile(src, zipDest, options,
(err, data) => {
var zipStat = fileio.statSync(zipDest);
var isFile = zipStat.isFile();
expect(isFile).assertTrue();
var srcSize = fileio.statSync(src).size;
var destSize = zipStat.size;
expect(srcSize>destSize).assertTrue();
expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK);
zlib.unzipFile(zipDest, unzipDir, options,
(err, data) => {
var unzipStat = fileio.statSync(unzipDest);
var isFile = unzipStat.isFile();
expect(isFile).assertTrue();
var destSize = unzipStat.size;
var originSize = fileio.statSync(src).size;
var result = (originSize == destSize);
expect(result).assertTrue();
expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK);
done();
})
});
} catch(err) {
console.error('FWK_ZipFile_0500 err:' + err);
done();
}
console.log("==================FWK_ZipFile_3300 end==================");
})
/*
* @tc.number: FWK_zipFile_3400
* @tc.name: zipFile
* @tc.desc: inFile doesn't exist
*/
it('FWK_zipFile_3400', 0, async function (done) {
console.log("==================FWK_zipFile_3400 start==================");
var src = "/data/noExist.txt";
var dest = "/data/test/";
var options = {}
zlib.zipFile(src, dest, options).then((data) => {
console.log("zipFilePromise_3400 data: " + data);
expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_STREAM_ERROR);
done();
}).catch((err)=>{
console.log("zipFilePromise_3400 err: " + err);
done();
});
console.log("==================zipFilePromise_3400 end ==================");
})
/*
* @tc.number: FWK_zipFile_3500
* @tc.name: zipFile
* @tc.desc: inFile is a directory that doesn't exist
*/
it('FWK_zipFile_3500', 0, async function (done) {
console.log("==================FWK_zipFile_3500 start==================");
var src = "/data/teste/fefsef.txt";
var dest = "/data/testA/sfefsfe.zip";
var options = {}
zlib.zipFile(src, dest, options).then((data) => {
console.log("zipFilePromise_3500 data: " + data);
expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_DATA_ERROR);
done();
}).catch((err)=>{
console.log("zipFilePromise_3500 err: " + err);
done();
});
console.log("==================zipFilePromise_3500 end ==================");
})
/*
* @tc.number: FWK_zipFile_3600
* @tc.name: zipFile
* @tc.desc:output file not specified
*/
it('FWK_zipFile_3600', 0, async function (done) {
console.log("==================FWK_zipFile_3600 start==================");
var src = "/data/test/ceshi.txt";
var dest = "";
var options = {}
zlib.zipFile(src, dest, options).then((data) => {
console.log("zipFilePromise_3600 data: " + data);
expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_STREAM_ERROR);
done();
}).catch((err)=>{
console.log("zipFilePromise_3600 err: " + err);
done();
});
console.log("==================zipFilePromise_3600 end ==================")
})
/*
* @tc.number: FWK_zipFile_3700
* @tc.name: zipFile
* @tc.desc:output file not specified
*/
it('FWK_ZipFile_3700', 0, async function (done) {
console.log("==================zipFilePromise_3700 start==================");
var src = "/data/test/ceshi.txt";
var dest = "/data/testB/ceshi.txt.zip";
var options = {}
zlib.zipFile(src, dest, options).then((data) => {
console.log("zipFilePromise_3700 data: " + data);
expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_STREAM_ERROR);
done();
}).catch((err)=>{
console.log("zipFilePromise_3700 err: " + err);
done();
});
console.log("==================zipFilePromise_3700 end ==================");
})
/*
* @tc.number: FWK_ZipFile_3800
* @tc.name: zipFile
* @tc.desc: FlushType.FLUSH_TYPE_NO_FLUSH
*/
it('FWK_ZipFile_3800', 0, async function (done) {
console.log("==================FWK_ZipFile_3800 start==================");
var src = "/data/test/ceshi.txt";
var zipDest = "/data/testb/ceshi.zip";
var unzipDir = "/data/testb/";
var unzipDest = "/data/testb/ceshi.txt";
try {
var options = {};
options.flush = zlib.FlushType.FLUSH_TYPE_NO_FLUSH;
zlib.zipFile(src, unzipDir, options,).then((data) => {
var zipStat = fileio.statSync(zipDest);
var isFile = zipStat.isFile();
expect(isFile).assertTrue();
var srcSize = fileio.statSync(src).size;
var destSize = zipStat.size;
expect(srcSize>destSize).assertTrue();
expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK);
zlib.zipFile(zipDest, unzipDir, options,).then((data) => {
var unzipStat = fileio.statSync(unzipDest);
var isFile = unzipStat.isFile();
expect(isFile).assertTrue();
var destSize = unzipStat.size;
var originSize = fileio.statSync(src).size;
var result = (originSize == destSize);
expect(result).assertTrue();
expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK);
done();
}).catch((err)=>{
console.log("FWK_ZipFile_3800 .catch((err)=>" + err);
done();
})
}).catch((err)=>{
console.log("FWK_ZipFile_3800 .catch((err)=>" + err);
done();
});
} catch(err) {
console.error('FWK_ZipFile_3800 err:' + err);
done();
}
console.log("==================FWK_ZipFile_3800 end==================");
})
/*
* @tc.number: FWK_ZipFile_3900
* @tc.name: zipFile
* @tc.desc: FlushType.FLUSH_TYPE_NO_FLUSH
*/
it('FWK_ZipFile_3900', 0, async function (done) {
console.log("==================FWK_ZipFile_3900 start==================");
var src = "/data/test/ceshi.txt";
var zipDest = "/data/testb/ceshi.zip";
var unzipDir = "/data/testb/";
var unzipDest = "/data/testb/ceshi.txt";
try {
var options = {};
options.flush = zlib.FlushType.FLUSH_TYPE_PARTIAL_FLUSH,
zlib.zipFile(src, unzipDir, options,).then((data) => {
var zipStat = fileio.statSync(zipDest);
var isFile = zipStat.isFile();
expect(isFile).assertTrue();
var srcSize = fileio.statSync(src).size;
var destSize = zipStat.size;
expect(srcSize>destSize).assertTrue();
expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK);
zlib.zipFile(zipDest, unzipDir, options,).then((data) => {
var unzipStat = fileio.statSync(unzipDest);
var isFile = unzipStat.isFile();
expect(isFile).assertTrue();
var destSize = unzipStat.size;
var originSize = fileio.statSync(src).size;
var result = (originSize == destSize);
expect(result).assertTrue();
expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK);
done();
}).catch((err)=>{
console.log("FWK_ZipFile_3900 .catch((err)=>" + err);
done();
})
}).catch((err)=>{
console.log("FWK_ZipFile_3900 .catch((err)=>" + err);
done();
});
} catch(err) {
console.error('FWK_ZipFile_3900 err:' + err);
done();
}
console.log("==================FWK_ZipFile_3900 end==================");
})
/*
* @tc.number: FWK_ZipFile_4000
* @tc.name: zipFile
* @tc.desc: FlushType.FLUSH_TYPE_NO_FLUSH
*/
it('FWK_ZipFile_4000', 0, async function (done) {
console.log("==================FWK_ZipFile_4000 start==================");
var src = "/data/test/";
var dest = "/data/testA/ceshi.txt.zip";
try {
var options = {};
options.flush = zlib.FlushType.FLUSH_TYPE_NO_FLUSH;
await zlib.zipFile(src, dest, options,
(err, data) => {
var smallStat = fileio.statSync(dest);
var isFile = smallStat.isFile();
expect(isFile).assertTrue();
expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK);
done();
});
} catch(err) {
console.error('FWK_ZipFile_4000 err:' + err);
done();
}
console.log("==================FWK_ZipFile_4000 end==================");
})
/*
* @tc.number: FWK_ZipFile_4100
* @tc.name: zipFile
* @tc.desc: FlushType.FLUSH_TYPE_NO_FLUSH
*/
it('FWK_ZipFile_4100', 0, async function (done) {
console.log("==================FWK_ZipFile_4100 start==================");
var src = "/data/test/";
var dest = "/data/testA/ceshi.txt.zip";
try {
var options = {};
options.flush = zlib.FlushType.FLUSH_TYPE_PARTIAL_FLUSH,
await zlib.zipFile(src, dest, options,).then((data) => {
var smallStat = fileio.statSync(dest);
var isFile = smallStat.isFile();
expect(isFile).assertTrue();
expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK);
done();
}).catch((err)=>{
console.log("FWK_ZipFile_4100 .catch((err)=>" + err);
done();
});
} catch(err) {
console.error('FWK_ZipFile_4100 err:' + err);
done();
}
console.log("==================FWK_ZipFile_4100 end==================");
})
/*
* @tc.number: FWK_ZipFile_4200
* @tc.name: unzipFile
* @tc.desc: unzipFile
*/
it('FWK_ZipFile_4200', 0, async function (done) {
console.log("==================FWK_UnzipFile_0100 start==================");
var src = "/data/noExist.txt";
var dest = "/data/test/";
var options = {}
zlib.unzipFile(src, dest, options,
(err, data) => {
console.log("FWK_ZipFile_4200 data: " + data);
expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_DATA_ERROR);
done();
});
})
/*
* @tc.number: FWK_ZipFile_4300
* @tc.name: unzipFile
* @tc.desc: unzipFile
*/
it('FWK_ZipFile_4300', 0, async function (done) {
console.log("==================FWK_ZipFile_4300 start==================");
var src = "/data/test/";
var dest = "/data/testA/ceshi.txt.zip";
var options = {}
zlib.unzipFile(src, dest, options,
(err, data) => {
console.log("FWK_ZipFile_4300 data: " + data);
expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_ERRNO);
done();
});
})
/*
* @tc.number: FWK_ZipFile_4400
* @tc.name: unzipFile
* @tc.desc: unzipFile
*/
it('FWK_ZipFile_4400', 0, async function (done) {
console.log("==================FWK_ZipFile_4300 start==================");
var src = "/data/test/cdshitwo.txt";
var dest = "/data/testA/ceshi.txt.zip";
var options = {}
zlib.unzipFile(src, dest, options,
(err, data) => {
console.log("FWK_ZipFile_4400 data: " + data);
expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_DATA_ERROR);
done();
});
})
/*
* @tc.number: FWK_ZipFile_4500
* @tc.name: unzipFile
* @tc.desc: unzipFile
*/
it('FWK_ZipFile_4500', 0, async function (done) {
console.log("==================FWK_ZipFile_4500 start==================");
var src = "/data/testA/ceshi.txt.zip";
var dest = "";
var options = {}
zlib.unzipFile(src, dest, options,
(err, data) => {
console.log("FWK_ZipFile_4500 data: " + data);
expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_ERRNO);
done();
});
})
/*
* @tc.number: FWK_ZipFile_4600
* @tc.name: zipFile
* @tc.desc: FlushType.FLUSH_TYPE_NO_FLUSH
*/
it('FWK_ZipFile_4600', 0, async function (done) {
console.log("==================FWK_ZipFile_4600 start==================");
var src = "/data/test/ceshitwo.zip";
var dest = "/data/testb";
var origin = "/data/test/ceshitwo.txt";
var destFile = "/data/testb/ceshitwo.txt";
try {
var options = {};
options.flushFlush = zlib.FlushType.FLUSH_TYPE_NO_FLUSH,
await zlib.unzipFile(src, dest, options,
(err, data) => {
var smallStat = fileio.statSync(destFile);
var isFile = smallStat.isFile();
expect(isFile).assertTrue();
var destSize = smallStat.size;
var originStat = fileio.statSync(origin);
var originSize = originStat.size;
console.log("FWK_ZipFile_4600 destSize=" + destSize);
console.log("FWK_ZipFile_4600 data=" + data);
var result = (originSize == destSize);
expect(result).assertTrue();
expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK);
done();
});
} catch(err) {
console.error('FWK_ZipFilFWK_ZipFile_4600e_4200 err:' + err);
done();
}
console.log("==================FWK_ZipFile_4600 end==================");
})
/*
* @tc.number: FWK_ZipFile_4700
* @tc.name: zipFile
* @tc.desc: inFile doesn't exist
*/
it('FWK_ZipFile_4700', 0, async function (done) {
console.log("==================FWK_UnzipFile_1200 start==================");
var src = "/data/noExist.txt";
var dest = "/data/test/";
var options = {}
zlib.unzipFile(src, dest, options).then((data) => {
console.log("FWK_ZipFile_4700 data: " + data);
expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_DATA_ERROR);
done();
}).catch((err)=>{
console.log("FWK_ZipFile_4700 err: " + err);
done();
});
console.log("==================FWK_ZipFile_4700 end ==================");
})
/*
* @tc.number: FWK_ZipFile_4800
* @tc.name: zipFile
* @tc.desc: inFile is a directory that doesn't exist
*/
it('FWK_ZipFile_4800', 0, async function (done) {
console.log("==================FWK_ZipFile_4800 start==================");
var src = "/data/test";
var dest = "/data/testA/ceshi.txt";
var options = {}
zlib.unzipFile(src, dest, options).then((data) => {
console.log("FWK_ZipFile_4800 data: " + data);
expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_ERRNO);
done();
}).catch((err)=>{
console.log("FWK_ZipFile_4800 err: " + err);
done();
});
console.log("==================FWK_ZipFile_4800 end ==================");
})
/*
* @tc.number: FWK_ZipFile_4900
* @tc.name: zipFile
* @tc.desc:output file not specified
*/
it('FWK_ZipFile_4900', 0, async function (done) {
console.log("==================FWK_ZipFile_4900 start==================");
var src = "/data/test/ceshi.txt";
var dest = "/data/testc/ceshi.txt.zip";
var options = {}
zlib.unzipFile(src, dest, options).then((data) => {
console.log("FWK_ZipFile_4900 data: " + data);
expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_ERRNO);
done();
}).catch((err)=>{
console.log("FWK_ZipFile_4900 err: " + err);
done();
});
console.log("==================FWK_ZipFile_4900 end ==================");
})
/*
* @tc.number: FWK_ZipFile_5000
* @tc.name: unzipFile
* @tc.desc: unzipFile
*/
it('FWK_ZipFile_5000', 0, async function (done) {
console.log("==================FWK_ZipFile_5000 start==================");
var src = "/data/test/cdshitwo.txt";
var dest = "/data/testA/ceshi.txt.zip";
var options = {}
zlib.unzipFile(src, dest, options,).then((data)=>{
console.log("FWK_ZipFile_5000 data: " + data);
expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_DATA_ERROR);
done();
}).catch((err)=>{
console.log("FWK_ZipFile_5000 err: " + err);
done();
});
})
/*
* @tc.number: FWK_ZipFile_5100
* @tc.name: zipFile
* @tc.desc: FlushType.FLUSH_TYPE_NO_FLUSH
*/
it('FWK_ZipFile_5100', 0, async function (done) {
console.log("==================FWK_ZipFile_5100 start==================");
var src = "/data/test/ceshitwo.zip";
var dest = "/data/testb";
var origin = "/data/test/ceshitwo.txt";
var destFile = "/data/testb/ceshitwo.txt";
try {
var options = {};
options.flushFlush = zlib.FlushType.FLUSH_TYPE_NO_FLUSH,
zlib.unzipFile(src, dest, options).then((data)=>{
var smallStat = fileio.statSync(destFile);
var isFile = smallStat.isFile();
expect(isFile).assertTrue();
var destSize = smallStat.size;
var originStat = fileio.statSync(origin);
var originSize = originStat.size;
console.log("FWK_ZipFile_5100 destSize=" + destSize);
console.log("FWK_ZipFile_5100 data=" + data);
var result = (originSize == destSize);
expect(result).assertTrue();
expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK);
done();
}).catch((err)=>{
expect(fail).assertTrue();
console.log("FWK_ZipFile_5100 .catch((err)=>" + err);
done();
});
} catch(err) {
console.error('FWK_ZipFile_5100 err:' + err);
expect(fail).assertTrue();
done();
}
console.log("==================FWK_ZipFile_5100 end==================");
})
/*
* @tc.number: FWK_ZipFile_5200
* @tc.name: zipFile
* @tc.desc: strategy.COMPRESS_STRATEGY_FIXED
*/
it('FWK_ZipFile_5200', 0, async function (done) {
console.log("==================FWK_ZipFile_5200 start==================");
var src = "/data/test/ceshi.txt";
var zipDest = "/data/testA/ceshi.zip";
var unzipDir = "/data/testA/";
var unzipDest = "/data/testA/ceshi.txt";
try{
var options = {};
options.strategy = zlib.CompressStrategy.COMPRESS_STRATEGY_FIXED,
await zlib.zipFile(src, zipDest, options,
(err, data) => {
var zipStat = fileio.statSync(zipDest);
var isFile = zipStat.isFile();
expect(isFile).assertTrue();
var srcSize = fileio.statSync(src).size;
var destSize = zipStat.size;
expect(srcSize>destSize).assertTrue();
expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK);
zlib.unzipFile(zipDest, unzipDir, options,
(err, data) => {
var unzipStat = fileio.statSync(unzipDest);
var isFile = unzipStat.isFile();
expect(isFile).assertTrue();
var destSize = unzipStat.size;
var originSize = fileio.statSync(src).size;
var result = (originSize == destSize);
expect(result).assertTrue();
expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK);
done();
})
});
} catch(err) {
console.error('FWK_ZipFile_5200 err:' + err);
done();
}
console.log("==================FWK_ZipFile_5200 end==================");
})
})
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册