actszipfileandunzipfiletest.test.js 44.3 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'
J
jiyong_sd 已提交
19 20
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'

R
renyi 已提交
21 22
var dir = "";
var infos = "";
J
jiyong_sd 已提交
23
export default function ActsZlibTest() {
K
kirl75 已提交
24
describe('ActsZlibTest', function () {
R
renyi 已提交
25 26 27 28 29 30 31
    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";
R
renyi 已提交
32
       var objectthree ="com.example.amsZipfileUnzipfileST.MainAbility/ActsZlibTest/example.amsZipfileUnzipfileST";
R
renyi 已提交
33 34 35 36
        infos =dir + objectone + objecttwo + objectthree;
        done();
      })
    });
K
kirl75 已提交
37

K
kirl75 已提交
38 39 40 41 42 43
/*
* @tc.number: ACTS_ZipFile_0100
* @tc.name: zipFile
* @tc.desc: inFile is empty
*/
it('ACTS_ZipFile_0100', 0, async function (done) {
R
renyi 已提交
44 45
    console.log("==================ACTS_ZipFile_0100 start==================");
    var path ="";
K
kirl75 已提交
46 47
    var zipDest = dir + "/ACTS_ZipFile_0100.zip"
    var options = {};
R
renyi 已提交
48
    options.level = zlib.CompressLevel.COMPRESS_LEVEL_NO_COMPRESSION;
R
renyi 已提交
49 50 51 52 53
    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) => {
L
longwei 已提交
54 55
      console.log("ACTS_ZipFile_0100 zipFile fail: " + err);
      expect(err).assertEqual(zlib.ErrorCode.ERROR_CODE_ERRNO);
R
renyi 已提交
56 57
      done();
    })
R
renyi 已提交
58
    console.log("==================ACTS_ZipFile_0100 end==================");
R
renyi 已提交
59
  })
K
kirl75 已提交
60 61 62 63 64 65 66

/*
* @tc.number: ACTS_ZipFile_0200
* @tc.name: zipFile
* @tc.desc: inFile doesn't exist
*/
it('ACTS_ZipFile_0200', 0, async function (done) {
R
renyi 已提交
67 68 69 70
    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);
K
kirl75 已提交
71
    fileio.write(fd, infos).then(function (number) {
R
renyi 已提交
72 73
      console.info("ACTS_ZipFile_0200 write data to file successfully:" + number);
      var options = {};
R
renyi 已提交
74
      options.level = zlib.CompressLevel.COMPRESS_LEVEL_DEFAULT_COMPRESSION;
R
renyi 已提交
75 76 77 78 79
      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) => {
L
longwei 已提交
80 81
        console.log("ACTS_ZipFile_0200 zipFile fail: " + err);
        expect(err).assertEqual(zlib.ErrorCode.ERROR_CODE_ERRNO);
R
renyi 已提交
82 83
        done();
      })
K
kirl75 已提交
84
    }).catch(function (err) {
R
renyi 已提交
85
      console.info("ACTS_ZipFile_0200 write data to file failed with error:" + err);
R
renyi 已提交
86
      expect(err).assertFail();
R
renyi 已提交
87
      done();
K
kirl75 已提交
88
    });
R
renyi 已提交
89
    console.log("==================ACTS_ZipFile_0200 end==================");
R
renyi 已提交
90
  })
K
kirl75 已提交
91 92 93 94 95 96 97

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

/*
* @tc.number: ACTS_ZipFile_0400
* @tc.name: zipFile
I
inter515 已提交
126
* @tc.desc: The output file is a directory that does not exist
K
kirl75 已提交
127 128
*/
it('ACTS_ZipFile_0400', 0, async function (done) {
R
renyi 已提交
129 130 131 132
    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);
K
kirl75 已提交
133
    fileio.write(fd, infos).then(function (number) {
R
renyi 已提交
134 135
      console.info("ACTS_ZipFile_0400 write data to file successfully:" + number);
      var options = {};
R
renyi 已提交
136
      options.level = zlib.CompressLevel.COMPRESS_LEVEL_DEFAULT_COMPRESSION;
R
renyi 已提交
137 138 139 140 141
      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) => {
L
longwei 已提交
142 143
        console.log("ACTS_ZipFile_0400 zipFile fail: " + err);
        expect(err).assertEqual(zlib.ErrorCode.ERROR_CODE_ERRNO);
R
renyi 已提交
144 145
        done();
      })
K
kirl75 已提交
146
    }).catch(function (err) {
R
renyi 已提交
147
      console.info("ACTS_ZipFile_0400 write data to file failed with error:" + err);
R
renyi 已提交
148
      expect(err).assertFail();
R
renyi 已提交
149
      done();
K
kirl75 已提交
150
    });
R
renyi 已提交
151
    console.log("==================ACTS_ZipFile_0400 end==================");
R
renyi 已提交
152
  })
K
kirl75 已提交
153 154

/*
R
add api  
r00559040 已提交
155
* @tc.number: ACTS_ZipFile_2200
K
kirl75 已提交
156
* @tc.name: zipFile
R
add api  
r00559040 已提交
157
* @tc.desc: COMPRESS_LEVEL_NO_COMPRESSION,
K
kirl75 已提交
158
*/
R
add api  
r00559040 已提交
159 160
it('ACTS_ZipFile_2200', 0, async function (done) {
    console.log("==================ACTS_ZipFile_2200 start==================");
R
renyi 已提交
161
    var path = dir + "/ACTS_ZipFile_2200.txt";
R
add api  
r00559040 已提交
162
    var zipDest = dir + "/ACTS_ZipFile_2200.zip"
R
renyi 已提交
163 164 165 166 167
    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);
K
kirl75 已提交
168
    fileio.write(fd, infos).then(function (number) {
R
renyi 已提交
169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192
      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);
R
renyi 已提交
193
            expect(err).assertFail();
R
renyi 已提交
194 195 196 197
            done();
          })
        }).catch(function (error) {
          console.info("ACTS_ZipFile_2200 mkdir failed with error:" + error);
R
renyi 已提交
198 199
          expect(error).assertFail();
          done();
R
renyi 已提交
200 201 202 203
        });
      }).catch((err) => {
          console.log("zipFile fail: " + err);
          expect(err).assertFail();
R
renyi 已提交
204
          done();
R
renyi 已提交
205
      })
K
kirl75 已提交
206
    }).catch(function (err) {
R
add api  
r00559040 已提交
207
        console.info("ACTS_ZipFile_2200 write data to file failed with error:" + err);
R
renyi 已提交
208 209
        expect(err).assertFail();
        done();
K
kirl75 已提交
210
    });
R
add api  
r00559040 已提交
211
    console.log("==================ACTS_ZipFile_2200 end==================");
R
renyi 已提交
212
  });
K
kirl75 已提交
213 214

/*
R
add api  
r00559040 已提交
215
* @tc.number: ACTS_ZipFile_2300
K
kirl75 已提交
216
* @tc.name: zipFile
R
add api  
r00559040 已提交
217
* @tc.desc: COMPRESS_LEVEL_BEST_SPEED,
K
kirl75 已提交
218
*/
R
add api  
r00559040 已提交
219 220
it('ACTS_ZipFile_2300', 0, async function (done) {
    console.log("==================ACTS_ZipFile_2300 start==================");
R
renyi 已提交
221
    var path = dir + "/ACTS_ZipFile_2300.txt";
R
add api  
r00559040 已提交
222
    var zipDest = dir + "/ACTS_ZipFile_2300.zip"
R
renyi 已提交
223 224 225 226 227
    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);
K
kirl75 已提交
228
    fileio.write(fd, infos).then(function (number) {
R
renyi 已提交
229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252
      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);
R
renyi 已提交
253
            expect(err).assertFail();
R
renyi 已提交
254 255 256 257
            done();
          })
        }).catch(function (error) {
          console.info("ACTS_ZipFile_2300 mkdir failed with error:" + error);
R
renyi 已提交
258 259
          expect(error).assertFail();
          done();
R
renyi 已提交
260 261 262 263
        });
      }).catch((err) => {
          console.log("zipFile fail: " + err);
          expect(err).assertFail();
R
renyi 已提交
264
          done();
R
renyi 已提交
265
      })
K
kirl75 已提交
266
    }).catch(function (err) {
267
        console.info("ACTS_ZipFile_2300 write data to file failed with error:" + err);
R
renyi 已提交
268 269
        expect(err).assertFail();
        done();
K
kirl75 已提交
270
    });
R
renyi 已提交
271 272
     console.log("==================ACTS_ZipFile_2300 end==================");
  })
K
kirl75 已提交
273 274

/*
R
add api  
r00559040 已提交
275
* @tc.number: ACTS_ZipFile_2400
K
kirl75 已提交
276
* @tc.name: zipFile
R
add api  
r00559040 已提交
277
* @tc.desc: COMPRESS_LEVEL_BEST_COMPRESSION,
K
kirl75 已提交
278
*/
R
add api  
r00559040 已提交
279 280
it('ACTS_ZipFile_2400', 0, async function (done) {
    console.log("==================ACTS_ZipFile_2400 start==================");
R
renyi 已提交
281
    var path = dir + "/ACTS_ZipFile_2400.txt";
R
add api  
r00559040 已提交
282
    var zipDest = dir + "/ACTS_ZipFile_2400.zip"
R
renyi 已提交
283 284 285 286 287
    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);
K
kirl75 已提交
288
    fileio.write(fd, infos).then(function (number) {
R
renyi 已提交
289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312
      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);
R
renyi 已提交
313
            expect(err).assertFail();
R
renyi 已提交
314 315 316 317
            done();
          })
        }).catch(function (error) {
          console.info("ACTS_ZipFile_2400 mkdir failed with error:" + error);
R
renyi 已提交
318 319
          expect(error).assertFail();
          done();
R
renyi 已提交
320 321 322 323
        });
      }).catch((err) => {
          console.log("zipFile fail: " + err);
          expect(err).assertFail();
R
renyi 已提交
324
          done();
R
renyi 已提交
325
      })
K
kirl75 已提交
326
    }).catch(function (err) {
R
add api  
r00559040 已提交
327
        console.info("ACTS_ZipFile_2400 write data to file failed with error:" + err);
R
renyi 已提交
328 329
        expect(err).assertFail();
        done();
K
kirl75 已提交
330
    });
R
add api  
r00559040 已提交
331
    console.log("==================ACTS_ZipFile_2400 end==================");
R
renyi 已提交
332
  });
K
kirl75 已提交
333 334

/*
R
add api  
r00559040 已提交
335
* @tc.number: ACTS_ZipFile_2500
K
kirl75 已提交
336
* @tc.name: zipFile
R
add api  
r00559040 已提交
337
* @tc.desc: COMPRESS_LEVEL_DEFAULT_COMPRESSION,
K
kirl75 已提交
338
*/
R
add api  
r00559040 已提交
339 340
it('ACTS_ZipFile_2500', 0, async function (done) {
    console.log("==================ACTS_ZipFile_2500 start==================");
R
renyi 已提交
341
    var path = dir + "/ACTS_ZipFile_2500.txt";
R
add api  
r00559040 已提交
342
    var zipDest = dir + "/ACTS_ZipFile_2500.zip"
R
renyi 已提交
343 344 345 346 347
    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);
K
kirl75 已提交
348
    fileio.write(fd, infos).then(function (number) {
R
renyi 已提交
349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372
      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);
R
renyi 已提交
373
            expect(err).assertFail();
R
renyi 已提交
374 375 376 377
            done()
          })
        }).catch(function (error) {
          console.info("ACTS_ZipFile_2500 mkdir failed with error:" + error);
R
renyi 已提交
378 379
          expect(error).assertFail();
          done();
R
renyi 已提交
380 381 382 383
        });
      }).catch((err) => {
          console.log("zipFile fail: " + err);
          expect(err).assertFail();
R
renyi 已提交
384
          done();
R
renyi 已提交
385
      })
K
kirl75 已提交
386
    }).catch(function (err) {
R
add api  
r00559040 已提交
387
        console.info("ACTS_ZipFile_2500 write data to file failed with error:" + err);
R
renyi 已提交
388 389
        expect(err).assertFail();
        done();
K
kirl75 已提交
390
    });
R
add api  
r00559040 已提交
391
    console.log("==================ACTS_ZipFile_2500 end==================");
R
renyi 已提交
392
  });
K
kirl75 已提交
393 394

/*
R
add api  
r00559040 已提交
395
* @tc.number: ACTS_ZipFile_2600
K
kirl75 已提交
396
* @tc.name: zipFile
R
add api  
r00559040 已提交
397
* @tc.desc: MEM_LEVEL_MIN_MEMLEVEL,,
K
kirl75 已提交
398
*/
R
add api  
r00559040 已提交
399 400
it('ACTS_ZipFile_2600', 0, async function (done) {
    console.log("==================ACTS_ZipFile_2600 start==================");
R
renyi 已提交
401
    var path = dir + "/ACTS_ZipFile_2600.txt";
R
add api  
r00559040 已提交
402
    var zipDest = dir + "/ACTS_ZipFile_2600.zip"
R
renyi 已提交
403 404 405 406 407
    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);
K
kirl75 已提交
408
    fileio.write(fd, infos).then(function (number) {
R
renyi 已提交
409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432
      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);
R
renyi 已提交
433
            expect(err).assertFail();
R
renyi 已提交
434 435 436 437
            done();
          })
        }).catch(function (error) {
          console.info("ACTS_ZipFile_2600 mkdir failed with error:" + error);
R
renyi 已提交
438 439
          expect(error).assertFail();
          done();
R
renyi 已提交
440 441 442 443
        });
      }).catch((err) => {
          console.log("zipFile fail: " + err);
          expect(err).assertFail();
R
renyi 已提交
444
          done();
R
renyi 已提交
445
      })
K
kirl75 已提交
446
    }).catch(function (err) {
R
add api  
r00559040 已提交
447
        console.info("ACTS_ZipFile_2600 write data to file failed with error:" + err);
R
renyi 已提交
448 449
        expect(err).assertFail();
        done();
K
kirl75 已提交
450
    });
R
add api  
r00559040 已提交
451
    console.log("==================ACTS_ZipFile_2600 end==================");
R
renyi 已提交
452
  });
K
kirl75 已提交
453 454

/*
R
add api  
r00559040 已提交
455
* @tc.number: ACTS_ZipFile_2700
K
kirl75 已提交
456
* @tc.name: zipFile
R
add api  
r00559040 已提交
457
* @tc.desc: MEM_LEVEL_MAX_MEMLEVEL,,
K
kirl75 已提交
458
*/
R
add api  
r00559040 已提交
459 460
it('ACTS_ZipFile_2700', 0, async function (done) {
    console.log("==================ACTS_ZipFile_2700 start==================");
R
renyi 已提交
461
    var path = dir + "/ACTS_ZipFile_2700.txt";
R
add api  
r00559040 已提交
462
    var zipDest = dir + "/ACTS_ZipFile_2700.zip"
R
renyi 已提交
463 464 465 466 467
    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);
K
kirl75 已提交
468
    fileio.write(fd, infos).then(function (number) {
R
renyi 已提交
469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492
      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);
R
renyi 已提交
493
            expect(err).assertFail();
R
renyi 已提交
494 495 496 497
            done();
          })
        }).catch(function (error) {
          console.info("ACTS_ZipFile_2700 mkdir failed with error:" + error);
R
renyi 已提交
498 499
          expect(error).assertFail();
          done();
R
renyi 已提交
500 501 502 503
        });
      }).catch((err) => {
          console.log("zipFile fail: " + err);
         expect(err).assertFail();
R
renyi 已提交
504
         done();
R
renyi 已提交
505
      })
K
kirl75 已提交
506
    }).catch(function (err) {
R
add api  
r00559040 已提交
507
        console.info("ACTS_ZipFile_2700 write data to file failed with error:" + err);
R
renyi 已提交
508 509
        expect(err).assertFail();
        done();
K
kirl75 已提交
510
    });
R
add api  
r00559040 已提交
511
    console.log("==================ACTS_ZipFile_2700 end==================");
R
renyi 已提交
512
  });
K
kirl75 已提交
513 514

/*
R
add api  
r00559040 已提交
515
* @tc.number: ACTS_ZipFile_2800
K
kirl75 已提交
516
* @tc.name: zipFile
R
add api  
r00559040 已提交
517
* @tc.desc: MEM_LEVEL_DEFAULT_MEMLEVEL,,
K
kirl75 已提交
518
*/
R
add api  
r00559040 已提交
519 520
it('ACTS_ZipFile_2800', 0, async function (done) {
    console.log("==================ACTS_ZipFile_2800 start==================");
R
renyi 已提交
521
    var path = dir + "/ACTS_ZipFile_2800.txt";
R
add api  
r00559040 已提交
522
    var zipDest = dir + "/ACTS_ZipFile_2800.zip"
R
renyi 已提交
523 524 525 526 527
    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);
K
kirl75 已提交
528
    fileio.write(fd, infos).then(function (number) {
R
renyi 已提交
529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552
      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);
R
renyi 已提交
553
            expect(err).assertFail();
R
renyi 已提交
554 555 556 557
            done();
          })
        }).catch(function (error) {
          console.info("ACTS_ZipFile_2800 mkdir failed with error:" + error);
R
renyi 已提交
558 559
          expect(error).assertFail();
          done();
R
renyi 已提交
560 561 562 563
        });
      }).catch((err) => {
          console.log("zipFile fail: " + err);
          expect(err).assertFail();
R
renyi 已提交
564
          done();
R
renyi 已提交
565
      })
K
kirl75 已提交
566
    }).catch(function (err) {
R
add api  
r00559040 已提交
567
        console.info("ACTS_ZipFile_2800 write data to file failed with error:" + err);
R
renyi 已提交
568 569
        expect(err).assertFail();
        done();
K
kirl75 已提交
570
    });
R
add api  
r00559040 已提交
571
    console.log("==================ACTS_ZipFile_2800 end==================");
R
renyi 已提交
572
  });
K
kirl75 已提交
573 574

/*
R
add api  
r00559040 已提交
575
* @tc.number: ACTS_ZipFile_2900
K
kirl75 已提交
576
* @tc.name: zipFile
R
add api  
r00559040 已提交
577
* @tc.desc: COMPRESS_STRATEGY_DEFAULT_STRATEGY,,
K
kirl75 已提交
578
*/
R
add api  
r00559040 已提交
579 580
it('ACTS_ZipFile_2900', 0, async function (done) {
    console.log("==================ACTS_ZipFile_2900 start==================");
R
renyi 已提交
581
    var path = dir + "/ACTS_ZipFile_2900.txt";
R
add api  
r00559040 已提交
582
    var zipDest = dir + "/ACTS_ZipFile_2900.zip"
R
renyi 已提交
583 584 585 586 587
    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);
K
kirl75 已提交
588
    fileio.write(fd, infos).then(function (number) {
R
renyi 已提交
589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612
      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);
R
renyi 已提交
613
              expect(err).assertFail();
R
renyi 已提交
614 615 616 617
              done();
            })
          }).catch(function (error) {
            console.info("ACTS_ZipFile_2900 mkdir failed with error:" + error);
R
renyi 已提交
618 619
            expect(error).assertFail();
            done();
R
renyi 已提交
620 621 622 623
          });
      }).catch((err) => {
          console.log("zipFile fail: " + err);
          expect(err).assertFail();
R
renyi 已提交
624
          done();
R
renyi 已提交
625
      })
K
kirl75 已提交
626
    }).catch(function (err) {
R
add api  
r00559040 已提交
627
        console.info("ACTS_ZipFile_2900 write data to file failed with error:" + err);
R
renyi 已提交
628 629
        expect(err).assertFail();
        done();
K
kirl75 已提交
630
    });
R
add api  
r00559040 已提交
631
    console.log("==================ACTS_ZipFile_2900 end==================");
R
renyi 已提交
632
  });
K
kirl75 已提交
633 634

/*
R
add api  
r00559040 已提交
635
* @tc.number: ACTS_ZipFile_3000
K
kirl75 已提交
636
* @tc.name: zipFile
R
add api  
r00559040 已提交
637
* @tc.desc: COMPRESS_STRATEGY_FILTERED,,
K
kirl75 已提交
638
*/
R
add api  
r00559040 已提交
639 640
it('ACTS_ZipFile_3000', 0, async function (done) {
    console.log("==================ACTS_ZipFile_3000 start==================");
R
renyi 已提交
641
    var path = dir + "/ACTS_ZipFile_3000.txt";
R
add api  
r00559040 已提交
642
    var zipDest = dir + "/ACTS_ZipFile_3000.zip"
R
renyi 已提交
643 644 645 646 647
    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);
K
kirl75 已提交
648
    fileio.write(fd, infos).then(function (number) {
R
renyi 已提交
649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672
      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);
R
renyi 已提交
673
            expect(err).assertFail();
R
renyi 已提交
674 675 676 677
            done();
          })
        }).catch(function (error) {
          console.info("ACTS_ZipFile_3000 mkdir failed with error:" + error);
R
renyi 已提交
678 679
          expect(error).assertFail();
          done();
R
renyi 已提交
680 681 682 683
        });
      }).catch((err) => {
          console.log("zipFile fail: " + err);
          expect(err).assertFail();
R
renyi 已提交
684
          done();
R
renyi 已提交
685
      })
K
kirl75 已提交
686
    }).catch(function (err) {
R
add api  
r00559040 已提交
687
        console.info("ACTS_ZipFile_3000 write data to file failed with error:" + err);
R
renyi 已提交
688 689
        expect(err).assertFail();
        done();
K
kirl75 已提交
690
    });
R
add api  
r00559040 已提交
691
    console.log("==================ACTS_ZipFile_3000 end==================");
R
renyi 已提交
692
  });
K
kirl75 已提交
693 694

/*
R
add api  
r00559040 已提交
695
* @tc.number: ACTS_ZipFile_3100
K
kirl75 已提交
696
* @tc.name: zipFile
R
add api  
r00559040 已提交
697
* @tc.desc: COMPRESS_STRATEGY_HUFFMAN_ONLY,,
K
kirl75 已提交
698
*/
R
add api  
r00559040 已提交
699 700
it('ACTS_ZipFile_3100', 0, async function (done) {
    console.log("==================ACTS_ZipFile_3100 start==================");
R
renyi 已提交
701
    var path = dir + "/ACTS_ZipFile_3100.txt";
R
add api  
r00559040 已提交
702
    var zipDest = dir + "/ACTS_ZipFile_3100.zip"
R
renyi 已提交
703 704 705 706 707
    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);
K
kirl75 已提交
708
    fileio.write(fd, infos).then(function (number) {
R
renyi 已提交
709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732
      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);
R
renyi 已提交
733
            expect(err).assertFail();
R
renyi 已提交
734 735 736 737
            done();
          })
        }).catch(function (error) {
          console.info("ACTS_ZipFile_3100 mkdir failed with error:" + error);
R
renyi 已提交
738 739
          expect(error).assertFail();
          done();
R
renyi 已提交
740 741 742 743
        });
      }).catch((err) => {
          console.log("zipFile fail: " + err);
          expect(err).assertFail();
R
renyi 已提交
744
          done();
R
renyi 已提交
745
      })
K
kirl75 已提交
746
    }).catch(function (err) {
R
add api  
r00559040 已提交
747
        console.info("ACTS_ZipFile_3100 write data to file failed with error:" + err);
R
renyi 已提交
748 749
        expect(err).assertFail();
        done();
K
kirl75 已提交
750
    });
R
add api  
r00559040 已提交
751
    console.log("==================ACTS_ZipFile_3100 end==================");
R
renyi 已提交
752
  });
K
kirl75 已提交
753 754

/*
R
add api  
r00559040 已提交
755
* @tc.number: ACTS_ZipFile_3200
K
kirl75 已提交
756
* @tc.name: zipFile
R
add api  
r00559040 已提交
757
* @tc.desc: COMPRESS_STRATEGY_RLE,,
K
kirl75 已提交
758
*/
R
add api  
r00559040 已提交
759 760
it('ACTS_ZipFile_3200', 0, async function (done) {
    console.log("==================ACTS_ZipFile_3200 start==================");
R
renyi 已提交
761 762 763 764 765 766 767
    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);
K
kirl75 已提交
768
    fileio.write(fd, infos).then(function (number) {
R
renyi 已提交
769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792
      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();
R
renyi 已提交
793 794
            expect(err).assertFail();
            done();
R
renyi 已提交
795 796 797
          })
        }).catch(function (error) {
          console.info("ACTS_ZipFile_3200 mkdir failed with error:" + error);
R
renyi 已提交
798 799
          expect(error).assertFail();
          done();
R
renyi 已提交
800 801 802 803
        });
      }).catch((err) => {
          console.log("zipFile fail: " + err);
          expect(err).assertFail();
R
renyi 已提交
804
          done();
R
renyi 已提交
805
      })
K
kirl75 已提交
806
    }).catch(function (err) {
R
add api  
r00559040 已提交
807
        console.info("ACTS_ZipFile_3200 write data to file failed with error:" + err);
R
renyi 已提交
808 809
        expect(err).assertFail();
        done();
K
kirl75 已提交
810
    });
R
add api  
r00559040 已提交
811
    console.log("==================ACTS_ZipFile_3200 end==================");
R
renyi 已提交
812
  });
K
kirl75 已提交
813 814

/*
R
add api  
r00559040 已提交
815
* @tc.number: ACTS_ZipFile_3300
K
kirl75 已提交
816
* @tc.name: zipFile
817
* @tc.desc: COMPRESS_STRATEGY_FIXED,,
K
kirl75 已提交
818
*/
R
add api  
r00559040 已提交
819 820
it('ACTS_ZipFile_3300', 0, async function (done) {
    console.log("==================ACTS_ZipFile_3300 start==================");
R
renyi 已提交
821
    var path = dir + "/ACTS_ZipFile_3300.txt";
R
add api  
r00559040 已提交
822
    var zipDest = dir + "/ACTS_ZipFile_3300.zip"
R
renyi 已提交
823 824 825
    var unzipdir = dir + "/ACTS_ZipFile_3300";
    var unzipresultfile = unzipdir + "/ACTS_ZipFile_3300.txt";
    var options = {};
826
    options.strategy = zlib.CompressStrategy.COMPRESS_STRATEGY_FIXED;
R
renyi 已提交
827
    var fd = fileio.openSync(path, 0o100 | 0o2, 0o666);
K
kirl75 已提交
828
    fileio.write(fd, infos).then(function (number) {
R
renyi 已提交
829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852
      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);
R
renyi 已提交
853
            expect(err).assertFail();
R
renyi 已提交
854 855 856 857
            done();
          })
        }).catch(function (error) {
          console.info("ACTS_ZipFile_3300 mkdir failed with error:" + error);
R
renyi 已提交
858 859
          expect(error).assertFail();
          done();
R
renyi 已提交
860 861 862 863
        });
      }).catch((err) => {
          console.log("zipFile fail: " + err);
          expect(err).assertFail();
R
renyi 已提交
864
          done();
R
renyi 已提交
865
      })
K
kirl75 已提交
866
    }).catch(function (err) {
R
add api  
r00559040 已提交
867
        console.info("ACTS_ZipFile_3300 write data to file failed with error:" + err);
R
renyi 已提交
868 869
        expect(err).assertFail();
        done();
K
kirl75 已提交
870
    });
R
add api  
r00559040 已提交
871
    console.log("==================ACTS_ZipFile_3300 end==================");
R
renyi 已提交
872
  });
K
kirl75 已提交
873 874

/*
R
add api  
r00559040 已提交
875
* @tc.number: ACTS_ZipFile_3500
K
kirl75 已提交
876
* @tc.name: zipFile
877
* @tc.desc: INPUT_FILE_NOT_EXIST,,
K
kirl75 已提交
878
*/
R
add api  
r00559040 已提交
879 880
it('ACTS_ZipFile_3500', 0, async function (done) {
    console.log("==================ACTS_ZipFile_3500 start==================");
R
renyi 已提交
881 882 883
    var path = dir + "/ACTS_ZipFile_3500.txt";
    var src = dir + "/ACTS_ZipFile_9900.txt";
    var unzipdir = dir + "/ACTS_ZipFile_3500";
R
add api  
r00559040 已提交
884
    var options = {};
R
renyi 已提交
885 886 887 888 889
    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) => {
R
renyi 已提交
890
        console.log("ACTS_ZipFile_3500 data: " + data);
R
add api  
r00559040 已提交
891 892
        expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_ERRNO);
        done();
R
renyi 已提交
893
      }).catch((err) => {
R
renyi 已提交
894
        console.log("ACTS_ZipFile_3500 err: " + err);
L
longwei 已提交
895
        expect(err).assertEqual(zlib.ErrorCode.ERROR_CODE_ERRNO);
K
kirl75 已提交
896
        done();
R
renyi 已提交
897 898 899
      });
    }).catch(function (err) {
      console.info("ACTS_ZipFile_3500 write data to file failed with error:" + err);
R
renyi 已提交
900 901
      expect(err).assertFail();
      done();
K
kirl75 已提交
902
    });
R
renyi 已提交
903
    console.log("==================ACTS_ZipFile_3500 end ==================");
R
renyi 已提交
904
  })
K
kirl75 已提交
905 906

/*
R
add api  
r00559040 已提交
907
* @tc.number: ACTS_ZipFile_3600
K
kirl75 已提交
908
* @tc.name: zipFile
909
* @tc.desc: INPUT_FILE_NULL,,
K
kirl75 已提交
910
*/
R
add api  
r00559040 已提交
911 912
it('ACTS_ZipFile_3600', 0, async function (done) {
    console.log("==================ACTS_ZipFile_3600 start==================");
R
renyi 已提交
913
    var path = dir + "/ACTS_ZipFile_3600.txt";
R
add api  
r00559040 已提交
914
    var zipDest = "";
K
kirl75 已提交
915
    var options = {};
R
renyi 已提交
916 917 918 919 920
    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) => {
R
renyi 已提交
921
        console.log("ACTS_ZipFile_3600 data: " + data);
R
add api  
r00559040 已提交
922 923
        expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_ERRNO);
        done();
R
renyi 已提交
924
      }).catch((err) => {
R
renyi 已提交
925
        console.log("ACTS_ZipFile_3600 err: " + err);
L
longwei 已提交
926
        expect(err).assertEqual(zlib.ErrorCode.ERROR_CODE_ERRNO);
R
add api  
r00559040 已提交
927
        done();
R
renyi 已提交
928 929 930
      });
    }).catch(function (err) {
      console.info("ACTS_ZipFile_3600 write data to file failed with error:" + err);
R
renyi 已提交
931 932
      expect(err).assertFail();
      done();
R
add api  
r00559040 已提交
933
    });
R
renyi 已提交
934
    console.log("==================ACTS_ZipFile_3600 end ==================")
R
renyi 已提交
935
  })
K
kirl75 已提交
936 937 938 939

/*
* @tc.number: ACTS_ZipFile_4500
* @tc.name: zipFile
940
* @tc.desc: COMPRESS_STRATEGY_FILTERED_CALLBACK,,
K
kirl75 已提交
941 942
*/
it('ACTS_ZipFile_4500', 0, async function (done) {
R
renyi 已提交
943 944
    console.log("==================ACTS_ZipFile_4500 start==================");
    var path = dir + "/ACTS_ZipFile_4500.txt";
K
kirl75 已提交
945 946
    var zipDest = dir + "/ACTS_ZipFile_4500.zip"
    var unzipDest = dir + "/ACTS_ZipFile_9900.zip"
R
renyi 已提交
947 948
    var unzipdir = dir + "/ACTS_ZipFile_4500";
    var zipdir = dir + "/ACTS_ZipFile_9900";
K
kirl75 已提交
949
    var options = {};
K
kirl75 已提交
950
    options.strategy = zlib.CompressStrategy.COMPRESS_STRATEGY_FILTERED;
R
renyi 已提交
951 952 953 954 955 956 957 958 959 960 961 962 963
    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");
K
kirl75 已提交
964
            zlib.unzipFile(unzipDest, zipdir, options).then((data) => {
R
renyi 已提交
965 966 967
              console.log("ACTS_ZipFile_4500 data: " + data);
              expect(data).assertEqual(zlib.ErrorCode.ERROR_CODE_ERRNO);
              done();
K
kirl75 已提交
968
            }).catch((err) => {
R
renyi 已提交
969
              console.log("ACTS_ZipFile_4500 err: " + err);
X
xinxin13 已提交
970
              expect(err.code).assertEqual(zlib.ErrorCode.ERROR_CODE_ERRNO);
R
renyi 已提交
971
              done();
K
kirl75 已提交
972
            })
R
renyi 已提交
973 974
          }).catch(function (error) {
            console.info("ACTS_ZipFile_4500 mkdir failed with error:" + error);
R
renyi 已提交
975 976
            expect(error).assertFail();
            done();
R
renyi 已提交
977 978
          });
      }).catch((err) => {
979
         console.log("ACTS_ZipFile_4500 zipFile fail: " + err);
L
longwei 已提交
980
         expect(err).assertEqual(zlib.ErrorCode.ERROR_CODE_ERRNO);
R
renyi 已提交
981
         done();
R
renyi 已提交
982 983 984
      })
    }).catch(function (err) {
        console.info("ACTS_ZipFile_4500 write data to file failed with error:" + err);
R
renyi 已提交
985 986
        expect(err).assertFail();
        done();
R
renyi 已提交
987
    });
R
renyi 已提交
988
    console.log("==================ACTS_ZipFile_4500 end==================");
R
renyi 已提交
989
  })
K
kirl75 已提交
990 991

/*
R
add api  
r00559040 已提交
992
* @tc.number: ACTS_ZipFile_4900
K
kirl75 已提交
993
* @tc.name: zipFile
994
* @tc.desc: COMPRESS_STRATEGY_FILTERED_PROMISE,
K
kirl75 已提交
995
*/
R
add api  
r00559040 已提交
996 997
it('ACTS_ZipFile_4900', 0, async function (done) {
    console.log("==================ACTS_ZipFile_4900 start==================");
R
renyi 已提交
998
    var path = dir + "/ACTS_ZipFile_4900.txt";
R
add api  
r00559040 已提交
999 1000
    var zipDest = dir + "/ACTS_ZipFile_4900.zip"
    var unzipDest = dir + "/ACTS_ZipFile_4900.zip"
R
renyi 已提交
1001 1002
    var unzipdir = dir + "/ACTS_ZipFile_4900";
    var zipdir = dir + "/ACTS_ZipFile_4900";
K
kirl75 已提交
1003
    var options = {};
R
add api  
r00559040 已提交
1004
    options.strategy = zlib.CompressStrategy.COMPRESS_STRATEGY_FILTERED;
R
renyi 已提交
1005 1006 1007 1008
    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 => {
R
add api  
r00559040 已提交
1009 1010 1011 1012 1013 1014 1015
        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);
R
renyi 已提交
1016 1017 1018 1019 1020 1021 1022
        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 => {
1023
            console.log("ACTS_ZipFile_4900 err: " + err);
R
renyi 已提交
1024 1025 1026 1027 1028
            expect(err).assertFail();
            done();
          })
        }).catch(function (error) {
          console.info("ACTS_ZipFile_4900 mkdir failed with error:" + error);
R
renyi 已提交
1029 1030
          expect(error).assertFail();
          done();
R
renyi 已提交
1031 1032
        });
      }).catch(err => {
1033
        console.log("ACTS_ZipFile_4900 zipFile fail: " + err);
R
add api  
r00559040 已提交
1034
        expect(err).assertFail();
R
renyi 已提交
1035
        done();
R
renyi 已提交
1036 1037 1038
      })
    }).catch(function (err) {
      console.info("ACTS_ZipFile_4900 write data to file failed with error:" + err);
R
renyi 已提交
1039 1040
      expect(err).assertFail();
      done();
R
add api  
r00559040 已提交
1041
    });
R
renyi 已提交
1042
    console.log("==================ACTS_ZipFile_4900 end==================");
R
renyi 已提交
1043
})
R
add api  
r00559040 已提交
1044
    
K
kirl75 已提交
1045
/*
R
add api  
r00559040 已提交
1046
* @tc.number: ACTS_ZipFile_5000
K
kirl75 已提交
1047
* @tc.name: zipFile
R
add api  
r00559040 已提交
1048
* @tc.desc: COMPRESS_STRATEGY_FIXED,
K
kirl75 已提交
1049
*/
R
add api  
r00559040 已提交
1050 1051
it('ACTS_ZipFile_5000', 0, async function (done) {
    console.log("==================ACTS_ZipFile_5000 start==================");
R
renyi 已提交
1052
    var path = dir + "/ACTS_ZipFile_5000.txt";
R
add api  
r00559040 已提交
1053
    var zipDest = dir + "/ACTS_ZipFile_5000.zip"
R
renyi 已提交
1054
    var unzipdir = dir + "/ACTS_ZipFile_5000";
K
kirl75 已提交
1055
    var options = {};
R
add api  
r00559040 已提交
1056
    options.strategy = zlib.CompressStrategy.COMPRESS_STRATEGY_FIXED;
R
renyi 已提交
1057 1058 1059 1060
    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 => {
R
add api  
r00559040 已提交
1061 1062 1063 1064 1065 1066 1067
        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);
R
renyi 已提交
1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080
        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);
R
renyi 已提交
1081 1082
          expect(error).assertFail();
          done();
R
renyi 已提交
1083 1084
        });
      }).catch(err => {
R
add api  
r00559040 已提交
1085 1086
        console.log("zipFile fail: " + err);
        expect(err).assertFail();
R
renyi 已提交
1087
        done();
R
renyi 已提交
1088 1089 1090
      })
    }).catch(function (err) {
      console.info("ACTS_ZipFile_5000 write data to file failed with error:" + err);
R
renyi 已提交
1091 1092
      expect(err).assertFail();
      done();
R
add api  
r00559040 已提交
1093
    });
R
renyi 已提交
1094
    console.log("==================ACTS_ZipFile_5000 end==================");
K
kirl75 已提交
1095 1096
    })
})
J
jiyong_sd 已提交
1097
}
K
kirl75 已提交
1098