diff --git a/telephony/telephonyjstest/netmanager_base/jshttp/src/main/js/test/HttpRequest2JsunitTest.test.js b/telephony/telephonyjstest/netmanager_base/jshttp/src/main/js/test/HttpRequest2JsunitTest.test.js index c1aff5c8111312631fbec88f706bec107f1edefc..c78bf883604a8916210c73c9ca7d5cd57dfc0f1d 100644 --- a/telephony/telephonyjstest/netmanager_base/jshttp/src/main/js/test/HttpRequest2JsunitTest.test.js +++ b/telephony/telephonyjstest/netmanager_base/jshttp/src/main/js/test/HttpRequest2JsunitTest.test.js @@ -35,32 +35,32 @@ function dataEnd_on_callback() { console.log("dataEnd_on_callback callback function"); } -function dataProgress_on_callback(data) { - console.log("dataProgress_on_callback receive datProgress:" + JSON.stringify(data)); +function dataReceiveProgress_on_callback(data) { + console.log("dataReceiveProgress_on_callback receive datProgress:" + JSON.stringify(data)); } -export default function HttpRequest2JsunitTest() { - describe("HttpRequest2JsunitTest", function () { +export default function HttprequestInStreamJsunitTest() { + describe("HttprequestInStreamJsunitTest", function () { /** - * @tc.number Telephony_http_HttpRequest_request2_0100 - * @tc.name httprequest2::request2 - * @tc.desc Test request2(url: string, callback: AsyncCallback): void. + * @tc.number Telephony_http_HttpRequest_requestInStream_0100 + * @tc.name httprequestInStream::requestInStream + * @tc.desc Test requestInStream(url: string, callback: AsyncCallback): void. */ - it("SUB_Telephony_NetStack_HttpRequest2_Async_0100", 0, async function (done) { - let CaseName = "SUB_Telephony_NetStack_HttpRequest2_Async_0100"; + it("SUB_Telephony_NetStack_HttprequestInStream_Async_0100", 0, async function (done) { + let CaseName = "SUB_Telephony_NetStack_HttprequestInStream_Async_0100"; let Address_Img = "https://img1.baidu.com/it/u=3010094603,1247181326&fm=253&fmt=auto&app=138&f=JPEG?w=800&h=500"; let httpRequest = http.createHttp(); try { httpRequest.on("dataReceive", dataReceive_on_callback); - httpRequest.on("dataProgress", dataProgress_on_callback); + httpRequest.on("dataReceiveProgress", dataReceiveProgress_on_callback); httpRequest.on("dataEnd", dataEnd_on_callback); - httpRequest.request2(Address_Img, httpRequestOptions, (err, data) => { + httpRequest.requestInStream(Address_Img, httpRequestOptions, (err, data) => { console.info(CaseName + " responseCode data : " + data); - console.log(CaseName + "NETSTACK request2 OK!"); + console.log(CaseName + "NETSTACK requestInStream OK!"); httpRequest.off("dataReceive"); console.log("NETSTACK off dataReceive success!"); - httpRequest.off("dataProgress"); - console.log("NETSTACK off dataProgress success!"); + httpRequest.off("dataReceiveProgress"); + console.log("NETSTACK off dataReceiveProgress success!"); httpRequest.off("dataEnd"); console.log("NETSTACK off dataEnd success!"); expect(data == 200).assertTrue(); @@ -68,7 +68,7 @@ export default function HttpRequest2JsunitTest() { done(); }) } catch (error) { - console.log(CaseName + " request2 catch : error = " + JSON.stringify(error)); + console.log(CaseName + " requestInStream catch : error = " + JSON.stringify(error)); expect(error).assertFalse(); done(); } @@ -76,35 +76,35 @@ export default function HttpRequest2JsunitTest() { /** - * @tc.number Telephony_http_HttpRequest_request2_0200 - * @tc.name httprequest2::request2 - * @tc.desc Test request2(url: string, options: HttpRequestOptions, callback: AsyncCallback): void. + * @tc.number Telephony_http_HttpRequest_requestInStream_0200 + * @tc.name httprequestInStream::requestInStream + * @tc.desc Test requestInStream(url: string, options: HttpRequestOptions, callback: AsyncCallback): void. */ - it("SUB_Telephony_NetStack_HttpRequest2_Async_0200", 0, async function (done) { - let CaseName = "SUB_Telephony_NetStack_HttpRequest2_Async_0200" + it("SUB_Telephony_NetStack_HttprequestInStream_Async_0200", 0, async function (done) { + let CaseName = "SUB_Telephony_NetStack_HttprequestInStream_Async_0200" var httpRequest = http.createHttp(); - httpRequest.request2(Address_Baidu, (err, data) => { + httpRequest.requestInStream(Address_Baidu, (err, data) => { if (err) { - console.log(CaseName + " request2 ERROR" + JSON.stringify(err)); + console.log(CaseName + " requestInStream ERROR" + JSON.stringify(err)); expect().assertFail(); done(); } httpRequest.destroy(); - console.log(CaseName + " request2 Finish responseCode " + data); + console.log(CaseName + " requestInStream Finish responseCode " + data); done(); }); }); /** - * @tc.number Telephony_http_HttpRequest_request2_0100 - * @tc.name httprequest2::request2 - * @tc.desc Test request2(url: string, options: HttpRequestOptions): Promise. + * @tc.number Telephony_http_HttpRequest_requestInStream_0100 + * @tc.name httprequestInStream::requestInStream + * @tc.desc Test requestInStream(url: string, options: HttpRequestOptions): Promise. */ - it("SUB_Telephony_NetStack_HttpRequest2_Promise_0100", 0, async function (done) { - let CaseName = "SUB_Telephony_NetStack_HttpRequest2_Promise_0100"; + it("SUB_Telephony_NetStack_HttprequestInStream_Promise_0100", 0, async function (done) { + let CaseName = "SUB_Telephony_NetStack_HttprequestInStream_Promise_0100"; var httpRequest = http.createHttp(); - httpRequest.request2(Address_Baidu, httpRequestOptions).then(function (data) { - console.log(CaseName + " request2 Finish responseCode " + data); + httpRequest.requestInStream(Address_Baidu, httpRequestOptions).then(function (data) { + console.log(CaseName + " requestInStream Finish responseCode " + data); httpRequest.destroy(); done(); }).catch(function (err) { @@ -115,15 +115,15 @@ export default function HttpRequest2JsunitTest() { }); /** - * @tc.number Telephony_http_HttpRequest_request2_0100 - * @tc.name httprequest2::request2 - * @tc.desc Test request2(url: string): Promise. + * @tc.number Telephony_http_HttpRequest_requestInStream_0100 + * @tc.name httprequestInStream::requestInStream + * @tc.desc Test requestInStream(url: string): Promise. */ - it("SUB_Telephony_NetStack_HttpRequest2_Promise_0200", 0, async function (done) { - let CaseName = "SUB_Telephony_NetStack_HttpRequest2_Promise_0200"; + it("SUB_Telephony_NetStack_HttprequestInStream_Promise_0200", 0, async function (done) { + let CaseName = "SUB_Telephony_NetStack_HttprequestInStream_Promise_0200"; var httpRequest = http.createHttp(); - httpRequest.request2(Address_Baidu).then(function (data) { - console.log(CaseName + " request2 Finish responseCode " + data); + httpRequest.requestInStream(Address_Baidu).then(function (data) { + console.log(CaseName + " requestInStream Finish responseCode " + data); httpRequest.destroy(); done(); }).catch(function (err) { @@ -135,16 +135,16 @@ export default function HttpRequest2JsunitTest() { /** - * @tc.number SUB_Telephony_NetStack_HttpRequest2_on_dataReceive_0100 - * @tc.name httprequest2::on_dataReceive + * @tc.number SUB_Telephony_NetStack_HttprequestInStream_on_dataReceive_0100 + * @tc.name httprequestInStream::on_dataReceive * @tc.desc Test on(type: "dataReceive", callback: Callback): void. */ - it("SUB_Telephony_NetStack_HttpRequest2_on_dataReceive_0100", 0, function (done) { - let CaseName = "SUB_Telephony_NetStack_HttpRequest2_on_dataReceive_0100"; + it("SUB_Telephony_NetStack_HttprequestInStream_on_dataReceive_0100", 0, function (done) { + let CaseName = "SUB_Telephony_NetStack_HttprequestInStream_on_dataReceive_0100"; try { var httpRequest = http.createHttp(); httpRequest.on("dataReceive", dataReceive_on_callback); - httpRequest.request2(Address_Baidu).then(function (data) { + httpRequest.requestInStream(Address_Baidu).then(function (data) { console.log(CaseName + " on dataReceive Finish "); expect(data == 200).assertTrue(); httpRequest.destroy(); @@ -163,16 +163,16 @@ export default function HttpRequest2JsunitTest() { /** - * @tc.number SUB_Telephony_NetStack_HttpRequest2_off_dataReceive_0100 - * @tc.name httprequest2::off_dataReceive + * @tc.number SUB_Telephony_NetStack_HttprequestInStream_off_dataReceive_0100 + * @tc.name httprequestInStream::off_dataReceive * @tc.desc Test off(type: "dataReceive", callback: Callback): void. */ - it("SUB_Telephony_NetStack_HttpRequest2_off_dataReceive_0100", 0, function (done) { - let CaseName = "SUB_Telephony_NetStack_HttpRequest2_off_dataReceive_0100"; + it("SUB_Telephony_NetStack_HttprequestInStream_off_dataReceive_0100", 0, function (done) { + let CaseName = "SUB_Telephony_NetStack_HttprequestInStream_off_dataReceive_0100"; try { var httpRequest = http.createHttp(); httpRequest.on("dataReceive", dataReceive_on_callback); - httpRequest.request2(Address_Baidu).then(function (data) { + httpRequest.requestInStream(Address_Baidu).then(function (data) { httpRequest.off("dataReceive", dataReceive_on_callback); console.log(CaseName + " off dataReceive Finish "); expect(data == 200).assertTrue(); @@ -192,16 +192,16 @@ export default function HttpRequest2JsunitTest() { /** - * @tc.number SUB_Telephony_NetStack_HttpRequest2_off_dataReceive_0200 - * @tc.name httprequest2::off_dataReceive + * @tc.number SUB_Telephony_NetStack_HttprequestInStream_off_dataReceive_0200 + * @tc.name httprequestInStream::off_dataReceive * @tc.desc Test off(type: "dataReceive"): void. */ - it("SUB_Telephony_NetStack_HttpRequest2_off_dataReceive_0200", 0, function (done) { - let CaseName = "SUB_Telephony_NetStack_HttpRequest2_off_dataReceive_0200"; + it("SUB_Telephony_NetStack_HttprequestInStream_off_dataReceive_0200", 0, function (done) { + let CaseName = "SUB_Telephony_NetStack_HttprequestInStream_off_dataReceive_0200"; try { var httpRequest = http.createHttp(); httpRequest.on("dataReceive", dataReceive_on_callback); - httpRequest.request2(Address_Baidu).then(function (data) { + httpRequest.requestInStream(Address_Baidu).then(function (data) { httpRequest.off("dataReceive"); console.log(CaseName + " off dataReceive Finish "); expect(data == 200).assertTrue(); @@ -220,17 +220,17 @@ export default function HttpRequest2JsunitTest() { }); /** - * @tc.number SUB_Telephony_NetStack_HttpRequest2_on_dataProgress_0100 - * @tc.name httprequest2::on_dataProgress - * @tc.desc Test on(type: "dataProgress", callback: Callback<{ receiveSize: number, totalSize: number }>): void. + * @tc.number SUB_Telephony_NetStack_HttprequestInStream_on_dataReceiveProgress_0100 + * @tc.name httprequestInStream::on_dataReceiveProgress + * @tc.desc Test on(type: "dataReceiveProgress", callback: Callback<{ receiveSize: number, totalSize: number }>): void. */ - it("SUB_Telephony_NetStack_HttpRequest2_on_dataProgress_0100", 0, function (done) { - let CaseName = "SUB_Telephony_NetStack_HttpRequest2_on_dataProgress_0100"; + it("SUB_Telephony_NetStack_HttprequestInStream_on_dataReceiveProgress_0100", 0, function (done) { + let CaseName = "SUB_Telephony_NetStack_HttprequestInStream_on_dataReceiveProgress_0100"; try { var httpRequest = http.createHttp(); - httpRequest.on("dataProgress", dataProgress_on_callback); - httpRequest.request2(Address_Baidu).then(function (data) { - console.log(CaseName + " on dataProgress Finish "); + httpRequest.on("dataReceiveProgress", dataReceiveProgress_on_callback); + httpRequest.requestInStream(Address_Baidu).then(function (data) { + console.log(CaseName + " on dataReceiveProgress Finish "); expect(data == 200).assertTrue(); httpRequest.destroy(); done(); @@ -247,18 +247,18 @@ export default function HttpRequest2JsunitTest() { }); /** - * @tc.number SUB_Telephony_NetStack_HttpRequest2_off_dataProgress_0100 - * @tc.name httprequest2::off_dataProgress - * @tc.desc Test off(type: "dataProgress", callback: Callback<{ receiveSize: number, totalSize: number }>): void. + * @tc.number SUB_Telephony_NetStack_HttprequestInStream_off_dataReceiveProgress_0100 + * @tc.name httprequestInStream::off_dataReceiveProgress + * @tc.desc Test off(type: "dataReceiveProgress", callback: Callback<{ receiveSize: number, totalSize: number }>): void. */ - it("SUB_Telephony_NetStack_HttpRequest2_off_dataProgress_0100", 0, function (done) { - let CaseName = "SUB_Telephony_NetStack_HttpRequest2_off_dataProgress_0100"; + it("SUB_Telephony_NetStack_HttprequestInStream_off_dataReceiveProgress_0100", 0, function (done) { + let CaseName = "SUB_Telephony_NetStack_HttprequestInStream_off_dataReceiveProgress_0100"; try { var httpRequest = http.createHttp(); - httpRequest.on("dataProgress", dataProgress_on_callback); - httpRequest.request2(Address_Baidu).then(function (data) { - httpRequest.off("dataProgress", dataProgress_on_callback); - console.log(CaseName + " off dataProgress Finish "); + httpRequest.on("dataReceiveProgress", dataReceiveProgress_on_callback); + httpRequest.requestInStream(Address_Baidu).then(function (data) { + httpRequest.off("dataReceiveProgress", dataReceiveProgress_on_callback); + console.log(CaseName + " off dataReceiveProgress Finish "); expect(data == 200).assertTrue(); httpRequest.destroy(); done(); @@ -276,18 +276,18 @@ export default function HttpRequest2JsunitTest() { /** - * @tc.number SUB_Telephony_NetStack_HttpRequest2_off_dataProgress_0200 - * @tc.name httprequest2::off_dataProgress - * @tc.desc Test off(type: "dataProgress"): void. + * @tc.number SUB_Telephony_NetStack_HttprequestInStream_off_dataReceiveProgress_0200 + * @tc.name httprequestInStream::off_dataReceiveProgress + * @tc.desc Test off(type: "dataReceiveProgress"): void. */ - it("SUB_Telephony_NetStack_HttpRequest2_off_dataProgress_0200", 0, function (done) { - let CaseName = "SUB_Telephony_NetStack_HttpRequest2_off_dataProgress_0200"; + it("SUB_Telephony_NetStack_HttprequestInStream_off_dataReceiveProgress_0200", 0, function (done) { + let CaseName = "SUB_Telephony_NetStack_HttprequestInStream_off_dataReceiveProgress_0200"; try { var httpRequest = http.createHttp(); - httpRequest.on("dataProgress", dataProgress_on_callback); - httpRequest.request2(Address_Baidu).then(function (data) { - httpRequest.off("dataProgress"); - console.log(CaseName + " off dataProgress Finish "); + httpRequest.on("dataReceiveProgress", dataReceiveProgress_on_callback); + httpRequest.requestInStream(Address_Baidu).then(function (data) { + httpRequest.off("dataReceiveProgress"); + console.log(CaseName + " off dataReceiveProgress Finish "); expect(data == 200).assertTrue(); httpRequest.destroy(); done(); @@ -305,16 +305,16 @@ export default function HttpRequest2JsunitTest() { /** - * @tc.number SUB_Telephony_NetStack_HttpRequest2_on_dataEnd_0100 - * @tc.name httprequest2::on_dataEnd + * @tc.number SUB_Telephony_NetStack_HttprequestInStream_on_dataEnd_0100 + * @tc.name httprequestInStream::on_dataEnd * @tc.desc Test on(type: "dataEnd", callback: Callback): void. */ - it("SUB_Telephony_NetStack_HttpRequest2_on_dataEnd_0100", 0, function (done) { - let CaseName = "SUB_Telephony_NetStack_HttpRequest2_on_dataEnd_0100"; + it("SUB_Telephony_NetStack_HttprequestInStream_on_dataEnd_0100", 0, function (done) { + let CaseName = "SUB_Telephony_NetStack_HttprequestInStream_on_dataEnd_0100"; try { var httpRequest = http.createHttp(); httpRequest.on("dataEnd", dataEnd_on_callback); - httpRequest.request2(Address_Baidu).then(function (data) { + httpRequest.requestInStream(Address_Baidu).then(function (data) { console.log(CaseName + " on dataEnd Finish "); expect(data == 200).assertTrue(); httpRequest.destroy(); @@ -333,16 +333,16 @@ export default function HttpRequest2JsunitTest() { /** - * @tc.number SUB_Telephony_NetStack_HttpRequest2_off_dataEnd_0100 - * @tc.name httprequest2::off_dataEnd + * @tc.number SUB_Telephony_NetStack_HttprequestInStream_off_dataEnd_0100 + * @tc.name httprequestInStream::off_dataEnd * @tc.desc Test off(type: "dataEnd", callback?: Callback): void. */ - it("SUB_Telephony_NetStack_HttpRequest2_off_dataEnd_0100", 0, function (done) { - let CaseName = "SUB_Telephony_NetStack_HttpRequest2_off_dataEnd_0100"; + it("SUB_Telephony_NetStack_HttprequestInStream_off_dataEnd_0100", 0, function (done) { + let CaseName = "SUB_Telephony_NetStack_HttprequestInStream_off_dataEnd_0100"; try { var httpRequest = http.createHttp(); httpRequest.on("dataEnd", dataEnd_on_callback); - httpRequest.request2(Address_Baidu).then(function (data) { + httpRequest.requestInStream(Address_Baidu).then(function (data) { httpRequest.off("dataEnd", dataEnd_on_callback); console.log(CaseName + " off dataEnd Finish "); expect(data == 200).assertTrue(); @@ -362,16 +362,16 @@ export default function HttpRequest2JsunitTest() { /** - * @tc.number SUB_Telephony_NetStack_HttpRequest2_off_dataEnd_0200 - * @tc.name httprequest2::off_dataEnd + * @tc.number SUB_Telephony_NetStack_HttprequestInStream_off_dataEnd_0200 + * @tc.name httprequestInStream::off_dataEnd * @tc.desc Test off(type: "dataEnd"): void;. */ - it("SUB_Telephony_NetStack_HttpRequest2_off_dataEnd_0200", 0, function (done) { - let CaseName = "SUB_Telephony_NetStack_HttpRequest2_off_dataEnd_0200"; + it("SUB_Telephony_NetStack_HttprequestInStream_off_dataEnd_0200", 0, function (done) { + let CaseName = "SUB_Telephony_NetStack_HttprequestInStream_off_dataEnd_0200"; try { var httpRequest = http.createHttp(); httpRequest.on("dataEnd", dataEnd_on_callback); - httpRequest.request2(Address_Baidu).then(function (data) { + httpRequest.requestInStream(Address_Baidu).then(function (data) { httpRequest.off("dataEnd"); console.log(CaseName + " off dataEnd Finish "); expect(data == 200).assertTrue();