Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
d9581f4e
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,发现更多精彩内容 >>
提交
d9581f4e
编写于
3月 16, 2022
作者:
W
weier
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Signed-off-by: weier <duanlinrang@huawei.com>
Changes to be committed:
上级
12f49a2d
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
30 addition
and
121 deletion
+30
-121
miscservices/RequestTest_js/entry/src/main/js/Test/Publicfunction.js
...s/RequestTest_js/entry/src/main/js/Test/Publicfunction.js
+8
-4
miscservices/RequestTest_js/entry/src/main/js/Test/UploadCallbackXTSJsunit.test.js
...js/entry/src/main/js/Test/UploadCallbackXTSJsunit.test.js
+22
-117
未找到文件。
miscservices/RequestTest_js/entry/src/main/js/Test/Publicfunction.js
浏览文件 @
d9581f4e
...
@@ -31,15 +31,19 @@ function getUploadConfig(fileurl){
...
@@ -31,15 +31,19 @@ function getUploadConfig(fileurl){
let
File
=
{
let
File
=
{
filename
:
'
test
'
,
// When multipart is submitted, the file name in the request header.
filename
:
'
test
'
,
// When multipart is submitted, the file name in the request header.
name
:
'
test
'
,
// When multipart is submitted, the name of the form item. The default is file.
name
:
'
test
'
,
// When multipart is submitted, the name of the form item. The default is file.
uri
:
'
internal://cache/test.txt
'
,
//The local storage path of the file (please refer to the storage directory definition for path usage).
uri
:
'
internal://cache/test.txt
'
,
type
:
'
txt
'
//The content type of the file is obtained by default according to the suffix of the file name or path.
//The local storage path of the file
// (please refer to the storage directory definition for path usage).
type
:
'
txt
'
//The content type of the file is obtained by default
// according to the suffix of the file name or path.
}
}
let
FileArray
=
new
Array
();
let
FileArray
=
new
Array
();
FileArray
[
0
]
=
File
;
FileArray
[
0
]
=
File
;
let
header_h
ttp
=
{
headers
:
'
http
'
}
let
Header_H
ttp
=
{
headers
:
'
http
'
}
let
UploadConfig
=
{
let
UploadConfig
=
{
url
:
'
http://192.168.112.124/upload_test/
'
,
// Resource address.
url
:
'
http://192.168.112.124/upload_test/
'
,
// Resource address.
header
:
header_h
ttp
,
// Adds an HTTP or HTTPS header to be included with the upload request.
header
:
Header_H
ttp
,
// Adds an HTTP or HTTPS header to be included with the upload request.
method
:
'
POST
'
,
// Request method: POST, PUT. The default POST.
method
:
'
POST
'
,
// Request method: POST, PUT. The default POST.
files
:
FileArray
,
// A list of files to be uploaded. Please use multipart/form-data to submit.
files
:
FileArray
,
// A list of files to be uploaded. Please use multipart/form-data to submit.
data
:
RequestData
// The requested form data.
data
:
RequestData
// The requested form data.
...
...
miscservices/RequestTest_js/entry/src/main/js/Test/UploadCallbackXTSJsunit.test.js
浏览文件 @
d9581f4e
...
@@ -17,27 +17,28 @@ import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '
...
@@ -17,27 +17,28 @@ import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '
import
request
from
'
@ohos.request
'
;
import
request
from
'
@ohos.request
'
;
import
*
as
pubfun
from
'
./Publicfunction.js
'
import
*
as
pubfun
from
'
./Publicfunction.js
'
var
type_p
rogress
=
'
progress
'
;
var
Type_P
rogress
=
'
progress
'
;
var
t
ype_HeaderReceive
=
'
headerReceive
'
;
var
T
ype_HeaderReceive
=
'
headerReceive
'
;
var
t
ype_Fail
=
'
fail
'
;
var
T
ype_Fail
=
'
fail
'
;
let
uploadTask
;
let
uploadTask
;
let
file7url
=
'
internal://cache/test.txt
'
;
let
file7url
=
'
internal://cache/test.txt
'
;
//let file10kurl = '';
//let file10murl = '';
// var shell = require('shelljs')
describe
(
'
UploadTest
'
,
function
()
{
describe
(
'
UploadTest
'
,
function
()
{
beforeAll
(
function
()
{
beforeAll
(
function
()
{
console
.
info
(
'
beforeAll: Prerequisites at the test suite level, which are executed before the test suite is executed.
'
);
console
.
info
(
'
beforeAll: Prerequisites at the test suite level,
'
+
'
which are executed before the test suite is executed.
'
);
})
})
beforeEach
(
function
()
{
beforeEach
(
function
()
{
console
.
info
(
'
beforeEach: Prerequisites at the test case level, which are executed before each test case is executed.
'
);
console
.
info
(
'
beforeEach: Prerequisites at the test case level,
'
+
'
which are executed before each test case is executed.
'
);
})
})
afterEach
(
function
()
{
afterEach
(
function
()
{
console
.
info
(
'
afterEach: Test case-level clearance conditions, which are executed after each test case is executed.
'
);
console
.
info
(
'
afterEach: Test case-level clearance conditions,
'
+
'
which are executed after each test case is executed.
'
);
})
})
afterAll
(
function
()
{
afterAll
(
function
()
{
console
.
info
(
'
afterAll: Test suite-level cleanup condition, which is executed after the test suite is executed
'
);
console
.
info
(
'
afterAll: Test suite-level cleanup condition,
'
+
'
which is executed after the test suite is executed
'
);
})
})
/*
/*
* @tc.number : InitUploadtaskCallback001
* @tc.number : InitUploadtaskCallback001
...
@@ -49,12 +50,6 @@ describe('UploadTest', function () {
...
@@ -49,12 +50,6 @@ describe('UploadTest', function () {
*/
*/
it
(
'
InitUploadtaskCallback001
'
,
0
,
async
function
(
done
)
{
it
(
'
InitUploadtaskCallback001
'
,
0
,
async
function
(
done
)
{
try
{
try
{
// const cmd = `echo \"123456\" > /data/accounts/account_0/appdata/com.example.myapplication.hmservice/cache/test.txt`;
// shell.exec(cmd, (err) => {
// if (err) {
// throw Error(err).message;
// }
// })
console
.
log
(
"
Testupdate before getuploadconfig
"
);
console
.
log
(
"
Testupdate before getuploadconfig
"
);
let
UploadConfig
=
pubfun
.
getUploadConfig
(
file7url
)
let
UploadConfig
=
pubfun
.
getUploadConfig
(
file7url
)
console
.
log
(
"
Testupdate before upload UploadConfig =
"
+
JSON
.
stringify
(
UploadConfig
));
console
.
log
(
"
Testupdate before upload UploadConfig =
"
+
JSON
.
stringify
(
UploadConfig
));
...
@@ -75,6 +70,7 @@ describe('UploadTest', function () {
...
@@ -75,6 +70,7 @@ describe('UploadTest', function () {
done
();
done
();
}
}
})
})
/*
/*
* @tc.number : SwitchOnProgressCallback001
* @tc.number : SwitchOnProgressCallback001
* @tc.name : Use getEntries get the value by mixing the string key
* @tc.name : Use getEntries get the value by mixing the string key
...
@@ -85,18 +81,7 @@ describe('UploadTest', function () {
...
@@ -85,18 +81,7 @@ describe('UploadTest', function () {
*/
*/
it
(
'
SwitchOnProgressCallback001
'
,
0
,
async
function
(
done
)
{
it
(
'
SwitchOnProgressCallback001
'
,
0
,
async
function
(
done
)
{
try
{
try
{
/*console.log("Testupdate before getuploadconfig");
pubfun
.
publiconprogress
(
uploadTask
,
Type_Progress
);
let UploadConfig = pubfun.getUploadConfig(file7url)
console.log("Testupdate before upload UploadConfig = " + JSON.stringify(UploadConfig));
console.log("Testupdate before upload");
await pubfun.publicupload(UploadConfig).then((data) => {
console.log("Testupdate going upload uploadTask = " + data);
uploadTask = data;
}).catch((err) => {
console.log("SwitchOnProgressCallback001 fail" + JSON.stringify(err));
})*/
pubfun
.
publiconprogress
(
uploadTask
,
type_progress
);
expect
(
true
).
assertEqual
(
0
==
0
);
expect
(
true
).
assertEqual
(
0
==
0
);
done
();
done
();
}
catch
(
err
)
{
}
catch
(
err
)
{
...
@@ -105,6 +90,7 @@ describe('UploadTest', function () {
...
@@ -105,6 +90,7 @@ describe('UploadTest', function () {
done
();
done
();
}
}
});
});
/*
/*
* @tc.number : SwitchOffProgressCallback001
* @tc.number : SwitchOffProgressCallback001
* @tc.name : Use getEntries get the value by mixing the string key
* @tc.name : Use getEntries get the value by mixing the string key
...
@@ -115,17 +101,10 @@ describe('UploadTest', function () {
...
@@ -115,17 +101,10 @@ describe('UploadTest', function () {
*/
*/
it
(
'
SwitchOffProgressCallback001
'
,
0
,
async
function
(
done
)
{
it
(
'
SwitchOffProgressCallback001
'
,
0
,
async
function
(
done
)
{
try
{
try
{
/*let UploadConfig = pubfun.getUploadConfig(file7url)
pubfun
.
publiconprogress
(
uploadTask
,
Type_Progress
);
await pubfun.publicupload(UploadConfig).then((data) => {
uploadTask = data;
}).catch((err) => {
console.log("SwitchOffProgressCallback001 fail 1" + JSON.stringify(err));
})*/
pubfun
.
publiconprogress
(
uploadTask
,
type_progress
);
expect
(
true
).
assertEqual
(
0
==
0
);
expect
(
true
).
assertEqual
(
0
==
0
);
await
pubfun
.
publicoffprogress
(
uploadTask
,
type_p
rogress
).
then
((
data
)
=>
{
await
pubfun
.
publicoffprogress
(
uploadTask
,
Type_P
rogress
).
then
((
data
)
=>
{
console
.
log
(
"
SwitchOffProgressCallback001 data
"
+
JSON
.
stringify
(
data
));
console
.
log
(
"
SwitchOffProgressCallback001 data
"
+
JSON
.
stringify
(
data
));
expect
(
7
).
assertEqual
(
data
.
totalSize
);
expect
(
7
).
assertEqual
(
data
.
totalSize
);
done
();
done
();
...
@@ -140,62 +119,7 @@ describe('UploadTest', function () {
...
@@ -140,62 +119,7 @@ describe('UploadTest', function () {
done
();
done
();
}
}
})
})
/*
* @tc.number : SwitchOnHeaderReceiveCallback001
* @tc.name : Use getEntries get the value by mixing the string key
* @tc.desc : Mixed strings value can be obtained correctly
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 1
*/
/*it('SwitchOnHeaderReceiveCallback001', 0, async function (done) {
try {
let UploadConfig = pubfun.getUploadConfig(file7url)
await pubfun.publicupload(UploadConfig).then((data) => {
uploadTask = data;
}).catch((err) => {
console.log("SwitchOnHeaderReceiveCallback001 fail 1" + JSON.stringify(err));
})
await pubfun.publicon(uploadTask,type_HeaderReceive).then((data) => {
console.info("upOnHeader headers:" + JSON.stringify(data));
expect('待确认').assertEqual(data);
done();
}).catch((err) => {
console.log("SwitchOnHeaderReceiveCallback001 fail 2" + JSON.stringify(err));
})
} catch (e) {
console.log("SwitchOnHeaderReceiveCallback001 fail 3" + JSON.stringify(e));
expect(null).assertFail();
}
})
/*
* @tc.number : SwitchOffHeaderReceiveCallback001
* @tc.name : Use getEntries get the value by mixing the string key
* @tc.desc : Mixed strings value can be obtained correctly
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 1
*/
/*it('SwitchOffHeaderReceiveCallback001', 0, async function (done) {
try {
let UploadConfig = pubfun.getUploadConfig(file7url)
await pubfun.publicupload(UploadConfig).then((data) => {
uploadTask = data;
}).catch((err) => {
console.log("SwitchOffHeaderReceiveCallback001 fail 1" + JSON.stringify(err));
})
await pubfun.publicoff(uploadTask,type_HeaderReceive).then((data) => {
console.info("upOnHeader headers:" + JSON.stringify(data));
expect('待确认').assertEqual(data);
done();
}).catch((err) => {
console.log("SwitchOffHeaderReceiveCallback001 fail 2" + JSON.stringify(err));
})
} catch (e) {
console.log("SwitchOffHeaderReceiveCallback001 fail 3" + JSON.stringify(e));
expect(null).assertFail();
}
})
/*
/*
* @tc.number : SwitchOnFailCallback001
* @tc.number : SwitchOnFailCallback001
* @tc.name : Use getEntries get the value by mixing the string key
* @tc.name : Use getEntries get the value by mixing the string key
...
@@ -206,14 +130,7 @@ describe('UploadTest', function () {
...
@@ -206,14 +130,7 @@ describe('UploadTest', function () {
*/
*/
it
(
'
SwitchOnFailCallback001
'
,
0
,
async
function
(
done
)
{
it
(
'
SwitchOnFailCallback001
'
,
0
,
async
function
(
done
)
{
try
{
try
{
/*let UploadConfig = pubfun.getUploadConfig(file7url)
await
pubfun
.
publicon
(
uploadTask
,
Type_Fail
).
then
((
data
)
=>
{
await pubfun.publicupload(UploadConfig).then((data) => {
uploadTask = data;
}).catch((err) => {
console.log("SwitchOnFailCallback001 fail 1" + JSON.stringify(err));
})*/
await
pubfun
.
publicon
(
uploadTask
,
type_Fail
).
then
((
data
)
=>
{
console
.
log
(
"
SwitchOnFailCallback001 data
"
+
data
);
console
.
log
(
"
SwitchOnFailCallback001 data
"
+
data
);
expect
(
5
).
assertEqual
(
data
);
expect
(
5
).
assertEqual
(
data
);
done
();
done
();
...
@@ -228,6 +145,7 @@ describe('UploadTest', function () {
...
@@ -228,6 +145,7 @@ describe('UploadTest', function () {
done
();
done
();
}
}
})
})
/*
/*
* @tc.number : SwitchOffFailCallback001
* @tc.number : SwitchOffFailCallback001
* @tc.name : Use getEntries get the value by mixing the string key
* @tc.name : Use getEntries get the value by mixing the string key
...
@@ -238,15 +156,8 @@ describe('UploadTest', function () {
...
@@ -238,15 +156,8 @@ describe('UploadTest', function () {
*/
*/
it
(
'
SwitchOffFailCallback001
'
,
0
,
async
function
(
done
)
{
it
(
'
SwitchOffFailCallback001
'
,
0
,
async
function
(
done
)
{
try
{
try
{
/*let UploadConfig = pubfun.getUploadConfig(file7url)
await
pubfun
.
publicon
(
uploadTask
,
Type_Fail
)
await pubfun.publicupload(UploadConfig).then((data) => {
await
pubfun
.
publicoff
(
uploadTask
,
Type_Fail
).
then
((
data
)
=>
{
uploadTask = data;
}).catch((err) => {
console.log("SwitchOffFailCallback001 fail 1" + JSON.stringify(err));
})*/
await
pubfun
.
publicon
(
uploadTask
,
type_Fail
)
await
pubfun
.
publicoff
(
uploadTask
,
type_Fail
).
then
((
data
)
=>
{
console
.
log
(
"
SwitchOffFailCallback001 data
"
+
data
);
console
.
log
(
"
SwitchOffFailCallback001 data
"
+
data
);
expect
(
5
).
assertEqual
(
data
);
expect
(
5
).
assertEqual
(
data
);
done
();
done
();
...
@@ -261,6 +172,7 @@ describe('UploadTest', function () {
...
@@ -261,6 +172,7 @@ describe('UploadTest', function () {
done
();
done
();
}
}
})
})
/*
/*
* @tc.number : RemoveCallback001
* @tc.number : RemoveCallback001
* @tc.name : Use getEntries get the value by mixing the string key
* @tc.name : Use getEntries get the value by mixing the string key
...
@@ -271,13 +183,6 @@ describe('UploadTest', function () {
...
@@ -271,13 +183,6 @@ describe('UploadTest', function () {
*/
*/
it
(
'
RemoveCallback001
'
,
0
,
async
function
(
done
)
{
it
(
'
RemoveCallback001
'
,
0
,
async
function
(
done
)
{
try
{
try
{
/*let UploadConfig = pubfun.getUploadConfig(file7url)
await pubfun.publicupload(UploadConfig).then((data) => {
uploadTask = data;
}).catch((err) => {
console.log("RemoveCallback001 fail 1" + JSON.stringify(err));
})*/
await
pubfun
.
publicremove
(
uploadTask
).
then
((
data
)
=>
{
await
pubfun
.
publicremove
(
uploadTask
).
then
((
data
)
=>
{
console
.
log
(
"
RemoveCallback001 data
"
+
data
);
console
.
log
(
"
RemoveCallback001 data
"
+
data
);
expect
(
true
).
assertEqual
(
data
);
expect
(
true
).
assertEqual
(
data
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录