From 48dd9da46983253fa7f641a4fab61d9660a17b8c Mon Sep 17 00:00:00 2001 From: gaoxi Date: Sat, 25 Jun 2022 17:23:15 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E7=94=B5=E8=AF=9D=E7=94=A8?= =?UTF-8?q?=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: gaoxi --- .../ets/test/RequestMethodJsunit.test.ets | 218 +++++++++++++++++- .../main/ets/test/ResponseCodeJsunit.test.ets | 50 ++++ .../ets/test/ConnectionSecondJsUnit.test.ets | 16 ++ .../src/main/ets/test/SocketJsunit.test.ets | 2 +- .../main/js/test/NetworkSearchErrors.test.js | 2 + .../MainAbility/test/ObserverJsunit.test.ets | 72 +++++- 6 files changed, 347 insertions(+), 13 deletions(-) diff --git a/telephony/telephonyjstest/netmanager_http/entry/src/main/ets/test/RequestMethodJsunit.test.ets b/telephony/telephonyjstest/netmanager_http/entry/src/main/ets/test/RequestMethodJsunit.test.ets index 9c47f1c2e..b61d8d1c9 100644 --- a/telephony/telephonyjstest/netmanager_http/entry/src/main/ets/test/RequestMethodJsunit.test.ets +++ b/telephony/telephonyjstest/netmanager_http/entry/src/main/ets/test/RequestMethodJsunit.test.ets @@ -377,8 +377,6 @@ export default function requestMethodJsunit() { } }); - - /** * @tc.number Telephony_http_HttpRequestMethod_PUT_0200 * @tc.name HttpRequestMethod::PUT @@ -417,6 +415,222 @@ export default function requestMethodJsunit() { } }); + /** + * @tc.number Telephony_http_HttpRequestMethod_head_0100 + * @tc.name HttpRequestMethod::HEAD + * @tc.desc Test Test HttpRequestMethod property. + */ + + it("Telephony_http_HttpRequestMethod_head_0100", 0, async function (done) { + var casename = 'Telephony_http_HttpRequestMethod_0600'; + console.log("-----------------------HttpRequestMethod_head Test is starting-----------------------"); + try { + let httpRequestOptions = { + method: "HEAD", + extraData: null, + header: "content-type': 'application/json", + readTimeout: 60, + connectTimeout: 60 + } + 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.getResponseCode = 200).assertTrue(); + console.log("-----------------------HttpRequestMethod_head Test end-----------------------"); + done(); + }); + } catch (error) { + console.log("Telephony_Http_HttpRequestMethod_head_0100 : error = " + error); + done(); + } + }); + + /** + * @tc.number Telephony_http_HttpRequestMethod_HEAD_0200 + * @tc.name HttpRequestMethod::HEAD + * @tc.desc Test Test HttpRequestMethod property. + */ + it("Telephony_http_HttpRequestMethod_HEAD_0200", 0, async function (done) { + var casename = "Telephony_http_HttpRequestMethod_0500" + console.log("-----------------------HttpRequestMethod_HEAD_01 Test is starting-----------------------"); + try { + let httpRequestOptions = { + method: "HEAD", + extraData: null, + header: "content-type': 'application/json", + readTimeout: 60, + connectTimeout: 60 + } + 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.getResponseCode = 200).assertTrue(); + console.log("-----------------------HttpRequestMethod_HEAD_01 Test end-----------------------"); + done(); + }).catch(error => { + console.info(casename+"errocode" + JSON.stringify(error)); + done(); + }); + } catch (error) { + console.log("Telephony_http_HttpRequestMethod_HEAD_0200 : error = " + error); + done(); + } + }); + + /** + * @tc.number Telephony_http_HttpRequestMethod_DELETE_0100 + * @tc.name HttpRequestMethod::DELETE + * @tc.desc Test Test HttpRequestMethod property. + */ + + it("Telephony_http_HttpRequestMethod_DELETE_0100", 0, async function (done) { + var casename = 'Telephony_http_HttpRequestMethod_0600'; + console.log("-----------------------HttpRequestMethod_DELETE Test is starting-----------------------"); + try { + let httpRequestOptions = { + method: "DELETE", + extraData: null, + header: "content-type': 'application/json", + readTimeout: 60, + connectTimeout: 60 + } + 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.getResponseCode = 200).assertTrue(); + console.log("-----------------------HttpRequestMethod_DELETE Test end-----------------------"); + done(); + }); + } catch (error) { + console.log("Telephony_Http_HttpRequestMethod_DELETE_0100 : error = " + error); + done(); + } + }); + + /** + * @tc.number Telephony_http_HttpRequestMethod_DELETE_0200 + * @tc.name HttpRequestMethod::DELETE + * @tc.desc Test Test HttpRequestMethod property. + */ + it("Telephony_http_HttpRequestMethod_DELETE_0200", 0, async function (done) { + var casename = "Telephony_http_HttpRequestMethod_0500" + console.log("-----------------------HttpRequestMethod_DELETE_01 Test is starting-----------------------"); + try { + let httpRequestOptions = { + method: "DELETE", + extraData: null, + header: "content-type': 'application/json", + readTimeout: 60, + connectTimeout: 60 + } + 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.getResponseCode = 200).assertTrue(); + console.log("-----------------------HttpRequestMethod_DELETE_01 Test end-----------------------"); + done(); + }).catch(error => { + console.info(casename+"errocode" + JSON.stringify(error)); + done(); + }); + } catch (error) { + console.log("Telephony_http_HttpRequestMethod_DELETE_0200 : error = " + error); + done(); + } + }); + + /** + * @tc.number Telephony_http_HttpRequestMethod_CONNECT_0100 + * @tc.name HttpRequestMethod::CONNECT + * @tc.desc Test Test HttpRequestMethod property. + */ + + it("Telephony_http_HttpRequestMethod_CONNECT_0100", 0, async function (done) { + var casename = 'Telephony_http_HttpRequestMethod_0600'; + console.log("-----------------------HttpRequestMethod_CONNECT Test is starting-----------------------"); + try { + let httpRequestOptions = { + method: "CONNECT", + extraData: null, + header: "content-type': 'application/json", + readTimeout: 60, + connectTimeout: 60 + } + 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.getResponseCode = 200).assertTrue(); + console.log("-----------------------HttpRequestMethod_CONNECT Test end-----------------------"); + done(); + }); + } catch (error) { + console.log("Telephony_Http_HttpRequestMethod_CONNECT_0100 : error = " + error); + done(); + } + }); + + /** + * @tc.number Telephony_http_HttpRequestMethod_CONNECT_0200 + * @tc.name HttpRequestMethod::CONNECT + * @tc.desc Test Test HttpRequestMethod property. + */ + it("Telephony_http_HttpRequestMethod_CONNECT_0200", 0, async function (done) { + var casename = "Telephony_http_HttpRequestMethod_0500" + console.log("-----------------------HttpRequestMethod_CONNECT_01 Test is starting-----------------------"); + try { + let httpRequestOptions = { + method: "CONNECT", + extraData: null, + header: "content-type': 'application/json", + readTimeout: 60, + connectTimeout: 60 + } + 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.getResponseCode = 200).assertTrue(); + console.log("-----------------------HttpRequestMethod_CONNECT_01 Test end-----------------------"); + done(); + }).catch(error => { + console.info(casename+"errocode" + JSON.stringify(error)); + done(); + }); + } catch (error) { + console.log("Telephony_http_HttpRequestMethod_CONNECT_0200 : error = " + error); + done(); + } + }); + }) }; diff --git a/telephony/telephonyjstest/netmanager_http/entry/src/main/ets/test/ResponseCodeJsunit.test.ets b/telephony/telephonyjstest/netmanager_http/entry/src/main/ets/test/ResponseCodeJsunit.test.ets index 4d75cdb78..309042fbe 100644 --- a/telephony/telephonyjstest/netmanager_http/entry/src/main/ets/test/ResponseCodeJsunit.test.ets +++ b/telephony/telephonyjstest/netmanager_http/entry/src/main/ets/test/ResponseCodeJsunit.test.ets @@ -467,6 +467,23 @@ export default function responseCodeJsunit() { } }); + /** + * @tc.number Telephony_Http_ResponseCode_VERSION_0100 + * @tc.name ResponseCode::VERSION + * @tc.desc Test Test ResponseCode property. + */ + + it("Telephony_Http_ResponseCode_VERSION_0100", 0, async function (done) { + console.log("-----------------------ResponseCode VERSION Test is starting-----------------------"); + try { + expect(505).assertEqual(http.ResponseCode.VERSION); + console.log("-----------------------ResponseCode VERSION Test end-----------------------"); + done(); + } catch (error) { + console.log("Telephony_Http_ResponseCode_VERSION_0100 : error = " + error); + done(); + } + }); /** * @tc.number Telephony_Http_ResponseCode_CREATED_0100 @@ -486,6 +503,22 @@ export default function responseCodeJsunit() { } }); + /** + * @tc.number Telephony_Http_ResponseCode_RESET_0100 + * @tc.name ResponseCode::RESET + * @tc.desc Test Test ResponseCode property. + */ + it("Telephony_Http_ResponseCode_RESET_0100", 0, async function (done) { + console.log("-----------------------ResponseCode RESET Test is starting-----------------------"); + try { + expect(205).assertEqual(http.ResponseCode.RESET); + console.log("-----------------------ResponseCode RESET Test end-----------------------"); + done(); + } catch (error) { + console.log("Telephony_Http_ResponseCode_RESET_0100 : error = " + error); + done(); + } + }); /** * @tc.number Telephony_Http_ResponseCode_PARTIAL_0100 @@ -524,6 +557,23 @@ export default function responseCodeJsunit() { } }); + /** + * @tc.number Telephony_Http_ResponseCode_FORBIDDEN_0100 + * @tc.name ResponseCode::FORBIDDEN + * @tc.desc Test Test ResponseCode property. + */ + + it("Telephony_Http_ResponseCode_FORBIDDEN_0100", 0, async function (done) { + console.log("-----------------------ResponseCode FORBIDDEN Test is starting-----------------------"); + try { + expect(403).assertEqual(http.ResponseCode.FORBIDDEN); + console.log("-----------------------ResponseCode FORBIDDEN Test end-----------------------"); + done(); + } catch (error) { + console.log("Telephony_Http_ResponseCode_FORBIDDEN_0100 : error = " + error); + done(); + } + }); /** * @tc.number Telephony_Http_ResponseCode_NOT_FOUND_0100 diff --git a/telephony/telephonyjstest/netmanager_socket/entry/src/main/ets/test/ConnectionSecondJsUnit.test.ets b/telephony/telephonyjstest/netmanager_socket/entry/src/main/ets/test/ConnectionSecondJsUnit.test.ets index e7eef78c5..56db29fc6 100644 --- a/telephony/telephonyjstest/netmanager_socket/entry/src/main/ets/test/ConnectionSecondJsUnit.test.ets +++ b/telephony/telephonyjstest/netmanager_socket/entry/src/main/ets/test/ConnectionSecondJsUnit.test.ets @@ -121,6 +121,19 @@ export default function connectionSecondJsUnit() { it("Telephony_connection_RouteInfo_0300", 0, function (done) { console.log("----------------------RouteInfo Properties Test is starting-----------------------"); try { + let resultInterface = { + interface: '123' + }; + let resultDestination = { + destination: { + address: "192.168.1.2" + } + }; + let resultGateway = { + gateway: { + address: "192.168.1.3" + } + }; let resultDefaultRoute = { isDefaultRoute: true }; @@ -129,6 +142,9 @@ export default function connectionSecondJsUnit() { }; expect(true).assertEqual(resultDefaultRoute.isDefaultRoute); expect(true).assertEqual(resultHasGateway.hasGateway); + expect("123").assertEqual(resultInterface.interface); + expect("192.168.1.2").assertEqual(resultDestination.destination.address); + expect("192.168.1.3").assertEqual(resultGateway.gateway.address); console.log("-----------------------RouteInfo Properties Test end-----------------------"); done(); } catch (err) { diff --git a/telephony/telephonyjstest/netmanager_socket/entry/src/main/ets/test/SocketJsunit.test.ets b/telephony/telephonyjstest/netmanager_socket/entry/src/main/ets/test/SocketJsunit.test.ets index 12b5ccf6b..33c6b4109 100644 --- a/telephony/telephonyjstest/netmanager_socket/entry/src/main/ets/test/SocketJsunit.test.ets +++ b/telephony/telephonyjstest/netmanager_socket/entry/src/main/ets/test/SocketJsunit.test.ets @@ -655,7 +655,7 @@ export default function socketJsunit() { broadcast: true } try{ - udp.setExtraOptions(udpExtraOptions, funtion(error,data) { + udp.setExtraOptions(udpExtraOptions, function(error,data) { if (error) { expect().assertFail(); console.log(`${caseName} error, case failed,error: ` + JSON.stringify(error)); diff --git a/telephony/telephonyjstest/network_search/network_search_errors/entry/src/main/js/test/NetworkSearchErrors.test.js b/telephony/telephonyjstest/network_search/network_search_errors/entry/src/main/js/test/NetworkSearchErrors.test.js index b5f4d9049..8ed985b92 100644 --- a/telephony/telephonyjstest/network_search/network_search_errors/entry/src/main/js/test/NetworkSearchErrors.test.js +++ b/telephony/telephonyjstest/network_search/network_search_errors/entry/src/main/js/test/NetworkSearchErrors.test.js @@ -54,6 +54,7 @@ describe('ActsNetworkSearchTest', function () { afterEach(async function () { try { expect(radio.RADIO_TECHNOLOGY_UNKNOWN === 0).assertTrue(); + expect(radio.RADIO_TECHNOLOGY_GSM === 1).assertTrue(); expect(radio.RADIO_TECHNOLOGY_1XRTT === 2).assertTrue(); expect(radio.RADIO_TECHNOLOGY_WCDMA === 3).assertTrue(); expect(radio.RADIO_TECHNOLOGY_HSPA === 4).assertTrue(); @@ -117,6 +118,7 @@ describe('ActsNetworkSearchTest', function () { expect(data.regState != radio.REG_STATE_IN_SERVICE).assertTrue(); expect(data.nsaState != radio.NSA_STATE_SA_ATTACHED).assertTrue(); expect(data.isCaActive != true).assertTrue(); + expect(data.isEmergency != true).assertTrue(); expect().assertFail(); done(); }); diff --git a/telephony/telephonyjstest/observer/entry/src/main/ets/MainAbility/test/ObserverJsunit.test.ets b/telephony/telephonyjstest/observer/entry/src/main/ets/MainAbility/test/ObserverJsunit.test.ets index 6261c3259..8fa572389 100644 --- a/telephony/telephonyjstest/observer/entry/src/main/ets/MainAbility/test/ObserverJsunit.test.ets +++ b/telephony/telephonyjstest/observer/entry/src/main/ets/MainAbility/test/ObserverJsunit.test.ets @@ -36,6 +36,11 @@ export default function observerJsunit() { * @tc.desc : check the getCellularDataState callback to verify the call back data */ it('Telephony_observer_observer_DataConnectState_0100', 0, function (done) { + expect(observer.NetworkState == radio.NetworkState).assertTrue(); + expect(observer.SignalInformation == radio.SignalInformation).assertTrue(); + expect(observer.CellInformation == radio.CellInformation ).assertTrue(); + expect(observer.RatType == radio.RadioTechnology).assertTrue(); + expect(observer.CallState == call.CallState).assertTrue(); console.log("************* Telephony_observer_observer_DataConnectState_0100 Test start *************") cellular.getCellularDataState((err, data) => { if (!err) { @@ -553,11 +558,58 @@ export default function observerJsunit() { expect(true).assertTrue() done() } - // expect(0).assertEqual(LockReason.SIM_NONE) + expect(0).assertEqual(LockReason.SIM_NONE) done() console.log("************* Telephony_observer_LockReason_SIM_NONE_0100 Test end *************") }) + /* + * @tc.number : Telephony_observer_LockReason_SIM_PIN_0100 + * @tc.name : SIM_PIN + * @tc.desc : check the SIM_PIN property of LockReason + */ + it('Telephony_observer_LockReason_SIM_PIN_0100', 0, function (done) { + console.log("************* Telephony_observer_LockReason_SIM_PIN_0100 Test start *************") + if (utils.notCheck) { + expect(true).assertTrue() + done() + } + expect(1).assertEqual(LockReason.SIM_PIN) + done() + console.log("************* Telephony_observer_LockReason_SIM_PIN_0100 Test end *************") + }) + + /* + * @tc.number : Telephony_observer_LockReason_SIM_PUK_0100 + * @tc.name : SIM_PUK + * @tc.desc : check the SIM_PUK property of LockReason + */ + it('Telephony_observer_LockReason_SIM_PUK_0100', 0, function (done) { + console.log("************* Telephony_observer_LockReason_SIM_PUK_0100 Test start *************") + if (utils.notCheck) { + expect(true).assertTrue() + done() + } + expect(2).assertEqual(LockReason.SIM_PUK) + done() + console.log("************* Telephony_observer_LockReason_SIM_PUK_0100 Test end *************") + }) + + /* + * @tc.number : Telephony_observer_LockReason_SIM_PN_PIN_0100 + * @tc.name : SIM_PN_PIN + * @tc.desc : check the SIM_PN_PIN property of LockReason + */ + it('Telephony_observer_LockReason_SIM_PN_PIN_0100', 0, function (done) { + console.log("************* Telephony_observer_LockReason_SIM_PN_PIN_0100 Test start *************") + if (utils.notCheck) { + expect(true).assertTrue() + done() + } + expect(3).assertEqual(LockReason.SIM_PN_PIN) + done() + console.log("************* Telephony_observer_LockReason_SIM_PN_PIN_0100 Test end *************") + }) /* * @tc.number : Telephony_observer_LockReason_SIM_PN_PUK_0100 * @tc.name : SIM_PN_PUK @@ -569,7 +621,7 @@ export default function observerJsunit() { expect(true).assertTrue() done() } - // expect(4).assertEqual(LockReason.SIM_PN_PUK) + expect(4).assertEqual(LockReason.SIM_PN_PUK) done() console.log("************* Telephony_observer_LockReason_SIM_PN_PUK_0100 Test end *************") }) @@ -585,7 +637,7 @@ export default function observerJsunit() { expect(true).assertTrue() done() } - // expect(5).assertEqual(LockReason.SIM_PU_PIN) + expect(5).assertEqual(LockReason.SIM_PU_PIN) done() console.log("************* Telephony_observer_LockReason_SIM_PU_PIN_0100 Test end *************") }) @@ -601,7 +653,7 @@ export default function observerJsunit() { expect(true).assertTrue() done() } - // expect(6).assertEqual(LockReason.SIM_PU_PUK) + expect(6).assertEqual(LockReason.SIM_PU_PUK) done() console.log("************* Telephony_observer_LockReason_SIM_PU_PUK_0100 Test end *************") }) @@ -617,7 +669,7 @@ export default function observerJsunit() { expect(true).assertTrue() done() } - // expect(7).assertEqual(LockReason.SIM_PP_PIN) + expect(7).assertEqual(LockReason.SIM_PP_PIN) done() console.log("************* Telephony_observer_LockReason_SIM_PP_PIN_0100 Test end *************") }) @@ -633,7 +685,7 @@ export default function observerJsunit() { expect(true).assertTrue() done() } - // expect(8).assertEqual(LockReason.SIM_PP_PUK) + expect(8).assertEqual(LockReason.SIM_PP_PUK) done() console.log("************* Telephony_observer_LockReason_SIM_PP_PUK_0100 Test end *************") }) @@ -649,7 +701,7 @@ export default function observerJsunit() { expect(true).assertTrue() done() } - // expect(9).assertEqual(LockReason.SIM_PC_PIN) + expect(9).assertEqual(LockReason.SIM_PC_PIN) done() console.log("************* Telephony_observer_LockReason_SIM_PC_PIN_0100 Test end *************") }) @@ -665,7 +717,7 @@ export default function observerJsunit() { expect(true).assertTrue() done() } - // expect(10).assertEqual(LockReason.SIM_PC_PUK) + expect(10).assertEqual(LockReason.SIM_PC_PUK) done() console.log("************* Telephony_observer_LockReason_SIM_PC_PUK_0100 Test end *************") }) @@ -681,7 +733,7 @@ export default function observerJsunit() { expect(true).assertTrue() done() } - // expect(11).assertEqual(LockReason.SIM_SIM_PIN) + expect(11).assertEqual(LockReason.SIM_SIM_PIN) done() console.log("************* Telephony_observer_LockReason_SIM_SIM_PIN_0100 Test end *************") }) @@ -697,7 +749,7 @@ export default function observerJsunit() { expect(true).assertTrue() done() } - // expect(12).assertEqual(LockReason.SIM_SIM_PUK) + expect(12).assertEqual(LockReason.SIM_SIM_PUK) done() console.log("************* Telephony_observer_LockReason_SIM_SIM_PUK_0100 Test end *************") }) -- GitLab