actszipfileandunzipfiletest.test.js 95.8 KB
Newer Older
K
kirl75 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
/*
* 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'
R
renyi 已提交
18
import featureAbility from '@ohos.ability.featureAbility'
I
inter515 已提交
19
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect, Level } from '@ohos/hypium'
J
jiyong_sd 已提交
20

I
inter515 已提交
21 22 23
let dir = "";
let infos = "";
let SRC_FILE_INVALID = 900001;
I
inter515 已提交
24
let OUTPUT_FILE_INVALID = 900002;
I
inter515 已提交
25
let PARAM_ERROR = 401;
I
add xts  
inter515 已提交
26

J
jiyong_sd 已提交
27
export default function ActsZlibTest() {
I
add xts  
inter515 已提交
28 29 30 31 32 33 34 35 36 37 38 39 40
    describe('ActsZlibTest', function () {
        beforeEach(async (done) => {
            var context = featureAbility.getContext();
            context.getCacheDir((err, data) => {
                console.info('ActsZlibTest successful. Data:' + JSON.stringify(data));
                dir = data;
                var objectone = "com.example.amsZipfileUnzipfileST.MainAbility/com.example.amsZipfileUnzipfileST/";
                var objecttwo = "com.example.amsZipfileUnzipfileST.MainAbility/com.example.amsZipfileUnzipfileST/zipunzip";
                var objectthree = "com.example.amsZipfileUnzipfileST.MainAbility/ActsZlibTest/example.amsZipfileUnzipfileST";
                infos = dir + objectone + objecttwo + objectthree;
                done();
            })
        });
K
kirl75 已提交
41

I
add xts  
inter515 已提交
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
        /*
        * @tc.number: ACTS_ZipFile_0100
        * @tc.name: zipFile
        * @tc.desc: inFile is empty
        */
        it('ACTS_ZipFile_0100', 0, async function (done) {
            console.log("==================ACTS_ZipFile_0100 start==================");
            var path = "";
            var zipDest = dir + "/ACTS_ZipFile_0100.zip"
            var options = {};
            options.level = zlib.CompressLevel.COMPRESS_LEVEL_NO_COMPRESSION;
            zlib.zipFile(path, zipDest, options).then((data) => {
                console.log("ACTS_ZipFile_0100 data: " + data);
                expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_ERRNO);
                done();
            }).catch((err) => {
                console.log("ACTS_ZipFile_0100 zipFile fail: " + err);
                expect(err).assertEqual(zlib.ErrorCode.ERROR_CODE_ERRNO);
                done();
            })
            console.log("==================ACTS_ZipFile_0100 end==================");
        })
K
kirl75 已提交
64

I
add xts  
inter515 已提交
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
        /*
        * @tc.number: ACTS_ZipFile_0200
        * @tc.name: zipFile
        * @tc.desc: inFile doesn't exist
        */
        it('ACTS_ZipFile_0200', 0, async function (done) {
            console.log("==================ACTS_ZipFile_0200 start==================");
            var path = dir + "/ACTS_ZipFile_9999900.txt";
            var src = dir + "/ACTS_ZipFile_999991100.txt";
            var fd = fileio.openSync(path, 0o100 | 0o2, 0o666);
            fileio.write(fd, infos).then(function (number) {
                console.info("ACTS_ZipFile_0200 write data to file successfully:" + number);
                var options = {};
                options.level = zlib.CompressLevel.COMPRESS_LEVEL_DEFAULT_COMPRESSION;
                zlib.zipFile(src, dir, options).then((data) => {
                    console.log("ACTS_ZipFile_0200 data: " + data);
                    expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_ERRNO);
                    done();
                }).catch((err) => {
                    console.log("ACTS_ZipFile_0200 zipFile fail: " + err);
                    expect(err).assertEqual(zlib.ErrorCode.ERROR_CODE_ERRNO);
                    done();
                })
            }).catch(function (err) {
                console.info("ACTS_ZipFile_0200 write data to file failed with error:" + err);
                expect(err).assertFail();
                done();
            });
            console.log("==================ACTS_ZipFile_0200 end==================");
        })
K
kirl75 已提交
95

I
add xts  
inter515 已提交
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125
        /*
        * @tc.number: ACTS_ZipFile_0300
        * @tc.name: zipFile
        * @tc.desc: output file not specified
        */
        it('ACTS_ZipFile_0300', 0, async function (done) {
            console.log("==================ACTS_ZipFile_0300 start==================");
            var path = dir + "/ACTS_ZipFile_0300.txt";
            var zipDest = "";
            var fd = fileio.openSync(path, 0o100 | 0o2, 0o666);
            fileio.write(fd, infos).then(function (number) {
                console.info("ACTS_ZipFile_0300 write data to file successfully:" + number);
                var options = {};
                options.level = zlib.CompressLevel.COMPRESS_LEVEL_DEFAULT_COMPRESSION;
                zlib.zipFile(path, zipDest, options).then((data) => {
                    console.log("ACTS_ZipFile_0300 data: " + data);
                    expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_ERRNO);
                    done();
                }).catch((err) => {
                    console.log("ACTS_ZipFile_0300 zipFile fail: " + err);
                    expect(err).assertEqual(zlib.ErrorCode.ERROR_CODE_ERRNO);
                    done();
                })
            }).catch(function (err) {
                console.info("ACTS_ZipFile_0300 write data to file failed with error:" + err);
                expect(err).assertFail();
                done();
            });
            console.log("==================ACTS_ZipFile_0300 end==================");
        })
K
kirl75 已提交
126

I
add xts  
inter515 已提交
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156
        /*
        * @tc.number: ACTS_ZipFile_0400
        * @tc.name: zipFile
        * @tc.desc: The output file is a directory that does not exist
        */
        it('ACTS_ZipFile_0400', 0, async function (done) {
            console.log("==================ACTS_ZipFile_0400 start==================");
            var path = dir + "/ACTS_ZipFile_0400.txt";
            var zipDest = "/ACTS_ZipFile_0400.zip";
            var fd = fileio.openSync(path, 0o100 | 0o2, 0o666);
            fileio.write(fd, infos).then(function (number) {
                console.info("ACTS_ZipFile_0400 write data to file successfully:" + number);
                var options = {};
                options.level = zlib.CompressLevel.COMPRESS_LEVEL_DEFAULT_COMPRESSION;
                zlib.zipFile(path, zipDest, options).then((data) => {
                    console.log("ACTS_ZipFile_0400 data: " + data);
                    expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_ERRNO);
                    done();
                }).catch((err) => {
                    console.log("ACTS_ZipFile_0400 zipFile fail: " + err);
                    expect(err).assertEqual(zlib.ErrorCode.ERROR_CODE_ERRNO);
                    done();
                })
            }).catch(function (err) {
                console.info("ACTS_ZipFile_0400 write data to file failed with error:" + err);
                expect(err).assertFail();
                done();
            });
            console.log("==================ACTS_ZipFile_0400 end==================");
        })
K
kirl75 已提交
157

I
add xts  
inter515 已提交
158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215
        /*
        * @tc.number: ACTS_ZipFile_2200
        * @tc.name: zipFile
        * @tc.desc: COMPRESS_LEVEL_NO_COMPRESSION,
        */
        it('ACTS_ZipFile_2200', 0, async function (done) {
            console.log("==================ACTS_ZipFile_2200 start==================");
            var path = dir + "/ACTS_ZipFile_2200.txt";
            var zipDest = dir + "/ACTS_ZipFile_2200.zip"
            var unzipdir = dir + "/ACTS_ZipFile_2200";
            var unzipresultfile = unzipdir + "/ACTS_ZipFile_2200.txt";
            var options = {};
            options.level = zlib.CompressLevel.COMPRESS_LEVEL_NO_COMPRESSION;
            var fd = fileio.openSync(path, 0o100 | 0o2, 0o666);
            fileio.write(fd, infos).then(function (number) {
                console.info("ACTS_ZipFile_2200 write data to file secondlly successfully:" + number);
                zlib.zipFile(path, zipDest, options).then((data) => {
                    var zipStat = fileio.statSync(zipDest);
                    var isFile = zipStat.isFile();
                    expect(isFile).assertTrue();
                    var srcSize = fileio.statSync(path).size;
                    var destSize = zipStat.size;
                    expect(srcSize > destSize).assertTrue();
                    expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK);
                    fileio.mkdir(unzipdir).then(function () {
                        console.info("ACTS_ZipFile_2200 mkdir successfully");
                        zlib.unzipFile(zipDest, unzipdir, options).then((data) => {
                            var unzipStat = fileio.statSync(unzipresultfile);
                            var isFile = unzipStat.isFile();
                            expect(isFile).assertTrue();
                            var destSize = unzipStat.size;
                            var originSize = fileio.statSync(path).size;
                            var result = (originSize == destSize);
                            expect(result).assertTrue();
                            expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK);
                            console.error('ACTS_ZipFile_2200 unzipFile');
                            done();
                        }).catch((err) => {
                            console.log("ACTS_ZipFile_2200 err: " + err);
                            expect(err).assertFail();
                            done();
                        })
                    }).catch(function (error) {
                        console.info("ACTS_ZipFile_2200 mkdir failed with error:" + error);
                        expect(error).assertFail();
                        done();
                    });
                }).catch((err) => {
                    console.log("zipFile fail: " + err);
                    expect(err).assertFail();
                    done();
                })
            }).catch(function (err) {
                console.info("ACTS_ZipFile_2200 write data to file failed with error:" + err);
                expect(err).assertFail();
                done();
            });
            console.log("==================ACTS_ZipFile_2200 end==================");
R
renyi 已提交
216
        });
K
kirl75 已提交
217

I
add xts  
inter515 已提交
218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276
        /*
        * @tc.number: ACTS_ZipFile_2300
        * @tc.name: zipFile
        * @tc.desc: COMPRESS_LEVEL_BEST_SPEED,
        */
        it('ACTS_ZipFile_2300', 0, async function (done) {
            console.log("==================ACTS_ZipFile_2300 start==================");
            var path = dir + "/ACTS_ZipFile_2300.txt";
            var zipDest = dir + "/ACTS_ZipFile_2300.zip"
            var unzipdir = dir + "/ACTS_ZipFile_2300";
            var unzipresultfile = unzipdir + "/ACTS_ZipFile_2300.txt";
            var options = {};
            options.level = zlib.CompressLevel.COMPRESS_LEVEL_BEST_SPEED;
            var fd = fileio.openSync(path, 0o100 | 0o2, 0o666);
            fileio.write(fd, infos).then(function (number) {
                console.info("ACTS_ZipFile_2300 write data to file successfully:" + number);
                zlib.zipFile(path, zipDest, options).then((data) => {
                    var zipStat = fileio.statSync(zipDest);
                    var isFile = zipStat.isFile();
                    expect(isFile).assertTrue();
                    var srcSize = fileio.statSync(path).size;
                    var destSize = zipStat.size;
                    expect(srcSize > destSize).assertTrue();
                    expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK);
                    fileio.mkdir(unzipdir).then(function () {
                        console.info("ACTS_ZipFile_2300 mkdir successfully");
                        zlib.unzipFile(zipDest, unzipdir, options).then((data) => {
                            var unzipStat = fileio.statSync(unzipresultfile);
                            var isFile = unzipStat.isFile();
                            expect(isFile).assertTrue();
                            var destSize = unzipStat.size;
                            var originSize = fileio.statSync(path).size;
                            var result = (originSize == destSize);
                            expect(result).assertTrue();
                            expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK);
                            console.error('ACTS_ZipFile_2300 unzipFile');
                            done();
                        }).catch((err) => {
                            console.log("ACTS_ZipFile_2300 err: " + err);
                            expect(err).assertFail();
                            done();
                        })
                    }).catch(function (error) {
                        console.info("ACTS_ZipFile_2300 mkdir failed with error:" + error);
                        expect(error).assertFail();
                        done();
                    });
                }).catch((err) => {
                    console.log("zipFile fail: " + err);
                    expect(err).assertFail();
                    done();
                })
            }).catch(function (err) {
                console.info("ACTS_ZipFile_2300 write data to file failed with error:" + err);
                expect(err).assertFail();
                done();
            });
            console.log("==================ACTS_ZipFile_2300 end==================");
        })
K
kirl75 已提交
277

I
add xts  
inter515 已提交
278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335
        /*
        * @tc.number: ACTS_ZipFile_2400
        * @tc.name: zipFile
        * @tc.desc: COMPRESS_LEVEL_BEST_COMPRESSION,
        */
        it('ACTS_ZipFile_2400', 0, async function (done) {
            console.log("==================ACTS_ZipFile_2400 start==================");
            var path = dir + "/ACTS_ZipFile_2400.txt";
            var zipDest = dir + "/ACTS_ZipFile_2400.zip"
            var unzipdir = dir + "/ACTS_ZipFile_2400";
            var unzipresultfile = unzipdir + "/ACTS_ZipFile_2400.txt";
            var options = {};
            options.level = zlib.CompressLevel.COMPRESS_LEVEL_BEST_COMPRESSION;
            var fd = fileio.openSync(path, 0o100 | 0o2, 0o666);
            fileio.write(fd, infos).then(function (number) {
                console.info("ACTS_ZipFile_2400 write data to file successfully:" + number);
                zlib.zipFile(path, zipDest, options).then((data) => {
                    var zipStat = fileio.statSync(zipDest);
                    var isFile = zipStat.isFile();
                    expect(isFile).assertTrue();
                    var srcSize = fileio.statSync(path).size;
                    var destSize = zipStat.size;
                    expect(srcSize > destSize).assertTrue();
                    expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK);
                    fileio.mkdir(unzipdir).then(function () {
                        console.info("ACTS_ZipFile_2400 mkdir successfully");
                        zlib.unzipFile(zipDest, unzipdir, options).then((data) => {
                            var unzipStat = fileio.statSync(unzipresultfile);
                            var isFile = unzipStat.isFile();
                            expect(isFile).assertTrue();
                            var destSize = unzipStat.size;
                            var originSize = fileio.statSync(path).size;
                            var result = (originSize == destSize);
                            expect(result).assertTrue();
                            expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK);
                            console.error('ACTS_ZipFile_2400 unzipFile');
                            done();
                        }).catch((err) => {
                            console.log("ACTS_ZipFile_2400 err: " + err);
                            expect(err).assertFail();
                            done();
                        })
                    }).catch(function (error) {
                        console.info("ACTS_ZipFile_2400 mkdir failed with error:" + error);
                        expect(error).assertFail();
                        done();
                    });
                }).catch((err) => {
                    console.log("zipFile fail: " + err);
                    expect(err).assertFail();
                    done();
                })
            }).catch(function (err) {
                console.info("ACTS_ZipFile_2400 write data to file failed with error:" + err);
                expect(err).assertFail();
                done();
            });
            console.log("==================ACTS_ZipFile_2400 end==================");
R
renyi 已提交
336
        });
K
kirl75 已提交
337

I
add xts  
inter515 已提交
338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395
        /*
        * @tc.number: ACTS_ZipFile_2500
        * @tc.name: zipFile
        * @tc.desc: COMPRESS_LEVEL_DEFAULT_COMPRESSION,
        */
        it('ACTS_ZipFile_2500', 0, async function (done) {
            console.log("==================ACTS_ZipFile_2500 start==================");
            var path = dir + "/ACTS_ZipFile_2500.txt";
            var zipDest = dir + "/ACTS_ZipFile_2500.zip"
            var unzipdir = dir + "/ACTS_ZipFile_2500";
            var unzipresultfile = unzipdir + "/ACTS_ZipFile_2500.txt";
            var options = {};
            options.level = zlib.CompressLevel.COMPRESS_LEVEL_DEFAULT_COMPRESSION;
            var fd = fileio.openSync(path, 0o100 | 0o2, 0o666);
            fileio.write(fd, infos).then(function (number) {
                console.info("ACTS_ZipFile_2500 write data to file successfully:" + number);
                zlib.zipFile(path, zipDest, options).then((data) => {
                    var zipStat = fileio.statSync(zipDest);
                    var isFile = zipStat.isFile();
                    expect(isFile).assertTrue();
                    var srcSize = fileio.statSync(path).size;
                    var destSize = zipStat.size;
                    expect(srcSize > destSize).assertTrue();
                    expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK);
                    fileio.mkdir(unzipdir).then(function () {
                        console.info("ACTS_ZipFile_2500 mkdir successfully");
                        zlib.unzipFile(zipDest, unzipdir, options).then((data) => {
                            var unzipStat = fileio.statSync(unzipresultfile);
                            var isFile = unzipStat.isFile();
                            expect(isFile).assertTrue();
                            var destSize = unzipStat.size;
                            var originSize = fileio.statSync(path).size;
                            var result = (originSize == destSize);
                            expect(result).assertTrue();
                            expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK);
                            console.error('ACTS_ZipFile_2500 unzipFile');
                            done();
                        }).catch((err) => {
                            console.log("ACTS_ZipFile_2500 err: " + err);
                            expect(err).assertFail();
                            done()
                        })
                    }).catch(function (error) {
                        console.info("ACTS_ZipFile_2500 mkdir failed with error:" + error);
                        expect(error).assertFail();
                        done();
                    });
                }).catch((err) => {
                    console.log("zipFile fail: " + err);
                    expect(err).assertFail();
                    done();
                })
            }).catch(function (err) {
                console.info("ACTS_ZipFile_2500 write data to file failed with error:" + err);
                expect(err).assertFail();
                done();
            });
            console.log("==================ACTS_ZipFile_2500 end==================");
R
renyi 已提交
396
        });
K
kirl75 已提交
397

I
add xts  
inter515 已提交
398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455
        /*
        * @tc.number: ACTS_ZipFile_2600
        * @tc.name: zipFile
        * @tc.desc: MEM_LEVEL_MIN_MEMLEVEL,,
        */
        it('ACTS_ZipFile_2600', 0, async function (done) {
            console.log("==================ACTS_ZipFile_2600 start==================");
            var path = dir + "/ACTS_ZipFile_2600.txt";
            var zipDest = dir + "/ACTS_ZipFile_2600.zip"
            var unzipdir = dir + "/ACTS_ZipFile_2600";
            var unzipresultfile = unzipdir + "/ACTS_ZipFile_2600.txt";
            var options = {};
            options.memLevel = zlib.MemLevel.MEM_LEVEL_MIN;
            var fd = fileio.openSync(path, 0o100 | 0o2, 0o666);
            fileio.write(fd, infos).then(function (number) {
                console.info("ACTS_ZipFile_2600 write data to file successfully:" + number);
                zlib.zipFile(path, zipDest, options).then((data) => {
                    var zipStat = fileio.statSync(zipDest);
                    var isFile = zipStat.isFile();
                    expect(isFile).assertTrue();
                    var srcSize = fileio.statSync(path).size;
                    var destSize = zipStat.size;
                    expect(srcSize > destSize).assertTrue();
                    expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK);
                    fileio.mkdir(unzipdir).then(function () {
                        console.info("ACTS_ZipFile_2600 mkdir successfully");
                        zlib.unzipFile(zipDest, unzipdir, options).then((data) => {
                            var unzipStat = fileio.statSync(unzipresultfile);
                            var isFile = unzipStat.isFile();
                            expect(isFile).assertTrue();
                            var destSize = unzipStat.size;
                            var originSize = fileio.statSync(path).size;
                            var result = (originSize == destSize);
                            expect(result).assertTrue();
                            expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK);
                            console.error('ACTS_ZipFile_2600 unzipFile');
                            done();
                        }).catch((err) => {
                            console.log("ACTS_ZipFile_2600 err: " + err);
                            expect(err).assertFail();
                            done();
                        })
                    }).catch(function (error) {
                        console.info("ACTS_ZipFile_2600 mkdir failed with error:" + error);
                        expect(error).assertFail();
                        done();
                    });
                }).catch((err) => {
                    console.log("zipFile fail: " + err);
                    expect(err).assertFail();
                    done();
                })
            }).catch(function (err) {
                console.info("ACTS_ZipFile_2600 write data to file failed with error:" + err);
                expect(err).assertFail();
                done();
            });
            console.log("==================ACTS_ZipFile_2600 end==================");
R
renyi 已提交
456
        });
K
kirl75 已提交
457

I
add xts  
inter515 已提交
458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515
        /*
        * @tc.number: ACTS_ZipFile_2700
        * @tc.name: zipFile
        * @tc.desc: MEM_LEVEL_MAX_MEMLEVEL,,
        */
        it('ACTS_ZipFile_2700', 0, async function (done) {
            console.log("==================ACTS_ZipFile_2700 start==================");
            var path = dir + "/ACTS_ZipFile_2700.txt";
            var zipDest = dir + "/ACTS_ZipFile_2700.zip"
            var unzipdir = dir + "/ACTS_ZipFile_2700";
            var unzipresultfile = unzipdir + "/ACTS_ZipFile_2700.txt";
            var options = {};
            options.memLevel = zlib.MemLevel.MEM_LEVEL_MAX;
            var fd = fileio.openSync(path, 0o100 | 0o2, 0o666);
            fileio.write(fd, infos).then(function (number) {
                console.info("ACTS_ZipFile_2700 write data to file successfully:" + number);
                zlib.zipFile(path, zipDest, options).then((data) => {
                    var zipStat = fileio.statSync(zipDest);
                    var isFile = zipStat.isFile();
                    expect(isFile).assertTrue();
                    var srcSize = fileio.statSync(path).size;
                    var destSize = zipStat.size;
                    expect(srcSize > destSize).assertTrue();
                    expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK);
                    fileio.mkdir(unzipdir).then(function () {
                        console.info("ACTS_ZipFile_2700 mkdir successfully");
                        zlib.unzipFile(zipDest, unzipdir, options).then((data) => {
                            var unzipStat = fileio.statSync(unzipresultfile);
                            var isFile = unzipStat.isFile();
                            expect(isFile).assertTrue();
                            var destSize = unzipStat.size;
                            var originSize = fileio.statSync(path).size;
                            var result = (originSize == destSize);
                            expect(result).assertTrue();
                            expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK);
                            console.error('ACTS_ZipFile_2700 unzipFile');
                            done();
                        }).catch((err) => {
                            console.log("ACTS_ZipFile_2700 err: " + err);
                            expect(err).assertFail();
                            done();
                        })
                    }).catch(function (error) {
                        console.info("ACTS_ZipFile_2700 mkdir failed with error:" + error);
                        expect(error).assertFail();
                        done();
                    });
                }).catch((err) => {
                    console.log("zipFile fail: " + err);
                    expect(err).assertFail();
                    done();
                })
            }).catch(function (err) {
                console.info("ACTS_ZipFile_2700 write data to file failed with error:" + err);
                expect(err).assertFail();
                done();
            });
            console.log("==================ACTS_ZipFile_2700 end==================");
R
renyi 已提交
516
        });
K
kirl75 已提交
517

I
add xts  
inter515 已提交
518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575
        /*
        * @tc.number: ACTS_ZipFile_2800
        * @tc.name: zipFile
        * @tc.desc: MEM_LEVEL_DEFAULT_MEMLEVEL,,
        */
        it('ACTS_ZipFile_2800', 0, async function (done) {
            console.log("==================ACTS_ZipFile_2800 start==================");
            var path = dir + "/ACTS_ZipFile_2800.txt";
            var zipDest = dir + "/ACTS_ZipFile_2800.zip"
            var unzipdir = dir + "/ACTS_ZipFile_2800";
            var unzipresultfile = unzipdir + "/ACTS_ZipFile_2800.txt";
            var options = {};
            options.memLevel = zlib.MemLevel.MEM_LEVEL_DEFAULT;
            var fd = fileio.openSync(path, 0o100 | 0o2, 0o666);
            fileio.write(fd, infos).then(function (number) {
                console.info("ACTS_ZipFile_2800 write data to file successfully:" + number);
                zlib.zipFile(path, zipDest, options).then((data) => {
                    var zipStat = fileio.statSync(zipDest);
                    var isFile = zipStat.isFile();
                    expect(isFile).assertTrue();
                    var srcSize = fileio.statSync(path).size;
                    var destSize = zipStat.size;
                    expect(srcSize > destSize).assertTrue();
                    expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK);
                    fileio.mkdir(unzipdir).then(function () {
                        console.info("ACTS_ZipFile_2800 mkdir successfully");
                        zlib.unzipFile(zipDest, unzipdir, options).then((data) => {
                            var unzipStat = fileio.statSync(unzipresultfile);
                            var isFile = unzipStat.isFile();
                            expect(isFile).assertTrue();
                            var destSize = unzipStat.size;
                            var originSize = fileio.statSync(path).size;
                            var result = (originSize == destSize);
                            expect(result).assertTrue();
                            expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK);
                            console.error('ACTS_ZipFile_2800 unzipFile');
                            done();
                        }).catch((err) => {
                            console.log("ACTS_ZipFile_2800 err: " + err);
                            expect(err).assertFail();
                            done();
                        })
                    }).catch(function (error) {
                        console.info("ACTS_ZipFile_2800 mkdir failed with error:" + error);
                        expect(error).assertFail();
                        done();
                    });
                }).catch((err) => {
                    console.log("zipFile fail: " + err);
                    expect(err).assertFail();
                    done();
                })
            }).catch(function (err) {
                console.info("ACTS_ZipFile_2800 write data to file failed with error:" + err);
                expect(err).assertFail();
                done();
            });
            console.log("==================ACTS_ZipFile_2800 end==================");
R
renyi 已提交
576
        });
K
kirl75 已提交
577

I
add xts  
inter515 已提交
578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636
        /*
        * @tc.number: ACTS_ZipFile_2900
        * @tc.name: zipFile
        * @tc.desc: COMPRESS_STRATEGY_DEFAULT_STRATEGY,,
        */
        it('ACTS_ZipFile_2900', 0, async function (done) {
            console.log("==================ACTS_ZipFile_2900 start==================");
            var path = dir + "/ACTS_ZipFile_2900.txt";
            var zipDest = dir + "/ACTS_ZipFile_2900.zip"
            var unzipdir = dir + "/ACTS_ZipFile_2900";
            var unzipresultfile = unzipdir + "/ACTS_ZipFile_2900.txt";
            var options = {};
            options.strategy = zlib.CompressStrategy.COMPRESS_STRATEGY_DEFAULT_STRATEGY;
            var fd = fileio.openSync(path, 0o100 | 0o2, 0o666);
            fileio.write(fd, infos).then(function (number) {
                console.info("ACTS_ZipFile_2900 write data to file successfully:" + number);
                zlib.zipFile(path, zipDest, options).then((data) => {
                    var zipStat = fileio.statSync(zipDest);
                    var isFile = zipStat.isFile();
                    expect(isFile).assertTrue();
                    var srcSize = fileio.statSync(path).size;
                    var destSize = zipStat.size;
                    expect(srcSize > destSize).assertTrue();
                    expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK);
                    fileio.mkdir(unzipdir).then(function () {
                        console.info("ACTS_ZipFile_2900 mkdir successfully");
                        zlib.unzipFile(zipDest, unzipdir, options).then((data) => {
                            var unzipStat = fileio.statSync(unzipresultfile);
                            var isFile = unzipStat.isFile();
                            expect(isFile).assertTrue();
                            var destSize = unzipStat.size;
                            var originSize = fileio.statSync(path).size;
                            var result = (originSize == destSize);
                            expect(result).assertTrue();
                            expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK);
                            console.error('ACTS_ZipFile_2900 unzipFile');
                            done();
                        }).catch((err) => {
                            console.log("ACTS_ZipFile_2900 err: " + err);
                            expect(err).assertFail();
                            done();
                        })
                    }).catch(function (error) {
                        console.info("ACTS_ZipFile_2900 mkdir failed with error:" + error);
                        expect(error).assertFail();
                        done();
                    });
                }).catch((err) => {
                    console.log("zipFile fail: " + err);
                    expect(err).assertFail();
                    done();
                })
            }).catch(function (err) {
                console.info("ACTS_ZipFile_2900 write data to file failed with error:" + err);
                expect(err).assertFail();
                done();
            });
            console.log("==================ACTS_ZipFile_2900 end==================");
        });
K
kirl75 已提交
637

I
add xts  
inter515 已提交
638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695
        /*
        * @tc.number: ACTS_ZipFile_3000
        * @tc.name: zipFile
        * @tc.desc: COMPRESS_STRATEGY_FILTERED,,
        */
        it('ACTS_ZipFile_3000', 0, async function (done) {
            console.log("==================ACTS_ZipFile_3000 start==================");
            var path = dir + "/ACTS_ZipFile_3000.txt";
            var zipDest = dir + "/ACTS_ZipFile_3000.zip"
            var unzipdir = dir + "/ACTS_ZipFile_3000";
            var unzipresultfile = unzipdir + "/ACTS_ZipFile_3000.txt";
            var options = {};
            options.strategy = zlib.CompressStrategy.COMPRESS_STRATEGY_FILTERED;
            var fd = fileio.openSync(path, 0o100 | 0o2, 0o666);
            fileio.write(fd, infos).then(function (number) {
                console.info("ACTS_ZipFile_3000 write data to file successfully:" + number);
                zlib.zipFile(path, zipDest, options).then((data) => {
                    var zipStat = fileio.statSync(zipDest);
                    var isFile = zipStat.isFile();
                    expect(isFile).assertTrue();
                    var srcSize = fileio.statSync(path).size;
                    var destSize = zipStat.size;
                    expect(srcSize > destSize).assertTrue();
                    expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK);
                    fileio.mkdir(unzipdir).then(function () {
                        console.info("ACTS_ZipFile_3000 mkdir successfully");
                        zlib.unzipFile(zipDest, unzipdir, options).then((data) => {
                            var unzipStat = fileio.statSync(unzipresultfile);
                            var isFile = unzipStat.isFile();
                            expect(isFile).assertTrue();
                            var destSize = unzipStat.size;
                            var originSize = fileio.statSync(path).size;
                            var result = (originSize == destSize);
                            expect(result).assertTrue();
                            expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK);
                            console.error('ACTS_ZipFile_3000 unzipFile');
                            done();
                        }).catch((err) => {
                            console.log("ACTS_ZipFile_3000 err: " + err);
                            expect(err).assertFail();
                            done();
                        })
                    }).catch(function (error) {
                        console.info("ACTS_ZipFile_3000 mkdir failed with error:" + error);
                        expect(error).assertFail();
                        done();
                    });
                }).catch((err) => {
                    console.log("zipFile fail: " + err);
                    expect(err).assertFail();
                    done();
                })
            }).catch(function (err) {
                console.info("ACTS_ZipFile_3000 write data to file failed with error:" + err);
                expect(err).assertFail();
                done();
            });
            console.log("==================ACTS_ZipFile_3000 end==================");
R
renyi 已提交
696
        });
K
kirl75 已提交
697

I
add xts  
inter515 已提交
698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755
        /*
        * @tc.number: ACTS_ZipFile_3100
        * @tc.name: zipFile
        * @tc.desc: COMPRESS_STRATEGY_HUFFMAN_ONLY,,
        */
        it('ACTS_ZipFile_3100', 0, async function (done) {
            console.log("==================ACTS_ZipFile_3100 start==================");
            var path = dir + "/ACTS_ZipFile_3100.txt";
            var zipDest = dir + "/ACTS_ZipFile_3100.zip"
            var unzipdir = dir + "/ACTS_ZipFile_3100";
            var unzipresultfile = unzipdir + "/ACTS_ZipFile_3100.txt";
            var options = {};
            options.strategy = zlib.CompressStrategy.COMPRESS_STRATEGY_HUFFMAN_ONLY;
            var fd = fileio.openSync(path, 0o100 | 0o2, 0o666);
            fileio.write(fd, infos).then(function (number) {
                console.info("ACTS_ZipFile_3100 write data to file successfully:" + number);
                zlib.zipFile(path, zipDest, options).then((data) => {
                    var zipStat = fileio.statSync(zipDest);
                    var isFile = zipStat.isFile();
                    expect(isFile).assertTrue();
                    var srcSize = fileio.statSync(path).size;
                    var destSize = zipStat.size;
                    expect(srcSize > destSize).assertTrue();
                    expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK);
                    fileio.mkdir(unzipdir).then(function () {
                        console.info("ACTS_ZipFile_3100 mkdir successfully");
                        zlib.unzipFile(zipDest, unzipdir, options).then((data) => {
                            var unzipStat = fileio.statSync(unzipresultfile);
                            var isFile = unzipStat.isFile();
                            expect(isFile).assertTrue();
                            var destSize = unzipStat.size;
                            var originSize = fileio.statSync(path).size;
                            var result = (originSize == destSize);
                            expect(result).assertTrue();
                            expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK);
                            console.error('ACTS_ZipFile_3100 unzipFile');
                            done();
                        }).catch((err) => {
                            console.log("ACTS_ZipFile_3100 err: " + err);
                            expect(err).assertFail();
                            done();
                        })
                    }).catch(function (error) {
                        console.info("ACTS_ZipFile_3100 mkdir failed with error:" + error);
                        expect(error).assertFail();
                        done();
                    });
                }).catch((err) => {
                    console.log("zipFile fail: " + err);
                    expect(err).assertFail();
                    done();
                })
            }).catch(function (err) {
                console.info("ACTS_ZipFile_3100 write data to file failed with error:" + err);
                expect(err).assertFail();
                done();
            });
            console.log("==================ACTS_ZipFile_3100 end==================");
R
renyi 已提交
756
        });
K
kirl75 已提交
757

I
add xts  
inter515 已提交
758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816
        /*
        * @tc.number: ACTS_ZipFile_3200
        * @tc.name: zipFile
        * @tc.desc: COMPRESS_STRATEGY_RLE,,
        */
        it('ACTS_ZipFile_3200', 0, async function (done) {
            console.log("==================ACTS_ZipFile_3200 start==================");
            var path = dir + "/ACTS_ZipFile_3200.txt";
            var zipDest = dir + "/ACTS_ZipFile_3200.zip";
            var unzipdir = dir + "/ACTS_ZipFile_3200";
            var unzipresultfile = unzipdir + "/ACTS_ZipFile_3200.txt";
            var options = {};
            options.strategy = zlib.CompressStrategy.COMPRESS_STRATEGY_RLE;
            var fd = fileio.openSync(path, 0o100 | 0o2, 0o666);
            fileio.write(fd, infos).then(function (number) {
                console.info("ACTS_ZipFile_3200 write data to file successfully:" + number);
                zlib.zipFile(path, zipDest, options).then((data) => {
                    var zipStat = fileio.statSync(zipDest);
                    var isFile = zipStat.isFile();
                    expect(isFile).assertTrue();
                    var srcSize = fileio.statSync(path).size;
                    var destSize = zipStat.size;
                    expect(srcSize > destSize).assertTrue();
                    expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK);
                    fileio.mkdir(unzipdir).then(function () {
                        console.info("ACTS_ZipFile_3200 mkdir successfully");
                        zlib.unzipFile(zipDest, unzipdir, options).then((data) => {
                            var unzipStat = fileio.statSync(unzipresultfile);
                            var isFile = unzipStat.isFile();
                            expect(isFile).assertTrue();
                            var destSize = unzipStat.size;
                            var originSize = fileio.statSync(path).size;
                            var result = (originSize == destSize);
                            expect(result).assertTrue();
                            expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK);
                            console.error('ACTS_ZipFile_3200 unzipFile');
                            done();
                        }).catch((err) => {
                            console.log("ACTS_ZipFile_3200 err: " + err);
                            done();
                            expect(err).assertFail();
                            done();
                        })
                    }).catch(function (error) {
                        console.info("ACTS_ZipFile_3200 mkdir failed with error:" + error);
                        expect(error).assertFail();
                        done();
                    });
                }).catch((err) => {
                    console.log("zipFile fail: " + err);
                    expect(err).assertFail();
                    done();
                })
            }).catch(function (err) {
                console.info("ACTS_ZipFile_3200 write data to file failed with error:" + err);
                expect(err).assertFail();
                done();
            });
            console.log("==================ACTS_ZipFile_3200 end==================");
R
renyi 已提交
817
        });
K
kirl75 已提交
818

I
add xts  
inter515 已提交
819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876
        /*
        * @tc.number: ACTS_ZipFile_3300
        * @tc.name: zipFile
        * @tc.desc: COMPRESS_STRATEGY_FIXED,,
        */
        it('ACTS_ZipFile_3300', 0, async function (done) {
            console.log("==================ACTS_ZipFile_3300 start==================");
            var path = dir + "/ACTS_ZipFile_3300.txt";
            var zipDest = dir + "/ACTS_ZipFile_3300.zip"
            var unzipdir = dir + "/ACTS_ZipFile_3300";
            var unzipresultfile = unzipdir + "/ACTS_ZipFile_3300.txt";
            var options = {};
            options.strategy = zlib.CompressStrategy.COMPRESS_STRATEGY_FIXED;
            var fd = fileio.openSync(path, 0o100 | 0o2, 0o666);
            fileio.write(fd, infos).then(function (number) {
                console.info("ACTS_ZipFile_3300 write data to file successfully:" + number);
                zlib.zipFile(path, zipDest, options).then((data) => {
                    var zipStat = fileio.statSync(zipDest);
                    var isFile = zipStat.isFile();
                    expect(isFile).assertTrue();
                    var srcSize = fileio.statSync(path).size;
                    var destSize = zipStat.size;
                    expect(srcSize > destSize).assertTrue();
                    expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK);
                    fileio.mkdir(unzipdir).then(function () {
                        console.info("ACTS_ZipFile_3300 mkdir successfully");
                        zlib.unzipFile(zipDest, unzipdir, options).then((data) => {
                            var unzipStat = fileio.statSync(unzipresultfile);
                            var isFile = unzipStat.isFile();
                            expect(isFile).assertTrue();
                            var destSize = unzipStat.size;
                            var originSize = fileio.statSync(path).size;
                            var result = (originSize == destSize);
                            expect(result).assertTrue();
                            expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK);
                            console.error('ACTS_ZipFile_3300 unzipFile');
                            done();
                        }).catch((err) => {
                            console.log("ACTS_ZipFile_3300 err: " + err);
                            expect(err).assertFail();
                            done();
                        })
                    }).catch(function (error) {
                        console.info("ACTS_ZipFile_3300 mkdir failed with error:" + error);
                        expect(error).assertFail();
                        done();
                    });
                }).catch((err) => {
                    console.log("zipFile fail: " + err);
                    expect(err).assertFail();
                    done();
                })
            }).catch(function (err) {
                console.info("ACTS_ZipFile_3300 write data to file failed with error:" + err);
                expect(err).assertFail();
                done();
            });
            console.log("==================ACTS_ZipFile_3300 end==================");
R
renyi 已提交
877
        });
K
kirl75 已提交
878

I
add xts  
inter515 已提交
879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909
        /*
        * @tc.number: ACTS_ZipFile_3500
        * @tc.name: zipFile
        * @tc.desc: INPUT_FILE_NOT_EXIST,,
        */
        it('ACTS_ZipFile_3500', 0, async function (done) {
            console.log("==================ACTS_ZipFile_3500 start==================");
            var path = dir + "/ACTS_ZipFile_3500.txt";
            var src = dir + "/ACTS_ZipFile_9900.txt";
            var unzipdir = dir + "/ACTS_ZipFile_3500";
            var options = {};
            options.strategy = zlib.CompressStrategy.COMPRESS_STRATEGY_FILTERED;
            var fd = fileio.openSync(path, 0o100 | 0o2, 0o666);
            fileio.write(fd, infos).then(function (number) {
                console.info("ACTS_ZipFile_3500 write  successfully:" + number);
                zlib.zipFile(src, dir, options).then((data) => {
                    console.log("ACTS_ZipFile_3500 data: " + data);
                    expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_ERRNO);
                    done();
                }).catch((err) => {
                    console.log("ACTS_ZipFile_3500 err: " + err);
                    expect(err).assertEqual(zlib.ErrorCode.ERROR_CODE_ERRNO);
                    done();
                });
            }).catch(function (err) {
                console.info("ACTS_ZipFile_3500 write data to file failed with error:" + err);
                expect(err).assertFail();
                done();
            });
            console.log("==================ACTS_ZipFile_3500 end ==================");
        })
K
kirl75 已提交
910

I
add xts  
inter515 已提交
911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940
        /*
        * @tc.number: ACTS_ZipFile_3600
        * @tc.name: zipFile
        * @tc.desc: INPUT_FILE_NULL,,
        */
        it('ACTS_ZipFile_3600', 0, async function (done) {
            console.log("==================ACTS_ZipFile_3600 start==================");
            var path = dir + "/ACTS_ZipFile_3600.txt";
            var zipDest = "";
            var options = {};
            options.strategy = zlib.CompressStrategy.COMPRESS_STRATEGY_FILTERED;
            var fd = fileio.openSync(path, 0o100 | 0o2, 0o666);
            fileio.write(fd, infos).then(function (number) {
                console.info("ACTS_ZipFile_3600 write data to file successfully:" + number);
                zlib.zipFile(path, zipDest, options).then((data) => {
                    console.log("ACTS_ZipFile_3600 data: " + data);
                    expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_ERRNO);
                    done();
                }).catch((err) => {
                    console.log("ACTS_ZipFile_3600 err: " + err);
                    expect(err).assertEqual(zlib.ErrorCode.ERROR_CODE_ERRNO);
                    done();
                });
            }).catch(function (err) {
                console.info("ACTS_ZipFile_3600 write data to file failed with error:" + err);
                expect(err).assertFail();
                done();
            });
            console.log("==================ACTS_ZipFile_3600 end ==================")
        })
K
kirl75 已提交
941

I
add xts  
inter515 已提交
942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101
        /*
        * @tc.number: ACTS_ZipFile_4500
        * @tc.name: zipFile
        * @tc.desc: COMPRESS_STRATEGY_FILTERED_CALLBACK,,
        */
        it('ACTS_ZipFile_4500', 0, async function (done) {
            console.log("==================ACTS_ZipFile_4500 start==================");
            var path = dir + "/ACTS_ZipFile_4500.txt";
            var zipDest = dir + "/ACTS_ZipFile_4500.zip"
            var unzipDest = dir + "/ACTS_ZipFile_9900.zip"
            var unzipdir = dir + "/ACTS_ZipFile_4500";
            var zipdir = dir + "/ACTS_ZipFile_9900";
            var options = {};
            options.strategy = zlib.CompressStrategy.COMPRESS_STRATEGY_FILTERED;
            var fd = fileio.openSync(path, 0o100 | 0o2, 0o666);
            fileio.write(fd, infos).then(function (number) {
                console.info("ACTS_ZipFile_4500 write data to file successfully:" + number);
                zlib.zipFile(path, zipDest, options).then((data) => {
                    var zipStat = fileio.statSync(zipDest);
                    var isFile = zipStat.isFile();
                    expect(isFile).assertTrue();
                    var srcSize = fileio.statSync(path).size;
                    var destSize = zipStat.size;
                    expect(srcSize > destSize).assertTrue();
                    expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK);
                    fileio.mkdir(unzipdir).then(function () {
                        console.info("ACTS_ZipFile_4500 mkdir successfully");
                        zlib.unzipFile(unzipDest, zipdir, options).then((data) => {
                            console.log("ACTS_ZipFile_4500 data: " + data);
                            expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_ERRNO);
                            done();
                        }).catch((err) => {
                            console.log("ACTS_ZipFile_4500 err: " + err);
                            expect(err).assertEqual(zlib.ErrorCode.ERROR_CODE_ERRNO);
                            done();
                        })
                    }).catch(function (error) {
                        console.info("ACTS_ZipFile_4500 mkdir failed with error:" + error);
                        expect(error).assertFail();
                        done();
                    });
                }).catch((err) => {
                    console.log("ACTS_ZipFile_4500 zipFile fail: " + err);
                    expect(err).assertEqual(zlib.ErrorCode.ERROR_CODE_ERRNO);
                    done();
                })
            }).catch(function (err) {
                console.info("ACTS_ZipFile_4500 write data to file failed with error:" + err);
                expect(err).assertFail();
                done();
            });
            console.log("==================ACTS_ZipFile_4500 end==================");
        })

        /*
        * @tc.number: ACTS_ZipFile_4900
        * @tc.name: zipFile
        * @tc.desc: COMPRESS_STRATEGY_FILTERED_PROMISE,
        */
        it('ACTS_ZipFile_4900', 0, async function (done) {
            console.log("==================ACTS_ZipFile_4900 start==================");
            var path = dir + "/ACTS_ZipFile_4900.txt";
            var zipDest = dir + "/ACTS_ZipFile_4900.zip"
            var unzipDest = dir + "/ACTS_ZipFile_4900.zip"
            var unzipdir = dir + "/ACTS_ZipFile_4900";
            var zipdir = dir + "/ACTS_ZipFile_4900";
            var options = {};
            options.strategy = zlib.CompressStrategy.COMPRESS_STRATEGY_FILTERED;
            var fd = fileio.openSync(path, 0o100 | 0o2, 0o666);
            fileio.write(fd, infos).then(function (number) {
                console.info("ACTS_ZipFile_4900 write data to file successfully:" + number);
                zlib.zipFile(path, zipDest, options).then(data => {
                    var zipStat = fileio.statSync(zipDest);
                    var isFile = zipStat.isFile();
                    expect(isFile).assertTrue();
                    var srcSize = fileio.statSync(path).size;
                    var destSize = zipStat.size;
                    expect(srcSize > destSize).assertTrue();
                    expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK);
                    fileio.mkdir(unzipdir).then(function () {
                        console.info("ACTS_ZipFile_4900 mkdir successfully");
                        zlib.unzipFile(unzipDest, zipdir, options).then(data => {
                            console.log("ACTS_ZipFile_4900 data: " + data);
                            expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK);
                            done();
                        }).catch(err => {
                            console.log("ACTS_ZipFile_4900 err: " + err);
                            expect(err).assertFail();
                            done();
                        })
                    }).catch(function (error) {
                        console.info("ACTS_ZipFile_4900 mkdir failed with error:" + error);
                        expect(error).assertFail();
                        done();
                    });
                }).catch(err => {
                    console.log("ACTS_ZipFile_4900 zipFile fail: " + err);
                    expect(err).assertFail();
                    done();
                })
            }).catch(function (err) {
                console.info("ACTS_ZipFile_4900 write data to file failed with error:" + err);
                expect(err).assertFail();
                done();
            });
            console.log("==================ACTS_ZipFile_4900 end==================");
        })

        /*
        * @tc.number: ACTS_ZipFile_5000
        * @tc.name: zipFile
        * @tc.desc: COMPRESS_STRATEGY_FIXED,
        */
        it('ACTS_ZipFile_5000', 0, async function (done) {
            console.log("==================ACTS_ZipFile_5000 start==================");
            var path = dir + "/ACTS_ZipFile_5000.txt";
            var zipDest = dir + "/ACTS_ZipFile_5000.zip"
            var unzipdir = dir + "/ACTS_ZipFile_5000";
            var options = {};
            options.strategy = zlib.CompressStrategy.COMPRESS_STRATEGY_FIXED;
            var fd = fileio.openSync(path, 0o100 | 0o2, 0o666);
            fileio.write(fd, infos).then(function (number) {
                console.info("ACTS_ZipFile_5000 write data to file successfully:" + number);
                zlib.zipFile(path, zipDest, options).then(data => {
                    var zipStat = fileio.statSync(zipDest);
                    var isFile = zipStat.isFile();
                    expect(isFile).assertTrue();
                    var srcSize = fileio.statSync(path).size;
                    var destSize = zipStat.size;
                    expect(srcSize > destSize).assertTrue();
                    expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK);
                    fileio.mkdir(unzipdir).then(function () {
                        console.info("ACTS_ZipFile_5000 mkdir successfully");
                        zlib.unzipFile(zipDest, unzipdir, options).then(data => {
                            console.log("ACTS_ZipFile_5000 data: " + data);
                            expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_OK);
                            done();
                        }).catch(err => {
                            console.log("unzipFile fail: " + err);
                            expect(err).assertFail();
                            done();
                        })
                    }).catch(function (error) {
                        console.info("ACTS_ZipFile_5000 mkdir failed with error:" + error);
                        expect(error).assertFail();
                        done();
                    });
                }).catch(err => {
                    console.log("zipFile fail: " + err);
                    expect(err).assertFail();
                    done();
                })
            }).catch(function (err) {
                console.info("ACTS_ZipFile_5000 write data to file failed with error:" + err);
                expect(err).assertFail();
                done();
            });
            console.log("==================ACTS_ZipFile_5000 end==================");
        })

I
inter515 已提交
1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163
        /*
        * @tc.number: SUB_BMS_TOOL_ZLIB_0076
        * @tc.name: compressFileOfFolders
        * @tc.desc: test compressFile when input is folders
        */
        it('compressFileOfFolders', Level.LEVEL2, async function (done) {
            console.log("==================compressFileOfFolders start==================");
            let inputPath1 = dir + "/compressFileOfFolders1";
            let inputPath2 = dir + "/compressFileOfFolders2";
            let path1 = inputPath1 + "/compressFileOfFolders1.txt";
            let zipDest1 = dir + "/compressFileOfFolders1.zip";
            let path2 = inputPath2 + "/compressFileOfFolders2.txt";
            let zipDest2 = dir + "/compressFileOfFolders2.zip";
            fileio.mkdirSync(inputPath1);
            fileio.mkdirSync(inputPath2);
            let fd = fileio.openSync(path1, 0o100 | 0o2, 0o666);
            await fileio.write(fd, infos).then(function (number) {
                console.info("compressFileOfFolders write data to file successfully :" + number);
            }).catch(function (err) {
                console.info("compressFileOfFolders write data to file failed with error:" + err);
                expect(err).assertFail();
            });
            console.info("compressFileOfFolders start compressFile");
            await zlib.compressFile(inputPath1, zipDest1, {
                level: zlib.CompressLevel.COMPRESS_LEVEL_DEFAULT_COMPRESSION
            }).then((data) => {
                console.info("compressFileOfFolders data: " + JSON.stringify(data));
                let zipStat = fileio.statSync(zipDest1);
                let isFile = zipStat.isFile();
                expect(isFile).assertTrue();
                let srcSize = fileio.statSync(path1).size;
                let destSize = zipStat.size;
                expect(srcSize > destSize).assertTrue();
                expect(data).assertEqual(null);
            }).catch((err) => {
                console.info("compressFileOfFolders data: " + JSON.stringify(err));
                expect(err).assertFail();
            })
            let fd2 = fileio.openSync(path2, 0o100 | 0o2, 0o666);
            await fileio.write(fd2, infos).then(function (number) {
                console.info("compressFileOfFolders write data to file successfully :" + number);
            }).catch(function (err) {
                console.info("compressFileOfFolders write data to file failed with error:" + err);
                expect(err).assertFail();
            });
            zlib.compressFile(inputPath2, zipDest2, {
                level: zlib.CompressLevel.COMPRESS_LEVEL_DEFAULT_COMPRESSION
            }, (err, data) => {
                console.info("compressFileOfFolders data2: " + JSON.stringify(data));
                console.info("compressFileOfFolders err2: " + JSON.stringify(err));
                let zipStat = fileio.statSync(zipDest2);
                let isFile = zipStat.isFile();
                expect(isFile).assertTrue();
                let srcSize = fileio.statSync(path2).size;
                let destSize = zipStat.size;
                expect(srcSize > destSize).assertTrue();
                expect(data).assertEqual(undefined);
                expect(err).assertEqual(null);
                done();
            })
        })

I
add xts  
inter515 已提交
1164
        /*
I
inter515 已提交
1165 1166 1167
        * @tc.number: SUB_BMS_TOOL_ZLIB_0077
        * @tc.name: compressFileTest
        * @tc.desc: test compressFile when inFile and out file is valid
I
add xts  
inter515 已提交
1168
        */
I
inter515 已提交
1169
        it('compressFileTest', Level.LEVEL2, async function (done) {
I
inter515 已提交
1170 1171 1172 1173 1174
            console.log("==================compressFileTest start==================");
            let path1 = dir + "/compressFileTest1.txt";
            let zipDest1 = dir + "/compressFileTest1.zip";
            let path2 = dir + "/compressFileTest2.txt";
            let zipDest2 = dir + "/compressFileTest2.zip";
I
add xts  
inter515 已提交
1175 1176
            let fd = fileio.openSync(path1, 0o100 | 0o2, 0o666);
            await fileio.write(fd, infos).then(function (number) {
I
inter515 已提交
1177
                console.info("compressFileTest write data to file successfully :" + number);
I
add xts  
inter515 已提交
1178
            }).catch(function (err) {
I
inter515 已提交
1179
                console.info("compressFileTest write data to file failed with error:" + err);
I
add xts  
inter515 已提交
1180 1181
                expect(err).assertFail();
            });
I
inter515 已提交
1182
            console.info("compressFileTest start compressFile");
I
add xts  
inter515 已提交
1183 1184 1185
            await zlib.compressFile(path1, zipDest1, {
                level: zlib.CompressLevel.COMPRESS_LEVEL_DEFAULT_COMPRESSION
            }).then((data) => {
I
inter515 已提交
1186
                console.info("compressFileTest data: " + JSON.stringify(data));
I
add xts  
inter515 已提交
1187 1188 1189 1190 1191 1192 1193
                let zipStat = fileio.statSync(zipDest1);
                let isFile = zipStat.isFile();
                expect(isFile).assertTrue();
                let srcSize = fileio.statSync(path1).size;
                let destSize = zipStat.size;
                expect(srcSize > destSize).assertTrue();
                expect(data).assertEqual(null);
K
kirl75 已提交
1194
            }).catch((err) => {
I
inter515 已提交
1195
                console.info("compressFileTest data: " + JSON.stringify(err));
I
add xts  
inter515 已提交
1196
                expect(err).assertFail();
K
kirl75 已提交
1197
            })
I
add xts  
inter515 已提交
1198 1199
            let fd2 = fileio.openSync(path2, 0o100 | 0o2, 0o666);
            await fileio.write(fd2, infos).then(function (number) {
I
inter515 已提交
1200
                console.info("compressFileTest write data to file successfully :" + number);
I
add xts  
inter515 已提交
1201
            }).catch(function (err) {
I
inter515 已提交
1202
                console.info("compressFileTest write data to file failed with error:" + err);
I
add xts  
inter515 已提交
1203 1204 1205 1206 1207
                expect(err).assertFail();
            });
            zlib.compressFile(path2, zipDest2, {
                level: zlib.CompressLevel.COMPRESS_LEVEL_DEFAULT_COMPRESSION
            }, (err, data) => {
I
inter515 已提交
1208 1209
                console.info("compressFileTest data2: " + JSON.stringify(data));
                console.info("compressFileTest err2: " + JSON.stringify(err));
I
add xts  
inter515 已提交
1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220
                let zipStat = fileio.statSync(zipDest2);
                let isFile = zipStat.isFile();
                expect(isFile).assertTrue();
                let srcSize = fileio.statSync(path2).size;
                let destSize = zipStat.size;
                expect(srcSize > destSize).assertTrue();
                expect(data).assertEqual(undefined);
                expect(err).assertEqual(null);
                done();
            })
        })
1221

I
add xts  
inter515 已提交
1222
        /*
I
inter515 已提交
1223 1224 1225
        * @tc.number: SUB_BMS_TOOL_ZLIB_0078
        * @tc.name: compressFileInFileNotExist
        * @tc.desc: test compressFile when inFile is not exist
I
add xts  
inter515 已提交
1226
        */
I
inter515 已提交
1227
        it('compressFileInFileNotExist', Level.LEVEL3, async function (done) {
I
inter515 已提交
1228 1229 1230
            console.log("==================compressFileInFileNotExist start==================");
            let path = "nonexist.txt";
            let zipDest = dir + "/compressFileInFileNotExist.zip";
I
add xts  
inter515 已提交
1231 1232 1233
            await zlib.compressFile(path, zipDest, {
                level: zlib.CompressLevel.COMPRESS_LEVEL_NO_COMPRESSION
            }).then((data) => {
I
inter515 已提交
1234
                console.log("compressFileInFileNotExist invalid src file success!");
I
add xts  
inter515 已提交
1235 1236 1237
                expect(data).assertFail();
                done();
            }).catch((err) => {
I
inter515 已提交
1238 1239 1240 1241 1242 1243 1244
                console.log("compressFileInFileNotExist zipFile fail: " + JSON.stringify(err));
                expect(err.code).assertEqual(SRC_FILE_INVALID);
                done();
            })
            zlib.compressFile(path, zipDest, {
                level: zlib.CompressLevel.COMPRESS_LEVEL_NO_COMPRESSION
            }, (err, data) => {
I
add xts  
inter515 已提交
1245
                expect(err.code).assertEqual(SRC_FILE_INVALID);
I
inter515 已提交
1246
                expect(data).assertEqual(undefined);
I
add xts  
inter515 已提交
1247 1248
                done();
            })
I
inter515 已提交
1249
            console.log("==================compressFileInFileNotExist end==================");
I
add xts  
inter515 已提交
1250
        })
1251

I
add xts  
inter515 已提交
1252
        /*
I
inter515 已提交
1253 1254 1255 1256
        * @tc.number: SUB_BMS_TOOL_ZLIB_0079
        * @tc.name: compressFileInFileNull
        * @tc.desc: test compressFile when inFile is null
        */
I
inter515 已提交
1257
        it('compressFileInFileNull', Level.LEVEL3, async function (done) {
I
inter515 已提交
1258 1259
            console.log("==================compressFileInFileNull start==================");
            let zipDest = dir + "/compressFileInFileNull.zip";
I
inter515 已提交
1260
            try {
I
inter515 已提交
1261 1262 1263 1264 1265 1266 1267 1268 1269
                await zlib.compressFile(null, zipDest, {
                    level: zlib.CompressLevel.COMPRESS_LEVEL_NO_COMPRESSION
                }).then((data) => {
                    console.log("compressFileInFileNull invalid src file success!");
                    expect().assertFail();
                }).catch((err) => {
                    console.log("compressFileInFileNull zipFile fail: " + JSON.stringify(err));
                    expect().assertFail();
                })
I
inter515 已提交
1270
            } catch (err) {
I
inter515 已提交
1271 1272
                expect(err.code).assertEqual(PARAM_ERROR);
            }
I
inter515 已提交
1273
            try {
I
inter515 已提交
1274 1275 1276 1277 1278 1279 1280
                zlib.compressFile(null, zipDest, {
                    level: zlib.CompressLevel.COMPRESS_LEVEL_NO_COMPRESSION
                }, (err, data) => {
                    console.log("compressFile result");
                    expect().assertFail();
                    done();
                })
I
inter515 已提交
1281
            } catch (err) {
I
inter515 已提交
1282 1283 1284 1285 1286 1287
                expect(err.code).assertEqual(PARAM_ERROR);
                done();
            }
            console.log("==================compressFileInFileNull end==================");
        })

I
inter515 已提交
1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324
        /*
        * @tc.number: SUB_BMS_TOOL_ZLIB_0080
        * @tc.name: compressFileOutFileNotExist
        * @tc.desc: test compressFile when outFile is not existed.
        */
        it('compressFileOutFileNull', Level.LEVEL3, async function (done) {
            console.log("==================compressFileOutFileNull start==================");
            let path1 = dir + "/compressFileOutFileNull.txt";
            let outFile = "/11111/22222.zip";
            let fd = fileio.openSync(path1, 0o100 | 0o2, 0o666);
            await fileio.write(fd, infos).then(function (number) {
                console.info("fileio write data to file successfully :" + number);
            }).catch(function (err) {
                console.info("fileio write data to file failed with error:" + err);
                expect(err).assertFail();
            });
            await zlib.compressFile(path1, outFile, {
                level: zlib.CompressLevel.COMPRESS_LEVEL_NO_COMPRESSION
            }).then((data) => {
                console.log("compressFileOutFileNull invalid src file success!");
                expect().assertFail();
            }).catch((err) => {
                console.log("compressFileOutFileNull zipFile fail: " + JSON.stringify(err));
                expect(err.code).assertEqual(OUTPUT_FILE_INVALID);

            })
            zlib.compressFile(path1, outFile, {
                level: zlib.CompressLevel.COMPRESS_LEVEL_NO_COMPRESSION
            }, (err, data) => {
                console.log("compressFile result");
                expect(err.code).assertEqual(OUTPUT_FILE_INVALID);
                done();
            })
            console.log("==================compressFileOutFileNull end==================");
        })


I
inter515 已提交
1325 1326 1327 1328
        /*
        * @tc.number: SUB_BMS_TOOL_ZLIB_0081
        * @tc.name: compressFileOutFileNull
        * @tc.desc: test compressFile when outFile is null
I
add xts  
inter515 已提交
1329
        */
I
inter515 已提交
1330
        it('compressFileOutFileNull', Level.LEVEL3, async function (done) {
I
inter515 已提交
1331 1332 1333 1334 1335 1336 1337 1338 1339
            console.log("==================compressFileOutFileNull start==================");
            let path1 = dir + "/compressFileOutFileNull.txt";
            let fd = fileio.openSync(path1, 0o100 | 0o2, 0o666);
            await fileio.write(fd, infos).then(function (number) {
                console.info("fileio write data to file successfully :" + number);
            }).catch(function (err) {
                console.info("fileio write data to file failed with error:" + err);
                expect(err).assertFail();
            });
I
inter515 已提交
1340
            try {
I
inter515 已提交
1341 1342 1343 1344 1345 1346 1347 1348 1349
                await zlib.compressFile(path1, null, {
                    level: zlib.CompressLevel.COMPRESS_LEVEL_NO_COMPRESSION
                }).then((data) => {
                    console.log("compressFileOutFileNull invalid src file success!");
                    expect().assertFail();
                }).catch((err) => {
                    console.log("compressFileOutFileNull zipFile fail: " + JSON.stringify(err));
                    expect().assertFail();
                })
I
inter515 已提交
1350
            } catch (err) {
I
inter515 已提交
1351 1352
                expect(err.code).assertEqual(PARAM_ERROR);
            }
I
inter515 已提交
1353
            try {
I
inter515 已提交
1354 1355 1356 1357 1358 1359 1360
                zlib.compressFile(path1, null, {
                    level: zlib.CompressLevel.COMPRESS_LEVEL_NO_COMPRESSION
                }, (err, data) => {
                    console.log("compressFile result");
                    expect().assertFail();
                    done();
                })
I
inter515 已提交
1361
            } catch (err) {
I
inter515 已提交
1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372
                expect(err.code).assertEqual(PARAM_ERROR);
                done();
            }
            console.log("==================compressFileOutFileNull end==================");
        })

        /*
        * @tc.number: SUB_BMS_TOOL_ZLIB_0082
        * @tc.name: compressFileOptionNull
        * @tc.desc: test compressFile when option is null
        */
I
inter515 已提交
1373
        it('compressFileOptionNull', Level.LEVEL3, async function (done) {
I
inter515 已提交
1374 1375 1376 1377 1378 1379 1380 1381 1382 1383
            console.log("==================compressFileOptionNull start==================");
            let path1 = dir + "/compressFileOptionNull.txt";
            let zipDest1 = dir + "/compressFileOptionNull.zip";
            let fd = fileio.openSync(path1, 0o100 | 0o2, 0o666);
            await fileio.write(fd, infos).then(function (number) {
                console.info("fileio write data to file successfully :" + number);
            }).catch(function (err) {
                console.info("fileio write data to file failed with error:" + err);
                expect(err).assertFail();
            });
I
inter515 已提交
1384
            try {
I
inter515 已提交
1385 1386 1387 1388 1389 1390 1391
                await zlib.compressFile(path1, zipDest1, null).then((data) => {
                    console.log("compressFileOptionNull invalid src file success!");
                    expect().assertFail();
                }).catch((err) => {
                    console.log("compressFileOptionNull zipFile fail: " + JSON.stringify(err));
                    expect().assertFail();
                })
I
inter515 已提交
1392
            } catch (err) {
I
inter515 已提交
1393 1394
                expect(err.code).assertEqual(PARAM_ERROR);
            }
I
inter515 已提交
1395
            try {
I
inter515 已提交
1396 1397 1398 1399 1400
                zlib.compressFile(path1, zipDest1, null, (err, data) => {
                    console.log("compressFile result");
                    expect().assertFail();
                    done();
                })
I
inter515 已提交
1401
            } catch (err) {
I
inter515 已提交
1402 1403 1404 1405 1406 1407
                expect(err.code).assertEqual(PARAM_ERROR);
                done();
            }
            console.log("==================compressFileOptionNull end==================");
        })

I
inter515 已提交
1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443
        /*
        * @tc.number: SUB_BMS_TOOL_ZLIB_0083
        * @tc.name: compressFileInvalidOption
        * @tc.desc: test compressFile when option is invalid
        */
        it('compressFileInvalidOption', Level.LEVEL3, async function (done) {
            console.log("==================compressFileInvalidOption start==================");
            let path1 = dir + "/compressFileInvalidOption.txt";
            let zipDest1 = dir + "/compressFileInvalidOption.zip";
            let fd = fileio.openSync(path1, 0o100 | 0o2, 0o666);
            await fileio.write(fd, infos).then(function (number) {
                console.info("fileio write data to file successfully :" + number);
            }).catch(function (err) {
                console.info("fileio write data to file failed with error:" + err);
                expect(err).assertFail();
            });
            await zlib.compressFile(path1, zipDest1, {
                memLevel: -1
            }).then((data) => {
                console.log("compressFileInvalidOption invalid src file success!");
                expect(data).assertNull();
            }).catch((err) => {
                console.log("compressFileInvalidOption zipFile fail: " + JSON.stringify(err));
                expect().assertFail();
            })
            zlib.compressFile(path1, zipDest1, {
                memLevel: -1
            }, (err, data) => {
                console.log("compressFile result");
                expect(data).assertUndefined();
                expect(err).assertNull();
                done();
            })
            console.log("==================compressFileInvalidOption end==================");
        })

I
inter515 已提交
1444 1445 1446 1447 1448
        /*
        * @tc.number: SUB_BMS_TOOL_ZLIB_0084
        * @tc.name: compressFileStrategyNull
        * @tc.desc: test compressFile when strategy is null
        */
I
inter515 已提交
1449
        it('compressFileStrategyNull', Level.LEVEL3, async function (done) {
I
inter515 已提交
1450 1451 1452 1453 1454 1455 1456 1457 1458 1459
            console.log("==================compressFileStrategyNull start==================");
            let path1 = dir + "/compressFileStrategyNull.txt";
            let zipDest1 = dir + "/compressFileStrategyNull.zip";
            let fd = fileio.openSync(path1, 0o100 | 0o2, 0o666);
            await fileio.write(fd, infos).then(function (number) {
                console.info("fileio write data to file successfully :" + number);
            }).catch(function (err) {
                console.info("fileio write data to file failed with error:" + err);
                expect(err).assertFail();
            });
I
inter515 已提交
1460
            try {
I
inter515 已提交
1461 1462 1463 1464 1465 1466 1467 1468 1469
                await zlib.compressFile(path1, zipDest1, {
                    strategy: null
                }).then((data) => {
                    console.log("compressFileStrategyNull invalid src file success!");
                    expect().assertFail();
                }).catch((err) => {
                    console.log("compressFileStrategyNull zipFile fail: " + JSON.stringify(err));
                    expect().assertFail();
                })
I
inter515 已提交
1470
            } catch (err) {
I
inter515 已提交
1471 1472
                expect(err.code).assertEqual(PARAM_ERROR);
            }
I
inter515 已提交
1473
            try {
I
inter515 已提交
1474 1475 1476 1477 1478 1479 1480
                zlib.compressFile(path1, zipDest1, {
                    strategy: null
                }, (err, data) => {
                    console.log("compressFile result");
                    expect().assertFail();
                    done();
                })
I
inter515 已提交
1481
            } catch (err) {
I
inter515 已提交
1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492
                expect(err.code).assertEqual(PARAM_ERROR);
                done();
            }
            console.log("==================compressFileOutFileNull end==================");
        })

        /*
        * @tc.number: SUB_BMS_TOOL_ZLIB_0087
        * @tc.name: decompressFileTest
        * @tc.desc: test decompressFile when inFile and out file is valid
        */
I
inter515 已提交
1493
        it('decompressFileTest', Level.LEVEL2, async function (done) {
I
inter515 已提交
1494 1495 1496 1497 1498 1499 1500 1501
            console.log("==================decompressFileTest start==================");
            let path = dir + "/decompressFileTest.txt";
            let zipDest1 = dir + "/decompressFileTest1.zip";
            let zipDest2 = dir + "/decompressFileTest2.zip";
            let unzipdir1 = dir + "/decompressFileTest1";
            let unzipdir2 = dir + "/decompressFileTest2";
            let finalFile1 = unzipdir1 + "/decompressFileTest.txt";
            let finalFile2 = unzipdir2 + "/decompressFileTest.txt";
I
add xts  
inter515 已提交
1502 1503
            let fd = fileio.openSync(path, 0o100 | 0o2, 0o666);
            await fileio.write(fd, infos).then(function (number) {
I
inter515 已提交
1504
                console.info("decompressFileTest write data to file success " + JSON.stringify(number));
I
add xts  
inter515 已提交
1505
            }).catch(function (err) {
I
inter515 已提交
1506
                console.info("decompressFileTest write data to file failed with error:" + err);
I
add xts  
inter515 已提交
1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539
                expect(err).assertFail();
            });
            await zlib.compressFile(path, zipDest1, {
                level: zlib.CompressLevel.COMPRESS_LEVEL_DEFAULT_COMPRESSION
            }).then(data => {
                console.info("compressFile success " + JSON.stringify(data));
                let zipStat = fileio.statSync(zipDest1);
                let isFile = zipStat.isFile();
                expect(isFile).assertTrue();
                let srcSize = fileio.statSync(path).size;
                let destSize = zipStat.size;
                expect(srcSize > destSize).assertTrue();
                expect(data).assertEqual(null);
            }).catch(err => {
                console.info("compressFile fail " + JSON.stringify(err));
                expect(err).assertFail();
            })
            await zlib.compressFile(path, zipDest2, {
                level: zlib.CompressLevel.COMPRESS_LEVEL_DEFAULT_COMPRESSION
            }).then(data => {
                console.info("compressFile success " + JSON.stringify(data));
                let zipStat = fileio.statSync(zipDest2);
                let isFile = zipStat.isFile();
                expect(isFile).assertTrue();
                let srcSize = fileio.statSync(path).size;
                let destSize = zipStat.size;
                expect(srcSize > destSize).assertTrue();
                expect(data).assertEqual(null);
            }).catch(err => {
                console.info("compressFile fail " + JSON.stringify(err));
                expect(err).assertFail();
            })
            await fileio.mkdir(unzipdir1).then(function () {
I
inter515 已提交
1540
                console.info("decompressFileTest mkdir successfully");
I
add xts  
inter515 已提交
1541
            }).catch(function (error) {
I
inter515 已提交
1542
                console.info("decompressFileTest mkdir failed with error:" + error);
I
add xts  
inter515 已提交
1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557
                expect(error).assertFail();
            });
            await zlib.decompressFile(zipDest1, unzipdir1, {
                level: zlib.CompressLevel.COMPRESS_LEVEL_DEFAULT_COMPRESSION
            }).then(data => {
                console.info("decompressFile success1 " + JSON.stringify(data));
                let zipStat = fileio.statSync(finalFile1);
                let isFile = zipStat.isFile();
                expect(isFile).assertTrue();
                expect(data).assertEqual(null);
            }).catch(err => {
                console.info("decompressFile fail1 " + JSON.stringify(err));
                expect(err).assertFail();
            })
            await fileio.mkdir(unzipdir2).then(function () {
I
inter515 已提交
1558
                console.info("decompressFileTest mkdir successfully");
I
add xts  
inter515 已提交
1559
            }).catch(function (error) {
I
inter515 已提交
1560
                console.info("decompressFileTest mkdir failed with error:" + error);
I
add xts  
inter515 已提交
1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575
                expect(error).assertFail();
            });
            zlib.decompressFile(zipDest2, unzipdir2, {
                level: zlib.CompressLevel.COMPRESS_LEVEL_DEFAULT_COMPRESSION
            }, (err, data) => {
                console.info("decompressFile success2 " + JSON.stringify(data));
                console.info("decompressFile success2 " + JSON.stringify(err));
                let zipStat = fileio.statSync(finalFile2);
                let isFile = zipStat.isFile();
                expect(isFile).assertTrue();
                expect(data).assertEqual(undefined);
                expect(err).assertEqual(null);
                done();
            })
        })
1576

I
add xts  
inter515 已提交
1577
        /*
I
inter515 已提交
1578 1579 1580
        * @tc.number: SUB_BMS_TOOL_ZLIB_0088
        * @tc.name: decompressFileInFileNotExist
        * @tc.desc: test decompressFile when inFile is not exist
I
add xts  
inter515 已提交
1581
        */
I
inter515 已提交
1582
        it('decompressFileInFileNotExist', Level.LEVEL3, async function (done) {
I
inter515 已提交
1583 1584 1585
            console.log("==================decompressFileInFileNotExist start==================");
            let zipDest = dir + "/noneexist.zip";
            let unzipdir = dir + "/decompressFileInFileNotExist";
I
add xts  
inter515 已提交
1586
            await fileio.mkdir(unzipdir).then(function () {
I
inter515 已提交
1587
                console.info("fileio mkdir successfully");
I
add xts  
inter515 已提交
1588
            }).catch(function (error) {
I
inter515 已提交
1589
                console.info("fileio mkdir failed with error:" + error);
I
add xts  
inter515 已提交
1590 1591 1592 1593 1594
                expect(error).assertFail();
            });
            await zlib.decompressFile(zipDest, unzipdir, {
                strategy: zlib.CompressStrategy.COMPRESS_STRATEGY_FIXED
            }).then(data => {
I
inter515 已提交
1595
                console.log("decompressFile data: " + data);
I
add xts  
inter515 已提交
1596 1597 1598 1599 1600 1601 1602
                expect(data).assertFail(null);
                done();
            }).catch(err => {
                console.log("decompress fail: " + JSON.stringify(err));
                expect(err.code).assertEqual(SRC_FILE_INVALID);
                done();
            })
I
inter515 已提交
1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617
            zlib.decompressFile(zipDest, unzipdir, {
                strategy: zlib.CompressStrategy.COMPRESS_STRATEGY_FIXED
            }, (err, data) => {
                expect(err.code).assertEqual(SRC_FILE_INVALID);
                expect(data).assertEqual(undefined);
                done();
            })
            console.log("==================decompressFileInFileNotExist end==================");
        })

        /*
        * @tc.number: SUB_BMS_TOOL_ZLIB_0089
        * @tc.name: decompressFileInFileNull
        * @tc.desc: test decompressFile when inFile is null
        */
I
inter515 已提交
1618
        it('decompressFileInFileNull', Level.LEVEL3, async function (done) {
I
inter515 已提交
1619 1620 1621 1622 1623 1624 1625 1626
            console.log("==================decompressFileInFileNull start==================");
            let unzipdir = dir + "/decompressFileInFileNull";
            await fileio.mkdir(unzipdir).then(function () {
                console.info("fileio mkdir successfully");
            }).catch(function (error) {
                console.info("fileio mkdir failed with error:" + error);
                expect(error).assertFail();
            });
I
inter515 已提交
1627
            try {
I
inter515 已提交
1628 1629 1630 1631 1632 1633 1634 1635 1636
                await zlib.decompressFile(null, unzipdir, {
                    strategy: zlib.CompressStrategy.COMPRESS_STRATEGY_FIXED
                }).then(data => {
                    console.log("decompressFile data: " + data);
                    expect().assertFail();
                }).catch(err => {
                    console.log("decompress fail: " + JSON.stringify(err));
                    expect().assertFail();
                })
I
inter515 已提交
1637
            } catch (err) {
I
inter515 已提交
1638 1639 1640
                console.log("decompress fail: " + JSON.stringify(err));
                expect(err.code).assertEqual(PARAM_ERROR);
            }
I
inter515 已提交
1641
            try {
I
inter515 已提交
1642 1643 1644 1645 1646 1647
                zlib.decompressFile(null, unzipdir, {
                    strategy: zlib.CompressStrategy.COMPRESS_STRATEGY_FIXED
                }, (err, data) => {
                    expect().assertFail();
                    done();
                })
I
inter515 已提交
1648
            } catch (err) {
I
inter515 已提交
1649 1650 1651 1652 1653 1654 1655
                console.log("decompress fail: " + JSON.stringify(err));
                expect(err.code).assertEqual(PARAM_ERROR);
                done();
            }
            console.log("==================decompressFileInFileNull end==================");
        })

I
inter515 已提交
1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705
        /*
        * @tc.number: SUB_BMS_TOOL_ZLIB_0090
        * @tc.name: decompressFileOutFileNotExist
        * @tc.desc: test decompressFile when outFile is not existed.
        */
        it('decompressFileOutFileNotExist', Level.LEVEL3, async function (done) {
            console.log("==================decompressFileOutFileNotExist start==================");
            let path = dir + "/decompressFileOutFileNotExist.txt";
            let zipDest1 = dir + "/decompressFileOutFileNotExist.zip";
            let outFile = "/111111/22222/test";
            let fd = fileio.openSync(path, 0o100 | 0o2, 0o666);
            await fileio.write(fd, infos).then(function (number) {
                console.info("decompressFileOutFileNotExist write data to file success " + JSON.stringify(number));
            }).catch(function (err) {
                console.info("decompressFileOutFileNotExist write data to file failed with error:" + err);
                expect(err).assertFail();
            });
            await zlib.compressFile(path, zipDest1, {
                level: zlib.CompressLevel.COMPRESS_LEVEL_DEFAULT_COMPRESSION
            }).then(data => {
                console.info("compressFile success " + JSON.stringify(data));
                let zipStat = fileio.statSync(zipDest1);
                let isFile = zipStat.isFile();
                expect(isFile).assertTrue();
                let srcSize = fileio.statSync(path).size;
                let destSize = zipStat.size;
                expect(srcSize > destSize).assertTrue();
                expect(data).assertEqual(null);
            }).catch(err => {
                console.info("compressFile fail " + JSON.stringify(err));
                expect(err).assertFail();
            })
            await zlib.decompressFile(zipDest1, outFile, {
                strategy: zlib.CompressStrategy.COMPRESS_STRATEGY_FIXED
            }).then(data => {
                console.log("decompressFile data: " + data);
                expect().assertFail();
            }).catch(err => {
                console.log("decompress fail: " + JSON.stringify(err));
                expect(err.code).assertEqual(OUTPUT_FILE_INVALID);
            })
            zlib.decompressFile(zipDest1, outFile, {
                strategy: zlib.CompressStrategy.COMPRESS_STRATEGY_FIXED
            }, (err, data) => {
                expect(err.code).assertEqual(OUTPUT_FILE_INVALID);
                done();
            })
            console.log("==================decompressFileOutFileNotExist end==================");
        })

I
inter515 已提交
1706 1707 1708 1709 1710
        /*
        * @tc.number: SUB_BMS_TOOL_ZLIB_0091
        * @tc.name: decompressFileOutFileNull
        * @tc.desc: test decompressFile when outFile is null
        */
I
inter515 已提交
1711
        it('decompressFileOutFileNull', Level.LEVEL3, async function (done) {
I
inter515 已提交
1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736
            console.log("==================decompressFileOutFileNull start==================");
            let path = dir + "/decompressFileOutFileNull.txt";
            let zipDest1 = dir + "/decompressFileOutFileNull.zip";
            let fd = fileio.openSync(path, 0o100 | 0o2, 0o666);
            await fileio.write(fd, infos).then(function (number) {
                console.info("decompressFileOutFileNull write data to file success " + JSON.stringify(number));
            }).catch(function (err) {
                console.info("decompressFileOutFileNull write data to file failed with error:" + err);
                expect(err).assertFail();
            });
            await zlib.compressFile(path, zipDest1, {
                level: zlib.CompressLevel.COMPRESS_LEVEL_DEFAULT_COMPRESSION
            }).then(data => {
                console.info("compressFile success " + JSON.stringify(data));
                let zipStat = fileio.statSync(zipDest1);
                let isFile = zipStat.isFile();
                expect(isFile).assertTrue();
                let srcSize = fileio.statSync(path).size;
                let destSize = zipStat.size;
                expect(srcSize > destSize).assertTrue();
                expect(data).assertEqual(null);
            }).catch(err => {
                console.info("compressFile fail " + JSON.stringify(err));
                expect(err).assertFail();
            })
I
inter515 已提交
1737
            try {
I
inter515 已提交
1738 1739 1740 1741 1742 1743 1744 1745 1746
                await zlib.decompressFile(zipDest1, null, {
                    strategy: zlib.CompressStrategy.COMPRESS_STRATEGY_FIXED
                }).then(data => {
                    console.log("decompressFile data: " + data);
                    expect().assertFail();
                }).catch(err => {
                    console.log("decompress fail: " + JSON.stringify(err));
                    expect().assertFail();
                })
I
inter515 已提交
1747
            } catch (err) {
I
inter515 已提交
1748 1749 1750
                console.log("decompress fail: " + JSON.stringify(err));
                expect(err.code).assertEqual(PARAM_ERROR);
            }
I
inter515 已提交
1751
            try {
I
inter515 已提交
1752 1753 1754 1755 1756 1757
                zlib.decompressFile(zipDest1, null, {
                    strategy: zlib.CompressStrategy.COMPRESS_STRATEGY_FIXED
                }, (err, data) => {
                    expect().assertFail();
                    done();
                })
I
inter515 已提交
1758
            } catch (err) {
I
inter515 已提交
1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770
                console.log("decompress fail: " + JSON.stringify(err));
                expect(err.code).assertEqual(PARAM_ERROR);
                done();
            }
            console.log("==================decompressFileOutFileNull end==================");
        })

        /*
        * @tc.number: SUB_BMS_TOOL_ZLIB_0092
        * @tc.name: decompressFileOptionNull
        * @tc.desc: test decompressFile when option is null
        */
I
inter515 已提交
1771
        it('decompressFileOptionNull', Level.LEVEL3, async function (done) {
I
inter515 已提交
1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803
            console.log("==================decompressFileOptionNull start==================");
            let path = dir + "/decompressFileOptionNull.txt";
            let zipDest1 = dir + "/decompressFileOptionNull.zip";
            let fd = fileio.openSync(path, 0o100 | 0o2, 0o666);
            await fileio.write(fd, infos).then(function (number) {
                console.info("SUB_BMS_TOOL_ZLIB_0087 write data to file success " + JSON.stringify(number));
            }).catch(function (err) {
                console.info("SUB_BMS_TOOL_ZLIB_0087 write data to file failed with error:" + err);
                expect(err).assertFail();
            });
            await zlib.compressFile(path, zipDest1, {
                level: zlib.CompressLevel.COMPRESS_LEVEL_DEFAULT_COMPRESSION
            }).then(data => {
                console.info("compressFile success " + JSON.stringify(data));
                let zipStat = fileio.statSync(zipDest1);
                let isFile = zipStat.isFile();
                expect(isFile).assertTrue();
                let srcSize = fileio.statSync(path).size;
                let destSize = zipStat.size;
                expect(srcSize > destSize).assertTrue();
                expect(data).assertEqual(null);
            }).catch(err => {
                console.info("compressFile fail " + JSON.stringify(err));
                expect(err).assertFail();
            })
            let unzipdir = dir + "/decompressFileOptionNull";
            await fileio.mkdir(unzipdir).then(function () {
                console.info("fileio mkdir successfully");
            }).catch(function (error) {
                console.info("fileio mkdir failed with error:" + error);
                expect(error).assertFail();
            });
I
inter515 已提交
1804
            try {
I
inter515 已提交
1805 1806 1807 1808 1809 1810 1811
                await zlib.decompressFile(zipDest1, unzipdir, null).then(data => {
                    console.log("decompressFile data: " + data);
                    expect().assertFail();
                }).catch(err => {
                    console.log("decompress fail: " + JSON.stringify(err));
                    expect().assertFail();
                })
I
inter515 已提交
1812
            } catch (err) {
I
inter515 已提交
1813 1814 1815
                console.log("decompress fail: " + JSON.stringify(err));
                expect(err.code).assertEqual(PARAM_ERROR);
            }
I
inter515 已提交
1816
            try {
I
inter515 已提交
1817 1818 1819 1820
                zlib.decompressFile(zipDest1, unzipdir, null, (err, data) => {
                    expect().assertFail();
                    done();
                })
I
inter515 已提交
1821
            } catch (err) {
I
inter515 已提交
1822 1823 1824 1825 1826
                console.log("decompress fail: " + JSON.stringify(err));
                expect(err.code).assertEqual(PARAM_ERROR);
                done();
            }
            console.log("==================decompressFileOutFileNull end==================");
1827 1828
        })

I
inter515 已提交
1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885
        /*
        * @tc.number: SUB_BMS_TOOL_ZLIB_0093
        * @tc.name: decompressFileInvalidOption
        * @tc.desc: test decompressFile when option is invalid
        */
        it('decompressFileInvalidOption', Level.LEVEL3, async function (done) {
            console.log("==================decompressFileInvalidOption start==================");
            let path = dir + "/decompressFileInvalidOption.txt";
            let zipDest1 = dir + "/decompressFileInvalidOption.zip";
            let fd = fileio.openSync(path, 0o100 | 0o2, 0o666);
            await fileio.write(fd, infos).then(function (number) {
                console.info("SUB_BMS_TOOL_ZLIB_0087 write data to file success " + JSON.stringify(number));
            }).catch(function (err) {
                console.info("SUB_BMS_TOOL_ZLIB_0087 write data to file failed with error:" + err);
                expect(err).assertFail();
            });
            await zlib.compressFile(path, zipDest1, {
                level: zlib.CompressLevel.COMPRESS_LEVEL_DEFAULT_COMPRESSION
            }).then(data => {
                console.info("compressFile success " + JSON.stringify(data));
                let zipStat = fileio.statSync(zipDest1);
                let isFile = zipStat.isFile();
                expect(isFile).assertTrue();
                let srcSize = fileio.statSync(path).size;
                let destSize = zipStat.size;
                expect(srcSize > destSize).assertTrue();
                expect(data).assertEqual(null);
            }).catch(err => {
                console.info("compressFile fail " + JSON.stringify(err));
                expect(err).assertFail();
            })
            let unzipdir = dir + "/decompressFileInvalidOption";
            await fileio.mkdir(unzipdir).then(function () {
                console.info("fileio mkdir successfully");
            }).catch(function (error) {
                console.info("fileio mkdir failed with error:" + error);
                expect(error).assertFail();
            });
            await zlib.decompressFile(zipDest1, unzipdir, {
                memLevel: -1
            }).then(data => {
                console.log("decompressFile data: " + data);
                expect(data).assertNull();
            }).catch(err => {
                console.log("decompress fail: " + JSON.stringify(err));
                expect().assertFail();
            })
            zlib.decompressFile(zipDest1, unzipdir, {
                memLevel: -1
            }, (err, data) => {
                expect(data).assertUndefined();
                expect(err).assertNull();
                done();
            })
            console.log("==================decompressFileOutFileNull end==================");
        })

I
inter515 已提交
1886 1887 1888 1889 1890
        /*
        * @tc.number: SUB_BMS_TOOL_ZLIB_0094
        * @tc.name: decompressFileStrategyNull
        * @tc.desc: test decompressFile when strategy is null
        */
I
inter515 已提交
1891
        it('decompressFileStrategyNull', Level.LEVEL3, async function (done) {
I
inter515 已提交
1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923
            console.log("==================decompressFileStrategyNull start==================");
            let path = dir + "/decompressFileStrategyNull.txt";
            let zipDest1 = dir + "/decompressFileStrategyNull.zip";
            let fd = fileio.openSync(path, 0o100 | 0o2, 0o666);
            await fileio.write(fd, infos).then(function (number) {
                console.info("decompressFileStrategyNull write data to file success " + JSON.stringify(number));
            }).catch(function (err) {
                console.info("decompressFileStrategyNull write data to file failed with error:" + err);
                expect(err).assertFail();
            });
            await zlib.compressFile(path, zipDest1, {
                level: zlib.CompressLevel.COMPRESS_LEVEL_DEFAULT_COMPRESSION
            }).then(data => {
                console.info("compressFile success " + JSON.stringify(data));
                let zipStat = fileio.statSync(zipDest1);
                let isFile = zipStat.isFile();
                expect(isFile).assertTrue();
                let srcSize = fileio.statSync(path).size;
                let destSize = zipStat.size;
                expect(srcSize > destSize).assertTrue();
                expect(data).assertEqual(null);
            }).catch(err => {
                console.info("compressFile fail " + JSON.stringify(err));
                expect(err).assertFail();
            })
            let unzipdir = dir + "/decompressFileStrategyNull";
            await fileio.mkdir(unzipdir).then(function () {
                console.info("fileio mkdir successfully");
            }).catch(function (error) {
                console.info("fileio mkdir failed with error:" + error);
                expect(error).assertFail();
            });
I
inter515 已提交
1924
            try {
I
inter515 已提交
1925 1926 1927 1928 1929 1930 1931 1932 1933
                await zlib.decompressFile(zipDest1, unzipdir, {
                    strategy: null
                }).then(data => {
                    console.log("decompressFile data: " + data);
                    expect().assertFail();
                }).catch(err => {
                    console.log("decompress fail: " + JSON.stringify(err));
                    expect().assertFail();
                })
I
inter515 已提交
1934
            } catch (err) {
I
inter515 已提交
1935 1936 1937
                console.log("decompress fail: " + JSON.stringify(err));
                expect(err.code).assertEqual(PARAM_ERROR);
            }
I
inter515 已提交
1938
            try {
I
inter515 已提交
1939 1940 1941 1942 1943 1944
                zlib.decompressFile(zipDest1, unzipdir, {
                    strategy: null
                }, (err, data) => {
                    expect().assertFail();
                    done();
                })
I
inter515 已提交
1945
            } catch (err) {
I
inter515 已提交
1946 1947 1948 1949 1950 1951
                console.log("decompress fail: " + JSON.stringify(err));
                expect(err.code).assertEqual(PARAM_ERROR);
                done();
            }
            console.log("==================decompressFileStrategyNull end==================");
        })
1952
    })
J
jiyong_sd 已提交
1953
}
K
kirl75 已提交
1954