diff --git a/miscservices/InputMethodTest_ets/entry/src/main/ets/MainAbility/test/RequestDownloadTaskJsunit.test.ets b/miscservices/InputMethodTest_ets/entry/src/main/ets/MainAbility/test/RequestDownloadTaskJsunit.test.ets index 6b9f4278d410e3696510e2b13dde2a2dcb38f825..5c6b25be9dcd8141187212be692428a6f53f9e56 100644 --- a/miscservices/InputMethodTest_ets/entry/src/main/ets/MainAbility/test/RequestDownloadTaskJsunit.test.ets +++ b/miscservices/InputMethodTest_ets/entry/src/main/ets/MainAbility/test/RequestDownloadTaskJsunit.test.ets @@ -335,5 +335,177 @@ export default function requestDownloadJsunit() { done(); }); + /** + * @tc.number requestDownload_test_015 + * @tc.name Test The request DownloadTask + * @tc.desc Function test + */ + it('requestDownload_test_015', 0, async function (done) { + try { + request.download(downloadConfig, (downloadTask) => { + console.log("downloadConfig result:" + JSON.stringify(downloadTask)) + downloadTask.remove().then((result) => { + console.info('requestDownload_test_015 Download task removed result=' + result); + expect(true).assertTrue(); + }).catch ((err) => { + console.log("requestDownload_test_015 downloadTask remove err:" + err); + expect(true).assertTrue(); + }); + }); + } catch (exception) { + console.log("requestDownload_test_015 failed due to execute timeout 5s"); + expect(true).assertTrue(); + } + done(); + }); + + /** + * @tc.number requestDownload_test_016 + * @tc.name Test The request DownloadTask + * @tc.desc Function test + */ + it('requestDownload_test_016', 0, async function (done) { + try { + request.download(downloadConfig, (downloadTask) => { + console.log("downloadConfig result:" + JSON.stringify(downloadTask)) + downloadTask.query().then((downloadInfo) => { + console.info('requestDownload_test_016 Data:' + JSON.stringify(downloadInfo)); + expect(true).assertTrue(); + }) .catch((err) => { + console.log("downloadTask query err:" + err); + expect(true).assertTrue(); + }); + }); + } catch (err) { + console.log("requestDownload_test_016 invoke download error : " + JSON.stringify(err)); + expect(true).assertTrue(); + } + done(); + }); + + /** + * @tc.number requestDownload_test_017 + * @tc.name Test The request DownloadTask + * @tc.desc Function test + */ + it('requestDownload_test_017', 0, async function (done) { + try { + request.download(downloadConfig, (downloadTask) => { + console.log("downloadConfig result:" + JSON.stringify(downloadTask)) + downloadTask.queryMimeType().then((data) => { + console.info('requestDownload_test_017. Data:' + JSON.stringify(data)); + expect(true).assertTrue(); + }).catch((err) => { + console.log("downloadTask queryMimeType err:" + err); + expect(true).assertTrue(); + }); + }); + } catch (exception) { + console.log("requestDownload_test_017 failed due to execute timeout 5s"); + expect(true).assertTrue(); + } + done(); + }); + + /** + * @tc.number requestDownload_test_018 + * @tc.name Test The request DownloadTask + * @tc.desc Function test + */ + it('requestDownload_test_018', 0, async function (done) { + try { + request.download(downloadConfig, (downloadTask) => { + console.log("downloadConfig result:" + JSON.stringify(downloadTask)) + downloadTask.pause().then((data) => { + console.info('requestDownload_test_018. Data:' + JSON.stringify(data)); + expect(true).assertTrue(); + }).catch((err) => { + console.log("requestDownload_test_018 err:" + err); + expect(true).assertTrue(); + }); + }); + } catch (exception) { + console.log("requestDownload_test_018 failed due to execute timeout 5s"); + expect(true).assertTrue(); + } + done(); + }); + + /** + * @tc.number requestDownload_test_019 + * @tc.name Test The request DownloadTask + * @tc.desc Function test + */ + it('requestDownload_test_019', 0, async function (done) { + try { + request.download(downloadConfig, (downloadTask) => { + console.log("downloadConfig result:" + JSON.stringify(downloadTask)) + downloadTask.pause((err, result)=>{ + if(err) { + console.error('requestDownload_test_019 error:' + JSON.stringify(err)); + expect(true).assertTrue(); + } else { + console.info('requestDownload_test_019. result:' + JSON.stringify(result)); + expect(true).assertTrue(); + } + }); + }); + } catch (exception) { + console.log("requestDownload_test_019 failed due to execute timeout 5s"); + expect(true).assertTrue(); + } + done(); + }); + + /** + * @tc.number requestDownload_test_020 + * @tc.name Test The request DownloadTask + * @tc.desc Function test + */ + it('requestDownload_test_020', 0, async function (done) { + try { + request.download(downloadConfig, (downloadTask) => { + console.log("downloadConfig result:" + JSON.stringify(downloadTask)) + downloadTask.resume().then((data) => { + console.info('requestDownload_test_020. Data:' + JSON.stringify(data)); + expect(true).assertTrue(); + }).catch((err) => { + console.log("requestDownload_test_020 err:" + err); + expect(true).assertTrue(); + }); + }); + } catch (exception) { + console.log("requestDownload_test_020 failed due to execute timeout 5s"); + expect(true).assertTrue(); + } + done(); + }); + + /** + * @tc.number requestDownload_test_021 + * @tc.name Test The request DownloadTask + * @tc.desc Function test + */ + it('requestDownload_test_021', 0, async function (done) { + try { + request.download(downloadConfig, (downloadTask) => { + console.log("downloadConfig result:" + JSON.stringify(downloadTask)) + downloadTask.resume((err, result)=>{ + if(err) { + console.error('requestDownload_test_021 error:' + JSON.stringify(err)); + expect(true).assertTrue(); + } else { + console.info('requestDownload_test_021. result:' + JSON.stringify(result)); + expect(true).assertTrue(); + } + }); + }); + } catch (exception) { + console.log("requestDownload_test_021 failed due to execute timeout 5s"); + expect(true).assertTrue(); + } + done(); + }); + }) -} +} \ No newline at end of file diff --git a/miscservices/InputMethodTest_ets/entry/src/main/ets/MainAbility/test/RequestJsunit.test.ets b/miscservices/InputMethodTest_ets/entry/src/main/ets/MainAbility/test/RequestJsunit.test.ets index 58cf8b8d786b91acd1e34a0d9b8eb66298303899..5f479d050fe2bf3709e3109728df07eeac0d7fd5 100644 --- a/miscservices/InputMethodTest_ets/entry/src/main/ets/MainAbility/test/RequestJsunit.test.ets +++ b/miscservices/InputMethodTest_ets/entry/src/main/ets/MainAbility/test/RequestJsunit.test.ets @@ -196,7 +196,44 @@ export default function requestJsunit() { console.log("-----------------------request_upload_0006 end-----------------------"); done(); }) - }) + }); + + /** + * @tc.name: ohos.request_request_upload_0007 + * @tc.desc: request_upload Method detection + */ + it('request_upload_0007', 0, async function (done) { + console.log("-----------------------request_upload_0007 is starting-----------------------"); + try { + console.log("request_upload_0007 getUploadConfig() " + getUploadConfig()); + request.upload(getUploadConfig(), (err, uploadTask) => { + if (err) { + expect().assertFail(); + } else { + console.log("request_upload_0007 progress uploadTask =" + JSON.stringify(uploadTask)); + uploadTask.on('headerReceive', function (data1, data2) { + console.log("request_upload_0007 headerReceive on data1 =" + data1); + console.log("request_upload_0007 headerReceive on data2 =" + data2); + }) + uploadTask.off('headerReceive', function (data1, data2) { + console.log("request_upload_0007 headerReceive off data1 =" + data1); + console.log("request_upload_0007 headerReceive off data2 =" + data2); + }) + uploadTask.remove().then((result) => { + console.log("request_upload_0006 remove =" + result); + }).catch((err) => { + console.error('Failed to remove the upload task. Cause: ' + JSON.stringify(err)); + }); + } + }) + } catch (err) { + expect(true).assertEqual(true); + console.error("request_upload_0007 error: " + err); + } + console.log("-----------------------request_upload_0007 end-----------------------"); + done(); + }) + }); function getUploadConfig() { let file = { diff --git a/telephony/telephonyjstest/netmanager_http/entry/src/main/ets/MainAbility/test/HttpRequestJsunit.test.ets b/telephony/telephonyjstest/netmanager_http/entry/src/main/ets/MainAbility/test/HttpRequestJsunit.test.ets index 9206a966e37720ada0a50ca7a614451365d48e2e..08904c4a18d20514fe306cb324037a5e2032fed4 100644 --- a/telephony/telephonyjstest/netmanager_http/entry/src/main/ets/MainAbility/test/HttpRequestJsunit.test.ets +++ b/telephony/telephonyjstest/netmanager_http/entry/src/main/ets/MainAbility/test/HttpRequestJsunit.test.ets @@ -270,6 +270,58 @@ export default function httpRequestJsunit() { } }); + /** + * @tc.number Telephony_http_HttpRequest_off_headersReceive_0200 + * @tc.name httprequest::off_headersReceive + * @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); + done(); + } + }); + + /** + * @tc.number Telephony_http_HttpRequest_once_headersReceive_0100 + * @tc.name httprequest::once_headersReceive + * @tc.desc Test Test httprequest property. + */ + it("Telephony_http_HttpRequest_once_headersReceive_0100", 0, function (done) { + var casename = "Telephony_http_HttpRequest_once_headersReceive_0100" + 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(); + }); + + } catch (error) { + console.log("Telephony_http_HttpRequest_once_headersReceive_010 : error = " + error); + done(); + } + }); }) diff --git a/telephony/telephonyjstest/netmanager_socket/entry/src/main/ets/MainAbility/test/ConnectionSecondJsUnit.test.ets b/telephony/telephonyjstest/netmanager_socket/entry/src/main/ets/MainAbility/test/ConnectionSecondJsUnit.test.ets index 79976f3360b4f0a18cfc71f1f5b5aedc98a6593f..94072906d7feedb91c7067a98d7dc166d8554049 100644 --- a/telephony/telephonyjstest/netmanager_socket/entry/src/main/ets/MainAbility/test/ConnectionSecondJsUnit.test.ets +++ b/telephony/telephonyjstest/netmanager_socket/entry/src/main/ets/MainAbility/test/ConnectionSecondJsUnit.test.ets @@ -113,6 +113,47 @@ export default function connectionSecondJsUnit() { done(); }); + /** + * @tc.name: 'Telephony_connection_getConnectionProperties_Promise_0200 + * @tc.desc: getConnectionProperties detection + */ + it('Telephony_connection_getConnectionProperties_Promise_0200', 0, function (done) { + console.log("----------Telephony_connection_getConnectionProperties_Promise_0200 Test is starting------"); + if(false){ + expect(true).assertTrue(); + done(); + return; + } + let caseName = 'Telephony_connection_getConnectionProperties_Promise_0200'; + connection.getAllNets((error, data) => { + if (error) { + console.log(`${caseName} get data fail: ${error}`); + expect().assertTrue(); + done(); + } else { + console.log(`${caseName} get netID value : ${JSON.stringify(data[0])}`); + connection.getConnectionProperties(data[0]).then((value) => { + console.log(`${caseName} get value success: ${JSON.stringify(value)}`); + console.log(caseName + " ifaceName: " + value.ifaceName); + console.log(caseName + " mtu: " + value.mtu); + console.log(caseName + " netAddrList.length: " + value.netAddrList.length); + expect(value.ifaceName == "").assertTrue(); + expect(value.domain == "").assertTrue(); + expect(value.mtu == 0).assertTrue(); + expect(value.netAddrList.length == 0).assertTrue(); + expect(value.dnsList.length == 0).assertTrue(); + expect(value.routeList.length == 0).assertTrue(); + done(); + }).catch((error) => { + console.log(`${caseName} getConnectionProperties fail: ${error}`); + expect().assertFail(); + done(); + }); + } + console.log("-----------------------Telephony getConnectionProperties Test end-----------------------"); + done(); + }); + /** * @tc.name: Telephony_connection_RouteInfo_0300 * @tc.desc: RouteInfo Properties detection