Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
ff38126c
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看板
提交
ff38126c
编写于
7月 27, 2023
作者:
Z
zhangyushuai
1
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
request off 用例优化 002
Signed-off-by:
N
zhangyushuai
<
zhangyushuai1@huawei.com
>
上级
7ede3e8c
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
217 addition
and
56 deletion
+217
-56
request/RequestTest_ets/entry/src/main/ets/test/requestDownload.test.ets
...Test_ets/entry/src/main/ets/test/requestDownload.test.ets
+5
-5
request/newRequestAuthorityTest/entry/src/main/ets/test/requestDownload001.test.ets
...yTest/entry/src/main/ets/test/requestDownload001.test.ets
+153
-0
request/newRequestAuthorityTest/entry/src/main/ets/test/requestDownload002.test.ets
...yTest/entry/src/main/ets/test/requestDownload002.test.ets
+59
-51
未找到文件。
request/RequestTest_ets/entry/src/main/ets/test/requestDownload.test.ets
浏览文件 @
ff38126c
...
@@ -337,7 +337,7 @@ export default function requestDownloadJSUnit() {
...
@@ -337,7 +337,7 @@ export default function requestDownloadJSUnit() {
console
.
info
(
"====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0001 downloadTask: "
+
downloadTask
);
console
.
info
(
"====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0001 downloadTask: "
+
downloadTask
);
expect
(
downloadTask
!=
undefined
)
.
assertEqual
(
true
);
expect
(
downloadTask
!=
undefined
)
.
assertEqual
(
true
);
downloadTask
.
on
(
'progress'
,
async
(
data1
,
data2
)
=>
{
downloadTask
.
on
(
'progress'
,
async
(
data1
,
data2
)
=>
{
downloadTask
.
off
(
'progress'
,
async
(
data1
,
data2
)
=>
{}
);
downloadTask
.
off
(
'progress'
);
await
downloadTask
.
remove
();
await
downloadTask
.
remove
();
fileio
.
unlinkSync
(
filePath
);
fileio
.
unlinkSync
(
filePath
);
done
();
done
();
...
@@ -368,7 +368,7 @@ export default function requestDownloadJSUnit() {
...
@@ -368,7 +368,7 @@ export default function requestDownloadJSUnit() {
try
{
try
{
expect
(
downloadTask
!=
undefined
)
.
assertEqual
(
true
);
expect
(
downloadTask
!=
undefined
)
.
assertEqual
(
true
);
downloadTask
.
on
(
'complete'
,
()
=>
{});
downloadTask
.
on
(
'complete'
,
()
=>
{});
downloadTask
.
off
(
'complete'
,
async
()
=>
{}
);
downloadTask
.
off
(
'complete'
);
await
downloadTask
.
remove
();
await
downloadTask
.
remove
();
fileio
.
unlinkSync
(
filePath
);
fileio
.
unlinkSync
(
filePath
);
done
();
done
();
...
@@ -397,7 +397,7 @@ export default function requestDownloadJSUnit() {
...
@@ -397,7 +397,7 @@ export default function requestDownloadJSUnit() {
try
{
try
{
expect
(
downloadTask
!=
undefined
)
.
assertEqual
(
true
);
expect
(
downloadTask
!=
undefined
)
.
assertEqual
(
true
);
downloadTask
.
on
(
'pause'
,
()
=>
{});
downloadTask
.
on
(
'pause'
,
()
=>
{});
downloadTask
.
off
(
'pause'
,
async
()
=>
{}
);
downloadTask
.
off
(
'pause'
);
await
downloadTask
.
remove
();
await
downloadTask
.
remove
();
fileio
.
unlinkSync
(
filePath
);
fileio
.
unlinkSync
(
filePath
);
done
();
done
();
...
@@ -426,7 +426,7 @@ export default function requestDownloadJSUnit() {
...
@@ -426,7 +426,7 @@ export default function requestDownloadJSUnit() {
try
{
try
{
expect
(
downloadTask
!=
undefined
)
.
assertEqual
(
true
);
expect
(
downloadTask
!=
undefined
)
.
assertEqual
(
true
);
downloadTask
.
on
(
'remove'
,
()
=>
{});
downloadTask
.
on
(
'remove'
,
()
=>
{});
downloadTask
.
off
(
'remove'
,
async
()
=>
{}
);
downloadTask
.
off
(
'remove'
);
await
downloadTask
.
remove
();
await
downloadTask
.
remove
();
fileio
.
unlinkSync
(
filePath
);
fileio
.
unlinkSync
(
filePath
);
done
();
done
();
...
@@ -455,7 +455,7 @@ export default function requestDownloadJSUnit() {
...
@@ -455,7 +455,7 @@ export default function requestDownloadJSUnit() {
try
{
try
{
expect
(
downloadTask
!=
undefined
)
.
assertEqual
(
true
);
expect
(
downloadTask
!=
undefined
)
.
assertEqual
(
true
);
downloadTask
.
on
(
'fail'
,
(
data
)
=>
{});
downloadTask
.
on
(
'fail'
,
(
data
)
=>
{});
downloadTask
.
off
(
'fail'
,
async
(
err
)
=>
{}
);
downloadTask
.
off
(
'fail'
);
await
downloadTask
.
remove
();
await
downloadTask
.
remove
();
fileio
.
unlinkSync
(
filePath
);
fileio
.
unlinkSync
(
filePath
);
done
();
done
();
...
...
request/newRequestAuthorityTest/entry/src/main/ets/test/requestDownload001.test.ets
浏览文件 @
ff38126c
...
@@ -1038,6 +1038,159 @@ export default function requestDownloadOneJSUnitTest() {
...
@@ -1038,6 +1038,159 @@ export default function requestDownloadOneJSUnitTest() {
}
}
})
})
/**
* @tc.number SUB_Misc_REQUEST_Create_Callback_0070
* @tc.desc remove a download session.
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
*/
it
(
"SUB_Misc_REQUEST_Create_Callback_0070"
,
0
,
async
function
(
done
)
{
let
urls
=
'x'
;
for
(
let
i
=
0
;
i
<
2030
;
i
++
){
urls
+=
'x'
;
}
let
config
=
{
action
:
request
.
agent
.
Action
.
DOWNLOAD
,
url
:
'https://'
+
urls
+
'/test.apk'
,
title
:
'createTest'
,
description
:
"XTS download test!"
,
mode
:
request
.
agent
.
Mode
.
BACKGROUND
,
overwrite
:
true
,
saveas
:
"./SUB_Misc_REQUEST_Create_Callback_0070.txt"
,
network
:
request
.
agent
.
Network
.
WIFI
,
};
console
.
info
(
"====>-------------------SUB_Misc_REQUEST_Create_Callback_0070 is start ---------------------"
);
request
.
agent
.
create
(
globalThis
.
abilityContext
,
config
,
async
(
err
,
task
)
=>
{
try
{
if
(
err
){
console
.
info
(
`====>SUB_Misc_REQUEST_Create_Callback_0070 task creat fail: `
+
JSON
.
stringify
(
err
));
expect
()
.
assertFail
();
}
console
.
info
(
`====>SUB_Misc_REQUEST_Create_Callback_0070 Succeeded download task length: `
+
task
.
config
.
url
.
length
);
await
request
.
agent
.
remove
(
task
.
tid
);
done
();
}
catch
(
err
)
{
console
.
info
(
`====>SUB_Misc_REQUEST_Create_Callback_0070 Succeeded in starting a download task.`
+
JSON
.
stringify
(
err
));
done
();
}
});
})
/**
* @tc.number SUB_Misc_REQUEST_Create_Promise_0070
* @tc.desc remove a download session.
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
*/
it
(
"SUB_Misc_REQUEST_Create_Promise_0070"
,
0
,
async
function
(
done
)
{
let
urls
=
'x'
;
for
(
let
i
=
0
;
i
<
2030
;
i
++
){
urls
+=
'x'
;
}
let
config
=
{
action
:
request
.
agent
.
Action
.
DOWNLOAD
,
url
:
'https://'
+
urls
+
'/test.apk'
,
title
:
'createTest'
,
description
:
"XTS download test!"
,
mode
:
request
.
agent
.
Mode
.
BACKGROUND
,
overwrite
:
true
,
saveas
:
"./SUB_Misc_REQUEST_Create_Promise_0070.txt"
,
network
:
request
.
agent
.
Network
.
WIFI
,
};
console
.
info
(
"====>-------------SUB_Misc_REQUEST_Create_Promise_0070 is starting----------------"
);
try
{
let
task
=
await
request
.
agent
.
create
(
globalThis
.
abilityContext
,
config
);
console
.
info
(
`====>SUB_Misc_REQUEST_Create_Promise_0070 Succeeded download task length: `
+
task
.
config
.
url
.
length
);
await
request
.
agent
.
remove
(
task
.
tid
);
expect
(
true
)
.
assertTrue
();
done
();
}
catch
(
err
){
console
.
info
(
"====>SUB_Misc_REQUEST_Create_Promise_0070 create err: "
+
JSON
.
stringify
(
err
));
expect
()
.
assertFail
();
console
.
info
(
"-----------------------SUB_Misc_REQUEST_Create_Promise_0070 is end-----------------------"
);
done
();
}
})
/**
* @tc.number SUB_Misc_REQUEST_Create_Callback_0080
* @tc.desc remove a download session.
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
*/
it
(
"SUB_Misc_REQUEST_Create_Callback_0080"
,
0
,
async
function
(
done
)
{
let
urls
=
'x'
;
for
(
let
i
=
0
;
i
<
2031
;
i
++
){
urls
+=
'x'
;
}
let
config
=
{
action
:
request
.
agent
.
Action
.
DOWNLOAD
,
url
:
'https://'
+
urls
+
'/test.apk'
,
title
:
'createTest'
,
description
:
"XTS download test!"
,
mode
:
request
.
agent
.
Mode
.
BACKGROUND
,
overwrite
:
true
,
saveas
:
"./SUB_Misc_REQUEST_Create_Callback_0080.txt"
,
network
:
request
.
agent
.
Network
.
WIFI
,
};
console
.
info
(
"====>-------------------SUB_Misc_REQUEST_Create_Callback_0080 is start ---------------------"
);
try
{
request
.
agent
.
create
(
globalThis
.
abilityContext
,
config
,
(
err
,
task
)
=>
{
try
{
console
.
info
(
`====>SUB_Misc_REQUEST_Create_Callback_0080 Succeeded in starting a download task.`
);
expect
()
.
assertFail
();
}
catch
(
err
)
{
console
.
info
(
`====>SUB_Misc_REQUEST_Create_Callback_0080 Succeeded in starting a download task.`
+
JSON
.
stringify
(
err
));
request
.
agent
.
remove
(
task
.
tid
);
done
();
}
});
}
catch
(
err
){
console
.
info
(
"====>SUB_Misc_REQUEST_Create_Callback_0080 create err: "
+
JSON
.
stringify
(
err
));
console
.
info
(
"-----------------------SUB_Misc_REQUEST_Create_Callback_0080 is end-----------------------"
);
expect
(
err
.
code
)
.
assertEqual
(
401
);
done
();
}
})
/**
* @tc.number SUB_Misc_REQUEST_Create_Promise_0080
* @tc.desc remove a download session.
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
*/
it
(
"SUB_Misc_REQUEST_Create_Promise_0080"
,
0
,
async
function
(
done
)
{
let
urls
=
'x'
;
for
(
let
i
=
0
;
i
<
2031
;
i
++
){
urls
+=
'x'
;
}
let
config
=
{
action
:
request
.
agent
.
Action
.
DOWNLOAD
,
url
:
'https://'
+
urls
+
'/test.apk'
,
title
:
'createTest'
,
description
:
"XTS download test!"
,
mode
:
request
.
agent
.
Mode
.
BACKGROUND
,
overwrite
:
true
,
saveas
:
"./SUB_Misc_REQUEST_Create_Promise_0080.txt"
,
network
:
request
.
agent
.
Network
.
WIFI
,
};
console
.
info
(
"====>-------------SUB_Misc_REQUEST_Create_Promise_0080 is starting----------------"
);
try
{
await
request
.
agent
.
create
(
globalThis
.
abilityContext
,
config
);
console
.
info
(
`====>SUB_Misc_REQUEST_Create_Promise_0080 Succeeded in starting a download task.`
);
expect
()
.
assertFail
();
}
catch
(
err
){
console
.
info
(
"====>SUB_Misc_REQUEST_Create_Promise_0080 create err: "
+
JSON
.
stringify
(
err
));
expect
(
err
.
code
)
.
assertEqual
(
401
);
console
.
info
(
"-----------------------SUB_Misc_REQUEST_Create_Promise_0080 is end-----------------------"
);
done
();
}
})
/**
/**
* @tc.number SUB_Misc_REQUEST_Create_Promise_0110
* @tc.number SUB_Misc_REQUEST_Create_Promise_0110
* @tc.desc remove a download session.
* @tc.desc remove a download session.
...
...
request/newRequestAuthorityTest/entry/src/main/ets/test/requestDownload002.test.ets
浏览文件 @
ff38126c
...
@@ -237,6 +237,7 @@ export default function requestDownloadTwoUnitTest() {
...
@@ -237,6 +237,7 @@ export default function requestDownloadTwoUnitTest() {
console
.
info
(
"====>SUB_Misc_REQUEST_Off_Download_Progress_0020 on_progressCallback flag: "
+
flag
);
console
.
info
(
"====>SUB_Misc_REQUEST_Off_Download_Progress_0020 on_progressCallback flag: "
+
flag
);
}
}
let
on_progressCallback1
=
(
pro
)
=>
{
let
on_progressCallback1
=
(
pro
)
=>
{
task
.
off
(
'progress'
);
flag1
=
false
;
flag1
=
false
;
console
.
info
(
"====>SUB_Misc_REQUEST_Off_Download_Progress_0020 on_progressCallback1 flag1: "
+
flag1
);
console
.
info
(
"====>SUB_Misc_REQUEST_Off_Download_Progress_0020 on_progressCallback1 flag1: "
+
flag1
);
expect
(
true
)
.
assertTrue
();
expect
(
true
)
.
assertTrue
();
...
@@ -537,6 +538,7 @@ export default function requestDownloadTwoUnitTest() {
...
@@ -537,6 +538,7 @@ export default function requestDownloadTwoUnitTest() {
console
.
info
(
"====>SUB_Misc_REQUEST_Off_Download_Completed_0020 on_progressCallback flag: "
+
flag
);
console
.
info
(
"====>SUB_Misc_REQUEST_Off_Download_Completed_0020 on_progressCallback flag: "
+
flag
);
}
}
let
on_progressCallback1
=
(
pro
)
=>
{
let
on_progressCallback1
=
(
pro
)
=>
{
task
.
off
(
'completed'
);
flag1
=
false
;
flag1
=
false
;
console
.
info
(
"====>SUB_Misc_REQUEST_Off_Download_Completed_0020 on_progressCallback1 flag1: "
+
flag1
);
console
.
info
(
"====>SUB_Misc_REQUEST_Off_Download_Completed_0020 on_progressCallback1 flag1: "
+
flag1
);
expect
(
true
)
.
assertTrue
();
expect
(
true
)
.
assertTrue
();
...
@@ -837,6 +839,7 @@ export default function requestDownloadTwoUnitTest() {
...
@@ -837,6 +839,7 @@ export default function requestDownloadTwoUnitTest() {
console
.
info
(
"====>SUB_Misc_REQUEST_Off_Download_Failed_0020 on_progressCallback flag: "
+
flag
);
console
.
info
(
"====>SUB_Misc_REQUEST_Off_Download_Failed_0020 on_progressCallback flag: "
+
flag
);
}
}
let
on_progressCallback1
=
(
pro
)
=>
{
let
on_progressCallback1
=
(
pro
)
=>
{
task
.
off
(
'failed'
);
flag1
=
false
;
flag1
=
false
;
console
.
info
(
"====>SUB_Misc_REQUEST_Off_Download_Failed_0020 on_progressCallback1 flag1: "
+
flag1
);
console
.
info
(
"====>SUB_Misc_REQUEST_Off_Download_Failed_0020 on_progressCallback1 flag1: "
+
flag1
);
expect
(
true
)
.
assertTrue
();
expect
(
true
)
.
assertTrue
();
...
@@ -1881,32 +1884,33 @@ export default function requestDownloadTwoUnitTest() {
...
@@ -1881,32 +1884,33 @@ export default function requestDownloadTwoUnitTest() {
let
task
:
request
.
agent
.
Task
let
task
:
request
.
agent
.
Task
function
onCompletedCallback
(
progress
){
function
onCompletedCallback
(
progress
){
console
.
debug
(
'====>SUB_Misc_REQUEST_Touch_Callback_0010 onCompletedCallback start'
)
task
.
off
(
'completed'
);
console
.
debug
(
'====>SUB_Misc_REQUEST_Touch_Callback_0010 onCompletedCallback start'
);
request
.
agent
.
touch
(
task
.
tid
,
config
.
token
,(
err
,
taskInfo
)
=>
{
request
.
agent
.
touch
(
task
.
tid
,
config
.
token
,(
err
,
taskInfo
)
=>
{
try
{
try
{
if
(
err
){
if
(
err
){
console
.
debug
(
'====>SUB_Misc_REQUEST_Touch_Callback_0010 err:'
+
JSON
.
stringify
(
err
))
console
.
debug
(
'====>SUB_Misc_REQUEST_Touch_Callback_0010 err:'
+
JSON
.
stringify
(
err
))
;
expect
()
.
assertFail
()
expect
()
.
assertFail
()
;
done
();
done
();
}
}
expect
(
taskInfo
.
url
)
.
assertEqual
(
config
.
url
)
expect
(
taskInfo
.
url
)
.
assertEqual
(
config
.
url
)
;
expect
(
taskInfo
.
data
)
.
assertEqual
(
""
)
expect
(
taskInfo
.
data
)
.
assertEqual
(
""
)
;
expect
(
taskInfo
.
title
)
.
assertEqual
(
config
.
title
)
expect
(
taskInfo
.
title
)
.
assertEqual
(
config
.
title
)
;
done
();
done
();
}
catch
(
err
){
}
catch
(
err
){
console
.
debug
(
'====>SUB_Misc_REQUEST_Touch_Callback_0010 touch throw_err:'
+
JSON
.
stringify
(
err
))
console
.
debug
(
'====>SUB_Misc_REQUEST_Touch_Callback_0010 touch throw_err:'
+
JSON
.
stringify
(
err
))
;
done
();
done
();
}
}
})
})
}
}
try
{
try
{
task
=
await
request
.
agent
.
create
(
globalThis
.
abilityContext
,
config
)
task
=
await
request
.
agent
.
create
(
globalThis
.
abilityContext
,
config
)
;
task
.
on
(
'completed'
,
onCompletedCallback
)
task
.
on
(
'completed'
,
onCompletedCallback
)
;
await
task
.
start
()
await
task
.
start
()
;
}
catch
(
err
){
}
catch
(
err
){
console
.
debug
(
'====>SUB_Misc_REQUEST_Touch_Callback_0010 create throw_err:'
+
JSON
.
stringify
(
err
))
console
.
debug
(
'====>SUB_Misc_REQUEST_Touch_Callback_0010 create throw_err:'
+
JSON
.
stringify
(
err
))
;
expect
()
.
assertFail
()
expect
()
.
assertFail
()
;
done
();
done
();
}
}
...
@@ -1934,25 +1938,26 @@ export default function requestDownloadTwoUnitTest() {
...
@@ -1934,25 +1938,26 @@ export default function requestDownloadTwoUnitTest() {
let
task
:
request
.
agent
.
Task
let
task
:
request
.
agent
.
Task
async
function
onCompletedCallback
(
progress
){
async
function
onCompletedCallback
(
progress
){
console
.
debug
(
'====>SUB_Misc_REQUEST_Touch_Promise_0010 onCompletedCallback start'
)
task
.
off
(
'completed'
);
console
.
debug
(
'====>SUB_Misc_REQUEST_Touch_Promise_0010 onCompletedCallback start'
);
try
{
try
{
let
taskInfo
=
await
request
.
agent
.
touch
(
task
.
tid
,
config
.
token
)
let
taskInfo
=
await
request
.
agent
.
touch
(
task
.
tid
,
config
.
token
)
;
expect
(
taskInfo
.
title
)
.
assertEqual
(
config
.
title
)
expect
(
taskInfo
.
title
)
.
assertEqual
(
config
.
title
)
;
done
();
done
();
}
catch
(
err
){
}
catch
(
err
){
console
.
debug
(
'====>SUB_Misc_REQUEST_Touch_Promise_0010 touch throw_err:'
+
JSON
.
stringify
(
err
))
console
.
debug
(
'====>SUB_Misc_REQUEST_Touch_Promise_0010 touch throw_err:'
+
JSON
.
stringify
(
err
))
;
expect
()
.
assertFail
()
expect
()
.
assertFail
()
;
done
();
done
();
}
}
}
}
try
{
try
{
task
=
await
request
.
agent
.
create
(
globalThis
.
abilityContext
,
config
)
task
=
await
request
.
agent
.
create
(
globalThis
.
abilityContext
,
config
)
;
task
.
on
(
'completed'
,
onCompletedCallback
)
task
.
on
(
'completed'
,
onCompletedCallback
)
;
await
task
.
start
()
await
task
.
start
()
;
}
catch
(
err
){
}
catch
(
err
){
console
.
debug
(
'====>SUB_Misc_REQUEST_Touch_Promise_0010 create throw_err:'
+
JSON
.
stringify
(
err
))
console
.
debug
(
'====>SUB_Misc_REQUEST_Touch_Promise_0010 create throw_err:'
+
JSON
.
stringify
(
err
))
;
expect
()
.
assertFail
()
expect
()
.
assertFail
()
;
done
();
done
();
}
}
...
@@ -1980,27 +1985,28 @@ export default function requestDownloadTwoUnitTest() {
...
@@ -1980,27 +1985,28 @@ export default function requestDownloadTwoUnitTest() {
let
task
:
request
.
agent
.
Task
let
task
:
request
.
agent
.
Task
function
onCompletedCallback
(
progress
){
function
onCompletedCallback
(
progress
){
console
.
debug
(
'====>SUB_Misc_REQUEST_Touch_Callback_0020 onCompletedCallback start'
)
task
.
off
(
'completed'
);
console
.
debug
(
'====>SUB_Misc_REQUEST_Touch_Callback_0020 onCompletedCallback start'
);
try
{
try
{
// @ts-ignore
// @ts-ignore
request
.
agent
.
touch
({},
config
.
token
,(
err
,
taskInfo
)
=>
{
request
.
agent
.
touch
({},
config
.
token
,(
err
,
taskInfo
)
=>
{
expect
()
.
assertFail
()
expect
()
.
assertFail
()
;
done
();
done
();
})
})
}
catch
(
err
){
}
catch
(
err
){
console
.
debug
(
'====>SUB_Misc_REQUEST_Touch_Callback_0020 touch throw_err:'
+
JSON
.
stringify
(
err
))
console
.
debug
(
'====>SUB_Misc_REQUEST_Touch_Callback_0020 touch throw_err:'
+
JSON
.
stringify
(
err
))
;
expect
(
err
.
code
)
.
assertEqual
(
401
)
expect
(
err
.
code
)
.
assertEqual
(
401
)
;
done
();
done
();
}
}
}
}
try
{
try
{
task
=
await
request
.
agent
.
create
(
globalThis
.
abilityContext
,
config
)
task
=
await
request
.
agent
.
create
(
globalThis
.
abilityContext
,
config
)
;
task
.
on
(
'completed'
,
onCompletedCallback
)
task
.
on
(
'completed'
,
onCompletedCallback
)
;
await
task
.
start
()
await
task
.
start
()
;
}
catch
(
err
){
}
catch
(
err
){
console
.
debug
(
'====>SUB_Misc_REQUEST_Touch_Callback_0020 create throw_err:'
+
JSON
.
stringify
(
err
))
console
.
debug
(
'====>SUB_Misc_REQUEST_Touch_Callback_0020 create throw_err:'
+
JSON
.
stringify
(
err
))
;
expect
()
.
assertFail
()
expect
()
.
assertFail
()
;
done
();
done
();
}
}
...
@@ -2028,26 +2034,27 @@ export default function requestDownloadTwoUnitTest() {
...
@@ -2028,26 +2034,27 @@ export default function requestDownloadTwoUnitTest() {
let
task
:
request
.
agent
.
Task
let
task
:
request
.
agent
.
Task
async
function
onCompletedCallback
(
progress
){
async
function
onCompletedCallback
(
progress
){
console
.
debug
(
'====>SUB_Misc_REQUEST_Touch_Promise_0030 onCompletedCallback start'
)
task
.
off
(
'completed'
);
console
.
debug
(
'====>SUB_Misc_REQUEST_Touch_Promise_0030 onCompletedCallback start'
);
try
{
try
{
// @ts-ignore
// @ts-ignore
let
taskInfo
=
await
request
.
agent
.
touch
(
task
.
tid
,
{})
let
taskInfo
=
await
request
.
agent
.
touch
(
task
.
tid
,
{})
;
expect
()
.
assertFail
()
expect
()
.
assertFail
()
;
done
();
done
();
}
catch
(
err
){
}
catch
(
err
){
console
.
debug
(
'====>SUB_Misc_REQUEST_Touch_Promise_0030 touch throw_err:'
+
JSON
.
stringify
(
err
))
console
.
debug
(
'====>SUB_Misc_REQUEST_Touch_Promise_0030 touch throw_err:'
+
JSON
.
stringify
(
err
))
;
expect
(
err
.
code
)
.
assertEqual
(
401
)
expect
(
err
.
code
)
.
assertEqual
(
401
)
;
done
();
done
();
}
}
}
}
try
{
try
{
task
=
await
request
.
agent
.
create
(
globalThis
.
abilityContext
,
config
)
task
=
await
request
.
agent
.
create
(
globalThis
.
abilityContext
,
config
)
;
task
.
on
(
'completed'
,
onCompletedCallback
)
task
.
on
(
'completed'
,
onCompletedCallback
)
;
await
task
.
start
()
await
task
.
start
()
;
}
catch
(
err
){
}
catch
(
err
){
console
.
debug
(
'====>SUB_Misc_REQUEST_Touch_Promise_0030 create throw_err:'
+
JSON
.
stringify
(
err
))
console
.
debug
(
'====>SUB_Misc_REQUEST_Touch_Promise_0030 create throw_err:'
+
JSON
.
stringify
(
err
))
;
expect
()
.
assertFail
()
expect
()
.
assertFail
()
;
done
();
done
();
}
}
...
@@ -2075,27 +2082,28 @@ export default function requestDownloadTwoUnitTest() {
...
@@ -2075,27 +2082,28 @@ export default function requestDownloadTwoUnitTest() {
let
task
:
request
.
agent
.
Task
let
task
:
request
.
agent
.
Task
function
onCompletedCallback
(
progress
){
function
onCompletedCallback
(
progress
){
console
.
debug
(
'====>SUB_Misc_REQUEST_Touch_Callback_0040 onCompletedCallback start'
)
task
.
off
(
'completed'
);
console
.
debug
(
'====>SUB_Misc_REQUEST_Touch_Callback_0040 onCompletedCallback start'
);
try
{
try
{
request
.
agent
.
touch
(
task
.
tid
,
config
.
token
+
'1'
,(
err
,
taskInfo
)
=>
{
request
.
agent
.
touch
(
task
.
tid
,
config
.
token
+
'1'
,(
err
,
taskInfo
)
=>
{
console
.
debug
(
'====>SUB_Misc_REQUEST_Touch_Callback_0040 touch err:'
+
JSON
.
stringify
(
err
))
console
.
debug
(
'====>SUB_Misc_REQUEST_Touch_Callback_0040 touch err:'
+
JSON
.
stringify
(
err
))
;
expect
(
err
.
code
)
.
assertEqual
(
21900006
)
expect
(
err
.
code
)
.
assertEqual
(
21900006
)
;
done
();
done
();
})
})
}
catch
(
err
){
}
catch
(
err
){
console
.
debug
(
'====>SUB_Misc_REQUEST_Touch_Callback_0040 touch throw_err:'
+
JSON
.
stringify
(
err
))
console
.
debug
(
'====>SUB_Misc_REQUEST_Touch_Callback_0040 touch throw_err:'
+
JSON
.
stringify
(
err
))
;
expect
()
.
assertFail
()
expect
()
.
assertFail
()
;
done
();
done
();
}
}
}
}
try
{
try
{
task
=
await
request
.
agent
.
create
(
globalThis
.
abilityContext
,
config
)
task
=
await
request
.
agent
.
create
(
globalThis
.
abilityContext
,
config
)
;
task
.
on
(
'completed'
,
onCompletedCallback
)
task
.
on
(
'completed'
,
onCompletedCallback
)
;
await
task
.
start
()
await
task
.
start
()
;
}
catch
(
err
){
}
catch
(
err
){
console
.
debug
(
'====>SUB_Misc_REQUEST_Touch_Callback_0040 create throw_err:'
+
JSON
.
stringify
(
err
))
console
.
debug
(
'====>SUB_Misc_REQUEST_Touch_Callback_0040 create throw_err:'
+
JSON
.
stringify
(
err
))
;
expect
()
.
assertFail
()
expect
()
.
assertFail
()
;
done
();
done
();
}
}
...
...
鸿蒙社区
@harmonycommunity
mentioned in commit
39e4f26e
·
7月 30, 2023
mentioned in commit
39e4f26e
mentioned in commit 39e4f26ead04ca8267cc8afdb0153796c4e6e9f7
开关提交列表
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录