From 366878756af1a4812a01abf94c7dc9ff3665ac1a Mon Sep 17 00:00:00 2001 From: gaoxi Date: Mon, 13 Jun 2022 17:35:21 +0800 Subject: [PATCH] =?UTF-8?q?netmanager=5Fsocket=E7=94=A8=E4=BE=8B=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: gaoxi --- .../src/main/ets/test/SocketJsunit.test.ets | 391 +++--------------- 1 file changed, 56 insertions(+), 335 deletions(-) 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 0fec9f3f9..12b5ccf6b 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 @@ -387,11 +387,7 @@ export default function socketJsunit() { it('Telephony_Socket_UDPSocket_bind_0200', 0, function (done) { let caseName = "Telephony_Socket_UDPSocket_bind_0200" console.log("************* Telephony_Socket_UDPSocket_bind_0200 Test start*************"); - if (2 === 0) { - expect(true).assertTrue(); - done(); - return; - } + let netAddress: socket.NetAddress = { address: "test address", family: 1, @@ -446,12 +442,7 @@ export default function socketJsunit() { */ it('Telephony_Socket_UDPSocket_bind_0400', 0, function (done) { console.log("************* Telephony_Socket_UDPSocket_bind_0400 Test start*************"); - let caseName = "Telephony_Socket_UDPSocket_bind_0400" - if (2 === 0) { - expect(true).assertTrue(); - done(); - return; - } + let caseName = "Telephony_Socket_UDPSocket_bind_0400" let netAddress = { address: "third test address", family: 3, @@ -475,12 +466,7 @@ export default function socketJsunit() { */ it('Telephony_Socket_UDPSocket_send_0100', 0, function (done) { console.log("************* Telephony_Socket_UDPSocket_send_0100 Test start*************"); - let caseName = "Telephony_Socket_UDPSocket_send_0100" - if (2 === 0) { - expect(true).assertTrue(); - done(); - return; - } + let caseName = "Telephony_Socket_UDPSocket_send_0100" let udpSendOptions = { data: "test data", address: { @@ -510,12 +496,7 @@ export default function socketJsunit() { */ it('Telephony_Socket_UDPSocket_send_0200', 0, function (done) { console.log("************* Telephony_Socket_UDPSocket_send_0200 Test start*************"); - let caseName = "Telephony_Socket_UDPSocket_send_0200" - if (2 === 0) { - expect(true).assertTrue(); - done(); - return; - } + let caseName = "Telephony_Socket_UDPSocket_send_0200" let udpSendOptions = { data: "test data", address: { @@ -540,12 +521,7 @@ export default function socketJsunit() { */ it('Telephony_Socket_UDPSocket_send_0300', 0, function (done) { console.log("************* Telephony_Socket_UDPSocket_send_0300 Test start*************"); - let caseName = "Telephony_Socket_UDPSocket_send_0300" - if (2 === 0) { - expect(true).assertTrue(); - done(); - return; - } + let caseName = "Telephony_Socket_UDPSocket_send_0300" let udpSendOptions = { data: "test data", address: { @@ -573,12 +549,7 @@ export default function socketJsunit() { */ it('Telephony_Socket_UDPSocket_send_0400', 0, function (done) { console.log("************* Telephony_Socket_UDPSocket_send_0400 Test start*************"); - let caseName = "Telephony_Socket_UDPSocket_send_0400" - if (2 === 0) { - expect(true).assertTrue(); - done(); - return; - } + let caseName = "Telephony_Socket_UDPSocket_send_0400" let udpSendOptions = { data: "test data", address: { @@ -601,12 +572,7 @@ export default function socketJsunit() { */ it('Telephony_Socket_UDPSocket_close_0100', 0, function (done) { console.log("************* Telephony_Socket_UDPSocket_close_0100 Test start*************"); - let caseName = "Telephony_Socket_UDPSocket_close_0100" - if (2 === 0) { - expect(true).assertTrue(); - done(); - return; - } + let caseName = "Telephony_Socket_UDPSocket_close_0100" udp.close((error, data) => { if (error) { console.log(`${caseName} error, case success,error:${toString(error)}`); @@ -627,12 +593,7 @@ export default function socketJsunit() { */ it('Telephony_Socket_UDPSocket_close_0200', 0, function (done) { console.log("************* Telephony_Socket_UDPSocket_close_0200 Test start*************"); - let caseName = "Telephony_Socket_UDPSocket_close_0200" - if (2 === 0) { - expect(true).assertTrue(); - done(); - return; - } + let caseName = "Telephony_Socket_UDPSocket_close_0200" udp.close().then(data => { console.log(`${caseName} success,data:${toString(data)}`); }).catch((error) => { @@ -649,12 +610,7 @@ export default function socketJsunit() { */ it('Telephony_Socket_UDPSocket_getState_0100', 0, function (done) { console.log("************* Telephony_Socket_UDPSocket_getState_0100 Test start*************"); - let caseName = "Telephony_Socket_UDPSocket_getState_0100" - if (2 === 0) { - expect(true).assertTrue(); - done(); - return; - } + let caseName = "Telephony_Socket_UDPSocket_getState_0100" udp.getState((error, data) => { if (error) { console.log(`${caseName} error, case success,error:${toString(error)}`); @@ -676,12 +632,7 @@ export default function socketJsunit() { */ it('Telephony_Socket_UDPSocket_getState_0200', 0, function (done) { console.log("************* Telephony_Socket_UDPSocket_getState_0200 Test start*************"); - let caseName = "Telephony_Socket_UDPSocket_getState_0200" - if (2 === 0) { - expect(true).assertTrue(); - done(); - return; - } + let caseName = "Telephony_Socket_UDPSocket_getState_0200" udp.getState().then(data => { console.log(`${caseName} success,data:${toString(data)}`); }).catch((error) => { @@ -699,12 +650,7 @@ export default function socketJsunit() { */ it('Telephony_Socket_UDPSocket_setExtraOptions_0100', 0, function (done) { console.log("************* Telephony_Socket_UDPSocket_setExtraOptions_0100 Test start*************"); - let caseName = "Telephony_Socket_UDPSocket_setExtraOptions_0100" - if (2 === 0) { - expect(true).assertTrue(); - done(); - return; - } + let caseName = "Telephony_Socket_UDPSocket_setExtraOptions_0100" let udpExtraOptions = { broadcast: true } @@ -761,12 +707,7 @@ export default function socketJsunit() { */ it('Telephony_Socket_UDPSocket_setExtraOptions_0300', 0, function (done) { console.log("************* Telephony_Socket_UDPSocket_setExtraOptions_0300 Test start*************"); - let caseName = "Telephony_Socket_UDPSocket_setExtraOptions_0300" - if (2 === 0) { - expect(true).assertTrue(); - done(); - return; - } + let caseName = "Telephony_Socket_UDPSocket_setExtraOptions_0300" let udpExtraOptions = {} udp.setExtraOptions(udpExtraOptions, (error) => { if (error) { @@ -813,12 +754,7 @@ export default function socketJsunit() { */ it('Telephony_Socket_UDPSocket_on_message_0100', 0, function (done) { console.log("************* Telephony_Socket_UDPSocket_on_message_0100 Test start*************"); - let caseName = "Telephony_Socket_UDPSocket_on_message_0100" - if (2 === 0) { - expect(true).assertTrue(); - done(); - return; - } + let caseName = "Telephony_Socket_UDPSocket_on_message_0100" udp.on('message', (data) => { let socketRemoteInfo = data.remoteInfo; console.log(`${caseName} port:${socketRemoteInfo.port}`); @@ -835,12 +771,7 @@ export default function socketJsunit() { */ it('Telephony_Socket_UDPSocket_off_message_0100', 0, function (done) { console.log("************* Telephony_Socket_UDPSocket_off_message_0100 Test start*************"); - let caseName = "Telephony_Socket_UDPSocket_off_message_0100" - if (2 === 0) { - expect(true).assertTrue(); - done(); - return; - } + let caseName = "Telephony_Socket_UDPSocket_off_message_0100" udp.off("message", data => { let socketRemoteInfo = data.remoteInfo; console.log(`${caseName} port:${socketRemoteInfo.port}`); @@ -856,12 +787,7 @@ export default function socketJsunit() { * @tc.desc : Cancels listening for message receiving events of the UDPSocket connection. */ it('Telephony_Socket_UDPSocket_off_message_0200', 0, function (done) { - console.log("************* Telephony_Socket_UDPSocket_off_message_0200 Test start*************"); - if (2 === 0) { - expect(true).assertTrue(); - done(); - return; - } + console.log("************* Telephony_Socket_UDPSocket_off_message_0200 Test start*************"); udp.off("message"); expect(true).assertTrue(); console.log("************* Telephony_Socket_UDPSocket_off_message_0200 Test end*************"); @@ -874,12 +800,7 @@ export default function socketJsunit() { * @tc.desc : Listens for data packet message events or close events of the UDPSocket connection. */ it('Telephony_Socket_UDPSocket_on_listening_0100', 0, function (done) { - console.log("************* Telephony_Socket_UDPSocket_on_listening_0100 Test start*************"); - if (2 === 0) { - expect(true).assertTrue(); - done(); - return; - } + console.log("************* Telephony_Socket_UDPSocket_on_listening_0100 Test start*************"); udp.on("listening", data => { expect(true).assertTrue(); }); @@ -893,12 +814,7 @@ export default function socketJsunit() { * @tc.desc : Cancels listening for data packet message events or close events of the UDPSocket connection. */ it('Telephony_Socket_UDPSocket_off_listening_0100', 0, function (done) { - console.log("************* Telephony_Socket_UDPSocket_off_listening_0100 Test start*************"); - if (2 === 0) { - expect(true).assertTrue(); - done(); - return; - } + console.log("************* Telephony_Socket_UDPSocket_off_listening_0100 Test start*************"); udp.off("listening", data => { expect(true).assertTrue(); }); @@ -912,12 +828,7 @@ export default function socketJsunit() { * @tc.desc : Cancels listening for data packet message events or close events of the UDPSocket connection. */ it('Telephony_Socket_UDPSocket_off_listening_0200', 0, function (done) { - console.log("************* Telephony_Socket_UDPSocket_off_listening_0200 Test start*************"); - if (2 === 0) { - expect(true).assertTrue(); - done(); - return; - } + console.log("************* Telephony_Socket_UDPSocket_off_listening_0200 Test start*************"); udp.off("listening"); expect(true).assertTrue(); console.log("************* Telephony_Socket_UDPSocket_off_listening_0200 Test end*************"); @@ -930,12 +841,7 @@ export default function socketJsunit() { * @tc.desc : Listens for data packet message events or close events of the UDPSocket connection. */ it('Telephony_Socket_UDPSocket_on_close_0100', 0, function (done) { - console.log("************* Telephony_Socket_UDPSocket_on_close_0100 Test start*************"); - if (2 === 0) { - expect(true).assertTrue(); - done(); - return; - } + console.log("************* Telephony_Socket_UDPSocket_on_close_0100 Test start*************"); udp.on("close", data => { expect(true).assertTrue(); }); @@ -949,12 +855,7 @@ export default function socketJsunit() { * @tc.desc : Cancels listening for data packet message events or close events of the UDPSocket connection. */ it('Telephony_Socket_UDPSocket_off_close_0100', 0, function (done) { - console.log("************* Telephony_Socket_UDPSocket_off_close_0100 Test start*************"); - if (2 === 0) { - expect(true).assertTrue(); - done(); - return; - } + console.log("************* Telephony_Socket_UDPSocket_off_close_0100 Test start*************"); udp.off("close", data => { expect(true).assertTrue(); }); @@ -968,12 +869,7 @@ export default function socketJsunit() { * @tc.desc : Cancels listening for data packet message events or close events of the UDPSocket connection. */ it('Telephony_Socket_UDPSocket_off_close_0200', 0, function (done) { - console.log("************* Telephony_Socket_UDPSocket_off_close_0200 Test start*************"); - if (2 === 0) { - expect(true).assertTrue(); - done(); - return; - } + console.log("************* Telephony_Socket_UDPSocket_off_close_0200 Test start*************"); udp.off("close"); expect(true).assertTrue(); console.log("************* Telephony_Socket_UDPSocket_off_close_0200 Test end*************"); @@ -987,12 +883,7 @@ export default function socketJsunit() { */ it('Telephony_Socket_UDPSocket_on_error_0100', 0, function (done) { console.log("************* Telephony_Socket_UDPSocket_on_error_0100 Test start*************"); - let caseName = "Telephony_Socket_UDPSocket_on_error_0100" - if (2 === 0) { - expect(true).assertTrue(); - done(); - return; - } + let caseName = "Telephony_Socket_UDPSocket_on_error_0100" udp.on("error", error => { console.log(`${caseName} fail, error:${toString(error)}`); expect().assertFail(); @@ -1009,12 +900,7 @@ export default function socketJsunit() { */ it('Telephony_Socket_UDPSocket_off_error_0100', 0, function (done) { console.log("************* Telephony_Socket_UDPSocket_off_error_0100 Test start*************"); - let caseName = "Telephony_Socket_UDPSocket_off_error_0100" - if (2 === 0) { - expect(true).assertTrue(); - done(); - return; - } + let caseName = "Telephony_Socket_UDPSocket_off_error_0100" udp.off("error", error => { console.log(`${caseName} fail, error:${toString(error)}`); expect().assertFail(); @@ -1030,12 +916,7 @@ export default function socketJsunit() { * @tc.desc : Cancels listening for error events of the UDPSocket connection. */ it('Telephony_Socket_UDPSocket_off_error_0200', 0, function (done) { - console.log("************* Telephony_Socket_UDPSocket_off_error_0200 Test start*************"); - if (2 === 0) { - expect(true).assertTrue(); - done(); - return; - } + console.log("************* Telephony_Socket_UDPSocket_off_error_0200 Test start*************"); udp.off("error"); expect(true).assertTrue(); console.log("************* Telephony_Socket_UDPSocket_off_error_0200 Test end*************"); @@ -1076,12 +957,7 @@ export default function socketJsunit() { */ it('Telephony_Socket_TCPSocket_bind_0200', 0, function (done) { console.log("************* Telephony_Socket_TCPSocket_bind_0200 Test start*************"); - let caseName = "Telephony_Socket_TCPSocket_bind_0200" - if (2 === 0) { - expect(true).assertTrue(); - done(); - return; - } + let caseName = "Telephony_Socket_TCPSocket_bind_0200" let netAddress = { address: "test address", family: 1, @@ -1131,11 +1007,7 @@ export default function socketJsunit() { it('Telephony_Socket_TCPSocket_bind_0400', 0, function (done) { console.log("************* Telephony_Socket_TCPSocket_bind_0400 Test start*************"); let caseName = "Telephony_Socket_TCPSocket_bind_0400" - if (2 === 0) { - expect(true).assertTrue(); - done(); - return; - } + let netAddress = { address: "third test address" } @@ -1157,12 +1029,7 @@ export default function socketJsunit() { */ it('Telephony_Socket_TCPSocket_send_0100', 0, function (done) { console.log("************* Telephony_Socket_TCPSocket_send_0100 Test start*************"); - let caseName = "Telephony_Socket_TCPSocket_send_0100" - if (2 === 0) { - expect(true).assertTrue(); - done(); - return; - } + let caseName = "Telephony_Socket_TCPSocket_send_0100" let tcpSendOptions = { data: "test data", encoding: "test encoding" @@ -1188,12 +1055,7 @@ export default function socketJsunit() { */ it('Telephony_Socket_TCPSocket_send_0200', 0, function (done) { console.log("************* Telephony_Socket_TCPSocket_send_0200 Test start*************"); - let caseName = "Telephony_Socket_TCPSocket_send_0200" - if (2 === 0) { - expect(true).assertTrue(); - done(); - return; - } + let caseName = "Telephony_Socket_TCPSocket_send_0200" let tcpSendOptions = { data: "test data", encoding: "test encoding" @@ -1214,12 +1076,7 @@ export default function socketJsunit() { */ it('Telephony_Socket_TCPSocket_send_0300', 0, function (done) { console.log("************* Telephony_Socket_TCPSocket_send_0300 Test start*************"); - let caseName = "Telephony_Socket_TCPSocket_send_0300" - if (2 === 0) { - expect(true).assertTrue(); - done(); - return; - } + let caseName = "Telephony_Socket_TCPSocket_send_0300" let tcpSendOptions = { data: "second test data", } @@ -1244,12 +1101,7 @@ export default function socketJsunit() { */ it('Telephony_Socket_TCPSocket_send_0400', 0, function (done) { console.log("************* Telephony_Socket_TCPSocket_send_0400 Test start*************"); - let caseName = "Telephony_Socket_TCPSocket_send_0400" - if (2 === 0) { - expect(true).assertTrue(); - done(); - return; - } + let caseName = "Telephony_Socket_TCPSocket_send_0400" let tcpSendOptions = { data: "second test data", } @@ -1269,12 +1121,7 @@ export default function socketJsunit() { */ it('Telephony_Socket_TCPSocket_connect_0100', 0, function (done) { console.log("************* Telephony_Socket_TCPSocket_connect_0100 Test start*************"); - let caseName = "Telephony_Socket_TCPSocket_connect_0100" - if (2 === 0) { - expect(true).assertTrue(); - done(); - return; - } + let caseName = "Telephony_Socket_TCPSocket_connect_0100" let tcpConnectOptions = { address: { address: "test address", @@ -1304,12 +1151,7 @@ export default function socketJsunit() { */ it('Telephony_Socket_TCPSocket_connect_0200', 0, function (done) { console.log("************* Telephony_Socket_TCPSocket_connect_0200 Test start*************"); - let caseName = "Telephony_Socket_TCPSocket_connect_0200" - if (2 === 0) { - expect(true).assertTrue(); - done(); - return; - } + let caseName = "Telephony_Socket_TCPSocket_connect_0200" let tcpConnectOptions = { address: { address: "test address", @@ -1334,12 +1176,7 @@ export default function socketJsunit() { */ it('Telephony_Socket_TCPSocket_connect_0300', 0, function (done) { console.log("************* Telephony_Socket_TCPSocket_connect_0300 Test start*************"); - let caseName = "Telephony_Socket_TCPSocket_connect_0300" - if (2 === 0) { - expect(true).assertTrue(); - done(); - return; - } + let caseName = "Telephony_Socket_TCPSocket_connect_0300" let tcpConnectOptions = { address: { address: "second test address", @@ -1368,12 +1205,7 @@ export default function socketJsunit() { */ it('Telephony_Socket_TCPSocket_connect_0200', 0, function (done) { console.log("************* Telephony_Socket_TCPSocket_connect_0400 Test start*************"); - let caseName = "Telephony_Socket_TCPSocket_connect_0400" - if (2 === 0) { - expect(true).assertTrue(); - done(); - return; - } + let caseName = "Telephony_Socket_TCPSocket_connect_0400" let tcpConnectOptions = { address: { address: "second test address", @@ -1397,12 +1229,7 @@ export default function socketJsunit() { */ it('Telephony_Socket_TCPSocket_close_0100', 0, function (done) { console.log("************* Telephony_Socket_TCPSocket_close_0100 Test start*************"); - let caseName = "Telephony_Socket_TCPSocket_close_0100" - if (2 === 0) { - expect(true).assertTrue(); - done(); - return; - } + let caseName = "Telephony_Socket_TCPSocket_close_0100" tcp.close((error, data) => { if (error) { console.log(`${caseName} error, case success,error:${toString(error)}`); @@ -1423,12 +1250,7 @@ export default function socketJsunit() { */ it('Telephony_Socket_TCPSocket_close_0200', 0, function (done) { console.log("************* Telephony_Socket_TCPSocket_close_0200 Test start*************"); - let caseName = "Telephony_Socket_TCPSocket_close_0200" - if (2 === 0) { - expect(true).assertTrue(); - done(); - return; - } + let caseName = "Telephony_Socket_TCPSocket_close_0200" tcp.close().then(data => { console.log(`${caseName} success,data:${toString(data)}`); }).catch((error) => { @@ -1445,12 +1267,7 @@ export default function socketJsunit() { */ it('Telephony_Socket_TCPSocket_getState_0100', 0, function (done) { console.log("************* Telephony_Socket_TCPSocket_getState_0100 Test start*************"); - let caseName = "Telephony_Socket_TCPSocket_getState_0100" - if (2 === 0) { - expect(true).assertTrue(); - done(); - return; - } + let caseName = "Telephony_Socket_TCPSocket_getState_0100" tcp.getState((error, data) => { if (error) { console.log(`${caseName} case success,error:${toString(error)}`); @@ -1472,18 +1289,12 @@ export default function socketJsunit() { */ it('Telephony_Socket_TCPSocket_getState_0200', 0, function (done) { console.log("************* Telephony_Socket_TCPSocket_getState_0200 Test start*************"); - let caseName = "Telephony_Socket_TCPSocket_getState_0200" - if (2 === 0) { - expect(true).assertTrue(); - done(); - return; - } + let caseName = "Telephony_Socket_TCPSocket_getState_0200" tcp.getState().then(data => { console.log(`${caseName} success,data:${toString(data)}`); }).catch((error) => { console.log(`${caseName} failed,error:${toString(error)}`); }); - console.log("************* Telephony_Socket_TCPSocket_getState_0200 Test end*************"); done(); }); @@ -1495,12 +1306,7 @@ export default function socketJsunit() { */ it('Telephony_Socket_TCPSocket_setExtraOptions_0100', 0, function (done) { console.log("************* Telephony_Socket_TCPSocket_setExtraOptions_0100 Test start*************"); - let caseName = "Telephony_Socket_TCPSocket_setExtraOptions_0100" - if (2 === 0) { - expect(true).assertTrue(); - done(); - return; - } + let caseName = "Telephony_Socket_TCPSocket_setExtraOptions_0100" let tcpExtraOptions = { keepAlive: true, OOBInline: true, @@ -1531,12 +1337,7 @@ export default function socketJsunit() { */ it('Telephony_Socket_TCPSocket_setExtraOptions_0200', 0, function (done) { console.log("************* Telephony_Socket_TCPSocket_setExtraOptions_0200 Test start*************"); - let caseName = "Telephony_Socket_TCPSocket_setExtraOptions_0200" - if (2 === 0) { - expect(true).assertTrue(); - done(); - return; - } + let caseName = "Telephony_Socket_TCPSocket_setExtraOptions_0200" let tcpExtraOptions = { keepAlive: true, OOBInline: true, @@ -1568,12 +1369,7 @@ export default function socketJsunit() { */ it('Telephony_Socket_TCPSocket_setExtraOptions_0300', 0, function (done) { console.log("************* Telephony_Socket_TCPSocket_setExtraOptions_0300 Test start*************"); - let caseName = "Telephony_Socket_TCPSocket_setExtraOptions_0300" - if (2 === 0) { - expect(true).assertTrue(); - done(); - return; - } + let caseName = "Telephony_Socket_TCPSocket_setExtraOptions_0300" let tcpExtraOptions = { socketLinger: { on: true, @@ -1601,12 +1397,7 @@ export default function socketJsunit() { */ it('Telephony_Socket_TCPSocket_setExtraOptions_0400', 0, function (done) { console.log("************* Telephony_Socket_TCPSocket_setExtraOptions_0400 Test start*************"); - let caseName = "Telephony_Socket_TCPSocket_setExtraOptions_0400" - if (2 === 0) { - expect(true).assertTrue(); - done(); - return; - } + let caseName = "Telephony_Socket_TCPSocket_setExtraOptions_0400" let tcpExtraOptions = { socketLinger: { on: true, @@ -1635,12 +1426,7 @@ export default function socketJsunit() { */ it('Telephony_Socket_TCPSocket_getRemoteAddress_0100', 0, function (done) { console.log("************* Telephony_Socket_TCPSocket_getRemoteAddress_0100 Test start*************"); - let caseName = "Telephony_Socket_TCPSocket_getRemoteAddress_0100" - if (2 === 0) { - expect(true).assertTrue(); - done(); - return; - } + let caseName = "Telephony_Socket_TCPSocket_getRemoteAddress_0100" tcp.getRemoteAddress((error) => { if (error) { console.log(`${caseName} error, case success,error:${toString(error)}`); @@ -1661,12 +1447,7 @@ export default function socketJsunit() { */ it('Telephony_Socket_TCPSocket_getRemoteAddress_0200', 0, function (done) { console.log("************* Telephony_Socket_TCPSocket_getRemoteAddress_0200 Test start*************"); - let caseName = "Telephony_Socket_TCPSocket_getRemoteAddress_0200" - if (2 === 0) { - expect(true).assertTrue(); - done(); - return; - } + let caseName = "Telephony_Socket_TCPSocket_getRemoteAddress_0200" tcp.getRemoteAddress().then(data => { console.log(`${caseName} success,data:${toString(data)}`); }).catch((error) => { @@ -1683,12 +1464,7 @@ export default function socketJsunit() { */ it('Telephony_Socket_TCPSocket_on_message_0100', 0, function (done) { console.log("************* Telephony_Socket_TCPSocket_on_message_0100 Test start*************"); - let caseName = "Telephony_Socket_TCPSocket_on_message_0100" - if (2 === 0) { - expect(true).assertTrue(); - done(); - return; - } + let caseName = "Telephony_Socket_TCPSocket_on_message_0100" tcp.on("message", data => { let socketRemoteInfo: socket.SocketRemoteInfo = data.remoteInfo; console.log(`${caseName} port:${socketRemoteInfo.port}`); @@ -1705,12 +1481,7 @@ export default function socketJsunit() { */ it('Telephony_Socket_TCPSocket_off_message_0100', 0, function (done) { console.log("************* Telephony_Socket_TCPSocket_off_message_0100 Test start*************"); - let caseName = "Telephony_Socket_TCPSocket_off_message_0100" - if (2 === 0) { - expect(true).assertTrue(); - done(); - return; - } + let caseName = "Telephony_Socket_TCPSocket_off_message_0100" tcp.off("message", data => { let socketRemoteInfo: socket.SocketRemoteInfo = data.remoteInfo; console.log(`${caseName} port:${socketRemoteInfo.port}`); @@ -1726,12 +1497,7 @@ export default function socketJsunit() { * @tc.desc : Cancels listening for message receiving events of the TCPSocket connection. */ it('Telephony_Socket_TCPSocket_off_message_0200', 0, function (done) { - console.log("************* Telephony_Socket_TCPSocket_off_message_0200 Test start*************"); - if (2 === 0) { - expect(true).assertTrue(); - done(); - return; - } + console.log("************* Telephony_Socket_TCPSocket_off_message_0200 Test start*************"); tcp.off("message"); expect(true).assertTrue(); console.log("************* Telephony_Socket_TCPSocket_off_message_0200 Test end*************"); @@ -1744,12 +1510,7 @@ export default function socketJsunit() { * @tc.desc : Listens for connection or close events of the TCPSocket connection. */ it('Telephony_Socket_TCPSocket_on_connect_0100', 0, function (done) { - console.log("************* Telephony_Socket_TCPSocket_on_connect_0100 Test start*************"); - if (2 === 0) { - expect(true).assertTrue(); - done(); - return; - } + console.log("************* Telephony_Socket_TCPSocket_on_connect_0100 Test start*************"); tcp.on("connect", data => { expect(true).assertTrue(); }); @@ -1763,12 +1524,7 @@ export default function socketJsunit() { * @tc.desc : Cancels listening for connection or close events of the TCPSocket connection. */ it('Telephony_Socket_TCPSocket_off_connect_0100', 0, function (done) { - console.log("************* Telephony_Socket_TCPSocket_off_connect_0100 Test start*************"); - if (2 === 0) { - expect(true).assertTrue(); - done(); - return; - } + console.log("************* Telephony_Socket_TCPSocket_off_connect_0100 Test start*************"); tcp.off("connect", data => { expect(true).assertTrue(); }); @@ -1782,12 +1538,7 @@ export default function socketJsunit() { * @tc.desc : Cancels listening for connection or close events of the TCPSocket connection. */ it('Telephony_Socket_TCPSocket_off_connect_0200', 0, function (done) { - console.log("************* Telephony_Socket_TCPSocket_off_connect_0200 Test start*************"); - if (2 === 0) { - expect(true).assertTrue(); - done(); - return; - } + console.log("************* Telephony_Socket_TCPSocket_off_connect_0200 Test start*************"); tcp.off("connect"); expect(true).assertTrue(); console.log("************* Telephony_Socket_TCPSocket_off_connect_0200 Test end*************"); @@ -1800,12 +1551,7 @@ export default function socketJsunit() { * @tc.desc : Listens for connection or close events of the TCPSocket connection. */ it('Telephony_Socket_TCPSocket_on_close_0100', 0, function (done) { - console.log("************* Telephony_Socket_TCPSocket_on_close_0100 Test start*************"); - if (2 === 0) { - expect(true).assertTrue(); - done(); - return; - } + console.log("************* Telephony_Socket_TCPSocket_on_close_0100 Test start*************"); tcp.on("close", data => { expect(true).assertTrue(); }); @@ -1819,12 +1565,7 @@ export default function socketJsunit() { * @tc.desc : Cancels listening for connection or close events of the TCPSocket connection. */ it('Telephony_Socket_TCPSocket_off_close_0100', 0, function (done) { - console.log("************* Telephony_Socket_TCPSocket_off_close_0100 Test start*************"); - if (2 === 0) { - expect(true).assertTrue(); - done(); - return; - } + console.log("************* Telephony_Socket_TCPSocket_off_close_0100 Test start*************"); tcp.off("close", data => { expect(true).assertTrue(); }); @@ -1838,12 +1579,7 @@ export default function socketJsunit() { * @tc.desc : Cancels listening for connection or close events of the TCPSocket connection. */ it('Telephony_Socket_TCPSocket_off_close_0200', 0, function (done) { - console.log("************* Telephony_Socket_TCPSocket_off_close_0200 Test start*************"); - if (2 === 0) { - expect(true).assertTrue(); - done(); - return; - } + console.log("************* Telephony_Socket_TCPSocket_off_close_0200 Test start*************"); tcp.off("close"); expect(true).assertTrue(); console.log("************* Telephony_Socket_TCPSocket_off_close_0200 Test end*************"); @@ -1857,12 +1593,7 @@ export default function socketJsunit() { */ it('Telephony_Socket_TCPSocket_on_error_0100', 0, function (done) { console.log("************* Telephony_Socket_TCPSocket_on_error_0100 Test start*************"); - let caseName = "Telephony_Socket_TCPSocket_on_error_0100" - if (2 === 0) { - expect(true).assertTrue(); - done(); - return; - } + let caseName = "Telephony_Socket_TCPSocket_on_error_0100" tcp.on("error", error => { console.log(`${caseName} fail, error:${toString(error)}`); expect().assertFail(); @@ -1879,12 +1610,7 @@ export default function socketJsunit() { */ it('Telephony_Socket_TCPSocket_off_error_0100', 0, function (done) { console.log("************* Telephony_Socket_TCPSocket_off_error_0100 Test start*************"); - let caseName = "Telephony_Socket_TCPSocket_off_error_0100" - if (2 === 0) { - expect(true).assertTrue(); - done(); - return; - } + let caseName = "Telephony_Socket_TCPSocket_off_error_0100" tcp.off("error", error => { console.log(`${caseName} fail, error:${toString(error)}`); expect().assertFail(); @@ -1900,12 +1626,7 @@ export default function socketJsunit() { * @tc.desc : Cancels listening for error events of the TCPSocket connection. */ it('Telephony_Socket_TCPSocket_off_error_0200', 0, function (done) { - console.log("************* Telephony_Socket_TCPSocket_off_error_0200 Test start*************"); - if (2 === 0) { - expect(true).assertTrue(); - done(); - return; - } + console.log("************* Telephony_Socket_TCPSocket_off_error_0200 Test start*************"); tcp.off("error"); expect(true).assertTrue(); console.log("************* Telephony_Socket_TCPSocket_off_error_0200 Test end*************"); -- GitLab