From 1019d6cb332c9354518dd725b5f8d3f3b61a2a04 Mon Sep 17 00:00:00 2001 From: gaoxi785 Date: Sat, 22 Jul 2023 14:14:59 +0800 Subject: [PATCH] sendshortmessage Signed-off-by: gaoxi785 --- .../src/main/ets/test/HttpJsunit.test.ets | 41 +++++++++++++++++-- .../src/main/js/test/SmsMmsError.test.js | 8 ++-- 2 files changed, 41 insertions(+), 8 deletions(-) diff --git a/telephony/telephonyjstest/netmanager_http/entry/src/main/ets/test/HttpJsunit.test.ets b/telephony/telephonyjstest/netmanager_http/entry/src/main/ets/test/HttpJsunit.test.ets index 85043ce86..3ea617643 100644 --- a/telephony/telephonyjstest/netmanager_http/entry/src/main/ets/test/HttpJsunit.test.ets +++ b/telephony/telephonyjstest/netmanager_http/entry/src/main/ets/test/HttpJsunit.test.ets @@ -15,8 +15,7 @@ import {describe, it, expect} from '@ohos/hypium'; import http from '@ohos.net.http'; import connection from "@ohos.net.connection"; -import ethernet from '@ohos.net.ethernet'; -type httpProxy = connection.HttpProxy; +import socket from '@ohos.net.socket'; export default function httpJsunit() { describe("httpJsunitTest", function () { @@ -157,8 +156,14 @@ export default function httpJsunit() { }); }).catch(error => { console.log("setAppNet err " + JSON.stringify(error)); + expect().assertFail(); + done(); + }); + }).catch(error => { + console.log("getDefaultNet err " + JSON.stringify(error)); + expect().assertFail(); + done(); }); - }); }); /** @@ -183,8 +188,36 @@ export default function httpJsunit() { }); }).catch(error => { console.log("setAppNet err " + JSON.stringify(error)); + expect().assertFail(); + done(); + }); + }).catch(error => { + console.log("getDefaultNet err " + JSON.stringify(error)); + expect().assertFail(); + done(); }); - }); }); + + /** + * @tc.number Telephony_Connection_Request_Socket_0100 + * @tc.name Test type + * @tc.desc Function test + */ + it('Telephony_Connection_Request_Socket_0100', 0, async function (done) { + let caseName = 'Telephony_Connection_Request_Socket_0100'; + type HttpProxy = connection.HttpProxy; + type TCPSocket = socket.TCPSocket; + type UDPSocket = socket.UDPSocket; + Test(http.createHttp(),socket.constructTCPSocketInstance(),socket.constructUDPSocketInstance()); + + function Test(httpProxy:HttpProxy,tcpSocket:TCPSocket,udpSocket:UDPSocket){ + except(httpProxy != null).assertTrue(); + except(tcpSocket != null).assertTrue(); + except(udpSocket != null).assertTrue(); + httpRequest.destroy(); + tcpSocket.close(); + udp.close(); + done(); + } }); } \ No newline at end of file diff --git a/telephony/telephonyjstest/sms_mms/sms_mms_error/src/main/js/test/SmsMmsError.test.js b/telephony/telephonyjstest/sms_mms/sms_mms_error/src/main/js/test/SmsMmsError.test.js index 25d1effa4..ee93b4b0f 100644 --- a/telephony/telephonyjstest/sms_mms/sms_mms_error/src/main/js/test/SmsMmsError.test.js +++ b/telephony/telephonyjstest/sms_mms/sms_mms_error/src/main/js/test/SmsMmsError.test.js @@ -182,7 +182,7 @@ describe('SmsMmsErrorTest', function () { sendCallback, deliveryCallback }; - sms.sendMessage(options).then((data)=>{ + sms.sendShortMessage(options).then((data)=>{ console.info('Telephony_SmsMms_sendShortMessage_Promise_0100 ' + JSON.stringify(data)); expect().assertFail(); done(); @@ -224,9 +224,9 @@ describe('SmsMmsErrorTest', function () { sendCallback, deliveryCallback }; - sms.sendMessage(options,(err,data)=>{ + sms.sendShortMessage(options,(err, data)=>{ if(err){ - expect(error.code == 201).assertTrue(); + expect(err.code == 201).assertTrue(); done(); } else { console.info('Telephony_SmsMms_sendShortMessage_Async_0100 ' + JSON.stringify(data)); @@ -234,7 +234,7 @@ describe('SmsMmsErrorTest', function () { done(); } }); - } catch (err) { + } catch (error) { expect(true).assertFalse(); done(); } -- GitLab