Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
aeff23e2
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看板
未验证
提交
aeff23e2
编写于
5月 25, 2023
作者:
O
openharmony_ci
提交者:
Gitee
5月 25, 2023
浏览文件
操作
浏览文件
下载
差异文件
!8767 网络http_request2接口用例整改
Merge pull request !8767 from zhangfuzhi/cherry-pick-1685012534
上级
6a6e5dd2
8143ccbe
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
32 addition
and
53 deletion
+32
-53
telephony/telephonyjstest/netmanager_base/jshttp/src/main/js/test/HttpRequest2JsunitTest.js
...er_base/jshttp/src/main/js/test/HttpRequest2JsunitTest.js
+32
-53
未找到文件。
telephony/telephonyjstest/netmanager_base/jshttp/src/main/js/test/HttpRequest2JsunitTest.js
浏览文件 @
aeff23e2
...
...
@@ -25,25 +25,18 @@ let httpRequestOptions = {
connectTimeout
:
60000
};
let
delayTime
=
4000
;
let
dataReceive_status
;
let
dataProgress_status
;
let
dataEnd_status
;
let
Address_Baidu
=
"
https://www.baidu.com/
"
;
function
dataReceive_on_callback
(
data
)
{
console
.
log
(
"
dataReceive_on_callback receive len:
"
+
JSON
.
stringify
(
data
.
byteLength
));
dataReceive_status
=
true
;
}
function
dataEnd_on_callback
()
{
console
.
log
(
"
dataEnd_on_callback callback function
"
);
dataEnd_status
=
true
;
}
function
dataProgress_on_callback
(
data
)
{
console
.
log
(
"
dataProgress_on_callback receive datProgress:
"
+
JSON
.
stringify
(
data
));
dataProgress_status
=
true
;
}
export
default
function
HttpRequest2JsunitTest
()
{
...
...
@@ -61,7 +54,7 @@ export default function HttpRequest2JsunitTest() {
httpRequest
.
on
(
"
dataReceive
"
,
dataReceive_on_callback
);
httpRequest
.
on
(
"
dataProgress
"
,
dataProgress_on_callback
);
httpRequest
.
on
(
"
dataEnd
"
,
dataEnd_on_callback
);
httpRequest
.
request2
(
Address_Img
,
httpRequestOptions
,
(
err
,
data
)
=>
{
httpRequest
.
request2
(
Address_Img
,
httpRequestOptions
,
(
err
,
data
)
=>
{
console
.
info
(
CaseName
+
"
responseCode data :
"
+
data
);
console
.
log
(
CaseName
+
"
NETSTACK request2 OK!
"
);
httpRequest
.
off
(
"
dataReceive
"
);
...
...
@@ -70,11 +63,12 @@ export default function HttpRequest2JsunitTest() {
console
.
log
(
"
NETSTACK off dataProgress success!
"
);
httpRequest
.
off
(
"
dataEnd
"
);
console
.
log
(
"
NETSTACK off dataEnd success!
"
);
expect
(
data
==
200
).
assertTrue
();
httpRequest
.
destroy
();
done
();
})
}
catch
(
error
)
{
console
.
log
(
"
NETSTACK
request2 catch : error =
"
+
JSON
.
stringify
(
error
));
console
.
log
(
CaseName
+
"
request2 catch : error =
"
+
JSON
.
stringify
(
error
));
expect
(
error
).
assertFalse
();
done
();
}
...
...
@@ -89,7 +83,7 @@ export default function HttpRequest2JsunitTest() {
it
(
"
SUB_Telephony_NetStack_HttpRequest2_Async_0200
"
,
0
,
async
function
(
done
)
{
let
CaseName
=
"
SUB_Telephony_NetStack_HttpRequest2_Async_0200
"
var
httpRequest
=
http
.
createHttp
();
httpRequest
.
request2
(
Address_Baidu
,
(
err
,
data
)
=>
{
httpRequest
.
request2
(
Address_Baidu
,
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
log
(
CaseName
+
"
request2 ERROR
"
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
...
...
@@ -150,13 +144,11 @@ export default function HttpRequest2JsunitTest() {
try
{
var
httpRequest
=
http
.
createHttp
();
httpRequest
.
on
(
"
dataReceive
"
,
dataReceive_on_callback
);
httpRequest
.
request2
(
Address_Baidu
).
then
(
function
()
{
setTimeout
(()
=>
{
expect
(
dataReceive_status
).
assertEqual
(
true
);
httpRequest
.
request2
(
Address_Baidu
).
then
(
function
(
data
)
{
console
.
log
(
CaseName
+
"
on dataReceive Finish
"
);
expect
(
data
==
200
).
assertTrue
();
httpRequest
.
destroy
();
done
();
},
delayTime
);
}).
catch
(
function
(
err
)
{
console
.
log
(
CaseName
+
"
: error =
"
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
...
...
@@ -179,13 +171,11 @@ export default function HttpRequest2JsunitTest() {
let
CaseName
=
"
SUB_Telephony_NetStack_HttpRequest2_off_dataReceive_0100
"
;
try
{
var
httpRequest
=
http
.
createHttp
();
httpRequest
.
request2
(
Address_Baidu
).
then
(
function
()
{
httpRequest
.
on
(
"
dataReceive
"
,
dataReceive_on_callback
);
httpRequest
.
request2
(
Address_Baidu
).
then
(
function
(
data
)
{
httpRequest
.
off
(
"
dataReceive
"
,
dataReceive_on_callback
);
dataEnd_status
=
false
;
setTimeout
(()
=>
{
expect
(
dataReceive_status
).
assertEqual
(
false
);
},
delayTime
);
console
.
log
(
CaseName
+
"
off dataReceive Finish
"
);
expect
(
data
==
200
).
assertTrue
();
httpRequest
.
destroy
();
done
();
}).
catch
(
function
(
err
)
{
...
...
@@ -211,11 +201,10 @@ export default function HttpRequest2JsunitTest() {
try
{
var
httpRequest
=
http
.
createHttp
();
httpRequest
.
on
(
"
dataReceive
"
,
dataReceive_on_callback
);
httpRequest
.
request2
(
Address_Baidu
).
then
(
function
()
{
setTimeout
(()
=>
{
httpRequest
.
request2
(
Address_Baidu
).
then
(
function
(
data
)
{
httpRequest
.
off
(
"
dataReceive
"
);
},
delayTime
);
console
.
log
(
CaseName
+
"
off dataReceive Finish
"
);
expect
(
data
==
200
).
assertTrue
();
httpRequest
.
destroy
();
done
();
}).
catch
(
function
(
err
)
{
...
...
@@ -240,11 +229,9 @@ export default function HttpRequest2JsunitTest() {
try
{
var
httpRequest
=
http
.
createHttp
();
httpRequest
.
on
(
"
dataProgress
"
,
dataProgress_on_callback
);
httpRequest
.
request2
(
Address_Baidu
).
then
(
function
()
{
setTimeout
(()
=>
{
expect
(
dataProgress_status
).
assertEqual
(
true
);
},
delayTime
);
httpRequest
.
request2
(
Address_Baidu
).
then
(
function
(
data
)
{
console
.
log
(
CaseName
+
"
on dataProgress Finish
"
);
expect
(
data
==
200
).
assertTrue
();
httpRequest
.
destroy
();
done
();
}).
catch
(
function
(
err
)
{
...
...
@@ -268,13 +255,11 @@ export default function HttpRequest2JsunitTest() {
let
CaseName
=
"
SUB_Telephony_NetStack_HttpRequest2_off_dataProgress_0100
"
;
try
{
var
httpRequest
=
http
.
createHttp
();
httpRequest
.
request2
(
Address_Baidu
).
then
(
function
()
{
httpRequest
.
on
(
"
dataProgress
"
,
dataProgress_on_callback
);
httpRequest
.
request2
(
Address_Baidu
).
then
(
function
(
data
)
{
httpRequest
.
off
(
"
dataProgress
"
,
dataProgress_on_callback
);
dataEnd_status
=
false
;
setTimeout
(()
=>
{
expect
(
dataProgress_status
).
assertEqual
(
false
);
},
delayTime
);
console
.
log
(
CaseName
+
"
off dataProgress Finish
"
);
expect
(
data
==
200
).
assertTrue
();
httpRequest
.
destroy
();
done
();
}).
catch
(
function
(
err
)
{
...
...
@@ -300,11 +285,10 @@ export default function HttpRequest2JsunitTest() {
try
{
var
httpRequest
=
http
.
createHttp
();
httpRequest
.
on
(
"
dataProgress
"
,
dataProgress_on_callback
);
httpRequest
.
request2
(
Address_Baidu
).
then
(
function
()
{
setTimeout
(()
=>
{
httpRequest
.
request2
(
Address_Baidu
).
then
(
function
(
data
)
{
httpRequest
.
off
(
"
dataProgress
"
);
},
delayTime
);
console
.
log
(
CaseName
+
"
off dataProgress Finish
"
);
expect
(
data
==
200
).
assertTrue
();
httpRequest
.
destroy
();
done
();
}).
catch
(
function
(
err
)
{
...
...
@@ -330,11 +314,9 @@ export default function HttpRequest2JsunitTest() {
try
{
var
httpRequest
=
http
.
createHttp
();
httpRequest
.
on
(
"
dataEnd
"
,
dataEnd_on_callback
);
httpRequest
.
request2
(
Address_Baidu
).
then
(
function
()
{
setTimeout
(()
=>
{
expect
(
dataEnd_status
).
assertEqual
(
true
);
},
delayTime
);
httpRequest
.
request2
(
Address_Baidu
).
then
(
function
(
data
)
{
console
.
log
(
CaseName
+
"
on dataEnd Finish
"
);
expect
(
data
==
200
).
assertTrue
();
httpRequest
.
destroy
();
done
();
}).
catch
(
function
(
err
)
{
...
...
@@ -359,13 +341,11 @@ export default function HttpRequest2JsunitTest() {
let
CaseName
=
"
SUB_Telephony_NetStack_HttpRequest2_off_dataEnd_0100
"
;
try
{
var
httpRequest
=
http
.
createHttp
();
httpRequest
.
on
(
"
dataEnd
"
,
dataEnd_on_callback
);
httpRequest
.
request2
(
Address_Baidu
).
then
(
function
(
data
)
{
httpRequest
.
off
(
"
dataEnd
"
,
dataEnd_on_callback
);
dataEnd_status
=
false
;
httpRequest
.
request2
(
Address_Baidu
).
then
(
function
()
{
setTimeout
(()
=>
{
expect
(
dataEnd_status
).
assertEqual
(
false
);
},
delayTime
);
console
.
log
(
CaseName
+
"
off dataEnd Finish
"
);
expect
(
data
==
200
).
assertTrue
();
httpRequest
.
destroy
();
done
();
}).
catch
(
function
(
err
)
{
...
...
@@ -391,11 +371,10 @@ export default function HttpRequest2JsunitTest() {
try
{
var
httpRequest
=
http
.
createHttp
();
httpRequest
.
on
(
"
dataEnd
"
,
dataEnd_on_callback
);
httpRequest
.
request2
(
Address_Baidu
).
then
(
function
()
{
setTimeout
(()
=>
{
httpRequest
.
request2
(
Address_Baidu
).
then
(
function
(
data
)
{
httpRequest
.
off
(
"
dataEnd
"
);
},
delayTime
);
console
.
log
(
CaseName
+
"
off dataEnd Finish
"
);
expect
(
data
==
200
).
assertTrue
();
httpRequest
.
destroy
();
done
();
}).
catch
(
function
(
err
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录