From eaf384d5dbeaecf957ce2a1a75443e162216c527 Mon Sep 17 00:00:00 2001 From: zhangfuzhi Date: Wed, 22 Feb 2023 15:18:14 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=8E=A5=E5=8F=A3=EF=BC=8C?= =?UTF-8?q?=E8=A1=A5=E5=85=85=E6=8E=A5=E5=8F=A3=E8=A6=86=E7=9B=96=E7=8E=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhangfuzhi --- .../test/HttpRequestOptionsJsunit.test.ets | 62 ++++++++++++++++ .../main/ets/test/ConnectionJsunit.test.ets | 71 +++++++++++++++++++ .../ets/test/NetworkManagerSocket.test.ets | 4 +- .../main/js/test/NetworkSearchErrors.test.js | 2 + .../main/ets/test/RadioSecondJsunit.test.ets | 1 + .../src/main/js/test/SimManager.test.js | 4 +- 6 files changed, 140 insertions(+), 4 deletions(-) diff --git a/telephony/telephonyjstest/netmanager_http/entry/src/main/ets/test/HttpRequestOptionsJsunit.test.ets b/telephony/telephonyjstest/netmanager_http/entry/src/main/ets/test/HttpRequestOptionsJsunit.test.ets index fff6880a9..5e92c8fce 100644 --- a/telephony/telephonyjstest/netmanager_http/entry/src/main/ets/test/HttpRequestOptionsJsunit.test.ets +++ b/telephony/telephonyjstest/netmanager_http/entry/src/main/ets/test/HttpRequestOptionsJsunit.test.ets @@ -464,6 +464,68 @@ export default function HttpRequestOptionsJsunit() { } }); + /** + * @tc.number Telephony_Http_HttpRequestOptions_UsingProxy_0100 + * @tc.name Telephony_Http_HttpRequestOptions_UsingProxy_0100 + * @tc.desc Telephony_Http_HttpRequestOptions_UsingProxy_0100 + */ + it("Telephony_Http_HttpRequestOptions_UsingProxy_0100", 0, async function (done) { + let httpRequest = http.createHttp(); + httpRequest.request( + "https://www.baidu.com/", + { + connectTimeout: 60000, + readTimeout: 60000, + usingProxy: true, + }, (err, data) => { + if (!err) { + console.info('Telephony_Http_HttpRequestOptions_UsingProxy_0100 code:' + data.responseCode); + expect(data.responseCode == http.ResponseCode.OK).assertTrue(); + done(); + } else { + console.info('Telephony_Http_HttpRequestOptions_UsingProxy_0100 error:' + JSON.stringify(err)); + httpRequest.destroy(); + expect(true).assertFalse(); + done(); + } + } + ); + }); + + /** + * @tc.number Telephony_Http_HttpRequestOptions_UsingProxy_0200 + * @tc.name Telephony_Http_HttpRequestOptions_UsingProxy_0200 + * @tc.desc Telephony_Http_HttpRequestOptions_UsingProxy_0200 + */ + it("Telephony_Http_HttpRequestOptions_UsingProxy_0200", 0, async function (done) { + let httpRequest = http.createHttp(); + let ExclusionList = "" + let array = ExclusionList.split(','); + let httpProxy = { + host: "host", + port: 1, + exclusionList: array + } + httpRequest.request( + "https://www.baidu.com/", + { + connectTimeout: 60000, + readTimeout: 60000, + usingProxy: httpProxy, + }, (err, data) => { + if (!err) { + console.info('Telephony_Http_HttpRequestOptions_UsingProxy_0200 code:' + data.responseCode); + expect(true).assertFalse(); + done(); + } else { + console.info('Telephony_Http_HttpRequestOptions_UsingProxy_0200 error:' + JSON.stringify(err)); + httpRequest.destroy(); + expect(err.code == 2300005).assertTrue(); + done(); + } + } + ); + }); }) }; diff --git a/telephony/telephonyjstest/netmanager_socket/entry/src/main/ets/test/ConnectionJsunit.test.ets b/telephony/telephonyjstest/netmanager_socket/entry/src/main/ets/test/ConnectionJsunit.test.ets index a34a1dd8c..9d1e1df4b 100644 --- a/telephony/telephonyjstest/netmanager_socket/entry/src/main/ets/test/ConnectionJsunit.test.ets +++ b/telephony/telephonyjstest/netmanager_socket/entry/src/main/ets/test/ConnectionJsunit.test.ets @@ -1294,6 +1294,77 @@ export default function connectionJsunit() { done(); }); + + /* + * @tc.number : Telephony_Connection_setAppNet_callback_0100 + * @tc.name : Telephony_Connection_setAppNet_callback_0100 + * @tc.desc : Telephony_Connection_setAppNet_callback_0100 + */ + it('Telephony_Connection_setAppNet_callback_0100', 0, function (done) { + connection.getDefaultNet(function (error, netHandle) { + if (error) { + console.log("getDefaultNet error " + JSON.stringify(error)); + expect(true).assertFalse(); + done(); + return; + } + console.log("getDefaultNet success " + JSON.stringify(netHandle)); + connection.setAppNet(netHandle, (error, data) => { + if (error) { + console.log("setAppNet error " + JSON.stringify(error)); + expect(true).assertFalse(); + done(); + return; + } + console.log("setAppNet success " + JSON.stringify(data)); + connection.getAppNet(function (error, data) { + if (error) { + console.log("getAppNet error " + JSON.stringify(error)); + expect(true).assertFalse(); + done(); + return; + } + console.log("getAppNet success " + JSON.stringify(data)); + expect(netHandle.netId == data.netId).assertTrue(); + done(); + }) + }); + }) + }); + + /* + * @tc.number : Telephony_Connection_setAppNet_promise_0100 + * @tc.name : Telephony_Connection_setAppNet_promise_0100 + * @tc.desc : Telephony_Connection_setAppNet_promise_0100 + */ + it('Telephony_Connection_setAppNet_promise_0100', 0, function (done) { + connection.getDefaultNet(function (error, netHandle) { + if (error) { + console.log("getDefaultNet error " + JSON.stringify(error)); + expect(true).assertFalse(); + done(); + return; + } + console.log("getDefaultNet success " + JSON.stringify(netHandle)); + connection.setAppNet(netHandle).then((data) => { + console.log("setAppNet success " + JSON.stringify(data)); + connection.getAppNet().then((data) => { + console.log("getAppNet success " + JSON.stringify(data)); + expect(netHandle.netId == data.netId).assertTrue(); + done(); + }).catch(error => { + console.log("getAppNet error " + JSON.stringify(error)); + expect(true).assertFalse(); + done(); + }) + }).catch(error => { + console.log("setAppNet error " + JSON.stringify(error)); + expect(true).assertFalse(); + done(); + }) + }) + }); + console.log("************* connection Test end*************"); }) } diff --git a/telephony/telephonyjstest/netmanager_socket/entry/src/main/ets/test/NetworkManagerSocket.test.ets b/telephony/telephonyjstest/netmanager_socket/entry/src/main/ets/test/NetworkManagerSocket.test.ets index 5c0b0a0f4..e4779aa71 100644 --- a/telephony/telephonyjstest/netmanager_socket/entry/src/main/ets/test/NetworkManagerSocket.test.ets +++ b/telephony/telephonyjstest/netmanager_socket/entry/src/main/ets/test/NetworkManagerSocket.test.ets @@ -30,7 +30,7 @@ let options = { key: "key", cert: "cert", ca: ["ca"], - passwd: "123456", + password: "123456", protocols: [socket.Protocol.TLSv12, socket.Protocol.TLSv13], useRemoteCipherPrefer: true, signatureAlgorithms: "rsa_pss_rsae_sha256:ECDSA+SHA256", @@ -82,7 +82,7 @@ export default function networkManagerSocketTest() { expect(options.secureOptions.key != undefined).assertEqual(true); expect(options.secureOptions.cert != undefined).assertEqual(true); expect(options.secureOptions.ca != undefined).assertEqual(true); - expect(options.secureOptions.passwd != undefined).assertEqual(true); + expect(options.secureOptions.password != undefined).assertEqual(true); expect(options.secureOptions.protocols != undefined).assertEqual(true); expect(options.secureOptions.protocols[0] == "TLSv1.2").assertEqual(true); expect(options.secureOptions.protocols[1] == "TLSv1.3").assertEqual(true); diff --git a/telephony/telephonyjstest/network_search/network_search_errors/src/main/js/test/NetworkSearchErrors.test.js b/telephony/telephonyjstest/network_search/network_search_errors/src/main/js/test/NetworkSearchErrors.test.js index 03a24e13c..5a53ff480 100644 --- a/telephony/telephonyjstest/network_search/network_search_errors/src/main/js/test/NetworkSearchErrors.test.js +++ b/telephony/telephonyjstest/network_search/network_search_errors/src/main/js/test/NetworkSearchErrors.test.js @@ -397,6 +397,7 @@ describe('ActsNetworkSearchTest', function () { it('Telephony_NetworkSearch_isRadioOn_Promise_0200', 0, async function (done) { try { await radio.isRadioOn(); + done(); } catch (err) { console.error('When the device has no modem, the interface reports an error' + JSON.stringify(err)); expect(err.code).assertEqual(8300000); @@ -432,6 +433,7 @@ describe('ActsNetworkSearchTest', function () { try { let data = await radio.isRadioOn(0); console.info('Telephony_NetworkSearch_isRadioOn_Promise_0300 finish ' + JSON.stringify(data)); + done(); } catch (err) { console.error('When the device has no modem, the interface reports an error' + JSON.stringify(err)); expect(err.code).assertEqual(8300000); diff --git a/telephony/telephonyjstest/radiostatistic/entry/src/main/ets/test/RadioSecondJsunit.test.ets b/telephony/telephonyjstest/radiostatistic/entry/src/main/ets/test/RadioSecondJsunit.test.ets index 7dd043e14..b145e0ca9 100644 --- a/telephony/telephonyjstest/radiostatistic/entry/src/main/ets/test/RadioSecondJsunit.test.ets +++ b/telephony/telephonyjstest/radiostatistic/entry/src/main/ets/test/RadioSecondJsunit.test.ets @@ -315,6 +315,7 @@ export default function radioSecondJsunit() { expect(data[i].timeStamp).assertLarger(0); expect(NETWORK_TYPES).assertContain(data[i].signalInformation.signalType); expect(NETWORK_SIGNAL).assertContain(data[i].signalInformation.signalLevel); + expect(NETWORK_SIGNAL).assertContain(data[i].signalInformation.dBm); expect(data[i].data != undefined && data[i].data != '' && data[i].data != null).assertTrue(); if (data[i].networkType === radio.NetworkType.NETWORK_TYPE_LTE) { console.log("radio.NetworkType.NETWORK_TYPE_LTE:" + radio.NetworkType.NETWORK_TYPE_LTE); diff --git a/telephony/telephonyjstest/sim/sim_manager_function_test/src/main/js/test/SimManager.test.js b/telephony/telephonyjstest/sim/sim_manager_function_test/src/main/js/test/SimManager.test.js index 0d3e63b8a..b9391aec2 100644 --- a/telephony/telephonyjstest/sim/sim_manager_function_test/src/main/js/test/SimManager.test.js +++ b/telephony/telephonyjstest/sim/sim_manager_function_test/src/main/js/test/SimManager.test.js @@ -270,7 +270,7 @@ describe('SimManagerTest', function () { it('Telephony_Sim_isSimActive_Async_0700', 0, async function (done) { sim.isSimActive(env.SLOTID2, (err, data) => { console.info("isSimActive async err info :" + JSON.stringify(err) + "data:" + JSON.stringify(data)); - expect(err.code).assertEqual(202); + expect(err.code).assertEqual(8300001); done(); }); }); @@ -289,7 +289,7 @@ describe('SimManagerTest', function () { done(); }).catch(err => { console.info("isSimActive promise err info :" + JSON.stringify(err)); - expect(err.code).assertEqual(202); + expect(err.code).assertEqual(8300001); done(); }); }); -- GitLab