Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
8ddabfbe
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看板
未验证
提交
8ddabfbe
编写于
8月 05, 2023
作者:
O
openharmony_ci
提交者:
Gitee
8月 05, 2023
浏览文件
操作
浏览文件
下载
差异文件
!9678 【包管理子系统 master】新增zlib解压接口用例
Merge pull request !9678 from ry/master
上级
cb4c2721
ea32e35a
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
267 addition
and
0 deletion
+267
-0
bundlemanager/zlib/actszipfileandunzipfiletest/src/main/js/test/actszipfileandunzipfiletest.test.js
...test/src/main/js/test/actszipfileandunzipfiletest.test.js
+267
-0
未找到文件。
bundlemanager/zlib/actszipfileandunzipfiletest/src/main/js/test/actszipfileandunzipfiletest.test.js
浏览文件 @
8ddabfbe
...
...
@@ -1572,6 +1572,95 @@ export default function ActsZlibTest() {
})
})
/*
* @tc.number: SUB_BMS_TOOL_ZLIB_0087
* @tc.name: decompressDifferentLevel
* @tc.desc: test decompressFile when inFile and out file is valid
*/
it
(
'
decompressDifferentLevel
'
,
Level
.
LEVEL2
,
async
function
(
done
)
{
console
.
info
(
"
==================decompressDifferentLevel start==================
"
);
let
path
=
dir
+
"
/decompressFileTest.txt
"
;
let
zipDest1
=
dir
+
"
/decompressFileTest1.zip
"
;
let
zipDest2
=
dir
+
"
/decompressFileTest2.zip
"
;
let
unzipdir1
=
dir
+
"
/SUB_BMS_TOOL_ZLIB_0087a
"
;
let
unzipdir2
=
dir
+
"
/SUB_BMS_TOOL_ZLIB_0087b
"
;
let
finalFile1
=
unzipdir1
+
"
/decompressFileTest.txt
"
;
let
finalFile2
=
unzipdir2
+
"
/decompressFileTest.txt
"
;
let
fd
=
fileio
.
openSync
(
path
,
0o100
|
0o2
,
0o666
);
await
fileio
.
write
(
fd
,
infos
).
then
(
function
(
number
)
{
console
.
info
(
"
decompressDifferentLevel write data to file success
"
+
JSON
.
stringify
(
number
));
}).
catch
(
function
(
err
)
{
console
.
info
(
"
decompressDifferentLevel write data to file failed with error:
"
+
err
);
expect
(
err
).
assertFail
();
});
await
zlib
.
compressFile
(
path
,
zipDest1
,
{
level
:
zlib
.
CompressLevel
.
COMPRESS_LEVEL_BEST_COMPRESSION
}).
then
(
data
=>
{
console
.
info
(
"
decompressDifferentLevel 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
(
"
decompressDifferentLevel fail
"
+
JSON
.
stringify
(
err
));
expect
(
err
).
assertFail
();
})
await
zlib
.
compressFile
(
path
,
zipDest2
,
{
level
:
zlib
.
CompressLevel
.
COMPRESS_LEVEL_BEST_SPEED
}).
then
(
data
=>
{
console
.
info
(
"
decompressDifferentLevel success
"
+
JSON
.
stringify
(
data
));
let
zipStat
=
fileio
.
statSync
(
zipDest2
);
let
isFile
=
zipStat
.
isFile
();
expect
(
isFile
).
assertTrue
();
let
srcSize
=
fileio
.
statSync
(
path
).
size
;
let
destSize
=
zipStat
.
size
;
expect
(
srcSize
>
destSize
).
assertTrue
();
expect
(
data
).
assertEqual
(
null
);
}).
catch
(
err
=>
{
console
.
info
(
"
decompressDifferentLevel fail
"
+
JSON
.
stringify
(
err
));
expect
(
err
).
assertFail
();
})
await
fileio
.
mkdir
(
unzipdir1
).
then
(
function
()
{
console
.
info
(
"
decompressDifferentLevel mkdir successfully
"
);
}).
catch
(
function
(
error
)
{
console
.
info
(
"
decompressDifferentLevel mkdir failed with error:
"
+
error
);
expect
(
error
).
assertFail
();
});
await
zlib
.
decompressFile
(
zipDest1
,
unzipdir1
,
{
level
:
zlib
.
CompressLevel
.
COMPRESS_LEVEL_BEST_COMPRESSION
}).
then
(
data
=>
{
console
.
info
(
"
decompressDifferentLevel success1
"
+
JSON
.
stringify
(
data
));
let
zipStat
=
fileio
.
statSync
(
finalFile1
);
let
isFile
=
zipStat
.
isFile
();
expect
(
isFile
).
assertTrue
();
expect
(
data
).
assertEqual
(
null
);
}).
catch
(
err
=>
{
console
.
info
(
"
decompressDifferentLevel fail1
"
+
JSON
.
stringify
(
err
));
expect
(
err
).
assertFail
();
})
await
fileio
.
mkdir
(
unzipdir2
).
then
(
function
()
{
console
.
info
(
"
decompressDifferentLevel mkdir successfully
"
);
}).
catch
(
function
(
error
)
{
console
.
info
(
"
decompressDifferentLevel mkdir failed with error:
"
+
error
);
expect
(
error
).
assertFail
();
});
zlib
.
decompressFile
(
zipDest2
,
unzipdir2
,
{
level
:
zlib
.
CompressLevel
.
COMPRESS_LEVEL_BEST_SPEED
},
(
err
,
data
)
=>
{
console
.
info
(
"
decompressDifferentLevel success2
"
+
JSON
.
stringify
(
data
));
console
.
info
(
"
decompressDifferentLevel success2
"
+
JSON
.
stringify
(
err
));
let
zipStat
=
fileio
.
statSync
(
finalFile2
);
let
isFile
=
zipStat
.
isFile
();
expect
(
isFile
).
assertTrue
();
expect
(
data
).
assertEqual
(
undefined
);
expect
(
err
).
assertEqual
(
null
);
done
();
})
})
/*
* @tc.number: SUB_BMS_TOOL_ZLIB_0088
* @tc.name: decompressFileInFileNotExist
...
...
@@ -2036,6 +2125,184 @@ export default function ActsZlibTest() {
})
})
/*
* @tc.number: SUB_BMS_TOOL_ZLIB_0097
* @tc.name: decompressFileOutfileSpecialCharDir
* @tc.desc: test decompressFile when outFile is a dir
*/
it
(
'
decompressFileOutfileSpecialCharDir
'
,
Level
.
LEVEL2
,
async
function
(
done
)
{
console
.
info
(
"
==================decompressFileOutfileSpecialCharDir start==================
"
);
let
path
=
dir
+
"
/decompressFileTest.txt
"
;
let
zipDest1
=
dir
+
"
/@#@##.zip
"
;
let
zipDest2
=
dir
+
"
/@#@#@.zip
"
;
let
unzipdir1
=
dir
+
"
/@####1
"
;
let
unzipdir2
=
dir
+
"
/#@@@@2
"
;
let
finalFile1
=
unzipdir1
+
"
/decompressFileTest.txt
"
;
let
finalFile2
=
unzipdir2
+
"
/decompressFileTest.txt
"
;
let
fd
=
fileio
.
openSync
(
path
,
0o100
|
0o2
,
0o666
);
await
fileio
.
write
(
fd
,
infos
).
then
(
function
(
number
)
{
console
.
info
(
"
decompressFileOutfileSpecialCharDir write data to file success
"
+
JSON
.
stringify
(
number
));
}).
catch
(
function
(
err
)
{
console
.
info
(
"
decompressFileOutfileSpecialCharDir 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
(
"
decompressFileOutfileSpecialCharDir 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
(
"
decompressFileOutfileSpecialCharDir fail
"
+
JSON
.
stringify
(
err
));
expect
(
err
).
assertFail
();
})
await
zlib
.
compressFile
(
path
,
zipDest2
,
{
level
:
zlib
.
CompressLevel
.
COMPRESS_LEVEL_DEFAULT_COMPRESSION
}).
then
(
data
=>
{
console
.
info
(
"
decompressFileOutfileSpecialCharDir success
"
+
JSON
.
stringify
(
data
));
let
zipStat
=
fileio
.
statSync
(
zipDest2
);
let
isFile
=
zipStat
.
isFile
();
expect
(
isFile
).
assertTrue
();
let
srcSize
=
fileio
.
statSync
(
path
).
size
;
let
destSize
=
zipStat
.
size
;
expect
(
srcSize
>
destSize
).
assertTrue
();
expect
(
data
).
assertEqual
(
null
);
}).
catch
(
err
=>
{
console
.
info
(
"
decompressFileOutfileSpecialCharDir fail
"
+
JSON
.
stringify
(
err
));
expect
(
err
).
assertFail
();
})
await
fileio
.
mkdir
(
unzipdir1
).
then
(
function
()
{
console
.
info
(
"
decompressFileOutfileSpecialCharDir mkdir successfully
"
);
}).
catch
(
function
(
error
)
{
console
.
info
(
"
decompressFileOutfileSpecialCharDir mkdir failed with error:
"
+
error
);
expect
(
error
).
assertFail
();
});
await
zlib
.
decompressFile
(
zipDest1
,
unzipdir1
,
{
level
:
zlib
.
CompressLevel
.
COMPRESS_LEVEL_DEFAULT_COMPRESSION
}).
then
(
data
=>
{
console
.
info
(
"
decompressFileOutfileSpecialCharDir success1
"
+
JSON
.
stringify
(
data
));
let
zipStat
=
fileio
.
statSync
(
finalFile1
);
let
isFile
=
zipStat
.
isFile
();
expect
(
isFile
).
assertTrue
();
expect
(
data
).
assertEqual
(
null
);
}).
catch
(
err
=>
{
console
.
info
(
"
decompressFileOutfileSpecialCharDir fail1
"
+
JSON
.
stringify
(
err
));
expect
(
err
).
assertFail
();
})
await
fileio
.
mkdir
(
unzipdir2
).
then
(
function
()
{
console
.
info
(
"
decompressFileOutfileSpecialCharDir mkdir successfully
"
);
}).
catch
(
function
(
error
)
{
console
.
info
(
"
decompressFileOutfileSpecialCharDir mkdir failed with error:
"
+
error
);
expect
(
error
).
assertFail
();
});
zlib
.
decompressFile
(
zipDest2
,
unzipdir2
,
{
level
:
zlib
.
CompressLevel
.
COMPRESS_LEVEL_DEFAULT_COMPRESSION
},
(
err
,
data
)
=>
{
console
.
info
(
"
decompressFileOutfileSpecialCharDir success2
"
+
JSON
.
stringify
(
data
));
console
.
info
(
"
decompressFileOutfileSpecialCharDir success2
"
+
JSON
.
stringify
(
err
));
let
zipStat
=
fileio
.
statSync
(
finalFile2
);
let
isFile
=
zipStat
.
isFile
();
expect
(
isFile
).
assertTrue
();
expect
(
data
).
assertEqual
(
undefined
);
expect
(
err
).
assertEqual
(
null
);
done
();
})
})
/*
* @tc.number: SUB_BMS_TOOL_ZLIB_0098
* @tc.name: decompressFileInfileChineseDir
* @tc.desc: test decompressFile when outFile is a dir
*/
it
(
'
decompressFileInfileChineseDir
'
,
Level
.
LEVEL2
,
async
function
(
done
)
{
console
.
info
(
"
==================decompressFileInfileChineseDir start==================
"
);
let
path
=
dir
+
"
/decompressFileTest.txt
"
;
let
zipDest1
=
dir
+
"
/解压1.zip
"
;
let
zipDest2
=
dir
+
"
/解压2.zip
"
;
let
unzipdir1
=
dir
+
"
/文件夹1
"
;
let
unzipdir2
=
dir
+
"
/文件夹2
"
;
let
finalFile1
=
unzipdir1
+
"
/decompressFileTest.txt
"
;
let
finalFile2
=
unzipdir2
+
"
/decompressFileTest.txt
"
;
let
fd
=
fileio
.
openSync
(
path
,
0o100
|
0o2
,
0o666
);
await
fileio
.
write
(
fd
,
infos
).
then
(
function
(
number
)
{
console
.
info
(
"
decompressFileInfileChineseDir write data to file success
"
+
JSON
.
stringify
(
number
));
}).
catch
(
function
(
err
)
{
console
.
info
(
"
decompressFileInfileChineseDir 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
(
"
decompressFileInfileChineseDir 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
(
"
decompressFileInfileChineseDir fail
"
+
JSON
.
stringify
(
err
));
expect
(
err
).
assertFail
();
})
await
zlib
.
compressFile
(
path
,
zipDest2
,
{
level
:
zlib
.
CompressLevel
.
COMPRESS_LEVEL_DEFAULT_COMPRESSION
}).
then
(
data
=>
{
console
.
info
(
"
decompressFileInfileChineseDir success
"
+
JSON
.
stringify
(
data
));
let
zipStat
=
fileio
.
statSync
(
zipDest2
);
let
isFile
=
zipStat
.
isFile
();
expect
(
isFile
).
assertTrue
();
let
srcSize
=
fileio
.
statSync
(
path
).
size
;
let
destSize
=
zipStat
.
size
;
expect
(
srcSize
>
destSize
).
assertTrue
();
expect
(
data
).
assertEqual
(
null
);
}).
catch
(
err
=>
{
console
.
info
(
"
decompressFileInfileChineseDir fail
"
+
JSON
.
stringify
(
err
));
expect
(
err
).
assertFail
();
})
await
fileio
.
mkdir
(
unzipdir1
).
then
(
function
()
{
console
.
info
(
"
decompressFileInfileChineseDir mkdir successfully
"
);
}).
catch
(
function
(
error
)
{
console
.
info
(
"
decompressFileInfileChineseDir mkdir failed with error:
"
+
error
);
expect
(
error
).
assertFail
();
});
await
zlib
.
decompressFile
(
zipDest1
,
unzipdir1
,
{
level
:
zlib
.
CompressLevel
.
COMPRESS_LEVEL_DEFAULT_COMPRESSION
}).
then
(
data
=>
{
console
.
info
(
"
decompressFileInfileChineseDir success1
"
+
JSON
.
stringify
(
data
));
let
zipStat
=
fileio
.
statSync
(
finalFile1
);
let
isFile
=
zipStat
.
isFile
();
expect
(
isFile
).
assertTrue
();
expect
(
data
).
assertEqual
(
null
);
}).
catch
(
err
=>
{
console
.
info
(
"
decompressFileInfileChineseDir fail1
"
+
JSON
.
stringify
(
err
));
expect
(
err
).
assertFail
();
})
await
fileio
.
mkdir
(
unzipdir2
).
then
(
function
()
{
console
.
info
(
"
decompressFileInfileChineseDir mkdir successfully
"
);
}).
catch
(
function
(
error
)
{
console
.
info
(
"
decompressFileInfileChineseDir mkdir failed with error:
"
+
error
);
expect
(
error
).
assertFail
();
});
zlib
.
decompressFile
(
zipDest2
,
unzipdir2
,
{
level
:
zlib
.
CompressLevel
.
COMPRESS_LEVEL_DEFAULT_COMPRESSION
},
(
err
,
data
)
=>
{
console
.
info
(
"
decompressFileInfileChineseDir success2
"
+
JSON
.
stringify
(
data
));
console
.
info
(
"
decompressFileInfileChineseDir success2
"
+
JSON
.
stringify
(
err
));
let
zipStat
=
fileio
.
statSync
(
finalFile2
);
let
isFile
=
zipStat
.
isFile
();
expect
(
isFile
).
assertTrue
();
expect
(
data
).
assertEqual
(
undefined
);
expect
(
err
).
assertEqual
(
null
);
done
();
})
})
/*
* @tc.number: SUB_BMS_TOOL_ZLIB_0099
* @tc.name: decompressFileInfileChinesePath
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录