Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
7d9ad525
X
Xts Acts
项目概览
OpenHarmony
/
Xts Acts
大约 1 年 前同步成功
通知
9
Star
22
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
X
Xts Acts
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
7d9ad525
编写于
3月 19, 2022
作者:
O
openharmony_ci
提交者:
Gitee
3月 19, 2022
浏览文件
操作
浏览文件
下载
差异文件
!2642 api补齐,增加memset_s校验
Merge pull request !2642 from ry/master
上级
7bb301fe
a28e4221
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
434 addition
and
1761 deletion
+434
-1761
appexecfwk/bundle_standard/bundlemanager/actsbundlemanagertest/entry/src/main/js/test/ExampleJsunit.test.js
...emanagertest/entry/src/main/js/test/ExampleJsunit.test.js
+10
-9
appexecfwk/zlib/actszipfileandunzipfiletest/entry/src/main/js/test/actszipfileandunzipfiletest.test.js
...ntry/src/main/js/test/actszipfileandunzipfiletest.test.js
+385
-1731
appexecfwk_lite/appexecfwk_hal/src/bundle_mgr_test.c
appexecfwk_lite/appexecfwk_hal/src/bundle_mgr_test.c
+17
-10
appexecfwk_lite/appexecfwk_posix/src/BundleMgrTest.cpp
appexecfwk_lite/appexecfwk_posix/src/BundleMgrTest.cpp
+22
-11
未找到文件。
appexecfwk/bundle_standard/bundlemanager/actsbundlemanagertest/entry/src/main/js/test/ExampleJsunit.test.js
浏览文件 @
7d9ad525
...
...
@@ -2126,14 +2126,13 @@ describe('ActsBundleManagerTest', function () {
expect
(
err
.
code
).
assertEqual
(
0
);
expect
(
data
.
status
).
assertEqual
(
demo
.
InstallErrorCode
.
SUCCESS
);
expect
(
data
.
statusMessage
).
assertEqual
(
'
SUCCESS
'
);
getInfo
();
});
async
function
getInfo
()
{
demo
.
queryAbilityByWant
(
await
demo
.
queryAbilityByWant
(
{
"
bundleName
"
:
"
com.example.myapplication1
"
,
"
abilityName
"
:
"
com.example.myapplication1.MainAbility
"
,
},
demo
.
BundleFlag
.
GET_ABILITY_INFO_WITH_APPLICATION
|
demo
.
BundleFlag
.
GET_ABILITY_INFO_WITH_PERMISSION
,
},
demo
.
BundleFlag
.
GET_ABILITY_INFO_WITH_APPLICATION
|
demo
.
BundleFlag
.
GET_ABILITY_INFO_WITH_PERMISSION
|
demo
.
BundleFlag
.
GET_ABILITY_INFO_WITH_METADATA
,
100
).
then
(
data
=>
{
expect
(
data
.
length
).
assertLarger
(
0
);
for
(
let
i
=
0
,
len
=
data
.
length
;
i
<
len
;
i
++
)
{
...
...
@@ -2144,9 +2143,9 @@ describe('ActsBundleManagerTest', function () {
expect
(
datainfo
.
icon
).
assertEqual
(
"
$media:icon
"
)
expect
(
datainfo
.
moduleName
).
assertEqual
(
"
entry
"
)
expect
(
datainfo
.
bundleName
).
assertEqual
(
NAME1
)
expect
(
datainfo
.
type
).
assertEqual
(
1
)
expect
(
datainfo
.
type
).
assertEqual
(
demo
.
AbilityType
.
PAGE
)
expect
(
datainfo
.
subType
).
assertEqual
(
demo
.
AbilitySubType
.
UNSPECIFIED
)
expect
(
datainfo
.
orientation
).
assertEqual
(
0
)
expect
(
datainfo
.
orientation
).
assertEqual
(
demo
.
DisplayOrientation
.
UNSPECIFIED
)
expect
(
datainfo
.
launchMode
).
assertEqual
(
demo
.
LaunchMode
.
STANDARD
)
expect
(
datainfo
.
permissions
[
0
]).
assertEqual
(
"
com.permission.BMS_PERMISSION_CAMERA
"
)
expect
(
datainfo
.
applicationInfo
.
name
).
assertEqual
(
NAME1
)
...
...
@@ -2159,12 +2158,14 @@ describe('ActsBundleManagerTest', function () {
expect
(
datainfo
.
applicationInfo
.
systemApp
).
assertEqual
(
true
)
expect
(
datainfo
.
applicationInfo
.
supportedModes
).
assertEqual
(
0
)
expect
(
datainfo
.
applicationInfo
.
enabled
).
assertEqual
(
true
)
expect
(
datainfo
.
metaData
.
customizeDatas
.
length
).
assertLarger
(
0
)
expect
(
datainfo
.
metaData
.
length
).
assertLarger
(
0
)
for
(
var
j
=
0
;
j
<
datainfo
.
applicationInfo
.
moduleInfos
;
j
++
)
{
expect
(
datainfo
.
applicationInfo
.
moduleInfos
[
j
].
moduleName
).
assertEqual
(
"
entry
"
)
expect
(
datainfo
.
applicationInfo
.
moduleInfos
[
j
].
moduleSourceDir
).
assertEqual
(
DIR1
)
}
}
}).
catch
(
err
=>
{
expect
(
err
).
assertFail
();
})
installData
.
uninstall
(
NAME1
,
{
userId
:
100
,
...
...
@@ -2176,7 +2177,7 @@ describe('ActsBundleManagerTest', function () {
expect
(
data
.
statusMessage
).
assertEqual
(
'
SUCCESS
'
);
done
();
});
}
}
);
})
/**
...
...
appexecfwk/zlib/actszipfileandunzipfiletest/entry/src/main/js/test/actszipfileandunzipfiletest.test.js
浏览文件 @
7d9ad525
...
...
@@ -147,31 +147,33 @@ it('ACTS_ZipFile_0400', 0, async function (done) {
})
/*
* @tc.number: ACTS_ZipFile_
05
00
* @tc.number: ACTS_ZipFile_
19
00
* @tc.name: zipFile
* @tc.desc:
FlushType.FLUSH_TYPE_NO_FLUSH
* @tc.desc:
chunkSize: 64,
*/
it
(
'
ACTS_ZipFile_
05
00
'
,
0
,
async
function
(
done
)
{
console
.
log
(
"
==================
FWK_ZipFile_06
00 start==================
"
);
it
(
'
ACTS_ZipFile_
19
00
'
,
0
,
async
function
(
done
)
{
console
.
log
(
"
==================
ACTS_ZipFile_19
00 start==================
"
);
let
dirfirst
=
"
/data/accounts/account_0/appdata
"
let
dirsecond
=
dirfirst
+
"
/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST
"
let
dir
=
dirsecond
+
"
/com.example.amsZipfileUnzipfileST.MainAbility/files
"
;
let
path
=
dir
+
"
/ACTS_ZipFile_
0500.txt
"
;
a
var
zipDest
=
dir
+
"
/ACTS_ZipFile_
0500.zip
"
let
path
=
dir
+
"
/ACTS_ZipFile_
1900.txt
"
;
var
zipDest
=
dir
+
"
/ACTS_ZipFile_
1900.zip
"
;
let
infos
=
path
+
dir
;
let
unzipdirfirst
=
"
/data/accounts/account_0/appdata
"
;
let
unzipdirsecond
=
unzipdirfirst
+
"
/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST
"
let
unzipdir
=
unzipdirsecond
+
"
/com.example.amsZipfileUnzipfileST.MainAbility/files/ACTS_ZipFile_
05
00
"
;
let
unzipresultfile
=
unzipdir
+
"
/ACTS_ZipFile_
05
00.txt
"
;
let
unzipdir
=
unzipdirsecond
+
"
/com.example.amsZipfileUnzipfileST.MainAbility/files/ACTS_ZipFile_
19
00
"
;
let
unzipresultfile
=
unzipdir
+
"
/ACTS_ZipFile_
19
00.txt
"
;
let
fd
=
fileio
.
openSync
(
path
,
0o100
|
0o2
,
0o666
);
fileio
.
write
(
fd
,
infos
).
then
(
function
(
number
)
{
console
.
info
(
"
ACTS_ZipFile_
05
00 write data to file successfully:
"
+
number
);
console
.
info
(
"
ACTS_ZipFile_
19
00 write data to file successfully:
"
+
number
);
}).
catch
(
function
(
err
)
{
console
.
info
(
"
ACTS_ZipFile_
05
00 write data to file failed with error:
"
+
err
);
console
.
info
(
"
ACTS_ZipFile_
19
00 write data to file failed with error:
"
+
err
);
});
try
{
var
options
=
{};
options
.
flush
=
zlib
.
FlushType
.
FLUSH_TYPE_NO_FLUSH
;
var
options
=
{
chunkSize
:
64
,
};
await
zlib
.
zipFile
(
path
,
zipDest
,
options
,
(
err
,
data
)
=>
{
var
zipStat
=
fileio
.
statSync
(
zipDest
);
...
...
@@ -182,9 +184,9 @@ it('ACTS_ZipFile_0500', 0, async function (done) {
expect
(
srcSize
>
destSize
).
assertTrue
();
expect
(
data
).
assertEqual
(
zlib
.
ErrorCode
.
ERROR_CODE_OK
);
fileio
.
mkdir
(
unzipdir
).
then
(
function
()
{
console
.
info
(
"
ACTS_ZipFile_
05
00 mkdir successfully
"
);
console
.
info
(
"
ACTS_ZipFile_
19
00 mkdir successfully
"
);
}).
catch
(
function
(
error
)
{
console
.
info
(
"
ACTS_ZipFile_
05
00 mkdir failed with error:
"
+
error
);
console
.
info
(
"
ACTS_ZipFile_
19
00 mkdir failed with error:
"
+
error
);
});
zlib
.
unzipFile
(
zipDest
,
unzipdir
,
options
).
then
((
data
)
=>
{
var
unzipStat
=
fileio
.
statSync
(
unzipresultfile
);
...
...
@@ -195,47 +197,49 @@ it('ACTS_ZipFile_0500', 0, async function (done) {
var
result
=
(
originSize
==
destSize
);
expect
(
result
).
assertTrue
();
expect
(
data
).
assertEqual
(
zlib
.
ErrorCode
.
ERROR_CODE_OK
);
console
.
error
(
'
ACTS_ZipFile_
05
00 unzipFile
'
);
console
.
error
(
'
ACTS_ZipFile_
19
00 unzipFile
'
);
done
();
}).
catch
((
err
)
=>
{
console
.
log
(
"
ACTS_ZipFile_
05
00 err:
"
+
err
);
console
.
log
(
"
ACTS_ZipFile_
19
00 err:
"
+
err
);
done
();
})
done
();
});
}
catch
(
err
)
{
console
.
error
(
'
ACTS_ZipFile_
05
00 err:
'
+
err
);
console
.
error
(
'
ACTS_ZipFile_
19
00 err:
'
+
err
);
done
();
}
console
.
log
(
"
==================ACTS_ZipFile_
05
00 end==================
"
);
console
.
log
(
"
==================ACTS_ZipFile_
19
00 end==================
"
);
})
/*
* @tc.number: ACTS_ZipFile_
06
00
* @tc.number: ACTS_ZipFile_
20
00
* @tc.name: zipFile
* @tc.desc:
FlushType.FLUSH_TYPE_NO_FLUSH
* @tc.desc:
chunkSize: 1024,
*/
it
(
'
ACTS_ZipFile_
06
00
'
,
0
,
async
function
(
done
)
{
console
.
log
(
"
==================
FWK_ZipFile_06
00 start==================
"
);
it
(
'
ACTS_ZipFile_
20
00
'
,
0
,
async
function
(
done
)
{
console
.
log
(
"
==================
ACTS_ZipFile_20
00 start==================
"
);
let
dirfirst
=
"
/data/accounts/account_0/appdata
"
let
dirsecond
=
dirfirst
+
"
/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST
"
let
dir
=
dirsecond
+
"
/com.example.amsZipfileUnzipfileST.MainAbility/files
"
;
let
path
=
dir
+
"
/ACTS_ZipFile_
06
00.txt
"
;
var
zipDest
=
dir
+
"
/ACTS_ZipFile_
06
00.zip
"
let
path
=
dir
+
"
/ACTS_ZipFile_
20
00.txt
"
;
var
zipDest
=
dir
+
"
/ACTS_ZipFile_
20
00.zip
"
let
infos
=
path
+
dir
;
let
unzipdirfirst
=
"
/data/accounts/account_0/appdata
"
;
let
unzipdirsecond
=
unzipdirfirst
+
"
/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST
"
let
unzipdir
=
unzipdirsecond
+
"
/com.example.amsZipfileUnzipfileST.MainAbility/files/ACTS_ZipFile_
06
00
"
;
let
unzipresultfile
=
unzipdir
+
"
/ACTS_ZipFile_
06
00.txt
"
;
let
unzipdir
=
unzipdirsecond
+
"
/com.example.amsZipfileUnzipfileST.MainAbility/files/ACTS_ZipFile_
20
00
"
;
let
unzipresultfile
=
unzipdir
+
"
/ACTS_ZipFile_
20
00.txt
"
;
let
fd
=
fileio
.
openSync
(
path
,
0o100
|
0o2
,
0o666
);
fileio
.
write
(
fd
,
infos
).
then
(
function
(
number
)
{
console
.
info
(
"
ACTS_ZipFile_
06
00 write data to file successfully:
"
+
number
);
console
.
info
(
"
ACTS_ZipFile_
20
00 write data to file successfully:
"
+
number
);
}).
catch
(
function
(
err
)
{
console
.
info
(
"
ACTS_ZipFile_
06
00 write data to file failed with error:
"
+
err
);
console
.
info
(
"
ACTS_ZipFile_
20
00 write data to file failed with error:
"
+
err
);
});
try
{
var
options
=
{};
options
.
flush
=
zlib
.
FlushType
.
FLUSH_TYPE_NO_FLUSH
;
var
options
=
{
chunkSize
:
1024
,
};
await
zlib
.
zipFile
(
path
,
zipDest
,
options
,
(
err
,
data
)
=>
{
var
zipStat
=
fileio
.
statSync
(
zipDest
);
...
...
@@ -246,9 +250,9 @@ it('ACTS_ZipFile_0600', 0, async function (done) {
expect
(
srcSize
>
destSize
).
assertTrue
();
expect
(
data
).
assertEqual
(
zlib
.
ErrorCode
.
ERROR_CODE_OK
);
fileio
.
mkdir
(
unzipdir
).
then
(
function
()
{
console
.
info
(
"
ACTS_ZipFile_
06
00 mkdir successfully
"
);
console
.
info
(
"
ACTS_ZipFile_
20
00 mkdir successfully
"
);
}).
catch
(
function
(
error
)
{
console
.
info
(
"
ACTS_ZipFile_
06
00 mkdir failed with error:
"
+
error
);
console
.
info
(
"
ACTS_ZipFile_
20
00 mkdir failed with error:
"
+
error
);
});
zlib
.
unzipFile
(
zipDest
,
unzipdir
,
options
).
then
((
data
)
=>
{
var
unzipStat
=
fileio
.
statSync
(
unzipresultfile
);
...
...
@@ -259,48 +263,49 @@ it('ACTS_ZipFile_0600', 0, async function (done) {
var
result
=
(
originSize
==
destSize
);
expect
(
result
).
assertTrue
();
expect
(
data
).
assertEqual
(
zlib
.
ErrorCode
.
ERROR_CODE_OK
);
console
.
error
(
'
ACTS_ZipFile_
06
00 unzipFile
'
);
console
.
error
(
'
ACTS_ZipFile_
20
00 unzipFile
'
);
done
();
}).
catch
((
err
)
=>
{
console
.
log
(
"
ACTS_ZipFile_
06
00 err:
"
+
err
);
console
.
log
(
"
ACTS_ZipFile_
20
00 err:
"
+
err
);
done
();
})
done
();
});
}
catch
(
err
)
{
console
.
error
(
'
ACTS_ZipFile_
06
00 err:
'
+
err
);
console
.
error
(
'
ACTS_ZipFile_
20
00 err:
'
+
err
);
done
();
}
console
.
log
(
"
==================ACTS_ZipFile_
06
00 end==================
"
);
console
.
log
(
"
==================ACTS_ZipFile_
20
00 end==================
"
);
})
/*
* @tc.number: ACTS_ZipFile_
07
00
* @tc.number: ACTS_ZipFile_
21
00
* @tc.name: zipFile
* @tc.desc:
FlushType.FLUSH_TYPE_SYNC_FLUSH
* @tc.desc:
chunkSize: 999,
*/
it
(
'
ACTS_ZipFile_
07
00
'
,
0
,
async
function
(
done
)
{
console
.
log
(
"
==================ACTS_ZipFile_
07
00 start==================
"
);
it
(
'
ACTS_ZipFile_
21
00
'
,
0
,
async
function
(
done
)
{
console
.
log
(
"
==================ACTS_ZipFile_
21
00 start==================
"
);
let
dirfirst
=
"
/data/accounts/account_0/appdata
"
let
dirsecond
=
dirfirst
+
"
/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST
"
let
dir
=
dirsecond
+
"
/com.example.amsZipfileUnzipfileST.MainAbility/files
"
;
let
path
=
dir
+
"
/ACTS_ZipFile_
07
00.txt
"
;
var
zipDest
=
dir
+
"
/ACTS_ZipFile_
07
00.zip
"
let
path
=
dir
+
"
/ACTS_ZipFile_
21
00.txt
"
;
var
zipDest
=
dir
+
"
/ACTS_ZipFile_
21
00.zip
"
let
infos
=
path
+
dir
;
let
unzipdirfirst
=
"
/data/accounts/account_0/appdata
"
;
let
unzipdirsecond
=
unzipdirfirst
+
"
/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST
"
let
unzipdir
=
unzipdirsecond
+
"
/com.example.amsZipfileUnzipfileST.MainAbility/files/ACTS_ZipFile_
07
00
"
;
let
unzipresultfile
=
unzipdir
+
"
/ACTS_ZipFile_
07
00.txt
"
;
let
unzipdir
=
unzipdirsecond
+
"
/com.example.amsZipfileUnzipfileST.MainAbility/files/ACTS_ZipFile_
21
00
"
;
let
unzipresultfile
=
unzipdir
+
"
/ACTS_ZipFile_
21
00.txt
"
;
let
fd
=
fileio
.
openSync
(
path
,
0o100
|
0o2
,
0o666
);
fileio
.
write
(
fd
,
infos
).
then
(
function
(
number
)
{
console
.
info
(
"
ACTS_ZipFile_
07
00 write data to file successfully:
"
+
number
);
console
.
info
(
"
ACTS_ZipFile_
21
00 write data to file successfully:
"
+
number
);
}).
catch
(
function
(
err
)
{
console
.
info
(
"
ACTS_ZipFile_
07
00 write data to file failed with error:
"
+
err
);
console
.
info
(
"
ACTS_ZipFile_
21
00 write data to file failed with error:
"
+
err
);
});
try
{
var
options
=
{};
options
.
flush
=
zlib
.
FlushType
.
FLUSH_TYPE_SYNC_FLUSH
;
var
options
=
{
chunkSize
:
999
,
};
await
zlib
.
zipFile
(
path
,
zipDest
,
options
,
(
err
,
data
)
=>
{
var
zipStat
=
fileio
.
statSync
(
zipDest
);
...
...
@@ -311,9 +316,9 @@ it('ACTS_ZipFile_0700', 0, async function (done) {
expect
(
srcSize
>
destSize
).
assertTrue
();
expect
(
data
).
assertEqual
(
zlib
.
ErrorCode
.
ERROR_CODE_OK
);
fileio
.
mkdir
(
unzipdir
).
then
(
function
()
{
console
.
info
(
"
ACTS_ZipFile_
07
00 mkdir successfully
"
);
console
.
info
(
"
ACTS_ZipFile_
21
00 mkdir successfully
"
);
}).
catch
(
function
(
error
)
{
console
.
info
(
"
ACTS_ZipFile_
07
00 mkdir failed with error:
"
+
error
);
console
.
info
(
"
ACTS_ZipFile_
21
00 mkdir failed with error:
"
+
error
);
});
zlib
.
unzipFile
(
zipDest
,
unzipdir
,
options
).
then
((
data
)
=>
{
var
unzipStat
=
fileio
.
statSync
(
unzipresultfile
);
...
...
@@ -324,48 +329,48 @@ it('ACTS_ZipFile_0700', 0, async function (done) {
var
result
=
(
originSize
==
destSize
);
expect
(
result
).
assertTrue
();
expect
(
data
).
assertEqual
(
zlib
.
ErrorCode
.
ERROR_CODE_OK
);
console
.
error
(
'
ACTS_ZipFile_
07
00 unzipFile
'
);
console
.
error
(
'
ACTS_ZipFile_
21
00 unzipFile
'
);
done
();
}).
catch
((
err
)
=>
{
console
.
log
(
"
ACTS_ZipFile_
07
00 err:
"
+
err
);
console
.
log
(
"
ACTS_ZipFile_
21
00 err:
"
+
err
);
done
();
})
done
();
});
}
catch
(
err
)
{
console
.
error
(
'
ACTS_ZipFile_
07
00 err:
'
+
err
);
console
.
error
(
'
ACTS_ZipFile_
21
00 err:
'
+
err
);
done
();
}
console
.
log
(
"
==================ACTS_ZipFile_
07
00 end==================
"
);
console
.
log
(
"
==================ACTS_ZipFile_
21
00 end==================
"
);
})
/*
* @tc.number: ACTS_ZipFile_
08
00
* @tc.number: ACTS_ZipFile_
22
00
* @tc.name: zipFile
* @tc.desc:
FlushType.FLUSH_TYPE_FULL_FLUSH
* @tc.desc:
COMPRESS_LEVEL_NO_COMPRESSION,
*/
it
(
'
ACTS_ZipFile_
08
00
'
,
0
,
async
function
(
done
)
{
console
.
log
(
"
==================ACTS_ZipFile_
08
00 start==================
"
);
it
(
'
ACTS_ZipFile_
22
00
'
,
0
,
async
function
(
done
)
{
console
.
log
(
"
==================ACTS_ZipFile_
22
00 start==================
"
);
let
dirfirst
=
"
/data/accounts/account_0/appdata
"
let
dirsecond
=
dirfirst
+
"
/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST
"
let
dir
=
dirsecond
+
"
/com.example.amsZipfileUnzipfileST.MainAbility/files
"
;
let
path
=
dir
+
"
/ACTS_ZipFile_
08
00.txt
"
;
var
zipDest
=
dir
+
"
/ACTS_ZipFile_
08
00.zip
"
let
path
=
dir
+
"
/ACTS_ZipFile_
22
00.txt
"
;
var
zipDest
=
dir
+
"
/ACTS_ZipFile_
22
00.zip
"
let
infos
=
path
+
dir
;
let
unzipdirfirst
=
"
/data/accounts/account_0/appdata
"
;
let
unzipdirsecond
=
unzipdirfirst
+
"
/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST
"
let
unzipdir
=
unzipdirsecond
+
"
/com.example.amsZipfileUnzipfileST.MainAbility/files/ACTS_ZipFile_
08
00
"
;
let
unzipresultfile
=
unzipdir
+
"
/ACTS_ZipFile_
08
00.txt
"
;
let
unzipdir
=
unzipdirsecond
+
"
/com.example.amsZipfileUnzipfileST.MainAbility/files/ACTS_ZipFile_
22
00
"
;
let
unzipresultfile
=
unzipdir
+
"
/ACTS_ZipFile_
22
00.txt
"
;
let
fd
=
fileio
.
openSync
(
path
,
0o100
|
0o2
,
0o666
);
fileio
.
write
(
fd
,
infos
).
then
(
function
(
number
)
{
console
.
info
(
"
ACTS_ZipFile_
08
00 write data to file successfully:
"
+
number
);
console
.
info
(
"
ACTS_ZipFile_
22
00 write data to file successfully:
"
+
number
);
}).
catch
(
function
(
err
)
{
console
.
info
(
"
ACTS_ZipFile_
08
00 write data to file failed with error:
"
+
err
);
console
.
info
(
"
ACTS_ZipFile_
22
00 write data to file failed with error:
"
+
err
);
});
try
{
var
options
=
{};
options
.
flush
=
zlib
.
FlushType
.
FLUSH_TYPE_FULL_FLUSH
;
options
.
level
=
zlib
.
CompressLevel
.
COMPRESS_LEVEL_NO_COMPRESSION
;
await
zlib
.
zipFile
(
path
,
zipDest
,
options
,
(
err
,
data
)
=>
{
var
zipStat
=
fileio
.
statSync
(
zipDest
);
...
...
@@ -376,9 +381,9 @@ it('ACTS_ZipFile_0800', 0, async function (done) {
expect
(
srcSize
>
destSize
).
assertTrue
();
expect
(
data
).
assertEqual
(
zlib
.
ErrorCode
.
ERROR_CODE_OK
);
fileio
.
mkdir
(
unzipdir
).
then
(
function
()
{
console
.
info
(
"
ACTS_ZipFile_
08
00 mkdir successfully
"
);
console
.
info
(
"
ACTS_ZipFile_
22
00 mkdir successfully
"
);
}).
catch
(
function
(
error
)
{
console
.
info
(
"
ACTS_ZipFile_
08
00 mkdir failed with error:
"
+
error
);
console
.
info
(
"
ACTS_ZipFile_
22
00 mkdir failed with error:
"
+
error
);
});
zlib
.
unzipFile
(
zipDest
,
unzipdir
,
options
).
then
((
data
)
=>
{
var
unzipStat
=
fileio
.
statSync
(
unzipresultfile
);
...
...
@@ -389,48 +394,48 @@ it('ACTS_ZipFile_0800', 0, async function (done) {
var
result
=
(
originSize
==
destSize
);
expect
(
result
).
assertTrue
();
expect
(
data
).
assertEqual
(
zlib
.
ErrorCode
.
ERROR_CODE_OK
);
console
.
error
(
'
ACTS_ZipFile_
08
00 unzipFile
'
);
console
.
error
(
'
ACTS_ZipFile_
22
00 unzipFile
'
);
done
();
}).
catch
((
err
)
=>
{
console
.
log
(
"
ACTS_ZipFile_
08
00 err:
"
+
err
);
console
.
log
(
"
ACTS_ZipFile_
22
00 err:
"
+
err
);
done
();
})
done
();
});
}
catch
(
err
)
{
console
.
error
(
'
ACTS_ZipFile_
08
00 err:
'
+
err
);
console
.
error
(
'
ACTS_ZipFile_
22
00 err:
'
+
err
);
done
();
}
console
.
log
(
"
==================ACTS_ZipFile_
08
00 end==================
"
);
console
.
log
(
"
==================ACTS_ZipFile_
22
00 end==================
"
);
})
/*
* @tc.number: ACTS_ZipFile_
09
00
* @tc.number: ACTS_ZipFile_
23
00
* @tc.name: zipFile
* @tc.desc:
FlushType.FLUSH_TYPE_FINISH
* @tc.desc:
COMPRESS_LEVEL_BEST_SPEED,
*/
it
(
'
ACTS_ZipFile_
09
00
'
,
0
,
async
function
(
done
)
{
console
.
log
(
"
==================ACTS_ZipFile_
09
00 start==================
"
);
it
(
'
ACTS_ZipFile_
23
00
'
,
0
,
async
function
(
done
)
{
console
.
log
(
"
==================ACTS_ZipFile_
23
00 start==================
"
);
let
dirfirst
=
"
/data/accounts/account_0/appdata
"
let
dirsecond
=
dirfirst
+
"
/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST
"
let
dir
=
dirsecond
+
"
/com.example.amsZipfileUnzipfileST.MainAbility/files
"
;
let
path
=
dir
+
"
/ACTS_ZipFile_
09
00.txt
"
;
var
zipDest
=
dir
+
"
/ACTS_ZipFile_
09
00.zip
"
let
path
=
dir
+
"
/ACTS_ZipFile_
23
00.txt
"
;
var
zipDest
=
dir
+
"
/ACTS_ZipFile_
23
00.zip
"
let
infos
=
path
+
dir
;
let
unzipdirfirst
=
"
/data/accounts/account_0/appdata
"
;
let
unzipdirsecond
=
unzipdirfirst
+
"
/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST
"
let
unzipdir
=
unzipdirsecond
+
"
/com.example.amsZipfileUnzipfileST.MainAbility/files/ACTS_ZipFile_
09
00
"
;
let
unzipresultfile
=
unzipdir
+
"
/ACTS_ZipFile_
09
00.txt
"
;
let
unzipdir
=
unzipdirsecond
+
"
/com.example.amsZipfileUnzipfileST.MainAbility/files/ACTS_ZipFile_
23
00
"
;
let
unzipresultfile
=
unzipdir
+
"
/ACTS_ZipFile_
23
00.txt
"
;
let
fd
=
fileio
.
openSync
(
path
,
0o100
|
0o2
,
0o666
);
fileio
.
write
(
fd
,
infos
).
then
(
function
(
number
)
{
console
.
info
(
"
ACTS_ZipFile_
09
00 write data to file successfully:
"
+
number
);
console
.
info
(
"
ACTS_ZipFile_
23
00 write data to file successfully:
"
+
number
);
}).
catch
(
function
(
err
)
{
console
.
info
(
"
ACTS_ZipFile_
09
00 write data to file failed with error:
"
+
err
);
console
.
info
(
"
ACTS_ZipFile_
23
00 write data to file failed with error:
"
+
err
);
});
try
{
var
options
=
{};
options
.
flush
=
zlib
.
FlushType
.
FLUSH_TYPE_FINISH
;
options
.
level
=
zlib
.
CompressLevel
.
COMPRESS_LEVEL_BEST_SPEED
;
await
zlib
.
zipFile
(
path
,
zipDest
,
options
,
(
err
,
data
)
=>
{
var
zipStat
=
fileio
.
statSync
(
zipDest
);
...
...
@@ -441,9 +446,9 @@ it('ACTS_ZipFile_0900', 0, async function (done) {
expect
(
srcSize
>
destSize
).
assertTrue
();
expect
(
data
).
assertEqual
(
zlib
.
ErrorCode
.
ERROR_CODE_OK
);
fileio
.
mkdir
(
unzipdir
).
then
(
function
()
{
console
.
info
(
"
ACTS_ZipFile_
09
00 mkdir successfully
"
);
console
.
info
(
"
ACTS_ZipFile_
23
00 mkdir successfully
"
);
}).
catch
(
function
(
error
)
{
console
.
info
(
"
ACTS_ZipFile_
09
00 mkdir failed with error:
"
+
error
);
console
.
info
(
"
ACTS_ZipFile_
23
00 mkdir failed with error:
"
+
error
);
});
zlib
.
unzipFile
(
zipDest
,
unzipdir
,
options
).
then
((
data
)
=>
{
var
unzipStat
=
fileio
.
statSync
(
unzipresultfile
);
...
...
@@ -454,48 +459,48 @@ it('ACTS_ZipFile_0900', 0, async function (done) {
var
result
=
(
originSize
==
destSize
);
expect
(
result
).
assertTrue
();
expect
(
data
).
assertEqual
(
zlib
.
ErrorCode
.
ERROR_CODE_OK
);
console
.
error
(
'
ACTS_ZipFile_
09
00 unzipFile
'
);
console
.
error
(
'
ACTS_ZipFile_
23
00 unzipFile
'
);
done
();
}).
catch
((
err
)
=>
{
console
.
log
(
"
ACTS_ZipFile_
09
00 err:
"
+
err
);
console
.
log
(
"
ACTS_ZipFile_
23
00 err:
"
+
err
);
done
();
})
done
();
});
}
catch
(
err
)
{
console
.
error
(
'
ACTS_ZipFile_
09
00 err:
'
+
err
);
console
.
error
(
'
ACTS_ZipFile_
23
00 err:
'
+
err
);
done
();
}
console
.
log
(
"
==================ACTS_ZipFile_
09
00 end==================
"
);
console
.
log
(
"
==================ACTS_ZipFile_
23
00 end==================
"
);
})
/*
* @tc.number: ACTS_ZipFile_
10
00
* @tc.number: ACTS_ZipFile_
24
00
* @tc.name: zipFile
* @tc.desc:
FlushType.FLUSH_TYPE_BLOCK
* @tc.desc:
COMPRESS_LEVEL_BEST_COMPRESSION,
*/
it
(
'
ACTS_ZipFile_
10
00
'
,
0
,
async
function
(
done
)
{
console
.
log
(
"
==================ACTS_ZipFile_
10
00 start==================
"
);
it
(
'
ACTS_ZipFile_
24
00
'
,
0
,
async
function
(
done
)
{
console
.
log
(
"
==================ACTS_ZipFile_
24
00 start==================
"
);
let
dirfirst
=
"
/data/accounts/account_0/appdata
"
let
dirsecond
=
dirfirst
+
"
/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST
"
let
dir
=
dirsecond
+
"
/com.example.amsZipfileUnzipfileST.MainAbility/files
"
;
let
path
=
dir
+
"
/ACTS_ZipFile_
10
00.txt
"
;
var
zipDest
=
dir
+
"
/ACTS_ZipFile_
10
00.zip
"
let
path
=
dir
+
"
/ACTS_ZipFile_
24
00.txt
"
;
var
zipDest
=
dir
+
"
/ACTS_ZipFile_
24
00.zip
"
let
infos
=
path
+
dir
;
let
unzipdirfirst
=
"
/data/accounts/account_0/appdata
"
;
let
unzipdirsecond
=
unzipdirfirst
+
"
/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST
"
let
unzipdir
=
unzipdirsecond
+
"
/com.example.amsZipfileUnzipfileST.MainAbility/files/ACTS_ZipFile_
10
00
"
;
let
unzipresultfile
=
unzipdir
+
"
/ACTS_ZipFile_
10
00.txt
"
;
let
unzipdir
=
unzipdirsecond
+
"
/com.example.amsZipfileUnzipfileST.MainAbility/files/ACTS_ZipFile_
24
00
"
;
let
unzipresultfile
=
unzipdir
+
"
/ACTS_ZipFile_
24
00.txt
"
;
let
fd
=
fileio
.
openSync
(
path
,
0o100
|
0o2
,
0o666
);
fileio
.
write
(
fd
,
infos
).
then
(
function
(
number
)
{
console
.
info
(
"
ACTS_ZipFile_
10
00 write data to file successfully:
"
+
number
);
console
.
info
(
"
ACTS_ZipFile_
24
00 write data to file successfully:
"
+
number
);
}).
catch
(
function
(
err
)
{
console
.
info
(
"
ACTS_ZipFile_
10
00 write data to file failed with error:
"
+
err
);
console
.
info
(
"
ACTS_ZipFile_
24
00 write data to file failed with error:
"
+
err
);
});
try
{
var
options
=
{};
options
.
flush
=
zlib
.
FlushType
.
FLUSH_TYPE_BLOCK
;
options
.
level
=
zlib
.
CompressLevel
.
COMPRESS_LEVEL_BEST_COMPRESSION
;
await
zlib
.
zipFile
(
path
,
zipDest
,
options
,
(
err
,
data
)
=>
{
var
zipStat
=
fileio
.
statSync
(
zipDest
);
...
...
@@ -506,9 +511,9 @@ it('ACTS_ZipFile_1000', 0, async function (done) {
expect
(
srcSize
>
destSize
).
assertTrue
();
expect
(
data
).
assertEqual
(
zlib
.
ErrorCode
.
ERROR_CODE_OK
);
fileio
.
mkdir
(
unzipdir
).
then
(
function
()
{
console
.
info
(
"
ACTS_ZipFile_
10
00 mkdir successfully
"
);
console
.
info
(
"
ACTS_ZipFile_
24
00 mkdir successfully
"
);
}).
catch
(
function
(
error
)
{
console
.
info
(
"
ACTS_ZipFile_
10
00 mkdir failed with error:
"
+
error
);
console
.
info
(
"
ACTS_ZipFile_
24
00 mkdir failed with error:
"
+
error
);
});
zlib
.
unzipFile
(
zipDest
,
unzipdir
,
options
).
then
((
data
)
=>
{
var
unzipStat
=
fileio
.
statSync
(
unzipresultfile
);
...
...
@@ -519,48 +524,48 @@ it('ACTS_ZipFile_1000', 0, async function (done) {
var
result
=
(
originSize
==
destSize
);
expect
(
result
).
assertTrue
();
expect
(
data
).
assertEqual
(
zlib
.
ErrorCode
.
ERROR_CODE_OK
);
console
.
error
(
'
ACTS_ZipFile_
10
00 unzipFile
'
);
console
.
error
(
'
ACTS_ZipFile_
24
00 unzipFile
'
);
done
();
}).
catch
((
err
)
=>
{
console
.
log
(
"
ACTS_ZipFile_
10
00 err:
"
+
err
);
console
.
log
(
"
ACTS_ZipFile_
24
00 err:
"
+
err
);
done
();
})
done
();
});
}
catch
(
err
)
{
console
.
error
(
'
ACTS_ZipFile_
10
00 err:
'
+
err
);
console
.
error
(
'
ACTS_ZipFile_
24
00 err:
'
+
err
);
done
();
}
console
.
log
(
"
==================ACTS_ZipFile_
10
00 end==================
"
);
console
.
log
(
"
==================ACTS_ZipFile_
24
00 end==================
"
);
})
/*
* @tc.number: ACTS_ZipFile_
11
00
* @tc.number: ACTS_ZipFile_
25
00
* @tc.name: zipFile
* @tc.desc:
FlushType.FLUSH_TYPE_TREES
* @tc.desc:
COMPRESS_LEVEL_DEFAULT_COMPRESSION,
*/
it
(
'
ACTS_ZipFile_
11
00
'
,
0
,
async
function
(
done
)
{
console
.
log
(
"
==================ACTS_ZipFile_
11
00 start==================
"
);
it
(
'
ACTS_ZipFile_
25
00
'
,
0
,
async
function
(
done
)
{
console
.
log
(
"
==================ACTS_ZipFile_
25
00 start==================
"
);
let
dirfirst
=
"
/data/accounts/account_0/appdata
"
let
dirsecond
=
dirfirst
+
"
/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST
"
let
dir
=
dirsecond
+
"
/com.example.amsZipfileUnzipfileST.MainAbility/files
"
;
let
path
=
dir
+
"
/ACTS_ZipFile_
11
00.txt
"
;
var
zipDest
=
dir
+
"
/ACTS_ZipFile_
11
00.zip
"
let
path
=
dir
+
"
/ACTS_ZipFile_
25
00.txt
"
;
var
zipDest
=
dir
+
"
/ACTS_ZipFile_
25
00.zip
"
let
infos
=
path
+
dir
;
let
unzipdirfirst
=
"
/data/accounts/account_0/appdata
"
;
let
unzipdirsecond
=
unzipdirfirst
+
"
/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST
"
let
unzipdir
=
unzipdirsecond
+
"
/com.example.amsZipfileUnzipfileST.MainAbility/files/ACTS_ZipFile_
11
00
"
;
let
unzipresultfile
=
unzipdir
+
"
/ACTS_ZipFile_
11
00.txt
"
;
let
unzipdir
=
unzipdirsecond
+
"
/com.example.amsZipfileUnzipfileST.MainAbility/files/ACTS_ZipFile_
25
00
"
;
let
unzipresultfile
=
unzipdir
+
"
/ACTS_ZipFile_
25
00.txt
"
;
let
fd
=
fileio
.
openSync
(
path
,
0o100
|
0o2
,
0o666
);
fileio
.
write
(
fd
,
infos
).
then
(
function
(
number
)
{
console
.
info
(
"
ACTS_ZipFile_
11
00 write data to file successfully:
"
+
number
);
console
.
info
(
"
ACTS_ZipFile_
25
00 write data to file successfully:
"
+
number
);
}).
catch
(
function
(
err
)
{
console
.
info
(
"
ACTS_ZipFile_
11
00 write data to file failed with error:
"
+
err
);
console
.
info
(
"
ACTS_ZipFile_
25
00 write data to file failed with error:
"
+
err
);
});
try
{
var
options
=
{};
options
.
flush
=
zlib
.
FlushType
.
FLUSH_TYPE_TREES
;
options
.
level
=
zlib
.
CompressLevel
.
COMPRESS_LEVEL_DEFAULT_COMPRESSION
;
await
zlib
.
zipFile
(
path
,
zipDest
,
options
,
(
err
,
data
)
=>
{
var
zipStat
=
fileio
.
statSync
(
zipDest
);
...
...
@@ -571,9 +576,9 @@ it('ACTS_ZipFile_1100', 0, async function (done) {
expect
(
srcSize
>
destSize
).
assertTrue
();
expect
(
data
).
assertEqual
(
zlib
.
ErrorCode
.
ERROR_CODE_OK
);
fileio
.
mkdir
(
unzipdir
).
then
(
function
()
{
console
.
info
(
"
ACTS_ZipFile_
11
00 mkdir successfully
"
);
console
.
info
(
"
ACTS_ZipFile_
25
00 mkdir successfully
"
);
}).
catch
(
function
(
error
)
{
console
.
info
(
"
ACTS_ZipFile_
11
00 mkdir failed with error:
"
+
error
);
console
.
info
(
"
ACTS_ZipFile_
25
00 mkdir failed with error:
"
+
error
);
});
zlib
.
unzipFile
(
zipDest
,
unzipdir
,
options
).
then
((
data
)
=>
{
var
unzipStat
=
fileio
.
statSync
(
unzipresultfile
);
...
...
@@ -584,48 +589,48 @@ it('ACTS_ZipFile_1100', 0, async function (done) {
var
result
=
(
originSize
==
destSize
);
expect
(
result
).
assertTrue
();
expect
(
data
).
assertEqual
(
zlib
.
ErrorCode
.
ERROR_CODE_OK
);
console
.
error
(
'
ACTS_ZipFile_
11
00 unzipFile
'
);
console
.
error
(
'
ACTS_ZipFile_
25
00 unzipFile
'
);
done
();
}).
catch
((
err
)
=>
{
console
.
log
(
"
ACTS_ZipFile_
11
00 err:
"
+
err
);
console
.
log
(
"
ACTS_ZipFile_
25
00 err:
"
+
err
);
done
();
})
done
();
});
}
catch
(
err
)
{
console
.
error
(
'
ACTS_ZipFile_
11
00 err:
'
+
err
);
console
.
error
(
'
ACTS_ZipFile_
25
00 err:
'
+
err
);
done
();
}
console
.
log
(
"
==================ACTS_ZipFile_
11
00 end==================
"
);
console
.
log
(
"
==================ACTS_ZipFile_
25
00 end==================
"
);
})
/*
* @tc.number: ACTS_ZipFile_
12
00
* @tc.number: ACTS_ZipFile_
26
00
* @tc.name: zipFile
* @tc.desc:
FlushType.FLUSH_TYPE_NO_FLUSH
* @tc.desc:
MEM_LEVEL_MIN_MEMLEVEL,,
*/
it
(
'
ACTS_ZipFile_
12
00
'
,
0
,
async
function
(
done
)
{
console
.
log
(
"
==================ACTS_ZipFile_
12
00 start==================
"
);
it
(
'
ACTS_ZipFile_
26
00
'
,
0
,
async
function
(
done
)
{
console
.
log
(
"
==================ACTS_ZipFile_
26
00 start==================
"
);
let
dirfirst
=
"
/data/accounts/account_0/appdata
"
let
dirsecond
=
dirfirst
+
"
/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST
"
let
dir
=
dirsecond
+
"
/com.example.amsZipfileUnzipfileST.MainAbility/files
"
;
let
path
=
dir
+
"
/ACTS_ZipFile_
12
00.txt
"
;
var
zipDest
=
dir
+
"
/ACTS_ZipFile_
12
00.zip
"
let
path
=
dir
+
"
/ACTS_ZipFile_
26
00.txt
"
;
var
zipDest
=
dir
+
"
/ACTS_ZipFile_
26
00.zip
"
let
infos
=
path
+
dir
;
let
unzipdirfirst
=
"
/data/accounts/account_0/appdata
"
;
let
unzipdirsecond
=
unzipdirfirst
+
"
/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST
"
let
unzipdir
=
unzipdirsecond
+
"
/com.example.amsZipfileUnzipfileST.MainAbility/files/ACTS_ZipFile_
12
00
"
;
let
unzipresultfile
=
unzipdir
+
"
/ACTS_ZipFile_
12
00.txt
"
;
let
unzipdir
=
unzipdirsecond
+
"
/com.example.amsZipfileUnzipfileST.MainAbility/files/ACTS_ZipFile_
26
00
"
;
let
unzipresultfile
=
unzipdir
+
"
/ACTS_ZipFile_
26
00.txt
"
;
let
fd
=
fileio
.
openSync
(
path
,
0o100
|
0o2
,
0o666
);
fileio
.
write
(
fd
,
infos
).
then
(
function
(
number
)
{
console
.
info
(
"
ACTS_ZipFile_
12
00 write data to file successfully:
"
+
number
);
console
.
info
(
"
ACTS_ZipFile_
26
00 write data to file successfully:
"
+
number
);
}).
catch
(
function
(
err
)
{
console
.
info
(
"
ACTS_ZipFile_
12
00 write data to file failed with error:
"
+
err
);
console
.
info
(
"
ACTS_ZipFile_
26
00 write data to file failed with error:
"
+
err
);
});
try
{
var
options
=
{};
options
.
flush
=
zlib
.
FlushType
.
FLUSH_TYPE_NO_FLUSH
;
options
.
memLevel
=
zlib
.
MemLevel
.
MEM_LEVEL_MIN
;
await
zlib
.
zipFile
(
path
,
zipDest
,
options
,
(
err
,
data
)
=>
{
var
zipStat
=
fileio
.
statSync
(
zipDest
);
...
...
@@ -636,9 +641,9 @@ it('ACTS_ZipFile_1200', 0, async function (done) {
expect
(
srcSize
>
destSize
).
assertTrue
();
expect
(
data
).
assertEqual
(
zlib
.
ErrorCode
.
ERROR_CODE_OK
);
fileio
.
mkdir
(
unzipdir
).
then
(
function
()
{
console
.
info
(
"
ACTS_ZipFile_
12
00 mkdir successfully
"
);
console
.
info
(
"
ACTS_ZipFile_
26
00 mkdir successfully
"
);
}).
catch
(
function
(
error
)
{
console
.
info
(
"
ACTS_ZipFile_
12
00 mkdir failed with error:
"
+
error
);
console
.
info
(
"
ACTS_ZipFile_
26
00 mkdir failed with error:
"
+
error
);
});
zlib
.
unzipFile
(
zipDest
,
unzipdir
,
options
).
then
((
data
)
=>
{
var
unzipStat
=
fileio
.
statSync
(
unzipresultfile
);
...
...
@@ -649,48 +654,48 @@ it('ACTS_ZipFile_1200', 0, async function (done) {
var
result
=
(
originSize
==
destSize
);
expect
(
result
).
assertTrue
();
expect
(
data
).
assertEqual
(
zlib
.
ErrorCode
.
ERROR_CODE_OK
);
console
.
error
(
'
ACTS_ZipFile_
12
00 unzipFile
'
);
console
.
error
(
'
ACTS_ZipFile_
26
00 unzipFile
'
);
done
();
}).
catch
((
err
)
=>
{
console
.
log
(
"
ACTS_ZipFile_
12
00 err:
"
+
err
);
console
.
log
(
"
ACTS_ZipFile_
26
00 err:
"
+
err
);
done
();
})
done
();
});
}
catch
(
err
)
{
console
.
error
(
'
ACTS_ZipFile_
12
00 err:
'
+
err
);
console
.
error
(
'
ACTS_ZipFile_
26
00 err:
'
+
err
);
done
();
}
console
.
log
(
"
==================ACTS_ZipFile_
12
00 end==================
"
);
console
.
log
(
"
==================ACTS_ZipFile_
26
00 end==================
"
);
})
/*
* @tc.number: ACTS_ZipFile_
13
00
* @tc.number: ACTS_ZipFile_
27
00
* @tc.name: zipFile
* @tc.desc:
FlushType.FLUSH_TYPE_PARTIAL_FLUSH
* @tc.desc:
MEM_LEVEL_MAX_MEMLEVEL,,
*/
it
(
'
ACTS_ZipFile_
13
00
'
,
0
,
async
function
(
done
)
{
console
.
log
(
"
==================ACTS_ZipFile_
13
00 start==================
"
);
it
(
'
ACTS_ZipFile_
27
00
'
,
0
,
async
function
(
done
)
{
console
.
log
(
"
==================ACTS_ZipFile_
27
00 start==================
"
);
let
dirfirst
=
"
/data/accounts/account_0/appdata
"
let
dirsecond
=
dirfirst
+
"
/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST
"
let
dir
=
dirsecond
+
"
/com.example.amsZipfileUnzipfileST.MainAbility/files
"
;
let
path
=
dir
+
"
/ACTS_ZipFile_
13
00.txt
"
;
var
zipDest
=
dir
+
"
/ACTS_ZipFile_
13
00.zip
"
let
path
=
dir
+
"
/ACTS_ZipFile_
27
00.txt
"
;
var
zipDest
=
dir
+
"
/ACTS_ZipFile_
27
00.zip
"
let
infos
=
path
+
dir
;
let
unzipdirfirst
=
"
/data/accounts/account_0/appdata
"
;
let
unzipdirsecond
=
unzipdirfirst
+
"
/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST
"
let
unzipdir
=
unzipdirsecond
+
"
/com.example.amsZipfileUnzipfileST.MainAbility/files/ACTS_ZipFile_
13
00
"
;
let
unzipresultfile
=
unzipdir
+
"
/ACTS_ZipFile_
13
00.txt
"
;
let
unzipdir
=
unzipdirsecond
+
"
/com.example.amsZipfileUnzipfileST.MainAbility/files/ACTS_ZipFile_
27
00
"
;
let
unzipresultfile
=
unzipdir
+
"
/ACTS_ZipFile_
27
00.txt
"
;
let
fd
=
fileio
.
openSync
(
path
,
0o100
|
0o2
,
0o666
);
fileio
.
write
(
fd
,
infos
).
then
(
function
(
number
)
{
console
.
info
(
"
ACTS_ZipFile_
13
00 write data to file successfully:
"
+
number
);
console
.
info
(
"
ACTS_ZipFile_
27
00 write data to file successfully:
"
+
number
);
}).
catch
(
function
(
err
)
{
console
.
info
(
"
ACTS_ZipFile_
13
00 write data to file failed with error:
"
+
err
);
console
.
info
(
"
ACTS_ZipFile_
27
00 write data to file failed with error:
"
+
err
);
});
try
{
var
options
=
{};
options
.
flush
=
zlib
.
FlushType
.
FLUSH_TYPE_PARTIAL_FLUSH
;
options
.
memLevel
=
zlib
.
MemLevel
.
MEM_LEVEL_MAX
;
await
zlib
.
zipFile
(
path
,
zipDest
,
options
,
(
err
,
data
)
=>
{
var
zipStat
=
fileio
.
statSync
(
zipDest
);
...
...
@@ -701,9 +706,9 @@ it('ACTS_ZipFile_1300', 0, async function (done) {
expect
(
srcSize
>
destSize
).
assertTrue
();
expect
(
data
).
assertEqual
(
zlib
.
ErrorCode
.
ERROR_CODE_OK
);
fileio
.
mkdir
(
unzipdir
).
then
(
function
()
{
console
.
info
(
"
ACTS_ZipFile_
13
00 mkdir successfully
"
);
console
.
info
(
"
ACTS_ZipFile_
27
00 mkdir successfully
"
);
}).
catch
(
function
(
error
)
{
console
.
info
(
"
ACTS_ZipFile_
13
00 mkdir failed with error:
"
+
error
);
console
.
info
(
"
ACTS_ZipFile_
27
00 mkdir failed with error:
"
+
error
);
});
zlib
.
unzipFile
(
zipDest
,
unzipdir
,
options
).
then
((
data
)
=>
{
var
unzipStat
=
fileio
.
statSync
(
unzipresultfile
);
...
...
@@ -714,48 +719,48 @@ it('ACTS_ZipFile_1300', 0, async function (done) {
var
result
=
(
originSize
==
destSize
);
expect
(
result
).
assertTrue
();
expect
(
data
).
assertEqual
(
zlib
.
ErrorCode
.
ERROR_CODE_OK
);
console
.
error
(
'
ACTS_ZipFile_
13
00 unzipFile
'
);
console
.
error
(
'
ACTS_ZipFile_
27
00 unzipFile
'
);
done
();
}).
catch
((
err
)
=>
{
console
.
log
(
"
ACTS_ZipFile_
13
00 err:
"
+
err
);
console
.
log
(
"
ACTS_ZipFile_
27
00 err:
"
+
err
);
done
();
})
done
();
});
}
catch
(
err
)
{
console
.
error
(
'
ACTS_ZipFile_
13
00 err:
'
+
err
);
console
.
error
(
'
ACTS_ZipFile_
27
00 err:
'
+
err
);
done
();
}
console
.
log
(
"
==================ACTS_ZipFile_
13
00 end==================
"
);
console
.
log
(
"
==================ACTS_ZipFile_
27
00 end==================
"
);
})
/*
* @tc.number: ACTS_ZipFile_
14
00
* @tc.number: ACTS_ZipFile_
28
00
* @tc.name: zipFile
* @tc.desc:
FlushType.FLUSH_TYPE_SYNC_FLUSH
* @tc.desc:
MEM_LEVEL_DEFAULT_MEMLEVEL,,
*/
it
(
'
ACTS_ZipFile_
14
00
'
,
0
,
async
function
(
done
)
{
console
.
log
(
"
==================ACTS_ZipFile_
14
00 start==================
"
);
it
(
'
ACTS_ZipFile_
28
00
'
,
0
,
async
function
(
done
)
{
console
.
log
(
"
==================ACTS_ZipFile_
28
00 start==================
"
);
let
dirfirst
=
"
/data/accounts/account_0/appdata
"
let
dirsecond
=
dirfirst
+
"
/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST
"
let
dir
=
dirsecond
+
"
/com.example.amsZipfileUnzipfileST.MainAbility/files
"
;
let
path
=
dir
+
"
/ACTS_ZipFile_
14
00.txt
"
;
var
zipDest
=
dir
+
"
/ACTS_ZipFile_
14
00.zip
"
let
path
=
dir
+
"
/ACTS_ZipFile_
28
00.txt
"
;
var
zipDest
=
dir
+
"
/ACTS_ZipFile_
28
00.zip
"
let
infos
=
path
+
dir
;
let
unzipdirfirst
=
"
/data/accounts/account_0/appdata
"
;
let
unzipdirsecond
=
unzipdirfirst
+
"
/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST
"
let
unzipdir
=
unzipdirsecond
+
"
/com.example.amsZipfileUnzipfileST.MainAbility/files/ACTS_ZipFile_
14
00
"
;
let
unzipresultfile
=
unzipdir
+
"
/ACTS_ZipFile_
14
00.txt
"
;
let
unzipdir
=
unzipdirsecond
+
"
/com.example.amsZipfileUnzipfileST.MainAbility/files/ACTS_ZipFile_
28
00
"
;
let
unzipresultfile
=
unzipdir
+
"
/ACTS_ZipFile_
28
00.txt
"
;
let
fd
=
fileio
.
openSync
(
path
,
0o100
|
0o2
,
0o666
);
fileio
.
write
(
fd
,
infos
).
then
(
function
(
number
)
{
console
.
info
(
"
ACTS_ZipFile_
14
00 write data to file successfully:
"
+
number
);
console
.
info
(
"
ACTS_ZipFile_
28
00 write data to file successfully:
"
+
number
);
}).
catch
(
function
(
err
)
{
console
.
info
(
"
ACTS_ZipFile_
14
00 write data to file failed with error:
"
+
err
);
console
.
info
(
"
ACTS_ZipFile_
28
00 write data to file failed with error:
"
+
err
);
});
try
{
var
options
=
{};
options
.
flush
=
zlib
.
FlushType
.
FLUSH_TYPE_SYNC_FLUSH
;
options
.
memLevel
=
zlib
.
MemLevel
.
MEM_LEVEL_DEFAULT
;
await
zlib
.
zipFile
(
path
,
zipDest
,
options
,
(
err
,
data
)
=>
{
var
zipStat
=
fileio
.
statSync
(
zipDest
);
...
...
@@ -766,9 +771,9 @@ it('ACTS_ZipFile_1400', 0, async function (done) {
expect
(
srcSize
>
destSize
).
assertTrue
();
expect
(
data
).
assertEqual
(
zlib
.
ErrorCode
.
ERROR_CODE_OK
);
fileio
.
mkdir
(
unzipdir
).
then
(
function
()
{
console
.
info
(
"
ACTS_ZipFile_
14
00 mkdir successfully
"
);
console
.
info
(
"
ACTS_ZipFile_
28
00 mkdir successfully
"
);
}).
catch
(
function
(
error
)
{
console
.
info
(
"
ACTS_ZipFile_
14
00 mkdir failed with error:
"
+
error
);
console
.
info
(
"
ACTS_ZipFile_
28
00 mkdir failed with error:
"
+
error
);
});
zlib
.
unzipFile
(
zipDest
,
unzipdir
,
options
).
then
((
data
)
=>
{
var
unzipStat
=
fileio
.
statSync
(
unzipresultfile
);
...
...
@@ -779,48 +784,48 @@ it('ACTS_ZipFile_1400', 0, async function (done) {
var
result
=
(
originSize
==
destSize
);
expect
(
result
).
assertTrue
();
expect
(
data
).
assertEqual
(
zlib
.
ErrorCode
.
ERROR_CODE_OK
);
console
.
error
(
'
ACTS_ZipFile_
14
00 unzipFile
'
);
console
.
error
(
'
ACTS_ZipFile_
28
00 unzipFile
'
);
done
();
}).
catch
((
err
)
=>
{
console
.
log
(
"
ACTS_ZipFile_
14
00 err:
"
+
err
);
console
.
log
(
"
ACTS_ZipFile_
28
00 err:
"
+
err
);
done
();
})
done
();
});
}
catch
(
err
)
{
console
.
error
(
'
ACTS_ZipFile_
14
00 err:
'
+
err
);
console
.
error
(
'
ACTS_ZipFile_
28
00 err:
'
+
err
);
done
();
}
console
.
log
(
"
==================ACTS_ZipFile_
14
00 end==================
"
);
console
.
log
(
"
==================ACTS_ZipFile_
28
00 end==================
"
);
})
/*
* @tc.number: ACTS_ZipFile_
15
00
* @tc.number: ACTS_ZipFile_
29
00
* @tc.name: zipFile
* @tc.desc:
FlushType.FLUSH_TYPE_FULL_FLUSH
* @tc.desc:
COMPRESS_STRATEGY_DEFAULT_STRATEGY,,
*/
it
(
'
ACTS_ZipFile_
15
00
'
,
0
,
async
function
(
done
)
{
console
.
log
(
"
==================ACTS_ZipFile_
15
00 start==================
"
);
it
(
'
ACTS_ZipFile_
29
00
'
,
0
,
async
function
(
done
)
{
console
.
log
(
"
==================ACTS_ZipFile_
29
00 start==================
"
);
let
dirfirst
=
"
/data/accounts/account_0/appdata
"
let
dirsecond
=
dirfirst
+
"
/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST
"
let
dir
=
dirsecond
+
"
/com.example.amsZipfileUnzipfileST.MainAbility/files
"
;
let
path
=
dir
+
"
/ACTS_ZipFile_
15
00.txt
"
;
var
zipDest
=
dir
+
"
/ACTS_ZipFile_
15
00.zip
"
let
path
=
dir
+
"
/ACTS_ZipFile_
29
00.txt
"
;
var
zipDest
=
dir
+
"
/ACTS_ZipFile_
29
00.zip
"
let
infos
=
path
+
dir
;
let
unzipdirfirst
=
"
/data/accounts/account_0/appdata
"
;
let
unzipdirsecond
=
unzipdirfirst
+
"
/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST
"
let
unzipdir
=
unzipdirsecond
+
"
/com.example.amsZipfileUnzipfileST.MainAbility/files/ACTS_ZipFile_
15
00
"
;
let
unzipresultfile
=
unzipdir
+
"
/ACTS_ZipFile_
15
00.txt
"
;
let
unzipdir
=
unzipdirsecond
+
"
/com.example.amsZipfileUnzipfileST.MainAbility/files/ACTS_ZipFile_
29
00
"
;
let
unzipresultfile
=
unzipdir
+
"
/ACTS_ZipFile_
29
00.txt
"
;
let
fd
=
fileio
.
openSync
(
path
,
0o100
|
0o2
,
0o666
);
fileio
.
write
(
fd
,
infos
).
then
(
function
(
number
)
{
console
.
info
(
"
ACTS_ZipFile_
15
00 write data to file successfully:
"
+
number
);
console
.
info
(
"
ACTS_ZipFile_
29
00 write data to file successfully:
"
+
number
);
}).
catch
(
function
(
err
)
{
console
.
info
(
"
ACTS_ZipFile_
15
00 write data to file failed with error:
"
+
err
);
console
.
info
(
"
ACTS_ZipFile_
29
00 write data to file failed with error:
"
+
err
);
});
try
{
var
options
=
{};
options
.
flush
=
zlib
.
FlushType
.
FLUSH_TYPE_FULL_FLUSH
;
options
.
strategy
=
zlib
.
CompressStrategy
.
COMPRESS_STRATEGY_DEFAULT_STRATEGY
;
await
zlib
.
zipFile
(
path
,
zipDest
,
options
,
(
err
,
data
)
=>
{
var
zipStat
=
fileio
.
statSync
(
zipDest
);
...
...
@@ -831,9 +836,9 @@ it('ACTS_ZipFile_1500', 0, async function (done) {
expect
(
srcSize
>
destSize
).
assertTrue
();
expect
(
data
).
assertEqual
(
zlib
.
ErrorCode
.
ERROR_CODE_OK
);
fileio
.
mkdir
(
unzipdir
).
then
(
function
()
{
console
.
info
(
"
ACTS_ZipFile_
15
00 mkdir successfully
"
);
console
.
info
(
"
ACTS_ZipFile_
29
00 mkdir successfully
"
);
}).
catch
(
function
(
error
)
{
console
.
info
(
"
ACTS_ZipFile_
15
00 mkdir failed with error:
"
+
error
);
console
.
info
(
"
ACTS_ZipFile_
29
00 mkdir failed with error:
"
+
error
);
});
zlib
.
unzipFile
(
zipDest
,
unzipdir
,
options
).
then
((
data
)
=>
{
var
unzipStat
=
fileio
.
statSync
(
unzipresultfile
);
...
...
@@ -844,48 +849,48 @@ it('ACTS_ZipFile_1500', 0, async function (done) {
var
result
=
(
originSize
==
destSize
);
expect
(
result
).
assertTrue
();
expect
(
data
).
assertEqual
(
zlib
.
ErrorCode
.
ERROR_CODE_OK
);
console
.
error
(
'
ACTS_ZipFile_
15
00 unzipFile
'
);
console
.
error
(
'
ACTS_ZipFile_
29
00 unzipFile
'
);
done
();
}).
catch
((
err
)
=>
{
console
.
log
(
"
ACTS_ZipFile_
15
00 err:
"
+
err
);
console
.
log
(
"
ACTS_ZipFile_
29
00 err:
"
+
err
);
done
();
})
done
();
});
}
catch
(
err
)
{
console
.
error
(
'
ACTS_ZipFile_
15
00 err:
'
+
err
);
console
.
error
(
'
ACTS_ZipFile_
29
00 err:
'
+
err
);
done
();
}
console
.
log
(
"
==================ACTS_ZipFile_
15
00 end==================
"
);
console
.
log
(
"
==================ACTS_ZipFile_
29
00 end==================
"
);
})
/*
* @tc.number: ACTS_ZipFile_
16
00
* @tc.number: ACTS_ZipFile_
30
00
* @tc.name: zipFile
* @tc.desc:
FlushType.FLUSH_TYPE_FINISH
* @tc.desc:
COMPRESS_STRATEGY_FILTERED,,
*/
it
(
'
ACTS_ZipFile_
16
00
'
,
0
,
async
function
(
done
)
{
console
.
log
(
"
==================ACTS_ZipFile_
16
00 start==================
"
);
it
(
'
ACTS_ZipFile_
30
00
'
,
0
,
async
function
(
done
)
{
console
.
log
(
"
==================ACTS_ZipFile_
30
00 start==================
"
);
let
dirfirst
=
"
/data/accounts/account_0/appdata
"
let
dirsecond
=
dirfirst
+
"
/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST
"
let
dir
=
dirsecond
+
"
/com.example.amsZipfileUnzipfileST.MainAbility/files
"
;
let
path
=
dir
+
"
/ACTS_ZipFile_
16
00.txt
"
;
var
zipDest
=
dir
+
"
/ACTS_ZipFile_
16
00.zip
"
let
path
=
dir
+
"
/ACTS_ZipFile_
30
00.txt
"
;
var
zipDest
=
dir
+
"
/ACTS_ZipFile_
30
00.zip
"
let
infos
=
path
+
dir
;
let
unzipdirfirst
=
"
/data/accounts/account_0/appdata
"
;
let
unzipdirsecond
=
unzipdirfirst
+
"
/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST
"
let
unzipdir
=
unzipdirsecond
+
"
/com.example.amsZipfileUnzipfileST.MainAbility/files/ACTS_ZipFile_
16
00
"
;
let
unzipresultfile
=
unzipdir
+
"
/ACTS_ZipFile_
16
00.txt
"
;
let
unzipdir
=
unzipdirsecond
+
"
/com.example.amsZipfileUnzipfileST.MainAbility/files/ACTS_ZipFile_
30
00
"
;
let
unzipresultfile
=
unzipdir
+
"
/ACTS_ZipFile_
30
00.txt
"
;
let
fd
=
fileio
.
openSync
(
path
,
0o100
|
0o2
,
0o666
);
fileio
.
write
(
fd
,
infos
).
then
(
function
(
number
)
{
console
.
info
(
"
ACTS_ZipFile_
16
00 write data to file successfully:
"
+
number
);
console
.
info
(
"
ACTS_ZipFile_
30
00 write data to file successfully:
"
+
number
);
}).
catch
(
function
(
err
)
{
console
.
info
(
"
ACTS_ZipFile_
16
00 write data to file failed with error:
"
+
err
);
console
.
info
(
"
ACTS_ZipFile_
30
00 write data to file failed with error:
"
+
err
);
});
try
{
var
options
=
{};
options
.
flush
=
zlib
.
FlushType
.
FLUSH_TYPE_FINISH
;
options
.
strategy
=
zlib
.
CompressStrategy
.
COMPRESS_STRATEGY_FILTERED
;
await
zlib
.
zipFile
(
path
,
zipDest
,
options
,
(
err
,
data
)
=>
{
var
zipStat
=
fileio
.
statSync
(
zipDest
);
...
...
@@ -896,9 +901,9 @@ it('ACTS_ZipFile_1600', 0, async function (done) {
expect
(
srcSize
>
destSize
).
assertTrue
();
expect
(
data
).
assertEqual
(
zlib
.
ErrorCode
.
ERROR_CODE_OK
);
fileio
.
mkdir
(
unzipdir
).
then
(
function
()
{
console
.
info
(
"
ACTS_ZipFile_
16
00 mkdir successfully
"
);
console
.
info
(
"
ACTS_ZipFile_
30
00 mkdir successfully
"
);
}).
catch
(
function
(
error
)
{
console
.
info
(
"
ACTS_ZipFile_
16
00 mkdir failed with error:
"
+
error
);
console
.
info
(
"
ACTS_ZipFile_
30
00 mkdir failed with error:
"
+
error
);
});
zlib
.
unzipFile
(
zipDest
,
unzipdir
,
options
).
then
((
data
)
=>
{
var
unzipStat
=
fileio
.
statSync
(
unzipresultfile
);
...
...
@@ -909,48 +914,48 @@ it('ACTS_ZipFile_1600', 0, async function (done) {
var
result
=
(
originSize
==
destSize
);
expect
(
result
).
assertTrue
();
expect
(
data
).
assertEqual
(
zlib
.
ErrorCode
.
ERROR_CODE_OK
);
console
.
error
(
'
ACTS_ZipFile_
16
00 unzipFile
'
);
console
.
error
(
'
ACTS_ZipFile_
30
00 unzipFile
'
);
done
();
}).
catch
((
err
)
=>
{
console
.
log
(
"
ACTS_ZipFile_
16
00 err:
"
+
err
);
console
.
log
(
"
ACTS_ZipFile_
30
00 err:
"
+
err
);
done
();
})
done
();
});
}
catch
(
err
)
{
console
.
error
(
'
ACTS_ZipFile_
16
00 err:
'
+
err
);
console
.
error
(
'
ACTS_ZipFile_
30
00 err:
'
+
err
);
done
();
}
console
.
log
(
"
==================ACTS_ZipFile_
16
00 end==================
"
);
console
.
log
(
"
==================ACTS_ZipFile_
30
00 end==================
"
);
})
/*
* @tc.number: ACTS_ZipFile_
17
00
* @tc.number: ACTS_ZipFile_
31
00
* @tc.name: zipFile
* @tc.desc:
FlushType.FLUSH_TYPE_BLOCK
* @tc.desc:
COMPRESS_STRATEGY_HUFFMAN_ONLY,,
*/
it
(
'
ACTS_ZipFile_
17
00
'
,
0
,
async
function
(
done
)
{
console
.
log
(
"
==================ACTS_ZipFile_
17
00 start==================
"
);
it
(
'
ACTS_ZipFile_
31
00
'
,
0
,
async
function
(
done
)
{
console
.
log
(
"
==================ACTS_ZipFile_
31
00 start==================
"
);
let
dirfirst
=
"
/data/accounts/account_0/appdata
"
let
dirsecond
=
dirfirst
+
"
/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST
"
let
dir
=
dirsecond
+
"
/com.example.amsZipfileUnzipfileST.MainAbility/files
"
;
let
path
=
dir
+
"
/ACTS_ZipFile_
17
00.txt
"
;
var
zipDest
=
dir
+
"
/ACTS_ZipFile_
17
00.zip
"
let
path
=
dir
+
"
/ACTS_ZipFile_
31
00.txt
"
;
var
zipDest
=
dir
+
"
/ACTS_ZipFile_
31
00.zip
"
let
infos
=
path
+
dir
;
let
unzipdirfirst
=
"
/data/accounts/account_0/appdata
"
;
let
unzipdirsecond
=
unzipdirfirst
+
"
/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST
"
let
unzipdir
=
unzipdirsecond
+
"
/com.example.amsZipfileUnzipfileST.MainAbility/files/ACTS_ZipFile_
17
00
"
;
let
unzipresultfile
=
unzipdir
+
"
/ACTS_ZipFile_
17
00.txt
"
;
let
unzipdir
=
unzipdirsecond
+
"
/com.example.amsZipfileUnzipfileST.MainAbility/files/ACTS_ZipFile_
31
00
"
;
let
unzipresultfile
=
unzipdir
+
"
/ACTS_ZipFile_
31
00.txt
"
;
let
fd
=
fileio
.
openSync
(
path
,
0o100
|
0o2
,
0o666
);
fileio
.
write
(
fd
,
infos
).
then
(
function
(
number
)
{
console
.
info
(
"
ACTS_ZipFile_
17
00 write data to file successfully:
"
+
number
);
console
.
info
(
"
ACTS_ZipFile_
31
00 write data to file successfully:
"
+
number
);
}).
catch
(
function
(
err
)
{
console
.
info
(
"
ACTS_ZipFile_
17
00 write data to file failed with error:
"
+
err
);
console
.
info
(
"
ACTS_ZipFile_
31
00 write data to file failed with error:
"
+
err
);
});
try
{
var
options
=
{};
options
.
flush
=
zlib
.
FlushType
.
FLUSH_TYPE_BLOCK
;
options
.
strategy
=
zlib
.
CompressStrategy
.
COMPRESS_STRATEGY_HUFFMAN_ONLY
;
await
zlib
.
zipFile
(
path
,
zipDest
,
options
,
(
err
,
data
)
=>
{
var
zipStat
=
fileio
.
statSync
(
zipDest
);
...
...
@@ -961,9 +966,9 @@ it('ACTS_ZipFile_1700', 0, async function (done) {
expect
(
srcSize
>
destSize
).
assertTrue
();
expect
(
data
).
assertEqual
(
zlib
.
ErrorCode
.
ERROR_CODE_OK
);
fileio
.
mkdir
(
unzipdir
).
then
(
function
()
{
console
.
info
(
"
ACTS_ZipFile_
17
00 mkdir successfully
"
);
console
.
info
(
"
ACTS_ZipFile_
31
00 mkdir successfully
"
);
}).
catch
(
function
(
error
)
{
console
.
info
(
"
ACTS_ZipFile_
17
00 mkdir failed with error:
"
+
error
);
console
.
info
(
"
ACTS_ZipFile_
31
00 mkdir failed with error:
"
+
error
);
});
zlib
.
unzipFile
(
zipDest
,
unzipdir
,
options
).
then
((
data
)
=>
{
var
unzipStat
=
fileio
.
statSync
(
unzipresultfile
);
...
...
@@ -974,48 +979,48 @@ it('ACTS_ZipFile_1700', 0, async function (done) {
var
result
=
(
originSize
==
destSize
);
expect
(
result
).
assertTrue
();
expect
(
data
).
assertEqual
(
zlib
.
ErrorCode
.
ERROR_CODE_OK
);
console
.
error
(
'
ACTS_ZipFile_
17
00 unzipFile
'
);
console
.
error
(
'
ACTS_ZipFile_
31
00 unzipFile
'
);
done
();
}).
catch
((
err
)
=>
{
console
.
log
(
"
ACTS_ZipFile_
17
00 err:
"
+
err
);
console
.
log
(
"
ACTS_ZipFile_
31
00 err:
"
+
err
);
done
();
})
done
();
});
}
catch
(
err
)
{
console
.
error
(
'
ACTS_ZipFile_
17
00 err:
'
+
err
);
console
.
error
(
'
ACTS_ZipFile_
31
00 err:
'
+
err
);
done
();
}
console
.
log
(
"
==================ACTS_ZipFile_
17
00 end==================
"
);
console
.
log
(
"
==================ACTS_ZipFile_
31
00 end==================
"
);
})
/*
* @tc.number: ACTS_ZipFile_
18
00
* @tc.number: ACTS_ZipFile_
32
00
* @tc.name: zipFile
* @tc.desc:
FlushType.FLUSH_TYPE_TREES
* @tc.desc:
COMPRESS_STRATEGY_RLE,,
*/
it
(
'
ACTS_ZipFile_
18
00
'
,
0
,
async
function
(
done
)
{
console
.
log
(
"
==================
FWK_ZipFile_06
00 start==================
"
);
it
(
'
ACTS_ZipFile_
32
00
'
,
0
,
async
function
(
done
)
{
console
.
log
(
"
==================
ACTS_ZipFile_32
00 start==================
"
);
let
dirfirst
=
"
/data/accounts/account_0/appdata
"
let
dirsecond
=
dirfirst
+
"
/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST
"
let
dir
=
dirsecond
+
"
/com.example.amsZipfileUnzipfileST.MainAbility/files
"
;
let
path
=
dir
+
"
/ACTS_ZipFile_
18
00.txt
"
;
var
zipDest
=
dir
+
"
/ACTS_ZipFile_
18
00.zip
"
let
path
=
dir
+
"
/ACTS_ZipFile_
32
00.txt
"
;
var
zipDest
=
dir
+
"
/ACTS_ZipFile_
32
00.zip
"
let
infos
=
path
+
dir
;
let
unzipdirfirst
=
"
/data/accounts/account_0/appdata
"
;
let
unzipdirsecond
=
unzipdirfirst
+
"
/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST
"
let
unzipdir
=
unzipdirsecond
+
"
/com.example.amsZipfileUnzipfileST.MainAbility/files/ACTS_ZipFile_
18
00
"
;
let
unzipresultfile
=
unzipdir
+
"
/ACTS_ZipFile_
18
00.txt
"
;
let
unzipdir
=
unzipdirsecond
+
"
/com.example.amsZipfileUnzipfileST.MainAbility/files/ACTS_ZipFile_
32
00
"
;
let
unzipresultfile
=
unzipdir
+
"
/ACTS_ZipFile_
32
00.txt
"
;
let
fd
=
fileio
.
openSync
(
path
,
0o100
|
0o2
,
0o666
);
fileio
.
write
(
fd
,
infos
).
then
(
function
(
number
)
{
console
.
info
(
"
ACTS_ZipFile_
18
00 write data to file successfully:
"
+
number
);
console
.
info
(
"
ACTS_ZipFile_
32
00 write data to file successfully:
"
+
number
);
}).
catch
(
function
(
err
)
{
console
.
info
(
"
ACTS_ZipFile_
18
00 write data to file failed with error:
"
+
err
);
console
.
info
(
"
ACTS_ZipFile_
32
00 write data to file failed with error:
"
+
err
);
});
try
{
var
options
=
{};
options
.
flush
=
zlib
.
FlushType
.
FLUSH_TYPE_TREES
;
options
.
strategy
=
zlib
.
CompressStrategy
.
COMPRESS_STRATEGY_RLE
;
await
zlib
.
zipFile
(
path
,
zipDest
,
options
,
(
err
,
data
)
=>
{
var
zipStat
=
fileio
.
statSync
(
zipDest
);
...
...
@@ -1026,9 +1031,9 @@ it('ACTS_ZipFile_1800', 0, async function (done) {
expect
(
srcSize
>
destSize
).
assertTrue
();
expect
(
data
).
assertEqual
(
zlib
.
ErrorCode
.
ERROR_CODE_OK
);
fileio
.
mkdir
(
unzipdir
).
then
(
function
()
{
console
.
info
(
"
ACTS_ZipFile_
18
00 mkdir successfully
"
);
console
.
info
(
"
ACTS_ZipFile_
32
00 mkdir successfully
"
);
}).
catch
(
function
(
error
)
{
console
.
info
(
"
ACTS_ZipFile_
18
00 mkdir failed with error:
"
+
error
);
console
.
info
(
"
ACTS_ZipFile_
32
00 mkdir failed with error:
"
+
error
);
});
zlib
.
unzipFile
(
zipDest
,
unzipdir
,
options
).
then
((
data
)
=>
{
var
unzipStat
=
fileio
.
statSync
(
unzipresultfile
);
...
...
@@ -1039,1302 +1044,48 @@ it('ACTS_ZipFile_1800', 0, async function (done) {
var
result
=
(
originSize
==
destSize
);
expect
(
result
).
assertTrue
();
expect
(
data
).
assertEqual
(
zlib
.
ErrorCode
.
ERROR_CODE_OK
);
console
.
error
(
'
ACTS_ZipFile_
18
00 unzipFile
'
);
console
.
error
(
'
ACTS_ZipFile_
32
00 unzipFile
'
);
done
();
}).
catch
((
err
)
=>
{
console
.
log
(
"
ACTS_ZipFile_
18
00 err:
"
+
err
);
console
.
log
(
"
ACTS_ZipFile_
32
00 err:
"
+
err
);
done
();
})
done
();
});
}
catch
(
err
)
{
console
.
error
(
'
ACTS_ZipFile_
18
00 err:
'
+
err
);
console
.
error
(
'
ACTS_ZipFile_
32
00 err:
'
+
err
);
done
();
}
console
.
log
(
"
==================ACTS_ZipFile_
18
00 end==================
"
);
console
.
log
(
"
==================ACTS_ZipFile_
32
00 end==================
"
);
})
/*
* @tc.number: ACTS_ZipFile_
19
00
* @tc.number: ACTS_ZipFile_
33
00
* @tc.name: zipFile
* @tc.desc:
chunkSize: 64
,
* @tc.desc:
COMPRESS_STRATEGY_FILTERED,
,
*/
it
(
'
ACTS_ZipFile_1900
'
,
0
,
async
function
(
done
)
{
console
.
log
(
"
==================ACTS_ZipFile_1900 start==================
"
);
let
dirfirst
=
"
/data/accounts/account_0/appdata
"
let
dirsecond
=
dirfirst
+
"
/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST
"
let
dir
=
dirsecond
+
"
/com.example.amsZipfileUnzipfileST.MainAbility/files
"
;
let
path
=
dir
+
"
/ACTS_ZipFile_1900.txt
"
;
var
zipDest
=
dir
+
"
/ACTS_ZipFile_1900.zip
"
;
let
infos
=
path
+
dir
;
let
unzipdirfirst
=
"
/data/accounts/account_0/appdata
"
;
let
unzipdirsecond
=
unzipdirfirst
+
"
/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST
"
let
unzipdir
=
unzipdirsecond
+
"
/com.example.amsZipfileUnzipfileST.MainAbility/files/ACTS_ZipFile_1900
"
;
let
unzipresultfile
=
unzipdir
+
"
/ACTS_ZipFile_1900.txt
"
;
let
fd
=
fileio
.
openSync
(
path
,
0o100
|
0o2
,
0o666
);
fileio
.
write
(
fd
,
infos
).
then
(
function
(
number
)
{
console
.
info
(
"
ACTS_ZipFile_1900 write data to file successfully:
"
+
number
);
}).
catch
(
function
(
err
)
{
console
.
info
(
"
ACTS_ZipFile_1900 write data to file failed with error:
"
+
err
);
});
try
{
var
options
=
{
chunkSize
:
64
,
};
await
zlib
.
zipFile
(
path
,
zipDest
,
options
,
(
err
,
data
)
=>
{
var
zipStat
=
fileio
.
statSync
(
zipDest
);
var
isFile
=
zipStat
.
isFile
();
expect
(
isFile
).
assertTrue
();
var
srcSize
=
fileio
.
statSync
(
path
).
size
;
var
destSize
=
zipStat
.
size
;
expect
(
srcSize
>
destSize
).
assertTrue
();
expect
(
data
).
assertEqual
(
zlib
.
ErrorCode
.
ERROR_CODE_OK
);
fileio
.
mkdir
(
unzipdir
).
then
(
function
()
{
console
.
info
(
"
ACTS_ZipFile_1900 mkdir successfully
"
);
}).
catch
(
function
(
error
)
{
console
.
info
(
"
ACTS_ZipFile_1900 mkdir failed with error:
"
+
error
);
});
zlib
.
unzipFile
(
zipDest
,
unzipdir
,
options
).
then
((
data
)
=>
{
var
unzipStat
=
fileio
.
statSync
(
unzipresultfile
);
var
isFile
=
unzipStat
.
isFile
();
expect
(
isFile
).
assertTrue
();
var
destSize
=
unzipStat
.
size
;
var
originSize
=
fileio
.
statSync
(
path
).
size
;
var
result
=
(
originSize
==
destSize
);
expect
(
result
).
assertTrue
();
expect
(
data
).
assertEqual
(
zlib
.
ErrorCode
.
ERROR_CODE_OK
);
console
.
error
(
'
ACTS_ZipFile_1900 unzipFile
'
);
done
();
}).
catch
((
err
)
=>
{
console
.
log
(
"
ACTS_ZipFile_1900 err:
"
+
err
);
done
();
})
done
();
});
}
catch
(
err
)
{
console
.
error
(
'
ACTS_ZipFile_1900 err:
'
+
err
);
done
();
}
console
.
log
(
"
==================ACTS_ZipFile_1900 end==================
"
);
})
/*
* @tc.number: ACTS_ZipFile_2000
* @tc.name: zipFile
* @tc.desc: chunkSize: 1024,
*/
it
(
'
ACTS_ZipFile_2000
'
,
0
,
async
function
(
done
)
{
console
.
log
(
"
==================ACTS_ZipFile_2000 start==================
"
);
let
dirfirst
=
"
/data/accounts/account_0/appdata
"
let
dirsecond
=
dirfirst
+
"
/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST
"
let
dir
=
dirsecond
+
"
/com.example.amsZipfileUnzipfileST.MainAbility/files
"
;
let
path
=
dir
+
"
/ACTS_ZipFile_2000.txt
"
;
var
zipDest
=
dir
+
"
/ACTS_ZipFile_2000.zip
"
let
infos
=
path
+
dir
;
let
unzipdirfirst
=
"
/data/accounts/account_0/appdata
"
;
let
unzipdirsecond
=
unzipdirfirst
+
"
/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST
"
let
unzipdir
=
unzipdirsecond
+
"
/com.example.amsZipfileUnzipfileST.MainAbility/files/ACTS_ZipFile_2000
"
;
let
unzipresultfile
=
unzipdir
+
"
/ACTS_ZipFile_2000.txt
"
;
let
fd
=
fileio
.
openSync
(
path
,
0o100
|
0o2
,
0o666
);
fileio
.
write
(
fd
,
infos
).
then
(
function
(
number
)
{
console
.
info
(
"
ACTS_ZipFile_2000 write data to file successfully:
"
+
number
);
}).
catch
(
function
(
err
)
{
console
.
info
(
"
ACTS_ZipFile_2000 write data to file failed with error:
"
+
err
);
});
try
{
var
options
=
{
chunkSize
:
1024
,
};
await
zlib
.
zipFile
(
path
,
zipDest
,
options
,
(
err
,
data
)
=>
{
var
zipStat
=
fileio
.
statSync
(
zipDest
);
var
isFile
=
zipStat
.
isFile
();
expect
(
isFile
).
assertTrue
();
var
srcSize
=
fileio
.
statSync
(
path
).
size
;
var
destSize
=
zipStat
.
size
;
expect
(
srcSize
>
destSize
).
assertTrue
();
expect
(
data
).
assertEqual
(
zlib
.
ErrorCode
.
ERROR_CODE_OK
);
fileio
.
mkdir
(
unzipdir
).
then
(
function
()
{
console
.
info
(
"
ACTS_ZipFile_2000 mkdir successfully
"
);
}).
catch
(
function
(
error
)
{
console
.
info
(
"
ACTS_ZipFile_2000 mkdir failed with error:
"
+
error
);
});
zlib
.
unzipFile
(
zipDest
,
unzipdir
,
options
).
then
((
data
)
=>
{
var
unzipStat
=
fileio
.
statSync
(
unzipresultfile
);
var
isFile
=
unzipStat
.
isFile
();
expect
(
isFile
).
assertTrue
();
var
destSize
=
unzipStat
.
size
;
var
originSize
=
fileio
.
statSync
(
path
).
size
;
var
result
=
(
originSize
==
destSize
);
expect
(
result
).
assertTrue
();
expect
(
data
).
assertEqual
(
zlib
.
ErrorCode
.
ERROR_CODE_OK
);
console
.
error
(
'
ACTS_ZipFile_2000 unzipFile
'
);
done
();
}).
catch
((
err
)
=>
{
console
.
log
(
"
ACTS_ZipFile_2000 err:
"
+
err
);
done
();
})
done
();
});
}
catch
(
err
)
{
console
.
error
(
'
ACTS_ZipFile_2000 err:
'
+
err
);
done
();
}
console
.
log
(
"
==================ACTS_ZipFile_2000 end==================
"
);
})
/*
* @tc.number: ACTS_ZipFile_2100
* @tc.name: zipFile
* @tc.desc: chunkSize: 999,
*/
it
(
'
ACTS_ZipFile_2100
'
,
0
,
async
function
(
done
)
{
console
.
log
(
"
==================ACTS_ZipFile_2100 start==================
"
);
let
dirfirst
=
"
/data/accounts/account_0/appdata
"
let
dirsecond
=
dirfirst
+
"
/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST
"
let
dir
=
dirsecond
+
"
/com.example.amsZipfileUnzipfileST.MainAbility/files
"
;
let
path
=
dir
+
"
/ACTS_ZipFile_2100.txt
"
;
var
zipDest
=
dir
+
"
/ACTS_ZipFile_2100.zip
"
let
infos
=
path
+
dir
;
let
unzipdirfirst
=
"
/data/accounts/account_0/appdata
"
;
let
unzipdirsecond
=
unzipdirfirst
+
"
/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST
"
let
unzipdir
=
unzipdirsecond
+
"
/com.example.amsZipfileUnzipfileST.MainAbility/files/ACTS_ZipFile_2100
"
;
let
unzipresultfile
=
unzipdir
+
"
/ACTS_ZipFile_2100.txt
"
;
let
fd
=
fileio
.
openSync
(
path
,
0o100
|
0o2
,
0o666
);
fileio
.
write
(
fd
,
infos
).
then
(
function
(
number
)
{
console
.
info
(
"
ACTS_ZipFile_2100 write data to file successfully:
"
+
number
);
}).
catch
(
function
(
err
)
{
console
.
info
(
"
ACTS_ZipFile_2100 write data to file failed with error:
"
+
err
);
});
try
{
var
options
=
{
chunkSize
:
999
,
};
await
zlib
.
zipFile
(
path
,
zipDest
,
options
,
(
err
,
data
)
=>
{
var
zipStat
=
fileio
.
statSync
(
zipDest
);
var
isFile
=
zipStat
.
isFile
();
expect
(
isFile
).
assertTrue
();
var
srcSize
=
fileio
.
statSync
(
path
).
size
;
var
destSize
=
zipStat
.
size
;
expect
(
srcSize
>
destSize
).
assertTrue
();
expect
(
data
).
assertEqual
(
zlib
.
ErrorCode
.
ERROR_CODE_OK
);
fileio
.
mkdir
(
unzipdir
).
then
(
function
()
{
console
.
info
(
"
ACTS_ZipFile_2100 mkdir successfully
"
);
}).
catch
(
function
(
error
)
{
console
.
info
(
"
ACTS_ZipFile_2100 mkdir failed with error:
"
+
error
);
});
zlib
.
unzipFile
(
zipDest
,
unzipdir
,
options
).
then
((
data
)
=>
{
var
unzipStat
=
fileio
.
statSync
(
unzipresultfile
);
var
isFile
=
unzipStat
.
isFile
();
expect
(
isFile
).
assertTrue
();
var
destSize
=
unzipStat
.
size
;
var
originSize
=
fileio
.
statSync
(
path
).
size
;
var
result
=
(
originSize
==
destSize
);
expect
(
result
).
assertTrue
();
expect
(
data
).
assertEqual
(
zlib
.
ErrorCode
.
ERROR_CODE_OK
);
console
.
error
(
'
ACTS_ZipFile_2100 unzipFile
'
);
done
();
}).
catch
((
err
)
=>
{
console
.
log
(
"
ACTS_ZipFile_2100 err:
"
+
err
);
done
();
})
done
();
});
}
catch
(
err
)
{
console
.
error
(
'
ACTS_ZipFile_2100 err:
'
+
err
);
done
();
}
console
.
log
(
"
==================ACTS_ZipFile_2100 end==================
"
);
})
/*
* @tc.number: ACTS_ZipFile_2200
* @tc.name: zipFile
* @tc.desc: COMPRESS_LEVEL_NO_COMPRESSION,
*/
it
(
'
ACTS_ZipFile_2200
'
,
0
,
async
function
(
done
)
{
console
.
log
(
"
==================ACTS_ZipFile_2200 start==================
"
);
let
dirfirst
=
"
/data/accounts/account_0/appdata
"
let
dirsecond
=
dirfirst
+
"
/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST
"
let
dir
=
dirsecond
+
"
/com.example.amsZipfileUnzipfileST.MainAbility/files
"
;
let
path
=
dir
+
"
/ACTS_ZipFile_2200.txt
"
;
var
zipDest
=
dir
+
"
/ACTS_ZipFile_2200.zip
"
let
infos
=
path
+
dir
;
let
unzipdirfirst
=
"
/data/accounts/account_0/appdata
"
;
let
unzipdirsecond
=
unzipdirfirst
+
"
/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST
"
let
unzipdir
=
unzipdirsecond
+
"
/com.example.amsZipfileUnzipfileST.MainAbility/files/ACTS_ZipFile_2200
"
;
let
unzipresultfile
=
unzipdir
+
"
/ACTS_ZipFile_2200.txt
"
;
let
fd
=
fileio
.
openSync
(
path
,
0o100
|
0o2
,
0o666
);
fileio
.
write
(
fd
,
infos
).
then
(
function
(
number
)
{
console
.
info
(
"
ACTS_ZipFile_2200 write data to file successfully:
"
+
number
);
}).
catch
(
function
(
err
)
{
console
.
info
(
"
ACTS_ZipFile_2200 write data to file failed with error:
"
+
err
);
});
try
{
var
options
=
{};
options
.
level
=
zlib
.
CompressLevel
.
COMPRESS_LEVEL_NO_COMPRESSION
;
await
zlib
.
zipFile
(
path
,
zipDest
,
options
,
(
err
,
data
)
=>
{
var
zipStat
=
fileio
.
statSync
(
zipDest
);
var
isFile
=
zipStat
.
isFile
();
expect
(
isFile
).
assertTrue
();
var
srcSize
=
fileio
.
statSync
(
path
).
size
;
var
destSize
=
zipStat
.
size
;
expect
(
srcSize
>
destSize
).
assertTrue
();
expect
(
data
).
assertEqual
(
zlib
.
ErrorCode
.
ERROR_CODE_OK
);
fileio
.
mkdir
(
unzipdir
).
then
(
function
()
{
console
.
info
(
"
ACTS_ZipFile_2200 mkdir successfully
"
);
}).
catch
(
function
(
error
)
{
console
.
info
(
"
ACTS_ZipFile_2200 mkdir failed with error:
"
+
error
);
});
zlib
.
unzipFile
(
zipDest
,
unzipdir
,
options
).
then
((
data
)
=>
{
var
unzipStat
=
fileio
.
statSync
(
unzipresultfile
);
var
isFile
=
unzipStat
.
isFile
();
expect
(
isFile
).
assertTrue
();
var
destSize
=
unzipStat
.
size
;
var
originSize
=
fileio
.
statSync
(
path
).
size
;
var
result
=
(
originSize
==
destSize
);
expect
(
result
).
assertTrue
();
expect
(
data
).
assertEqual
(
zlib
.
ErrorCode
.
ERROR_CODE_OK
);
console
.
error
(
'
ACTS_ZipFile_2200 unzipFile
'
);
done
();
}).
catch
((
err
)
=>
{
console
.
log
(
"
ACTS_ZipFile_2200 err:
"
+
err
);
done
();
})
done
();
});
}
catch
(
err
)
{
console
.
error
(
'
ACTS_ZipFile_2200 err:
'
+
err
);
done
();
}
console
.
log
(
"
==================ACTS_ZipFile_2200 end==================
"
);
})
/*
* @tc.number: ACTS_ZipFile_2300
* @tc.name: zipFile
* @tc.desc: COMPRESS_LEVEL_BEST_SPEED,
*/
it
(
'
ACTS_ZipFile_2300
'
,
0
,
async
function
(
done
)
{
console
.
log
(
"
==================ACTS_ZipFile_2300 start==================
"
);
let
dirfirst
=
"
/data/accounts/account_0/appdata
"
let
dirsecond
=
dirfirst
+
"
/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST
"
let
dir
=
dirsecond
+
"
/com.example.amsZipfileUnzipfileST.MainAbility/files
"
;
let
path
=
dir
+
"
/ACTS_ZipFile_2300.txt
"
;
var
zipDest
=
dir
+
"
/ACTS_ZipFile_2300.zip
"
let
infos
=
path
+
dir
;
let
unzipdirfirst
=
"
/data/accounts/account_0/appdata
"
;
let
unzipdirsecond
=
unzipdirfirst
+
"
/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST
"
let
unzipdir
=
unzipdirsecond
+
"
/com.example.amsZipfileUnzipfileST.MainAbility/files/ACTS_ZipFile_2300
"
;
let
unzipresultfile
=
unzipdir
+
"
/ACTS_ZipFile_2300.txt
"
;
let
fd
=
fileio
.
openSync
(
path
,
0o100
|
0o2
,
0o666
);
fileio
.
write
(
fd
,
infos
).
then
(
function
(
number
)
{
console
.
info
(
"
ACTS_ZipFile_2300 write data to file successfully:
"
+
number
);
}).
catch
(
function
(
err
)
{
console
.
info
(
"
ACTS_ZipFile_2300 write data to file failed with error:
"
+
err
);
});
try
{
var
options
=
{};
options
.
level
=
zlib
.
CompressLevel
.
COMPRESS_LEVEL_BEST_SPEED
;
await
zlib
.
zipFile
(
path
,
zipDest
,
options
,
(
err
,
data
)
=>
{
var
zipStat
=
fileio
.
statSync
(
zipDest
);
var
isFile
=
zipStat
.
isFile
();
expect
(
isFile
).
assertTrue
();
var
srcSize
=
fileio
.
statSync
(
path
).
size
;
var
destSize
=
zipStat
.
size
;
expect
(
srcSize
>
destSize
).
assertTrue
();
expect
(
data
).
assertEqual
(
zlib
.
ErrorCode
.
ERROR_CODE_OK
);
fileio
.
mkdir
(
unzipdir
).
then
(
function
()
{
console
.
info
(
"
ACTS_ZipFile_2300 mkdir successfully
"
);
}).
catch
(
function
(
error
)
{
console
.
info
(
"
ACTS_ZipFile_2300 mkdir failed with error:
"
+
error
);
});
zlib
.
unzipFile
(
zipDest
,
unzipdir
,
options
).
then
((
data
)
=>
{
var
unzipStat
=
fileio
.
statSync
(
unzipresultfile
);
var
isFile
=
unzipStat
.
isFile
();
expect
(
isFile
).
assertTrue
();
var
destSize
=
unzipStat
.
size
;
var
originSize
=
fileio
.
statSync
(
path
).
size
;
var
result
=
(
originSize
==
destSize
);
expect
(
result
).
assertTrue
();
expect
(
data
).
assertEqual
(
zlib
.
ErrorCode
.
ERROR_CODE_OK
);
console
.
error
(
'
ACTS_ZipFile_2300 unzipFile
'
);
done
();
}).
catch
((
err
)
=>
{
console
.
log
(
"
ACTS_ZipFile_2300 err:
"
+
err
);
done
();
})
done
();
});
}
catch
(
err
)
{
console
.
error
(
'
ACTS_ZipFile_2300 err:
'
+
err
);
done
();
}
console
.
log
(
"
==================ACTS_ZipFile_2300 end==================
"
);
})
/*
* @tc.number: ACTS_ZipFile_2400
* @tc.name: zipFile
* @tc.desc: COMPRESS_LEVEL_BEST_COMPRESSION,
*/
it
(
'
ACTS_ZipFile_2400
'
,
0
,
async
function
(
done
)
{
console
.
log
(
"
==================ACTS_ZipFile_2400 start==================
"
);
let
dirfirst
=
"
/data/accounts/account_0/appdata
"
let
dirsecond
=
dirfirst
+
"
/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST
"
let
dir
=
dirsecond
+
"
/com.example.amsZipfileUnzipfileST.MainAbility/files
"
;
let
path
=
dir
+
"
/ACTS_ZipFile_2400.txt
"
;
var
zipDest
=
dir
+
"
/ACTS_ZipFile_2400.zip
"
let
infos
=
path
+
dir
;
let
unzipdirfirst
=
"
/data/accounts/account_0/appdata
"
;
let
unzipdirsecond
=
unzipdirfirst
+
"
/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST
"
let
unzipdir
=
unzipdirsecond
+
"
/com.example.amsZipfileUnzipfileST.MainAbility/files/ACTS_ZipFile_2400
"
;
let
unzipresultfile
=
unzipdir
+
"
/ACTS_ZipFile_2400.txt
"
;
let
fd
=
fileio
.
openSync
(
path
,
0o100
|
0o2
,
0o666
);
fileio
.
write
(
fd
,
infos
).
then
(
function
(
number
)
{
console
.
info
(
"
ACTS_ZipFile_2400 write data to file successfully:
"
+
number
);
}).
catch
(
function
(
err
)
{
console
.
info
(
"
ACTS_ZipFile_2400 write data to file failed with error:
"
+
err
);
});
try
{
var
options
=
{};
options
.
level
=
zlib
.
CompressLevel
.
COMPRESS_LEVEL_BEST_COMPRESSION
;
await
zlib
.
zipFile
(
path
,
zipDest
,
options
,
(
err
,
data
)
=>
{
var
zipStat
=
fileio
.
statSync
(
zipDest
);
var
isFile
=
zipStat
.
isFile
();
expect
(
isFile
).
assertTrue
();
var
srcSize
=
fileio
.
statSync
(
path
).
size
;
var
destSize
=
zipStat
.
size
;
expect
(
srcSize
>
destSize
).
assertTrue
();
expect
(
data
).
assertEqual
(
zlib
.
ErrorCode
.
ERROR_CODE_OK
);
fileio
.
mkdir
(
unzipdir
).
then
(
function
()
{
console
.
info
(
"
ACTS_ZipFile_2400 mkdir successfully
"
);
}).
catch
(
function
(
error
)
{
console
.
info
(
"
ACTS_ZipFile_2400 mkdir failed with error:
"
+
error
);
});
zlib
.
unzipFile
(
zipDest
,
unzipdir
,
options
).
then
((
data
)
=>
{
var
unzipStat
=
fileio
.
statSync
(
unzipresultfile
);
var
isFile
=
unzipStat
.
isFile
();
expect
(
isFile
).
assertTrue
();
var
destSize
=
unzipStat
.
size
;
var
originSize
=
fileio
.
statSync
(
path
).
size
;
var
result
=
(
originSize
==
destSize
);
expect
(
result
).
assertTrue
();
expect
(
data
).
assertEqual
(
zlib
.
ErrorCode
.
ERROR_CODE_OK
);
console
.
error
(
'
ACTS_ZipFile_2400 unzipFile
'
);
done
();
}).
catch
((
err
)
=>
{
console
.
log
(
"
ACTS_ZipFile_2400 err:
"
+
err
);
done
();
})
done
();
});
}
catch
(
err
)
{
console
.
error
(
'
ACTS_ZipFile_2400 err:
'
+
err
);
done
();
}
console
.
log
(
"
==================ACTS_ZipFile_2400 end==================
"
);
})
/*
* @tc.number: ACTS_ZipFile_2500
* @tc.name: zipFile
* @tc.desc: COMPRESS_LEVEL_DEFAULT_COMPRESSION,
*/
it
(
'
ACTS_ZipFile_2500
'
,
0
,
async
function
(
done
)
{
console
.
log
(
"
==================ACTS_ZipFile_2500 start==================
"
);
let
dirfirst
=
"
/data/accounts/account_0/appdata
"
let
dirsecond
=
dirfirst
+
"
/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST
"
let
dir
=
dirsecond
+
"
/com.example.amsZipfileUnzipfileST.MainAbility/files
"
;
let
path
=
dir
+
"
/ACTS_ZipFile_2500.txt
"
;
var
zipDest
=
dir
+
"
/ACTS_ZipFile_2500.zip
"
let
infos
=
path
+
dir
;
let
unzipdirfirst
=
"
/data/accounts/account_0/appdata
"
;
let
unzipdirsecond
=
unzipdirfirst
+
"
/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST
"
let
unzipdir
=
unzipdirsecond
+
"
/com.example.amsZipfileUnzipfileST.MainAbility/files/ACTS_ZipFile_2500
"
;
let
unzipresultfile
=
unzipdir
+
"
/ACTS_ZipFile_2500.txt
"
;
let
fd
=
fileio
.
openSync
(
path
,
0o100
|
0o2
,
0o666
);
fileio
.
write
(
fd
,
infos
).
then
(
function
(
number
)
{
console
.
info
(
"
ACTS_ZipFile_2500 write data to file successfully:
"
+
number
);
}).
catch
(
function
(
err
)
{
console
.
info
(
"
ACTS_ZipFile_2500 write data to file failed with error:
"
+
err
);
});
try
{
var
options
=
{};
options
.
level
=
zlib
.
CompressLevel
.
COMPRESS_LEVEL_DEFAULT_COMPRESSION
;
await
zlib
.
zipFile
(
path
,
zipDest
,
options
,
(
err
,
data
)
=>
{
var
zipStat
=
fileio
.
statSync
(
zipDest
);
var
isFile
=
zipStat
.
isFile
();
expect
(
isFile
).
assertTrue
();
var
srcSize
=
fileio
.
statSync
(
path
).
size
;
var
destSize
=
zipStat
.
size
;
expect
(
srcSize
>
destSize
).
assertTrue
();
expect
(
data
).
assertEqual
(
zlib
.
ErrorCode
.
ERROR_CODE_OK
);
fileio
.
mkdir
(
unzipdir
).
then
(
function
()
{
console
.
info
(
"
ACTS_ZipFile_2500 mkdir successfully
"
);
}).
catch
(
function
(
error
)
{
console
.
info
(
"
ACTS_ZipFile_2500 mkdir failed with error:
"
+
error
);
});
zlib
.
unzipFile
(
zipDest
,
unzipdir
,
options
).
then
((
data
)
=>
{
var
unzipStat
=
fileio
.
statSync
(
unzipresultfile
);
var
isFile
=
unzipStat
.
isFile
();
expect
(
isFile
).
assertTrue
();
var
destSize
=
unzipStat
.
size
;
var
originSize
=
fileio
.
statSync
(
path
).
size
;
var
result
=
(
originSize
==
destSize
);
expect
(
result
).
assertTrue
();
expect
(
data
).
assertEqual
(
zlib
.
ErrorCode
.
ERROR_CODE_OK
);
console
.
error
(
'
ACTS_ZipFile_2500 unzipFile
'
);
done
();
}).
catch
((
err
)
=>
{
console
.
log
(
"
ACTS_ZipFile_2500 err:
"
+
err
);
done
();
})
done
();
});
}
catch
(
err
)
{
console
.
error
(
'
ACTS_ZipFile_2500 err:
'
+
err
);
done
();
}
console
.
log
(
"
==================ACTS_ZipFile_2500 end==================
"
);
})
/*
* @tc.number: ACTS_ZipFile_2600
* @tc.name: zipFile
* @tc.desc: MEM_LEVEL_MIN_MEMLEVEL,,
*/
it
(
'
ACTS_ZipFile_2600
'
,
0
,
async
function
(
done
)
{
console
.
log
(
"
==================ACTS_ZipFile_2600 start==================
"
);
let
dirfirst
=
"
/data/accounts/account_0/appdata
"
let
dirsecond
=
dirfirst
+
"
/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST
"
let
dir
=
dirsecond
+
"
/com.example.amsZipfileUnzipfileST.MainAbility/files
"
;
let
path
=
dir
+
"
/ACTS_ZipFile_2600.txt
"
;
var
zipDest
=
dir
+
"
/ACTS_ZipFile_2600.zip
"
let
infos
=
path
+
dir
;
let
unzipdirfirst
=
"
/data/accounts/account_0/appdata
"
;
let
unzipdirsecond
=
unzipdirfirst
+
"
/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST
"
let
unzipdir
=
unzipdirsecond
+
"
/com.example.amsZipfileUnzipfileST.MainAbility/files/ACTS_ZipFile_2600
"
;
let
unzipresultfile
=
unzipdir
+
"
/ACTS_ZipFile_2600.txt
"
;
let
fd
=
fileio
.
openSync
(
path
,
0o100
|
0o2
,
0o666
);
fileio
.
write
(
fd
,
infos
).
then
(
function
(
number
)
{
console
.
info
(
"
ACTS_ZipFile_2600 write data to file successfully:
"
+
number
);
}).
catch
(
function
(
err
)
{
console
.
info
(
"
ACTS_ZipFile_2600 write data to file failed with error:
"
+
err
);
});
try
{
var
options
=
{};
options
.
memLevel
=
zlib
.
MemLevel
.
MEM_LEVEL_MIN
;
await
zlib
.
zipFile
(
path
,
zipDest
,
options
,
(
err
,
data
)
=>
{
var
zipStat
=
fileio
.
statSync
(
zipDest
);
var
isFile
=
zipStat
.
isFile
();
expect
(
isFile
).
assertTrue
();
var
srcSize
=
fileio
.
statSync
(
path
).
size
;
var
destSize
=
zipStat
.
size
;
expect
(
srcSize
>
destSize
).
assertTrue
();
expect
(
data
).
assertEqual
(
zlib
.
ErrorCode
.
ERROR_CODE_OK
);
fileio
.
mkdir
(
unzipdir
).
then
(
function
()
{
console
.
info
(
"
ACTS_ZipFile_2600 mkdir successfully
"
);
}).
catch
(
function
(
error
)
{
console
.
info
(
"
ACTS_ZipFile_2600 mkdir failed with error:
"
+
error
);
});
zlib
.
unzipFile
(
zipDest
,
unzipdir
,
options
).
then
((
data
)
=>
{
var
unzipStat
=
fileio
.
statSync
(
unzipresultfile
);
var
isFile
=
unzipStat
.
isFile
();
expect
(
isFile
).
assertTrue
();
var
destSize
=
unzipStat
.
size
;
var
originSize
=
fileio
.
statSync
(
path
).
size
;
var
result
=
(
originSize
==
destSize
);
expect
(
result
).
assertTrue
();
expect
(
data
).
assertEqual
(
zlib
.
ErrorCode
.
ERROR_CODE_OK
);
console
.
error
(
'
ACTS_ZipFile_2600 unzipFile
'
);
done
();
}).
catch
((
err
)
=>
{
console
.
log
(
"
ACTS_ZipFile_2600 err:
"
+
err
);
done
();
})
done
();
});
}
catch
(
err
)
{
console
.
error
(
'
ACTS_ZipFile_2600 err:
'
+
err
);
done
();
}
console
.
log
(
"
==================ACTS_ZipFile_2600 end==================
"
);
})
/*
* @tc.number: ACTS_ZipFile_2700
* @tc.name: zipFile
* @tc.desc: MEM_LEVEL_MAX_MEMLEVEL,,
*/
it
(
'
ACTS_ZipFile_2700
'
,
0
,
async
function
(
done
)
{
console
.
log
(
"
==================ACTS_ZipFile_2700 start==================
"
);
let
dirfirst
=
"
/data/accounts/account_0/appdata
"
let
dirsecond
=
dirfirst
+
"
/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST
"
let
dir
=
dirsecond
+
"
/com.example.amsZipfileUnzipfileST.MainAbility/files
"
;
let
path
=
dir
+
"
/ACTS_ZipFile_2700.txt
"
;
var
zipDest
=
dir
+
"
/ACTS_ZipFile_2700.zip
"
let
infos
=
path
+
dir
;
let
unzipdirfirst
=
"
/data/accounts/account_0/appdata
"
;
let
unzipdirsecond
=
unzipdirfirst
+
"
/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST
"
let
unzipdir
=
unzipdirsecond
+
"
/com.example.amsZipfileUnzipfileST.MainAbility/files/ACTS_ZipFile_2700
"
;
let
unzipresultfile
=
unzipdir
+
"
/ACTS_ZipFile_2700.txt
"
;
let
fd
=
fileio
.
openSync
(
path
,
0o100
|
0o2
,
0o666
);
fileio
.
write
(
fd
,
infos
).
then
(
function
(
number
)
{
console
.
info
(
"
ACTS_ZipFile_2700 write data to file successfully:
"
+
number
);
}).
catch
(
function
(
err
)
{
console
.
info
(
"
ACTS_ZipFile_2700 write data to file failed with error:
"
+
err
);
});
try
{
var
options
=
{};
options
.
memLevel
=
zlib
.
MemLevel
.
MEM_LEVEL_MAX
;
await
zlib
.
zipFile
(
path
,
zipDest
,
options
,
(
err
,
data
)
=>
{
var
zipStat
=
fileio
.
statSync
(
zipDest
);
var
isFile
=
zipStat
.
isFile
();
expect
(
isFile
).
assertTrue
();
var
srcSize
=
fileio
.
statSync
(
path
).
size
;
var
destSize
=
zipStat
.
size
;
expect
(
srcSize
>
destSize
).
assertTrue
();
expect
(
data
).
assertEqual
(
zlib
.
ErrorCode
.
ERROR_CODE_OK
);
fileio
.
mkdir
(
unzipdir
).
then
(
function
()
{
console
.
info
(
"
ACTS_ZipFile_2700 mkdir successfully
"
);
}).
catch
(
function
(
error
)
{
console
.
info
(
"
ACTS_ZipFile_2700 mkdir failed with error:
"
+
error
);
});
zlib
.
unzipFile
(
zipDest
,
unzipdir
,
options
).
then
((
data
)
=>
{
var
unzipStat
=
fileio
.
statSync
(
unzipresultfile
);
var
isFile
=
unzipStat
.
isFile
();
expect
(
isFile
).
assertTrue
();
var
destSize
=
unzipStat
.
size
;
var
originSize
=
fileio
.
statSync
(
path
).
size
;
var
result
=
(
originSize
==
destSize
);
expect
(
result
).
assertTrue
();
expect
(
data
).
assertEqual
(
zlib
.
ErrorCode
.
ERROR_CODE_OK
);
console
.
error
(
'
ACTS_ZipFile_2700 unzipFile
'
);
done
();
}).
catch
((
err
)
=>
{
console
.
log
(
"
ACTS_ZipFile_2700 err:
"
+
err
);
done
();
})
done
();
});
}
catch
(
err
)
{
console
.
error
(
'
ACTS_ZipFile_2700 err:
'
+
err
);
done
();
}
console
.
log
(
"
==================ACTS_ZipFile_2700 end==================
"
);
})
/*
* @tc.number: ACTS_ZipFile_2800
* @tc.name: zipFile
* @tc.desc: MEM_LEVEL_DEFAULT_MEMLEVEL,,
*/
it
(
'
ACTS_ZipFile_2800
'
,
0
,
async
function
(
done
)
{
console
.
log
(
"
==================ACTS_ZipFile_2800 start==================
"
);
let
dirfirst
=
"
/data/accounts/account_0/appdata
"
let
dirsecond
=
dirfirst
+
"
/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST
"
let
dir
=
dirsecond
+
"
/com.example.amsZipfileUnzipfileST.MainAbility/files
"
;
let
path
=
dir
+
"
/ACTS_ZipFile_2800.txt
"
;
var
zipDest
=
dir
+
"
/ACTS_ZipFile_2800.zip
"
let
infos
=
path
+
dir
;
let
unzipdirfirst
=
"
/data/accounts/account_0/appdata
"
;
let
unzipdirsecond
=
unzipdirfirst
+
"
/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST
"
let
unzipdir
=
unzipdirsecond
+
"
/com.example.amsZipfileUnzipfileST.MainAbility/files/ACTS_ZipFile_2800
"
;
let
unzipresultfile
=
unzipdir
+
"
/ACTS_ZipFile_2800.txt
"
;
let
fd
=
fileio
.
openSync
(
path
,
0o100
|
0o2
,
0o666
);
fileio
.
write
(
fd
,
infos
).
then
(
function
(
number
)
{
console
.
info
(
"
ACTS_ZipFile_2800 write data to file successfully:
"
+
number
);
}).
catch
(
function
(
err
)
{
console
.
info
(
"
ACTS_ZipFile_2800 write data to file failed with error:
"
+
err
);
});
try
{
var
options
=
{};
options
.
memLevel
=
zlib
.
MemLevel
.
MEM_LEVEL_DEFAULT
;
await
zlib
.
zipFile
(
path
,
zipDest
,
options
,
(
err
,
data
)
=>
{
var
zipStat
=
fileio
.
statSync
(
zipDest
);
var
isFile
=
zipStat
.
isFile
();
expect
(
isFile
).
assertTrue
();
var
srcSize
=
fileio
.
statSync
(
path
).
size
;
var
destSize
=
zipStat
.
size
;
expect
(
srcSize
>
destSize
).
assertTrue
();
expect
(
data
).
assertEqual
(
zlib
.
ErrorCode
.
ERROR_CODE_OK
);
fileio
.
mkdir
(
unzipdir
).
then
(
function
()
{
console
.
info
(
"
ACTS_ZipFile_2800 mkdir successfully
"
);
}).
catch
(
function
(
error
)
{
console
.
info
(
"
ACTS_ZipFile_2800 mkdir failed with error:
"
+
error
);
});
zlib
.
unzipFile
(
zipDest
,
unzipdir
,
options
).
then
((
data
)
=>
{
var
unzipStat
=
fileio
.
statSync
(
unzipresultfile
);
var
isFile
=
unzipStat
.
isFile
();
expect
(
isFile
).
assertTrue
();
var
destSize
=
unzipStat
.
size
;
var
originSize
=
fileio
.
statSync
(
path
).
size
;
var
result
=
(
originSize
==
destSize
);
expect
(
result
).
assertTrue
();
expect
(
data
).
assertEqual
(
zlib
.
ErrorCode
.
ERROR_CODE_OK
);
console
.
error
(
'
ACTS_ZipFile_2800 unzipFile
'
);
done
();
}).
catch
((
err
)
=>
{
console
.
log
(
"
ACTS_ZipFile_2800 err:
"
+
err
);
done
();
})
done
();
});
}
catch
(
err
)
{
console
.
error
(
'
ACTS_ZipFile_2800 err:
'
+
err
);
done
();
}
console
.
log
(
"
==================ACTS_ZipFile_2800 end==================
"
);
})
/*
* @tc.number: ACTS_ZipFile_2900
* @tc.name: zipFile
* @tc.desc: COMPRESS_STRATEGY_DEFAULT_STRATEGY,,
*/
it
(
'
ACTS_ZipFile_2900
'
,
0
,
async
function
(
done
)
{
console
.
log
(
"
==================ACTS_ZipFile_2900 start==================
"
);
let
dirfirst
=
"
/data/accounts/account_0/appdata
"
let
dirsecond
=
dirfirst
+
"
/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST
"
let
dir
=
dirsecond
+
"
/com.example.amsZipfileUnzipfileST.MainAbility/files
"
;
let
path
=
dir
+
"
/ACTS_ZipFile_2900.txt
"
;
var
zipDest
=
dir
+
"
/ACTS_ZipFile_2900.zip
"
let
infos
=
path
+
dir
;
let
unzipdirfirst
=
"
/data/accounts/account_0/appdata
"
;
let
unzipdirsecond
=
unzipdirfirst
+
"
/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST
"
let
unzipdir
=
unzipdirsecond
+
"
/com.example.amsZipfileUnzipfileST.MainAbility/files/ACTS_ZipFile_2900
"
;
let
unzipresultfile
=
unzipdir
+
"
/ACTS_ZipFile_2900.txt
"
;
let
fd
=
fileio
.
openSync
(
path
,
0o100
|
0o2
,
0o666
);
fileio
.
write
(
fd
,
infos
).
then
(
function
(
number
)
{
console
.
info
(
"
ACTS_ZipFile_2900 write data to file successfully:
"
+
number
);
}).
catch
(
function
(
err
)
{
console
.
info
(
"
ACTS_ZipFile_2900 write data to file failed with error:
"
+
err
);
});
try
{
var
options
=
{};
options
.
strategy
=
zlib
.
CompressStrategy
.
COMPRESS_STRATEGY_DEFAULT_STRATEGY
;
await
zlib
.
zipFile
(
path
,
zipDest
,
options
,
(
err
,
data
)
=>
{
var
zipStat
=
fileio
.
statSync
(
zipDest
);
var
isFile
=
zipStat
.
isFile
();
expect
(
isFile
).
assertTrue
();
var
srcSize
=
fileio
.
statSync
(
path
).
size
;
var
destSize
=
zipStat
.
size
;
expect
(
srcSize
>
destSize
).
assertTrue
();
expect
(
data
).
assertEqual
(
zlib
.
ErrorCode
.
ERROR_CODE_OK
);
fileio
.
mkdir
(
unzipdir
).
then
(
function
()
{
console
.
info
(
"
ACTS_ZipFile_2900 mkdir successfully
"
);
}).
catch
(
function
(
error
)
{
console
.
info
(
"
ACTS_ZipFile_2900 mkdir failed with error:
"
+
error
);
});
zlib
.
unzipFile
(
zipDest
,
unzipdir
,
options
).
then
((
data
)
=>
{
var
unzipStat
=
fileio
.
statSync
(
unzipresultfile
);
var
isFile
=
unzipStat
.
isFile
();
expect
(
isFile
).
assertTrue
();
var
destSize
=
unzipStat
.
size
;
var
originSize
=
fileio
.
statSync
(
path
).
size
;
var
result
=
(
originSize
==
destSize
);
expect
(
result
).
assertTrue
();
expect
(
data
).
assertEqual
(
zlib
.
ErrorCode
.
ERROR_CODE_OK
);
console
.
error
(
'
ACTS_ZipFile_2900 unzipFile
'
);
done
();
}).
catch
((
err
)
=>
{
console
.
log
(
"
ACTS_ZipFile_2900 err:
"
+
err
);
done
();
})
done
();
});
}
catch
(
err
)
{
console
.
error
(
'
ACTS_ZipFile_2900 err:
'
+
err
);
done
();
}
console
.
log
(
"
==================ACTS_ZipFile_2900 end==================
"
);
})
/*
* @tc.number: ACTS_ZipFile_3000
* @tc.name: zipFile
* @tc.desc: COMPRESS_STRATEGY_FILTERED,,
*/
it
(
'
ACTS_ZipFile_3000
'
,
0
,
async
function
(
done
)
{
console
.
log
(
"
==================ACTS_ZipFile_3000 start==================
"
);
let
dirfirst
=
"
/data/accounts/account_0/appdata
"
let
dirsecond
=
dirfirst
+
"
/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST
"
let
dir
=
dirsecond
+
"
/com.example.amsZipfileUnzipfileST.MainAbility/files
"
;
let
path
=
dir
+
"
/ACTS_ZipFile_3000.txt
"
;
var
zipDest
=
dir
+
"
/ACTS_ZipFile_3000.zip
"
let
infos
=
path
+
dir
;
let
unzipdirfirst
=
"
/data/accounts/account_0/appdata
"
;
let
unzipdirsecond
=
unzipdirfirst
+
"
/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST
"
let
unzipdir
=
unzipdirsecond
+
"
/com.example.amsZipfileUnzipfileST.MainAbility/files/ACTS_ZipFile_3000
"
;
let
unzipresultfile
=
unzipdir
+
"
/ACTS_ZipFile_3000.txt
"
;
let
fd
=
fileio
.
openSync
(
path
,
0o100
|
0o2
,
0o666
);
fileio
.
write
(
fd
,
infos
).
then
(
function
(
number
)
{
console
.
info
(
"
ACTS_ZipFile_3000 write data to file successfully:
"
+
number
);
}).
catch
(
function
(
err
)
{
console
.
info
(
"
ACTS_ZipFile_3000 write data to file failed with error:
"
+
err
);
});
try
{
var
options
=
{};
options
.
strategy
=
zlib
.
CompressStrategy
.
COMPRESS_STRATEGY_FILTERED
;
await
zlib
.
zipFile
(
path
,
zipDest
,
options
,
(
err
,
data
)
=>
{
var
zipStat
=
fileio
.
statSync
(
zipDest
);
var
isFile
=
zipStat
.
isFile
();
expect
(
isFile
).
assertTrue
();
var
srcSize
=
fileio
.
statSync
(
path
).
size
;
var
destSize
=
zipStat
.
size
;
expect
(
srcSize
>
destSize
).
assertTrue
();
expect
(
data
).
assertEqual
(
zlib
.
ErrorCode
.
ERROR_CODE_OK
);
fileio
.
mkdir
(
unzipdir
).
then
(
function
()
{
console
.
info
(
"
ACTS_ZipFile_3000 mkdir successfully
"
);
}).
catch
(
function
(
error
)
{
console
.
info
(
"
ACTS_ZipFile_3000 mkdir failed with error:
"
+
error
);
});
zlib
.
unzipFile
(
zipDest
,
unzipdir
,
options
).
then
((
data
)
=>
{
var
unzipStat
=
fileio
.
statSync
(
unzipresultfile
);
var
isFile
=
unzipStat
.
isFile
();
expect
(
isFile
).
assertTrue
();
var
destSize
=
unzipStat
.
size
;
var
originSize
=
fileio
.
statSync
(
path
).
size
;
var
result
=
(
originSize
==
destSize
);
expect
(
result
).
assertTrue
();
expect
(
data
).
assertEqual
(
zlib
.
ErrorCode
.
ERROR_CODE_OK
);
console
.
error
(
'
ACTS_ZipFile_3000 unzipFile
'
);
done
();
}).
catch
((
err
)
=>
{
console
.
log
(
"
ACTS_ZipFile_3000 err:
"
+
err
);
done
();
})
done
();
});
}
catch
(
err
)
{
console
.
error
(
'
ACTS_ZipFile_3000 err:
'
+
err
);
done
();
}
console
.
log
(
"
==================ACTS_ZipFile_3000 end==================
"
);
})
/*
* @tc.number: ACTS_ZipFile_3100
* @tc.name: zipFile
* @tc.desc: COMPRESS_STRATEGY_HUFFMAN_ONLY,,
*/
it
(
'
ACTS_ZipFile_3100
'
,
0
,
async
function
(
done
)
{
console
.
log
(
"
==================ACTS_ZipFile_3100 start==================
"
);
let
dirfirst
=
"
/data/accounts/account_0/appdata
"
let
dirsecond
=
dirfirst
+
"
/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST
"
let
dir
=
dirsecond
+
"
/com.example.amsZipfileUnzipfileST.MainAbility/files
"
;
let
path
=
dir
+
"
/ACTS_ZipFile_3100.txt
"
;
var
zipDest
=
dir
+
"
/ACTS_ZipFile_3100.zip
"
let
infos
=
path
+
dir
;
let
unzipdirfirst
=
"
/data/accounts/account_0/appdata
"
;
let
unzipdirsecond
=
unzipdirfirst
+
"
/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST
"
let
unzipdir
=
unzipdirsecond
+
"
/com.example.amsZipfileUnzipfileST.MainAbility/files/ACTS_ZipFile_3100
"
;
let
unzipresultfile
=
unzipdir
+
"
/ACTS_ZipFile_3100.txt
"
;
let
fd
=
fileio
.
openSync
(
path
,
0o100
|
0o2
,
0o666
);
fileio
.
write
(
fd
,
infos
).
then
(
function
(
number
)
{
console
.
info
(
"
ACTS_ZipFile_3100 write data to file successfully:
"
+
number
);
}).
catch
(
function
(
err
)
{
console
.
info
(
"
ACTS_ZipFile_3100 write data to file failed with error:
"
+
err
);
});
try
{
var
options
=
{};
options
.
strategy
=
zlib
.
CompressStrategy
.
COMPRESS_STRATEGY_HUFFMAN_ONLY
;
await
zlib
.
zipFile
(
path
,
zipDest
,
options
,
(
err
,
data
)
=>
{
var
zipStat
=
fileio
.
statSync
(
zipDest
);
var
isFile
=
zipStat
.
isFile
();
expect
(
isFile
).
assertTrue
();
var
srcSize
=
fileio
.
statSync
(
path
).
size
;
var
destSize
=
zipStat
.
size
;
expect
(
srcSize
>
destSize
).
assertTrue
();
expect
(
data
).
assertEqual
(
zlib
.
ErrorCode
.
ERROR_CODE_OK
);
fileio
.
mkdir
(
unzipdir
).
then
(
function
()
{
console
.
info
(
"
ACTS_ZipFile_3100 mkdir successfully
"
);
}).
catch
(
function
(
error
)
{
console
.
info
(
"
ACTS_ZipFile_3100 mkdir failed with error:
"
+
error
);
});
zlib
.
unzipFile
(
zipDest
,
unzipdir
,
options
).
then
((
data
)
=>
{
var
unzipStat
=
fileio
.
statSync
(
unzipresultfile
);
var
isFile
=
unzipStat
.
isFile
();
expect
(
isFile
).
assertTrue
();
var
destSize
=
unzipStat
.
size
;
var
originSize
=
fileio
.
statSync
(
path
).
size
;
var
result
=
(
originSize
==
destSize
);
expect
(
result
).
assertTrue
();
expect
(
data
).
assertEqual
(
zlib
.
ErrorCode
.
ERROR_CODE_OK
);
console
.
error
(
'
ACTS_ZipFile_3100 unzipFile
'
);
done
();
}).
catch
((
err
)
=>
{
console
.
log
(
"
ACTS_ZipFile_3100 err:
"
+
err
);
done
();
})
done
();
});
}
catch
(
err
)
{
console
.
error
(
'
ACTS_ZipFile_3100 err:
'
+
err
);
done
();
}
console
.
log
(
"
==================ACTS_ZipFile_3100 end==================
"
);
})
/*
* @tc.number: ACTS_ZipFile_3200
* @tc.name: zipFile
* @tc.desc: COMPRESS_STRATEGY_RLE,,
*/
it
(
'
ACTS_ZipFile_3200
'
,
0
,
async
function
(
done
)
{
console
.
log
(
"
==================ACTS_ZipFile_3200 start==================
"
);
let
dirfirst
=
"
/data/accounts/account_0/appdata
"
let
dirsecond
=
dirfirst
+
"
/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST
"
let
dir
=
dirsecond
+
"
/com.example.amsZipfileUnzipfileST.MainAbility/files
"
;
let
path
=
dir
+
"
/ACTS_ZipFile_3200.txt
"
;
var
zipDest
=
dir
+
"
/ACTS_ZipFile_3200.zip
"
let
infos
=
path
+
dir
;
let
unzipdirfirst
=
"
/data/accounts/account_0/appdata
"
;
let
unzipdirsecond
=
unzipdirfirst
+
"
/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST
"
let
unzipdir
=
unzipdirsecond
+
"
/com.example.amsZipfileUnzipfileST.MainAbility/files/ACTS_ZipFile_3200
"
;
let
unzipresultfile
=
unzipdir
+
"
/ACTS_ZipFile_3200.txt
"
;
let
fd
=
fileio
.
openSync
(
path
,
0o100
|
0o2
,
0o666
);
fileio
.
write
(
fd
,
infos
).
then
(
function
(
number
)
{
console
.
info
(
"
ACTS_ZipFile_3200 write data to file successfully:
"
+
number
);
}).
catch
(
function
(
err
)
{
console
.
info
(
"
ACTS_ZipFile_3200 write data to file failed with error:
"
+
err
);
});
try
{
var
options
=
{};
options
.
strategy
=
zlib
.
CompressStrategy
.
COMPRESS_STRATEGY_RLE
;
await
zlib
.
zipFile
(
path
,
zipDest
,
options
,
(
err
,
data
)
=>
{
var
zipStat
=
fileio
.
statSync
(
zipDest
);
var
isFile
=
zipStat
.
isFile
();
expect
(
isFile
).
assertTrue
();
var
srcSize
=
fileio
.
statSync
(
path
).
size
;
var
destSize
=
zipStat
.
size
;
expect
(
srcSize
>
destSize
).
assertTrue
();
expect
(
data
).
assertEqual
(
zlib
.
ErrorCode
.
ERROR_CODE_OK
);
fileio
.
mkdir
(
unzipdir
).
then
(
function
()
{
console
.
info
(
"
ACTS_ZipFile_3200 mkdir successfully
"
);
}).
catch
(
function
(
error
)
{
console
.
info
(
"
ACTS_ZipFile_3200 mkdir failed with error:
"
+
error
);
});
zlib
.
unzipFile
(
zipDest
,
unzipdir
,
options
).
then
((
data
)
=>
{
var
unzipStat
=
fileio
.
statSync
(
unzipresultfile
);
var
isFile
=
unzipStat
.
isFile
();
expect
(
isFile
).
assertTrue
();
var
destSize
=
unzipStat
.
size
;
var
originSize
=
fileio
.
statSync
(
path
).
size
;
var
result
=
(
originSize
==
destSize
);
expect
(
result
).
assertTrue
();
expect
(
data
).
assertEqual
(
zlib
.
ErrorCode
.
ERROR_CODE_OK
);
console
.
error
(
'
ACTS_ZipFile_3200 unzipFile
'
);
done
();
}).
catch
((
err
)
=>
{
console
.
log
(
"
ACTS_ZipFile_3200 err:
"
+
err
);
done
();
})
done
();
});
}
catch
(
err
)
{
console
.
error
(
'
ACTS_ZipFile_3200 err:
'
+
err
);
done
();
}
console
.
log
(
"
==================ACTS_ZipFile_3200 end==================
"
);
})
/*
* @tc.number: ACTS_ZipFile_3300
* @tc.name: zipFile
* @tc.desc: COMPRESS_STRATEGY_FILTERED,,
*/
it
(
'
ACTS_ZipFile_3300
'
,
0
,
async
function
(
done
)
{
console
.
log
(
"
==================ACTS_ZipFile_3300 start==================
"
);
let
dirfirst
=
"
/data/accounts/account_0/appdata
"
let
dirsecond
=
dirfirst
+
"
/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST
"
let
dir
=
dirsecond
+
"
/com.example.amsZipfileUnzipfileST.MainAbility/files
"
;
let
path
=
dir
+
"
/ACTS_ZipFile_3300.txt
"
;
var
zipDest
=
dir
+
"
/ACTS_ZipFile_3300.zip
"
let
infos
=
path
+
dir
;
let
unzipdirfirst
=
"
/data/accounts/account_0/appdata
"
;
let
unzipdirsecond
=
unzipdirfirst
+
"
/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST
"
let
unzipdir
=
unzipdirsecond
+
"
/com.example.amsZipfileUnzipfileST.MainAbility/files/ACTS_ZipFile_3300
"
;
let
unzipresultfile
=
unzipdir
+
"
/ACTS_ZipFile_3300.txt
"
;
let
fd
=
fileio
.
openSync
(
path
,
0o100
|
0o2
,
0o666
);
fileio
.
write
(
fd
,
infos
).
then
(
function
(
number
)
{
console
.
info
(
"
ACTS_ZipFile_3300 write data to file successfully:
"
+
number
);
}).
catch
(
function
(
err
)
{
console
.
info
(
"
ACTS_ZipFile_3300 write data to file failed with error:
"
+
err
);
});
try
{
var
options
=
{};
options
.
strategy
=
zlib
.
CompressStrategy
.
COMPRESS_STRATEGY_FILTERED
;
await
zlib
.
zipFile
(
path
,
zipDest
,
options
,
(
err
,
data
)
=>
{
var
zipStat
=
fileio
.
statSync
(
zipDest
);
var
isFile
=
zipStat
.
isFile
();
expect
(
isFile
).
assertTrue
();
var
srcSize
=
fileio
.
statSync
(
path
).
size
;
var
destSize
=
zipStat
.
size
;
expect
(
srcSize
>
destSize
).
assertTrue
();
expect
(
data
).
assertEqual
(
zlib
.
ErrorCode
.
ERROR_CODE_OK
);
fileio
.
mkdir
(
unzipdir
).
then
(
function
()
{
console
.
info
(
"
ACTS_ZipFile_3300 mkdir successfully
"
);
}).
catch
(
function
(
error
)
{
console
.
info
(
"
ACTS_ZipFile_3300 mkdir failed with error:
"
+
error
);
});
zlib
.
unzipFile
(
zipDest
,
unzipdir
,
options
).
then
((
data
)
=>
{
var
unzipStat
=
fileio
.
statSync
(
unzipresultfile
);
var
isFile
=
unzipStat
.
isFile
();
expect
(
isFile
).
assertTrue
();
var
destSize
=
unzipStat
.
size
;
var
originSize
=
fileio
.
statSync
(
path
).
size
;
var
result
=
(
originSize
==
destSize
);
expect
(
result
).
assertTrue
();
expect
(
data
).
assertEqual
(
zlib
.
ErrorCode
.
ERROR_CODE_OK
);
console
.
error
(
'
ACTS_ZipFile_3300 unzipFile
'
);
done
();
}).
catch
((
err
)
=>
{
console
.
log
(
"
ACTS_ZipFile_3300 err:
"
+
err
);
done
();
})
done
();
});
}
catch
(
err
)
{
console
.
error
(
'
ACTS_ZipFile_3300 err:
'
+
err
);
done
();
}
console
.
log
(
"
==================ACTS_ZipFile_3300 end==================
"
);
})
/*
* @tc.number: ACTS_ZipFile_3400
* @tc.name: zipFile
* @tc.desc: FLUSH_TYPE_NO_FLUSH,,
*/
it
(
'
ACTS_ZipFile_3400
'
,
0
,
async
function
(
done
)
{
console
.
log
(
"
==================ACTS_ZipFile_3400 start==================
"
);
let
dirfirst
=
"
/data/accounts/account_0/appdata
"
let
dirsecond
=
dirfirst
+
"
/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST
"
let
dir
=
dirsecond
+
"
/com.example.amsZipfileUnzipfileST.MainAbility/files
"
;
let
path
=
""
;
var
zipDest
=
dir
+
"
/ACTS_ZipFile_3400.zip
"
var
options
=
{};
options
.
flush
=
zlib
.
FlushType
.
FLUSH_TYPE_NO_FLUSH
;
zlib
.
zipFile
(
path
,
dir
,
options
).
then
((
data
)
=>
{
console
.
log
(
"
ACTS_ZipFile_3400 data:
"
+
data
);
expect
(
data
).
assertEqual
(
zlib
.
ErrorCode
.
ERROR_CODE_ERRNO
);
done
();
}).
catch
((
err
)
=>
{
console
.
log
(
"
ACTS_ZipFile_3400 err:
"
+
err
);
done
();
});
console
.
log
(
"
==================ACTS_ZipFile_3400 end ==================
"
);
})
/*
* @tc.number: ACTS_ZipFile_3500
* @tc.name: zipFile
* @tc.desc: FLUSH_TYPE_NO_FLUSH,,
*/
it
(
'
ACTS_ZipFile_3500
'
,
0
,
async
function
(
done
)
{
console
.
log
(
"
==================ACTS_ZipFile_3500 start==================
"
);
let
dirfirst
=
"
/data/accounts/account_0/appdata
"
let
dirsecond
=
dirfirst
+
"
/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST
"
let
dir
=
dirsecond
+
"
/com.example.amsZipfileUnzipfileST.MainAbility/files
"
;
let
path
=
dir
+
"
/ACTS_ZipFile_3500.txt
"
;
let
src
=
dir
+
"
/ACTS_ZipFile_5500.txt
"
;
var
zipDest
=
dir
+
"
/ACTS_ZipFile_3500.zip
"
let
infos
=
path
+
dir
;
let
unzipdirfirst
=
"
/data/accounts/account_0/appdata
"
;
let
unzipdirsecond
=
unzipdirfirst
+
"
/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST
"
let
unzipdir
=
unzipdirsecond
+
"
/com.example.amsZipfileUnzipfileST.MainAbility/files/ACTS_ZipFile_3500
"
;
let
unzipresultfile
=
unzipdir
+
"
/ACTS_ZipFile_3500.txt
"
;
let
fd
=
fileio
.
openSync
(
path
,
0o100
|
0o2
,
0o666
);
fileio
.
write
(
fd
,
infos
).
then
(
function
(
number
)
{
console
.
info
(
"
ACTS_ZipFile_3500 write data to file successfully:
"
+
number
);
}).
catch
(
function
(
err
)
{
console
.
info
(
"
ACTS_ZipFile_3500 write data to file failed with error:
"
+
err
);
});
var
options
=
{};
zlib
.
zipFile
(
src
,
dir
,
options
).
then
((
data
)
=>
{
console
.
log
(
"
zipFilePromise_3500 data:
"
+
data
);
expect
(
data
).
assertEqual
(
zlib
.
ErrorCode
.
ERROR_CODE_ERRNO
);
done
();
}).
catch
((
err
)
=>
{
console
.
log
(
"
zipFilePromise_3500 err:
"
+
err
);
done
();
});
console
.
log
(
"
==================zipFilePromise_3500 end ==================
"
);
})
/*
* @tc.number: ACTS_ZipFile_3600
* @tc.name: zipFile
* @tc.desc: FLUSH_TYPE_NO_FLUSH,,
*/
it
(
'
ACTS_ZipFile_3600
'
,
0
,
async
function
(
done
)
{
console
.
log
(
"
==================ACTS_ZipFile_3600 start==================
"
);
let
dirfirst
=
"
/data/accounts/account_0/appdata
"
let
dirsecond
=
dirfirst
+
"
/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST
"
let
dir
=
dirsecond
+
"
/com.example.amsZipfileUnzipfileST.MainAbility/files
"
;
let
path
=
dir
+
"
/ACTS_ZipFile_3600.txt
"
;
var
zipDest
=
""
;
let
infos
=
path
+
dir
;
let
unzipdirfirst
=
"
/data/accounts/account_0/appdata
"
;
let
unzipdirsecond
=
unzipdirfirst
+
"
/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST
"
let
unzipdir
=
unzipdirsecond
+
"
/com.example.amsZipfileUnzipfileST.MainAbility/files/ACTS_ZipFile_3600
"
;
let
unzipresultfile
=
unzipdir
+
"
/ACTS_ZipFile_3600.txt
"
;
let
fd
=
fileio
.
openSync
(
path
,
0o100
|
0o2
,
0o666
);
fileio
.
write
(
fd
,
infos
).
then
(
function
(
number
)
{
console
.
info
(
"
ACTS_ZipFile_3600 write data to file successfully:
"
+
number
);
}).
catch
(
function
(
err
)
{
console
.
info
(
"
ACTS_ZipFile_3600 write data to file failed with error:
"
+
err
);
});
var
options
=
{};
zlib
.
zipFile
(
path
,
zipDest
,
options
).
then
((
data
)
=>
{
console
.
log
(
"
zipFilePromise_3600 data:
"
+
data
);
expect
(
data
).
assertEqual
(
zlib
.
ErrorCode
.
ERROR_CODE_ERRNO
);
done
();
}).
catch
((
err
)
=>
{
console
.
log
(
"
zipFilePromise_3600 err:
"
+
err
);
done
();
});
console
.
log
(
"
==================zipFilePromise_3600 end ==================
"
)
})
/*
* @tc.number: ACTS_ZipFile_3700
* @tc.name: zipFile
* @tc.desc: FLUSH_TYPE_NO_FLUSH,,
*/
it
(
'
ACTS_ZipFile_3700
'
,
0
,
async
function
(
done
)
{
console
.
log
(
"
==================ACTS_ZipFile_3700 start==================
"
);
let
dirfirst
=
"
/data/accounts/account_0/appdata
"
let
dirsecond
=
dirfirst
+
"
/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST
"
let
dir
=
dirsecond
+
"
/com.example.amsZipfileUnzipfileST.MainAbility/files
"
;
let
path
=
dir
+
"
/ACTS_ZipFile_3700.txt
"
;
var
zipDest
=
dir
+
"
/ACTS_ZipFile_3700.zip
"
;
var
src
=
dir
+
"
/ACTS_ZipFile_6600.zip
"
;
let
infos
=
path
+
dir
;
let
unzipresultfilefirst
=
"
/data/accounts/account_0/appdata
"
;
let
unzipresultfilersecond
=
unzipresultfilefirst
+
"
/com.example.amsZipfileUnzipfileST
"
;
let
unzipresultfilerThrid
=
unzipresultfilersecond
+
"
/com.example.amsZipfileUnzipfileST
"
;
let
unzipresult
=
unzipresultfilerThrid
+
"
/com.example.amsZipfileUnzipfileST.MainAbility/files/ACTS_ZipFile_9200
"
;
let
unzipdirfirst
=
"
/data/accounts/account_0/appdata
"
;
let
unzipdirsecond
=
unzipdirfirst
+
"
/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST
"
let
unzipdir
=
unzipdirsecond
+
"
/com.example.amsZipfileUnzipfileST.MainAbility/files/ACTS_ZipFile_3700
"
;
let
fd
=
fileio
.
openSync
(
path
,
0o100
|
0o2
,
0o666
);
fileio
.
write
(
fd
,
infos
).
then
(
function
(
number
)
{
console
.
info
(
"
ACTS_ZipFile_3700 write data to file successfully:
"
+
number
);
}).
catch
(
function
(
err
)
{
console
.
info
(
"
ACTS_ZipFile_3700 write data to file failed with error:
"
+
err
);
});
var
options
=
{};
options
.
flush
=
zlib
.
FlushType
.
FLUSH_TYPE_NO_FLUSH
;
zlib
.
zipFile
(
src
,
unzipresultfile
,
options
).
then
((
data
)
=>
{
console
.
log
(
"
zipFilePromise_3700 data:
"
+
data
);
expect
(
data
).
assertEqual
(
zlib
.
ErrorCode
.
ERROR_CODE_ERRNO
);
done
();
}).
catch
((
err
)
=>
{
console
.
log
(
"
zipFilePromise_3700 err:
"
+
err
);
done
();
});
console
.
log
(
"
==================zipFilePromise_3700 end ==================
"
);
fileio
.
mkdir
(
unzipdir
).
then
(
function
()
{
console
.
info
(
"
ACTS_ZipFile_3700 mkdir successfully
"
);
}).
catch
(
function
(
error
)
{
console
.
info
(
"
ACTS_ZipFile_3700 mkdir failed with error:
"
+
error
);
});
})
/*
* @tc.number: ACTS_ZipFile_3800
* @tc.name: zipFile
* @tc.desc: FLUSH_TYPE_NO_FLUSH,,
*/
it
(
'
ACTS_ZipFile_3800
'
,
0
,
async
function
(
done
)
{
console
.
log
(
"
==================ACTS_ZipFile_3800 start==================
"
);
let
dirfirst
=
"
/data/accounts/account_0/appdata
"
let
dirsecond
=
dirfirst
+
"
/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST
"
let
dir
=
dirsecond
+
"
/com.example.amsZipfileUnzipfileST.MainAbility/files
"
;
let
path
=
dir
+
"
/ACTS_ZipFile_3800.txt
"
;
var
zipDest
=
dir
+
"
/ACTS_ZipFile_3800.zip
"
let
infos
=
path
+
dir
;
let
unzipdirfirst
=
"
/data/accounts/account_0/appdata
"
;
let
unzipdirsecond
=
unzipdirfirst
+
"
/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST
"
let
unzipdir
=
unzipdirsecond
+
"
/com.example.amsZipfileUnzipfileST.MainAbility/files/ACTS_ZipFile_3800
"
;
let
unzipresultfile
=
unzipdir
+
"
/ACTS_ZipFile_3800.txt
"
;
let
fd
=
fileio
.
openSync
(
path
,
0o100
|
0o2
,
0o666
);
fileio
.
write
(
fd
,
infos
).
then
(
function
(
number
)
{
console
.
info
(
"
ACTS_ZipFile_3800 write data to file successfully:
"
+
number
);
}).
catch
(
function
(
err
)
{
console
.
info
(
"
ACTS_ZipFile_3800 write data to file failed with error:
"
+
err
);
});
try
{
var
options
=
{};
options
.
flush
=
zlib
.
FlushType
.
FLUSH_TYPE_NO_FLUSH
;
await
zlib
.
zipFile
(
path
,
zipDest
,
options
,
(
err
,
data
)
=>
{
var
zipStat
=
fileio
.
statSync
(
zipDest
);
var
isFile
=
zipStat
.
isFile
();
expect
(
isFile
).
assertTrue
();
var
srcSize
=
fileio
.
statSync
(
path
).
size
;
var
destSize
=
zipStat
.
size
;
expect
(
srcSize
>
destSize
).
assertTrue
();
expect
(
data
).
assertEqual
(
zlib
.
ErrorCode
.
ERROR_CODE_OK
);
fileio
.
mkdir
(
unzipdir
).
then
(
function
()
{
console
.
info
(
"
ACTS_ZipFile_3800 mkdir successfully
"
);
}).
catch
(
function
(
error
)
{
console
.
info
(
"
ACTS_ZipFile_3800 mkdir failed with error:
"
+
error
);
});
zlib
.
unzipFile
(
zipDest
,
unzipdir
,
options
).
then
((
data
)
=>
{
var
unzipStat
=
fileio
.
statSync
(
unzipresultfile
);
var
isFile
=
unzipStat
.
isFile
();
expect
(
isFile
).
assertTrue
();
var
destSize
=
unzipStat
.
size
;
var
originSize
=
fileio
.
statSync
(
path
).
size
;
var
result
=
(
originSize
==
destSize
);
expect
(
result
).
assertTrue
();
expect
(
data
).
assertEqual
(
zlib
.
ErrorCode
.
ERROR_CODE_OK
);
console
.
error
(
'
ACTS_ZipFile_3800 unzipFile
'
);
done
();
}).
catch
((
err
)
=>
{
console
.
log
(
"
ACTS_ZipFile_3800 err:
"
+
err
);
done
();
})
done
();
});
}
catch
(
err
)
{
console
.
error
(
'
ACTS_ZipFile_3800 err:
'
+
err
);
done
();
}
console
.
log
(
"
==================ACTS_ZipFile_3800 end==================
"
);
})
/*
* @tc.number: ACTS_ZipFile_3900
* @tc.name: zipFile
* @tc.desc: FLUSH_TYPE_NO_FLUSH,,
*/
it
(
'
ACTS_ZipFile_3900
'
,
0
,
async
function
(
done
)
{
console
.
log
(
"
==================ACTS_ZipFile_3900 start==================
"
);
let
dirfirst
=
"
/data/accounts/account_0/appdata
"
let
dirsecond
=
dirfirst
+
"
/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST
"
let
dir
=
dirsecond
+
"
/com.example.amsZipfileUnzipfileST.MainAbility/files
"
;
let
path
=
dir
+
"
/ACTS_ZipFile_3900.txt
"
;
var
zipDest
=
dir
+
"
/ACTS_ZipFile_3900.zip
"
let
infos
=
path
+
dir
;
let
unzipdirfirst
=
"
/data/accounts/account_0/appdata
"
;
let
unzipdirsecond
=
unzipdirfirst
+
"
/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST
"
let
unzipdir
=
unzipdirsecond
+
"
/com.example.amsZipfileUnzipfileST.MainAbility/files/ACTS_ZipFile_3900
"
;
let
unzipresultfile
=
unzipdir
+
"
/ACTS_ZipFile_3900.txt
"
;
let
fd
=
fileio
.
openSync
(
path
,
0o100
|
0o2
,
0o666
);
fileio
.
write
(
fd
,
infos
).
then
(
function
(
number
)
{
console
.
info
(
"
ACTS_ZipFile_3900 write data to file successfully:
"
+
number
);
}).
catch
(
function
(
err
)
{
console
.
info
(
"
ACTS_ZipFile_3900 write data to file failed with error:
"
+
err
);
});
try
{
var
options
=
{};
options
.
flush
=
zlib
.
FlushType
.
FLUSH_TYPE_NO_FLUSH
;
await
zlib
.
zipFile
(
path
,
zipDest
,
options
,
(
err
,
data
)
=>
{
var
zipStat
=
fileio
.
statSync
(
zipDest
);
var
isFile
=
zipStat
.
isFile
();
expect
(
isFile
).
assertTrue
();
var
srcSize
=
fileio
.
statSync
(
path
).
size
;
var
destSize
=
zipStat
.
size
;
expect
(
srcSize
>
destSize
).
assertTrue
();
expect
(
data
).
assertEqual
(
zlib
.
ErrorCode
.
ERROR_CODE_OK
);
fileio
.
mkdir
(
unzipdir
).
then
(
function
()
{
console
.
info
(
"
ACTS_ZipFile_3900 mkdir successfully
"
);
}).
catch
(
function
(
error
)
{
console
.
info
(
"
ACTS_ZipFile_3900 mkdir failed with error:
"
+
error
);
});
zlib
.
unzipFile
(
zipDest
,
unzipdir
,
options
).
then
((
data
)
=>
{
var
unzipStat
=
fileio
.
statSync
(
unzipresultfile
);
var
isFile
=
unzipStat
.
isFile
();
expect
(
isFile
).
assertTrue
();
var
destSize
=
unzipStat
.
size
;
var
originSize
=
fileio
.
statSync
(
path
).
size
;
var
result
=
(
originSize
==
destSize
);
expect
(
result
).
assertTrue
();
expect
(
data
).
assertEqual
(
zlib
.
ErrorCode
.
ERROR_CODE_OK
);
console
.
error
(
'
ACTS_ZipFile_3900 unzipFile
'
);
done
();
}).
catch
((
err
)
=>
{
console
.
log
(
"
ACTS_ZipFile_3900 err:
"
+
err
);
done
();
})
done
();
});
}
catch
(
err
)
{
console
.
error
(
'
ACTS_ZipFile_3900 err:
'
+
err
);
done
();
}
console
.
log
(
"
==================ACTS_ZipFile_3900 end==================
"
);
})
/*
* @tc.number: ACTS_ZipFile_4000
* @tc.name: zipFile
* @tc.desc: FLUSH_TYPE_NO_FLUSH,,
*/
it
(
'
ACTS_ZipFile_4000
'
,
0
,
async
function
(
done
)
{
console
.
log
(
"
==================FWK_ZipFile_0600 start==================
"
);
it
(
'
ACTS_ZipFile_3300
'
,
0
,
async
function
(
done
)
{
console
.
log
(
"
==================ACTS_ZipFile_3300 start==================
"
);
let
dirfirst
=
"
/data/accounts/account_0/appdata
"
let
dirsecond
=
dirfirst
+
"
/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST
"
let
dir
=
dirsecond
+
"
/com.example.amsZipfileUnzipfileST.MainAbility/files
"
;
let
path
=
dir
+
"
/ACTS_ZipFile_
40
00.txt
"
;
var
zipDest
=
dir
+
"
/ACTS_ZipFile_
40
00.zip
"
let
path
=
dir
+
"
/ACTS_ZipFile_
33
00.txt
"
;
var
zipDest
=
dir
+
"
/ACTS_ZipFile_
33
00.zip
"
let
infos
=
path
+
dir
;
let
unzipdirfirst
=
"
/data/accounts/account_0/appdata
"
;
let
unzipdirsecond
=
unzipdirfirst
+
"
/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST
"
let
unzipdir
=
unzipdirsecond
+
"
/com.example.amsZipfileUnzipfileST.MainAbility/files/ACTS_ZipFile_
40
00
"
;
let
unzipresultfile
=
unzipdir
+
"
/ACTS_ZipFile_
40
00.txt
"
;
let
unzipdir
=
unzipdirsecond
+
"
/com.example.amsZipfileUnzipfileST.MainAbility/files/ACTS_ZipFile_
33
00
"
;
let
unzipresultfile
=
unzipdir
+
"
/ACTS_ZipFile_
33
00.txt
"
;
let
fd
=
fileio
.
openSync
(
path
,
0o100
|
0o2
,
0o666
);
fileio
.
write
(
fd
,
infos
).
then
(
function
(
number
)
{
console
.
info
(
"
ACTS_ZipFile_
40
00 write data to file successfully:
"
+
number
);
console
.
info
(
"
ACTS_ZipFile_
33
00 write data to file successfully:
"
+
number
);
}).
catch
(
function
(
err
)
{
console
.
info
(
"
ACTS_ZipFile_
40
00 write data to file failed with error:
"
+
err
);
console
.
info
(
"
ACTS_ZipFile_
33
00 write data to file failed with error:
"
+
err
);
});
try
{
var
options
=
{};
options
.
flush
=
zlib
.
FlushType
.
FLUSH_TYPE_NO_FLUSH
;
options
.
strategy
=
zlib
.
CompressStrategy
.
COMPRESS_STRATEGY_FILTERED
;
await
zlib
.
zipFile
(
path
,
zipDest
,
options
,
(
err
,
data
)
=>
{
var
zipStat
=
fileio
.
statSync
(
zipDest
);
...
...
@@ -2345,9 +1096,9 @@ it('ACTS_ZipFile_4000', 0, async function (done) {
expect
(
srcSize
>
destSize
).
assertTrue
();
expect
(
data
).
assertEqual
(
zlib
.
ErrorCode
.
ERROR_CODE_OK
);
fileio
.
mkdir
(
unzipdir
).
then
(
function
()
{
console
.
info
(
"
ACTS_ZipFile_
40
00 mkdir successfully
"
);
console
.
info
(
"
ACTS_ZipFile_
33
00 mkdir successfully
"
);
}).
catch
(
function
(
error
)
{
console
.
info
(
"
ACTS_ZipFile_
40
00 mkdir failed with error:
"
+
error
);
console
.
info
(
"
ACTS_ZipFile_
33
00 mkdir failed with error:
"
+
error
);
});
zlib
.
unzipFile
(
zipDest
,
unzipdir
,
options
).
then
((
data
)
=>
{
var
unzipStat
=
fileio
.
statSync
(
unzipresultfile
);
...
...
@@ -2358,181 +1109,99 @@ it('ACTS_ZipFile_4000', 0, async function (done) {
var
result
=
(
originSize
==
destSize
);
expect
(
result
).
assertTrue
();
expect
(
data
).
assertEqual
(
zlib
.
ErrorCode
.
ERROR_CODE_OK
);
console
.
error
(
'
ACTS_ZipFile_
40
00 unzipFile
'
);
console
.
error
(
'
ACTS_ZipFile_
33
00 unzipFile
'
);
done
();
}).
catch
((
err
)
=>
{
console
.
log
(
"
ACTS_ZipFile_
40
00 err:
"
+
err
);
console
.
log
(
"
ACTS_ZipFile_
33
00 err:
"
+
err
);
done
();
})
done
();
});
}
catch
(
err
)
{
console
.
error
(
'
ACTS_ZipFile_
05
00 err:
'
+
err
);
console
.
error
(
'
ACTS_ZipFile_
33
00 err:
'
+
err
);
done
();
}
console
.
log
(
"
==================ACTS_ZipFile_
40
00 end==================
"
);
console
.
log
(
"
==================ACTS_ZipFile_
33
00 end==================
"
);
})
/*
* @tc.number: ACTS_ZipFile_
41
00
* @tc.number: ACTS_ZipFile_
35
00
* @tc.name: zipFile
* @tc.desc: FLUSH_TYPE_NO_FLUSH,,
*/
it
(
'
ACTS_ZipFile_
41
00
'
,
0
,
async
function
(
done
)
{
console
.
log
(
"
==================ACTS_ZipFile_
41
00 start==================
"
);
it
(
'
ACTS_ZipFile_
35
00
'
,
0
,
async
function
(
done
)
{
console
.
log
(
"
==================ACTS_ZipFile_
35
00 start==================
"
);
let
dirfirst
=
"
/data/accounts/account_0/appdata
"
let
dirsecond
=
dirfirst
+
"
/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST
"
let
dir
=
dirsecond
+
"
/com.example.amsZipfileUnzipfileST.MainAbility/files
"
;
let
path
=
dir
+
"
/ACTS_ZipFile_4100.txt
"
;
var
zipDest
=
dir
+
"
/ACTS_ZipFile_4100.zip
"
let
path
=
dir
+
"
/ACTS_ZipFile_3500.txt
"
;
let
src
=
dir
+
"
/ACTS_ZipFile_5500.txt
"
;
var
zipDest
=
dir
+
"
/ACTS_ZipFile_3500.zip
"
let
infos
=
path
+
dir
;
let
unzipdirfirst
=
"
/data/accounts/account_0/appdata
"
;
let
unzipdirsecond
=
unzipdirfirst
+
"
/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST
"
let
unzipdir
=
unzipdirsecond
+
"
/com.example.amsZipfileUnzipfileST.MainAbility/files/ACTS_ZipFile_
41
00
"
;
let
unzipresultfile
=
unzipdir
+
"
/ACTS_ZipFile_
41
00.txt
"
;
let
unzipdir
=
unzipdirsecond
+
"
/com.example.amsZipfileUnzipfileST.MainAbility/files/ACTS_ZipFile_
35
00
"
;
let
unzipresultfile
=
unzipdir
+
"
/ACTS_ZipFile_
35
00.txt
"
;
let
fd
=
fileio
.
openSync
(
path
,
0o100
|
0o2
,
0o666
);
fileio
.
write
(
fd
,
infos
).
then
(
function
(
number
)
{
console
.
info
(
"
ACTS_ZipFile_
41
00 write data to file successfully:
"
+
number
);
console
.
info
(
"
ACTS_ZipFile_
35
00 write data to file successfully:
"
+
number
);
}).
catch
(
function
(
err
)
{
console
.
info
(
"
ACTS_ZipFile_
41
00 write data to file failed with error:
"
+
err
);
console
.
info
(
"
ACTS_ZipFile_
35
00 write data to file failed with error:
"
+
err
);
});
try
{
var
options
=
{};
options
.
flush
=
zlib
.
FlushType
.
FLUSH_TYPE_NO_FLUSH
;
await
zlib
.
zipFile
(
path
,
zipDest
,
options
,
(
err
,
data
)
=>
{
var
zipStat
=
fileio
.
statSync
(
zipDest
);
var
isFile
=
zipStat
.
isFile
();
expect
(
isFile
).
assertTrue
();
var
srcSize
=
fileio
.
statSync
(
path
).
size
;
var
destSize
=
zipStat
.
size
;
expect
(
srcSize
>
destSize
).
assertTrue
();
expect
(
data
).
assertEqual
(
zlib
.
ErrorCode
.
ERROR_CODE_OK
);
fileio
.
mkdir
(
unzipdir
).
then
(
function
()
{
console
.
info
(
"
ACTS_ZipFile_4100 mkdir successfully
"
);
}).
catch
(
function
(
error
)
{
console
.
info
(
"
ACTS_ZipFile_4100 mkdir failed with error:
"
+
error
);
});
zlib
.
unzipFile
(
zipDest
,
unzipdir
,
options
).
then
((
data
)
=>
{
var
unzipStat
=
fileio
.
statSync
(
unzipresultfile
);
var
isFile
=
unzipStat
.
isFile
();
expect
(
isFile
).
assertTrue
();
var
destSize
=
unzipStat
.
size
;
var
originSize
=
fileio
.
statSync
(
path
).
size
;
var
result
=
(
originSize
==
destSize
);
expect
(
result
).
assertTrue
();
expect
(
data
).
assertEqual
(
zlib
.
ErrorCode
.
ERROR_CODE_OK
);
console
.
error
(
'
ACTS_ZipFile_4100 unzipFile
'
);
done
();
}).
catch
((
err
)
=>
{
console
.
log
(
"
ACTS_ZipFile_4100 err:
"
+
err
);
done
();
})
done
();
});
}
catch
(
err
)
{
console
.
error
(
'
ACTS_ZipFile_4100 err:
'
+
err
);
var
options
=
{};
zlib
.
zipFile
(
src
,
dir
,
options
).
then
((
data
)
=>
{
console
.
log
(
"
zipFilePromise_3500 data:
"
+
data
);
expect
(
data
).
assertEqual
(
zlib
.
ErrorCode
.
ERROR_CODE_ERRNO
);
done
();
}).
catch
((
err
)
=>
{
console
.
log
(
"
zipFilePromise_3500 err:
"
+
err
);
done
();
}
console
.
log
(
"
==================ACTS_ZipFile_4100 end==================
"
);
})
/*
* @tc.number: ACTS_ZipFile_4200
* @tc.name: zipFile
* @tc.desc: FLUSH_TYPE_NO_FLUSH,,
*/
it
(
'
ACTS_ZipFile_4200
'
,
0
,
async
function
(
done
)
{
console
.
log
(
"
==================ACTS_ZipFile_4200 start==================
"
);
let
dirfirst
=
"
/data/accounts/account_0/appdata
"
let
dirsecond
=
dirfirst
+
"
/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST
"
let
dir
=
dirsecond
+
"
/com.example.amsZipfileUnzipfileST.MainAbility/files
"
;
let
src
=
dir
+
"
/ACTS_ZipFile_100000.txt
"
;
let
path
=
dir
+
"
/ACTS_ZipFile_9900.txt
"
;
var
zipDest
=
dir
+
"
/ACTS_ZipFile_4200.zip
"
let
infos
=
path
+
dir
;
let
unzipdirfirst
=
"
/data/accounts/account_0/appdata
"
;
let
unzipdirsecond
=
unzipdirfirst
+
"
/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST
"
let
unzipdir
=
unzipdirsecond
+
"
/com.example.amsZipfileUnzipfileST.MainAbility/files/ACTS_ZipFile_4200
"
;
let
unzipresultfile
=
unzipdir
+
"
/ACTS_ZipFile_4200.txt
"
;
let
fd
=
fileio
.
openSync
(
path
,
0o100
|
0o2
,
0o666
);
fileio
.
write
(
fd
,
infos
).
then
(
function
(
number
)
{
console
.
info
(
"
ACTS_ZipFile_0200 write data to file successfully:
"
+
number
);
}).
catch
(
function
(
err
)
{
console
.
info
(
"
ACTS_ZipFile_0200 write data to file failed with error:
"
+
err
);
});
var
options
=
{};
options
.
flush
=
zlib
.
FlushType
.
FLUSH_TYPE_NO_FLUSH
;
await
zlib
.
zipFile
(
src
,
dir
,
options
,
(
err
,
data
)
=>
{
console
.
log
(
"
ACTS_ZipFile_4200 data:
"
+
data
);
expect
(
data
).
assertEqual
(
zlib
.
ErrorCode
.
ERROR_CODE_ERRNO
);
done
();
});
})
/*
* @tc.number: ACTS_ZipFile_4300
* @tc.name: zipFile
* @tc.desc: FLUSH_TYPE_NO_FLUSH,,
*/
it
(
'
ACTS_ZipFile_4300
'
,
0
,
async
function
(
done
)
{
console
.
log
(
"
==================ACTS_ZipFile_4300 start==================
"
);
let
dirfirst
=
"
/data/accounts/account_0/appdata
"
let
dirsecond
=
dirfirst
+
"
/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST
"
let
dir
=
dirsecond
+
"
/com.example.amsZipfileUnzipfileST.MainAbility/files
"
;
var
zipDest
=
dir
+
"
/ACTS_ZipFile_4300.zip
"
var
options
=
{};
options
.
flush
=
zlib
.
FlushType
.
FLUSH_TYPE_NO_FLUSH
;
await
zlib
.
unzipFile
(
dir
,
zipDest
,
options
,
(
err
,
data
)
=>
{
console
.
log
(
"
ACTS_ZipFile_4300 data:
"
+
data
);
expect
(
data
).
assertEqual
(
zlib
.
ErrorCode
.
ERROR_CODE_ERRNO
);
done
();
});
console
.
log
(
"
==================zipFilePromise_3500 end ==================
"
);
})
/*
* @tc.number: ACTS_ZipFile_
44
00
* @tc.number: ACTS_ZipFile_
36
00
* @tc.name: zipFile
* @tc.desc: FLUSH_TYPE_NO_FLUSH,,
*/
it
(
'
ACTS_ZipFile_
44
00
'
,
0
,
async
function
(
done
)
{
console
.
log
(
"
==================ACTS_ZipFile_
44
00 start==================
"
);
it
(
'
ACTS_ZipFile_
36
00
'
,
0
,
async
function
(
done
)
{
console
.
log
(
"
==================ACTS_ZipFile_
36
00 start==================
"
);
let
dirfirst
=
"
/data/accounts/account_0/appdata
"
let
dirsecond
=
dirfirst
+
"
/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST
"
let
dir
=
dirsecond
+
"
/com.example.amsZipfileUnzipfileST.MainAbility/files
"
;
let
path
=
dir
+
"
/ACTS_ZipFile_
44
00.txt
"
;
var
zipDest
=
dir
+
"
/ACTS_ZipFile_4400.zip
"
let
path
=
dir
+
"
/ACTS_ZipFile_
36
00.txt
"
;
var
zipDest
=
""
;
let
infos
=
path
+
dir
;
let
unzipdirfirst
=
"
/data/accounts/account_0/appdata
"
;
let
unzipdirsecond
=
unzipdirfirst
+
"
/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST
"
let
unzipdir
=
unzipdirsecond
+
"
/com.example.amsZipfileUnzipfileST.MainAbility/files/ACTS_ZipFile_
44
00
"
;
let
unzipresultfile
=
unzipdir
+
"
/ACTS_ZipFile_
44
00.txt
"
;
let
unzipdir
=
unzipdirsecond
+
"
/com.example.amsZipfileUnzipfileST.MainAbility/files/ACTS_ZipFile_
36
00
"
;
let
unzipresultfile
=
unzipdir
+
"
/ACTS_ZipFile_
36
00.txt
"
;
let
fd
=
fileio
.
openSync
(
path
,
0o100
|
0o2
,
0o666
);
fileio
.
write
(
fd
,
infos
).
then
(
function
(
number
)
{
console
.
info
(
"
ACTS_ZipFile_
44
00 write data to file successfully:
"
+
number
);
console
.
info
(
"
ACTS_ZipFile_
36
00 write data to file successfully:
"
+
number
);
}).
catch
(
function
(
err
)
{
console
.
info
(
"
ACTS_ZipFile_
44
00 write data to file failed with error:
"
+
err
);
console
.
info
(
"
ACTS_ZipFile_
36
00 write data to file failed with error:
"
+
err
);
});
var
options
=
{};
options
.
flush
=
zlib
.
FlushType
.
FLUSH_TYPE_PARTIAL_FLUSH
;
zlib
.
unzipFile
(
path
,
zipDest
,
options
,
(
err
,
data
)
=>
{
console
.
log
(
"
FWK_ZipFile_4400 data:
"
+
data
);
expect
(
data
).
assertEqual
(
zlib
.
ErrorCode
.
ERROR_CODE_ERRNO
);
done
();
});
zlib
.
zipFile
(
path
,
zipDest
,
options
).
then
((
data
)
=>
{
console
.
log
(
"
zipFilePromise_3600 data:
"
+
data
);
expect
(
data
).
assertEqual
(
zlib
.
ErrorCode
.
ERROR_CODE_ERRNO
);
done
();
}).
catch
((
err
)
=>
{
console
.
log
(
"
zipFilePromise_3600 err:
"
+
err
);
done
();
});
console
.
log
(
"
==================zipFilePromise_3600 end ==================
"
)
})
/*
* @tc.number: ACTS_ZipFile_4500
* @tc.name: zipFile
* @tc.desc:
FLUSH_TYPE_NO_FLUSH
,,
* @tc.desc:
COMPRESS_STRATEGY_FILTERED
,,
*/
it
(
'
ACTS_ZipFile_4500
'
,
0
,
async
function
(
done
)
{
console
.
log
(
"
==================ACTS_ZipFile_5000 start==================
"
);
...
...
@@ -2585,135 +1254,120 @@ it('ACTS_ZipFile_4500', 0, async function (done) {
})
/*
* @tc.number: ACTS_ZipFile_4600
* @tc.name: zipFile
* @tc.desc: FLUSH_TYPE_NO_FLUSH,,
*/
it
(
'
ACTS_ZipFile_4600
'
,
0
,
async
function
(
done
)
{
console
.
log
(
"
==================ACTS_ZipFile_4600 start==================
"
);
let
dirfirst
=
"
/data/accounts/account_0/appdata
"
let
dirsecond
=
dirfirst
+
"
/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST
"
let
dir
=
dirsecond
+
"
/com.example.amsZipfileUnzipfileST.MainAbility/files
"
;
let
path
=
""
;
var
zipDest
=
dir
+
"
/ACTS_ZipFile_4600.txt
"
;
let
infos
=
path
+
dir
;
var
options
=
{};
options
.
flush
=
zlib
.
FlushType
.
FLUSH_TYPE_NO_FLUSH
;
await
zlib
.
unzipFile
(
path
,
dir
,
options
,
(
err
,
data
)
=>
{
console
.
log
(
"
ACTS_ZipFile_4600 data:
"
+
data
);
expect
(
data
).
assertEqual
(
zlib
.
ErrorCode
.
ERROR_CODE_ERRNO
);
done
();
});
})
/*
* @tc.number: ACTS_ZipFile_4700
* @tc.name: zipFile
* @tc.desc: FLUSH_TYPE_NO_FLUSH,,
*/
it
(
'
ACTS_ZipFile_4700
'
,
0
,
async
function
(
done
)
{
console
.
log
(
"
==================ACTS_ZipFile_4700 start==================
"
);
let
dirfirst
=
"
/data/accounts/account_0/appdata
"
let
dirsecond
=
dirfirst
+
"
/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST
"
let
dir
=
dirsecond
+
"
/com.example.amsZipfileUnzipfileST.MainAbility/files
"
;
var
zipDest
=
dir
+
"
/ACTS_ZipFile_4700.zip
"
var
options
=
{};
options
.
flush
=
zlib
.
FlushType
.
FLUSH_TYPE_NO_FLUSH
;
await
zlib
.
unzipFile
(
dir
,
zipDest
,
options
,
(
err
,
data
)
=>
{
console
.
log
(
"
ACTS_ZipFile_4700 data:
"
+
data
);
expect
(
data
).
assertEqual
(
zlib
.
ErrorCode
.
ERROR_CODE_ERRNO
);
done
();
});
})
/*
* @tc.number: ACTS_ZipFile_4800
* @tc.number: ACTS_ZipFile_4900
* @tc.name: zipFile
* @tc.desc:
FLUSH_TYPE_NO_FLUSH,
,
* @tc.desc:
COMPRESS_STRATEGY_FILTERED
,
*/
it
(
'
ACTS_ZipFile_4
8
00
'
,
0
,
async
function
(
done
)
{
console
.
log
(
"
==================ACTS_ZipFile_4
8
00 start==================
"
);
it
(
'
ACTS_ZipFile_4
9
00
'
,
0
,
async
function
(
done
)
{
console
.
log
(
"
==================ACTS_ZipFile_4
9
00 start==================
"
);
let
dirfirst
=
"
/data/accounts/account_0/appdata
"
let
dirsecond
=
dirfirst
+
"
/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST
"
let
dir
=
dirsecond
+
"
/com.example.amsZipfileUnzipfileST.MainAbility/files
"
;
let
path
=
dir
+
"
/ACTS_ZipFile_4800.txt
"
;
var
zipDest
=
dir
+
"
/ACTS_ZipFile_4800.zip
"
let
path
=
dir
+
"
/ACTS_ZipFile_4900.txt
"
;
var
zipDest
=
dir
+
"
/ACTS_ZipFile_4900.zip
"
var
unzipDest
=
dir
+
"
/ACTS_ZipFile_4900.zip
"
let
infos
=
path
+
dir
;
let
unzipdirfirst
=
"
/data/accounts/account_0/appdata
"
;
let
unzipdirsecond
=
unzipdirfirst
+
"
/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST
"
let
unzipdir
=
unzipdirsecond
+
"
/com.example.amsZipfileUnzipfileST.MainAbility/files/ACTS_ZipFile_4800
"
;
let
unzipresultfile
=
unzipdir
+
"
/ACTS_ZipFile_4800.txt
"
;
let
unzipdir
=
unzipdirsecond
+
"
/com.example.amsZipfileUnzipfileST.MainAbility/files/ACTS_ZipFile_4900
"
;
let
zipdirfirst
=
"
/data/accounts/account_0/appdata
"
;
let
zipdirsecond
=
zipdirfirst
+
"
/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST
"
let
zipdir
=
zipdirsecond
+
"
/com.example.amsZipfileUnzipfileST.MainAbility/files/ACTS_ZipFile_4900
"
;
let
unzipresultfile
=
zipdir
+
"
/ACTS_ZipFile_4900.txt
"
;
let
fd
=
fileio
.
openSync
(
path
,
0o100
|
0o2
,
0o666
);
fileio
.
write
(
fd
,
infos
).
then
(
function
(
number
)
{
console
.
info
(
"
ACTS_ZipFile_4
8
00 write data to file successfully:
"
+
number
);
console
.
info
(
"
ACTS_ZipFile_4
9
00 write data to file successfully:
"
+
number
);
}).
catch
(
function
(
err
)
{
console
.
info
(
"
ACTS_ZipFile_4
8
00 write data to file failed with error:
"
+
err
);
console
.
info
(
"
ACTS_ZipFile_4
9
00 write data to file failed with error:
"
+
err
);
});
var
options
=
{};
options
.
flush
=
zlib
.
FlushType
.
FLUSH_TYPE_PARTIAL_FLUSH
;
zlib
.
unzipFile
(
path
,
zipDest
,
options
,
(
err
,
data
)
=>
{
console
.
log
(
"
ACTS_ZipFile_4800 data:
"
+
data
);
expect
(
data
).
assertEqual
(
zlib
.
ErrorCode
.
ERROR_CODE_ERRNO
);
done
();
});
})
options
.
strategy
=
zlib
.
CompressStrategy
.
COMPRESS_STRATEGY_FILTERED
;
await
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
);
}).
catch
(
err
=>
{
console
.
log
(
"
zipFile fail:
"
+
err
);
expect
(
err
).
assertFail
();
})
await
fileio
.
mkdir
(
unzipdir
).
then
(
function
()
{
console
.
info
(
"
ACTS_ZipFile_4900 mkdir successfully
"
);
}).
catch
(
function
(
error
)
{
console
.
info
(
"
ACTS_ZipFile_4900 mkdir failed with error:
"
+
error
);
});
await
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
(
"
unzipFile fail:
"
+
err
);
expect
(
err
).
assertFail
();
done
();
})
})
/*
* @tc.number: ACTS_ZipFile_
49
00
* @tc.number: ACTS_ZipFile_
50
00
* @tc.name: zipFile
* @tc.desc:
FLUSH_TYPE_NO_FLUSH,
,
* @tc.desc:
COMPRESS_STRATEGY_FIXED
,
*/
it
(
'
ACTS_ZipFile_
49
00
'
,
0
,
async
function
(
done
)
{
console
.
log
(
"
==================ACTS_ZipFile_
49
00 start==================
"
);
it
(
'
ACTS_ZipFile_
50
00
'
,
0
,
async
function
(
done
)
{
console
.
log
(
"
==================ACTS_ZipFile_
50
00 start==================
"
);
let
dirfirst
=
"
/data/accounts/account_0/appdata
"
let
dirsecond
=
dirfirst
+
"
/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST
"
let
dir
=
dirsecond
+
"
/com.example.amsZipfileUnzipfileST.MainAbility/files
"
;
let
path
=
dir
+
"
/ACTS_ZipFile_
49
00.txt
"
;
var
zipDest
=
dir
+
"
/ACTS_ZipFile_
49
00.zip
"
var
unzipDest
=
dir
+
"
/ACTS_ZipFile_
49
00.zip
"
let
path
=
dir
+
"
/ACTS_ZipFile_
50
00.txt
"
;
var
zipDest
=
dir
+
"
/ACTS_ZipFile_
50
00.zip
"
var
unzipDest
=
dir
+
"
/ACTS_ZipFile_
50
00.zip
"
let
infos
=
path
+
dir
;
let
unzipdirfirst
=
"
/data/accounts/account_0/appdata
"
;
let
unzipdirsecond
=
unzipdirfirst
+
"
/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST
"
let
unzipdir
=
unzipdirsecond
+
"
/com.example.amsZipfileUnzipfileST.MainAbility/files/ACTS_ZipFile_
49
00
"
;
let
unzipdir
=
unzipdirsecond
+
"
/com.example.amsZipfileUnzipfileST.MainAbility/files/ACTS_ZipFile_
50
00
"
;
let
zipdirfirst
=
"
/data/accounts/account_0/appdata
"
;
let
zipdirsecond
=
zipdirfirst
+
"
/com.example.amsZipfileUnzipfileST/com.example.amsZipfileUnzipfileST
"
let
zipdir
=
zipdirsecond
+
"
/com.example.amsZipfileUnzipfileST.MainAbility/files/ACTS_ZipFile_
98
00
"
;
let
unzipresultfile
=
zipdir
+
"
/ACTS_ZipFile_
49
00.txt
"
;
let
zipdir
=
zipdirsecond
+
"
/com.example.amsZipfileUnzipfileST.MainAbility/files/ACTS_ZipFile_
50
00
"
;
let
unzipresultfile
=
zipdir
+
"
/ACTS_ZipFile_
50
00.txt
"
;
let
fd
=
fileio
.
openSync
(
path
,
0o100
|
0o2
,
0o666
);
fileio
.
write
(
fd
,
infos
).
then
(
function
(
number
)
{
console
.
info
(
"
ACTS_ZipFile_
49
00 write data to file successfully:
"
+
number
);
console
.
info
(
"
ACTS_ZipFile_
50
00 write data to file successfully:
"
+
number
);
}).
catch
(
function
(
err
)
{
console
.
info
(
"
ACTS_ZipFile_
49
00 write data to file failed with error:
"
+
err
);
console
.
info
(
"
ACTS_ZipFile_
50
00 write data to file failed with error:
"
+
err
);
});
var
options
=
{};
options
.
strategy
=
zlib
.
CompressStrategy
.
COMPRESS_STRATEGY_FILTERED
;
await
zlib
.
zipFile
(
path
,
zipDest
,
options
,
(
err
,
data
)
=>
{
var
zipStat
=
fileio
.
statSync
(
zipDest
);
var
isFile
=
zipStat
.
isFile
();
expect
(
isFile
).
assertTrue
();
var
srcSize
=
fileio
.
statSync
(
path
).
size
;
var
destSize
=
zipStat
.
size
;
expect
(
srcSize
>
destSize
).
assertTrue
();
expect
(
data
).
assertEqual
(
zlib
.
ErrorCode
.
ERROR_CODE_OK
);
fileio
.
mkdir
(
unzipdir
).
then
(
function
()
{
console
.
info
(
"
ACTS_ZipFile_4900 mkdir successfully
"
);
}).
catch
(
function
(
error
)
{
console
.
info
(
"
ACTS_ZipFile_4900 mkdir failed with error:
"
+
error
);
});
zlib
.
unzipFile
(
unzipDest
,
zipdir
,
options
,
(
err
,
data
)
=>
{
console
.
log
(
"
ACTS_ZipFile_4900 data:
"
+
data
);
expect
(
data
).
assertEqual
(
zlib
.
ErrorCode
.
ERROR_CODE_ERRNO
);
done
();
});
})
options
.
strategy
=
zlib
.
CompressStrategy
.
COMPRESS_STRATEGY_FIXED
;
await
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
);
}).
catch
(
err
=>
{
console
.
log
(
"
zipFile fail:
"
+
err
);
expect
(
err
).
assertFail
();
})
await
fileio
.
mkdir
(
unzipdir
).
then
(
function
()
{
console
.
info
(
"
ACTS_ZipFile_5000 mkdir successfully
"
);
}).
catch
(
function
(
error
)
{
console
.
info
(
"
ACTS_ZipFile_5000 mkdir failed with error:
"
+
error
);
});
await
zlib
.
unzipFile
(
unzipDest
,
zipdir
,
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
();
})
})
})
...
...
appexecfwk_lite/appexecfwk_hal/src/bundle_mgr_test.c
浏览文件 @
7d9ad525
...
...
@@ -51,7 +51,8 @@ LITE_TEST_CASE(BundleMgrTestSuite, testClearAbilityInfoLegal, Function | MediumT
{
printf
(
"------start testClearAbilityInfo------
\n
"
);
AbilityInfo
abilityInfo
;
memset_s
(
&
abilityInfo
,
sizeof
(
abilityInfo
),
0
,
sizeof
(
abilityInfo
));
int
result
=
memset_s
(
&
abilityInfo
,
sizeof
(
abilityInfo
),
0
,
sizeof
(
abilityInfo
));
TEST_ASSERT_TRUE
(
result
==
0
);
abilityInfo
.
bundleName
=
"com.openharmony.testjsdemo"
;
TEST_ASSERT_EQUAL_STRING
(
abilityInfo
.
bundleName
,
"com.openharmony.testjsdemo"
);
ClearAbilityInfo
(
&
abilityInfo
);
...
...
@@ -68,7 +69,8 @@ LITE_TEST_CASE(BundleMgrTestSuite, testClearAbilityInfoIllegal, Function | Mediu
{
printf
(
"------start testClearAbilityInfoIllegal------
\n
"
);
AbilityInfo
abilityInfo
=
{
0
};
memset_s
(
&
abilityInfo
,
sizeof
(
abilityInfo
),
0
,
sizeof
(
abilityInfo
));
int
result
=
memset_s
(
&
abilityInfo
,
sizeof
(
abilityInfo
),
0
,
sizeof
(
abilityInfo
));
TEST_ASSERT_TRUE
(
result
==
0
);
abilityInfo
.
bundleName
=
"com.openharmony.testjsdemo"
;
ClearAbilityInfo
(
NULL
);
TEST_ASSERT_EQUAL_STRING
(
abilityInfo
.
bundleName
,
"com.openharmony.testjsdemo"
);
...
...
@@ -84,7 +86,8 @@ LITE_TEST_CASE(BundleMgrTestSuite, testClearBundleInfoLegal, Function | MediumTe
{
printf
(
"------start testClearBundleInfo------
\n
"
);
BundleInfo
bundleInfo
=
{
0
};
memset_s
(
&
bundleInfo
,
sizeof
(
bundleInfo
),
0
,
sizeof
(
bundleInfo
));
int
result
=
memset_s
(
&
bundleInfo
,
sizeof
(
bundleInfo
),
0
,
sizeof
(
bundleInfo
));
TEST_ASSERT_TRUE
(
result
==
0
);
bundleInfo
.
bundleName
=
"com.openharmony.testjsdemo"
;
TEST_ASSERT_EQUAL_STRING
(
bundleInfo
.
bundleName
,
"com.openharmony.testjsdemo"
);
ClearBundleInfo
(
&
bundleInfo
);
...
...
@@ -101,7 +104,8 @@ LITE_TEST_CASE(BundleMgrTestSuite, testClearBundleInfoIllegal, Function | Medium
{
printf
(
"------start testClearBundleInfoIllegal------
\n
"
);
BundleInfo
bundleInfo
;
memset_s
(
&
bundleInfo
,
sizeof
(
bundleInfo
),
0
,
sizeof
(
bundleInfo
));
int
result
=
memset_s
(
&
bundleInfo
,
sizeof
(
bundleInfo
),
0
,
sizeof
(
bundleInfo
));
TEST_ASSERT_TRUE
(
result
==
0
);
bundleInfo
.
bundleName
=
"com.openharmony.testjsdemo"
;
ClearBundleInfo
(
NULL
);
TEST_ASSERT_EQUAL_STRING
(
bundleInfo
.
bundleName
,
"com.openharmony.testjsdemo"
);
...
...
@@ -117,7 +121,8 @@ LITE_TEST_CASE(BundleMgrTestSuite, testClearModuleInfoLegal, Function | MediumTe
{
printf
(
"------start testClearModuleInfo------
\n
"
);
ModuleInfo
moduleInfo
=
{
0
};
memset_s
(
&
moduleInfo
,
sizeof
(
moduleInfo
),
0
,
sizeof
(
moduleInfo
));
int
result
=
memset_s
(
&
moduleInfo
,
sizeof
(
moduleInfo
),
0
,
sizeof
(
moduleInfo
));
TEST_ASSERT_TRUE
(
result
==
0
);
moduleInfo
.
moduleName
=
"test"
;
TEST_ASSERT_EQUAL_STRING
(
moduleInfo
.
moduleName
,
"test"
);
ClearModuleInfo
(
&
moduleInfo
);
...
...
@@ -134,7 +139,8 @@ LITE_TEST_CASE(BundleMgrTestSuite, testClearModuleInfoIllegal, Function | Medium
{
printf
(
"------start testClearModuleInfoIllegal------
\n
"
);
ModuleInfo
moduleInfo
=
{
0
};
memset_s
(
&
moduleInfo
,
sizeof
(
moduleInfo
),
0
,
sizeof
(
moduleInfo
));
int
result
=
memset_s
(
&
moduleInfo
,
sizeof
(
moduleInfo
),
0
,
sizeof
(
moduleInfo
));
TEST_ASSERT_TRUE
(
result
==
0
);
moduleInfo
.
moduleName
=
"test"
;
ClearModuleInfo
(
NULL
);
TEST_ASSERT_EQUAL_STRING
(
moduleInfo
.
moduleName
,
"test"
);
...
...
@@ -278,9 +284,10 @@ LITE_TEST_CASE(BundleMgrTestSuite, testGetBundleInfoIllegal, Function | MediumTe
{
printf
(
"------start testGetBundleInfoIllegal------
\n
"
);
BundleInfo
bundleInfo
;
memset_s
(
&
bundleInfo
,
sizeof
(
bundleInfo
),
0
,
sizeof
(
bundleInfo
));
int
result
=
memset_s
(
&
bundleInfo
,
sizeof
(
bundleInfo
),
0
,
sizeof
(
bundleInfo
));
TEST_ASSERT_TRUE
(
result
==
0
);
const
char
*
bundleName
=
"com.openharmony.nothishap"
;
int
32_t
flags
=
0
;
int
flags
=
0
;
uint8_t
ret
=
GetBundleInfo
(
bundleName
,
flags
,
&
bundleInfo
);
TEST_ASSERT_TRUE
(
ret
==
2
);
ret
=
GetBundleInfo
(
NULL
,
flags
,
&
bundleInfo
);
...
...
@@ -303,8 +310,8 @@ LITE_TEST_CASE(BundleMgrTestSuite, testGetBundleInfosIllegal, Function | MediumT
{
printf
(
"------start testGetBundleInfosIllegal------
\n
"
);
BundleInfo
*
bundleInfos
=
{
NULL
};
int
32_t
*
length
=
NULL
;
int
32_t
flags
=
0
;
int
*
length
=
NULL
;
int
flags
=
0
;
uint8_t
ret
=
GetBundleInfos
(
flags
,
NULL
,
length
);
TEST_ASSERT_TRUE
(
ret
==
1
);
ret
=
GetBundleInfos
(
flags
,
&
bundleInfos
,
NULL
);
...
...
appexecfwk_lite/appexecfwk_posix/src/BundleMgrTest.cpp
浏览文件 @
7d9ad525
...
...
@@ -102,7 +102,8 @@ HWTEST_F(BundleMgrTest, testClearAbilityInfoIllegal, Function | MediumTest | Lev
printf
(
"------start testClearAbilityInfoIllegal------
\n
"
);
// abilityInfo is nullptr
AbilityInfo
abilityInfo
;
memset_s
(
&
abilityInfo
,
sizeof
(
abilityInfo
),
0
,
sizeof
(
abilityInfo
));
int32_t
result
=
memset_s
(
&
abilityInfo
,
sizeof
(
abilityInfo
),
0
,
sizeof
(
abilityInfo
));
EXPECT_EQ
(
result
,
0
);
abilityInfo
.
bundleName
=
(
char
*
)
"com.openharmony.testjsdemo"
;
printf
(
"abilityInfo.bundleName is %s
\n
"
,
abilityInfo
.
bundleName
);
ClearAbilityInfo
(
nullptr
);
...
...
@@ -119,7 +120,8 @@ HWTEST_F(BundleMgrTest, testClearBundleInfoIllegal, Function | MediumTest | Leve
{
printf
(
"------start testClearBundleInfoIllegal------
\n
"
);
BundleInfo
bundleInfo
;
memset_s
(
&
bundleInfo
,
sizeof
(
bundleInfo
),
0
,
sizeof
(
bundleInfo
));
int32_t
result
=
memset_s
(
&
bundleInfo
,
sizeof
(
bundleInfo
),
0
,
sizeof
(
bundleInfo
));
EXPECT_EQ
(
result
,
0
);
bundleInfo
.
bundleName
=
(
char
*
)
"com.openharmony.testjsdemo"
;
printf
(
"abilityInfo.bundleName is %s
\n
"
,
bundleInfo
.
bundleName
);
ClearBundleInfo
(
nullptr
);
...
...
@@ -137,7 +139,8 @@ HWTEST_F(BundleMgrTest, testClearModuleInfoIllegal, Function | MediumTest | Leve
{
printf
(
"------start testClearModuleInfoIllegal------
\n
"
);
ModuleInfo
moduleInfo
;
memset_s
(
&
moduleInfo
,
sizeof
(
moduleInfo
),
0
,
sizeof
(
moduleInfo
));
int32_t
result
=
memset_s
(
&
moduleInfo
,
sizeof
(
moduleInfo
),
0
,
sizeof
(
moduleInfo
));
EXPECT_EQ
(
result
,
0
);
moduleInfo
.
description
=
(
char
*
)
"test app"
;
moduleInfo
.
moduleType
=
(
char
*
)
"entry"
;
ClearModuleInfo
(
nullptr
);
...
...
@@ -556,15 +559,18 @@ HWTEST_F(BundleMgrTest, testQueryAbilityInfoRight, Function | MediumTest | Level
{
printf
(
"------start testQueryAbilityInfoRight------
\n
"
);
Want
want
;
memset_s
(
&
want
,
sizeof
(
Want
),
0
,
sizeof
(
Want
));
int32_t
resultWant
=
memset_s
(
&
want
,
sizeof
(
Want
),
0
,
sizeof
(
Want
));
EXPECT_EQ
(
resultWant
,
0
);
ElementName
element
;
memset_s
(
&
element
,
sizeof
(
ElementName
),
0
,
sizeof
(
ElementName
));
int32_t
resultElementName
=
memset_s
(
&
element
,
sizeof
(
ElementName
),
0
,
sizeof
(
ElementName
));
EXPECT_EQ
(
resultElementName
,
0
);
SetElementAbilityName
(
&
element
,
"MainAbility"
);
SetElementBundleName
(
&
element
,
"com.openharmony.testjsdemo"
);
SetWantElement
(
&
want
,
element
);
SetWantData
(
&
want
,
"test"
,
4
);
AbilityInfo
abilityInfo
;
memset_s
(
&
abilityInfo
,
sizeof
(
abilityInfo
),
0
,
sizeof
(
abilityInfo
));
int32_t
result
=
memset_s
(
&
abilityInfo
,
sizeof
(
abilityInfo
),
0
,
sizeof
(
abilityInfo
));
EXPECT_EQ
(
result
,
0
);
printf
(
"element.elementname is %s
\n
"
,
want
.
element
->
bundleName
);
printf
(
"AbilityName2 is %s
\n
"
,
want
.
element
->
abilityName
);
g_errorCode
=
QueryAbilityInfo
(
&
want
,
&
abilityInfo
);
...
...
@@ -584,16 +590,19 @@ HWTEST_F(BundleMgrTest, testQueryAbilityInfoIllegal, Function | MediumTest | Lev
{
printf
(
"------start testQueryAbilityInfoIllegal------
\n
"
);
AbilityInfo
abilityInfo
;
memset_s
(
&
abilityInfo
,
sizeof
(
AbilityInfo
),
0
,
sizeof
(
AbilityInfo
));
int32_t
result
=
memset_s
(
&
abilityInfo
,
sizeof
(
AbilityInfo
),
0
,
sizeof
(
AbilityInfo
));
EXPECT_EQ
(
result
,
0
);
// want is nullptr
g_errorCode
=
QueryAbilityInfo
(
nullptr
,
&
abilityInfo
);
printf
(
"ret is %d
\n
"
,
g_errorCode
);
EXPECT_TRUE
(
g_errorCode
==
4
);
// abilityInfo is nullptr
Want
want
;
memset_s
(
&
want
,
sizeof
(
Want
),
0
,
sizeof
(
Want
));
int32_t
resultWant
=
memset_s
(
&
want
,
sizeof
(
Want
),
0
,
sizeof
(
Want
));
EXPECT_EQ
(
resultWant
,
0
);
ElementName
element
;
memset_s
(
&
element
,
sizeof
(
ElementName
),
0
,
sizeof
(
ElementName
));
int32_t
resultElementName
=
memset_s
(
&
element
,
sizeof
(
ElementName
),
0
,
sizeof
(
ElementName
));
EXPECT_EQ
(
resultElementName
,
0
);
SetElementAbilityName
(
&
element
,
"MainAbility"
);
SetElementBundleName
(
&
element
,
"com.openharmony.testjsdemo"
);
SetWantElement
(
&
want
,
element
);
...
...
@@ -624,7 +633,8 @@ HWTEST_F(BundleMgrTest, testGetBundleInfoRight, Function | MediumTest | Level1)
{
printf
(
"------start testGetBundleInfoRight------
\n
"
);
BundleInfo
bundleInfo
;
memset_s
(
&
bundleInfo
,
sizeof
(
bundleInfo
),
0
,
sizeof
(
bundleInfo
));
int32_t
result
=
memset_s
(
&
bundleInfo
,
sizeof
(
bundleInfo
),
0
,
sizeof
(
bundleInfo
));
EXPECT_EQ
(
result
,
0
);
const
char
*
bundleName
=
(
char
*
)
"com.openharmony.testjsdemo"
;
int32_t
flags
=
0
;
printf
(
"bundleName is %s
\n
"
,
bundleName
);
...
...
@@ -655,7 +665,8 @@ HWTEST_F(BundleMgrTest, testGetBundleInfoIllegal, Function | MediumTest | Level2
{
printf
(
"------start testGetBundleInfoIllegal------
\n
"
);
BundleInfo
bundleInfo
;
memset_s
(
&
bundleInfo
,
sizeof
(
bundleInfo
),
0
,
sizeof
(
bundleInfo
));
int32_t
result
=
memset_s
(
&
bundleInfo
,
sizeof
(
bundleInfo
),
0
,
sizeof
(
bundleInfo
));
EXPECT_EQ
(
result
,
0
);
const
char
*
bundleName
=
(
char
*
)
"com.openharmony.nothishap"
;
int32_t
flags
=
0
;
// error bundleName
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录