diff --git a/telephony/telephonyjstest/netmanager_base/dns/Test.json b/telephony/telephonyjstest/netmanager_base/dns/Test.json index e0d8ef8a0d800fc4424af33024108fb8c29d134f..3ad5aa31cfdf9ef66c312400efff3bd1c5f7ddae 100644 --- a/telephony/telephonyjstest/netmanager_base/dns/Test.json +++ b/telephony/telephonyjstest/netmanager_base/dns/Test.json @@ -2,7 +2,7 @@ "description": "Function test of sim manager interface", "driver": { "type": "JSUnitTest", - "test-timeout": "1800000", + "test-timeout": "900000", "package": "com.ohos.dns", "shell-timeout": "60000" }, diff --git a/telephony/telephonyjstest/netmanager_base/jshttp/Test.json b/telephony/telephonyjstest/netmanager_base/jshttp/Test.json index c09c93e8521456fd8678f2a3d90bf070c5bf2b50..05f25c764ae46670f4a5c3dc2cafd6713c044e0a 100644 --- a/telephony/telephonyjstest/netmanager_base/jshttp/Test.json +++ b/telephony/telephonyjstest/netmanager_base/jshttp/Test.json @@ -2,7 +2,7 @@ "description": "Function test of sim manager interface", "driver": { "type": "JSUnitTest", - "test-timeout": "1800000", + "test-timeout": "900000", "package": "com.ohos.jshttp", "shell-timeout": "60000" }, diff --git a/telephony/telephonyjstest/netmanager_base/jshttp/entry/src/main/js/test/NetworkManagerHttp.test.js b/telephony/telephonyjstest/netmanager_base/jshttp/entry/src/main/js/test/NetworkManagerHttp.test.js index 51a68b3f48e6e0b7c77f0447db0521bd3cb53eba..48d0ef01a29904ab78c5c2e0978484985362b8e8 100644 --- a/telephony/telephonyjstest/netmanager_base/jshttp/entry/src/main/js/test/NetworkManagerHttp.test.js +++ b/telephony/telephonyjstest/netmanager_base/jshttp/entry/src/main/js/test/NetworkManagerHttp.test.js @@ -42,7 +42,7 @@ describe('Telephony_NETSTACK_HTTPTest',function(){ let http = netHttp.createHttp() http.request("https://httpbin.org/user-agent").then(function(data){ expect(data.responseCode === netHttp.ResponseCode.OK).assertTrue(); - expect(JSON.parse(data.result)["user-agent"] === "libcurl-agent/1.0").assertTrue(); + expect(JSON.parse(data.result)["user-agent"] != undefined).assertTrue(); done(); }) }); diff --git a/telephony/telephonyjstest/netmanager_base/network_nopermission/Test.json b/telephony/telephonyjstest/netmanager_base/network_nopermission/Test.json index d7233dc4ef835a9676ac2a8fedcd2104216ce0a0..79882ec7b93e4c975671840862463134c9e1aec4 100644 --- a/telephony/telephonyjstest/netmanager_base/network_nopermission/Test.json +++ b/telephony/telephonyjstest/netmanager_base/network_nopermission/Test.json @@ -2,7 +2,7 @@ "description": "Function test of sim manager interface", "driver": { "type": "JSUnitTest", - "test-timeout": "1800000", + "test-timeout": "900000", "package": "com.ohos.network_nopermission", "shell-timeout": "60000" }, diff --git a/telephony/telephonyjstest/netmanager_base/network_wifi/Test.json b/telephony/telephonyjstest/netmanager_base/network_wifi/Test.json index 61ebec364ea70f6f580ab07d6235e817ddbfc1ab..b0b262dd1125811932f5ca640048193a07576e9a 100644 --- a/telephony/telephonyjstest/netmanager_base/network_wifi/Test.json +++ b/telephony/telephonyjstest/netmanager_base/network_wifi/Test.json @@ -2,7 +2,7 @@ "description": "Function test of sim manager interface", "driver": { "type": "JSUnitTest", - "test-timeout": "1800000", + "test-timeout": "900000", "package": "com.ohos.network_wifi", "shell-timeout": "60000" }, diff --git a/telephony/telephonyjstest/netmanager_base/register/entry/src/main/js/test/NetworkManagerRegister.test.js b/telephony/telephonyjstest/netmanager_base/register/entry/src/main/js/test/NetworkManagerRegister.test.js index 1e4f84680c4841794adad0c345d1d9bb4c23085e..e408e70301bd0e197d17f805c9d66faa44da6914 100644 --- a/telephony/telephonyjstest/netmanager_base/register/entry/src/main/js/test/NetworkManagerRegister.test.js +++ b/telephony/telephonyjstest/netmanager_base/register/entry/src/main/js/test/NetworkManagerRegister.test.js @@ -40,6 +40,9 @@ function sleepOther(timeout) { for (var t = Date.now(); Date.now() - t <= timeout;) ; } + function sleep(time) { + return new Promise((resolve)=>setTimeout(resolve,time)); + } /** *@tc.number Telephony_NetworkManager_register_Async_0100 @@ -229,13 +232,13 @@ console.info(`${caseName} netBlockStatusChange handle = :` + value.handle.netId); } }); - netConn.on('netBlockStatusChange', (error, value) => { + netConn.on('netCapabilitiesChange', (error, value) => { if (error) { console.info(`${caseName} register fail: ${error}`); expect().assertFail(); done(); } else { - console.info(`${caseName} netBlockStatusChange handle = :` + value.handle.netId); + console.info(`${caseName} netCapabilitiesChange handle = :` + value.handle.netId); } }); netConn.on('netConnectionPropertiesChange', (error, value) => { @@ -1565,8 +1568,8 @@ } let netId = 0; let netConn = connection.createNetConnection(netSpecifier, TIMEOUT); - netConn.on('netAvailable', (error, value) => { - if (error) { + netConn.on('netAvailable', (value) => { + if (value === undefined) { console.info(`${caseName} register fail: ${error}`); expect().assertFail(); done(); @@ -1724,8 +1727,8 @@ }, bearerPrivateIdentifier: '123' } let netConn = connection.createNetConnection(netSpecifier, TIMEOUT); - netConn.on('netAvailable', (error, value) => { - if (error) { + netConn.on('netAvailable', (value) => { + if (value === undefined) { console.info(`${caseName} register fail: ${error}`); expect().assertFail(); done(); @@ -1862,8 +1865,8 @@ } let netId = 0; let netConn = connection.createNetConnection(netSpecifier, TIMEOUT); - netConn.on('netAvailable', (error, value) => { - if (error) { + netConn.on('netAvailable', ( value) => { + if (value === undefined) { console.info(`${caseName} register fail: ${error}`); expect().assertFail(); done(); @@ -2028,8 +2031,8 @@ } let netId = 0; let netConn = connection.createNetConnection(netSpecifier, TIMEOUT); - netConn.on('netAvailable', (error, value) => { - if (error) { + netConn.on('netAvailable', (value) => { + if (value === undefined) { console.info(`${caseName} register fail: ${error}`); expect().assertFail(); done(); @@ -2258,8 +2261,8 @@ }, bearerPrivateIdentifier: '123' } let netConn = connection.createNetConnection(netSpecifier, TIMEOUT_1); - netConn.on('netAvailable', (error, value) => { - if (error) { + netConn.on('netAvailable', (value) => { + if (value === undefined) { console.info(`${caseName} register fail: ${error}`); expect().assertFail(); done(); @@ -2323,6 +2326,7 @@ console.info(`${caseName} register fail ${error}`); } }); + await sleep(1000); netConn.unregister((error) => { if (error) { console.info(`${caseName} unregister result : ${error}`); @@ -2345,8 +2349,8 @@ it('Telephony_NetworkManager_unregister_Async_0200', 0, async function (done) { let caseName = 'Telephony_NetworkManager_unregister_Async_0200'; let netConn = connection.createNetConnection(); - netConn.on('netAvailable', (error, value) => { - if (error) { + netConn.on('netAvailable', (value) => { + if (value === undefined) { console.info(`${caseName} register fail: ${error}`); expect().assertFail(); done(); @@ -2410,6 +2414,7 @@ console.info(`${caseName} register fail ${error}`); } }); + await sleep(1000); netConn.unregister((error) => { if (error) { console.info(`${caseName} unregister result : ${error}`); @@ -2431,8 +2436,8 @@ it('Telephony_NetworkManager_unregister_Async_0300', 0, async function (done) { let caseName = 'Telephony_NetworkManager_unregister_Async_0300'; let netConn = connection.createNetConnection(); - netConn.on('netAvailable', (error, value) => { - if (error) { + netConn.on('netAvailable', (value) => { + if (value === undefined) { console.info(`${caseName} register fail: ${error}`); expect().assertFail(); done(); @@ -2491,6 +2496,12 @@ done(); } }); + netConn.register((error) => { + if (error) { + console.info(`${caseName} register fail ${error}`); + } + }); + await sleep(1000); netConn.unregister((error) => { if (error) { console.info(`${caseName} unregister result : ${error}`); diff --git a/telephony/telephonyjstest/netmanager_base/socket/entry/src/main/js/test/NetStackSocket.test.js b/telephony/telephonyjstest/netmanager_base/socket/entry/src/main/js/test/NetStackSocket.test.js index f92d99872e3bca1705eb0e5d5dabcebd14346c28..eab96e66eb343b1479664edbee08812e8d0a65b1 100644 --- a/telephony/telephonyjstest/netmanager_base/socket/entry/src/main/js/test/NetStackSocket.test.js +++ b/telephony/telephonyjstest/netmanager_base/socket/entry/src/main/js/test/NetStackSocket.test.js @@ -227,18 +227,26 @@ describe('Telephony_NETSTACK_SocketTest', function () { it('Telephony_NetStack_UDPTest1200', 0, function (done) { let udp = netSocket.constructUDPSocketInstance() + udp.on('message', function () { + }) udp.off('message', function () { expect().assertFail() done() }) + udp.on('listening', function () { + }) udp.off('listening', function () { expect().assertFail() done() }) + udp.on('close', function () { + }) udp.off('close', function () { expect().assertFail() done() }) + udp.on('error', function () { + }) udp.off('error', function () { expect().assertFail() done() @@ -246,9 +254,6 @@ describe('Telephony_NETSTACK_SocketTest', function () { done() }); - - - /** * @tc.number Telephony_NetStack_TCPTest0100 * @tc.name TCP bind,callback方式,预计无异常,错误码为undefined @@ -423,7 +428,7 @@ describe('Telephony_NETSTACK_SocketTest', function () { expect().assertFail() done() }) - tcp.on('listening', function () { + tcp.on('connect', function () { expect().assertFail() done() }) @@ -446,18 +451,26 @@ describe('Telephony_NETSTACK_SocketTest', function () { it('Telephony_NetStack_TCPTest1200', 0, function (done) { let tcp = netSocket.constructTCPSocketInstance() + tcp.on('message', function () { + }) tcp.off('message', function () { expect().assertFail() done() }) - tcp.off('listening', function () { + tcp.on('connect', function () { + }) + tcp.off('connect', function () { expect().assertFail() done() }) + tcp.on('close', function () { + }) tcp.off('close', function () { expect().assertFail() done() }) + tcp.on('error', function () { + }) tcp.off('error', function () { expect().assertFail() done() diff --git a/telephony/telephonyjstest/netmanager_base/system_fetch/Test.json b/telephony/telephonyjstest/netmanager_base/system_fetch/Test.json index 08058699b9ec9664911c956b61d707c3d3a45305..3ccd069b60940bd4dc345d6bc05edf61c2e8ed79 100644 --- a/telephony/telephonyjstest/netmanager_base/system_fetch/Test.json +++ b/telephony/telephonyjstest/netmanager_base/system_fetch/Test.json @@ -2,7 +2,7 @@ "description": "Function test of sim manager interface", "driver": { "type": "JSUnitTest", - "test-timeout": "1800000", + "test-timeout": "900000", "package": "com.ohos.system_fetch", "shell-timeout": "60000" }, diff --git a/telephony/telephonyjstest/netmanager_base/system_fetch/entry/src/main/js/test/Http.fetch.test.js b/telephony/telephonyjstest/netmanager_base/system_fetch/entry/src/main/js/test/Http.fetch.test.js index 127dd2339aa0c969e09a1ab9e104633e066ba58e..59ffb28ab96ae12952d9c4022e925d08cf357abe 100644 --- a/telephony/telephonyjstest/netmanager_base/system_fetch/entry/src/main/js/test/Http.fetch.test.js +++ b/telephony/telephonyjstest/netmanager_base/system_fetch/entry/src/main/js/test/Http.fetch.test.js @@ -44,7 +44,7 @@ describe("Telephony_NetStack_HttpTest", function () { http.request("https://httpbin.org/user-agent").then(function(data){ console.info("NetStack "+ JSON.stringify(data)); expect(data.responseCode === NetHttp.ResponseCode.OK).assertTrue() - expect(JSON.parse(data.result)["user-agent"] === "libcurl-agent/1.0").assertTrue() + expect(JSON.parse(data.result)["user-agent"] != undefined).assertTrue() done(); }) }); @@ -174,7 +174,7 @@ describe("Telephony_NetStack_HttpTest", function () { success : function(data){ console.info("NetStack fetch success "+ JSON.stringify(data)) expect(data.code === 200).assertTrue() - expect(JSON.parse(data.data)["user-agent"] === "libcurl-agent/1.0").assertTrue() + expect(JSON.parse(data.data)["user-agent"] != undefined).assertTrue() done(); }, fail : function(){ @@ -200,7 +200,7 @@ describe("Telephony_NetStack_HttpTest", function () { success : function(data){ console.info("NetStack fetch success "+ JSON.stringify(data)) expect(data.code === 200).assertTrue() - expect(data.data["user-agent"] === "libcurl-agent/1.0").assertTrue() + expect(data.data["user-agent"] != undefined).assertTrue() done(); }, fail : function(){ diff --git a/telephony/telephonyjstest/netmanager_http/entry/src/main/ets/MainAbility/test/HttpJsunit.test.ets b/telephony/telephonyjstest/netmanager_http/entry/src/main/ets/MainAbility/test/HttpJsunit.test.ets index 4cbee959711b9f5ee298339f27a86dc791d8ee19..ff5ce75d8568f91c302a5a113927506a0a193e42 100644 --- a/telephony/telephonyjstest/netmanager_http/entry/src/main/ets/MainAbility/test/HttpJsunit.test.ets +++ b/telephony/telephonyjstest/netmanager_http/entry/src/main/ets/MainAbility/test/HttpJsunit.test.ets @@ -13,6 +13,7 @@ * limitations under the License. */ import {describe, beforeAll, afterAll, it, expect, afterEach} from 'deccjsunit/index'; +import connection from '@ohos.net.connection'; import http from '@ohos.net.http'; export default function httpJsunit() { @@ -24,8 +25,7 @@ export default function httpJsunit() { */ it("Telephony_Http_Http_createHttp_0100", 0, async function (done) { console.log("-----------------------http createHttp Test is starting-----------------------"); - var httpRequest = http.createHttp(); - expect(httpRequest != null).assertTrue(); + expect(connection.HttpRequest != undefined).assertFalse(); console.log("-----------------------http createHttp Test end-----------------------"); done(); }); 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 7df7bd96efe0f0ff48bd5c10edd9e10ec1355a46..85accd9ad4bd8cd1cad1219e27a444075f79f83c 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 @@ -417,6 +417,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_0600" + 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_0700'; + 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_0700" + 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_0800'; + 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_0800" + 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/MainAbility/test/ResponseCodeJsunit.test.ets b/telephony/telephonyjstest/netmanager_http/entry/src/main/ets/MainAbility/test/ResponseCodeJsunit.test.ets index 23ef89283f39e57bb4b122588ecf277aecf5e60f..c6674b2b76576130befbd74b098bc6cacab469b7 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 @@ -600,7 +600,59 @@ 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_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_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(); + } + }); }) }; diff --git a/telephony/telephonyjstest/netmanager_socket/entry/src/main/ets/MainAbility/test/ConnectionSecondJsUnit.test.ets b/telephony/telephonyjstest/netmanager_socket/entry/src/main/ets/MainAbility/test/ConnectionSecondJsUnit.test.ets index 98fdbb3281d6e801d7388cd885d3f52ff06693f3..ba7d6db4884ce4113ca4f11b279b3b6b2a7a01a7 100644 --- a/telephony/telephonyjstest/netmanager_socket/entry/src/main/ets/MainAbility/test/ConnectionSecondJsUnit.test.ets +++ b/telephony/telephonyjstest/netmanager_socket/entry/src/main/ets/MainAbility/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/MainAbility/test/SocketJsunit.test.ets b/telephony/telephonyjstest/netmanager_socket/entry/src/main/ets/MainAbility/test/SocketJsunit.test.ets index bb4a2e588b96aa6d4f8878ee82ce5be95cfac5a3..9479d0d5c4e21ab5f1a86a35cfd0f47a7fd46ddb 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 @@ -15,6 +15,7 @@ */ import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'; +import connection from '@ohos.net.connection'; import socket from '@ohos.net.socket' import utils from './Utils.ets' @@ -31,8 +32,7 @@ export default function socketJsunit() { */ it('Telephony_Socket_Socket_constructUDPSocketInstance_0100', 0, function (done) { console.log("************* Telephony_Socket_Socket_constructUDPSocketInstance_0100 Test start*************"); - var udpSocket = udp; - expect(udpSocket != null).assertTrue(); + expect(connection.UDPSocket != undefined).assertFalse(); console.log("************* Telephony_Socket_Socket_constructUDPSocketInstance_0100 Test end*************"); done(); }) @@ -44,8 +44,7 @@ export default function socketJsunit() { */ it('Telephony_Socket_Socket_constructTCPSocketInstance_0100', 0, function (done) { console.log("************* Telephony_Socket_Socket_constructTCPSocketInstance_0100 Test start*************"); - var tcpSocket = tcp; - expect(tcpSocket != null).assertTrue(); + expect(connection.TCPSocket != undefined).assertFalse(); console.log("************* Telephony_Socket_Socket_constructTCPSocketInstance_0100 Test end*************"); done(); }) 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 b5f4d9049c581b080e6d8f6cc5644a5f9b7801fe..e03e162683fa113670eece5ddcb83da6db231dbc 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(); @@ -116,6 +117,7 @@ describe('ActsNetworkSearchTest', function () { expect(data.isRoaming != true).assertTrue(); expect(data.regState != radio.REG_STATE_IN_SERVICE).assertTrue(); expect(data.nsaState != radio.NSA_STATE_SA_ATTACHED).assertTrue(); + expect(data.isEmergency != true).assertTrue(); expect(data.isCaActive != 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 020c7833a5516870594ffec9078c1f2a725f4e59..68c13f2e63d0aea93920045031592e68ed2412ab 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 @@ -17,6 +17,7 @@ import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from ' import observer from '@ohos.telephony.observer' import cellular from '@ohos.telephony.data' import radio from '@ohos.telephony.radio' +import call from '@ohos.telephony.call' import utils from './Utils.ets' import {SimStateData} from '@ohos.telephony.observer' import {LockReason} from '@ohos.telephony.observer' @@ -37,6 +38,11 @@ export default function observerJsunit() { */ it('Telephony_observer_observer_DataConnectState_0100', 0, function (done) { console.log("************* Telephony_observer_observer_DataConnectState_0100 Test start *************") + 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(); cellular.getCellularDataState((err, data) => { if (!err) { var dataConnectStateList = [cellular.DataConnectState.DATA_STATE_UNKNOWN, @@ -553,11 +559,59 @@ 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 +623,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 +639,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 +655,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 +671,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 +687,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 +703,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 +719,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 +735,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 +751,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 *************") }) diff --git a/telephony/telephonyjstest/radiostatistic/entry/src/main/ets/MainAbility/test/SmsMmsJsunit.test.ets b/telephony/telephonyjstest/radiostatistic/entry/src/main/ets/MainAbility/test/SmsMmsJsunit.test.ets index d5bdae5579733ad9cde19a273d1df1fd5f73080e..215d2a3ae6f4a4fffb92c0d9d097a5fe51f64297 100644 --- a/telephony/telephonyjstest/radiostatistic/entry/src/main/ets/MainAbility/test/SmsMmsJsunit.test.ets +++ b/telephony/telephonyjstest/radiostatistic/entry/src/main/ets/MainAbility/test/SmsMmsJsunit.test.ets @@ -17,7 +17,7 @@ import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from " import mms from '@ohos.telephony.sms'; import utils from './Utils.ets' export default function smsUiJsunit() { - describe('appInfoTest', function () { + describe('SmsMmsTest', function () { const SMS_SEND_DST_NUMBER = ''; const TRUE_SLOT_ID = 0; diff --git a/telephony/telephonyjstest/sim/sim_manager_function_test/entry/src/main/js/test/SimManager.test.js b/telephony/telephonyjstest/sim/sim_manager_function_test/entry/src/main/js/test/SimManager.test.js index 440500e88fb6c7cae7358f8d02633fad3511ca28..04755b1ec37cc5f57f1e94e16836f41a1468fce8 100644 --- a/telephony/telephonyjstest/sim/sim_manager_function_test/entry/src/main/js/test/SimManager.test.js +++ b/telephony/telephonyjstest/sim/sim_manager_function_test/entry/src/main/js/test/SimManager.test.js @@ -403,10 +403,10 @@ describe('SimManagerTest', function () { */ it('Telephony_Sim_hasOperatorPrivileges_Async_0400', 0, function (done) { const CASE_NAME = 'Telephony_Sim_hasOperatorPrivileges_Async_0400'; - sim.hasOperatorPrivileges(env.SLOTID2, (error, result) => { - if (error) { - console.log(`${CASE_NAME} hasOperatorPrivileges error: ${error.message}`); - expect().assertFail(); + sim.hasOperatorPrivileges(env.SLOTID2, (err, result) => { + if (err) { + console.log(`${CASE_NAME} hasOperatorPrivileges err: ${err.message}`); + expect(err.code).assertEqual(202); done(); return; } @@ -430,7 +430,7 @@ describe('SimManagerTest', function () { console.log(`${CASE_NAME} test finish.`); } catch (error) { console.log(`${CASE_NAME} hasOperatorPrivileges error: ${error.message}`); - expect().assertFail(); + expect(err.code).assertEqual(202); } done(); });