Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
608091c4
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看板
未验证
提交
608091c4
编写于
4月 21, 2023
作者:
O
openharmony_ci
提交者:
Gitee
4月 21, 2023
浏览文件
操作
浏览文件
下载
差异文件
!8507 【包管理子系统 master】新增zlib接口xts用例
Merge pull request !8507 from ry/master
上级
6440cfd4
65ce6eeb
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
243 addition
and
0 deletion
+243
-0
bundlemanager/zlib/actszipfileandunzipfiletest/src/main/js/test/actszipfileandunzipfiletest.test.js
...test/src/main/js/test/actszipfileandunzipfiletest.test.js
+243
-0
未找到文件。
bundlemanager/zlib/actszipfileandunzipfiletest/src/main/js/test/actszipfileandunzipfiletest.test.js
浏览文件 @
608091c4
...
...
@@ -21,6 +21,7 @@ import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect, Level
let
dir
=
""
;
let
infos
=
""
;
let
SRC_FILE_INVALID
=
900001
;
let
OUTPUT_FILE_INVALID
=
900002
;
let
PARAM_ERROR
=
401
;
export
default
function
ActsZlibTest
()
{
...
...
@@ -1098,6 +1099,68 @@ export default function ActsZlibTest() {
console
.
log
(
"
==================ACTS_ZipFile_5000 end==================
"
);
})
/*
* @tc.number: SUB_BMS_TOOL_ZLIB_0076
* @tc.name: compressFileOfFolders
* @tc.desc: test compressFile when input is folders
*/
it
(
'
compressFileOfFolders
'
,
Level
.
LEVEL2
,
async
function
(
done
)
{
console
.
log
(
"
==================compressFileOfFolders start==================
"
);
let
inputPath1
=
dir
+
"
/compressFileOfFolders1
"
;
let
inputPath2
=
dir
+
"
/compressFileOfFolders2
"
;
let
path1
=
inputPath1
+
"
/compressFileOfFolders1.txt
"
;
let
zipDest1
=
dir
+
"
/compressFileOfFolders1.zip
"
;
let
path2
=
inputPath2
+
"
/compressFileOfFolders2.txt
"
;
let
zipDest2
=
dir
+
"
/compressFileOfFolders2.zip
"
;
fileio
.
mkdirSync
(
inputPath1
);
fileio
.
mkdirSync
(
inputPath2
);
let
fd
=
fileio
.
openSync
(
path1
,
0o100
|
0o2
,
0o666
);
await
fileio
.
write
(
fd
,
infos
).
then
(
function
(
number
)
{
console
.
info
(
"
compressFileOfFolders write data to file successfully :
"
+
number
);
}).
catch
(
function
(
err
)
{
console
.
info
(
"
compressFileOfFolders write data to file failed with error:
"
+
err
);
expect
(
err
).
assertFail
();
});
console
.
info
(
"
compressFileOfFolders start compressFile
"
);
await
zlib
.
compressFile
(
inputPath1
,
zipDest1
,
{
level
:
zlib
.
CompressLevel
.
COMPRESS_LEVEL_DEFAULT_COMPRESSION
}).
then
((
data
)
=>
{
console
.
info
(
"
compressFileOfFolders data:
"
+
JSON
.
stringify
(
data
));
let
zipStat
=
fileio
.
statSync
(
zipDest1
);
let
isFile
=
zipStat
.
isFile
();
expect
(
isFile
).
assertTrue
();
let
srcSize
=
fileio
.
statSync
(
path1
).
size
;
let
destSize
=
zipStat
.
size
;
expect
(
srcSize
>
destSize
).
assertTrue
();
expect
(
data
).
assertEqual
(
null
);
}).
catch
((
err
)
=>
{
console
.
info
(
"
compressFileOfFolders data:
"
+
JSON
.
stringify
(
err
));
expect
(
err
).
assertFail
();
})
let
fd2
=
fileio
.
openSync
(
path2
,
0o100
|
0o2
,
0o666
);
await
fileio
.
write
(
fd2
,
infos
).
then
(
function
(
number
)
{
console
.
info
(
"
compressFileOfFolders write data to file successfully :
"
+
number
);
}).
catch
(
function
(
err
)
{
console
.
info
(
"
compressFileOfFolders write data to file failed with error:
"
+
err
);
expect
(
err
).
assertFail
();
});
zlib
.
compressFile
(
inputPath2
,
zipDest2
,
{
level
:
zlib
.
CompressLevel
.
COMPRESS_LEVEL_DEFAULT_COMPRESSION
},
(
err
,
data
)
=>
{
console
.
info
(
"
compressFileOfFolders data2:
"
+
JSON
.
stringify
(
data
));
console
.
info
(
"
compressFileOfFolders err2:
"
+
JSON
.
stringify
(
err
));
let
zipStat
=
fileio
.
statSync
(
zipDest2
);
let
isFile
=
zipStat
.
isFile
();
expect
(
isFile
).
assertTrue
();
let
srcSize
=
fileio
.
statSync
(
path2
).
size
;
let
destSize
=
zipStat
.
size
;
expect
(
srcSize
>
destSize
).
assertTrue
();
expect
(
data
).
assertEqual
(
undefined
);
expect
(
err
).
assertEqual
(
null
);
done
();
})
})
/*
* @tc.number: SUB_BMS_TOOL_ZLIB_0077
* @tc.name: compressFileTest
...
...
@@ -1222,6 +1285,43 @@ export default function ActsZlibTest() {
console
.
log
(
"
==================compressFileInFileNull end==================
"
);
})
/*
* @tc.number: SUB_BMS_TOOL_ZLIB_0080
* @tc.name: compressFileOutFileNotExist
* @tc.desc: test compressFile when outFile is not existed.
*/
it
(
'
compressFileOutFileNull
'
,
Level
.
LEVEL3
,
async
function
(
done
)
{
console
.
log
(
"
==================compressFileOutFileNull start==================
"
);
let
path1
=
dir
+
"
/compressFileOutFileNull.txt
"
;
let
outFile
=
"
/11111/22222.zip
"
;
let
fd
=
fileio
.
openSync
(
path1
,
0o100
|
0o2
,
0o666
);
await
fileio
.
write
(
fd
,
infos
).
then
(
function
(
number
)
{
console
.
info
(
"
fileio write data to file successfully :
"
+
number
);
}).
catch
(
function
(
err
)
{
console
.
info
(
"
fileio write data to file failed with error:
"
+
err
);
expect
(
err
).
assertFail
();
});
await
zlib
.
compressFile
(
path1
,
outFile
,
{
level
:
zlib
.
CompressLevel
.
COMPRESS_LEVEL_NO_COMPRESSION
}).
then
((
data
)
=>
{
console
.
log
(
"
compressFileOutFileNull invalid src file success!
"
);
expect
().
assertFail
();
}).
catch
((
err
)
=>
{
console
.
log
(
"
compressFileOutFileNull zipFile fail:
"
+
JSON
.
stringify
(
err
));
expect
(
err
.
code
).
assertEqual
(
OUTPUT_FILE_INVALID
);
})
zlib
.
compressFile
(
path1
,
outFile
,
{
level
:
zlib
.
CompressLevel
.
COMPRESS_LEVEL_NO_COMPRESSION
},
(
err
,
data
)
=>
{
console
.
log
(
"
compressFile result
"
);
expect
(
err
.
code
).
assertEqual
(
OUTPUT_FILE_INVALID
);
done
();
})
console
.
log
(
"
==================compressFileOutFileNull end==================
"
);
})
/*
* @tc.number: SUB_BMS_TOOL_ZLIB_0081
* @tc.name: compressFileOutFileNull
...
...
@@ -1305,6 +1405,42 @@ export default function ActsZlibTest() {
console
.
log
(
"
==================compressFileOptionNull end==================
"
);
})
/*
* @tc.number: SUB_BMS_TOOL_ZLIB_0083
* @tc.name: compressFileInvalidOption
* @tc.desc: test compressFile when option is invalid
*/
it
(
'
compressFileInvalidOption
'
,
Level
.
LEVEL3
,
async
function
(
done
)
{
console
.
log
(
"
==================compressFileInvalidOption start==================
"
);
let
path1
=
dir
+
"
/compressFileInvalidOption.txt
"
;
let
zipDest1
=
dir
+
"
/compressFileInvalidOption.zip
"
;
let
fd
=
fileio
.
openSync
(
path1
,
0o100
|
0o2
,
0o666
);
await
fileio
.
write
(
fd
,
infos
).
then
(
function
(
number
)
{
console
.
info
(
"
fileio write data to file successfully :
"
+
number
);
}).
catch
(
function
(
err
)
{
console
.
info
(
"
fileio write data to file failed with error:
"
+
err
);
expect
(
err
).
assertFail
();
});
await
zlib
.
compressFile
(
path1
,
zipDest1
,
{
memLevel
:
-
1
}).
then
((
data
)
=>
{
console
.
log
(
"
compressFileInvalidOption invalid src file success!
"
);
expect
(
data
).
assertNull
();
}).
catch
((
err
)
=>
{
console
.
log
(
"
compressFileInvalidOption zipFile fail:
"
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
})
zlib
.
compressFile
(
path1
,
zipDest1
,
{
memLevel
:
-
1
},
(
err
,
data
)
=>
{
console
.
log
(
"
compressFile result
"
);
expect
(
data
).
assertUndefined
();
expect
(
err
).
assertNull
();
done
();
})
console
.
log
(
"
==================compressFileInvalidOption end==================
"
);
})
/*
* @tc.number: SUB_BMS_TOOL_ZLIB_0084
* @tc.name: compressFileStrategyNull
...
...
@@ -1517,6 +1653,56 @@ export default function ActsZlibTest() {
console
.
log
(
"
==================decompressFileInFileNull end==================
"
);
})
/*
* @tc.number: SUB_BMS_TOOL_ZLIB_0090
* @tc.name: decompressFileOutFileNotExist
* @tc.desc: test decompressFile when outFile is not existed.
*/
it
(
'
decompressFileOutFileNotExist
'
,
Level
.
LEVEL3
,
async
function
(
done
)
{
console
.
log
(
"
==================decompressFileOutFileNotExist start==================
"
);
let
path
=
dir
+
"
/decompressFileOutFileNotExist.txt
"
;
let
zipDest1
=
dir
+
"
/decompressFileOutFileNotExist.zip
"
;
let
outFile
=
"
/111111/22222/test
"
;
let
fd
=
fileio
.
openSync
(
path
,
0o100
|
0o2
,
0o666
);
await
fileio
.
write
(
fd
,
infos
).
then
(
function
(
number
)
{
console
.
info
(
"
decompressFileOutFileNotExist write data to file success
"
+
JSON
.
stringify
(
number
));
}).
catch
(
function
(
err
)
{
console
.
info
(
"
decompressFileOutFileNotExist write data to file failed with error:
"
+
err
);
expect
(
err
).
assertFail
();
});
await
zlib
.
compressFile
(
path
,
zipDest1
,
{
level
:
zlib
.
CompressLevel
.
COMPRESS_LEVEL_DEFAULT_COMPRESSION
}).
then
(
data
=>
{
console
.
info
(
"
compressFile success
"
+
JSON
.
stringify
(
data
));
let
zipStat
=
fileio
.
statSync
(
zipDest1
);
let
isFile
=
zipStat
.
isFile
();
expect
(
isFile
).
assertTrue
();
let
srcSize
=
fileio
.
statSync
(
path
).
size
;
let
destSize
=
zipStat
.
size
;
expect
(
srcSize
>
destSize
).
assertTrue
();
expect
(
data
).
assertEqual
(
null
);
}).
catch
(
err
=>
{
console
.
info
(
"
compressFile fail
"
+
JSON
.
stringify
(
err
));
expect
(
err
).
assertFail
();
})
await
zlib
.
decompressFile
(
zipDest1
,
outFile
,
{
strategy
:
zlib
.
CompressStrategy
.
COMPRESS_STRATEGY_FIXED
}).
then
(
data
=>
{
console
.
log
(
"
decompressFile data:
"
+
data
);
expect
().
assertFail
();
}).
catch
(
err
=>
{
console
.
log
(
"
decompress fail:
"
+
JSON
.
stringify
(
err
));
expect
(
err
.
code
).
assertEqual
(
OUTPUT_FILE_INVALID
);
})
zlib
.
decompressFile
(
zipDest1
,
outFile
,
{
strategy
:
zlib
.
CompressStrategy
.
COMPRESS_STRATEGY_FIXED
},
(
err
,
data
)
=>
{
expect
(
err
.
code
).
assertEqual
(
OUTPUT_FILE_INVALID
);
done
();
})
console
.
log
(
"
==================decompressFileOutFileNotExist end==================
"
);
})
/*
* @tc.number: SUB_BMS_TOOL_ZLIB_0091
* @tc.name: decompressFileOutFileNull
...
...
@@ -1640,6 +1826,63 @@ export default function ActsZlibTest() {
console
.
log
(
"
==================decompressFileOutFileNull end==================
"
);
})
/*
* @tc.number: SUB_BMS_TOOL_ZLIB_0093
* @tc.name: decompressFileInvalidOption
* @tc.desc: test decompressFile when option is invalid
*/
it
(
'
decompressFileInvalidOption
'
,
Level
.
LEVEL3
,
async
function
(
done
)
{
console
.
log
(
"
==================decompressFileInvalidOption start==================
"
);
let
path
=
dir
+
"
/decompressFileInvalidOption.txt
"
;
let
zipDest1
=
dir
+
"
/decompressFileInvalidOption.zip
"
;
let
fd
=
fileio
.
openSync
(
path
,
0o100
|
0o2
,
0o666
);
await
fileio
.
write
(
fd
,
infos
).
then
(
function
(
number
)
{
console
.
info
(
"
SUB_BMS_TOOL_ZLIB_0087 write data to file success
"
+
JSON
.
stringify
(
number
));
}).
catch
(
function
(
err
)
{
console
.
info
(
"
SUB_BMS_TOOL_ZLIB_0087 write data to file failed with error:
"
+
err
);
expect
(
err
).
assertFail
();
});
await
zlib
.
compressFile
(
path
,
zipDest1
,
{
level
:
zlib
.
CompressLevel
.
COMPRESS_LEVEL_DEFAULT_COMPRESSION
}).
then
(
data
=>
{
console
.
info
(
"
compressFile success
"
+
JSON
.
stringify
(
data
));
let
zipStat
=
fileio
.
statSync
(
zipDest1
);
let
isFile
=
zipStat
.
isFile
();
expect
(
isFile
).
assertTrue
();
let
srcSize
=
fileio
.
statSync
(
path
).
size
;
let
destSize
=
zipStat
.
size
;
expect
(
srcSize
>
destSize
).
assertTrue
();
expect
(
data
).
assertEqual
(
null
);
}).
catch
(
err
=>
{
console
.
info
(
"
compressFile fail
"
+
JSON
.
stringify
(
err
));
expect
(
err
).
assertFail
();
})
let
unzipdir
=
dir
+
"
/decompressFileInvalidOption
"
;
await
fileio
.
mkdir
(
unzipdir
).
then
(
function
()
{
console
.
info
(
"
fileio mkdir successfully
"
);
}).
catch
(
function
(
error
)
{
console
.
info
(
"
fileio mkdir failed with error:
"
+
error
);
expect
(
error
).
assertFail
();
});
await
zlib
.
decompressFile
(
zipDest1
,
unzipdir
,
{
memLevel
:
-
1
}).
then
(
data
=>
{
console
.
log
(
"
decompressFile data:
"
+
data
);
expect
(
data
).
assertNull
();
}).
catch
(
err
=>
{
console
.
log
(
"
decompress fail:
"
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
})
zlib
.
decompressFile
(
zipDest1
,
unzipdir
,
{
memLevel
:
-
1
},
(
err
,
data
)
=>
{
expect
(
data
).
assertUndefined
();
expect
(
err
).
assertNull
();
done
();
})
console
.
log
(
"
==================decompressFileOutFileNull end==================
"
);
})
/*
* @tc.number: SUB_BMS_TOOL_ZLIB_0094
* @tc.name: decompressFileStrategyNull
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录