Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
6d540f2a
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,发现更多精彩内容 >>
未验证
提交
6d540f2a
编写于
10月 19, 2022
作者:
O
openharmony_ci
提交者:
Gitee
10月 19, 2022
浏览文件
操作
浏览文件
下载
差异文件
!5903 增加zlib compressFIle及decompressFIle接口xts
Merge pull request !5903 from longwei/master
上级
b56175c0
f5f70c36
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
148 addition
and
0 deletion
+148
-0
bundlemanager/zlib/actszipfileandunzipfiletest/src/main/js/test/actszipfileandunzipfiletest.test.js
...test/src/main/js/test/actszipfileandunzipfiletest.test.js
+148
-0
未找到文件。
bundlemanager/zlib/actszipfileandunzipfiletest/src/main/js/test/actszipfileandunzipfiletest.test.js
浏览文件 @
6d540f2a
...
...
@@ -20,6 +20,7 @@ import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from
var
dir
=
""
;
var
infos
=
""
;
var
SRC_FILE_INVALID
=
90001
;
export
default
function
ActsZlibTest
()
{
describe
(
'
ActsZlibTest
'
,
function
()
{
beforeEach
(
async
(
done
)
=>
{
...
...
@@ -1093,6 +1094,153 @@ it('ACTS_ZipFile_5000', 0, async function (done) {
});
console
.
log
(
"
==================ACTS_ZipFile_5000 end==================
"
);
})
/*
* @tc.number: SUB_BMS_TOOL_ZLIB_0076
* @tc.name: compressFile success
* @tc.desc: inFile and out file is valid
*/
it
(
'
SUB_BMS_TOOL_ZLIB_0077
'
,
0
,
async
function
(
done
)
{
console
.
log
(
"
==================ACTS_compressFile_0100 start==================
"
);
var
path
=
dir
+
"
/SUB_BMS_TOOL_ZLIB_0077.txt
"
;
var
zipDest
=
dir
+
"
/SUB_BMS_TOOL_ZLIB_0077.zip
"
;
var
fd
=
fileio
.
openSync
(
path
,
0o100
|
0o2
,
0o666
);
fileio
.
write
(
fd
,
infos
).
then
(
function
(
number
)
{
console
.
info
(
"
SUB_BMS_TOOL_ZLIB_0077 write data to file successfully :
"
+
number
);
var
options
=
{};
options
.
level
=
zlib
.
CompressLevel
.
COMPRESS_LEVEL_DEFAULT_COMPRESSION
;
console
.
info
(
"
SUB_BMS_TOOL_ZLIB_0077 start compressFile
"
);
zlib
.
compressFile
(
path
,
zipDest
,
options
).
then
((
data
)
=>
{
console
.
log
(
"
SUB_BMS_TOOL_ZLIB_0077 data:
"
+
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
(
null
);
done
();
}).
catch
((
err
)
=>
{
console
.
log
(
"
SUB_BMS_TOOL_ZLIB_0077 zipFile fail:
"
+
err
);
expect
(
data
).
assertFail
();
})
}).
catch
(
function
(
err
)
{
console
.
info
(
"
SUB_BMS_TOOL_ZLIB_0077 write data to file failed with error:
"
+
err
);
expect
(
err
).
assertFail
();
done
();
});
console
.
log
(
"
==================SUB_BMS_TOOL_ZLIB_0077 end==================
"
);
})
/*
* @tc.number: SUB_BMS_TOOL_ZLIB_0077
* @tc.name: compressFile src file is invalid
* @tc.desc: inFile is not exist
*/
it
(
'
SUB_BMS_TOOL_ZLIB_0078
'
,
0
,
async
function
(
done
)
{
console
.
log
(
"
==================SUB_BMS_TOOL_ZLIB_0078 start==================
"
);
var
path
=
"
nonexist.txt
"
;
var
zipDest
=
dir
+
"
/SUB_BMS_TOOL_ZLIB_0078.zip
"
var
options
=
{};
options
.
level
=
zlib
.
CompressLevel
.
COMPRESS_LEVEL_NO_COMPRESSION
;
zlib
.
compressFile
(
path
,
zipDest
,
options
).
then
((
data
)
=>
{
console
.
log
(
"
SUB_BMS_TOOL_ZLIB_0078 invalid src file success!
"
)
expect
(
data
).
assertFail
();
done
();
}).
catch
((
err
)
=>
{
console
.
log
(
"
SUB_BMS_TOOL_ZLIB_0078 zipFile fail:
"
+
err
);
expect
(
err
.
code
).
assertEqual
(
SRC_FILE_INVALID
);
done
();
})
console
.
log
(
"
==================SUB_BMS_TOOL_ZLIB_0078 end==================
"
);
})
/*
* @tc.number: SUB_BMS_TOOL_ZLIB_0077
* @tc.name: decompressFile success
* @tc.desc: inFile and out file is valid
*/
it
(
'
SUB_BMS_TOOL_ZLIB_0087
'
,
0
,
async
function
(
done
)
{
console
.
log
(
"
==================SUB_BMS_TOOL_ZLIB_0087 start==================
"
);
var
path
=
dir
+
"
/SUB_BMS_TOOL_ZLIB_0087.txt
"
;
var
zipDest
=
dir
+
"
/SUB_BMS_TOOL_ZLIB_0087.zip
"
var
unzipdir
=
dir
+
"
/SUB_BMS_TOOL_ZLIB_0087
"
;
var
finalFile
=
unzipdir
+
"
/SUB_BMS_TOOL_ZLIB_0087.txt
"
;
var
options
=
{};
options
.
strategy
=
zlib
.
CompressStrategy
.
COMPRESS_STRATEGY_FIXED
;
var
fd
=
fileio
.
openSync
(
path
,
0o100
|
0o2
,
0o666
);
fileio
.
write
(
fd
,
infos
).
then
(
function
(
number
)
{
console
.
info
(
"
SUB_BMS_TOOL_ZLIB_0087 write data to file successfully:
"
+
number
);
zlib
.
compressFile
(
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
(
null
);
fileio
.
mkdir
(
unzipdir
).
then
(
function
()
{
console
.
info
(
"
SUB_BMS_TOOL_ZLIB_0087 mkdir successfully
"
);
zlib
.
decompressFile
(
zipDest
,
unzipdir
,
options
).
then
(
data
=>
{
console
.
log
(
"
SUB_BMS_TOOL_ZLIB_0087 data:
"
+
data
);
var
zipStat
=
fileio
.
statSync
(
finalFile
);
var
isFile
=
zipStat
.
isFile
();
expect
(
isFile
).
assertTrue
();
expect
(
data
).
assertEqual
(
null
);
done
();
}).
catch
(
err
=>
{
console
.
log
(
"
decomepressFile fail:
"
+
err
);
expect
(
err
).
assertFail
();
done
();
})
}).
catch
(
function
(
error
)
{
console
.
info
(
"
SUB_BMS_TOOL_ZLIB_0087 mkdir failed with error:
"
+
error
);
expect
(
error
).
assertFail
();
done
();
});
}).
catch
(
err
=>
{
console
.
log
(
"
compress fail:
"
+
err
);
expect
(
err
).
assertFail
();
done
();
})
}).
catch
(
function
(
err
)
{
console
.
info
(
"
SUB_BMS_TOOL_ZLIB_0087 write data to file failed with error:
"
+
err
);
expect
(
err
).
assertFail
();
done
();
});
console
.
log
(
"
==================SUB_BMS_TOOL_ZLIB_0087 end==================
"
);
})
/*
* @tc.number: ACTS_decompressFile_0200
* @tc.name: decompressFile src file invalid
* @tc.desc: inFile is empty
*/
it
(
'
SUB_BMS_TOOL_ZLIB_0088
'
,
0
,
async
function
(
done
)
{
console
.
log
(
"
==================SUB_BMS_TOOL_ZLIB_0088 start==================
"
);
var
zipDest
=
dir
+
"
/noneexist.zip
"
var
unzipdir
=
dir
+
"
/SUB_BMS_TOOL_ZLIB_0088
"
;
var
options
=
{};
options
.
strategy
=
zlib
.
CompressStrategy
.
COMPRESS_STRATEGY_FIXED
;
fileio
.
mkdir
(
unzipdir
).
then
(
function
()
{
console
.
info
(
"
SUB_BMS_TOOL_ZLIB_0088 mkdir successfully
"
);
zlib
.
decompressFile
(
zipDest
,
unzipdir
,
options
).
then
(
data
=>
{
console
.
log
(
"
SUB_BMS_TOOL_ZLIB_0088 data:
"
+
data
);
expect
(
data
).
assertEqual
(
null
);
done
();
}).
catch
(
err
=>
{
console
.
log
(
"
decompress fail:
"
+
err
);
expect
(
err
.
code
).
assertEqual
(
SRC_FILE_INVALID
);
done
();
})
}).
catch
(
function
(
error
)
{
console
.
info
(
"
SUB_BMS_TOOL_ZLIB_0088 mkdir failed with error:
"
+
error
);
expect
(
error
).
assertFail
();
done
();
});
console
.
log
(
"
==================SUB_BMS_TOOL_ZLIB_0088 end==================
"
);
})
})
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录