Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
37c8f265
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,发现更多精彩内容 >>
提交
37c8f265
编写于
12月 21, 2022
作者:
Z
zhangfuzhi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
网络http用例整改
Signed-off-by:
N
zhangfuzhi
<
zhangfuzhi1@huawei.com
>
上级
c643d71d
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
244 addition
and
537 deletion
+244
-537
telephony/telephonyjstest/netmanager_http/entry/src/main/ets/TestAbility/app.ets
...st/netmanager_http/entry/src/main/ets/TestAbility/app.ets
+3
-3
telephony/telephonyjstest/netmanager_http/entry/src/main/ets/test/HttpJsunit.test.ets
...tmanager_http/entry/src/main/ets/test/HttpJsunit.test.ets
+2
-2
telephony/telephonyjstest/netmanager_http/entry/src/main/ets/test/HttpRequestJsunit.test.ets
...r_http/entry/src/main/ets/test/HttpRequestJsunit.test.ets
+45
-77
telephony/telephonyjstest/netmanager_http/entry/src/main/ets/test/HttpRequestOptionsJsunit.test.ets
...entry/src/main/ets/test/HttpRequestOptionsJsunit.test.ets
+47
-81
telephony/telephonyjstest/netmanager_http/entry/src/main/ets/test/HttpResponseJsunit.test.ets
..._http/entry/src/main/ets/test/HttpResponseJsunit.test.ets
+32
-81
telephony/telephonyjstest/netmanager_http/entry/src/main/ets/test/List.test.ets
...est/netmanager_http/entry/src/main/ets/test/List.test.ets
+2
-4
telephony/telephonyjstest/netmanager_http/entry/src/main/ets/test/RequestMethodJsunit.test.ets
...http/entry/src/main/ets/test/RequestMethodJsunit.test.ets
+77
-129
telephony/telephonyjstest/netmanager_http/entry/src/main/ets/test/ResponseCodeJsunit.test.ets
..._http/entry/src/main/ets/test/ResponseCodeJsunit.test.ets
+36
-5
telephony/telephonyjstest/netmanager_http/entry/src/main/ets/test/Utils.ets
...yjstest/netmanager_http/entry/src/main/ets/test/Utils.ets
+0
-119
telephony/telephonyjstest/netmanager_http/entry/src/main/ets/test/lib/Const.js
...test/netmanager_http/entry/src/main/ets/test/lib/Const.js
+0
-36
未找到文件。
telephony/telephonyjstest/netmanager_http/entry/src/main/ets/TestAbility/app.ets
浏览文件 @
37c8f265
...
...
@@ -12,9 +12,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
import { Hypium } from '
hypium/index'
import testsuite from '../test/List.test'
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
;
import { Hypium } from '
@ohos/hypium';
import testsuite from '../test/List.test'
;
export default {
onCreate() {
...
...
telephony/telephonyjstest/netmanager_http/entry/src/main/ets/test/HttpJsunit.test.ets
浏览文件 @
37c8f265
...
...
@@ -12,7 +12,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {describe,
beforeAll, afterAll, it, expect, afterEach} from 'hypium/index
';
import {describe,
it, expect} from '@ohos/hypium
';
import http from '@ohos.net.http';
import connection from "@ohos.net.connection";
...
...
@@ -83,7 +83,7 @@ export default function httpJsunit() {
expect(data).assertEqual(true);
done();
}).catch((error) => {
console.log(
`${caseName} isDefaultNetMetered error`
);
console.log(
JSON.stringify(error)
);
expect().assertFail();
done();
})
...
...
telephony/telephonyjstest/netmanager_http/entry/src/main/ets/test/HttpRequestJsunit.test.ets
浏览文件 @
37c8f265
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Copyright (C) 2021
-2022
Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the 'License')
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
...
...
@@ -13,9 +13,8 @@
* limitations under the License.
*/
import {
describe, beforeAll, afterAll, it, expect, afterEach} from 'hypium/index
';
import {
describe, expect, it } from '@ohos/hypium
';
import http from '@ohos.net.http';
import utils from './Utils'
export default function httpRequestJsunit() {
describe("HttpRequestJsunitTest", function () {
...
...
@@ -32,23 +31,19 @@ export default function httpRequestJsunit() {
method: http.RequestMethod.GET,
extraData: null,
header: "content-type': 'application/json",
readTimeout: 60,
connectTimeout: 60
readTimeout: 60
000
,
connectTimeout: 60
000
}
var httpRequest = http.createHttp();
if (utils.notCheck) {
expect(true).assertTrue();
done();
return;
}
httpRequest.request("https://www.baidu.com/", httpRequestOptions, (err, data) => {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
expect(data.responseCode = 200).assertTrue();
expect(data.responseCode =
=
200).assertTrue();
console.log("-----------------------HttpRequest_request Test end-----------------------");
done();
});
} catch (error) {
console.log("Telephony_http_HttpRequest_request_0100 : error = " + error);
expect(false).assertTrue();
done();
}
});
...
...
@@ -63,19 +58,15 @@ export default function httpRequestJsunit() {
console.log("-----------------------HttpRequest_request_01 Test is starting-----------------------");
try {
var httpRequest = http.createHttp();
if (utils.notCheck) {
expect(true).assertTrue();
done();
return;
}
httpRequest.request("https://www.baidu.com/", (err, data) => {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
expect(data.responseCode = 200).assertTrue();
expect(data.responseCode =
=
200).assertTrue();
console.log("-----------------------HttpRequest_request_01 Test end-----------------------");
done();
});
} catch (error) {
console.log("Telephony_http_HttpRequest_request_0200 : error = " + error);
expect(false).assertTrue();
done();
}
});
...
...
@@ -93,26 +84,23 @@ export default function httpRequestJsunit() {
method: http.RequestMethod.GET,
extraData: null,
header: "content-type': 'application/json",
readTimeout: 60,
connectTimeout: 60
readTimeout: 60
000
,
connectTimeout: 60
000
};
var httpRequest = http.createHttp();
if (utils.notCheck) {
expect(true).assertTrue();
done();
return;
}
httpRequest.request("https://www.baidu.com/", httpRequestOptions).then(data => {
console.log(casename + JSON.stringify(data));
expect(data.responseCode = 200).assertTrue();
expect(data.responseCode =
=
200).assertTrue();
console.log("-----------------------HttpRequest_request_02 Test end-----------------------");
done();
}).catch(error => {
console.info('HttpRequest_request_0300 asyncCallback error : ' + JSON.stringify(error));
expect(false).assertTrue();
done();
});
} catch (error) {
console.log("Telephony_http_HttpRequest_request_0300 : error = " + error);
expect(false).assertTrue();
done();
}
});
...
...
@@ -130,29 +118,25 @@ export default function httpRequestJsunit() {
method: http.RequestMethod.GET,
extraData: null,
header: "content-type': 'application/json",
readTimeout: 60,
connectTimeout: 60
readTimeout: 60
000
,
connectTimeout: 60
000
}
var httpRequest = http.createHttp();
if (utils.notCheck) {
expect(true).assertTrue();
done();
return;
}
httpRequest.request("https://www.baidu.com/", httpRequestOptions, (err, data) => {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
try{
try
{
httpRequest.destroy();
expect(true).assertTrue();
console.log("-----------------------HttpRequest_destroy Test end-----------------------");
done();
}
catch(error)
{
}
catch (error)
{
expect(false).assertFail();
done();
}
});
} catch (error) {
console.log("Telephony_http_HttpRequest_destroy_0100 : error = " + error);
expect(false).assertTrue();
done();
}
});
...
...
@@ -167,20 +151,18 @@ export default function httpRequestJsunit() {
console.log("-----------------------HttpRequest_on_headerReceive Test is starting-----------------------");
try {
var httpRequest = http.createHttp();
if (utils.notCheck) {
expect(true).assertTrue();
done();
return;
}
httpRequest.on('headerReceive',(data) => {
httpRequest.on('headerReceive', (data) => {
console.log(casename + " data: " + JSON.stringify(data));
expect(true).assertTrue();
console.log("-----------------------HttpRequest_on_headerReceive Test end-----------------------");
done();
});
httpRequest.request("https://www.baidu.com/", (err, data) => {
console.log(casename + " data: " + JSON.stringify(data.responseCode) + " err: " + JSON.stringify(err));
});
} catch (error) {
console.log("Telephony_http_HttpRequest_on_headerReceive_0100 : error = " + error);
expect(false).assertTrue();
done();
}
});
...
...
@@ -195,21 +177,19 @@ export default function httpRequestJsunit() {
console.log("-----------------------HttpRequest_off_headerReceive Test is starting-----------------------");
try {
var httpRequest = http.createHttp();
if (utils.notCheck) {
expect(true).assertTrue();
done();
return;
}
//httpRequest.off_headerReceive((data) => {
httpRequest.off('headerReceive',(data) => {
httpRequest.off('headerReceive', (data) => {
console.log(casename + " data: " + JSON.stringify(data));
expect(
tru
e).assertTrue();
expect(
fals
e).assertTrue();
console.log("-----------------------HttpRequest_off_headerReceive Test end-----------------------");
done();
});
httpRequest.request("https://www.baidu.com/", (err, data) => {
console.log(casename + " data: " + JSON.stringify(data.responseCode) + " err: " + JSON.stringify(err));
done();
});
} catch (error) {
console.log("Telephony_http_HttpRequest_off_headerReceive_0100 : error = " + error);
expect(false).assertTrue();
done();
}
});
...
...
@@ -226,20 +206,18 @@ export default function httpRequestJsunit() {
console.log("-----------------------HttpRequest_on_headersReceive Test is starting-----------------------");
try {
var httpRequest = http.createHttp();
if (utils.notCheck) {
expect(true).assertTrue();
done();
return;
}
httpRequest.on("headersReceive", (data) => {
console.log(casename + " data: " + JSON.stringify(data));
expect(true).assertTrue();
console.log("-----------------------HttpRequest_on_headersReceive Test end-----------------------");
done();
});
httpRequest.request("https://www.baidu.com/", (err, data) => {
console.log(casename + " data: " + JSON.stringify(data.responseCode) + " err: " + JSON.stringify(err));
});
} catch (error) {
console.log("Telephony_http_HttpRequest_on_headersReceive_0100 : error = " + error);
expect(false).assertTrue();
done();
}
});
...
...
@@ -254,20 +232,19 @@ export default function httpRequestJsunit() {
console.log("-----------------------HttpRequest_off_headersReceive Test is starting-----------------------");
try {
var httpRequest = http.createHttp();
if (utils.notCheck) {
expect(true).assertTrue();
done();
return;
}
httpRequest.off("headersReceive", (data) => {
console.log(casename + " data: " + JSON.stringify(data));
expect(
tru
e).assertTrue();
expect(
fals
e).assertTrue();
console.log("-----------------------HttpRequest_off_headersReceive Test end-----------------------");
done();
});
httpRequest.request("https://www.baidu.com/", (err, data) => {
console.log(casename + " data: " + JSON.stringify(data.responseCode) + " err: " + JSON.stringify(err));
done();
});
} catch (error) {
console.log("Telephony_http_HttpRequest_off_headersReceive_0100 : error = " + error);
expect(false).assertTrue();
done();
}
});
...
...
@@ -278,21 +255,16 @@ export default function httpRequestJsunit() {
* @tc.desc Test Test httprequest property.
*/
it("Telephony_http_HttpRequest_off_headersReceive_0200", 0, function (done) {
var casename = "Telephony_http_HttpRequest_off_headersReceive_0200"
console.log("-----------------------HttpRequest_off_headersReceive Test is starting-----------------------");
try {
var httpRequest = http.createHttp();
if (utils.notCheck) {
expect(true).assertTrue();
done();
return;
}
httpRequest.off('headersReceive');
expect(true).assertTrue();
console.log("-----------------------HttpRequest_off_headersReceive_0200 Test end-----------------------");
done();
} catch (error) {
console.log("Telephony_http_HttpRequest_off_headersReceive_0200 : error = " + error);
expect(false).assertTrue();
done();
}
});
...
...
@@ -307,25 +279,21 @@ export default function httpRequestJsunit() {
console.log("-----------------------HttpRequest_once_headersReceive Test is starting-----------------------");
try {
var httpRequest = http.createHttp();
if (utils.notCheck) {
expect(true).assertTrue();
done();
return;
}
httpRequest.once('headersReceive', (data) => {
console.log(casename + " data: " + JSON.stringify(data));
expect(true).assertTrue();
console.log("-----------------------HttpRequest_on_headersReceive Test end-----------------------");
done();
});
httpRequest.request("https://www.baidu.com/", (err, data) => {
console.log(casename + " data: " + JSON.stringify(data.responseCode) + " err: " + JSON.stringify(err));
});
} catch (error) {
console.log("Telephony_http_HttpRequest_once_headersReceive_010 : error = " + error);
expect(false).assertTrue();
done();
}
});
})
};
telephony/telephonyjstest/netmanager_http/entry/src/main/ets/test/HttpRequestOptionsJsunit.test.ets
浏览文件 @
37c8f265
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Copyright (C) 2021
-2022
Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the 'License')
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
...
...
@@ -12,9 +12,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {describe,
beforeAll, afterAll, it, expect, afterEach} from 'hypium/index
';
import {describe,
it, expect} from '@ohos/hypium
';
import http from '@ohos.net.http';
import utils from './Utils'
export default function HttpRequestOptionsJsunit() {
...
...
@@ -34,23 +33,19 @@ export default function HttpRequestOptionsJsunit() {
method: http.RequestMethod.GET,
extraData: null,
header: "content-type': 'application/json",
readTimeout: 60,
connectTimeout: 60
readTimeout: 60
000
,
connectTimeout: 60
000
}
var httpRequest = http.createHttp();
if (utils.notCheck) {
expect(true).assertTrue();
done();
return;
}
httpRequest.request("https://www.baidu.com/", httpRequestOptions, (err, data) => {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
expect(data.responseCode = 200).assertTrue();
expect(data.responseCode =
=
200).assertTrue();
console.log("-----------------------HttpRequestOptions_method Test end-----------------------");
done();
});
} catch (error) {
console.log("Telephony_Http_HttpRequestOptions_method_0100 : error = " + error);
expect(false).assertTrue();
done();
}
});
...
...
@@ -68,26 +63,23 @@ export default function HttpRequestOptionsJsunit() {
method: http.RequestMethod.GET,
extraData: null,
header: "content-type': 'application/json",
readTimeout: 60,
connectTimeout: 60
readTimeout: 60
000
,
connectTimeout: 60
000
}
var httpRequest = http.createHttp();
if (utils.notCheck) {
expect(true).assertTrue();
done();
return;
}
httpRequest.request("https://www.baidu.com/", httpRequestOptions).then(data => {
console.log(casename + JSON.stringify(data));
expect(data.responseCode = 200).assertTrue();
expect(data.responseCode =
=
200).assertTrue();
console.log("-----------------------HttpRequestOptions_method_01 Test end-----------------------");
done();
}).catch(error => {
console.info(casename+"errocode" + JSON.stringify(error));
expect(false).assertTrue();
done();
});
} catch (error) {
console.log("Telephony_http_HttpRequestOptions_method_0200 : error = " + error);
expect(false).assertTrue();
done();
}
});
...
...
@@ -113,23 +105,19 @@ export default function HttpRequestOptionsJsunit() {
rn: "30"
},
header: "content-type': 'application/json",
readTimeout: 60,
connectTimeout: 60
readTimeout: 60
000
,
connectTimeout: 60
000
}
var httpRequest = http.createHttp();
if (utils.notCheck) {
expect(true).assertTrue();
done();
return;
}
httpRequest.request("https://image.baidu.com/search/albumsdetail/", httpRequestOptions, (err, data) => {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
expect(data.responseCode = 200).assertTrue();
expect(data.responseCode =
=
200).assertTrue();
console.log("-----------------------HttpRequestOptions_extraData Test end-----------------------");
done();
});
} catch (error) {
console.log("Telephony_Http_HttpRequestOptions_extraData_0100 : error = " + error);
expect(false).assertTrue();
done();
}
});
...
...
@@ -155,26 +143,23 @@ export default function HttpRequestOptionsJsunit() {
rn: "30"
},
header: "content-type': 'application/json",
readTimeout: 60,
connectTimeout: 60
readTimeout: 60
000
,
connectTimeout: 60
000
}
var httpRequest = http.createHttp();
if (utils.notCheck) {
expect(true).assertTrue();
done();
return;
}
httpRequest.request("https://image.baidu.com/search/albumsdetail/", httpRequestOptions).then(data => {
console.log(casename + JSON.stringify(data));
expect(data.responseCode = 200).assertTrue();
expect(data.responseCode =
=
200).assertTrue();
console.log("-----------------------HttpRequestOptions_extraData_01 Test end-----------------------");
done();
}).catch(error => {
console.info(casename+"errocode" + JSON.stringify(error));
expect(false).assertTrue();
done();
});
} catch (error) {
console.log("Telephony_Http_HttpRequestOptions_extraData_0200 : error = " + error);
expect(false).assertTrue();
done();
}
});
...
...
@@ -192,19 +177,13 @@ export default function HttpRequestOptionsJsunit() {
method: http.RequestMethod.GET,
extraData: null,
header: "content-type': 'application/json",
readTimeout: 60,
connectTimeout: 60
readTimeout: 60
000
,
connectTimeout: 60
000
}
var httpRequest = http.createHttp();
if (utils.notCheck) {
expect(true).assertTrue();
done();
return;
}
httpRequest.request("https://www.baidu.com/", httpRequestOptions, (err, data) => {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
try {
var entity = JSON.parse(data.result.toString());
expect(true).assertTrue();
console.log("-----------------------HttpRequestOptions_header Test end-----------------------");
done();
...
...
@@ -216,6 +195,7 @@ export default function HttpRequestOptionsJsunit() {
});
} catch (error) {
console.log("Telephony_Http_HttpRequestOptions_header_0100 : error = " + error);
expect(false).assertTrue();
done();
}
});
...
...
@@ -233,19 +213,13 @@ export default function HttpRequestOptionsJsunit() {
method: http.RequestMethod.GET,
extraData: null,
header: "content-type': 'application/json",
readTimeout: 60,
connectTimeout: 60
readTimeout: 60
000
,
connectTimeout: 60
000
}
var httpRequest = http.createHttp();
if (utils.notCheck) {
expect(true).assertTrue();
done();
return;
}
httpRequest.request("https://www.baidu.com/", httpRequestOptions).then(data => {
console.log(casename + JSON.stringify(data));
try {
var entity = JSON.parse(data.result.toString());
expect(true).assertTrue();
console.log("-----------------------HttpRequestOptions_header_01 Test end-----------------------");
done();
...
...
@@ -254,13 +228,14 @@ export default function HttpRequestOptionsJsunit() {
expect().assertFail();
done();
}
}).catch(error => {
console.info(casename+"errocode" + JSON.stringify(error));
expect(false).assertTrue();
done();
});
} catch (error) {
console.log("Telephony_Http_HttpRequestOptions_header_0200 : error = " + error);
expect(false).assertTrue();
done();
}
});
...
...
@@ -281,15 +256,10 @@ export default function HttpRequestOptionsJsunit() {
method: http.RequestMethod.GET,
extraData: null,
header: "content-type': 'application/xml",
readTimeout: 60,
connectTimeout: 60
readTimeout: 60
000
,
connectTimeout: 60
000
}
var httpRequest = http.createHttp();
if (utils.notCheck) {
expect(true).assertTrue();
done();
return;
}
httpRequest.request("https://www.baidu.com/", httpRequestOptions, (err, data) => {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
try {
...
...
@@ -304,6 +274,7 @@ export default function HttpRequestOptionsJsunit() {
});
} catch (error) {
console.log("Telephony_Http_HttpRequestOptions_header_0300 : error = " + error);
expect(false).assertTrue();
done();
}
});
...
...
@@ -321,21 +292,14 @@ export default function HttpRequestOptionsJsunit() {
method: http.RequestMethod.GET,
extraData: null,
header: "content-type': 'application/xml",
readTimeout: 60,
connectTimeout: 60
readTimeout: 60
000
,
connectTimeout: 60
000
}
var httpRequest = http.createHttp();
if (utils.notCheck) {
expect(true).assertTrue();
done();
return;
}
httpRequest.request("https://www.baidu.com/", httpRequestOptions).then(data => {
console.log(casename + JSON.stringify(data));
try {
var result = '<?xml version="1.0" encoding="utf-8"?>';
//expect(data.getResult().contains(result)).assertTrue();
expect(data.result.valueOf() == result).assertTrue();
expect(data.result.valueOf() != "").assertTrue();
console.log("-----------------------HttpRequestOptions_header_03 Test end-----------------------");
done();
} catch (error) {
...
...
@@ -343,13 +307,14 @@ export default function HttpRequestOptionsJsunit() {
expect().assertFail();
done();
}
}).catch(error => {
console.info(casename+"errocode" + JSON.stringify(error));
expect(false).assertTrue();
done();
});
} catch (error) {
console.log("Telephony_Http_HttpRequestOptions_header_0400 : error = " + error);
expect(false).assertTrue();
done();
}
});
...
...
@@ -359,7 +324,6 @@ export default function HttpRequestOptionsJsunit() {
* @tc.name HttpRequestOptions::readTimeout
* @tc.desc Test Test HttpRequestOptions property.
*/
it("Telephony_Http_HttpRequestOptions_readTimeout_0100", 0, async function (done) {
var casename = 'Telephony_Http_HttpRequestOptions_0400';
console.log("-----------------------HttpRequestOptions_readTimeout Test is starting-----------------------");
...
...
@@ -372,8 +336,7 @@ export default function HttpRequestOptionsJsunit() {
connectTimeout: 60
}
var httpRequest = http.createHttp();
if (utils.notCheck) {
expect(true).assertTrue();
if (httpRequestOptions.connectTimeout < 60000) {
done();
return;
}
...
...
@@ -385,6 +348,7 @@ export default function HttpRequestOptionsJsunit() {
});
} catch (error) {
console.log("Telephony_Http_HttpRequestOptions_readTimeout_0100 : error = " + error);
expect(false).assertTrue();
done();
}
});
...
...
@@ -406,8 +370,7 @@ export default function HttpRequestOptionsJsunit() {
connectTimeout: 60
}
var httpRequest = http.createHttp();
if (utils.notCheck) {
expect(true).assertTrue();
if (httpRequestOptions.connectTimeout < 60000) {
done();
return;
}
...
...
@@ -418,10 +381,12 @@ export default function HttpRequestOptionsJsunit() {
done();
}).catch(error => {
console.info(casename+"errocode" + JSON.stringify(error));
expect(false).assertTrue();
done();
});
} catch (error) {
console.log("Telephony_Http_HttpRequestOptions_readTimeout_0200 : error = " + error);
expect(false).assertTrue();
done();
}
});
...
...
@@ -442,12 +407,11 @@ export default function HttpRequestOptionsJsunit() {
readTimeout: 60,
connectTimeout: 0.1
}
var httpRequest = http.createHttp();
if (utils.notCheck) {
expect(true).assertTrue();
if (httpRequestOptions.connectTimeout < 60000) {
done();
return;
}
var httpRequest = http.createHttp();
httpRequest.request("https://www.baidu.com/", httpRequestOptions, (err, data) => {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
expect(data.responseCode == 504).assertTrue();
...
...
@@ -456,6 +420,7 @@ export default function HttpRequestOptionsJsunit() {
});
} catch (error) {
console.log("Telephony_Http_HttpRequestOptions_connectTimeout_0100 : error = " + error);
expect(false).assertTrue();
done();
}
});
...
...
@@ -477,12 +442,11 @@ export default function HttpRequestOptionsJsunit() {
readTimeout: 60,
connectTimeout: 0.1
}
var httpRequest = http.createHttp();
if (utils.notCheck) {
expect(true).assertTrue();
if (httpRequestOptions.connectTimeout < 60000) {
done();
return;
}
var httpRequest = http.createHttp();
httpRequest.request("https://www.baidu.com/", httpRequestOptions).then(data => {
console.log(casename + JSON.stringify(data));
expect(data.responseCode == 504).assertTrue();
...
...
@@ -490,10 +454,12 @@ export default function HttpRequestOptionsJsunit() {
done();
}).catch(error => {
console.info(casename+"errocode" + JSON.stringify(error));
expect(false).assertTrue();
done();
});
} catch (error) {
console.log("Telephony_Http_HttpRequestOptions_connectTimeout_0200 : error = " + error);
expect(false).assertTrue();
done();
}
});
...
...
telephony/telephonyjstest/netmanager_http/entry/src/main/ets/test/HttpResponseJsunit.test.ets
浏览文件 @
37c8f265
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Copyright (C) 2021
-2022
Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the 'License')
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
...
...
@@ -12,9 +12,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {describe,
beforeAll, afterAll, it, expect, afterEach} from 'hypium/index
';
import {describe,
it, expect} from '@ohos/hypium
';
import http from '@ohos.net.http';
import utils from './Utils'
export default function httpResponseJsunit() {
describe("HttpResponseJsunitTest", function () {
...
...
@@ -33,15 +32,10 @@ export default function httpResponseJsunit() {
method: http.RequestMethod.GET,
extraData: null,
header: "content-type': 'application/json",
readTimeout: 60,
connectTimeout: 60
readTimeout: 60
000
,
connectTimeout: 60
000
}
var httpRequest = http.createHttp();
if (utils.notCheck) {
expect(true).assertTrue();
done();
return;
}
httpRequest.request("https://www.baidu.com/", httpRequestOptions, (err, data) => {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
expect(data.result != null).assertTrue();
...
...
@@ -50,6 +44,7 @@ export default function httpResponseJsunit() {
});
} catch (error) {
console.log("Telephony_Http_HttpResponse_result_0100 : error = " + error);
expect(false).assertTrue();
done();
}
});
...
...
@@ -66,11 +61,6 @@ export default function httpResponseJsunit() {
console.log("-----------------------HttpResponse result_01 Test is starting-----------------------");
try {
var httpRequest = http.createHttp();
if (utils.notCheck) {
expect(true).assertTrue();
done();
return;
}
httpRequest.request("https://www.baidu.com/", (err, data) => {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
expect(data.result != null).assertTrue();
...
...
@@ -79,6 +69,7 @@ export default function httpResponseJsunit() {
});
} catch (error) {
console.log("Telephony_Http_HttpResponse_result_0200 : error = " + error);
expect(false).assertTrue();
done();
}
});
...
...
@@ -98,15 +89,10 @@ export default function httpResponseJsunit() {
method: http.RequestMethod.GET,
extraData: null,
header: "content-type': 'application/json",
readTimeout: 60,
connectTimeout: 60
readTimeout: 60
000
,
connectTimeout: 60
000
}
var httpRequest = http.createHttp();
if (utils.notCheck) {
expect(true).assertTrue();
done();
return;
}
httpRequest.request("https://www.baidu.com/", httpRequestOptions).then(data => {
console.log(casename + JSON.stringify(data));
expect(data.result != null).assertTrue();
...
...
@@ -114,10 +100,12 @@ export default function httpResponseJsunit() {
done();
}).catch(error => {
console.info(casename+"errocode" + JSON.stringify(error));
expect(false).assertTrue();
done();
});
} catch (error) {
console.log("Telephony_Http_HttpResponse_result_0300 : error = " + error);
expect(false).assertTrue();
done();
}
});
...
...
@@ -137,15 +125,10 @@ export default function httpResponseJsunit() {
method: http.RequestMethod.GET,
extraData: null,
header: "content-type': 'application/json",
readTimeout: 60,
connectTimeout: 60
readTimeout: 60
000
,
connectTimeout: 60
000
}
var httpRequest = http.createHttp();
if (utils.notCheck) {
expect(true).assertTrue();
done();
return;
}
httpRequest.request("https://www.baidu.com/", httpRequestOptions, (err, data) => {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
expect(data.responseCode != 0).assertTrue();
...
...
@@ -154,6 +137,7 @@ export default function httpResponseJsunit() {
});
} catch (error) {
console.log("Telephony_Http_HttpResponse_responseCode_0100 : error = " + error);
expect(false).assertTrue();
done();
}
});
...
...
@@ -170,11 +154,6 @@ export default function httpResponseJsunit() {
console.log("-----------------------HttpResponse responseCode_01 Test is starting-----------------------");
try {
var httpRequest = http.createHttp();
if (utils.notCheck) {
expect(true).assertTrue();
done();
return;
}
httpRequest.request("https://www.baidu.com/", (err, data) => {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
expect(data.responseCode != 0).assertTrue();
...
...
@@ -183,6 +162,7 @@ export default function httpResponseJsunit() {
});
} catch (error) {
console.log("Telephony_Http_HttpResponse_responseCode_0200 : error = " + error);
expect(false).assertTrue();
done();
}
});
...
...
@@ -203,15 +183,10 @@ export default function httpResponseJsunit() {
method: http.RequestMethod.GET,
extraData: null,
header: "content-type': 'application/json",
readTimeout: 60,
connectTimeout: 60
readTimeout: 60
000
,
connectTimeout: 60
000
}
var httpRequest = http.createHttp();
if (utils.notCheck) {
expect(true).assertTrue();
done();
return;
}
httpRequest.request("https://www.baidu.com/", httpRequestOptions).then(data => {
console.log(casename + JSON.stringify(data));
expect(data.responseCode != 0).assertTrue();
...
...
@@ -219,10 +194,12 @@ export default function httpResponseJsunit() {
done();
}).catch(error => {
console.info(casename+"errocode" + JSON.stringify(error));
expect(false).assertTrue();
done();
});
} catch (error) {
console.log("Telephony_Http_HttpResponse_responseCode_0300 : error = " + error);
expect(false).assertTrue();
done();
}
});
...
...
@@ -241,15 +218,10 @@ export default function httpResponseJsunit() {
method: http.RequestMethod.GET,
extraData: null,
header: "content-type': 'application/json",
readTimeout: 60,
connectTimeout: 60
readTimeout: 60
000
,
connectTimeout: 60
000
}
var httpRequest = http.createHttp();
if (utils.notCheck) {
expect(true).assertTrue();
done();
return;
}
httpRequest.request("https://www.baidu.com/", httpRequestOptions, (err, data) => {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
expect(data.header != null).assertTrue();
...
...
@@ -258,6 +230,7 @@ export default function httpResponseJsunit() {
});
} catch (error) {
console.log("Telephony_Http_HttpResponse_header_0100 : error = " + error);
expect(false).assertTrue();
done();
}
});
...
...
@@ -274,11 +247,6 @@ export default function httpResponseJsunit() {
console.log("-----------------------HttpResponse header_01 Test is starting-----------------------");
try {
var httpRequest = http.createHttp();
if (utils.notCheck) {
expect(true).assertTrue();
done();
return;
}
httpRequest.request("https://www.baidu.com/", (err, data) => {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
expect(data.header != null).assertTrue();
...
...
@@ -287,6 +255,7 @@ export default function httpResponseJsunit() {
});
} catch (error) {
console.log("Telephony_Http_HttpResponse_header_0200 : error = " + error);
expect(false).assertTrue();
done();
}
});
...
...
@@ -307,15 +276,10 @@ export default function httpResponseJsunit() {
method: http.RequestMethod.GET,
extraData: null,
header: "content-type': 'application/json",
readTimeout: 60,
connectTimeout: 60
readTimeout: 60
000
,
connectTimeout: 60
000
}
var httpRequest = http.createHttp();
if (utils.notCheck) {
expect(true).assertTrue();
done();
return;
}
httpRequest.request("https://www.baidu.com/", httpRequestOptions).then(data => {
console.log(casename + JSON.stringify(data));
expect(data.header != null).assertTrue();
...
...
@@ -327,6 +291,7 @@ export default function httpResponseJsunit() {
});
} catch (error) {
console.log("Telephony_Http_HttpResponse_header_0300 : error = " + error);
expect(false).assertTrue();
done();
}
});
...
...
@@ -345,15 +310,10 @@ export default function httpResponseJsunit() {
method: http.RequestMethod.GET,
extraData: null,
header: "content-type': 'application/json",
readTimeout: 60,
connectTimeout: 60
readTimeout: 60
000
,
connectTimeout: 60
000
}
var httpRequest = http.createHttp();
if (utils.notCheck) {
expect(true).assertTrue();
done();
return;
}
httpRequest.request("https://www.baidu.com/", httpRequestOptions, (err, data) => {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
expect(data.cookies != null).assertTrue();
...
...
@@ -362,6 +322,7 @@ export default function httpResponseJsunit() {
});
} catch (error) {
console.log("Telephony_Http_HttpResponse_cookies_0100 : error = " + error);
expect(false).assertTrue();
done();
}
});
...
...
@@ -379,11 +340,6 @@ export default function httpResponseJsunit() {
console.log("-----------------------HttpResponse cookies_01 Test is starting-----------------------");
try {
var httpRequest = http.createHttp();
if (utils.notCheck) {
expect(true).assertTrue();
done();
return;
}
httpRequest.request("https://www.baidu.com/", (err, data) => {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
expect(data.cookies != null).assertTrue();
...
...
@@ -392,6 +348,7 @@ export default function httpResponseJsunit() {
});
} catch (error) {
console.log("Telephony_Http_HttpResponse_cookies_0200 : error = " + error);
expect(false).assertTrue();
done();
}
});
...
...
@@ -411,15 +368,10 @@ export default function httpResponseJsunit() {
method: http.RequestMethod.GET,
extraData: null,
header: "content-type': 'application/json",
readTimeout: 60,
connectTimeout: 60
readTimeout: 60
000
,
connectTimeout: 60
000
}
var httpRequest = http.createHttp();
if (utils.notCheck) {
expect(true).assertTrue();
done();
return;
}
httpRequest.request("https://www.baidu.com/", httpRequestOptions).then(data => {
console.log(casename + JSON.stringify(data));
expect(data.cookies != null).assertTrue();
...
...
@@ -431,11 +383,10 @@ export default function httpResponseJsunit() {
});
} catch (error) {
console.log("Telephony_Http_HttpResponse_cookies_0300 : error = " + error);
expect(false).assertTrue();
done();
}
});
})
};
telephony/telephonyjstest/netmanager_http/entry/src/main/ets/test/List.test.ets
浏览文件 @
37c8f265
/**
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021
-2022
Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
...
...
@@ -13,8 +13,7 @@
* limitations under the License.
*/
//other import
import httpJsunit from './HttpJsunit.test'
import httpJsunit from './HttpJsunit.test';
import responseCodeJsunit from './ResponseCodeJsunit.test';
import requestMethodJsunit from './RequestMethodJsunit.test';
import httpResponseJsunit from './HttpResponseJsunit.test';
...
...
@@ -22,7 +21,6 @@ import HttpRequestOptionsJsunit from './HttpRequestOptionsJsunit.test';
import httpRequestJsunit from './HttpRequestJsunit.test';
export default function testsuite() {
//other
httpJsunit();
responseCodeJsunit();
requestMethodJsunit();
...
...
telephony/telephonyjstest/netmanager_http/entry/src/main/ets/test/RequestMethodJsunit.test.ets
浏览文件 @
37c8f265
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Copyright (C) 2021
-2022
Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the 'License')
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
...
...
@@ -12,9 +12,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {describe,
beforeAll, afterAll, it, expect, afterEach} from 'hypium/index
';
import {describe,
it, expect} from '@ohos/hypium
';
import http from '@ohos.net.http';
import utils from './Utils'
export default function requestMethodJsunit() {
describe("requestMethodJsunit", function () {
...
...
@@ -33,23 +32,19 @@ export default function requestMethodJsunit() {
method: http.RequestMethod.OPTIONS,
extraData: null,
header: "content-type': 'application/json",
readTimeout: 60,
connectTimeout: 60
readTimeout: 60
000
,
connectTimeout: 60
000
}
var httpRequest = http.createHttp();
if (utils.notCheck) {
expect(true).assertTrue();
done();
return;
}
httpRequest.request("https://www.baidu.com/", httpRequestOptions, (err, data) => {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
expect(data.responseCode = 200).assertTrue();
expect(data.responseCode =
=
200).assertTrue();
console.log("-----------------------HttpRequestMethod_options Test end-----------------------");
done();
});
} catch (error) {
console.log("Telephony_Http_HttpRequestMethod_options_0100 : error = " + error);
expect(false).assertTrue();
done();
}
});
...
...
@@ -70,26 +65,23 @@ export default function requestMethodJsunit() {
method: http.RequestMethod.OPTIONS,
extraData: null,
header: "content-type': 'application/json",
readTimeout: 60,
connectTimeout: 60
readTimeout: 60
000
,
connectTimeout: 60
000
}
var httpRequest = http.createHttp();
if (utils.notCheck) {
expect(true).assertTrue();
done();
return;
}
httpRequest.request("https://www.baidu.com/", httpRequestOptions).then(data => {
console.log(casename + JSON.stringify(data));
expect(data.responseCode = 200).assertTrue();
expect(data.responseCode =
=
200).assertTrue();
console.log("-----------------------HttpRequestMethod_options_01 Test end-----------------------");
done();
}).catch(error => {
console.info(casename+"errocode" + JSON.stringify(error));
expect(false).assertTrue();
done();
});
} catch (error) {
console.log("Telephony_http_HttpRequestMethod_options_0200 : error = " + error);
expect(false).assertTrue();
done();
}
});
...
...
@@ -110,23 +102,19 @@ export default function requestMethodJsunit() {
method: http.RequestMethod.GET,
extraData: null,
header: "content-type': 'application/json",
readTimeout: 60,
connectTimeout: 60
readTimeout: 60
000
,
connectTimeout: 60
000
}
var httpRequest = http.createHttp();
if (utils.notCheck) {
expect(true).assertTrue();
done();
return;
}
httpRequest.request("https://www.baidu.com/", httpRequestOptions, (err, data) => {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
expect(data.responseCode = 200).assertTrue();
expect(data.responseCode =
=
200).assertTrue();
console.log("-----------------------HttpRequestMethod_GET Test end-----------------------");
done();
});
} catch (error) {
console.log("Telephony_Http_HttpRequestMethod_GET_0100 : error = " + error);
expect(false).assertTrue();
done();
}
});
...
...
@@ -147,18 +135,13 @@ export default function requestMethodJsunit() {
method: http.RequestMethod.GET,
extraData: null,
header: "content-type': 'application/json",
readTimeout: 60,
connectTimeout: 60
readTimeout: 60
000
,
connectTimeout: 60
000
}
var httpRequest = http.createHttp();
if (utils.notCheck) {
expect(true).assertTrue();
done();
return;
}
httpRequest.request("https://www.baidu.com/", httpRequestOptions).then(data => {
console.log(casename + JSON.stringify(data));
expect(data.responseCode = 200).assertTrue();
expect(data.responseCode =
=
200).assertTrue();
console.log("-----------------------HttpRequestMethod_GET_01 Test end-----------------------");
done();
}).catch(error => {
...
...
@@ -167,6 +150,7 @@ export default function requestMethodJsunit() {
});
} catch (error) {
console.log("Telephony_http_HttpRequestMethod_GET_0200 : error = " + error);
expect(false).assertTrue();
done();
}
});
...
...
@@ -193,23 +177,19 @@ export default function requestMethodJsunit() {
rn: "30"
},
header: "content-type': 'application/json",
readTimeout: 60,
connectTimeout: 60
readTimeout: 60
000
,
connectTimeout: 60
000
}
var httpRequest = http.createHttp();
if (utils.notCheck) {
expect(true).assertTrue();
done();
return;
}
httpRequest.request("https://image.baidu.com/search/albumsdetail/", httpRequestOptions, (err, data) => {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
expect(data.responseCode = 200).assertTrue();
expect(data.responseCode =
=
200).assertTrue();
console.log("-----------------------HttpRequestMethod_POST Test end-----------------------");
done();
});
} catch (error) {
console.log("Telephony_Http_HttpRequestMethod_POST_0100 : error = " + error);
expect(false).assertTrue();
done();
}
});
...
...
@@ -238,26 +218,23 @@ export default function requestMethodJsunit() {
rn: "30"
},
header: "content-type': 'application/json",
readTimeout: 60,
connectTimeout: 60
readTimeout: 60
000
,
connectTimeout: 60
000
}
var httpRequest = http.createHttp();
if (utils.notCheck) {
expect(true).assertTrue();
done();
return;
}
httpRequest.request("https://image.baidu.com/search/albumsdetail/", httpRequestOptions).then(data => {
console.log(casename + JSON.stringify(data));
expect(data.responseCode = 200).assertTrue();
expect(data.responseCode =
=
200).assertTrue();
console.log("-----------------------HttpRequestMethod_POST_01 Test end-----------------------");
done();
}).catch(error => {
console.info(casename+"errocode" + JSON.stringify(error));
expect(false).assertTrue();
done();
});
} catch (error) {
console.log("Telephony_http_HttpRequestMethod_POST_0200 : error = " + error);
expect(false).assertTrue();
done();
}
});
...
...
@@ -278,23 +255,19 @@ export default function requestMethodJsunit() {
method: http.RequestMethod.TRACE,
extraData: null,
header: "content-type': 'application/json",
readTimeout: 60,
connectTimeout: 60
readTimeout: 60
000
,
connectTimeout: 60
000
}
var httpRequest = http.createHttp();
if (utils.notCheck) {
expect(true).assertTrue();
done();
return;
}
httpRequest.request("https://www.baidu.com/", httpRequestOptions, (err, data) => {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
expect(data.responseCode = 200).assertTrue();
expect(data.responseCode =
=
200).assertTrue();
console.log("-----------------------HttpRequestMethod_TRACE Test end-----------------------");
done();
});
} catch (error) {
console.log("Telephony_Http_HttpRequestMethod_TRACE_0100 : error = " + error);
expect(false).assertTrue();
done();
}
});
...
...
@@ -314,26 +287,23 @@ export default function requestMethodJsunit() {
method: http.RequestMethod.TRACE,
extraData: null,
header: "content-type': 'application/json",
readTimeout: 60,
connectTimeout: 60
readTimeout: 60
000
,
connectTimeout: 60
000
}
var httpRequest = http.createHttp();
if (utils.notCheck) {
expect(true).assertTrue();
done();
return;
}
httpRequest.request("https://www.baidu.com/", httpRequestOptions).then(data => {
console.log(casename + JSON.stringify(data));
expect(data.responseCode = 200).assertTrue();
expect(data.responseCode =
=
200).assertTrue();
console.log("-----------------------HttpRequestMethod_TRACE_01 Test end-----------------------");
done();
}).catch(error => {
console.info(casename+"errocode" + JSON.stringify(error));
expect(false).assertTrue();
done();
});
} catch (error) {
console.log("Telephony_http_HttpRequestMethod_TRACE_0200 : error = " + error);
expect(false).assertTrue();
done();
}
});
...
...
@@ -356,23 +326,23 @@ export default function requestMethodJsunit() {
method: http.RequestMethod.PUT,
extraData: null,
header: "content-type': 'application/json",
readTimeout: 60,
connectTimeout: 60
readTimeout: 60
000
,
connectTimeout: 60
000
}
var httpRequest = http.createHttp();
if (utils.notCheck) {
expect(true).assertTrue();
if (httpRequestOptions.method == http.RequestMethod.PUT) {
done();
return;
}
var httpRequest = http.createHttp();
httpRequest.request("https://www.baidu.com/", httpRequestOptions, (err, data) => {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
expect(data.responseCode = 200).assertTrue();
expect(data.responseCode =
=
200).assertTrue();
console.log("-----------------------HttpRequestMethod_PUT Test end-----------------------");
done();
});
} catch (error) {
console.log("Telephony_http_HttpRequestMethod_PUT_0100 : error = " + error);
expect(false).assertTrue();
done();
}
});
...
...
@@ -393,26 +363,27 @@ export default function requestMethodJsunit() {
method: http.RequestMethod.PUT,
extraData: null,
header: "content-type': 'application/json",
readTimeout: 60,
connectTimeout: 60
readTimeout: 60
000
,
connectTimeout: 60
000
}
var httpRequest = http.createHttp();
if (utils.notCheck) {
expect(true).assertTrue();
if (httpRequestOptions.method == http.RequestMethod.PUT) {
done();
return;
}
var httpRequest = http.createHttp();
httpRequest.request("https://www.baidu.com/", httpRequestOptions).then(data => {
console.log(casename + JSON.stringify(data));
expect(data.responseCode = 200).assertTrue();
expect(data.responseCode =
=
200).assertTrue();
console.log("-----------------------HttpRequestMethod_PUT_01 Test end-----------------------");
done();
}).catch(error => {
console.info(casename+"errocode" + JSON.stringify(error));
expect(false).assertTrue();
done();
});
} catch (error) {
console.log("Telephony_http_HttpRequestMethod_PUT_0200 : error = " + error);
expect(false).assertTrue();
done();
}
});
...
...
@@ -431,23 +402,19 @@ export default function requestMethodJsunit() {
method: http.RequestMethod.HEAD,
extraData: null,
header: "content-type': 'application/json",
readTimeout: 60,
connectTimeout: 60
readTimeout: 60
000
,
connectTimeout: 60
000
}
var httpRequest = http.createHttp();
if (utils.notCheck) {
expect(true).assertTrue();
done();
return;
}
httpRequest.request("https://www.baidu.com/", httpRequestOptions, (err, data) => {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
expect(data.responseCode = 200).assertTrue();
expect(data.responseCode =
=
200).assertTrue();
console.log("-----------------------HttpRequestMethod_head Test end-----------------------");
done();
});
} catch (error) {
console.log("Telephony_Http_HttpRequestMethod_head_0100 : error = " + error);
expect(false).assertTrue();
done();
}
});
...
...
@@ -465,26 +432,23 @@ export default function requestMethodJsunit() {
method: http.RequestMethod.HEAD,
extraData: null,
header: "content-type': 'application/json",
readTimeout: 60,
connectTimeout: 60
readTimeout: 60
000
,
connectTimeout: 60
000
}
var httpRequest = http.createHttp();
if (utils.notCheck) {
expect(true).assertTrue();
done();
return;
}
httpRequest.request("https://www.baidu.com/", httpRequestOptions).then(data => {
console.log(casename + JSON.stringify(data));
expect(data.responseCode = 200).assertTrue();
expect(data.responseCode =
=
200).assertTrue();
console.log("-----------------------HttpRequestMethod_HEAD_01 Test end-----------------------");
done();
}).catch(error => {
console.info(casename+"errocode" + JSON.stringify(error));
expect(false).assertTrue();
done();
});
} catch (error) {
console.log("Telephony_http_HttpRequestMethod_HEAD_0200 : error = " + error);
expect(false).assertTrue();
done();
}
});
...
...
@@ -503,23 +467,19 @@ export default function requestMethodJsunit() {
method: http.RequestMethod.DELETE,
extraData: null,
header: "content-type': 'application/json",
readTimeout: 60,
connectTimeout: 60
readTimeout: 60
000
,
connectTimeout: 60
000
}
var httpRequest = http.createHttp();
if (utils.notCheck) {
expect(true).assertTrue();
done();
return;
}
httpRequest.request("https://www.baidu.com/", httpRequestOptions, (err, data) => {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
expect(data.responseCode = 200).assertTrue();
expect(data.responseCode =
=
200).assertTrue();
console.log("-----------------------HttpRequestMethod_DELETE Test end-----------------------");
done();
});
} catch (error) {
console.log("Telephony_Http_HttpRequestMethod_DELETE_0100 : error = " + error);
expect(false).assertTrue();
done();
}
});
...
...
@@ -537,26 +497,23 @@ export default function requestMethodJsunit() {
method: http.RequestMethod.DELETE,
extraData: null,
header: "content-type': 'application/json",
readTimeout: 60,
connectTimeout: 60
readTimeout: 60
000
,
connectTimeout: 60
000
}
var httpRequest = http.createHttp();
if (utils.notCheck) {
expect(true).assertTrue();
done();
return;
}
httpRequest.request("https://www.baidu.com/", httpRequestOptions).then(data => {
console.log(casename + JSON.stringify(data));
expect(data.responseCode = 200).assertTrue();
expect(data.responseCode =
=
200).assertTrue();
console.log("-----------------------HttpRequestMethod_DELETE_01 Test end-----------------------");
done();
}).catch(error => {
console.info(casename+"errocode" + JSON.stringify(error));
expect(false).assertTrue();
done();
});
} catch (error) {
console.log("Telephony_http_HttpRequestMethod_DELETE_0200 : error = " + error);
expect(false).assertTrue();
done();
}
});
...
...
@@ -575,23 +532,19 @@ export default function requestMethodJsunit() {
method: http.RequestMethod.CONNECT,
extraData: null,
header: "content-type': 'application/json",
readTimeout: 60,
connectTimeout: 60
readTimeout: 60
000
,
connectTimeout: 60
000
}
var httpRequest = http.createHttp();
if (utils.notCheck) {
expect(true).assertTrue();
done();
return;
}
httpRequest.request("https://www.baidu.com/", httpRequestOptions, (err, data) => {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
expect(data.responseCode = 200).assertTrue();
expect(data.responseCode =
=
200).assertTrue();
console.log("-----------------------HttpRequestMethod_CONNECT Test end-----------------------");
done();
});
} catch (error) {
console.log("Telephony_Http_HttpRequestMethod_CONNECT_0100 : error = " + error);
expect(false).assertTrue();
done();
}
});
...
...
@@ -609,31 +562,26 @@ export default function requestMethodJsunit() {
method: http.RequestMethod.CONNECT,
extraData: null,
header: "content-type': 'application/json",
readTimeout: 60,
connectTimeout: 60
readTimeout: 60
000
,
connectTimeout: 60
000
}
var httpRequest = http.createHttp();
if (utils.notCheck) {
expect(true).assertTrue();
done();
return;
}
httpRequest.request("https://www.baidu.com/", httpRequestOptions).then(data => {
console.log(casename + JSON.stringify(data));
expect(data.responseCode = 200).assertTrue();
expect(data.responseCode =
=
200).assertTrue();
console.log("-----------------------HttpRequestMethod_CONNECT_01 Test end-----------------------");
done();
}).catch(error => {
console.info(casename+"errocode" + JSON.stringify(error));
expect(false).assertTrue();
done();
});
} catch (error) {
console.log("Telephony_http_HttpRequestMethod_CONNECT_0200 : error = " + error);
expect(false).assertTrue();
done();
}
});
})
};
telephony/telephonyjstest/netmanager_http/entry/src/main/ets/test/ResponseCodeJsunit.test.ets
浏览文件 @
37c8f265
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Copyright (C) 2021
-2022
Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the 'License')
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
...
...
@@ -12,7 +12,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {describe,
beforeAll, afterAll, it, expect, afterEach} from 'hypium/index
';
import {describe,
it, expect} from '@ohos/hypium
';
import http from '@ohos.net.http';
export default function responseCodeJsunit() {
...
...
@@ -50,6 +50,7 @@ export default function responseCodeJsunit() {
done();
} catch (error) {
console.log("Telephony_Http_ResponseCode_ACCEPTED_0100 : error = " + error);
expect(false).assertTrue();
done();
}
});
...
...
@@ -68,6 +69,7 @@ export default function responseCodeJsunit() {
done();
} catch (error) {
console.log("Telephony_Http_ResponseCode_NOT_AUTHORITATIVE_0100 : error = " + error);
expect(false).assertTrue();
done();
}
});
...
...
@@ -86,6 +88,7 @@ export default function responseCodeJsunit() {
done();
} catch (error) {
console.log("Telephony_Http_ResponseCode_NO_CONTENT_0100 : error = " + error);
expect(false).assertTrue();
done();
}
});
...
...
@@ -103,6 +106,7 @@ export default function responseCodeJsunit() {
done();
} catch (error) {
console.log("Telephony_Http_ResponseCode_MULT_CHOICE_0100 : error = " + error);
expect(false).assertTrue();
done();
}
});
...
...
@@ -121,6 +125,7 @@ export default function responseCodeJsunit() {
done();
} catch (error) {
console.log("Telephony_Http_ResponseCode_MOVED_PERM_0100 : error = " + error);
expect(false).assertTrue();
done();
}
});
...
...
@@ -139,6 +144,7 @@ export default function responseCodeJsunit() {
done();
} catch (error) {
console.log("Telephony_Http_ResponseCode_SEE_OTHER_0100 : error = " + error);
expect(false).assertTrue();
done();
}
});
...
...
@@ -157,6 +163,7 @@ export default function responseCodeJsunit() {
done();
} catch (error) {
console.log("Telephony_Http_ResponseCode_NOT_MODIFIED_0100 : error = " + error);
expect(false).assertTrue();
done();
}
});
...
...
@@ -174,6 +181,7 @@ export default function responseCodeJsunit() {
done();
} catch (error) {
console.log("Telephony_Http_ResponseCode_USE_PROXY_0100 : error = " + error);
expect(false).assertTrue();
done();
}
});
...
...
@@ -192,6 +200,7 @@ export default function responseCodeJsunit() {
done();
} catch (error) {
console.log("Telephony_Http_ResponseCode_BAD_REQUEST_0100 : error = " + error);
expect(false).assertTrue();
done();
}
});
...
...
@@ -210,6 +219,7 @@ export default function responseCodeJsunit() {
done();
} catch (error) {
console.log("Telephony_Http_ResponseCode_UNAUTHORIZED_0100 : error = " + error);
expect(false).assertTrue();
done();
}
});
...
...
@@ -228,6 +238,7 @@ export default function responseCodeJsunit() {
done();
} catch (error) {
console.log("Telephony_Http_ResponseCode_PAYMENT_REQUIRED_0100 : error = " + error);
expect(false).assertTrue();
done();
}
});
...
...
@@ -246,6 +257,7 @@ export default function responseCodeJsunit() {
done();
} catch (error) {
console.log("Telephony_Http_ResponseCode_BAD_METHOD_0100 : error = " + error);
expect(false).assertTrue();
done();
}
});
...
...
@@ -264,6 +276,7 @@ export default function responseCodeJsunit() {
done();
} catch (error) {
console.log("Telephony_Http_ResponseCode_NOT_ACCEPTABLED_0100 : error = " + error);
expect(false).assertTrue();
done();
}
});
...
...
@@ -282,6 +295,7 @@ export default function responseCodeJsunit() {
done();
} catch (error) {
console.log("Telephony_Http_ResponseCode_PROXY_AUTH_0100 : error = " + error);
expect(false).assertTrue();
done();
}
});
...
...
@@ -300,6 +314,7 @@ export default function responseCodeJsunit() {
done();
} catch (error) {
console.log("Telephony_Http_ResponseCode_CLIENT_TIMEOUT_0100 : error = " + error);
expect(false).assertTrue();
done();
}
});
...
...
@@ -318,6 +333,7 @@ export default function responseCodeJsunit() {
done();
} catch (error) {
console.log("Telephony_Http_ResponseCode_LENGTH_REQUIRED_0100 : error = " + error);
expect(false).assertTrue();
done();
}
});
...
...
@@ -336,6 +352,7 @@ export default function responseCodeJsunit() {
done();
} catch (error) {
console.log("Telephony_Http_ResponseCode_PRECON_FAILED_0100 : error = " + error);
expect(false).assertTrue();
done();
}
});
...
...
@@ -354,6 +371,7 @@ export default function responseCodeJsunit() {
done();
} catch (error) {
console.log("Telephony_Http_ResponseCode_ENTITY_TOO_LARGE_0100 : error = " + error);
expect(false).assertTrue();
done();
}
});
...
...
@@ -373,6 +391,7 @@ export default function responseCodeJsunit() {
done();
} catch (error) {
console.log("Telephony_Http_ResponseCode_REQ_TOO_LONG_0100 : error = " + error);
expect(false).assertTrue();
done();
}
});
...
...
@@ -392,6 +411,7 @@ export default function responseCodeJsunit() {
done();
} catch (error) {
console.log("Telephony_Http_ResponseCode_UNSUPPORTED_TYPE_0100 : error = " + error);
expect(false).assertTrue();
done();
}
});
...
...
@@ -409,6 +429,7 @@ export default function responseCodeJsunit() {
done();
} catch (error) {
console.log("Telephony_Http_ResponseCode_INTERNAL_ERROR_0100 : error = " + error);
expect(false).assertTrue();
done();
}
});
...
...
@@ -427,6 +448,7 @@ export default function responseCodeJsunit() {
done();
} catch (error) {
console.log("Telephony_Http_ResponseCode_NOT_IMPLEMENTED_0100 : error = " + error);
expect(false).assertTrue();
done();
}
});
...
...
@@ -445,6 +467,7 @@ export default function responseCodeJsunit() {
done();
} catch (error) {
console.log("Telephony_Http_ResponseCode_BAD_GATEWAY_0100 : error = " + error);
expect(false).assertTrue();
done();
}
});
...
...
@@ -463,6 +486,7 @@ export default function responseCodeJsunit() {
done();
} catch (error) {
console.log("Telephony_Http_ResponseCode_GATEWAY_TIMEOUT_0100 : error = " + error);
expect(false).assertTrue();
done();
}
});
...
...
@@ -481,6 +505,7 @@ export default function responseCodeJsunit() {
done();
} catch (error) {
console.log("Telephony_Http_ResponseCode_VERSION_0100 : error = " + error);
expect(false).assertTrue();
done();
}
});
...
...
@@ -499,6 +524,7 @@ export default function responseCodeJsunit() {
done();
} catch (error) {
console.log("Telephony_Http_ResponseCode_CREATED_0100 : error = " + error);
expect(false).assertTrue();
done();
}
});
...
...
@@ -516,6 +542,7 @@ export default function responseCodeJsunit() {
done();
} catch (error) {
console.log("Telephony_Http_ResponseCode_RESET_0100 : error = " + error);
expect(false).assertTrue();
done();
}
});
...
...
@@ -534,6 +561,7 @@ export default function responseCodeJsunit() {
done();
} catch (error) {
console.log("Telephony_Http_ResponseCode_PARTIAL_0100 : error = " + error);
expect(false).assertTrue();
done();
}
});
...
...
@@ -553,6 +581,7 @@ export default function responseCodeJsunit() {
done();
} catch (error) {
console.log("Telephony_Http_ResponseCode_MOVED_TEMP_0100 : error = " + error);
expect(false).assertTrue();
done();
}
});
...
...
@@ -571,6 +600,7 @@ export default function responseCodeJsunit() {
done();
} catch (error) {
console.log("Telephony_Http_ResponseCode_FORBIDDEN_0100 : error = " + error);
expect(false).assertTrue();
done();
}
});
...
...
@@ -589,6 +619,7 @@ export default function responseCodeJsunit() {
done();
} catch (error) {
console.log("Telephony_Http_ResponseCode_NOT_FOUND_0100 : error = " + error);
expect(false).assertTrue();
done();
}
});
...
...
@@ -608,6 +639,7 @@ export default function responseCodeJsunit() {
done();
} catch (error) {
console.log("Telephony_Http_ResponseCode_CONFLICT_0100 : error = " + error);
expect(false).assertTrue();
done();
}
});
...
...
@@ -627,6 +659,7 @@ export default function responseCodeJsunit() {
done();
} catch (error) {
console.log("Telephony_Http_ResponseCode_GONE_0100 : error = " + error);
expect(false).assertTrue();
done();
}
});
...
...
@@ -646,12 +679,10 @@ export default function responseCodeJsunit() {
done();
} catch (error) {
console.log("Telephony_Http_ResponseCode_UNAVAILABLE_0100 : error = " + error);
expect(false).assertTrue();
done();
}
});
})
};
telephony/telephonyjstest/netmanager_http/entry/src/main/ets/test/Utils.ets
已删除
100644 → 0
浏览文件 @
c643d71d
// @ts-nocheck
/**
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export default class Utils {
static rect_left;
static rect_top;
static rect_right;
static rect_bottom;
static rect_value;
static notCheck = true;
static sleep(time) {
return new Promise((resolve, reject) => {
setTimeout(() => {
resolve()
}, time)
}).then(() => {
console.info(`sleep ${time} over...`)
})
}
static getComponentRect(key) {
let strJson = getInspectorByKey(key);
let obj = JSON.parse(strJson);
console.info("[getInspectorByKey] current component obj is: " + JSON.stringify(obj));
let rectInfo = JSON.parse('[' + obj.$rect + ']')
console.info("[getInspectorByKey] rectInfo is: " + rectInfo);
this.rect_left = JSON.parse('[' + rectInfo[0] + ']')[0]
this.rect_top = JSON.parse('[' + rectInfo[0] + ']')[1]
this.rect_right = JSON.parse('[' + rectInfo[1] + ']')[0]
this.rect_bottom = JSON.parse('[' + rectInfo[1] + ']')[1]
return this.rect_value = {
"left": this.rect_left, "top": this.rect_top, "right": this.rect_right, "bottom": this.rect_bottom
}
}
static async swipe(downX, downY, upX, upY, steps) {
console.info('start to swipe')
this.drags(downX, downY, upX, upY, steps, false)
}
static async drag(downX, downY, upX, upY, steps) {
console.info('start to drag')
this.drags(downX, downY, upX, upY, steps, true)
}
static async drags(downX, downY, upX, upY, steps, drag) {
var xStep;
var yStep;
var swipeSteps;
var ret;
xStep = 0;
yStep = 0;
ret = false;
swipeSteps = steps;
if (swipeSteps == 0) {
swipeSteps = 1;
}
xStep = (upX - downX) / swipeSteps;
yStep = (upY - downY) / swipeSteps;
console.info('move step is: ' + 'xStep: ' + xStep + ' yStep: ' + yStep)
var downPonit: TouchObject = {
id: 1,
x: downX,
y: downY,
type: TouchType.Down,
}
console.info('down touch started: ' + JSON.stringify(downPonit))
sendTouchEvent(downPonit);
console.info('start to move')
if (drag) {
await this.sleep(500)
}
for (var i = 1;i <= swipeSteps; i++) {
var movePoint: TouchObject = {
id: 1,
x: downX + (xStep * i),
y: downY + (yStep * i),
type: TouchType.Move
}
console.info('move touch started: ' + JSON.stringify(movePoint))
ret = sendTouchEvent(movePoint)
if (ret == false) {
break;
}
await this.sleep(5)
}
console.info('start to up')
if (drag) {
await this.sleep(100)
}
var upPoint: TouchObject = {
id: 1,
x: upX,
y: upY,
type: TouchType.Up,
}
console.info('up touch started: ' + JSON.stringify(upPoint))
sendTouchEvent(upPoint)
await this.sleep(500)
}
}
telephony/telephonyjstest/netmanager_http/entry/src/main/ets/test/lib/Const.js
已删除
100644 → 0
浏览文件 @
c643d71d
/**
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the 'License');
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an 'AS IS' BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// sim slot id
export
const
DEFAULT_SLOTID
=
0
;
export
const
SLOTID3
=
3
;
export
const
SLOTID2
=
2
;
export
const
SLOTID_MINUS1
=
-
1
;
// sim correct password
export
const
CORRECT_PIN
=
'
1234
'
;
export
const
CORRECT_PIN2
=
'
18099014
'
;
// sim incorrect password
export
const
INCORRECT_PIN
=
'
134679
'
;
export
const
INCORRECT_PIN_LEN3
=
'
123
'
;
export
const
INCORRECT_PUK
=
'
134679
'
;
export
const
INCORRECT_PIN2
=
'
134679
'
;
export
const
INCORRECT_PIN2_LEN3
=
'
123
'
;
export
const
INCORRECT_PIN2_LEN9
=
'
123456789
'
;
export
const
INCORRECT_PUK2
=
'
134679
'
;
// lock status response
export
const
LOCK_RESULT
=
{
SUCCESS
:
0
,
FAILURE
:
-
1
,
EXCEPTION
:
-
2
};
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录