diff --git a/telephony/telephonyjstest/netmanager_http/entry/src/main/ets/MainAbility/test/RequestMethodJsunit.test.ets b/telephony/telephonyjstest/netmanager_http/entry/src/main/ets/MainAbility/test/RequestMethodJsunit.test.ets index ebf9e7d171b8612699480b8c7d8a47eac2d69f00..eb3cc28a97c5e9942f5618bf2f84bb5888be0344 100644 --- a/telephony/telephonyjstest/netmanager_http/entry/src/main/ets/MainAbility/test/RequestMethodJsunit.test.ets +++ b/telephony/telephonyjstest/netmanager_http/entry/src/main/ets/MainAbility/test/RequestMethodJsunit.test.ets @@ -171,8 +171,6 @@ export default function requestMethodJsunit() { } }); - - /** * @tc.number Telephony_http_HttpRequestMethod_POST_0100 * @tc.name HttpRequestMethod::POST @@ -341,6 +339,89 @@ export default function requestMethodJsunit() { }); + + + + /** + * @tc.number Telephony_http_HttpRequestMethod_PUT_0100 + * @tc.name HttpRequestMethod::PUT + * @tc.desc Test Test HttpRequestMethod property. + */ + + it("Telephony_http_HttpRequestMethod_PUT_0100", 0, async function (done) { + var casename = "Telephony_http_HttpRequestMethod_0500" + console.log("-----------------------HttpRequestMethod_PUT Test is starting-----------------------"); + try { + let httpRequestOptions = { + method: "PUT", + 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_PUT Test end-----------------------"); + done(); + }); + } catch (error) { + console.log("Telephony_http_HttpRequestMethod_PUT_0100 : error = " + error); + done(); + } + }); + + + + /** + * @tc.number Telephony_http_HttpRequestMethod_PUT_0200 + * @tc.name HttpRequestMethod::PUT + * @tc.desc Test Test HttpRequestMethod property. + */ + + it("Telephony_http_HttpRequestMethod_PUT_0200", 0, async function (done) { + var casename = "Telephony_http_HttpRequestMethod_0500" + console.log("-----------------------HttpRequestMethod_PUT_01 Test is starting-----------------------"); + try { + let httpRequestOptions = { + method: "PUT", + 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_PUT_01 Test end-----------------------"); + done(); + }).catch(error => { + console.info(casename+"errocode" + JSON.stringify(error)); + done(); + }); + } catch (error) { + console.log("Telephony_http_HttpRequestMethod_PUT_0200 : error = " + error); + done(); + } + }); + + + + + + }) }; diff --git a/telephony/telephonyjstest/netmanager_http/entry/src/main/ets/MainAbility/test/ResponseCodeJsunit.test.ets b/telephony/telephonyjstest/netmanager_http/entry/src/main/ets/MainAbility/test/ResponseCodeJsunit.test.ets index 3f36dea146e9224bd860dbef032b3ec45df8c48e..04ff1a79bc8dbd02d6f7bdf496898b4d76f34c3e 100644 --- a/telephony/telephonyjstest/netmanager_http/entry/src/main/ets/MainAbility/test/ResponseCodeJsunit.test.ets +++ b/telephony/telephonyjstest/netmanager_http/entry/src/main/ets/MainAbility/test/ResponseCodeJsunit.test.ets @@ -450,6 +450,142 @@ export default function responseCodeJsunit() { }); + /** + * @tc.number Telephony_Http_ResponseCode_CREATED_0100 + * @tc.name ResponseCode::CREATED + * @tc.desc Test Test ResponseCode property. + */ + + it("Telephony_Http_ResponseCode_CREATED_0100", 0, async function (done) { + console.log("-----------------------ResponseCode CREATED Test is starting-----------------------"); + try { + expect(201).assertEqual(http.ResponseCode.CREATED); + console.log("-----------------------ResponseCode CREATED Test end-----------------------"); + done(); + } catch (error) { + console.log("Telephony_Http_ResponseCode_CREATED_0100 : error = " + error); + done(); + } + }); + + + /** + * @tc.number Telephony_Http_ResponseCode_PARTIAL_0100 + * @tc.name ResponseCode::PARTIAL + * @tc.desc Test Test ResponseCode property. + */ + + it("Telephony_Http_ResponseCode_PARTIAL_0100", 0, async function (done) { + console.log("-----------------------ResponseCode PARTIAL Test is starting-----------------------"); + try { + expect(206).assertEqual(http.ResponseCode.PARTIAL); + console.log("-----------------------ResponseCode PARTIAL Test end-----------------------"); + done(); + } catch (error) { + console.log("Telephony_Http_ResponseCode_PARTIAL_0100 : error = " + error); + done(); + } + }); + + + /** + * @tc.number Telephony_Http_ResponseCode_MOVED_TEMP_0100 + * @tc.name ResponseCode::MOVED_TEMP + * @tc.desc Test Test ResponseCode property. + */ + + it("Telephony_Http_ResponseCode_MOVED_TEMP_0100", 0, async function (done) { + console.log("-----------------------ResponseCode MOVED_TEMP Test is starting-----------------------"); + try { + expect(302).assertEqual(http.ResponseCode.MOVED_TEMP); + console.log("-----------------------ResponseCode MOVED_TEMP Test end-----------------------"); + done(); + } catch (error) { + console.log("Telephony_Http_ResponseCode_MOVED_TEMP_0100 : error = " + error); + done(); + } + }); + + + /** + * @tc.number Telephony_Http_ResponseCode_NOT_FOUND_0100 + * @tc.name ResponseCode::NOT_FOUND + * @tc.desc Test Test ResponseCode property. + */ + + it("Telephony_Http_ResponseCode_NOT_FOUND_0100", 0, async function (done) { + console.log("-----------------------ResponseCode NOT_FOUND Test is starting-----------------------"); + try { + expect(404).assertEqual(http.ResponseCode.NOT_FOUND); + console.log("-----------------------ResponseCode NOT_FOUND Test end-----------------------"); + done(); + } catch (error) { + console.log("Telephony_Http_ResponseCode_NOT_FOUND_0100 : error = " + error); + done(); + } + }); + + + + /** + * @tc.number Telephony_Http_ResponseCode_CONFLICT_0100 + * @tc.name ResponseCode::CONFLICT + * @tc.desc Test Test ResponseCode property. + */ + + it("Telephony_Http_ResponseCode_CONFLICT_0100", 0, async function (done) { + console.log("-----------------------ResponseCode CONFLICT Test is starting-----------------------"); + try { + expect(409).assertEqual(http.ResponseCode.CONFLICT); + console.log("-----------------------ResponseCode CONFLICT Test end-----------------------"); + done(); + } catch (error) { + console.log("Telephony_Http_ResponseCode_CONFLICT_0100 : error = " + error); + done(); + } + }); + + + + + /** + * @tc.number Telephony_Http_ResponseCode_GONE_0100 + * @tc.name ResponseCode::GONE + * @tc.desc Test Test ResponseCode property. + */ + + it("Telephony_Http_ResponseCode_GONE_0100", 0, async function (done) { + console.log("-----------------------ResponseCode GONE Test is starting-----------------------"); + try { + expect(410).assertEqual(http.ResponseCode.GONE); + console.log("-----------------------ResponseCode GONE Test end-----------------------"); + done(); + } catch (error) { + console.log("Telephony_Http_ResponseCode_GONE_0100 : error = " + error); + done(); + } + }); + + + /** + * @tc.number Telephony_Http_ResponseCode_UNAVAILABLE_0100 + * @tc.name ResponseCode::UNAVAILABLE + * @tc.desc Test Test ResponseCode property. + */ + + it("Telephony_Http_ResponseCode_UNAVAILABLE_0100", 0, async function (done) { + console.log("-----------------------ResponseCode UNAVAILABLE Test is starting-----------------------"); + try { + expect(503).assertEqual(http.ResponseCode.UNAVAILABLE); + console.log("-----------------------ResponseCode UNAVAILABLE Test end-----------------------"); + done(); + } catch (error) { + console.log("Telephony_Http_ResponseCode_UNAVAILABLE_0100 : error = " + error); + done(); + } + }); + + }) }; diff --git a/telephony/telephonyjstest/netmanager_socket/entry/src/main/ets/MainAbility/test/ConnectionJsunit.test.ets b/telephony/telephonyjstest/netmanager_socket/entry/src/main/ets/MainAbility/test/ConnectionJsunit.test.ets index b538fa17b0e9ea3621574b498cc70958bd0aa25e..1a27bf0f496a8144d0afd5beab6c9df13524f4b3 100644 --- a/telephony/telephonyjstest/netmanager_socket/entry/src/main/ets/MainAbility/test/ConnectionJsunit.test.ets +++ b/telephony/telephonyjstest/netmanager_socket/entry/src/main/ets/MainAbility/test/ConnectionJsunit.test.ets @@ -20,6 +20,7 @@ import utils from './Utils.ets' export default function connectionJsunit() { describe('connectionTest', function () { const TIMEOUT = 100; + const DELAY = 1000; const NETID_IVVALID = 99; const NETID_IVVALID2 = 0; console.log("************* connection Test start*************"); @@ -997,6 +998,119 @@ export default function connectionJsunit() { console.log("************* Telephony_Connection_Connection_bearerTypes_0100 Test end*************"); }) + /** + * @tc.number Telephony_Connection_Connection_register_0100 + * @tc.name register + * @tc.desc Receives status change notifications of a specified network. + */ + it('Telephony_Connection_Connection_register_0100', 0, async function (done) { + console.log("************* Telephony_Connection_Connection_register_0100 Test start*************"); + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + let caseName = 'Telephony_Connection_Connection_register_0100'; + let netSpecifier = { + netCapabilities: { + linkUpBandwidthKbps: 0, + linkDownBandwidthKbps: 0, + bearerTypes: [0], + networkCap: [0], + }, bearerPrivateIdentifier: '123' + } + let netConn = connection.createNetConnection(netSpecifier, TIMEOUT); + netConn.register((error) => { + if (error) { + console.log(`${caseName} register fail: ${error}`); + } + }); + await sleep(DELAY); + netConn.unregister((error) => { + if (error) { + console.log(`${caseName} unregister fail: ${error}`); + } + }); + expect(true).assertTrue(); + done(); + console.log("************* Telephony_Connection_Connection_register_0100 Test end*************"); + }); + + /** + * @tc.number Telephony_Connection_Connection_unregister_0100 + * @tc.name unregister + * @tc.desc Cancels listening for network status changes. test + */ + it('Telephony_Connection_Connection_unregister_0100', 0, async function (done) { + console.log("************* Telephony_Connection_Connection_unregister_0100 Test start*************"); + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + let caseName = 'Telephony_Connection_Connection_unregister_0100'; + let netSpecifier = { + netCapabilities: { + linkUpBandwidthKbps: 10, + linkDownBandwidthKbps: 11, + bearerTypes: [0], + networkCap: [0], + }, bearerPrivateIdentifier: '123' + } + let netConn = connection.createNetConnection(netSpecifier, TIMEOUT); + netConn.register((error) => { + if (error) { + console.log(`${caseName} register fail: ${error}`); + } + }); + await sleep(DELAY); + netConn.unregister((error) => { + if (error) { + console.log(`${caseName} unregister fail: ${error}`); + } + }); + expect(true).assertTrue(); + done(); + console.log("************* Telephony_Connection_Connection_unregister_0100 Test end*************"); + }); + + /* + * @tc.number : Telephony_Connection_Connection_netId_0100 + * @tc.name : netId + * @tc.desc : netId test. + */ + it('Telephony_Connection_Connection_netId_0100', 0, async function (done) { + console.log("************* Telephony_Connection_Connection_netId_0100 Test start*************"); + connection.getDefaultNet((error, data) => { + if (error) { + expect(true).assertTrue(); + } else { + expect(data.netId).assertEqual(100); + } + }); + console.log("************* Telephony_Connection_Connection_netId_0100 Test end*************"); + done(); + }); + + /* + * @tc.number : Telephony_Connection_Connection_domains_0100 + * @tc.name : domains + * @tc.desc : domains test. + */ + it('Telephony_Connection_Connection_domains_0100', 0, async function (done) { + console.log("************* Telephony_Connection_Connection_domains_0100 Test start*************"); + var handle = new connection.NetHandle(NETID_IVVALID); + connection.getConnectionProperties(handle, (error, data) => { + if (error) { + expect(true).assertTrue(); + } else { + expect(data.domains).assertEqual(""); + } + }); + console.log("************* Telephony_Connection_Connection_domains_0100 Test end*************"); + done(); + }); + console.log("************* connection Test end*************"); }) } diff --git a/telephony/telephonyjstest/netmanager_socket/entry/src/main/ets/MainAbility/test/SocketJsunit.test.ets b/telephony/telephonyjstest/netmanager_socket/entry/src/main/ets/MainAbility/test/SocketJsunit.test.ets index 92e5511993df039965f9f532872f93b533195fe2..f73e8ea5bbd525c7fd3de46403a6c32c36879586 100644 --- a/telephony/telephonyjstest/netmanager_socket/entry/src/main/ets/MainAbility/test/SocketJsunit.test.ets +++ b/telephony/telephonyjstest/netmanager_socket/entry/src/main/ets/MainAbility/test/SocketJsunit.test.ets @@ -395,13 +395,13 @@ export default function socketJsunit() { family: 1, port: 8080 } - try{ + try { await socket.UDPSocket.bind(netAddress).then(data => { console.log(`${caseName} success,data:${toString(data)}`); }).catch((error) => { console.log(`${caseName} failed,error:${toString(error)}`); }); - }catch(err){ + } catch (err) { console.log(`${caseName} failed,catch error:${toString(error)}`); } console.log("************* Telephony_Socket_UDPSocket_bind_0200 Test end*************"); @@ -586,6 +586,54 @@ export default function socketJsunit() { done(); }); + /* + * @tc.number : Telephony_Socket_UDPSocket_close_0100 + * @tc.name : close + * @tc.desc : Closes a UDPSocket connection. + */ + it('Telephony_Socket_UDPSocket_close_0100', 0, async function (done) { + console.log("************* Telephony_Socket_UDPSocket_close_0100 Test start*************"); + let caseName = "Telephony_Socket_UDPSocket_close_0100" + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + socket.UDPSocket.close((error, data) => { + if (error) { + console.log(`${caseName} error, case success,error:${toString(error)}`); + done(); + return; + } + expect().assertFail(); + done(); + }) + console.log("************* Telephony_Socket_UDPSocket_close_0100 Test end*************"); + done(); + }); + + /* + * @tc.number : Telephony_Socket_UDPSocket_close_0200 + * @tc.name : close + * @tc.desc : Closes a UDPSocket connection. + */ + it('Telephony_Socket_UDPSocket_close_0200', 0, async function (done) { + console.log("************* Telephony_Socket_UDPSocket_close_0200 Test start*************"); + let caseName = "Telephony_Socket_UDPSocket_close_0200" + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + socket.UDPSocket.close().then(data => { + console.log(`${caseName} success,data:${toString(data)}`); + }).catch((error) => { + console.log(`${caseName} failed,error:${toString(error)}`); + }); + console.log("************* Telephony_Socket_UDPSocket_close_0200 Test end*************"); + done(); + }); + /* * @tc.number : Telephony_Socket_UDPSocket_getState_0100 * @tc.name : getState @@ -1320,6 +1368,54 @@ export default function socketJsunit() { done(); }); + /* + * @tc.number : Telephony_Socket_TCPSocket_close_0100 + * @tc.name : close + * @tc.desc : Closes a UDPSocket connection. + */ + it('Telephony_Socket_TCPSocket_close_0100', 0, async function (done) { + console.log("************* Telephony_Socket_TCPSocket_close_0100 Test start*************"); + let caseName = "Telephony_Socket_TCPSocket_close_0100" + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + socket.TCPSocket.close((error, data) => { + if (error) { + console.log(`${caseName} error, case success,error:${toString(error)}`); + done(); + return; + } + expect().assertFail(); + done(); + }) + console.log("************* Telephony_Socket_TCPSocket_close_0100 Test end*************"); + done(); + }); + + /* + * @tc.number : Telephony_Socket_TCPSocket_close_0200 + * @tc.name : close + * @tc.desc : Closes a UDPSocket connection. + */ + it('Telephony_Socket_TCPSocket_close_0200', 0, async function (done) { + console.log("************* Telephony_Socket_TCPSocket_close_0200 Test start*************"); + let caseName = "Telephony_Socket_TCPSocket_close_0200" + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + socket.TCPSocket.close().then(data => { + console.log(`${caseName} success,data:${toString(data)}`); + }).catch((error) => { + console.log(`${caseName} failed,error:${toString(error)}`); + }); + console.log("************* Telephony_Socket_TCPSocket_close_0200 Test end*************"); + done(); + }); + /* * @tc.number : Telephony_Socket_TCPSocket_getState_0100 * @tc.name : getState diff --git a/telephony/telephonyjstest/netmanager_socket/entry/src/main/ets/MainAbility/test/WebSocketJsunit.test.ets b/telephony/telephonyjstest/netmanager_socket/entry/src/main/ets/MainAbility/test/WebSocketJsunit.test.ets index 79008189d96303b6bceca944f2b23a78b9b66a89..f1581fbf8ce0f8fc77c40833391d50d906fdeb7c 100644 --- a/telephony/telephonyjstest/netmanager_socket/entry/src/main/ets/MainAbility/test/WebSocketJsunit.test.ets +++ b/telephony/telephonyjstest/netmanager_socket/entry/src/main/ets/MainAbility/test/WebSocketJsunit.test.ets @@ -63,13 +63,30 @@ export default function webSocketJsunit() { it('Telephony_WebSocket_WebSocketCloseOptions_code_0100', 0, async function (done) { console.log("************* Telephony_WebSocket_WebSocketCloseOptions_code_0100 Test start*************"); let webSocketCloseOptions: webSocket.WebSocketCloseOptions = { - code: 1 + code: 1, + reason: "test reason" } expect(webSocketCloseOptions.code === 1).assertTrue(); console.log("************* Telephony_WebSocket_WebSocketCloseOptions_code_0100 Test end*************"); done(); }) + /* + * @tc.number : Telephony_WebSocket_WebSocketCloseOptions_reason_0100 + * @tc.name : webSocketCloseOptions.reason + * @tc.desc : webSocketCloseOptions.reason + */ + it('Telephony_WebSocket_WebSocketCloseOptions_reason_0100', 0, async function (done) { + console.log("************* Telephony_WebSocket_WebSocketCloseOptions_reason_0100 Test start*************"); + let webSocketCloseOptions: webSocket.WebSocketCloseOptions = { + code: 1, + reason: "test reason" + } + expect(webSocketCloseOptions.reason).assertEqual("test reason"); + console.log("************* Telephony_WebSocket_WebSocketCloseOptions_reason_0100 Test end*************"); + done(); + }) + /* * @tc.number : Telephony_WebSocket_WebSocket_connect_0100 * @tc.name : connect @@ -228,6 +245,91 @@ export default function webSocketJsunit() { done(); }) + /* + * @tc.number : Telephony_WebSocket_WebSocket_close_0100 + * @tc.name : close + * @tc.desc : Closes a WebSocket connection. + */ + it('Telephony_WebSocket_WebSocket_close_0100', 0, async function (done) { + console.log("************* Telephony_WebSocket_WebSocket_close_0100 Test start*************"); + let caseName = "Telephony_WebSocket_WebSocket_close_0100" + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + webSocket.close((error, data) => { + if (error) { + console.log(`${caseName} error, case success,error:${toString(error)}`); + done(); + return; + } + expect().assertFail(); + console.log(`${caseName} error, case failed,data:${toString(data)}`); + done(); + }) + console.log("************* Telephony_WebSocket_WebSocket_close_0100 Test end*************"); + done(); + }) + + /* + * @tc.number : Telephony_WebSocket_WebSocket_close_0200 + * @tc.name : close + * @tc.desc : Closes a WebSocket connection. + */ + it('Telephony_WebSocket_WebSocket_close_0200', 0, async function (done) { + console.log("************* Telephony_WebSocket_WebSocket_close_0200 Test start*************"); + let caseName = "Telephony_WebSocket_WebSocket_close_0200" + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + let webSocketCloseOptions: webSocket.WebSocketCloseOptions = { + code: 1, + reason: "test reason" + } + webSocket.close(webSocketCloseOptions, (error, data) => { + if (error) { + console.log(`${caseName} error, case success,error:${toString(error)}`); + done(); + return; + } + expect().assertFail(); + console.log(`${caseName} error, case failed,data:${toString(data)}`); + done(); + }) + console.log("************* Telephony_WebSocket_WebSocket_close_0200 Test end*************"); + done(); + }) + + /* + * @tc.number : Telephony_WebSocket_WebSocket_close_0300 + * @tc.name : close + * @tc.desc : Closes a WebSocket connection. + */ + it('Telephony_WebSocket_WebSocket_close_0300', 0, async function (done) { + console.log("************* Telephony_WebSocket_WebSocket_close_0300 Test start*************"); + let caseName = "Telephony_WebSocket_WebSocket_close_0300" + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + let webSocketCloseOptions: webSocket.WebSocketCloseOptions = { + code: 1, + reason: "test reason" + } + webSocket.close(webSocketCloseOptions).then(data => { + expect(true).assertTrue(); + console.log(`${caseName} success,data:${toString(data)}`); + }).catch((error) => { + console.log(`${caseName} failed,error:${toString(error)}`); + }) + console.log("************* Telephony_WebSocket_WebSocket_close_0300 Test end*************"); + done(); + }) + /* * @tc.number : Telephony_WebSocket_WebSocket_on_open_0100 * @tc.name : on @@ -236,7 +338,7 @@ export default function webSocketJsunit() { it('Telephony_WebSocket_WebSocket_on_open_0100', 0, async function (done) { console.log("************* Telephony_WebSocket_WebSocket_on_open_0100 Test start*************"); let caseName = "Telephony_WebSocket_WebSocket_on_open_0100" - try{ + try { webSocket.on("open", (error, data) => { if (error) { console.log(`${caseName} error, case success,error:${toString(error)}`); @@ -249,7 +351,7 @@ export default function webSocketJsunit() { }); expect(true).assertTrue(); done(); - }catch(err){ + } catch (err) { expect(true).assertTrue(); console.log(`${caseName} error, catch error:${toString(err)}`); done(); diff --git a/telephony/telephonyjstest/new_add/Test.json b/telephony/telephonyjstest/new_add/Test.json index cb0f0ae2e56cb366f2352288ffa4f8a50f9ff476..a83417445a6b1e50d9e6e4424f0f6815f29aed0f 100644 --- a/telephony/telephonyjstest/new_add/Test.json +++ b/telephony/telephonyjstest/new_add/Test.json @@ -2,7 +2,7 @@ "description": "Configuration for hjunit demo Tests", "driver": { "type": "JSUnitTest", - "test-timeout": "1800000", + "test-timeout": "2000000", "package": "com.ohos.newadd", "shell-timeout": "60000" }, diff --git a/telephony/telephonyjstest/new_add/entry/src/main/ets/MainAbility/test/CallJsunit.test.ets b/telephony/telephonyjstest/new_add/entry/src/main/ets/MainAbility/test/CallJsunit.test.ets index cd87b836016e5664c060e93121c1ba5529e2c1bd..e2c0f5c9af36956471b1adbf5a84aa8e86ec1eb8 100644 --- a/telephony/telephonyjstest/new_add/entry/src/main/ets/MainAbility/test/CallJsunit.test.ets +++ b/telephony/telephonyjstest/new_add/entry/src/main/ets/MainAbility/test/CallJsunit.test.ets @@ -606,8 +606,8 @@ export default function callJsunit(){ it('Telephony_Call_CallAttributeOptions_CallId', 0, function (done) { let caseName = 'Telephony_Call_CallAttributeOptions_CallId'; console.log(`==========> ${caseName} Test start ==========>`); - let callAttributeOptions = {call:1}; - expect(callAttributeOptions.call === 1).assertTrue(); + let callAttributeOptions = {callId:1}; + expect(callAttributeOptions.callId === 1).assertTrue(); console.log(`==========> ${caseName} Test end ==========>`); done(); }); diff --git a/telephony/telephonyjstest/new_add/entry/src/main/ets/MainAbility/test/ConvertOptionsJsunit.test.ets b/telephony/telephonyjstest/new_add/entry/src/main/ets/MainAbility/test/ConvertOptionsJsunit.test.ets index 8e1cd292ba8f6995b95cd93843a0544d1af465c1..95fd59ba442e4b3faba4f798b3bed278fdaa5eeb 100644 --- a/telephony/telephonyjstest/new_add/entry/src/main/ets/MainAbility/test/ConvertOptionsJsunit.test.ets +++ b/telephony/telephonyjstest/new_add/entry/src/main/ets/MainAbility/test/ConvertOptionsJsunit.test.ets @@ -1258,5 +1258,43 @@ export default function convertOptionsJsunit() { expect(result1).assertEqual(str1); done(); }) + + /** + * @tc.name: Telephony_convertxml_ConvertXML_3900 + * @tc.desc: To convert XML text to JavaScript object. + * @tc.require: AR000GFB5B + */ + it('Telephony_convertxml_ConvertXML_3900', 0, function () { + var xml = + '' + + '' + + ' '+ + ' Happy' + + ' Work' + + ' Play' + + ''; + var convertml = new ConvertXML(); + var result1 = convertml.convert(xml, {compact: false, ignoreInstruction: true}); + var str1 = '{"_declaration":{"_attributes":{"version":"1.0",'+ + '"encoding":"utf-8"}},'+ + '"_elements":[{"_type":"element",'+ + '"_name":"note",'+ + '"_attributes":{"importance":"high",'+ + '"logged":"true"},'+ + '"_elements":['+ + '{"_type":"element",'+ + '"_name":"title",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Happy"}]},'+ + '{"_type":"element",'+ + '"_name":"todo",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Work"}]},'+ + '{"_type":"element",'+ + '"_name":"todo",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Play"}]}]}]}' + expect(result1).assertEqual(str1); + }) }) } \ No newline at end of file diff --git a/telephony/telephonyjstest/new_add/entry/src/main/ets/MainAbility/test/ObserverJsunit.test.ets b/telephony/telephonyjstest/new_add/entry/src/main/ets/MainAbility/test/ObserverJsunit.test.ets index 7aaeec92e83a4a23a5d8573115ad28647dc6420f..c380826a013cc0e76c89ca9255a5f0f0b29a0965 100644 --- a/telephony/telephonyjstest/new_add/entry/src/main/ets/MainAbility/test/ObserverJsunit.test.ets +++ b/telephony/telephonyjstest/new_add/entry/src/main/ets/MainAbility/test/ObserverJsunit.test.ets @@ -22,6 +22,7 @@ import {SimStateData} from '@ohos.telephony.observer' import {LockReason} from '@ohos.telephony.observer' import sim from "@ohos.telephony.sim" + export default function observerJsunit() { describe('ObserverTest', function () { console.log("************* Observer Test start *************") @@ -758,6 +759,25 @@ export default function observerJsunit() { done() } + /* + * @tc.number : Telephony_Observer_SimStateData_Reason + * @tc.name : on_simStateChange + * @tc.desc : call the on method of simStateChange + */ + it('Telephony_Observer_SimStateData_Reason', 0, async function (done) { + console.log("************* Telephony_Observer_SimStateData_Reason Test start *************") + observer.on('simStateChange', (data:SimStateData) => { + if((data === null || data === undefined) + || (data.reason == null || data.reason === undefined)){ + expect(true).assertTrue() + done() + } + return + }) + console.log("************* Telephony_Observer_SimStateData_Reason Test end *************") + done() + }) + console.log("************* Observer Test end *************") }) } diff --git a/telephony/telephonyjstest/new_add/entry/src/main/ets/MainAbility/test/RadioSecondJsunit.test.ets b/telephony/telephonyjstest/new_add/entry/src/main/ets/MainAbility/test/RadioSecondJsunit.test.ets index d1de270b275d466a9d4b26a4c553dd8bbb659719..674085a97169c5d69e0143e525bb04f773756cf5 100644 --- a/telephony/telephonyjstest/new_add/entry/src/main/ets/MainAbility/test/RadioSecondJsunit.test.ets +++ b/telephony/telephonyjstest/new_add/entry/src/main/ets/MainAbility/test/RadioSecondJsunit.test.ets @@ -122,6 +122,39 @@ export default function radioSecondJsunit() { }); }) + /** + * @tc.number Telephony_NetworkSearch_NetworkState_Async_0100 + * @tc.name Test getNrOptionMode() to check the callback result + * @tc.desc Function test + */ + it('Telephony_NetworkSearch_NetworkState_Async_0100', 0, async function (done) { + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + radio.getNetworkState((err, data) => { + if (err) { + console.log(`Telephony_NetworkSearch_NetworkState_Async_0100 get fail err: ${err}`); + expect().assertFail(); + done(); + return; + } + console.log(`Telephony_NetworkSearch_NetworkState_Async_0100 end data: ${JSON.stringify(data)}`); + if (true) { + console.log(`Telephony_NetworkSearch_getNrOptionMode_Async_0100 1`); + expect(true).assertTrue(); + done(); + return; + } else { + expect(NROPTION_MODE).assertContain(data); + expect(NROPTION_MODE).assertContain(data.cfgTech); + done(); + } + }); + }) + + /** * @tc.number Telephony_NetworkSearch_getNetworkSearchInformation_Async_0100 * @tc.name Test the getNetworkSearchInformation() query function and set the slotId parameter input to 0, @@ -185,6 +218,8 @@ export default function radioSecondJsunit() { expect(data[i].data.earfcn >= CELL_INFO_MIN && data[i].data.earfcn <= CELL_EARFCN_MAX).assertTrue(); expect(data[i].data.pci >= CELL_INFO_MIN && data[i].data.pci <= CELL_PCI_MAX).assertTrue(); expect(data[i].data.mnc >= CELL_INFO_MIN && data[i].data.mnc <= CELL_MNC_MAX).assertTrue(); + expect(data[i].data.bandwidth >= CELL_INFO_MIN && data[i].data.bandwidth <= CELL_MNC_MAX).assertTrue(); + expect(data[i].data.isSupportEndc >= CELL_INFO_MIN && data[i].data.isSupportEndc <= CELL_MNC_MAX).assertTrue(); expect(data[i].data.mcc).assertEqual(CELL_MCC); } else if (data[i].networkType === radio.NETWORK_TYPE_WCDMA) { expect(data[i].data.lac >= CELL_INFO_MIN && data[i].data.lac <= CELL_LAC_TAC_MAX).assertTrue(); @@ -192,6 +227,7 @@ export default function radioSecondJsunit() { expect(data[i].data.uarfcn >= CELL_INFO_MIN && data[i].data.uarfcn <= CELL_ARFCN_MAX).assertTrue(); expect(data[i].data.psc >= CELL_INFO_MIN && data[i].data.psc <= CELL_PSC_MAX).assertTrue(); expect(data[i].data.mnc >= CELL_INFO_MIN && data[i].data.mnc <= CELL_MNC_MAX).assertTrue(); + expect(data[i].data.cpid >= CELL_INFO_MIN && data[i].data.cpid <= CELL_MNC_MAX).assertTrue(); expect(data[i].data.mcc).assertEqual(CELL_MCC); } else if (data[i].networkType === radio.NETWORK_TYPE_GSM) { expect(data[i].data.lac >= CELL_INFO_MIN && data[i].data.lac <= CELL_LAC_TAC_MAX).assertTrue(); @@ -200,9 +236,22 @@ export default function radioSecondJsunit() { expect(data[i].data.bsic >= CELL_INFO_MIN && data[i].data.bsic <= CELL_BSIC_MAX).assertTrue(); expect(data[i].data.mnc >= CELL_INFO_MIN && data[i].data.mnc <= CELL_MNC_MAX).assertTrue(); expect(data[i].data.mcc).assertEqual(CELL_MCC); + } else if (data[i].networkType === radio.NETWORK_TYPE_TDSCDMA) { + expect(data[i].data.baseId >= CELL_INFO_MIN && data[i].data.baseId <= CELL_LAC_TAC_MAX).assertTrue(); + expect(data[i].data.latitude >= CELL_INFO_MIN && data[i].data.latitude <= CELL_GSM_CELLID_MAX).assertTrue(); + expect(data[i].data.longitude >= CELL_INFO_MIN && data[i].data.longitude <= CELL_ARFCN_MAX).assertTrue(); + expect(data[i].data.bsic >= CELL_INFO_MIN && data[i].data.bsic <= CELL_BSIC_MAX).assertTrue(); + expect(data[i].data.nid >= CELL_INFO_MIN && data[i].data.nid <= CELL_MNC_MAX).assertTrue(); + expect(data[i].data.mcc).assertEqual(CELL_MCC); + } else if (data[i].networkType === radio.NETWORK_TYPE_NR) { + expect(data[i].data.nrArfcn >= CELL_INFO_MIN && data[i].data.nrArfcn <= CELL_LAC_TAC_MAX).assertTrue(); + expect(data[i].data.tac >= CELL_INFO_MIN && data[i].data.tac <= CELL_GSM_CELLID_MAX).assertTrue(); + expect(data[i].data.nci >= CELL_INFO_MIN && data[i].data.nci <= CELL_ARFCN_MAX).assertTrue(); + expect(data[i].data.mcc).assertEqual(CELL_MCC); } else { expect().assertFail(); } + } } }) diff --git a/telephony/telephonyjstest/new_add/entry/src/main/ets/MainAbility/test/SimJsunit.test.ets b/telephony/telephonyjstest/new_add/entry/src/main/ets/MainAbility/test/SimJsunit.test.ets index 7707cc9d7d9c0eb09d654327e4ffc212d92640b8..722f5dfb3e207739ca35d3aeecb5350adc1d696e 100644 --- a/telephony/telephonyjstest/new_add/entry/src/main/ets/MainAbility/test/SimJsunit.test.ets +++ b/telephony/telephonyjstest/new_add/entry/src/main/ets/MainAbility/test/SimJsunit.test.ets @@ -41,6 +41,8 @@ export default function simJsunit() { return; } expect(Object.keys(data).length !== containerIsEmpty).assertTrue(); + expect(data.field !== containerIsEmpty).assertTrue(); + expect(data.value !== containerIsEmpty).assertTrue(); console.log('Telephony_Sim_getOperatorConfigs_Async_0100 finish'); done(); }); @@ -72,6 +74,7 @@ export default function simJsunit() { && info.iccId === iccIdValue && info.showName === env.SIM_SLOT_NAME && info.showNumber === env.SIM_SLOT_NUMBER + && info.simId === "simId" ).assertTrue(); console.log(`${CASE_NAME} finish`); done(); @@ -116,7 +119,8 @@ export default function simJsunit() { return; } const CASE_NAME = 'Telephony_Sim_addIccDiallingNumbers_Async_0100'; - sim.addIccDiallingNumbers(env.SLOTID_MINUS1, + var number = env.SLOTID_MINUS1; + sim.addIccDiallingNumbers(number, sim.GENERAL_CONTACT, GENERAL_CONTACT_INFO, error => { diff --git a/telephony/telephonyjstest/new_add/entry/src/main/ets/MainAbility/test/SmsMmsJsunit.test.ets b/telephony/telephonyjstest/new_add/entry/src/main/ets/MainAbility/test/SmsMmsJsunit.test.ets index 70df080efa1ac8dc6093c4eae244d40719261d46..8e5fba7f4cb5cdd93dead2ceb494205c20041251 100644 --- a/telephony/telephonyjstest/new_add/entry/src/main/ets/MainAbility/test/SmsMmsJsunit.test.ets +++ b/telephony/telephonyjstest/new_add/entry/src/main/ets/MainAbility/test/SmsMmsJsunit.test.ets @@ -843,6 +843,7 @@ export default function smsUiJsunit() { done(); }); }); + /* * @tc.number Telephony_SmsMms_getSmsEncodingScheme_Async_0100 * @tc.name @@ -854,13 +855,48 @@ export default function smsUiJsunit() { done(); return; } - expect(sms.SmsEncodingScheme == 0).assertTrue(); + expect(sms.SMS_ENCODING_UNKNOWN == 0).assertTrue(); expect(sms.SMS_ENCODING_7BIT == 1).assertTrue(); expect(sms.SMS_ENCODING_8BIT == 2).assertTrue(); expect(sms.SMS_ENCODING_16BIT == 3).assertTrue(); done(); }); + /* + * @tc.number Telephony_SmsMms_getSendSmsResult_Async_0100 + * @tc.name + * @tc.desc Function test + */ + it('Telephony_SmsMms_getSendSmsResult_Async_0100', 0, async function (done) { + if (true) { + expect(true).assertTrue(); + done(); + return; + } + expect(sms.SEND_SMS_FAILURE_RADIO_OFF == 0).assertTrue(); + expect(sms.SEND_SMS_FAILURE_SERVICE_UNAVAILABLE == 1).assertTrue(); + expect(sms.SIM_MESSAGE_STATUS_FREE == 0).assertTrue(); + expect(sms.INSTANT_MESSAGE == 1).assertTrue(); + expect(sms.OPTIONAL_MESSAGE == 2).assertTrue(); + done(); + }); + + /* + * @tc.number Telephony_SmsMms_ShortMessageClass_Async_0100 + * @tc.name + * @tc.desc Function test + */ + it('Telephony_SmsMms_ShortMessageClass_Async_0100', 0, async function (done) { + if (true) { + expect(true).assertTrue(); + done(); + return; + } + expect(sms.SIM_MESSAGE_STATUS_FREE == 0).assertTrue(); + expect(sms.INSTANT_MESSAGE == 1).assertTrue(); + expect(sms.OPTIONAL_MESSAGE == 2).assertTrue(); + done(); + }); /* * @tc.number Telephony_SmsMms_getMmsCharSets_Async_0100 * @tc.name diff --git a/telephony/telephonyjstest/new_add/entry/src/main/ets/MainAbility/test/StatisticsJsunit.test.ets b/telephony/telephonyjstest/new_add/entry/src/main/ets/MainAbility/test/StatisticsJsunit.test.ets index 1e89921078666526077633446d37aaee269b88b7..8535e83e68597b014713c0240a543ac012b707b1 100644 --- a/telephony/telephonyjstest/new_add/entry/src/main/ets/MainAbility/test/StatisticsJsunit.test.ets +++ b/telephony/telephonyjstest/new_add/entry/src/main/ets/MainAbility/test/StatisticsJsunit.test.ets @@ -59,6 +59,7 @@ export default function statisticsUiJsunit() { statistics.getCellularRxBytes().then((data) => { console.log(`${caseName} get data = ${data.message}:${ data.code}`); expect(data.code >= DATA_0).assertTrue(); + expect(data.rxBytes >= DATA_0).assertTrue(); done(); }).catch((err) => { console.log(`${caseName} get data fail: ${err.message} ${err.code}`); @@ -85,6 +86,7 @@ export default function statisticsUiJsunit() { } console.log(`${caseName} get data: ${data.message} + ${data.code}`); expect(data.code >= DATA_0).assertTrue(); + expect(data.txBytes >= DATA_0).assertTrue(); done(); }); }); @@ -222,6 +224,7 @@ export default function statisticsUiJsunit() { } console.log(`${caseName} get data: ${data.message} + ${data.code}`); expect(data.code >= DATA_0).assertTrue(); + expect(data.rxPackets >= DATA_0).assertTrue(); done(); }); }); @@ -247,6 +250,7 @@ export default function statisticsUiJsunit() { } console.log(`${caseName} get data: ${data.message} + ${data.code}`); expect(data.code >= DATA_0).assertTrue(); + expect(data.txPackets >= DATA_0).assertTrue(); done(); }); });