提交 ba16296c 编写于 作者: H hu0475

完成telephony子系统http模块的跨平台测试套

Signed-off-by: Nhu0475 <huyanqiang5@huawei.com>
上级 03afbd99
......@@ -14,6 +14,6 @@
group("telephony") {
testonly = true
deps = [
"crossplatform/telephony_http_test:telephony_http_ets_test",
"crossplatform/telephony_http_test:ActsCrossplatformTelephonyHttpEtsTest",
"telephonyjstest:telephonyjstest" ]
}
......@@ -6,10 +6,10 @@
"versionName": "1.0.0",
"icon": "$media:app_icon",
"label": "$string:app_name",
"minAPIVersion": 9,
"targetAPIVersion": 9,
"minAPIVersion": 10,
"targetAPIVersion": 10,
"car": {
"apiCompatibleVersion": 9,
"apiCompatibleVersion": 10,
"singleUser": false
}
}
......
......@@ -12,7 +12,7 @@
# limitations under the License.
import("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("telephony_http_ets_test") {
ohos_js_hap_suite("ActsCrossplatformTelephonyHttpEtsTest") {
hap_profile = "src/main/module.json"
deps = [
":windowStage_js_assets",
......@@ -21,7 +21,7 @@ ohos_js_hap_suite("telephony_http_ets_test") {
ets2abc = true
certificate_profile = "./signature/openharmony_sx.p7b"
# hap_name: HAP的名字,可选,默认为目标名
hap_name = "telephony_http_ets_test"
hap_name = "ActsCrossplatformTelephonyHttpEtsTest"
part_name = "netstack"
subsystem_name = "communication"
}
......
......@@ -10,7 +10,7 @@
"kits": [
{
"test-file-name": [
"telephony_http_ets_test.hap"
"ActsCrossplatformTelephonyHttpEtsTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
......
/*
* Copyright (C) 2021-2022 Huawei Device Co., Ltd.
* Copyright (C) 2023 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
......@@ -42,6 +42,7 @@ export default function httpRequestJsunit() {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
expect(data.responseCode == 200).assertTrue();
console.log("-----------------------HttpRequest_request Test end-----------------------");
httpRequest.destroy();
done();
});
} catch (error) {
......@@ -68,6 +69,7 @@ export default function httpRequestJsunit() {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
expect(data.responseCode == 200).assertTrue();
console.log("-----------------------HttpRequest_request_01 Test end-----------------------");
httpRequest.destroy();
done();
});
} catch (error) {
......@@ -101,6 +103,7 @@ export default function httpRequestJsunit() {
console.log(casename + JSON.stringify(data));
expect(data.responseCode == 200).assertTrue();
console.log("-----------------------HttpRequest_request_02 Test end-----------------------");
httpRequest.destroy();
done();
}).catch(error => {
console.info('HttpRequest_request_0300 asyncCallback error : ' + JSON.stringify(error));
......@@ -138,6 +141,7 @@ export default function httpRequestJsunit() {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
expect(data.responseCode == 200).assertTrue();
console.log("-----------------------HttpRequest_request Test end-----------------------");
httpRequest.destroy();
done();
});
} catch (error) {
......@@ -171,6 +175,7 @@ export default function httpRequestJsunit() {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
expect(data.responseCode == 200).assertTrue();
console.log("-----------------------HttpRequest_request Test end-----------------------");
httpRequest.destroy();
done();
});
} catch (error) {
......@@ -206,6 +211,7 @@ export default function httpRequestJsunit() {
httpRequest.destroy();
expect(true).assertTrue();
console.log("-----------------------HttpRequest_destroy Test end-----------------------");
httpRequest.destroy();
done();
} catch (error) {
expect(false).assertFail();
......@@ -245,6 +251,7 @@ export default function httpRequestJsunit() {
httpRequest.destroy();
expect(true).assertTrue();
console.log("-----------------------HttpRequest_destroy Test end-----------------------");
httpRequest.destroy();
done();
} catch (error) {
expect(false).assertFail();
......@@ -284,6 +291,7 @@ export default function httpRequestJsunit() {
httpRequest.destroy();
expect(true).assertTrue();
console.log("-----------------------HttpRequest_destroy Test end-----------------------");
httpRequest.destroy();
done();
} catch (error) {
expect(false).assertFail();
......@@ -315,6 +323,7 @@ export default function httpRequestJsunit() {
console.log(casename + " data: " + JSON.stringify(data));
expect(true).assertTrue();
console.log("-----------------------HttpRequest_on_headersReceive Test end-----------------------");
httpRequest.destroy();
done();
});
httpRequest.request("https://www.baidu.com/", (err, data) => {
......@@ -344,6 +353,7 @@ export default function httpRequestJsunit() {
console.log(casename + " data: " + JSON.stringify(data));
expect(false).assertTrue();
console.log("-----------------------HttpRequest_off_headersReceive Test end-----------------------");
httpRequest.destroy();
done();
});
httpRequest.request("https://www.baidu.com/", (err, data) => {
......@@ -372,6 +382,7 @@ export default function httpRequestJsunit() {
httpRequest.off('headersReceive');
expect(true).assertTrue();
console.log("-----------------------HttpRequest_off_headersReceive_0200 Test end-----------------------");
httpRequest.destroy();
done();
} catch (error) {
console.log("testTelephonyHttpRequestOffheadersReceive002 : error = " + error);
......@@ -397,6 +408,7 @@ export default function httpRequestJsunit() {
console.log(casename + " data: " + JSON.stringify(data));
expect(true).assertTrue();
console.log("-----------------------HttpRequest_on_headersReceive Test end-----------------------");
httpRequest.destroy();
done();
});
httpRequest.request("https://www.baidu.com/", (err, data) => {
......@@ -426,6 +438,7 @@ export default function httpRequestJsunit() {
console.log(casename + " data: " + JSON.stringify(data));
expect(true).assertTrue();
console.log("-----------------------HttpRequest_on_headersReceive Test end-----------------------");
httpRequest.destroy();
done();
});
httpRequest.request("https://app.4399.cn/", (err, data) => {
......
/*
* Copyright (C) 2021-2022 Huawei Device Co., Ltd.
* Copyright (C) 2023 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
......@@ -18,8 +18,6 @@ import http from '@ohos.net.http';
export default function HttpRequestOptionsJsunit() {
describe("HttpRequestOptionsJsunitTest", function () {
/**
* @tc.number TEST_TELEPHONYHTTPREQUESTOPTIONSMETHOD_001
* @tc.name testTelephonyHttpRequestOptionsMethod001
......@@ -44,6 +42,7 @@ export default function HttpRequestOptionsJsunit() {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
expect(data.responseCode == 200).assertTrue();
console.log("-----------------------HttpRequestOptions_method Test end-----------------------");
httpRequest.destroy();
done();
});
} catch (error) {
......@@ -77,6 +76,7 @@ export default function HttpRequestOptionsJsunit() {
console.log(casename + JSON.stringify(data));
expect(data.responseCode == 200).assertTrue();
console.log("-----------------------HttpRequestOptions_method_01 Test end-----------------------");
httpRequest.destroy();
done();
}).catch(error => {
console.info(casename+"errocode" + JSON.stringify(error));
......@@ -114,6 +114,7 @@ export default function HttpRequestOptionsJsunit() {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
expect(data.responseCode == 200).assertTrue();
console.log("-----------------------HttpRequestOptions_method Test end-----------------------");
httpRequest.destroy();
done();
});
} catch (error) {
......@@ -155,6 +156,7 @@ export default function HttpRequestOptionsJsunit() {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
expect(data.responseCode == 200).assertTrue();
console.log("-----------------------HttpRequestOptions_extraData Test end-----------------------");
httpRequest.destroy();
done();
});
} catch (error) {
......@@ -196,6 +198,7 @@ export default function HttpRequestOptionsJsunit() {
console.log(casename + JSON.stringify(data));
expect(data.responseCode == 200).assertTrue();
console.log("-----------------------HttpRequestOptions_extraData_01 Test end-----------------------");
httpRequest.destroy();
done();
}).catch(error => {
console.info(casename+"errocode" + JSON.stringify(error));
......@@ -242,6 +245,7 @@ export default function HttpRequestOptionsJsunit() {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
expect(data.responseCode == 200).assertTrue();
console.log("-----------------------HttpRequestOptions_extraData Test end-----------------------");
httpRequest.destroy();
done();
});
} catch (error) {
......@@ -284,6 +288,7 @@ export default function HttpRequestOptionsJsunit() {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
expect(data.responseCode == 200).assertTrue();
console.log("-----------------------HttpRequestOptions_extraData Test end-----------------------");
httpRequest.destroy();
done();
});
} catch (error) {
......@@ -326,6 +331,7 @@ export default function HttpRequestOptionsJsunit() {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
expect(data.responseCode == 200).assertTrue();
console.log("-----------------------HttpRequestOptions_extraData Test end-----------------------");
httpRequest.destroy();
done();
});
} catch (error) {
......@@ -360,6 +366,7 @@ export default function HttpRequestOptionsJsunit() {
try {
expect(true).assertTrue();
console.log("-----------------------HttpRequestOptions_header Test end-----------------------");
httpRequest.destroy();
done();
} catch (error) {
console.log("testTelephonyHttpRequestOptionsHeaders001 : JSON parse error = " + error);
......@@ -399,6 +406,7 @@ export default function HttpRequestOptionsJsunit() {
try {
expect(true).assertTrue();
console.log("-----------------------HttpRequestOptions_header_01 Test end-----------------------");
httpRequest.destroy();
done();
} catch (error) {
console.log("Telephony_Http_HttpRequestOptions_header_0200 : JSON parse error = " + error);
......@@ -442,6 +450,7 @@ export default function HttpRequestOptionsJsunit() {
try {
expect(data.responseCode == 200).assertTrue();
console.log("-----------------------HttpRequestOptions_header_02 Test end-----------------------");
httpRequest.destroy();
done();
} catch (error) {
console.log("testTelephonyHttpRequestOptionsHeader003 : JSON parse error = " + error);
......@@ -481,6 +490,7 @@ export default function HttpRequestOptionsJsunit() {
try {
expect(data.result.valueOf() != "").assertTrue();
console.log("-----------------------HttpRequestOptions_header_03 Test end-----------------------");
httpRequest.destroy();
done();
} catch (error) {
console.log("testTelephonyHttpRequestOptionsHeader004 : JSON parse error = " + error);
......@@ -524,6 +534,7 @@ export default function HttpRequestOptionsJsunit() {
try {
expect(true).assertTrue();
console.log("-----------------------HttpRequestOptions_header Test end-----------------------");
httpRequest.destroy();
done();
} catch (error) {
console.log("testTelephonyHttpRequestOptionsHeaders001 : JSON parse error = " + error);
......@@ -571,6 +582,7 @@ export default function HttpRequestOptionsJsunit() {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
expect(data.responseCode == 200).assertTrue();
console.log("-----------------------HttpRequestOptions_extraData Test end-----------------------");
httpRequest.destroy();
done();
});
} catch (error) {
......@@ -613,6 +625,7 @@ export default function HttpRequestOptionsJsunit() {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
expect(data.responseCode == 200).assertTrue();
console.log("-----------------------HttpRequestOptions_extraData Test end-----------------------");
httpRequest.destroy();
done();
});
} catch (error) {
......@@ -655,6 +668,7 @@ export default function HttpRequestOptionsJsunit() {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
expect(data.responseCode == 200).assertTrue();
console.log("-----------------------HttpRequestOptions_extraData Test end-----------------------");
httpRequest.destroy();
done();
});
} catch (error) {
......@@ -697,6 +711,7 @@ export default function HttpRequestOptionsJsunit() {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
expect(data.responseCode == 200).assertTrue();
console.log("-----------------------HttpRequestOptions_usingProtocol Test end-----------------------");
httpRequest.destroy();
done();
});
} catch (error) {
......@@ -730,6 +745,7 @@ export default function HttpRequestOptionsJsunit() {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
expect(data.responseCode == 200).assertTrue();
console.log("-----------------------HttpRequestOptions_usingProtocol Test end-----------------------");
httpRequest.destroy();
done();
});
} catch (error) {
......@@ -766,6 +782,7 @@ export default function HttpRequestOptionsJsunit() {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
expect(data.responseCode == 200).assertTrue();
console.log("-----------------------HttpRequestOptions_usingProtocol Test end-----------------------");
httpRequest.destroy();
done();
});
} catch (error) {
......@@ -784,8 +801,8 @@ export default function HttpRequestOptionsJsunit() {
* @tc.level: level 2
*/
it("testTelephonyHttpRequestOptionsReadTimeout001", 0, async function (done) {
var casename = 'Telephony_Http_HttpRequestOptions_0400';
console.log("-----------------------HttpRequestOptions_readTimeout Test is starting-----------------------");
var casename = 'testTelephonyHttpRequestOptionsReadTimeout001';
console.log("-----------------------testTelephonyHttpRequestOptionsReadTimeout001 Test is starting-----------------------");
try {
let httpRequestOptions = {
method: http.RequestMethod.GET,
......@@ -795,19 +812,18 @@ export default function HttpRequestOptionsJsunit() {
connectTimeout: 60
}
var httpRequest = http.createHttp();
if (httpRequestOptions.connectTimeout < 60000) {
done();
return;
}
httpRequest.request("https://www.zhihu.com/signin", httpRequestOptions, (err, data) => {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
expect(data.responseCode == 408).assertTrue();
console.log("-----------------------HttpRequestOptions_readTimeout Test end-----------------------");
httpRequest.request("https://www.baidu.com/", httpRequestOptions, (err, data) => {
console.log(casename + ' error:' + JSON.stringify(err) + " data: " + JSON.stringify(data));
expect(err.code == 2300028).assertTrue();
expect(err.message == 'Timeout was reached').assertTrue();
httpRequest.destroy();
console.log("-----------------------testTelephonyHttpRequestOptionsReadTimeout001 Test end-----------------------");
httpRequest.destroy();
done();
});
} catch (error) {
console.log("testTelephonyHttpRequestOptionsReadTimeout001 : error = " + error);
expect(false).assertTrue();
expect(false).assertTrue();
done();
}
});
......@@ -821,8 +837,8 @@ export default function HttpRequestOptionsJsunit() {
* @tc.level: level 2
*/
it("testTelephonyHttpRequestOptionsReadTimeout002", 0, async function (done) {
var casename = 'Telephony_Http_HttpRequestOptions_0400';
console.log("-----------------------HttpRequestOptions_readTimeout_01 Test is starting-----------------------");
var casename = 'testTelephonyHttpRequestOptionsReadTimeout002';
console.log("-----------------------HttpRequestOptions_readTimeout_02 Test is starting-----------------------");
try {
let httpRequestOptions = {
method: http.RequestMethod.GET,
......@@ -832,18 +848,16 @@ export default function HttpRequestOptionsJsunit() {
connectTimeout: 60
}
var httpRequest = http.createHttp();
if (httpRequestOptions.connectTimeout < 60000) {
done();
return;
}
httpRequest.request("https://www.zhihu.com/signin", httpRequestOptions).then(data => {
httpRequest.request("https://www.baidu.com/", httpRequestOptions).then(data => {
console.log(casename + JSON.stringify(data));
expect(data.responseCode == 408).assertTrue();
console.log("-----------------------HttpRequestOptions_readTimeout_01 Test end-----------------------");
console.log("-----------------------HttpRequestOptions_readTimeout_02 Test end-----------------------");
expect().assertFail();
httpRequest.destroy();
done();
}).catch(error => {
console.info(casename+"errocode" + JSON.stringify(error));
expect(false).assertTrue();
expect(error.code == 2300028).assertTrue();
expect(error.message == 'Timeout was reached').assertTrue();
done();
});
} catch (error) {
......@@ -872,20 +886,18 @@ export default function HttpRequestOptionsJsunit() {
readTimeout: 60,
connectTimeout: 0.1
}
if (httpRequestOptions.connectTimeout < 60000) {
done();
return;
}
var httpRequest = http.createHttp();
httpRequest.request("https://app.4399.cn/", httpRequestOptions, (err, data) => {
httpRequest.request("https://www.baidu.com/", httpRequestOptions, (err, data) => {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
expect(data.responseCode == 504).assertTrue();
expect(err.code == 2300028).assertTrue();
expect(err.message == 'Timeout was reached').assertTrue();
console.log("-----------------------HttpRequestOptions_connectTimeout Test end-----------------------");
httpRequest.destroy();
done();
});
} catch (error) {
console.log("testTelephonyHttpRequestOptionsConnectTimeout001 : error = " + error);
expect(false).assertTrue();
//expect(false).assertTrue();
done();
}
});
......@@ -900,7 +912,7 @@ export default function HttpRequestOptionsJsunit() {
* @tc.level: level 2
*/
it("testTelephonyHttpRequestOptionsConnectTimeout002", 0, async function (done) {
var casename = 'Telephony_Http_HttpRequestOptions_0500';
var casename = 'Telephony_Http_HttpRequestOptions_0600';
console.log("-----------------------HttpRequestOptions_connectTimeout_01 Test is starting-----------------------");
try {
let httpRequestOptions = {
......@@ -910,24 +922,21 @@ export default function HttpRequestOptionsJsunit() {
readTimeout: 60,
connectTimeout: 0.1
}
if (httpRequestOptions.connectTimeout < 60000) {
done();
return;
}
var httpRequest = http.createHttp();
httpRequest.request("https://app.4399.cn/", httpRequestOptions).then(data => {
httpRequest.request("https://www.baidu.com/", httpRequestOptions).then(data => {
console.log(casename + JSON.stringify(data));
expect(data.responseCode == 504).assertTrue();
console.log("-----------------------HttpRequestOptions_connectTimeout_01 Test end-----------------------");
expect().assertFail();
httpRequest.destroy();
done();
}).catch(error => {
console.info(casename+"errocode" + JSON.stringify(error));
expect(false).assertTrue();
expect(error.code == 2300028).assertTrue();
expect(error.message == 'Timeout was reached').assertTrue();
done();
});
} catch (error) {
console.log("testTelephonyHttpRequestOptionsConnectTimeout002 : error = " + error);
expect(false).assertTrue();
done();
}
});
......
/*
* Copyright (C) 2021-2022 Huawei Device Co., Ltd.
* Copyright (C) 2023 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
......@@ -18,6 +18,189 @@ import http from '@ohos.net.http';
export default function httpResponseJsunit() {
describe("HttpResponseCacheJsunitTest", function () {
/**
*@tc.number : TEST_TELEPHONYHTTPRESPONSECACHESIZE_001
*@tc.name : testTelephonyHttpResponseCacheSize001
*@tc.desc : Test HttpResponseCache method: flush:callback.
*@tc.size : MediumTest
*@tc.type : Function
*@tc.level : Level 2
*/
it("testTelephonyHttpResponseCacheSize001", 0, async function (done) {
console.log("-----------------------HttpResponse result Test is starting-----------------------");
var caseName = 'telephonyHttpResponseCacheSize_0001';
try {
console.log("-----------------------HttpRequestOptions_method_01 Test is starting-----------------------");
try {
let httpRequestOptions = {
method: http.RequestMethod.GET,
extraData: null,
header: "content-type': 'application/json",
readTimeout: 60000,
connectTimeout: 60000,
usingCache: true
}
var httpRequest = http.createHttp();
httpRequest.request("https://www.baidu.com/", httpRequestOptions).then(data => {
console.log(caseName + JSON.stringify(data));
expect(data.responseCode == 200).assertTrue();
const httpResponseCache = http.createHttpResponseCache(1*1024*1024);
httpResponseCache.flush(err => {
try {
if (err) {
console.info(caseName + ' flush fail: ' + err);
expect().assertFail();
} else {
expect(true).assertTrue();
}
done();
} catch (err) {
console.info(caseName + ' meet error: ' + err);
done();
}
});
}).catch(error => {
console.info(caseName + "errocode" + JSON.stringify(error));
expect(false).assertTrue();
done();
});
} catch (error) {
console.log(caseName + " : error = " + error);
expect(false).assertTrue();
done();
}
} catch (error) {
console.log(caseName + " : error = " + error);
expect().assertFail();
done();
}
httpRequest.destroy();
});
/**
*@tc.number : TEST_TELEPHONYHTTPRESPONSECACHESIZE_002
*@tc.name : testTelephonyHttpResponseCacheSize002
*@tc.desc : Test HttpResponseCache method: flush:callback.
*@tc.size : MediumTest
*@tc.type : Function
*@tc.level : Level 2
*/
it("testTelephonyHttpResponseCacheSize002", 0, async function (done) {
console.log("-----------------------HttpResponse result Test is starting-----------------------");
var caseName = 'telephonyHttpResponseCacheSize_0002';
try {
console.log("-----------------------HttpRequestOptions_method_01 Test is starting-----------------------");
try {
let httpRequestOptions = {
method: http.RequestMethod.GET,
extraData: null,
header: "content-type': 'application/json",
readTimeout: 60000,
connectTimeout: 60000,
usingCache: true
}
var httpRequest = http.createHttp();
httpRequest.request("https://www.baidu.com/", httpRequestOptions).then(data => {
console.log(caseName + JSON.stringify(data));
expect(data.responseCode == 200).assertTrue();
const httpResponseCache = http.createHttpResponseCache(5*1024*1024);
httpResponseCache.flush(err => {
try {
if (err) {
console.info(caseName + ' flush fail: ' + err);
expect().assertFail();
} else {
expect(true).assertTrue();
}
done();
} catch (err) {
console.info(caseName + ' meet error: ' + err);
done();
}
});
}).catch(error => {
console.info(caseName + "errocode" + JSON.stringify(error));
expect(false).assertTrue();
done();
});
} catch (error) {
console.log(caseName + " : error = " + error);
expect(false).assertTrue();
done();
}
} catch (error) {
console.log(caseName + " : error = " + error);
expect().assertFail();
done();
}
httpRequest.destroy();
});
/**
*@tc.number : TEST_TELEPHONYHTTPRESPONSECACHESIZE_003
*@tc.name : testTelephonyHttpResponseCacheSize003
*@tc.desc : Test HttpResponseCache method: flush:callback.
*@tc.size : MediumTest
*@tc.type : Function
*@tc.level : Level 2
*/
it("testTelephonyHttpResponseCacheSize003", 0, async function (done) {
console.log("-----------------------HttpResponse result Test is starting-----------------------");
var caseName = 'telephonyHttpResponseCacheSize_0003';
try {
console.log("-----------------------HttpRequestOptions_method_01 Test is starting-----------------------");
try {
let httpRequestOptions = {
method: http.RequestMethod.GET,
extraData: null,
header: "content-type': 'application/json",
readTimeout: 60000,
connectTimeout: 60000,
usingCache: true
}
var httpRequest = http.createHttp();
httpRequest.request("https://www.baidu.com/", httpRequestOptions).then(data => {
console.log(caseName + JSON.stringify(data));
expect(data.responseCode == 200).assertTrue();
const httpResponseCache = http.createHttpResponseCache(10*1024*1024);
httpResponseCache.flush(err => {
try {
if (err) {
console.info(caseName + ' flush fail: ' + err);
expect().assertFail();
} else {
expect(true).assertTrue();
}
done();
} catch (err) {
console.info(caseName + ' meet error: ' + err);
done();
}
});
}).catch(error => {
console.info(caseName + "errocode" + JSON.stringify(error));
expect(false).assertTrue();
done();
});
} catch (error) {
console.log(caseName + " : error = " + error);
expect(false).assertTrue();
done();
}
} catch (error) {
console.log(caseName + " : error = " + error);
expect().assertFail();
done();
}
httpRequest.destroy();
});
/**
*@tc.number : TEST_TELEPHONY_HTTPRESPONSECACHEFLUSH_001
*@tc.name : testTelephonyHttpResponseCacheFlush001
......@@ -44,7 +227,6 @@ export default function httpResponseJsunit() {
httpRequest.request("https://www.baidu.com/", httpRequestOptions).then(data => {
console.log(caseName + JSON.stringify(data));
expect(data.responseCode == 200).assertTrue();
const httpResponseCache = http.createHttpResponseCache();
httpResponseCache.flush(err => {
try {
......@@ -77,6 +259,7 @@ export default function httpResponseJsunit() {
expect().assertFail();
done();
}
httpRequest.destroy();
});
......@@ -106,7 +289,6 @@ export default function httpResponseJsunit() {
httpRequest.request("https://app.4399.cn/", httpRequestOptions).then(data => {
console.log(caseName + JSON.stringify(data));
expect(data.responseCode == 200).assertTrue();
const httpResponseCache = http.createHttpResponseCache();
httpResponseCache.flush(err => {
try {
......@@ -139,6 +321,7 @@ export default function httpResponseJsunit() {
expect().assertFail();
done();
}
httpRequest.destroy();
});
/**
......@@ -194,6 +377,7 @@ export default function httpResponseJsunit() {
expect().assertFail();
done();
}
httpRequest.destroy();
});
/**
......@@ -222,7 +406,6 @@ export default function httpResponseJsunit() {
httpRequest.request("https://app.4399.cn/", httpRequestOptions).then(data => {
console.log(caseName + JSON.stringify(data));
expect(data.responseCode == 200).assertTrue();
const httpResponseCache = http.createHttpResponseCache();
httpResponseCache.flush().then(() => {
expect(true).assertTrue();
......@@ -249,6 +432,7 @@ export default function httpResponseJsunit() {
expect().assertFail();
done();
}
httpRequest.destroy();
});
......@@ -280,7 +464,6 @@ export default function httpResponseJsunit() {
httpRequest.request("https://www.baidu.com/", httpRequestOptions).then(data => {
console.log(caseName + JSON.stringify(data));
expect(data.responseCode == 200).assertTrue();
const httpResponseCache = http.createHttpResponseCache();
httpResponseCache.delete(err => {
try {
......@@ -313,6 +496,7 @@ export default function httpResponseJsunit() {
expect().assertFail();
done();
}
httpRequest.destroy();
});
/**
......@@ -341,7 +525,6 @@ export default function httpResponseJsunit() {
httpRequest.request("https://www.baidu.com/", httpRequestOptions).then(data => {
console.log(caseName + JSON.stringify(data));
expect(data.responseCode == 200).assertTrue();
const httpResponseCache = http.createHttpResponseCache();
httpResponseCache.delete().then(() => {
expect(true).assertTrue();
......@@ -368,6 +551,7 @@ export default function httpResponseJsunit() {
expect().assertFail();
done();
}
httpRequest.destroy();
});
})
......
/*
* Copyright (C) 2021-2022 Huawei Device Co., Ltd.
* Copyright (C) 2023 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
......@@ -43,6 +43,7 @@ export default function httpResponseJsunit() {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
expect(data.result != null).assertTrue();
console.log("-----------------------HttpResponse result Test end-----------------------");
httpRequest.destroy();
done();
});
} catch (error) {
......@@ -71,6 +72,7 @@ export default function httpResponseJsunit() {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
expect(data.result != null).assertTrue();
console.log("-----------------------HttpResponse result_01 Test end-----------------------");
httpRequest.destroy();
done();
});
} catch (error) {
......@@ -106,6 +108,7 @@ export default function httpResponseJsunit() {
console.log(casename + JSON.stringify(data));
expect(data.result != null).assertTrue();
console.log("-----------------------HttpResponse result_02 Test end-----------------------");
httpRequest.destroy();
done();
}).catch(error => {
console.info(casename+"errocode" + JSON.stringify(error));
......@@ -144,6 +147,7 @@ export default function httpResponseJsunit() {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
expect(data.result != null).assertTrue();
console.log("-----------------------HttpResponse result Test end-----------------------");
httpRequest.destroy();
done();
});
} catch (error) {
......@@ -179,6 +183,7 @@ export default function httpResponseJsunit() {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
expect(data.resultType == http.HttpDataType.STRING).assertTrue();
console.log("-----------------------HttpResponse result Test end-----------------------");
httpRequest.destroy();
done();
});
} catch (error) {
......@@ -214,6 +219,7 @@ export default function httpResponseJsunit() {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
expect(data.resultType == http.HttpDataType.OBJECT).assertTrue();
console.log("-----------------------HttpResponse result Test end-----------------------");
httpRequest.destroy();
done();
});
} catch (error) {
......@@ -249,6 +255,7 @@ export default function httpResponseJsunit() {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
expect(data.resultType == http.HttpDataType.ARRAY_BUFFER).assertTrue();
console.log("-----------------------HttpResponse result Test end-----------------------");
httpRequest.destroy();
done();
});
} catch (error) {
......@@ -284,6 +291,7 @@ export default function httpResponseJsunit() {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
expect(data.responseCode != 0).assertTrue();
console.log("-----------------------HttpResponse responseCode Test end-----------------------");
httpRequest.destroy();
done();
});
} catch (error) {
......@@ -312,6 +320,7 @@ export default function httpResponseJsunit() {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
expect(data.responseCode != 0).assertTrue();
console.log("-----------------------HttpResponse responseCode_01 Test end-----------------------");
httpRequest.destroy();
done();
});
} catch (error) {
......@@ -348,6 +357,7 @@ export default function httpResponseJsunit() {
console.log(casename + JSON.stringify(data));
expect(data.responseCode != 0).assertTrue();
console.log("-----------------------HttpResponse responseCode_02 Test end-----------------------");
httpRequest.destroy();
done();
}).catch(error => {
console.info(casename+"errocode" + JSON.stringify(error));
......@@ -386,6 +396,7 @@ export default function httpResponseJsunit() {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
expect(data.responseCode != 0).assertTrue();
console.log("-----------------------HttpResponse responseCode Test end-----------------------");
httpRequest.destroy();
done();
});
} catch (error) {
......@@ -422,6 +433,7 @@ export default function httpResponseJsunit() {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
expect(data.header != null).assertTrue();
console.log("-----------------------header result Test end-----------------------");
httpRequest.destroy();
done();
});
} catch (error) {
......@@ -450,6 +462,7 @@ export default function httpResponseJsunit() {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
expect(data.header != null).assertTrue();
console.log("-----------------------header header_01 Test end-----------------------");
httpRequest.destroy();
done();
});
} catch (error) {
......@@ -486,6 +499,7 @@ export default function httpResponseJsunit() {
console.log(casename + JSON.stringify(data));
expect(data.header != null).assertTrue();
console.log("-----------------------HttpResponse header_02 Test end-----------------------");
httpRequest.destroy();
done();
}).catch(error => {
console.info(casename+"errocode" + JSON.stringify(error));
......@@ -523,6 +537,7 @@ export default function httpResponseJsunit() {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
expect(data.header != null).assertTrue();
console.log("-----------------------header result Test end-----------------------");
httpRequest.destroy();
done();
});
} catch (error) {
......@@ -557,6 +572,7 @@ export default function httpResponseJsunit() {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
expect(data.cookies != null).assertTrue();
console.log("-----------------------HttpResponse cookies Test end-----------------------");
httpRequest.destroy();
done();
});
} catch (error) {
......@@ -586,6 +602,7 @@ export default function httpResponseJsunit() {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
expect(data.cookies != null).assertTrue();
console.log("-----------------------HttpResponse cookies_01 Test end-----------------------");
httpRequest.destroy();
done();
});
} catch (error) {
......@@ -621,6 +638,7 @@ export default function httpResponseJsunit() {
console.log(casename + JSON.stringify(data));
expect(data.cookies != null).assertTrue();
console.log("-----------------------HttpResponse cookies_02 Test end-----------------------");
httpRequest.destroy();
done();
}).catch(error => {
console.info(casename+"errocode" + JSON.stringify(error));
......@@ -658,6 +676,7 @@ export default function httpResponseJsunit() {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
expect(data.cookies != null).assertTrue();
console.log("-----------------------HttpResponse cookies Test end-----------------------");
httpRequest.destroy();
done();
});
} catch (error) {
......
/*
* Copyright (C) 2021-2022 Huawei Device Co., Ltd.
* Copyright (C) 2023 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
......@@ -43,6 +43,7 @@ export default function requestMethodJsunit() {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
expect(data.responseCode == 200).assertTrue();
console.log("-----------------------HttpRequestMethod_options Test end-----------------------");
httpRequest.destroy();
done();
});
} catch (error) {
......@@ -79,6 +80,7 @@ export default function requestMethodJsunit() {
console.log(casename + JSON.stringify(data));
expect(data.responseCode == 200).assertTrue();
console.log("-----------------------HttpRequestMethod_options_01 Test end-----------------------");
httpRequest.destroy();
done();
}).catch(error => {
console.info(casename+"errocode" + JSON.stringify(error));
......@@ -117,6 +119,7 @@ export default function requestMethodJsunit() {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
expect(data.responseCode == 200).assertTrue();
console.log("-----------------------HttpRequestMethod_options Test end-----------------------");
httpRequest.destroy();
done();
});
} catch (error) {
......@@ -153,6 +156,7 @@ export default function requestMethodJsunit() {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
expect(data.responseCode == 200).assertTrue();
console.log("-----------------------HttpRequestMethod_GET Test end-----------------------");
httpRequest.destroy();
done();
});
} catch (error) {
......@@ -189,6 +193,7 @@ export default function requestMethodJsunit() {
console.log(casename + JSON.stringify(data));
expect(data.responseCode == 200).assertTrue();
console.log("-----------------------HttpRequestMethod_GET_01 Test end-----------------------");
httpRequest.destroy();
done();
}).catch(error => {
console.info(casename+"errocode" + JSON.stringify(error));
......@@ -226,6 +231,7 @@ export default function requestMethodJsunit() {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
expect(data.responseCode == 200).assertTrue();
console.log("-----------------------HttpRequestMethod_GET Test end-----------------------");
httpRequest.destroy();
done();
});
} catch (error) {
......@@ -268,6 +274,7 @@ export default function requestMethodJsunit() {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
expect(data.responseCode == 200).assertTrue();
console.log("-----------------------HttpRequestMethod_POST Test end-----------------------");
httpRequest.destroy();
done();
});
} catch (error) {
......@@ -312,6 +319,7 @@ export default function requestMethodJsunit() {
console.log(casename + JSON.stringify(data));
expect(data.responseCode == 200).assertTrue();
console.log("-----------------------HttpRequestMethod_POST_01 Test end-----------------------");
httpRequest.destroy();
done();
}).catch(error => {
console.info(casename+"errocode" + JSON.stringify(error));
......@@ -352,6 +360,7 @@ export default function requestMethodJsunit() {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
expect(data.responseCode == 200).assertTrue();
console.log("-----------------------HttpRequestMethod_TRACE Test end-----------------------");
httpRequest.destroy();
done();
});
} catch (error) {
......@@ -387,6 +396,7 @@ export default function requestMethodJsunit() {
console.log(casename + JSON.stringify(data));
expect(data.responseCode == 200).assertTrue();
console.log("-----------------------HttpRequestMethod_TRACE_01 Test end-----------------------");
httpRequest.destroy();
done();
}).catch(error => {
console.info(casename+"errocode" + JSON.stringify(error));
......@@ -431,6 +441,7 @@ export default function requestMethodJsunit() {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
expect(data.responseCode == 200).assertTrue();
console.log("-----------------------HttpRequestMethod_PUT Test end-----------------------");
httpRequest.destroy();
done();
});
} catch (error) {
......@@ -469,6 +480,7 @@ export default function requestMethodJsunit() {
console.log(casename + JSON.stringify(data));
expect(data.responseCode == 200).assertTrue();
console.log("-----------------------HttpRequestMethod_PUT_01 Test end-----------------------");
httpRequest.destroy();
done();
}).catch(error => {
console.info(casename+"errocode" + JSON.stringify(error));
......@@ -511,6 +523,7 @@ export default function requestMethodJsunit() {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
expect(data.responseCode == 200).assertTrue();
console.log("-----------------------HttpRequestMethod_PUT Test end-----------------------");
httpRequest.destroy();
done();
});
} catch (error) {
......@@ -545,6 +558,7 @@ export default function requestMethodJsunit() {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
expect(data.responseCode == 200).assertTrue();
console.log("-----------------------HttpRequestMethod_head Test end-----------------------");
httpRequest.destroy();
done();
});
} catch (error) {
......@@ -578,6 +592,7 @@ export default function requestMethodJsunit() {
console.log(casename + JSON.stringify(data));
expect(data.responseCode == 200).assertTrue();
console.log("-----------------------HttpRequestMethod_HEAD_01 Test end-----------------------");
httpRequest.destroy();
done();
}).catch(error => {
console.info(casename+"errocode" + JSON.stringify(error));
......@@ -616,6 +631,7 @@ export default function requestMethodJsunit() {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
expect(data.responseCode == 200).assertTrue();
console.log("-----------------------HttpRequestMethod_head Test end-----------------------");
httpRequest.destroy();
done();
});
} catch (error) {
......@@ -650,6 +666,7 @@ export default function requestMethodJsunit() {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
expect(data.responseCode == 200).assertTrue();
console.log("-----------------------HttpRequestMethod_DELETE Test end-----------------------");
httpRequest.destroy();
done();
});
} catch (error) {
......@@ -683,6 +700,7 @@ export default function requestMethodJsunit() {
console.log(casename + JSON.stringify(data));
expect(data.responseCode == 200).assertTrue();
console.log("-----------------------HttpRequestMethod_DELETE_01 Test end-----------------------");
httpRequest.destroy();
done();
}).catch(error => {
console.info(casename+"errocode" + JSON.stringify(error));
......@@ -721,6 +739,7 @@ export default function requestMethodJsunit() {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
expect(data.responseCode == 200).assertTrue();
console.log("-----------------------HttpRequestMethod_DELETE Test end-----------------------");
httpRequest.destroy();
done();
});
} catch (error) {
......@@ -754,6 +773,7 @@ export default function requestMethodJsunit() {
console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data));
expect(data.responseCode == 200).assertTrue();
console.log("-----------------------HttpRequestMethod_CONNECT Test end-----------------------");
httpRequest.destroy();
done();
});
} catch (error) {
......@@ -787,6 +807,7 @@ export default function requestMethodJsunit() {
console.log(casename + JSON.stringify(data));
expect(data.responseCode == 200).assertTrue();
console.log("-----------------------HttpRequestMethod_CONNECT_01 Test end-----------------------");
httpRequest.destroy();
done();
}).catch(error => {
console.info(casename+"errocode" + JSON.stringify(error));
......
/*
* Copyright (C) 2021-2022 Huawei Device Co., Ltd.
* Copyright (C) 2023 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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册