diff --git a/telephony/telephonyjstest/BUILD.gn b/telephony/telephonyjstest/BUILD.gn index f3a1e49585171788469a2916b2606f5edd50c3f6..c5e3af1f1f81d29bb09878f73b8add7dec7d366d 100644 --- a/telephony/telephonyjstest/BUILD.gn +++ b/telephony/telephonyjstest/BUILD.gn @@ -21,4 +21,4 @@ group("telephonyjstest") { "sim:sim", "sms_mms:sms_mms", ] -} +} \ No newline at end of file diff --git a/telephony/telephonyjstest/call_manager/BUILD.gn b/telephony/telephonyjstest/call_manager/BUILD.gn index 37ac56a6913e60b3606fa87204165ec6e15c5a90..09e70c37b632ce2dd0e1cd77186c407c3a89c26e 100644 --- a/telephony/telephonyjstest/call_manager/BUILD.gn +++ b/telephony/telephonyjstest/call_manager/BUILD.gn @@ -22,4 +22,4 @@ group("call_manager") { "call_manager_test:CallManagerTest", ] } -} +} \ No newline at end of file diff --git a/telephony/telephonyjstest/call_manager/call_manager_mmi/BUILD.gn b/telephony/telephonyjstest/call_manager/call_manager_mmi/BUILD.gn index 00dd34b21793157d052ae5f4e530a87b7f142463..581030482f9b78c4bc589f8d14c2b25c77e9fdd0 100644 --- a/telephony/telephonyjstest/call_manager/call_manager_mmi/BUILD.gn +++ b/telephony/telephonyjstest/call_manager/call_manager_mmi/BUILD.gn @@ -28,4 +28,4 @@ ohos_js_assets("hjs_demo_js_assets") { ohos_resources("hjs_demo_resources") { sources = [ "./entry/src/main/js/resources" ] hap_profile = "./entry/src/main/config.json" -} +} \ No newline at end of file diff --git a/telephony/telephonyjstest/call_manager/call_manager_mmi/entry/src/main/js/test/CallManagerMMI.test.js b/telephony/telephonyjstest/call_manager/call_manager_mmi/entry/src/main/js/test/CallManagerMMI.test.js index 89d4fa8039673025157337f835a0c7bff28135c6..adf06755145419e6ba99f9f4e80657053f11a1c7 100644 --- a/telephony/telephonyjstest/call_manager/call_manager_mmi/entry/src/main/js/test/CallManagerMMI.test.js +++ b/telephony/telephonyjstest/call_manager/call_manager_mmi/entry/src/main/js/test/CallManagerMMI.test.js @@ -27,6 +27,7 @@ describe('CallManagerMMI', function () { it('Telephony_CallManager_MMI_Async_0100', 0, async function (done) { call.dial('**21*12599*10#', (err, data) => { if (err) { + expect().assertFail(); console.log('Telephony_CallManager_MMI_Async_0100 fail'); done(); return; @@ -34,16 +35,17 @@ describe('CallManagerMMI', function () { expect(data).assertTrue(); console.log('Telephony_CallManager_MMI_Async_0100 finish data = ' + data); done(); - }) - call.dial('##002#', (err, data) => { - if (err) { - console.log('Telephony_CallManager_MMI_Async_0100 fail'); + call.dial('##002#', (err, data) => { + if (err) { + expect().assertFail(); + console.log('Telephony_CallManager_MMI_Async_0100 fail'); + done(); + return; + } + expect(data).assertTrue(); + console.log('Telephony_CallManager_MMI_Async_0100 finish data = ' + data); done(); - return; - } - expect(data).assertTrue(); - console.log('Telephony_CallManager_MMI_Async_0100 finish data = ' + data); - done(); + }) }) }) @@ -56,22 +58,24 @@ describe('CallManagerMMI', function () { it('Telephony_CallManager_MMI_Async_0200', 0, async function (done) { call.dial('**33*0000#', (err, data) => { if (err) { + expect().assertFail(); console.log('Telephony_CallManager_MMI_Async_0200 fail'); done(); return; } expect(data).assertTrue(); console.log('Telephony_CallManager_MMI_Async_0200 finish data = ' + data); - }) - call.dial('#33*0000#', (err, data) => { - if (err) { - console.log('Telephony_CallManager_MMI_Async_0200 fail'); + call.dial('#33*0000#', (err, data) => { + if (err) { + expect().assertFail(); + console.log('Telephony_CallManager_MMI_Async_0200 fail'); + done(); + return; + } + expect(data).assertTrue(); + console.log('Telephony_CallManager_MMI_Async_0200 finish data = ' + data); done(); - return; - } - expect(data).assertTrue(); - console.log('Telephony_CallManager_MMI_Async_0200 finish data = ' + data); - done(); + }) }) }) @@ -84,22 +88,24 @@ describe('CallManagerMMI', function () { it('Telephony_CallManager_MMI_Async_0300', 0, async function (done) { call.dial('*331*0000#', (err, data) => { if (err) { + expect().assertFail(); console.log('Telephony_CallManager_MMI_Async_0300 fail'); done(); return; } expect(data).assertTrue(); console.log('Telephony_CallManager_MMI_Async_0300 finish data = ' + data); - }) - call.dial('#331#0000#', (err, data) => { - if (err) { - console.log('Telephony_CallManager_MMI_Async_0300 fail'); + call.dial('#331#0000#', (err, data) => { + if (err) { + expect().assertFail(); + console.log('Telephony_CallManager_MMI_Async_0300 fail'); + done(); + return; + } + expect(data).assertTrue(); + console.log('Telephony_CallManager_MMI_Async_0300 finish data = ' + data); done(); - return; - } - expect(data).assertTrue(); - console.log('Telephony_CallManager_MMI_Async_0300 finish data = ' + data); - done(); + }) }) }) @@ -112,6 +118,7 @@ describe('CallManagerMMI', function () { it('Telephony_CallManager_MMI_Async_0400', 0, async function (done) { call.dial('#35*0000#', (err, data) => { if (err) { + expect().assertFail(); console.log('Telephony_CallManager_MMI_Async_0400 fail'); done(); return; @@ -132,12 +139,12 @@ describe('CallManagerMMI', function () { var data = await call.dial('##330*0000#'); expect(data).assertTrue(); console.log('Telephony_CallManager_MMI_Promise_0100 finish data = ' + data); + done(); } catch (err) { console.log('Telephony_CallManager_MMI_Promise_0100 fail'); expect().assertFail(); done(); } - done(); }) /* @@ -151,12 +158,12 @@ describe('CallManagerMMI', function () { var data = await call.dial('*#330#0000#'); expect(data).assertTrue(); console.log('Telephony_CallManager_MMI_Promise_0200 finish data = ' + data); + done(); } catch (err) { expect().assertFail(); console.log('Telephony_CallManager_MMI_Promise_0200 fail'); done(); } - done(); }) /* @@ -169,12 +176,12 @@ describe('CallManagerMMI', function () { var data = await call.dial('*#31#'); expect(data).assertTrue(); console.log('Telephony_CallManager_MMI_Promise_0300 finish data = ' + data); + done(); } catch (err) { expect().assertFail(); console.log('Telephony_CallManager_MMI_Promise_0300 fail'); done(); } - done(); }) /* @@ -191,16 +198,17 @@ describe('CallManagerMMI', function () { expect().assertFail(); console.log('Telephony_CallManager_MMI_Promise_0400 fail'); done(); + return; } try { var data = await call.dial('*31#'); expect(data).assertTrue(); console.log('Telephony_CallManager_MMI_Promise_0400 finish data = ' + data); + done(); } catch (err) { expect().assertFail(); console.log('Telephony_CallManager_MMI_Promise_0400 fail'); done(); } - done(); }) }) diff --git a/telephony/telephonyjstest/call_manager/call_manager_on_dail/BUILD.gn b/telephony/telephonyjstest/call_manager/call_manager_on_dail/BUILD.gn index 27f9b3925cfdc420c151cf6e2729afa724b017eb..f16051c0c96367c33f4a1b8b6e0fd3e831eca6a7 100644 --- a/telephony/telephonyjstest/call_manager/call_manager_on_dail/BUILD.gn +++ b/telephony/telephonyjstest/call_manager/call_manager_on_dail/BUILD.gn @@ -28,4 +28,4 @@ ohos_js_assets("hjs_demo_js_assets") { ohos_resources("hjs_demo_resources") { sources = [ "./entry/src/main/js/resources" ] hap_profile = "./entry/src/main/config.json" -} +} \ No newline at end of file diff --git a/telephony/telephonyjstest/call_manager/call_manager_on_dail/entry/src/main/js/test/CallManagerOnDail.test.js b/telephony/telephonyjstest/call_manager/call_manager_on_dail/entry/src/main/js/test/CallManagerOnDail.test.js index 8953ca0142dbc1b87676681e3eca43446e0d40c2..1c48a112a515a7a1d2949b559af7fb5d3f398754 100644 --- a/telephony/telephonyjstest/call_manager/call_manager_on_dail/entry/src/main/js/test/CallManagerOnDail.test.js +++ b/telephony/telephonyjstest/call_manager/call_manager_on_dail/entry/src/main/js/test/CallManagerOnDail.test.js @@ -15,17 +15,32 @@ import call from '@ohos.telephony.call'; import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'; + +class RejectMessageOptions { + constructor(str){ + this.messageContent = str; + } +} + describe('CallManagerOnDial', function () { - const TEST_PHONY_NUMBER = '10086'; + + const GETMAIN_CALLID_ERRO = -1; + const timeOut = 20000; + const waitTime = 200; + const INVALID_NUMBER = ''; + const CALLMANAGER_TEST_PHONY_NUMBER = ''; + const THE_THREE_NUMBER = ''; + const EIGHTEEN_DIGITS = ''; + const WITH_LETTER_NUMBER = ''; + const EIGHT_NUMBER = ''; + const EIGHT_NUMBER_WITH_AN_AREA_CODE = ''; + const REJECT_MESSAGE_NUM = 1234567890123456789012345678901234567890; + const REJECT_MESSAGE_STR = 'Hi,你好呀?'; var callId = 0; var callState = -1; - var timeOut = 0; + var timing = 0; var endTime = 0; - var onTime = 25000; - var newCallId = 0 - var waitTime = 200; - const INVALID_NUMBER = '13800000000' - const GETMAIN_CALLID_ERRO = -1; + var newCallId = 0; const sleep = (time) => { return new Promise((resolve, reject) => { @@ -38,6 +53,7 @@ describe('CallManagerOnDial', function () { beforeAll(async function () { call.on('callDetailsChange', (err, callStateInfo) => { if (err) { + expect().assertFail(); console.log('Telephony_CallManager_on_Async fail err = ' + err); return; } @@ -50,6 +66,7 @@ describe('CallManagerOnDial', function () { afterAll(async function () { call.off('callDetailsChange', (err) => { if (err) { + expect().assertFail(); console.log('Telephony_CallManager_off_Async fail err = ' + err); } }) @@ -57,6 +74,7 @@ describe('CallManagerOnDial', function () { afterEach(async function () { const startTime = new Date().getTime(); + let flag = false; while(true){ if (callId > newCallId) { if (callState === call.CALL_STATUS_DISCONNECTED) { @@ -64,19 +82,25 @@ describe('CallManagerOnDial', function () { } newCallId = callId console.log('Telephony_CallManager_hangup_Async callId = ' + callId); - call.hangup(callId, async (err) => { + call.hangup(callId, (err) => { if (err) { + expect().assertFail(); console.log('Telephony_CallManager_hangup_Async fail err = ' + err); return; } console.log('Telephony_CallManager_hangup_Async finish'); - return; + flag = true; }) + if(flag) + { + return; + } } await sleep(waitTime); endTime = new Date().getTime(); - timeOut = endTime - startTime; - if (timeOut > onTime) { + timing = endTime - startTime; + if (timing > timeOut) { + expect().assertFail(); console.log("Telephony_CallManager_hangup is out of time"); break; @@ -86,12 +110,12 @@ describe('CallManagerOnDial', function () { /* * @tc.number Telephony_CallManager_dial_Async_0100 - * @tc.name Set the mandatory phone number to a normal number (10086) and call dial() as a callback, - * returning :true + * @tc.name Set the mandatory phone number to a normal number (CALLMANAGER_TEST_PHONY_NUMBER) and call dial() as + * a callback,returning :true * @tc.desc Function test */ it('Telephony_CallManager_dial_Async_0100', 0, async function (done) { - call.dial(TEST_PHONY_NUMBER, (err, data) => { + call.dial(CALLMANAGER_TEST_PHONY_NUMBER, (err, data) => { if (err) { console.log('Telephony_CallManager_dial_Async_0100 fail' + err); expect().assertFail(); @@ -103,14 +127,16 @@ describe('CallManagerOnDial', function () { }) const startTime = new Date().getTime(); while (true) { - if (callState === call.CALL_STATUS_DIALING || callState === call.CALL_STATUS_ACTIVE) { + if (callState === call.CALL_STATUS_DIALING || callState === call.CALL_STATUS_ACTIVE || + callState === call.CALL_STATUS_ALERTING) { done(); return; } await sleep(waitTime); endTime = new Date().getTime(); - timeOut = endTime - startTime; - if (timeOut > onTime) { + timing = endTime - startTime; + if (timing > timeOut) { + expect().assertFail(); done(); break; } @@ -127,6 +153,7 @@ describe('CallManagerOnDial', function () { call.dial('10086,1234567890123456789123', { accountId: 0 }, (err, data) => { if (err) { console.log('Telephony_CallManager_dial_Async_0400 fail err = ' + err); + expect().assertFail(); done(); return; } @@ -136,14 +163,16 @@ describe('CallManagerOnDial', function () { }) const startTime = new Date().getTime(); while (true) { - if (callState === call.CALL_STATUS_DIALING || callState === call.CALL_STATUS_ACTIVE) { + if (callState === call.CALL_STATUS_DIALING || callState === call.CALL_STATUS_ACTIVE || + callState === call.CALL_STATUS_ALERTING) { done(); return; } await sleep(waitTime); endTime = new Date().getTime(); - timeOut = endTime - startTime; - if (timeOut > onTime) { + timing = endTime - startTime; + if (timing > timeOut) { + expect().assertFail(); done(); break; } @@ -152,12 +181,12 @@ describe('CallManagerOnDial', function () { /* * @tc.number Telephony_CallManager_dial_Async_0500 - * @tc.name Set the mandatory phone number to an invalid number (abcDE123456), + * @tc.name Set the mandatory phone number to an invalid number (WITH_LETTER_NUMBER), * call dial() in callback mode, and return :true * @tc.desc Function test */ it('Telephony_CallManager_dial_Async_0500', 0, async function (done) { - call.dial('abcde123456', (err, data) => { + call.dial(WITH_LETTER_NUMBER, (err, data) => { if (err) { console.log('Telephony_CallManager_dial_Async_0500 fail err = ' + err); expect().assertFail(); @@ -169,14 +198,16 @@ describe('CallManagerOnDial', function () { }) const startTime = new Date().getTime(); while (true) { - if (callState === call.CALL_STATUS_DIALING || callState === call.CALL_STATUS_ACTIVE) { + if (callState === call.CALL_STATUS_DIALING || callState === call.CALL_STATUS_ACTIVE || + callState === call.CALL_STATUS_ALERTING) { done(); return; } await sleep(waitTime); endTime = new Date().getTime(); - timeOut = endTime - startTime; - if (timeOut > onTime) { + timing = endTime - startTime; + if (timing > timeOut) { + expect().assertFail(); done(); break; } @@ -185,14 +216,14 @@ describe('CallManagerOnDial', function () { /* * @tc.number Telephony_CallManager_dial_Async_0800 - * @tc.name Set the mandatory phone number to a normal number (10086) and the optional parameters options - * to {accountId: 0, videoState: 0, dialScene: 0, dialType: 0}. Dial () in callback mode and return - * :true + * @tc.name Set the mandatory phone number to a normal number (WITH_LETTER_NUMBER) and the optional parameters + * options to {accountId: 0, videoState: 0, dialScene: 0, dialType: 0}. Dial () in callback mode and + * return :true * @tc.desc Function test */ it('Telephony_CallManager_dial_Async_0800', 0, async function (done) { let obj = { accountId: 0, videoState: 0, dialScene: 0, dialType: 0 }; - call.dial('abcedf123456', obj, (err, data) => { + call.dial(WITH_LETTER_NUMBER, obj, (err, data) => { if (err) { expect().assertFail(); console.log('Telephony_CallManager_dial_Async_0800 fail err = ' + err); @@ -204,14 +235,16 @@ describe('CallManagerOnDial', function () { }) const startTime = new Date().getTime(); while (true) { - if (callState === call.CALL_STATUS_DIALING || callState === call.CALL_STATUS_ACTIVE) { + if (callState === call.CALL_STATUS_DIALING || callState === call.CALL_STATUS_ACTIVE || + callState === call.CALL_STATUS_ALERTING) { done(); return; } await sleep(waitTime); endTime = new Date().getTime(); - timeOut = endTime - startTime; - if (timeOut > onTime) { + timing = endTime - startTime; + if (timing > timeOut) { + expect().assertFail(); done(); break; } @@ -236,14 +269,16 @@ describe('CallManagerOnDial', function () { }) const startTime = new Date().getTime(); while (true) { - if (callState === call.CALL_STATUS_DIALING || callState === call.CALL_STATUS_ACTIVE) { + if (callState === call.CALL_STATUS_DIALING || callState === call.CALL_STATUS_ACTIVE || + callState === call.CALL_STATUS_ALERTING) { done(); return; } await sleep(waitTime); endTime = new Date().getTime(); - timeOut = endTime - startTime; - if (timeOut > onTime) { + timing = endTime - startTime; + if (timing > timeOut) { + expect().assertFail(); done(); break; } @@ -252,13 +287,14 @@ describe('CallManagerOnDial', function () { /* * @tc.number Telephony_CallManager_dial_Async_1300 - * @tc.name Set the mandatory phone number to a normal number (112) and the optional parameters options to - * {accountId: 0, videoState: 0, dialScene: 0, dialType: 0}. Dial () in callback mode and return :true + * @tc.name Set the mandatory phone number to a normal number (THE_THREE_NUMBER) and the optional parameters + * options to {accountId: 0, videoState: 0, dialScene: 0, dialType: 0}. Dial () in callback mode and + * return :true * @tc.desc Function test */ it('Telephony_CallManager_dial_Async_1300', 0, async function (done) { let obj = { accountId: 0, videoState: 0, dialScene: 0, dialType: 0 }; - call.dial('112', obj, (err, data) => { + call.dial(THE_THREE_NUMBER, obj, (err, data) => { if (err) { console.log('Telephony_CallManager_dial_Async_1300 fail err = ' + err); expect().assertFail(); @@ -270,14 +306,16 @@ describe('CallManagerOnDial', function () { }) const startTime = new Date().getTime(); while (true) { - if (callState === call.CALL_STATUS_DIALING || callState === call.CALL_STATUS_ACTIVE) { + if (callState === call.CALL_STATUS_DIALING || callState === call.CALL_STATUS_ACTIVE || + callState === call.CALL_STATUS_ALERTING) { done(); return; } await sleep(waitTime); endTime = new Date().getTime(); - timeOut = endTime - startTime; - if (timeOut > onTime) { + timing = endTime - startTime; + if (timing > timeOut) { + expect().assertFail(); done(); break; } @@ -286,25 +324,27 @@ describe('CallManagerOnDial', function () { /* * @tc.number Telephony_CallManager_dial_Promise_0100 - * @tc.name Set the mandatory phone number to a normal number (10086) and the optional parameters options to - * {accountId: 0, videoState: 0, dialScene: 0, dialType: 0}. Call dial() and return :true + * @tc.name Set the mandatory phone number to a normal number (EIGHTEEN_DIGITS) and the optional parameters + * options to {accountId: 0}. Call dial() and return :true * @tc.desc Function test */ it('Telephony_CallManager_dial_Promise_0100', 0, async function (done) { try { - var data = await call.dial('123456789123456789', { accountId: 0 }) + var data = await call.dial(EIGHTEEN_DIGITS, { accountId: 0 }) expect(data).assertTrue(); console.log('Telephony_CallManager_dial_Promise_0100 finish data = ' + data); const startTime = new Date().getTime(); while (true) { - if (callState === call.CALL_STATUS_DIALING || callState === call.CALL_STATUS_ACTIVE) { + if (callState === call.CALL_STATUS_DIALING || callState === call.CALL_STATUS_ACTIVE || + callState === call.CALL_STATUS_ALERTING) { done(); return; } await sleep(waitTime); endTime = new Date().getTime(); - timeOut = endTime - startTime; - if (timeOut > onTime) { + timing = endTime - startTime; + if (timing > timeOut) { + expect().assertFail(); done(); break; } @@ -318,13 +358,13 @@ describe('CallManagerOnDial', function () { /* * @tc.number Telephony_CallManager_dial_Promise_0300 - * @tc.name Set the mandatory phone number to abcDE123456 and optional parameters options to - * {accountId: 0, videoState: 0, dialScene: 0, dialType: 0},call dial() to dial, return :true + * @tc.name Set the mandatory phone number to WITH_LETTER_NUMBER and optional parameters options to + * {accountId: 0},call dial() to dial, return :true * @tc.desc Function test */ it('Telephony_CallManager_dial_Promise_0300', 0, async function (done) { try { - var data = await call.dial('abcde123456', { accountId: 0 }) + var data = await call.dial(WITH_LETTER_NUMBER, { accountId: 0 }) expect(data).assertTrue(); console.log('Telephony_CallManager_dial_Promise_0300 finish data = ' + data); } catch (err) { @@ -335,14 +375,16 @@ describe('CallManagerOnDial', function () { } const startTime = new Date().getTime(); while (true) { - if (callState === call.CALL_STATUS_DIALING || callState === call.CALL_STATUS_ACTIVE) { + if (callState === call.CALL_STATUS_DIALING || callState === call.CALL_STATUS_ACTIVE || + callState === call.CALL_STATUS_ALERTING) { done(); return; } await sleep(waitTime); endTime = new Date().getTime(); - timeOut = endTime - startTime; - if (timeOut > onTime) { + timing = endTime - startTime; + if (timing > timeOut) { + expect().assertFail(); done(); break; } @@ -351,13 +393,13 @@ describe('CallManagerOnDial', function () { /* * @tc.number Telephony_CallManager_dial_Promise_0600 - * @tc.name Set the required phone number to a normal number (10086) with no optional arguments and call - * dial() to dial, returning :true + * @tc.name Set the required phone number to a normal number (CALLMANAGER_TEST_PHONY_NUMBER) with no optional + * arguments and call dial() to dial, returning :true * @tc.desc Function test */ it('Telephony_CallManager_dial_Promise_0600', 0, async function (done) { try { - var data = await call.dial(TEST_PHONY_NUMBER, { accountId: 0 }) + var data = await call.dial(CALLMANAGER_TEST_PHONY_NUMBER, { accountId: 0 }) console.log('Telephony_CallManager_dial_Promise_0600 finish data = ' + data); expect(data).assertTrue(); } catch (err) { @@ -368,14 +410,16 @@ describe('CallManagerOnDial', function () { } const startTime = new Date().getTime(); while (true) { - if (callState === call.CALL_STATUS_DIALING || callState === call.CALL_STATUS_ACTIVE) { + if (callState === call.CALL_STATUS_DIALING || callState === call.CALL_STATUS_ACTIVE || + callState === call.CALL_STATUS_ALERTING) { done(); return; } await sleep(waitTime); endTime = new Date().getTime(); - timeOut = endTime - startTime; - if (timeOut > onTime) { + timing = endTime - startTime; + if (timing > timeOut) { + expect().assertFail(); done(); break; } @@ -385,7 +429,7 @@ describe('CallManagerOnDial', function () { /* * @tc.number Telephony_CallManager_dial_Promise_0700 * @tc.name Example Set the required phone number to a normal number INVALID_NUMBER. Options are - * {accountId: 0, videoState: 0, dialScene: 0, dialType: 0}, call dial() to dial, returning :true. + * {accountId: 0 }, call dial() to dial, returning :true. * @tc.desc Function test */ it('Telephony_CallManager_dial_Promise_0700', 0, async function (done) { @@ -401,14 +445,16 @@ describe('CallManagerOnDial', function () { } const startTime = new Date().getTime(); while (true) { - if (callState === call.CALL_STATUS_DIALING || callState === call.CALL_STATUS_ACTIVE) { + if (callState === call.CALL_STATUS_DIALING || callState === call.CALL_STATUS_ACTIVE || + callState === call.CALL_STATUS_ALERTING) { done(); return; } await sleep(waitTime); endTime = new Date().getTime(); - timeOut = endTime - startTime; - if (timeOut > onTime) { + timing = endTime - startTime; + if (timing > timeOut) { + expect().assertFail(); done(); break; } @@ -417,13 +463,13 @@ describe('CallManagerOnDial', function () { /* * @tc.number Telephony_CallManager_dial_Promise_0800 - * @tc.name Set the required phone number to a normal number (112) without the optional parameters, + * @tc.name Set the required phone number to a normal number (THE_THREE_NUMBER) without the optional parameters, * and call dial() to dial, returning :true * @tc.desc Function test */ it('Telephony_CallManager_dial_Promise_0800', 0, async function (done) { try { - var data = await call.dial('112'); + var data = await call.dial(THE_THREE_NUMBER); expect(data).assertTrue(); console.log('Telephony_CallManager_dial_Promise_0800 finish data = ' + data); } catch (err) { @@ -434,14 +480,16 @@ describe('CallManagerOnDial', function () { } const startTime = new Date().getTime(); while (true) { - if (callState === call.CALL_STATUS_DIALING || callState === call.CALL_STATUS_ACTIVE) { + if (callState === call.CALL_STATUS_DIALING || callState === call.CALL_STATUS_ACTIVE || + callState === call.CALL_STATUS_ALERTING) { done(); return; } await sleep(waitTime); endTime = new Date().getTime(); - timeOut = endTime - startTime; - if (timeOut > onTime) { + timing = endTime - startTime; + if (timing > timeOut) { + expect().assertFail(); done(); break; } @@ -450,7 +498,7 @@ describe('CallManagerOnDial', function () { /* * @tc.number Telephony_CallManager_dial_Promise_1000 - * @tc.name Will choose parameter number add ', '(10086123567901345789123), with no optional parameters, + * @tc.name Will choose parameter number add ', '(10086,123567901345789123), with no optional parameters, * call dial () to dial, return: true * @tc.desc Function test */ @@ -467,14 +515,16 @@ describe('CallManagerOnDial', function () { } const startTime = new Date().getTime(); while (true) { - if (callState === call.CALL_STATUS_DIALING || callState === call.CALL_STATUS_ACTIVE) { + if (callState === call.CALL_STATUS_DIALING || callState === call.CALL_STATUS_ACTIVE || + callState === call.CALL_STATUS_ALERTING) { done(); return; } await sleep(waitTime); endTime = new Date().getTime(); - timeOut = endTime - startTime; - if (timeOut > onTime) { + timing = endTime - startTime; + if (timing > timeOut) { + expect().assertFail(); done(); break; } @@ -483,13 +533,13 @@ describe('CallManagerOnDial', function () { /* * @tc.number Telephony_CallManager_dial_Promise_1100 - * @tc.name This parameter is mandatory. The phone number is 00000000. + * @tc.name This parameter is mandatory. The phone number is EIGHT_NUMBER. * Dial () with no optional parameters returns true * @tc.desc Function test */ it('Telephony_CallManager_dial_Promise_1100', 0, async function (done) { try { - var data = await call.dial('00000000'); + var data = await call.dial(EIGHT_NUMBER); expect(data).assertTrue(); console.log('Telephony_CallManager_dial_Promise_1100 finish data = ' + data); } catch (err) { @@ -500,14 +550,16 @@ describe('CallManagerOnDial', function () { } const startTime = new Date().getTime(); while (true) { - if (callState === call.CALL_STATUS_DIALING || callState === call.CALL_STATUS_ACTIVE) { + if (callState === call.CALL_STATUS_DIALING || callState === call.CALL_STATUS_ACTIVE || + callState === call.CALL_STATUS_ALERTING) { done(); return; } await sleep(waitTime); endTime = new Date().getTime(); - timeOut = endTime - startTime; - if (timeOut > onTime) { + timing = endTime - startTime; + if (timing > timeOut) { + expect().assertFail(); done(); break; } @@ -516,13 +568,13 @@ describe('CallManagerOnDial', function () { /* * @tc.number Telephony_CallManager_dial_Promise_1200 - * @tc.name The phone number is 000000000000000000. Dial () without any optional parameters. + * @tc.name The phone number is EIGHTEEN_DIGITS. Dial () without any optional parameters. * True is returned * @tc.desc Function test */ it('Telephony_CallManager_dial_Promise_1200', 0, async function (done) { try { - var data = await call.dial('000000000000000000'); + var data = await call.dial(EIGHTEEN_DIGITS); expect(data).assertTrue(); console.log('Telephony_CallManager_dial_Promise_1200 finish data = ' + data); } catch (err) { @@ -533,14 +585,16 @@ describe('CallManagerOnDial', function () { } const startTime = new Date().getTime(); while (true) { - if (callState === call.CALL_STATUS_DIALING || callState === call.CALL_STATUS_ACTIVE) { + if (callState === call.CALL_STATUS_DIALING || callState === call.CALL_STATUS_ACTIVE || + callState === call.CALL_STATUS_ALERTING) { done(); return; } await sleep(waitTime); endTime = new Date().getTime(); - timeOut = endTime - startTime; - if (timeOut > onTime) { + timing = endTime - startTime; + if (timing > timeOut) { + expect().assertFail(); done(); break; } @@ -549,13 +603,13 @@ describe('CallManagerOnDial', function () { /* * @tc.number Telephony_CallManager_dial_Promise_1300 - * @tc.name The phone number is the area code (0898) and the number is 0000 0000. Dial () without optional + * @tc.name The phone number is the area code and the number (0898 0000 0000). Dial () without optional * parameters returns true * @tc.desc Function test */ it('Telephony_CallManager_dial_Promise_1300', 0, async function (done) { try { - var data = await call.dial('0898 0000 0000'); + var data = await call.dial(EIGHT_NUMBER_WITH_AN_AREA_CODE); expect(data).assertTrue(); console.log('Telephony_CallManager_dial_Promise_1300 finish data = ' + data); } catch (err) { @@ -566,14 +620,16 @@ describe('CallManagerOnDial', function () { } const startTime = new Date().getTime(); while (true) { - if (callState === call.CALL_STATUS_DIALING || callState === call.CALL_STATUS_ACTIVE) { + if (callState === call.CALL_STATUS_DIALING || callState === call.CALL_STATUS_ACTIVE || + callState === call.CALL_STATUS_ALERTING) { done(); return; } await sleep(waitTime); endTime = new Date().getTime(); - timeOut = endTime - startTime; - if (timeOut > onTime) { + timing = endTime - startTime; + if (timing > timeOut) { + expect().assertFail(); done(); break; } @@ -587,7 +643,7 @@ describe('CallManagerOnDial', function () { * @tc.desc Function test */ it('Telephony_CallManager_switchCall_Async_0400', 0, async function (done) { - call.dial(TEST_PHONY_NUMBER, async (err, data) => { + call.dial(CALLMANAGER_TEST_PHONY_NUMBER, async (err, data) => { if (err) { expect().assertFail(); console.log('Telephony_CallManager_switchCall_Async_0400 dial fail err = ' + err); @@ -598,7 +654,8 @@ describe('CallManagerOnDial', function () { console.log('Telephony_CallManager_switchCall_Async_0400 dial finish data = ' + data); const startTime = new Date().getTime(); while (true) { - if (callState === call.CALL_STATUS_DIALING) { + if (callState === call.CALL_STATUS_DIALING || callState === call.CALL_STATUS_ACTIVE || + callState === call.CALL_STATUS_ALERTING) { call.switchCall(callId, (err) => { if (err) { console.log( @@ -608,14 +665,16 @@ describe('CallManagerOnDial', function () { } expect().assertFail(); console.log('Telephony_CallManager_switchCall_Async_0400 switchCall fail'); + done(); + return; }) - done(); return; } await sleep(waitTime); endTime = new Date().getTime(); - timeOut = endTime - startTime; - if (timeOut > onTime) { + timing = endTime - startTime; + if (timing > timeOut) { + expect().assertFail(); done(); break; } @@ -631,7 +690,7 @@ describe('CallManagerOnDial', function () { */ it('Telephony_CallManager_switchCall_Promise_0400', 0, async function (done) { try { - var data = await call.dial(TEST_PHONY_NUMBER); + var data = await call.dial(CALLMANAGER_TEST_PHONY_NUMBER); expect(data).assertTrue(); console.log('Telephony_CallManager_switchCall_Promise_0400 dial finish data = ' + data); } catch (err) { @@ -642,23 +701,25 @@ describe('CallManagerOnDial', function () { } const startTime = new Date().getTime(); while (true) { - if (callState === call.CALL_STATUS_DIALING) { + if (callState === call.CALL_STATUS_DIALING || callState === call.CALL_STATUS_ACTIVE || + callState === call.CALL_STATUS_ALERTING) { try { await call.switchCall(callId); expect().assertFail(); console.log('Telephony_CallManager_switchCall_Promise_0400 switchCall fail'); + done(); } catch (err) { console.log('Telephony_CallManager_switchCall_Promise_0400 switchCall finish err = ' + err.message); done(); return; } - done(); return; } await sleep(waitTime); endTime = new Date().getTime(); - timeOut = endTime - startTime; - if (timeOut > onTime) { + timing = endTime - startTime; + if (timing > timeOut) { + expect().assertFail(); done(); break; } @@ -672,7 +733,7 @@ describe('CallManagerOnDial', function () { * @tc.desc Function test */ it('Telephony_CallManager_holdCall_Async_0400', 0, async function (done) { - call.dial(TEST_PHONY_NUMBER, async (err, data) => { + call.dial(CALLMANAGER_TEST_PHONY_NUMBER, async (err, data) => { if (err) { expect().assertFail(); console.log('Telephony_CallManager_holdCall_Async_0400 dial fail err = ' + err); @@ -692,14 +753,16 @@ describe('CallManagerOnDial', function () { return; } console.log('Telephony_CallManager_holdCall_Async_0400 finish'); + done(); + return; }) - done(); return; } await sleep(waitTime); endTime = new Date().getTime(); - timeOut = endTime - startTime; - if (timeOut > onTime) { + timing = endTime - startTime; + if (timing > timeOut) { + expect().assertFail(); done(); break; } @@ -715,7 +778,7 @@ describe('CallManagerOnDial', function () { */ it('Telephony_CallManager_holdCall_Promise_0400', 0, async function (done) { try { - var data = await call.dial(TEST_PHONY_NUMBER); + var data = await call.dial(CALLMANAGER_TEST_PHONY_NUMBER); expect(data).assertTrue(); console.log('Telephony_CallManager_holdCall_Promise_0400 dial finish data = ' + data); } catch (err) { @@ -730,19 +793,20 @@ describe('CallManagerOnDial', function () { try { await call.holdCall(callId); console.log('Telephony_CallManager_holdCall_Promise_0400 holdCall finish'); + done(); } catch (err) { console.log('Telephony_CallManager_holdCall_Promise_0400 holdCall fail err = ' + err.message); expect().assertFail(); done(); return; } - done(); return; } await sleep(waitTime); endTime = new Date().getTime(); - timeOut = endTime - startTime; - if (timeOut > onTime) { + timing = endTime - startTime; + if (timing > timeOut) { + expect().assertFail(); done(); break; } @@ -756,7 +820,7 @@ describe('CallManagerOnDial', function () { * @tc.desc Function test */ it('Telephony_CallManager_unholdCall_Async_0400', 0, async function (done) { - call.dial(TEST_PHONY_NUMBER, async (err, data) => { + call.dial(CALLMANAGER_TEST_PHONY_NUMBER, async (err, data) => { if (err) { expect().assertFail(); console.log('Telephony_CallManager_unholdCall_Async_0400 dial fail err = ' + err); @@ -766,45 +830,49 @@ describe('CallManagerOnDial', function () { expect(data).assertTrue(); console.log('Telephony_CallManager_unholdCall_Async_0400 dial finish data = ' + data); const startTime = new Date().getTime(); - let holdCallflig = true; - let unHoldCallflig = true; + let flag = false; + let holdCallflag = true; + let unHoldCallflag = false; while (true) { - if (callState === call.CALL_STATUS_ACTIVE && holdCallflig === true) { - holdCallflig = false; + if (callState === call.CALL_STATUS_ACTIVE && holdCallflag === true) { + holdCallflag = false; call.holdCall(callId, (err) => { if (err) { expect().assertFail(); console.log( - 'Telephony_CallManager_unholdCall_Async_0400 holdCall fail err = ' + err.message - ); + 'Telephony_CallManager_unholdCall_Async_0400 holdCall fail err = ' + err.message ); done(); return; } console.log('Telephony_CallManager_unholdCall_Async_0400 holdCall finish'); + unHoldCallflag = true; }) } await sleep(waitTime); - if (callState === call.CALL_STATUS_HOLDING && unHoldCallflig === true) { - unHoldCallflig = false; + if (callState === call.CALL_STATUS_HOLDING && unHoldCallflag === true) { + unHoldCallflag = false; call.unHoldCall(callId, (err) => { if (err) { expect().assertFail(); console.log( - 'Telephony_CallManager_unholdCall_Async_0400 unHoldCall fail err = ' + - err.message - ); + 'Telephony_CallManager_unholdCall_Async_0400 unHoldCall fail err = ' + err.message ); done(); return; } + flag = true; console.log('Telephony_CallManager_unholdCall_Async_0400 unHoldCall finish'); done(); + return; }) - return; + if (flag){ + return; + } } await sleep(waitTime); endTime = new Date().getTime(); - timeOut = endTime - startTime; - if (timeOut > onTime) { + timing = endTime - startTime; + if (timing > timeOut) { + expect().assertFail(); done(); break; } @@ -820,7 +888,7 @@ describe('CallManagerOnDial', function () { */ it('Telephony_CallManager_unholdCall_Promise_0400', 0, async function (done) { try { - var data = await call.dial(TEST_PHONY_NUMBER); + var data = await call.dial(CALLMANAGER_TEST_PHONY_NUMBER); expect(data).assertTrue(); console.log('Telephony_CallManager_unholdCall_Promise_0400 dial finish data = ' + data); } catch (err) { @@ -829,12 +897,14 @@ describe('CallManagerOnDial', function () { done(); return; } - let holdCallflig = true; - let unHoldCallflig = true; + let flag = false; + let holdCallflag = true; + let unHoldCallflag = false; const startTime = new Date().getTime(); while (true) { - if (callState === call.CALL_STATUS_ACTIVE && holdCallflig === true) { - holdCallflig = false; + if (callState === call.CALL_STATUS_ACTIVE && holdCallflag === true) { + unHoldCallflag = true; + holdCallflag = false; try { await call.holdCall(callId); console.log('Telephony_CallManager_unholdCall_Promise_0400 holdCall finish'); @@ -842,17 +912,19 @@ describe('CallManagerOnDial', function () { console.log('Telephony_CallManager_unholdCall_Promise_0400 holdCall fail err = ' + err.message); expect().assertFail(); done(); + return; } } await sleep(waitTime); - if (callState === call.CALL_STATUS_HOLDING && unHoldCallflig === true) { - unHoldCallflig = false; + if (callState === call.CALL_STATUS_HOLDING && unHoldCallflag === true) { + unHoldCallflag = false; try { await call.unHoldCall(callId); console.log('Telephony_CallManager_unholdCall_Promise_0400 unHoldCall finish'); done(); return; } catch (err) { + flag = true; console.log( 'Telephony_CallManager_unholdCall_Promise_0400 unHoldCall fail err = ' + err.message ); @@ -861,23 +933,27 @@ describe('CallManagerOnDial', function () { return; } } - } - await sleep(waitTime); - endTime = new Date().getTime(); - timeOut = endTime - startTime; - if (timeOut > onTime) { - done(); - return; + if (flag){ + return; + } + await sleep(waitTime); + endTime = new Date().getTime(); + timing = endTime - startTime; + if (timing > timeOut) { + expect().assertFail(); + done(); + return; + } } }) /* * @tc.number Telephony_CallManager_hasCall_Async_0500 - * @tc.name Call 10086, hasCall() to confirm that there is a call, returns true + * @tc.name Call CALLMANAGER_TEST_PHONY_NUMBER, hasCall() to confirm that there is a call, returns true * @tc.desc Function test */ it('Telephony_CallManager_hasCall_Async_0500', 0, async function (done) { - call.dial(TEST_PHONY_NUMBER, async (err, data) => { + call.dial(CALLMANAGER_TEST_PHONY_NUMBER, async (err, data) => { if (err) { expect().assertFail(); console.log('Telephony_CallManager_hasCall_Async_0500 dial fail err = ' + err); @@ -888,7 +964,8 @@ describe('CallManagerOnDial', function () { console.log('Telephony_CallManager_hasCall_Async_0500 dial finish data = ' + data); const startTime = new Date().getTime(); while (true) { - if (callState === call.CALL_STATUS_DIALING || callState === call.CALL_STATUS_ACTIVE) { + if (callState === call.CALL_STATUS_DIALING || callState === call.CALL_STATUS_ACTIVE || + callState === call.CALL_STATUS_ALERTING) { call.hasCall((err, data) => { if (err) { expect().assertFail(); @@ -898,14 +975,16 @@ describe('CallManagerOnDial', function () { } expect(data).assertTrue(); console.log('Telephony_CallManager_hasCall_Async_0500 finish data = ' + data); + done(); + return; }) - done(); return; } await sleep(waitTime); endTime = new Date().getTime(); - timeOut = endTime - startTime; - if (timeOut > onTime) { + timing = endTime - startTime; + if (timing > timeOut) { + expect().assertFail(); done(); break; } @@ -915,12 +994,12 @@ describe('CallManagerOnDial', function () { /* * @tc.number Telephony_CallManager_hasCall_Promise_0500 - * @tc.name Call 10086, hasCall() to confirm that there is a call, returns true + * @tc.name Call CALLMANAGER_TEST_PHONY_NUMBER, hasCall() to confirm that there is a call, returns true * @tc.desc Function test */ it('Telephony_CallManager_hasCall_Promise_0500', 0, async function (done) { try { - var data = await call.dial(TEST_PHONY_NUMBER); + var data = await call.dial(CALLMANAGER_TEST_PHONY_NUMBER); expect(data).assertTrue(); console.log('Telephony_CallManager_hasCall_Promise_0500 dial finish data = ' + data); } catch (err) { @@ -931,24 +1010,26 @@ describe('CallManagerOnDial', function () { } const startTime = new Date().getTime(); while (true) { - if (callState === call.CALL_STATUS_DIALING || callState === call.CALL_STATUS_ACTIVE) { + if (callState === call.CALL_STATUS_DIALING || callState === call.CALL_STATUS_ACTIVE || + callState === call.CALL_STATUS_ALERTING) { try { data = await call.hasCall(); expect(data).assertTrue(); console.log('Telephony_CallManager_hasCall_Promise_0500 getCallState finish data = ' + data); + done(); + return; } catch (err) { console.log('Telephony_CallManager_hasCall_Promise_0500 getCallState fail err = ' + err); expect().assertFail(); done(); return; } - done(); - return; } await sleep(waitTime); endTime = new Date().getTime(); - timeOut = endTime - startTime; - if (timeOut > onTime) { + timing = endTime - startTime; + if (timing > timeOut) { + expect().assertFail(); done(); break; } @@ -962,7 +1043,7 @@ describe('CallManagerOnDial', function () { * @tc.desc Function test */ it('Telephony_CallManager_getCallState_Async_0200', 0, async function (done) { - call.dial(TEST_PHONY_NUMBER, async (err, data) => { + call.dial(CALLMANAGER_TEST_PHONY_NUMBER, async (err, data) => { if (err) { expect().assertFail(); console.log('Telephony_CallManager_getCallState_Async_0200 dial fail err = ' + err); @@ -973,7 +1054,8 @@ describe('CallManagerOnDial', function () { console.log('Telephony_CallManager_getCallState_Async_0200 dial finish data = ' + data); const startTime = new Date().getTime(); while (true) { - if (callState === call.CALL_STATUS_DIALING || callState === call.CALL_STATUS_ACTIVE) { + if (callState === call.CALL_STATUS_DIALING || callState === call.CALL_STATUS_ACTIVE || + callState === call.CALL_STATUS_ALERTING) { call.getCallState((err, data) => { if (err) { expect().assertFail(); @@ -983,14 +1065,16 @@ describe('CallManagerOnDial', function () { } expect(data === call.CALL_STATE_OFFHOOK).assertTrue(); console.log('Telephony_CallManager_getCallState_Async_0200 finish data = ' + data); + done(); + return; }) - done(); return; } await sleep(waitTime); endTime = new Date().getTime(); - timeOut = endTime - startTime; - if (timeOut > onTime) { + timing = endTime - startTime; + if (timing > timeOut) { + expect().assertFail(); done(); break; } @@ -1006,7 +1090,7 @@ describe('CallManagerOnDial', function () { */ it('Telephony_CallManager_getCallState_Promise_0200', 0, async function (done) { try { - var data = await call.dial(TEST_PHONY_NUMBER); + var data = await call.dial(CALLMANAGER_TEST_PHONY_NUMBER); expect(data).assertTrue(); console.log('Telephony_CallManager_getCallState_Promise_0200 dial finish data = ' + data); } catch (err) { @@ -1017,24 +1101,26 @@ describe('CallManagerOnDial', function () { } const startTime = new Date().getTime(); while (true) { - if (callState === call.CALL_STATUS_DIALING || callState === call.CALL_STATUS_ACTIVE) { + if (callState === call.CALL_STATUS_DIALING || callState === call.CALL_STATUS_ACTIVE || + callState === call.CALL_STATUS_ALERTING) { try { data = await call.getCallState(); expect(data === call.CALL_STATE_OFFHOOK).assertTrue(); console.log('Telephony_CallManager_getCallState_Promise_0200 getCallState finish data = ' + data); + done(); + return; } catch (err) { console.log('Telephony_CallManager_getCallState_Promise_0200 getCallState fail err = ' + err); expect().assertFail(); done(); return; } - done(); - return; } await sleep(waitTime); endTime = new Date().getTime(); - timeOut = endTime - startTime; - if (timeOut > onTime) { + timing = endTime - startTime; + if (timing > timeOut) { + expect().assertFail(); done(); break; } @@ -1047,7 +1133,7 @@ describe('CallManagerOnDial', function () { * @tc.desc Function test */ it('Telephony_CallManager_startDTMF_Async_0100', 0, async function (done) { - call.dial(TEST_PHONY_NUMBER, async (err, data) => { + call.dial(CALLMANAGER_TEST_PHONY_NUMBER, async (err, data) => { if (err) { console.log('Telephony_CallManager_startDTMF_Async_0100 dial fail err = ' + err); expect().assertFail(); @@ -1058,30 +1144,35 @@ describe('CallManagerOnDial', function () { console.log('Telephony_CallManager_startDTMF_Async_0100 dial finish data = ' + data); const startTime = new Date().getTime(); while (true) { - if (callState === call.CALL_STATUS_DIALING || callState === call.CALL_STATUS_ACTIVE) { + if (callState === call.CALL_STATUS_DIALING || callState === call.CALL_STATUS_ACTIVE || + callState === call.CALL_STATUS_ALERTING) { call.startDTMF(callId, '0', (err) => { if (err) { expect().assertFail(); console.log('Telephony_CallManager_startDTMF_Async_0100 startDTMF fail err = ' + err); + done(); return; } console.log('Telephony_CallManager_startDTMF_Async_0100 startDTMF finish data = ' + data); + call.stopDTMF(callId, (err) => { + if (err) { + expect().assertFail(); + console.log('Telephony_CallManager_startDTMF_Async_0100 stopDTMF fail err = ' + err); + done(); + return; + } + console.log('Telephony_CallManager_startDTMF_Async_0100 stopDTMF finish data = ' + data); + }) + done(); + return; }) - call.stopDTMF(callId, (err) => { - if (err) { - expect().assertFail(); - console.log('Telephony_CallManager_startDTMF_Async_0100 stopDTMF fail err = ' + err); - return; - } - console.log('Telephony_CallManager_startDTMF_Async_0100 stopDTMF finish data = ' + data); - }) - done(); return; } await sleep(waitTime); endTime = new Date().getTime(); - timeOut = endTime - startTime; - if (timeOut > onTime) { + timing = endTime - startTime; + if (timing > timeOut) { + expect().assertFail(); done(); break; } @@ -1095,7 +1186,7 @@ describe('CallManagerOnDial', function () { * @tc.desc Function test */ it('Telephony_CallManager_startDTMF_Async_0200', 0, async function (done) { - call.dial(TEST_PHONY_NUMBER, async (err, data) => { + call.dial(CALLMANAGER_TEST_PHONY_NUMBER, async (err, data) => { if (err) { console.log('Telephony_CallManager_startDTMF_Async_0200 dial fail err = ' + err); expect().assertFail(); @@ -1106,30 +1197,35 @@ describe('CallManagerOnDial', function () { console.log('Telephony_CallManager_startDTMF_Async_0200 dial finish data = ' + data); const startTime = new Date().getTime(); while (true) { - if (callState === call.CALL_STATUS_DIALING || callState === call.CALL_STATUS_ACTIVE) { + if (callState === call.CALL_STATUS_DIALING || callState === call.CALL_STATUS_ACTIVE || + callState === call.CALL_STATUS_ALERTING) { call.startDTMF(callId, '5', (err) => { if (err) { expect().assertFail(); console.log('Telephony_CallManager_startDTMF_Async_0200 startDTMF fail err = ' + err); + done(); return; } console.log('Telephony_CallManager_startDTMF_Async_0200 startDTMF finish data = ' + data); + call.stopDTMF(callId, (err) => { + if (err) { + expect().assertFail(); + console.log('Telephony_CallManager_startDTMF_Async_0200 stopDTMF fail err = ' + err); + done(); + return; + } + console.log('Telephony_CallManager_startDTMF_Async_0200 stopDTMF finish data = ' + data); + }) + done(); + return; }) - call.stopDTMF(callId, (err) => { - if (err) { - expect().assertFail(); - console.log('Telephony_CallManager_startDTMF_Async_0200 stopDTMF fail err = ' + err); - return; - } - console.log('Telephony_CallManager_startDTMF_Async_0200 stopDTMF finish data = ' + data); - }) - done(); return; } await sleep(waitTime); endTime = new Date().getTime(); - timeOut = endTime - startTime; - if (timeOut > onTime) { + timing = endTime - startTime; + if (timing > timeOut) { + expect().assertFail(); done(); break; } @@ -1143,7 +1239,7 @@ describe('CallManagerOnDial', function () { * @tc.desc Function test */ it('Telephony_CallManager_startDTMF_Async_0300', 0, async function (done) { - call.dial(TEST_PHONY_NUMBER, async (err, data) => { + call.dial(CALLMANAGER_TEST_PHONY_NUMBER, async (err, data) => { if (err) { console.log('Telephony_CallManager_startDTMF_Async_0300 dial fail err = ' + err); expect().assertFail(); @@ -1154,30 +1250,35 @@ describe('CallManagerOnDial', function () { console.log('Telephony_CallManager_startDTMF_Async_0300 dial finish data = ' + data); const startTime = new Date().getTime(); while (true) { - if (callState === call.CALL_STATUS_DIALING || callState === call.CALL_STATUS_ACTIVE) { + if (callState === call.CALL_STATUS_DIALING || callState === call.CALL_STATUS_ACTIVE || + callState === call.CALL_STATUS_ALERTING) { call.startDTMF(callId, '9', (err) => { if (err) { expect().assertFail(); console.log('Telephony_CallManager_startDTMF_Async_0300 startDTMF fail err = ' + err); + done(); return; } console.log('Telephony_CallManager_startDTMF_Async_0300 startDTMF finish data = ' + data); + call.stopDTMF(callId, (err) => { + if (err) { + expect().assertFail(); + console.log('Telephony_CallManager_startDTMF_Async_0300 stopDTMF fail err = ' + err); + done(); + return; + } + console.log('Telephony_CallManager_startDTMF_Async_0300 stopDTMF finish data = ' + data); + }) + done(); + return; }) - call.stopDTMF(callId, (err) => { - if (err) { - expect().assertFail(); - console.log('Telephony_CallManager_startDTMF_Async_0300 stopDTMF fail err = ' + err); - return; - } - console.log('Telephony_CallManager_startDTMF_Async_0300 stopDTMF finish data = ' + data); - }) - done(); return; } await sleep(waitTime); endTime = new Date().getTime(); - timeOut = endTime - startTime; - if (timeOut > onTime) { + timing = endTime - startTime; + if (timing > timeOut) { + expect().assertFail(); done(); break; } @@ -1191,7 +1292,7 @@ describe('CallManagerOnDial', function () { * @tc.desc Function test */ it('Telephony_CallManager_startDTMF_Async_0400', 0, async function (done) { - call.dial(TEST_PHONY_NUMBER, async (err, data) => { + call.dial(CALLMANAGER_TEST_PHONY_NUMBER, async (err, data) => { if (err) { console.log('Telephony_CallManager_startDTMF_Async_0400 dial fail err = ' + err); expect().assertFail(); @@ -1202,30 +1303,35 @@ describe('CallManagerOnDial', function () { console.log('Telephony_CallManager_startDTMF_Async_0400 dial finish : data = ' + data); const startTime = new Date().getTime(); while (true) { - if (callState === call.CALL_STATUS_DIALING || callState === call.CALL_STATUS_ACTIVE) { + if (callState === call.CALL_STATUS_DIALING || callState === call.CALL_STATUS_ACTIVE || + callState === call.CALL_STATUS_ALERTING) { call.startDTMF(callId, 'A', (err) => { if (err) { expect().assertFail(); console.log('Telephony_CallManager_startDTMF_Async_0400 startDTMF fail : err = ' + err); + done(); return; } console.log('Telephony_CallManager_startDTMF_Async_0400 startDTMF finish : data = ' + data); + call.stopDTMF(callId, (err) => { + if (err) { + expect().assertFail(); + console.log('Telephony_CallManager_startDTMF_Async_0400 stopDTMF fail : err = ' + err); + done(); + return; + } + console.log('Telephony_CallManager_startDTMF_Async_0400 stopDTMF finish : data = ' + data); + }) + done(); + return; }) - call.stopDTMF(callId, (err) => { - if (err) { - expect().assertFail(); - console.log('Telephony_CallManager_startDTMF_Async_0400 stopDTMF fail : err = ' + err); - return; - } - console.log('Telephony_CallManager_startDTMF_Async_0400 stopDTMF finish : data = ' + data); - }) - done(); return; } await sleep(waitTime); endTime = new Date().getTime(); - timeOut = endTime - startTime; - if (timeOut > onTime) { + timing = endTime - startTime; + if (timing > timeOut) { + expect().assertFail(); done(); break; } @@ -1239,7 +1345,7 @@ describe('CallManagerOnDial', function () { * @tc.desc Function test */ it('Telephony_CallManager_startDTMF_Async_0500', 0, async function (done) { - call.dial(TEST_PHONY_NUMBER,async (err, data) => { + call.dial(CALLMANAGER_TEST_PHONY_NUMBER,async (err, data) => { if (err) { console.log('Telephony_CallManager_startDTMF_Async_0500 dial fail : err = ' + err); expect().assertFail(); @@ -1250,30 +1356,35 @@ describe('CallManagerOnDial', function () { console.log('Telephony_CallManager_startDTMF_Async_0500 dial finish : data = ' + data); const startTime = new Date().getTime(); while (true) { - if (callState === call.CALL_STATUS_DIALING || callState === call.CALL_STATUS_ACTIVE) { + if (callState === call.CALL_STATUS_DIALING || callState === call.CALL_STATUS_ACTIVE || + callState === call.CALL_STATUS_ALERTING) { call.startDTMF(callId, 'C', (err) => { if (err) { expect().assertFail(); console.log('Telephony_CallManager_startDTMF_Async_0500 startDTMF fail : err = ' + err); + done(); return; } console.log('Telephony_CallManager_startDTMF_Async_0500 startDTMF finish : data = ' + data); + call.stopDTMF(callId, (err) => { + if (err) { + expect().assertFail(); + console.log('Telephony_CallManager_startDTMF_Async_0500 stopDTMF fail : err = ' + err); + done(); + return; + } + console.log('Telephony_CallManager_startDTMF_Async_0500 stopDTMF finish : data = ' + data); + }) + done(); + return; }) - call.stopDTMF(callId, (err) => { - if (err) { - expect().assertFail(); - console.log('Telephony_CallManager_startDTMF_Async_0500 stopDTMF fail : err = ' + err); - return; - } - console.log('Telephony_CallManager_startDTMF_Async_0500 stopDTMF finish : data = ' + data); - }) - done(); return; } await sleep(waitTime); endTime = new Date().getTime(); - timeOut = endTime - startTime; - if (timeOut > onTime) { + timing = endTime - startTime; + if (timing > timeOut) { + expect().assertFail(); done(); break; } @@ -1287,7 +1398,7 @@ describe('CallManagerOnDial', function () { * @tc.desc Function test */ it('Telephony_CallManager_startDTMF_Async_0600', 0, async function (done) { - call.dial(TEST_PHONY_NUMBER, async (err, data) => { + call.dial(CALLMANAGER_TEST_PHONY_NUMBER, async (err, data) => { if (err) { console.log('Telephony_CallManager_startDTMF_Async_0600 dial fail : err = ' + err); expect().assertFail(); @@ -1298,30 +1409,35 @@ describe('CallManagerOnDial', function () { console.log('Telephony_CallManager_startDTMF_Async_0600 dial finish : data = ' + data); const startTime = new Date().getTime(); while (true) { - if (callState === call.CALL_STATUS_DIALING || callState === call.CALL_STATUS_ACTIVE) { + if (callState === call.CALL_STATUS_DIALING || callState === call.CALL_STATUS_ACTIVE || + callState === call.CALL_STATUS_ALERTING) { call.startDTMF(callId, 'D', (err) => { if (err) { expect().assertFail(); console.log('Telephony_CallManager_startDTMF_Async_0600 startDTMF fail : err = ' + err); + done(); return; } console.log('Telephony_CallManager_startDTMF_Async_0600 startDTMF finish : data = ' + data); + call.stopDTMF(callId, (err) => { + if (err) { + expect().assertFail(); + console.log('Telephony_CallManager_startDTMF_Async_0600 stopDTMF fail : err = ' + err); + done(); + return; + } + console.log('Telephony_CallManager_startDTMF_Async_0600 stopDTMF finish : data = ' + data); + }) + done(); + return; }) - call.stopDTMF(callId, (err) => { - if (err) { - expect().assertFail(); - console.log('Telephony_CallManager_startDTMF_Async_0600 stopDTMF fail : err = ' + err); - return; - } - console.log('Telephony_CallManager_startDTMF_Async_0600 stopDTMF finish : data = ' + data); - }) - done(); return; } await sleep(waitTime); endTime = new Date().getTime(); - timeOut = endTime - startTime; - if (timeOut > onTime) { + timing = endTime - startTime; + if (timing > timeOut) { + expect().assertFail(); done(); break; } @@ -1335,7 +1451,7 @@ describe('CallManagerOnDial', function () { * @tc.desc Function test */ it('Telephony_CallManager_startDTMF_Async_0700', 0, async function (done) { - call.dial(TEST_PHONY_NUMBER, async (err, data) => { + call.dial(CALLMANAGER_TEST_PHONY_NUMBER, async (err, data) => { if (err) { console.log('Telephony_CallManager_startDTMF_Async_0700 dial fail : err = ' + err); expect().assertFail(); @@ -1346,22 +1462,26 @@ describe('CallManagerOnDial', function () { console.log('Telephony_CallManager_startDTMF_Async_0700 dial finish : data = ' + data); const startTime = new Date().getTime(); while (true) { - if (callState === call.CALL_STATUS_DIALING || callState === call.CALL_STATUS_ACTIVE) { + if (callState === call.CALL_STATUS_DIALING || callState === call.CALL_STATUS_ACTIVE || + callState === call.CALL_STATUS_ALERTING) { call.startDTMF(callId, 'd', (err) => { if (err) { console.log('Telephony_CallManager_startDTMF_Async_0700 startDTMF finish : err = ' + err); + done(); return; } console.log('Telephony_CallManager_startDTMF_Async_0700 startDTMF fail'); expect().assertFail(); + done(); + return; }) - done(); return; } await sleep(waitTime); endTime = new Date().getTime(); - timeOut = endTime - startTime; - if (timeOut > onTime) { + timing = endTime - startTime; + if (timing > timeOut) { + expect().assertFail(); done(); break; } @@ -1375,7 +1495,7 @@ describe('CallManagerOnDial', function () { * @tc.desc Function test */ it('Telephony_CallManager_startDTMF_Async_0800', 0, async function (done) { - call.dial(TEST_PHONY_NUMBER, async (err, data) => { + call.dial(CALLMANAGER_TEST_PHONY_NUMBER, async (err, data) => { if (err) { console.log('Telephony_CallManager_startDTMF_Async_0800 dial fail : err = ' + err); expect().assertFail(); @@ -1386,30 +1506,35 @@ describe('CallManagerOnDial', function () { console.log('Telephony_CallManager_startDTMF_Async_0800 dial finish : data = ' + data); const startTime = new Date().getTime(); while (true) { - if (callState === call.CALL_STATUS_DIALING || callState === call.CALL_STATUS_ACTIVE) { + if (callState === call.CALL_STATUS_DIALING || callState === call.CALL_STATUS_ACTIVE || + callState === call.CALL_STATUS_ALERTING) { call.startDTMF(callId, '*', (err) => { if (err) { expect().assertFail(); console.log('Telephony_CallManager_startDTMF_Async_0800 startDTMF fail : err = ' + err); + done(); return; } console.log('Telephony_CallManager_startDTMF_Async_0800 startDTMF finish : data = ' + data); + call.stopDTMF(callId, (err) => { + if (err) { + expect().assertFail(); + console.log('Telephony_CallManager_startDTMF_Async_0800 stopDTMF fail : err = ' + err); + done(); + return; + } + console.log('Telephony_CallManager_startDTMF_Async_0800 stopDTMF finish : data = ' + data); + }) + done(); + return; }) - call.stopDTMF(callId, (err) => { - if (err) { - expect().assertFail(); - console.log('Telephony_CallManager_startDTMF_Async_0800 stopDTMF fail : err = ' + err); - return; - } - console.log('Telephony_CallManager_startDTMF_Async_0800 stopDTMF finish : data = ' + data); - }) - done(); return; } await sleep(waitTime); endTime = new Date().getTime(); - timeOut = endTime - startTime; - if (timeOut > onTime) { + timing = endTime - startTime; + if (timing > timeOut) { + expect().assertFail(); done(); break; } @@ -1423,7 +1548,7 @@ describe('CallManagerOnDial', function () { * @tc.desc Function test */ it('Telephony_CallManager_startDTMF_Async_0900', 0, async function (done) { - call.dial(TEST_PHONY_NUMBER, async (err, data) => { + call.dial(CALLMANAGER_TEST_PHONY_NUMBER, async (err, data) => { if (err) { console.log('Telephony_CallManager_startDTMF_Async_0900 dial fail : err = ' + err); expect().assertFail(); @@ -1434,30 +1559,35 @@ describe('CallManagerOnDial', function () { console.log('Telephony_CallManager_startDTMF_Async_0900 dial finish : data = ' + data); const startTime = new Date().getTime(); while (true) { - if (callState === call.CALL_STATUS_DIALING || callState === call.CALL_STATUS_ACTIVE) { + if (callState === call.CALL_STATUS_DIALING || callState === call.CALL_STATUS_ACTIVE || + callState === call.CALL_STATUS_ALERTING) { call.startDTMF(callId, '#', (err) => { if (err) { expect().assertFail(); console.log('Telephony_CallManager_startDTMF_Async_0900 startDTMF fail : err = ' + err); + done(); return; } console.log('Telephony_CallManager_startDTMF_Async_0900 startDTMF finish : data = ' + data); + call.stopDTMF(callId, (err) => { + if (err) { + expect().assertFail(); + console.log('Telephony_CallManager_startDTMF_Async_0900 stopDTMF fail : err = ' + err); + done(); + return; + } + console.log('Telephony_CallManager_startDTMF_Async_0900 stopDTMF finish : data = ' + data); + }) + done(); + return; }) - call.stopDTMF(callId, (err) => { - if (err) { - expect().assertFail(); - console.log('Telephony_CallManager_startDTMF_Async_0900 stopDTMF fail : err = ' + err); - return; - } - console.log('Telephony_CallManager_startDTMF_Async_0900 stopDTMF finish : data = ' + data); - }) - done(); return; } await sleep(waitTime); endTime = new Date().getTime(); - timeOut = endTime - startTime; - if (timeOut > onTime) { + timing = endTime - startTime; + if (timing > timeOut) { + expect().assertFail(); done(); break; } @@ -1472,35 +1602,39 @@ describe('CallManagerOnDial', function () { */ it('Telephony_CallManager_startDTMF_Promise_0100', 0, async function (done) { try { - var data = await call.dial(TEST_PHONY_NUMBER); + var data = await call.dial(CALLMANAGER_TEST_PHONY_NUMBER); expect(data).assertTrue(); console.log('Telephony_CallManager_startDTMF_Promise_0100 dial finish : data = ' + data); const startTime = new Date().getTime(); while (true) { - if (callState === call.CALL_STATUS_DIALING || callState === call.CALL_STATUS_ACTIVE) { + if (callState === call.CALL_STATUS_DIALING || callState === call.CALL_STATUS_ACTIVE || + callState === call.CALL_STATUS_ALERTING) { try { await call.startDTMF(callId, '1'); console.log('Telephony_CallManager_startDTMF_Promise_0100 startDTMF finish : data = ' + data); } catch (err) { expect().assertFail(); console.log('Telephony_CallManager_startDTMF_Promise_0100 startDTMF fail : err = ' + err); + done(); return; } try { await call.stopDTMF(callId); console.log('Telephony_CallManager_startDTMF_Promise_0100 stopDTMF finish : data = ' + data); + done(); } catch (err) { expect().assertFail(); console.log('Telephony_CallManager_startDTMF_Promise_0100 stopDTMF fail : err = ' + err); + done(); return; } - done(); return; } await sleep(waitTime); endTime = new Date().getTime(); - timeOut = endTime - startTime; - if (timeOut > onTime) { + timing = endTime - startTime; + if (timing > timeOut) { + expect().assertFail(); done(); break; } @@ -1519,35 +1653,39 @@ describe('CallManagerOnDial', function () { */ it('Telephony_CallManager_startDTMF_Promise_0200', 0, async function (done) { try { - var data = await call.dial(TEST_PHONY_NUMBER); + var data = await call.dial(CALLMANAGER_TEST_PHONY_NUMBER); expect(data).assertTrue(); console.log('Telephony_CallManager_startDTMF_Promise_0200 dial finish : data = ' + data); const startTime = new Date().getTime(); while (true) { - if (callState === call.CALL_STATUS_DIALING || callState === call.CALL_STATUS_ACTIVE) { + if (callState === call.CALL_STATUS_DIALING || callState === call.CALL_STATUS_ACTIVE || + callState === call.CALL_STATUS_ALERTING) { try { await call.startDTMF(callId, '4'); console.log('Telephony_CallManager_startDTMF_Promise_0200 startDTMF finish : data = ' + data); } catch (err) { expect().assertFail(); console.log('Telephony_CallManager_startDTMF_Promise_0200 startDTMF fail : err = ' + err); + done(); return; } try { await call.stopDTMF(callId); console.log('Telephony_CallManager_startDTMF_Promise_0200 stopDTMF finish : data = ' + data); + done(); } catch (err) { expect().assertFail(); console.log('Telephony_CallManager_startDTMF_Promise_0200 stopDTMF fail : err = ' + err); + done(); return; } - done(); return; } await sleep(waitTime); endTime = new Date().getTime(); - timeOut = endTime - startTime; - if (timeOut > onTime) { + timing = endTime - startTime; + if (timing > timeOut) { + expect().assertFail(); done(); break; } @@ -1566,35 +1704,39 @@ describe('CallManagerOnDial', function () { */ it('Telephony_CallManager_startDTMF_Promise_0300', 0, async function (done) { try { - var data = await call.dial(TEST_PHONY_NUMBER); + var data = await call.dial(CALLMANAGER_TEST_PHONY_NUMBER); expect(data).assertTrue(); console.log('Telephony_CallManager_startDTMF_Promise_0300 dial finish : data = ' + data); const startTime = new Date().getTime(); while (true) { - if (callState === call.CALL_STATUS_DIALING || callState === call.CALL_STATUS_ACTIVE) { + if (callState === call.CALL_STATUS_DIALING || callState === call.CALL_STATUS_ACTIVE || + callState === call.CALL_STATUS_ALERTING) { try { await call.startDTMF(callId, '8'); console.log('Telephony_CallManager_startDTMF_Promise_0300 startDTMF finish : data = ' + data); } catch (err) { expect().assertFail(); console.log('Telephony_CallManager_startDTMF_Promise_0300 startDTMF fail : err = ' + err); + done(); return; } try { await call.stopDTMF(callId); console.log('Telephony_CallManager_startDTMF_Promise_0300 stopDTMF finish : data = ' + data); + done(); } catch (err) { expect().assertFail(); console.log('Telephony_CallManager_startDTMF_Promise_0300 stopDTMF fail : err = ' + err); + done(); return; } - done(); return; } await sleep(waitTime); endTime = new Date().getTime(); - timeOut = endTime - startTime; - if (timeOut > onTime) { + timing = endTime - startTime; + if (timing > timeOut) { + expect().assertFail(); done(); break; } @@ -1613,35 +1755,39 @@ describe('CallManagerOnDial', function () { */ it('Telephony_CallManager_startDTMF_Promise_0400', 0, async function (done) { try { - var data = await call.dial(TEST_PHONY_NUMBER); + var data = await call.dial(CALLMANAGER_TEST_PHONY_NUMBER); expect(data).assertTrue(); console.log('Telephony_CallManager_startDTMF_Promise_0400 dial finish : data = ' + data); const startTime = new Date().getTime(); while (true) { - if (callState === call.CALL_STATUS_DIALING || callState === call.CALL_STATUS_ACTIVE) { + if (callState === call.CALL_STATUS_DIALING || callState === call.CALL_STATUS_ACTIVE || + callState === call.CALL_STATUS_ALERTING) { try { await call.startDTMF(callId, 'B'); console.log('Telephony_CallManager_startDTMF_Promise_0400 startDTMF finish : data = ' + data); } catch (err) { expect().assertFail(); console.log('Telephony_CallManager_startDTMF_Promise_0400 startDTMF fail : err = ' + err); + done(); return; } try { await call.stopDTMF(callId); console.log('Telephony_CallManager_startDTMF_Promise_0400 stopDTMF finish : data = ' + data); + done(); } catch (err) { expect().assertFail(); console.log('Telephony_CallManager_startDTMF_Promise_0400 stopDTMF fail : err = ' + err); + done(); return; } - done(); return; } await sleep(waitTime); endTime = new Date().getTime(); - timeOut = endTime - startTime; - if (timeOut > onTime) { + timing = endTime - startTime; + if (timing > timeOut) { + expect().assertFail(); done(); break; } @@ -1660,35 +1806,39 @@ describe('CallManagerOnDial', function () { */ it('Telephony_CallManager_startDTMF_Promise_0500', 0, async function (done) { try { - var data = await call.dial(TEST_PHONY_NUMBER); + var data = await call.dial(CALLMANAGER_TEST_PHONY_NUMBER); expect(data).assertTrue(); console.log('Telephony_CallManager_startDTMF_Promise_0500 dial finish : data = ' + data); const startTime = new Date().getTime(); while (true) { - if (callState === call.CALL_STATUS_DIALING || callState === call.CALL_STATUS_ACTIVE) { + if (callState === call.CALL_STATUS_DIALING || callState === call.CALL_STATUS_ACTIVE || + callState === call.CALL_STATUS_ALERTING) { try { await call.startDTMF(callId, '7'); console.log('Telephony_CallManager_startDTMF_Promise_0500 startDTMF finish : data = ' + data); } catch (err) { expect().assertFail(); console.log('Telephony_CallManager_startDTMF_Promise_0500 startDTMF fail : err = ' + err); + done(); return; } try { await call.stopDTMF(callId); console.log('Telephony_CallManager_startDTMF_Promise_0500 stopDTMF finish : data = ' + data); + done(); } catch (err) { expect().assertFail(); console.log('Telephony_CallManager_startDTMF_Promise_0500 stopDTMF fail : err = ' + err); + done(); return; } - done(); return; } await sleep(waitTime); endTime = new Date().getTime(); - timeOut = endTime - startTime; - if (timeOut > onTime) { + timing = endTime - startTime; + if (timing > timeOut) { + expect().assertFail(); done(); break; } @@ -1707,32 +1857,38 @@ describe('CallManagerOnDial', function () { */ it('Telephony_CallManager_startDTMF_Promise_0600', 0, async function (done) { try { - var data = await call.dial(TEST_PHONY_NUMBER); + var data = await call.dial(CALLMANAGER_TEST_PHONY_NUMBER); expect(data).assertTrue(); console.log('Telephony_CallManager_startDTMF_Promise_0600 dial finish : data = ' + data); const startTime = new Date().getTime(); while (true) { - if (callState === call.CALL_STATUS_DIALING || callState === call.CALL_STATUS_ACTIVE) { + if (callState === call.CALL_STATUS_DIALING || callState === call.CALL_STATUS_ACTIVE || + callState === call.CALL_STATUS_ALERTING) { try { await call.startDTMF(callId, 'Z'); console.log('Telephony_CallManager_startDTMF_Promise_0600 startDTMF fail'); + done(); + return; } catch (err) { console.log('Telephony_CallManager_startDTMF_Promise_0600 startDTMF finish : err = ' + err); } try { await call.stopDTMF(callId); console.log('Telephony_CallManager_startDTMF_Promise_0600 stopDTMF finish : data = ' + data); + done(); } catch (err) { expect().assertFail(); console.log('Telephony_CallManager_startDTMF_Promise_0600 stopDTMF fail : err = ' + err); + done(); + return; } - done(); return; } await sleep(waitTime); endTime = new Date().getTime(); - timeOut = endTime - startTime; - if (timeOut > onTime) { + timing = endTime - startTime; + if (timing > timeOut) { + expect().assertFail(); done(); break; } @@ -1751,34 +1907,39 @@ describe('CallManagerOnDial', function () { */ it('Telephony_CallManager_startDTMF_Promise_0700', 0, async function (done) { try { - var data = await call.dial(TEST_PHONY_NUMBER); + var data = await call.dial(CALLMANAGER_TEST_PHONY_NUMBER); expect(data).assertTrue(); console.log('Telephony_CallManager_startDTMF_Promise_0700 dial finish : data = ' + data); const startTime = new Date().getTime(); while (true) { - if (callState === call.CALL_STATUS_DIALING || callState === call.CALL_STATUS_ACTIVE) { + if (callState === call.CALL_STATUS_DIALING || callState === call.CALL_STATUS_ACTIVE || + callState === call.CALL_STATUS_ALERTING) { try { await call.startDTMF(callId, 'a'); expect().assertFail(); console.log('Telephony_CallManager_startDTMF_Promise_0700 startDTMF fail'); + done(); + return; } catch (err) { console.log('Telephony_CallManager_startDTMF_Promise_0700 startDTMF finish : err = ' + err); } try { await call.stopDTMF(callId); console.log('Telephony_CallManager_startDTMF_Promise_0700 stopDTMF finish : data = ' + data); + done(); } catch (err) { expect().assertFail(); console.log('Telephony_CallManager_startDTMF_Promise_0700 stopDTMF fail : err = ' + err); + done(); return; } - done(); return; } await sleep(waitTime); endTime = new Date().getTime(); - timeOut = endTime - startTime; - if (timeOut > onTime) { + timing = endTime - startTime; + if (timing > timeOut) { + expect().assertFail(); done(); break; } @@ -1797,34 +1958,39 @@ describe('CallManagerOnDial', function () { */ it('Telephony_CallManager_startDTMF_Promise_0800', 0, async function (done) { try { - var data = await call.dial(TEST_PHONY_NUMBER); + var data = await call.dial(CALLMANAGER_TEST_PHONY_NUMBER); expect(data).assertTrue(); console.log('Telephony_CallManager_startDTMF_Promise_0800 dial finish : data = ' + data); const startTime = new Date().getTime(); while (true) { - if (callState === call.CALL_STATUS_DIALING || callState === call.CALL_STATUS_ACTIVE) { + if (callState === call.CALL_STATUS_DIALING || callState === call.CALL_STATUS_ACTIVE || + callState === call.CALL_STATUS_ALERTING) { try { await call.startDTMF(callId, '*'); console.log('Telephony_CallManager_startDTMF_Promise_0800 startDTMF finish : data = ' + data); } catch (err) { expect().assertFail(); console.log('Telephony_CallManager_startDTMF_Promise_0800 startDTMF fail : err = ' + err); + done(); return; } try { await call.stopDTMF(callId); console.log('Telephony_CallManager_startDTMF_Promise_0800 stopDTMF finish : data = ' + data); + done(); } catch (err) { expect().assertFail(); console.log('Telephony_CallManager_startDTMF_Promise_0800 stopDTMF fail : err = ' + err); + done(); + return; } - done(); return; } await sleep(waitTime); endTime = new Date().getTime(); - timeOut = endTime - startTime; - if (timeOut > onTime) { + timing = endTime - startTime; + if (timing > timeOut) { + expect().assertFail(); done(); break; } @@ -1843,35 +2009,39 @@ describe('CallManagerOnDial', function () { */ it('Telephony_CallManager_startDTMF_Promise_0900', 0, async function (done) { try { - var data = await call.dial(TEST_PHONY_NUMBER); + var data = await call.dial(CALLMANAGER_TEST_PHONY_NUMBER); expect(data).assertTrue(); console.log('Telephony_CallManager_startDTMF_Promise_0900 dial finish : data = ' + data); const startTime = new Date().getTime(); while (true) { - if (callState === call.CALL_STATUS_DIALING || callState === call.CALL_STATUS_ACTIVE) { + if (callState === call.CALL_STATUS_DIALING || callState === call.CALL_STATUS_ACTIVE || + callState === call.CALL_STATUS_ALERTING) { try { await call.startDTMF(callId, '#'); console.log('Telephony_CallManager_startDTMF_Promise_0900 startDTMF finish : data = ' + data); } catch (err) { expect().assertFail(); console.log('Telephony_CallManager_startDTMF_Promise_0900 startDTMF fail : err = ' + err); + done(); return; } try { await call.stopDTMF(callId); console.log('Telephony_CallManager_startDTMF_Promise_0900 stopDTMF finish : data = ' + data); + done(); } catch (err) { expect().assertFail(); console.log('Telephony_CallManager_startDTMF_Promise_0900 stopDTMF fail : err = ' + err); + done(); return; } - done(); return; } await sleep(waitTime); endTime = new Date().getTime(); - timeOut = endTime - startTime; - if (timeOut > onTime) { + timing = endTime - startTime; + if (timing > timeOut) { + expect().assertFail(); done(); break; } @@ -1889,7 +2059,7 @@ describe('CallManagerOnDial', function () { * @tc.desc Function test */ it('Telephony_CallManager_stopDTMF_Async_0200', 0, async function (done) { - call.dial(TEST_PHONY_NUMBER, async (err, data) => { + call.dial(CALLMANAGER_TEST_PHONY_NUMBER, async (err, data) => { if (err) { expect().assertFail(); console.log('Telephony_CallManager_stopDTMF_Async_0200 dial fail : err = ' + err); @@ -1900,22 +2070,26 @@ describe('CallManagerOnDial', function () { console.log('Telephony_CallManager_stopDTMF_Async_0200 dial finish : data = ' + data); const startTime = new Date().getTime(); while (true) { - if (callState === call.CALL_STATUS_DIALING || callState === call.CALL_STATUS_ACTIVE) { + if (callState === call.CALL_STATUS_DIALING || callState === call.CALL_STATUS_ACTIVE || + callState === call.CALL_STATUS_ALERTING) { call.stopDTMF(callId, (err) => { if (err) { expect().assertFail(); console.log('Telephony_CallManager_stopDTMF_Async_0200 stopDTMF fail : err = ' + err); + done(); return; } console.log('Telephony_CallManager_stopDTMF_Async_0200 stopDTMF finish : data = ' + data); + done(); + return; }) - done(); return; } await sleep(waitTime); endTime = new Date().getTime(); - timeOut = endTime - startTime; - if (timeOut > onTime) { + timing = endTime - startTime; + if (timing > timeOut) { + expect().assertFail(); done(); break; } @@ -1930,27 +2104,30 @@ describe('CallManagerOnDial', function () { */ it('Telephony_CallManager_stopDTMF_Promise_0200', 0, async function (done) { try { - var data = await call.dial(TEST_PHONY_NUMBER); + var data = await call.dial(CALLMANAGER_TEST_PHONY_NUMBER); expect(data).assertTrue(); console.log('Telephony_CallManager_stopDTMF_Promise_0200 dial finish : data = ' + data); const startTime = new Date().getTime(); while (true) { - if (callState === call.CALL_STATUS_DIALING || callState === call.CALL_STATUS_ACTIVE) { + if (callState === call.CALL_STATUS_DIALING || callState === call.CALL_STATUS_ACTIVE || + callState === call.CALL_STATUS_ALERTING) { try { await call.stopDTMF(callId); console.log('Telephony_CallManager_stopDTMF_Promise_0200 stopDTMF finish : data = ' + data); + done(); } catch (err) { console.log('Telephony_CallManager_stopDTMF_Promise_0200 stopDTMF fail : err = ' + err); expect().assertFail(); + done(); return; } - done(); return; } await sleep(waitTime); endTime = new Date().getTime(); - timeOut = endTime - startTime; - if (timeOut > onTime) { + timing = endTime - startTime; + if (timing > timeOut) { + expect().assertFail(); done(); break; } @@ -1968,7 +2145,7 @@ describe('CallManagerOnDial', function () { * @tc.desc Function test */ it('Telephony_CallManager_combineConference_Async_0200', 0, async function (done) { - call.dial(TEST_PHONY_NUMBER, async (err, data) => { + call.dial(CALLMANAGER_TEST_PHONY_NUMBER, async (err, data) => { if (err) { expect().assertFail(); console.log('Telephony_CallManager_combineConference_Async_0200 dial fail : err = ' + err); @@ -1979,7 +2156,8 @@ describe('CallManagerOnDial', function () { console.log('Telephony_CallManager_combineConference_Async_0200 dial finish : data = ' + data); const startTime = new Date().getTime(); while (true) { - if (callState === call.CALL_STATUS_DIALING || callState === call.CALL_STATUS_ACTIVE) { + if (callState === call.CALL_STATUS_DIALING || callState === call.CALL_STATUS_ACTIVE || + callState === call.CALL_STATUS_ALERTING) { call.combineConference(callId, (err) => { if (err) { console.log('Telephony_CallManager_combineConference_Async_0200 finish : err = ' + err); @@ -1988,15 +2166,16 @@ describe('CallManagerOnDial', function () { } console.log('Telephony_CallManager_combineConference_Async_0200 fail'); expect().assertFail(); - console.log('Telephony_CallManager_combineConference_Async_0200 finish : err = ' + err); + done(); + return; }) - done(); return; } await sleep(waitTime); endTime = new Date().getTime(); - timeOut = endTime - startTime; - if (timeOut > onTime) { + timing = endTime - startTime; + if (timing > timeOut) { + expect().assertFail(); done(); break; } @@ -2011,27 +2190,30 @@ describe('CallManagerOnDial', function () { */ it('Telephony_CallManager_combineConference_Promise_0200', 0, async function (done) { try { - var data = await call.dial(TEST_PHONY_NUMBER); + var data = await call.dial(CALLMANAGER_TEST_PHONY_NUMBER); expect(data).assertTrue(); console.log('Telephony_CallManager_combineConference_Promise_0200 dial finish : data = ' + data); const startTime = new Date().getTime(); while (true) { - if (callState === call.CALL_STATUS_DIALING || callState === call.CALL_STATUS_ACTIVE) { + if (callState === call.CALL_STATUS_DIALING || callState === call.CALL_STATUS_ACTIVE || + callState === call.CALL_STATUS_ALERTING) { try { await call.combineConference(callId); expect().assertFail(); console.log('Telephony_CallManager_combineConference_Promise_0200 fail'); + done(); } catch (err) { console.log('Telephony_CallManager_combineConference_Promise_0200 finish : err = ' + err); done(); + return; } - done(); return; } await sleep(waitTime); endTime = new Date().getTime(); - timeOut = endTime - startTime; - if (timeOut > onTime) { + timing = endTime - startTime; + if (timing > timeOut) { + expect().assertFail(); done(); break; } @@ -2049,7 +2231,7 @@ describe('CallManagerOnDial', function () { * @tc.desc Function test */ it('Telephony_CallManager_getMainCallId_Async_0200', 0, async function (done) { - call.dial(TEST_PHONY_NUMBER,async (err, data) => { + call.dial(CALLMANAGER_TEST_PHONY_NUMBER,async (err, data) => { if (err) { expect().assertFail(); console.log('Telephony_CallManager_getMainCallId_Async_0200 dial fail : err = ' + err); @@ -2060,22 +2242,27 @@ describe('CallManagerOnDial', function () { console.log('Telephony_CallManager_getMainCallId_Async_0200 dial finish : data = ' + data); const startTime = new Date().getTime(); while (true) { - if (callState === call.CALL_STATUS_DIALING || callState === call.CALL_STATUS_ACTIVE) { + if (callState === call.CALL_STATUS_DIALING || callState === call.CALL_STATUS_ACTIVE || + callState === call.CALL_STATUS_ALERTING) { call.getMainCallId(callId, (err, data) => { if (err) { expect().assertFail(); console.log('Telephony_CallManager_getMainCallId_Async_0200 fail : err = ' + err); + done(); + return; } expect(data === GETMAIN_CALLID_ERRO).assertTrue(); console.log('Telephony_CallManager_getMainCallId_Async_0200 finish : data = ' + data); + done(); + return; }) - done(); return; } await sleep(waitTime); endTime = new Date().getTime(); - timeOut = endTime - startTime; - if (timeOut > onTime) { + timing = endTime - startTime; + if (timing > timeOut) { + expect().assertFail(); done(); break; } @@ -2090,28 +2277,31 @@ describe('CallManagerOnDial', function () { */ it('Telephony_CallManager_getMainCallId_Promise_0200', 0, async function (done) { try { - var data = await call.dial(TEST_PHONY_NUMBER); + var data = await call.dial(CALLMANAGER_TEST_PHONY_NUMBER); expect(data).assertTrue(); console.log('Telephony_CallManager_getMainCallId_Promise_0200 dial finish : data = ' + data); const startTime = new Date().getTime(); while (true) { - if (callState === call.CALL_STATUS_DIALING || callState === call.CALL_STATUS_ACTIVE) { + if (callState === call.CALL_STATUS_DIALING || callState === call.CALL_STATUS_ACTIVE || + callState === call.CALL_STATUS_ALERTING) { try { var data = await call.getMainCallId(callId); expect(data === GETMAIN_CALLID_ERRO).assertTrue(); console.log('Telephony_CallManager_getMainCallId_Promise_0200 finish : data = ' + data); + done(); } catch (err) { expect().assertFail(); console.log('Telephony_CallManager_getMainCallId_Promise_0200 fail : err = ' + err); + done(); return; } - done(); return; } await sleep(waitTime); endTime = new Date().getTime(); - timeOut = endTime - startTime; - if (timeOut > onTime) { + timing = endTime - startTime; + if (timing > timeOut) { + expect().assertFail(); done(); break; } @@ -2129,7 +2319,7 @@ describe('CallManagerOnDial', function () { * @tc.desc Function test */ it('Telephony_CallManager_getSubCallIdList_Async_0200', 0, async function (done) { - call.dial(TEST_PHONY_NUMBER, async (err, data) => { + call.dial(CALLMANAGER_TEST_PHONY_NUMBER, async (err, data) => { if (err) { expect().assertFail(); console.log('Telephony_CallManager_getSubCallIdList_Async_0200 dial fail : err = ' + err); @@ -2140,23 +2330,27 @@ describe('CallManagerOnDial', function () { console.log('Telephony_CallManager_getSubCallIdList_Async_0200 dial finish : data = ' + data); const startTime = new Date().getTime(); while (true) { - if (callState === call.CALL_STATUS_DIALING || callState === call.CALL_STATUS_ACTIVE) { + if (callState === call.CALL_STATUS_DIALING || callState === call.CALL_STATUS_ACTIVE || + callState === call.CALL_STATUS_ALERTING) { call.getSubCallIdList(callId, (err, data) => { if (err) { expect().assertFail(); console.log('Telephony_CallManager_getSubCallIdList_Async_0200 fail : err = ' + err); + done(); return; } expect(data.length === 0).assertTrue(); console.log('Telephony_CallManager_getSubCallIdList_Async_0200 finish : data = ' + data); + done(); + return; }) - done(); return; } await sleep(waitTime); endTime = new Date().getTime(); - timeOut = endTime - startTime; - if (timeOut > onTime) { + timing = endTime - startTime; + if (timing > timeOut) { + expect().assertFail(); done(); break; } @@ -2171,28 +2365,31 @@ describe('CallManagerOnDial', function () { */ it('Telephony_CallManager_getSubCallIdList_Promise_0200', 0, async function (done) { try { - var data = await call.dial(TEST_PHONY_NUMBER); + var data = await call.dial(CALLMANAGER_TEST_PHONY_NUMBER); expect(data).assertTrue(); console.log('Telephony_CallManager_getSubCallIdList_Promise_0200 dial finish : data = ' + data); const startTime = new Date().getTime(); while (true) { - if (callState === call.CALL_STATUS_DIALING || callState === call.CALL_STATUS_ACTIVE) { + if (callState === call.CALL_STATUS_DIALING || callState === call.CALL_STATUS_ACTIVE || + callState === call.CALL_STATUS_ALERTING) { try { var data = await call.getSubCallIdList(callId); expect(data.length === 0).assertTrue(); console.log('Telephony_CallManager_getSubCallIdList_Promise_0200 finish : data = ' + data); + done(); } catch (err) { console.log('Telephony_CallManager_getSubCallIdList_Promise_0200 fail : err = ' + err); expect().assertFail(); + done(); return; } - done(); return; } await sleep(waitTime); endTime = new Date().getTime(); - timeOut = endTime - startTime; - if (timeOut > onTime) { + timing = endTime - startTime; + if (timing > timeOut) { + expect().assertFail(); done(); break; } @@ -2211,7 +2408,7 @@ describe('CallManagerOnDial', function () { * @tc.desc Function test */ it('Telephony_CallManager_getCallIdListForConference_Async_0200', 0, async function (done) { - call.dial(TEST_PHONY_NUMBER, async (err, data) => { + call.dial(CALLMANAGER_TEST_PHONY_NUMBER, async (err, data) => { if (err) { expect().assertFail(); console.log('Telephony_CallManager_getCallIdListForConference_Async_0200 dial fail : err = ' + err); @@ -2222,27 +2419,31 @@ describe('CallManagerOnDial', function () { console.log('Telephony_CallManager_getCallIdListForConference_Async_0200 dial finish : data = ' + data); const startTime = new Date().getTime(); while (true) { - if (callState === call.CALL_STATUS_DIALING || callState === call.CALL_STATUS_ACTIVE) { + if (callState === call.CALL_STATUS_DIALING || callState === call.CALL_STATUS_ACTIVE || + callState === call.CALL_STATUS_ALERTING) { call.getCallIdListForConference(callId, (err, data) => { if (err) { expect().assertFail(); console.log( 'Telephony_CallManager_getCallIdListForConference_Async_0200 fail : err = ' + err ); + done(); return; } expect(data.length === 0).assertTrue(); console.log( 'Telephony_CallManager_getCallIdListForConference_Async_0200 finish : data = ' + data ); + done(); + return; }) - done(); return; } await sleep(waitTime); endTime = new Date().getTime(); - timeOut = endTime - startTime; - if (timeOut > onTime) { + timing = endTime - startTime; + if (timing > timeOut) { + expect().assertFail(); done(); break; } @@ -2258,32 +2459,36 @@ describe('CallManagerOnDial', function () { */ it('Telephony_CallManager_getCallIdListForConference_Promise_0200', 0, async function (done) { try { - var data = await call.dial(TEST_PHONY_NUMBER); + var data = await call.dial(CALLMANAGER_TEST_PHONY_NUMBER); expect(data).assertTrue(); console.log('Telephony_CallManager_getCallIdListForConference_Promise_0200 dial finish : data = ' + data); const startTime = new Date().getTime(); while (true) { - if (callState === call.CALL_STATUS_DIALING || callState === call.CALL_STATUS_ACTIVE) { + if (callState === call.CALL_STATUS_DIALING || callState === call.CALL_STATUS_ACTIVE || + callState === call.CALL_STATUS_ALERTING) { try { var data = await call.getCallIdListForConference(callId); expect(data.length === 0).assertTrue(); console.log( 'Telephony_CallManager_getCallIdListForConference_Promise_0200 finish : data = ' + data ); + done(); + return; } catch (err) { expect().assertFail(); console.log( 'Telephony_CallManager_getCallIdListForConference_Promise_0200 fail : err = ' + err ); + done(); return; } - done(); return; } await sleep(waitTime); endTime = new Date().getTime(); - timeOut = endTime - startTime; - if (timeOut > onTime) { + timing = endTime - startTime; + if (timing > timeOut) { + expect().assertFail(); done(); break; } @@ -2302,7 +2507,7 @@ describe('CallManagerOnDial', function () { * @tc.desc Function test */ it('Telephony_CallManager_isInEmergencyCall_Async_0100', 0, async function (done) { - call.dial(TEST_PHONY_NUMBER, async (err, data) => { + call.dial(CALLMANAGER_TEST_PHONY_NUMBER, async (err, data) => { if (err) { expect().assertFail(); console.log('Telephony_CallManager_isInEmergencyCall_Async_0100 dial fail : err = ' + err); @@ -2313,7 +2518,8 @@ describe('CallManagerOnDial', function () { console.log('Telephony_CallManager_isInEmergencyCall_Async_0100 dial finish : data = ' + data); const startTime = new Date().getTime(); while (true) { - if (callState === call.CALL_STATUS_DIALING || callState === call.CALL_STATUS_ACTIVE) { + if (callState === call.CALL_STATUS_DIALING || callState === call.CALL_STATUS_ACTIVE || + callState === call.CALL_STATUS_ALERTING) { call.isInEmergencyCall((err, data) => { if (err) { console.log( @@ -2321,20 +2527,24 @@ describe('CallManagerOnDial', function () { err ); expect().assertFail(); + done(); + return; } expect(data === false).assertTrue(); console.log( 'Telephony_CallManager_isInEmergencyCall_Async_0100 isInEmrgencyCall finish : data = ' + data ); + done(); + return; }) - done(); return; } await sleep(waitTime); endTime = new Date().getTime(); - timeOut = endTime - startTime; - if (timeOut > onTime) { + timing = endTime - startTime; + if (timing > timeOut) { + expect().assertFail(); done(); break; } @@ -2344,12 +2554,12 @@ describe('CallManagerOnDial', function () { /* * @tc.number Telephony_CallManager_isInEmergencyCall_Async_0200 - * @tc.name Dial an emergency number (112) and call isInEmergencyCall() to determine whether an emergency - * call is made, returning true + * @tc.name Dial an emergency number (THE_THREE_NUMBER) and call isInEmergencyCall() to determine whether + * an emergency call is made, returning true * @tc.desc Function test */ it('Telephony_CallManager_isInEmergencyCall_Async_0200', 0, async function (done) { - call.dial('112', async (err, data) => { + call.dial(THE_THREE_NUMBER, async (err, data) => { if (err) { expect().assertFail(); console.log('Telephony_CallManager_isInEmergencyCall_Async_0200 dial fail : err = ' + err); @@ -2360,7 +2570,8 @@ describe('CallManagerOnDial', function () { console.log('Telephony_CallManager_isInEmergencyCall_Async_0200 dial finish : data = ' + data); const startTime = new Date().getTime(); while (true) { - if (callState === call.CALL_STATUS_DIALING || callState === call.CALL_STATUS_ACTIVE) { + if (callState === call.CALL_STATUS_DIALING || callState === call.CALL_STATUS_ACTIVE || + callState === call.CALL_STATUS_ALERTING ) { call.isInEmergencyCall((err, data) => { if (err) { console.log( @@ -2368,6 +2579,7 @@ describe('CallManagerOnDial', function () { err ); expect().assertFail(); + done(); return; } expect(data).assertTrue(); @@ -2375,14 +2587,16 @@ describe('CallManagerOnDial', function () { 'Telephony_CallManager_isInEmergencyCall_Async_0200 isInEmrgencyCall finish : data = ' + data ); + done(); + return; }) - done(); return; } await sleep(waitTime); endTime = new Date().getTime(); - timeOut = endTime - startTime; - if (timeOut > onTime) { + timing = endTime - startTime; + if (timing > timeOut) { + expect().assertFail(); done(); break; } @@ -2403,22 +2617,26 @@ describe('CallManagerOnDial', function () { console.log('Telephony_CallManager_isInEmergencyCall_Promise_0100 dial finish : data = ' + data); const startTime = new Date().getTime(); while (true) { - if (callState === call.CALL_STATUS_DIALING || callState === call.CALL_STATUS_ACTIVE) { + if (callState === call.CALL_STATUS_DIALING || callState === call.CALL_STATUS_ACTIVE || + callState === call.CALL_STATUS_ALERTING) { try { var data = await call.isInEmergencyCall(); expect(data === false).assertTrue(); console.log('Telephony_CallManager_isInEmergencyCall_Promise_0100 finish : data = ' + data); + done(); } catch (err) { expect().assertFail(); console.log('Telephony_CallManager_isInEmergencyCall_Promise_0100 fail : err = ' + err); + done(); + return; } - done(); return; } await sleep(waitTime); endTime = new Date().getTime(); - timeOut = endTime - startTime; - if (timeOut > onTime) { + timing = endTime - startTime; + if (timing > timeOut) { + expect().assertFail(); done(); break; } @@ -2432,33 +2650,37 @@ describe('CallManagerOnDial', function () { /* * @tc.number Telephony_CallManager_isInEmergencyCall_Promise_0200 - * @tc.name Dial an emergency number (112) and call isInEmergencyCall() to determine whether + * @tc.name Dial an emergency number (THE_THREE_NUMBER) and call isInEmergencyCall() to determine whether * an emergency call is made. The return value is true * @tc.desc Function test */ it('Telephony_CallManager_isInEmergencyCall_Promise_0200', 0, async function (done) { try { - var data = await call.dial('112'); + var data = await call.dial(THE_THREE_NUMBER); expect(data).assertTrue(); console.log('Telephony_CallManager_isInEmergencyCall_Promise_0200 dial finish : data = ' + data); const startTime = new Date().getTime(); while (true) { - if (callState === call.CALL_STATUS_DIALING || callState === call.CALL_STATUS_ACTIVE) { + if (callState === call.CALL_STATUS_DIALING || callState === call.CALL_STATUS_ACTIVE || + callState === call.CALL_STATUS_ALERTING) { try { var data = await call.isInEmergencyCall(); expect(data).assertTrue(); console.log('Telephony_CallManager_isInEmergencyCall_Promise_0200 finish : data = ' + data); + done(); } catch (err) { expect().assertFail(); console.log('Telephony_CallManager_isInEmergencyCall_Promise_0200 fail : err = ' + err); + done(); + return; } - done(); return; } await sleep(waitTime); endTime = new Date().getTime(); - timeOut = endTime - startTime; - if (timeOut > onTime) { + timing = endTime - startTime; + if (timing > timeOut) { + expect().assertFail(); done(); break; } @@ -2469,4 +2691,96 @@ describe('CallManagerOnDial', function () { done(); } }) + + /* + * @tc.number Telephony_CallManager_reject_Async_0400 + * @tc.name Make a call to a normal number (10086) and call reject with message REJECT_MESSAGE_NUM by callback, + * the function return error + * @tc.desc Function test + */ + it('Telephony_CallManager_reject_Async_0400', 0, async function (done) { + call.dial(CALLMANAGER_TEST_PHONY_NUMBER, async (err, data) => { + if (err) { + expect().assertFail(); + console.log(`Telephony_CallManager_reject_Async_0400 dial fail : err = ${err}`); + done(); + return; + } + expect(data).assertTrue(); + console.log(`Telephony_CallManager_reject_Async_0400 dial finish : data = ${data}`); + const startTime = new Date().getTime(); + while (true) { + if (callState === call.CALL_STATUS_DIALING || callState === call.CALL_STATUS_ACTIVE || + callState === call.CALL_STATUS_ALERTING) { + call.reject(call.callId, new RejectMessageOptions(REJECT_MESSAGE_NUM), (err, data) => { + if (err) { + console.log( + `Telephony_CallManager_reject_Async_0400 isInEmrgencyCall finish : err = ${ + err}` + ); + done(); + return; + } + console.log( + `Telephony_CallManager_reject_Async_0400 isInEmrgencyCall fail : data = ${ + data}` + ); + expect().assertFail(); + done(); + }); + return; + } + await sleep(waitTime); + endTime = new Date().getTime(); + timing = endTime - startTime; + if (timing > timeOut) { + expect().assertFail(); + done(); + break; + } + } + }); + }); + + /* + * @tc.number Telephony_CallManager_reject_Promise_0400 + * @tc.name Make a call to a normal number (10086) and call reject with message by promise, + * the function return error + * @tc.desc Function test + */ + it('Telephony_CallManager_reject_Promise_0400', 0, async function (done) { + try { + var data = await call.dial(CALLMANAGER_TEST_PHONY_NUMBER); + expect(data).assertTrue(); + console.log(`Telephony_CallManager_reject_Promise_0400 dial finish : data = ${data}`); + const startTime = new Date().getTime(); + while (true) { + if (callState === call.CALL_STATUS_DIALING || callState === call.CALL_STATUS_ACTIVE || + callState === call.CALL_STATUS_ALERTING) { + try { + var data = await call.reject(call.callId, new RejectMessageOptions(REJECT_MESSAGE_STR)); + expect().assertFail(); + console.log(`Telephony_CallManager_reject_Promise_0400 fail : data = ${data}`); + done(); + } catch (err) { + console.log(`Telephony_CallManager_reject_Promise_0400 finish : err = ${err}`); + done(); + } + return; + } + await sleep(waitTime); + endTime = new Date().getTime(); + timing = endTime - startTime; + if (timing > timeOut) { + expect().assertFail(); + done(); + break; + } + } + } catch (err) { + expect().assertFail(); + console.log(`Telephony_CallManager_reject_Promise_0400 dial fail : err = ${err}`); + done(); + } + }); }) \ No newline at end of file diff --git a/telephony/telephonyjstest/call_manager/call_manager_test/BUILD.gn b/telephony/telephonyjstest/call_manager/call_manager_test/BUILD.gn index 9ae38c44cb513271f967bbeccc6bca2667291990..4c5d71c8d19ade800b0db78de884b2cf783a9d50 100644 --- a/telephony/telephonyjstest/call_manager/call_manager_test/BUILD.gn +++ b/telephony/telephonyjstest/call_manager/call_manager_test/BUILD.gn @@ -28,4 +28,4 @@ ohos_js_assets("hjs_demo_js_assets") { ohos_resources("hjs_demo_resources") { sources = [ "./entry/src/main/js/resources" ] hap_profile = "./entry/src/main/config.json" -} +} \ No newline at end of file diff --git a/telephony/telephonyjstest/call_manager/call_manager_test/entry/src/main/js/test/CallManagerTest.test.js b/telephony/telephonyjstest/call_manager/call_manager_test/entry/src/main/js/test/CallManagerTest.test.js index cd8df1deba9ab878d30bb21758396ae5041d2efb..a0d97059983b8f52ab36a6d2006f8c78885dd8c8 100644 --- a/telephony/telephonyjstest/call_manager/call_manager_test/entry/src/main/js/test/CallManagerTest.test.js +++ b/telephony/telephonyjstest/call_manager/call_manager_test/entry/src/main/js/test/CallManagerTest.test.js @@ -18,9 +18,12 @@ import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from ' describe('CallManagerTest', function () { const ERROR_CALLID_999 = 999; const GETMAIN_CALLID_ERRO = -1; - const STATUS_ON = 1; const SLOT_0 = 0; const ERR_SLOT_ID = -1; + const MORE_THAN_30_NUMBERS = ''; + const INVALID_NUMBER = ''; + const ACTIVATE_TRUE = true; + const ACTIVATE_FALSE = false; /* * @tc.number Telephony_CallManager_getCallState_Async_0100 @@ -53,13 +56,13 @@ describe('CallManagerTest', function () { var data = await call.getCallState(); expect(data === call.CALL_STATE_IDLE).assertTrue(); console.log('Telephony_CallManager_getCallState_Promise_0100 finish data = ' + data); + done(); } catch (err) { console.log('Telephony_CallManager_getCallState_Promise_0100 : err = ' + err.message); expect().assertFail(); done(); return; } - done(); }) /* @@ -68,7 +71,7 @@ describe('CallManagerTest', function () { * @tc.desc Function test */ it('Telephony_CallManager_dial_Async_0200', 0, async function (done) { - call.dial('', (err) => { + call.dial('', (err, data) => { if (err) { console.log('Telephony_CallManager_dial_Async_0200 finish err = ' + err.message); done(); @@ -83,12 +86,12 @@ describe('CallManagerTest', function () { /* * @tc.number Telephony_CallManager_dial_Async_0300 * @tc.name Set will choose parameter number phone number more than 30 characters - * (' 12345678901234567890012345678901 ', separate phone number did not take ', '), + * ( '12345678901234567890012345678901' , separate phone number did not take ', '), * the callback way call dial () to dial, capture err * @tc.desc Function test */ it('Telephony_CallManager_dial_Async_0300', 0, async function (done) { - call.dial('12345678901234567890012345678901', (err) => { + call.dial(MORE_THAN_30_NUMBERS, (err, data) => { if (err) { console.log('Telephony_CallManager_dial_Async_0300 finish err = ' + err.message); done(); @@ -103,7 +106,7 @@ describe('CallManagerTest', function () { /* * @tc.number Telephony_CallManager_dial_Promise_0200 * @tc.name Set mandatory phone number to empty (' ') and optional options to - * {accountId: 1, videoState: 0, dialScene: 0, dialType: 0}. Call dial() to dial and capture err + * {accountId: 1}. Call dial() to dial and capture err * @tc.desc Function test */ it('Telephony_CallManager_dial_Promise_0200', 0, async function (done) { @@ -111,12 +114,12 @@ describe('CallManagerTest', function () { await call.dial('', { accountId: 1 }) console.log('Telephony_CallManager_dial_Promise_0200 fail'); expect().assertFail(); + done(); } catch (err) { console.log('Telephony_CallManager_dial_Promise_0200 finish err = ' + err.message); done(); return; } - done(); }) /* @@ -127,15 +130,15 @@ describe('CallManagerTest', function () { */ it('Telephony_CallManager_dial_Promise_0900', 0, async function (done) { try { - await call.dial('12345678901234567890012345678901'); + await call.dial(MORE_THAN_30_NUMBERS); expect().assertFail(); console.log('Telephony_CallManager_dial_Promise_0900 fail'); + done(); } catch (err) { console.log('Telephony_CallManager_dial_Promise_0900 finish err = ' + err.message); done(); return; } - done(); }) /* @@ -146,7 +149,7 @@ describe('CallManagerTest', function () { */ it('Telephony_CallManager_dial_Async_0900', 0, async function (done) { let obj = { accountId: 0, videoState: 0, dialScene: 0, dialType: 0 }; - call.dial('', obj, (err) => { + call.dial('', obj, (err, data) => { if (err) { console.log('Telephony_CallManager_dial_Async_0900 finish err = ' + err.message); done(); @@ -188,12 +191,12 @@ describe('CallManagerTest', function () { await call.holdCall(ERROR_CALLID_999); expect().assertFail(); console.log('Telephony_CallManager_holdCall_Promise_0100 fail'); + done(); } catch (err) { console.log('Telephony_CallManager_holdCall_Promise_0100 finish err = ' + err.message); done(); return; } - done(); }) /* @@ -263,42 +266,43 @@ describe('CallManagerTest', function () { await call.switchCall(ERROR_CALLID_999); expect().assertFail(); console.log('Telephony_CallManager_switchCall_Promise_0100 fail'); + done(); } catch (err) { console.log('Telephony_CallManager_switchCall_Promise_0100 finish err = ' + err); done(); return; } - done(); }) - /* + /* * @tc.number Telephony_CallManager_hasCall_Async_0100 * @tc.name After an empty call is automatically hung up, the callback method calls hasCall() to confirm that * there is no current call, returning false * @tc.desc Function test */ - it('Telephony_CallManager_hasCall_Async_0100', 0, async function (done) { - call.dial('', (err) => { - if (err) { - console.log('Telephony_CallManager_hasCall_Async_0100 dial finish err = ' + err.message); - call.hasCall((err, data) => { - if (err) { - console.log('Telephony_CallManager_hasCall_Async_0400 fail'); - expect().assertFail(); - done(); - return; - } - expect(data === false).assertTrue(); - console.log('Telephony_CallManager_hasCall_Async_0100 finish data = ' + data); - }) - done(); - return; - } - expect().assertFail(); - console.log('Telephony_CallManager_hasCall_Async_0100 dial fail'); - done(); - }) - }) + it('Telephony_CallManager_hasCall_Async_0100', 0, async function (done) { + call.dial('', (err) => { + if (err) { + console.log('Telephony_CallManager_hasCall_Async_0100 dial finish err = ' + err.message); + call.hasCall((err, data) => { + if (err) { + console.log('Telephony_CallManager_hasCall_Async_0400 fail'); + expect().assertFail(); + done(); + return; + } + expect(data === false).assertTrue(); + console.log('Telephony_CallManager_hasCall_Async_0100 finish data = ' + data); + done(); + return; + }) + return; + } + expect().assertFail(); + console.log('Telephony_CallManager_hasCall_Async_0100 dial fail'); + done(); + }) + }) /* * @tc.number Telephony_CallManager_hasCall_Async_0400 @@ -335,13 +339,13 @@ describe('CallManagerTest', function () { var data = await call.hasCall(); expect(data === false).assertTrue(); console.log('Telephony_CallManager_hasCall_Promise_0100 finish data = ' + data); + done(); } catch (err) { console.log('Telephony_CallManager_hasCall_Promise_0100 fail'); expect().assertFail(); done(); return; } - done(); } }) @@ -355,13 +359,13 @@ describe('CallManagerTest', function () { var data = await call.hasCall(); expect(data === false).assertTrue(); console.log('Telephony_CallManager_hasCall_Promise_0400 finish data = ' + data); + done(); } catch (err) { console.log('Telephony_CallManager_hasCall_Promise_0400 fail'); expect().assertFail(); done(); return; } - done(); }) /* @@ -392,12 +396,12 @@ describe('CallManagerTest', function () { await call.combineConference(ERROR_CALLID_999); console.log('Telephony_CallManager_combineConference_Promise_0100 fail'); expect().assertFail(); + done(); } catch (err) { console.log('Telephony_CallManager_combineConference_Promise_0100 finish err = ' + err.message); done(); return; } - done(); }) /* @@ -429,13 +433,13 @@ describe('CallManagerTest', function () { var data = await call.getSubCallIdList(ERROR_CALLID_999); expect(data.length === 0).assertTrue(); console.log('Telephony_CallManager_getSubCallIdList_Promise_0100 finish data = ' + data); + done(); } catch (err) { console.log('Telephony_CallManager_getSubCallIdList_Promise_0100 fail'); expect().assertFail(); done(); return; } - done(); }) /* @@ -469,12 +473,12 @@ describe('CallManagerTest', function () { var data = await call.getCallIdListForConference(ERROR_CALLID_999); expect(data.length === 0).assertTrue(); console.log('Telephony_CallManager_getCallIdListForConference_Promise_0100 finish data = ' + data); + done(); } catch (err) { console.log('Telephony_CallManager_getCallIdListForConference_Promise_0100 fail'); done(); return; } - done(); }) /* @@ -505,12 +509,12 @@ describe('CallManagerTest', function () { await call.startDTMF(ERROR_CALLID_999, 'C'); console.log('Telephony_CallManager_startDTMF_Promise_1000 fail'); expect().assertFail(); + done(); } catch (err) { console.log('Telephony_CallManager_startDTMF_Promise_1000 finish err = ' + err.message); done(); return; } - done(); }) /* @@ -541,12 +545,12 @@ describe('CallManagerTest', function () { await call.stopDTMF(ERROR_CALLID_999); expect().assertFail(); console.log('Telephony_CallManager_stopDTMF_Promise_0100 fail'); + done(); } catch (err) { console.log('Telephony_CallManager_stopDTMF_Promise_0100 finish err = ' + err.message); done(); return; } - done(); }) /* @@ -576,12 +580,12 @@ describe('CallManagerTest', function () { await call.reject(ERROR_CALLID_999); expect().assertFail(); console.log('Telephony_CallManager_reject_Promise_0100 fail'); + done(); } catch (err) { console.log('Telephony_CallManager_reject_Promise_0100 finish err = ' + err.message); done(); return; } - done(); }) /* @@ -612,12 +616,12 @@ describe('CallManagerTest', function () { await call.hangup(ERROR_CALLID_999); expect().assertFail(); console.log('Telephony_CallManager_hangup_Promise_0100 fail'); + done(); } catch (err) { console.log('Telephony_CallManager_hangup_Promise_0100 finish err = ' + err.message); done(); return; } - done(); }) /* @@ -649,13 +653,13 @@ describe('CallManagerTest', function () { var data = await call.getMainCallId(ERROR_CALLID_999); expect(data === GETMAIN_CALLID_ERRO).assertTrue(); console.log('Telephony_CallManager_getMainCallId_Promise_0100 finish data = ' + data); + done(); } catch (err) { expect().assertFail(); console.log('Telephony_CallManager_getMainCallId_Promise_0100 fail'); done(); return; } - done(); }) /* @@ -842,13 +846,13 @@ describe('CallManagerTest', function () { var data = await call.formatPhoneNumber('2000000'); expect(data === '200 0000').assertTrue(); console.log('Telephony_CallManager_formatPhoneNumber_Promise_0100 finish data = ' + data); + done(); } catch (err) { console.log('Telephony_CallManager_formatPhoneNumber_Promise_0100 fail'); expect().assertFail(); done(); return; } - done(); }) /* @@ -861,12 +865,12 @@ describe('CallManagerTest', function () { await call.formatPhoneNumber('010-100-0000', { countryCode: 'CN' }); expect().assertFail(); console.log('Telephony_CallManager_formatPhoneNumber_Promise_0200 fail'); + done(); } catch (err) { console.log('Telephony_CallManager_formatPhoneNumber_Promise_0200 finish err = ' + err); done(); return; } - done(); }) /* @@ -880,13 +884,13 @@ describe('CallManagerTest', function () { var data = await call.formatPhoneNumber('(010)00000000', { countryCode: 'CN' }); expect(data === '010 0000 0000').assertTrue(); console.log('Telephony_CallManager_formatPhoneNumber_Promise_0300 finish data = ' + data); + done(); } catch (err) { console.log('Telephony_CallManager_formatPhoneNumber_Promise_0300 fail'); expect().assertFail(); done(); return; } - done(); }) /* * @tc.number Telephony_CallManager_formatPhoneNumber_Promise_0400 @@ -899,13 +903,13 @@ describe('CallManagerTest', function () { var data = await call.formatPhoneNumber('200-0000', { countryCode: 'CN' }); expect(data === '200 0000').assertTrue(); console.log('Telephony_CallManager_formatPhoneNumber_Promise_0400 finish data = ' + data); + done(); } catch (err) { console.log('Telephony_CallManager_formatPhoneNumber_Promise_0400 fail'); expect().assertFail(); done(); return; } - done(); }) /* @@ -919,12 +923,12 @@ describe('CallManagerTest', function () { await call.formatPhoneNumber('666666999999', { countryCode: 'CN' }); console.log('Telephony_CallManager_formatPhoneNumber_Promise_0500 fail'); expect().assertFail(); + done(); + return; } catch (err) { console.log('Telephony_CallManager_formatPhoneNumber_Promise_0500 finish err = ' + err.message); done(); - return; } - done(); }) /* @@ -938,12 +942,12 @@ describe('CallManagerTest', function () { await call.formatPhoneNumber('20000000', { countryCode: 'abcdefg' }); expect().assertFail(); console.log('Telephony_CallManager_formatPhoneNumber_Promise_0600 fail'); + done(); + return; } catch (err) { console.log('Telephony_CallManager_formatPhoneNumber_Promise_0600 finish err = ' + err.message); done(); - return; } - done(); }) /* @@ -956,12 +960,12 @@ describe('CallManagerTest', function () { var data = await call.formatPhoneNumber('20000000', { countryCode: '' }); expect().assertFail(); console.log('Telephony_CallManager_formatPhoneNumber_Promise_0700 fail'); + done(); + return; } catch (err) { console.log('Telephony_CallManager_formatPhoneNumber_Promise_0700 finish err = ' + err.message); done(); - return; } - done(); }) /* @@ -1092,13 +1096,13 @@ describe('CallManagerTest', function () { var data = await call.formatPhoneNumberToE164('52300000000', 'CN'); expect(data === '+8652300000000').assertTrue(); console.log('Telephony_CallManager_formatPhoneNumberToE164_Promise_0100 finish data = ' + data); + done(); } catch (err) { console.log('Telephony_CallManager_formatPhoneNumberToE164_Promise_0100 fail'); expect().assertFail(); done(); return; } - done(); }) /* @@ -1113,13 +1117,13 @@ describe('CallManagerTest', function () { var data = await call.formatPhoneNumberToE164('(523)00000000', 'CN'); expect(data === '+8652300000000').assertTrue(); console.log('Telephony_CallManager_formatPhoneNumberToE164_Promise_0200 finish data = ' + data); + done(); } catch (err) { console.log('Telephony_CallManager_formatPhoneNumberToE164_Promise_0200 fail'); expect().assertFail(); done(); return; } - done(); }) /* @@ -1133,13 +1137,13 @@ describe('CallManagerTest', function () { var data = await call.formatPhoneNumberToE164('523-0000-0000', 'CN'); expect(data === '+8652300000000').assertTrue(); console.log('Telephony_CallManager_formatPhoneNumberToE164_Promise_0300 finish data = ' + data); + done(); } catch (err) { console.log('Telephony_CallManager_formatPhoneNumberToE164_Promise_0300 fail'); expect().assertFail(); done(); return; } - done(); }) /* @@ -1153,31 +1157,31 @@ describe('CallManagerTest', function () { await call.formatPhoneNumberToE164('999999', 'CN'); console.log('Telephony_CallManager_formatPhoneNumberToE164_Promise_0400 fail'); expect().assertFail(); + done(); } catch (err) { console.log('Telephony_CallManager_formatPhoneNumberToE164_Promise_0400 finish err = ' + err.message); done(); return; } - done(); }) /* * @tc.number Telephony_CallManager_formatPhoneNumberToE164_Promise_0500 - * @tc.name PhoneNumber is 999999. Type non-existent options: abCDFG. Call formatPhoneNumberToE164() to + * @tc.name PhoneNumber is 52300000000. Type non-existent options: abCDFG. Call formatPhoneNumberToE164() to * format the number and capture err * @tc.desc Function test */ it('Telephony_CallManager_formatPhoneNumberToE164_Promise_0500', 0, async function (done) { try { - await call.formatPhoneNumberToE164('999999', 'abcdefg'); + await call.formatPhoneNumberToE164('52300000000', 'abcdefg'); console.log('Telephony_CallManager_formatPhoneNumberToE164_Promise_0500 fail'); expect().assertFail(); + done(); } catch (err) { console.log('Telephony_CallManager_formatPhoneNumberToE164_Promise_0500 finish err = ' + err.message); done(); return; } - done(); }) /* @@ -1191,12 +1195,12 @@ describe('CallManagerTest', function () { await call.formatPhoneNumberToE164('52300000000', ''); expect().assertFail(); console.log('Telephony_CallManager_formatPhoneNumberToE164_Promise_0600 fail'); + done(); } catch (err) { console.log('Telephony_CallManager_formatPhoneNumberToE164_Promise_0600 finish err = ' + err.message); done(); return; } - done(); }) /* @@ -1221,12 +1225,12 @@ describe('CallManagerTest', function () { /* * @tc.number Telephony_CallManager_isEmergencyPhoneNumber_Async_0200 - * @tc.name PhoneNumber: 13766669999, options 1. Call isEmergencyPhoneNumber() to check whether it is an + * @tc.name PhoneNumber: INVALID_NUMBER, options 1. Call isEmergencyPhoneNumber() to check whether it is an * emergency number. The return value is false * @tc.desc Function test */ it('Telephony_CallManager_isEmergencyPhoneNumber_Async_0200', 0, async function (done) { - call.isEmergencyPhoneNumber('13766669999', { slotId: SLOT_0 }, (err, data) => { + call.isEmergencyPhoneNumber(INVALID_NUMBER, { slotId: SLOT_0 }, (err, data) => { if (err) { console.log('Telephony_CallManager_isEmergencyPhoneNumber_Async_0200 fail'); expect().assertFail(); @@ -1429,33 +1433,33 @@ describe('CallManagerTest', function () { var data = await call.isEmergencyPhoneNumber('0+0+0', { slotId: SLOT_0 }); expect(data === false).assertTrue(); console.log('Telephony_CallManager_isEmergencyPhoneNumber_Promise_0100 finish data = ' + data); + done(); } catch (err) { console.log('Telephony_CallManager_isEmergencyPhoneNumber_Promise_0100 fail'); expect().assertFail(); done(); return; } - done(); }) /* * @tc.number Telephony_CallManager_isEmergencyPhoneNumber_Promise_0200 - * @tc.name PhoneNumber: 13766669999, options 1. Call isEmergencyPhoneNumber() to check whether it is an + * @tc.name PhoneNumber: INVALID_NUMBER, options 1. Call isEmergencyPhoneNumber() to check whether it is an * emergency number. The return value is false * @tc.desc Function test */ it('Telephony_CallManager_isEmergencyPhoneNumber_Promise_0200', 0, async function (done) { try { - var data = await call.isEmergencyPhoneNumber('13766669999', { slotId: SLOT_0 }); + var data = await call.isEmergencyPhoneNumber('INVALID_NUMBER', { slotId: SLOT_0 }); expect(data === false).assertTrue(); console.log('Telephony_CallManager_isEmergencyPhoneNumber_Promise_0200 finish data = ' + data); + done(); } catch (err) { console.log('Telephony_CallManager_isEmergencyPhoneNumber_Promise_0200 fail'); expect().assertFail(); done(); return; } - done(); }) /* @@ -1469,13 +1473,13 @@ describe('CallManagerTest', function () { var data = await call.isEmergencyPhoneNumber('000', { slotId: SLOT_0 }); expect(data).assertTrue(); console.log('Telephony_CallManager_isEmergencyPhoneNumber_Promise_0300 finish data = ' + data); + done(); } catch (err) { console.log('Telephony_CallManager_isEmergencyPhoneNumber_Promise_0300 fail'); expect().assertFail(); done(); return; } - done(); }) /* @@ -1489,13 +1493,13 @@ describe('CallManagerTest', function () { var data = await call.isEmergencyPhoneNumber('112', { slotId: SLOT_0 }); expect(data).assertTrue(); console.log('Telephony_CallManager_isEmergencyPhoneNumber_Promise_0400 finish data = ' + data); + done(); } catch (err) { console.log('Telephony_CallManager_isEmergencyPhoneNumber_Promise_0400 fail'); expect().assertFail(); done(); return; } - done(); }) /* @@ -1509,13 +1513,13 @@ describe('CallManagerTest', function () { var data = await call.isEmergencyPhoneNumber('911', { slotId: SLOT_0 }); expect(data).assertTrue(); console.log('Telephony_CallManager_isEmergencyPhoneNumber_Promise_0500 finish data = ' + data); + done(); } catch (err) { console.log('Telephony_CallManager_isEmergencyPhoneNumber_Promise_0500 fail'); expect().assertFail(); done(); return; } - done(); }) /* @@ -1529,13 +1533,13 @@ describe('CallManagerTest', function () { var data = await call.isEmergencyPhoneNumber('08', { slotId: SLOT_0 }); expect(data).assertTrue(); console.log('Telephony_CallManager_isEmergencyPhoneNumber_Promise_0600 finish data = ' + data); + done(); } catch (err) { console.log('Telephony_CallManager_isEmergencyPhoneNumber_Promise_0600 fail'); expect().assertFail(); done(); return; } - done(); }) /* @@ -1549,13 +1553,13 @@ describe('CallManagerTest', function () { var data = await call.isEmergencyPhoneNumber('118', { slotId: SLOT_0 }); expect(data).assertTrue(); console.log('Telephony_CallManager_isEmergencyPhoneNumber_Promise_0700 finish data = ' + data); + done(); } catch (err) { console.log('Telephony_CallManager_isEmergencyPhoneNumber_Promise_0700 fail'); expect().assertFail(); done(); return; } - done(); }) /* @@ -1564,19 +1568,19 @@ describe('CallManagerTest', function () { * number. The return value is true * @tc.desc Function test */ - it('Telephony_CallManager_isEmergencyPhoneNumber_Promise_0800', 0, async function (done) { - try { - var data = await call.isEmergencyPhoneNumber('999', { slotId: SLOT_0 }); - expect(data).assertTrue(); - console.log('Telephony_CallManager_isEmergencyPhoneNumber_Promise_0800 finish data = ' + data); - } catch (err) { - console.log('Telephony_CallManager_isEmergencyPhoneNumber_Promise_0800 fail'); - expect().assertFail(); - done(); - return; - } - done(); - }) + it('Telephony_CallManager_isEmergencyPhoneNumber_Promise_0800', 0, async function (done) { + try { + var data = await call.isEmergencyPhoneNumber('999', { slotId: SLOT_0 }); + expect(data).assertTrue(); + console.log('Telephony_CallManager_isEmergencyPhoneNumber_Promise_0800 finish data = ' + data); + done(); + } catch (err) { + console.log('Telephony_CallManager_isEmergencyPhoneNumber_Promise_0800 fail'); + expect().assertFail(); + done(); + return; + } + }) /* * @tc.number Telephony_CallManager_isEmergencyPhoneNumber_Promise_1100 @@ -1589,13 +1593,13 @@ describe('CallManagerTest', function () { var data = await call.isEmergencyPhoneNumber('119'); expect(data).assertTrue(); console.log('Telephony_CallManager_isEmergencyPhoneNumber_Promise_1100 finish data = ' + data); + done(); } catch (err) { console.log('Telephony_CallManager_isEmergencyPhoneNumber_Promise_1100 fail'); expect().assertFail(); done(); return; } - done(); }) /* @@ -1609,33 +1613,34 @@ describe('CallManagerTest', function () { var data = await call.isEmergencyPhoneNumber('110'); expect(data).assertTrue(); console.log('Telephony_CallManager_isEmergencyPhoneNumber_Promise_1200 finish data = ' + data); + done(); } catch (err) { console.log('Telephony_CallManager_isEmergencyPhoneNumber_Promise_1200 fail'); expect().assertFail(); done(); return; } - done(); }) /* - * @tc.number Telephony_CallManager_isEmergencyPhoneNumber_Promise_1300 - * @tc.name PhoneNumber: 120 with options -1. Call isEmergencyPhoneNumber() to check whether it is an emergency - * number. The return value is err - * @tc.desc Function test - */ - it('Telephony_CallManager_isEmergencyPhoneNumber_Promise_1300', 0, async function (done) { - try { - await call.isEmergencyPhoneNumber('120', { slotId: ERR_SLOT_ID }); - expect.assertFail(); - console.log('Telephony_CallManager_isEmergencyPhoneNumber_Promise_1300 fail'); - } catch (err) { - console.log('Telephony_CallManager_isEmergencyPhoneNumber_Promise_1300 finish err =' + err); - done(); - return; - } - done(); - }) + * @tc.number Telephony_CallManager_getCallWaitingStatus_Async_0100 + * @tc.name Call waiting is enabled, slotId is 1, getCallWaiting() is called to getCallWaiting, and status is 1 + * @tc.desc Function test + */ + it('Telephony_CallManager_getCallWaitingStatus_Async_0100', 0, async function (done) { + call.getCallWaitingStatus(SLOT_0, (err, data) => { + if (err) { + console.log(`Telephony_CallManager_getCallWaitingStatus_Async_0100 fail err = ${err}`); + expect().assertFail(); + done(); + return; + } + console.log(`Telephony_CallManager_getCallWaitingStatus_Async_0100 data = ${data}`); + expect(data === call.CALL_WAITING_ENABLE).assertTrue(); + console.log('Telephony_CallManager_getCallWaitingStatus_Async_0100 finish'); + done(); + }); + }); /* * @tc.number Telephony_CallManager_getCallWaitingStatus_Async_0200 @@ -1646,15 +1651,99 @@ describe('CallManagerTest', function () { it('Telephony_CallManager_getCallWaitingStatus_Async_0200', 0, async function (done) { call.getCallWaitingStatus(ERR_SLOT_ID, (err) => { if (err) { - console.log('Telephony_CallManager_getCallWaitingStatus_Async_0200 finish : ' + err.message); + console.log(`Telephony_CallManager_getCallWaitingStatus_Async_0200 finish : ${err.message}`); done(); return; } expect().assertFail(); console.log('Telephony_CallManager_getCallWaitingStatus_Async_0200 fail'); done(); - }) - }) + }); + }); + + /* + * @tc.number Telephony_CallManager_getCallWaitingStatus_Async_0300 + * @tc.name Run function setCallWaiting by args slotId SLOT_0,activate ACTIVATE_TRUE to set by callback, + * run function getCallWaiting by args slotId is 1 by callback, + * the function return status call.CALL_WAITING_ENABLE + * the funciton return void + * @tc.desc Function test + */ + it('Telephony_CallManager_getCallWaitingStatus_Async_0300', 0, async function (done) { + call.setCallWaiting(SLOT_0, ACTIVATE_TRUE, (err, data) => { + if (err) { + console.log(`Telephony_CallManager_getCallWaitingStatus_Async_0300 fail err = ${err}`); + expect().assertFail(); + done(); + return; + } + call.getCallWaitingStatus(SLOT_0, (err, data) => { + if (err) { + console.log(`Telephony_CallManager_getCallWaitingStatus_Async_0300 fail err = ${err}`); + expect().assertFail(); + done(); + return; + } + console.log(`Telephony_CallManager_getCallWaitingStatus_Async_0300 data = ${data}`); + expect(data === call.CALL_WAITING_ENABLE).assertTrue(); + console.log('Telephony_CallManager_getCallWaitingStatus_Async_0300 finish'); + done(); + }); + }); + }); + + /* + * @tc.number Telephony_CallManager_getCallWaitingStatus_Async_0400 + * @tc.name Run function setCallWaiting by args slotId SLOT_0,activate ACTIVATE_FALSE to set by callback, + * run function getCallWaiting by args slotId is by callback, + * the function return status call.CALL_WAITING_DISABLE + * the funciton return void,then Run function setCallWaiting by args slotId SLOT_0, + * activate ACTIVATE_TRUE to reset + * @tc.desc Function test + */ + it('Telephony_CallManager_getCallWaitingStatus_Async_0400', 0, async function (done) { + call.setCallWaiting(SLOT_0, ACTIVATE_FALSE, (err, data) => { + if (err) { + console.log(`Telephony_CallManager_getCallWaitingStatus_Async_0400 fail err = ${err}`); + expect().assertFail(); + done(); + return; + } + call.getCallWaitingStatus(SLOT_0, (err, data) => { + if (err) { + console.log(`Telephony_CallManager_getCallWaitingStatus_Async_0400 fail err = ${err}`); + expect().assertFail(); + } else { + console.log(`Telephony_CallManager_getCallWaitingStatus_Async_0400 data = ${data}`); + expect(data === call.CALL_WAITING_DISABLE).assertTrue(); + console.log('Telephony_CallManager_getCallWaitingStatus_Async_0400 finish'); + } + call.setCallWaiting(SLOT_0, ACTIVATE_TRUE, (err, data) => { + done(); + }); + }); + }); + }); + + /* + * @tc.number Telephony_CallManager_getCallWaitingStatus_Promise_0100 + * @tc.name When the call wait sate is on test call getCallWaiting() in callback is on + * @tc.desc Function test + */ + it('Telephony_CallManager_getCallWaitingStatus_Promise_0100', 0, async function (done) { + try { + let data = await call.getCallWaitingStatus(SLOT_0); + expect(data === call.CALL_WAITING_ENABLE).assertTrue(); + console.log(`Telephony_CallManager_getCallWaitingStatus_Promise_0100 data = ${data}`); + console.log('Telephony_CallManager_getCallWaitingStatus_Promise_0100 finish'); + done(); + } catch (err) { + expect().assertFail(); + console.log(`Telephony_CallManager_getCallWaitingStatus_Promise_0100 fail err =${err}`); + done(); + + } + }); /* * @tc.number Telephony_CallManager_getCallWaitingStatus_Promise_0200 @@ -1669,47 +1758,57 @@ describe('CallManagerTest', function () { done(); console.log('Telephony_CallManager_getCallWaitingStatus_Promise_0200 fail'); } catch (err) { - console.log('Telephony_CallManager_getCallWaitingStatus_Promise_0200 finish err =' + err.message); + console.log(`Telephony_CallManager_getCallWaitingStatus_Promise_0200 finish err =${err.message}`); done(); } - }) + }); /* - * @tc.number Telephony_CallManager_getCallWaitingStatus_Async_0100 - * @tc.name Call waiting is enabled, slotId is 1, getCallWaiting() is called to getCallWaiting, and status is 1 + * @tc.number Telephony_CallManager_getCallWaitingStatus_Promise_0300 + * @tc.name Run function setCallWaiting by args slotId SLOT_0,activate ACTIVATE_TRUE to set by promise, + * run function getCallWaiting by args slotId is SLOT_0 by promise, + * the function return status call.CALL_WAITING_ENABLE + * the funciton return void * @tc.desc Function test */ - it('Telephony_CallManager_getCallWaitingStatus_Async_0100', 0, async function (done) { - call.getCallWaitingStatus(SLOT_0, (err, data) => { - if (err) { - console.log('Telephony_CallManager_getCallWaitingStatus_Async_0100 fail err = ' + err); - expect().assertFail(); - done(); - return; - } - console.log('Telephony_CallManager_getCallWaitingStatus_Async_0100 data = ' + data); - expect(data === STATUS_ON).assertTrue(); - console.log('Telephony_CallManager_getCallWaitingStatus_Async_0100 finish'); - done(); - }) - }) + it('Telephony_CallManager_getCallWaitingStatus_Promise_0300', 0, async function (done) { + try { + await call.setCallWaiting(SLOT_0, ACTIVATE_TRUE); + let data = await call.getCallWaitingStatus(SLOT_0); + console.log(`Telephony_CallManager_getCallWaitingStatus_Promise_0300 data = ${data}`); + expect(data === call.CALL_WAITING_ENABLE).assertTrue(); + console.log('Telephony_CallManager_getCallWaitingStatus_Promise_0300 finish'); + } catch (error) { + console.log(`Telephony_CallManager_getCallWaitingStatus_Promise_0300 fail error = ${error}`); + expect().assertFail(); + } + done(); + }); /* - * @tc.number Telephony_CallManager_getCallWaitingStatus_Promise_0100 - * @tc.name When the call wait sate is on test call getCallWaiting() in callback is on + * @tc.number Telephony_CallManager_getCallWaitingStatus_Promise_0400 + * @tc.name Run function setCallWaiting by args slotId SLOT_0,activate ACTIVATE_FALSE to set by promise, + * run function getCallWaiting by args slotId SLOT_0 by promise, + * the function return status call.CALL_WAITING_DISABLE, + * then Run function setCallWaiting by args slotId SLOT_0,activate ACTIVATE_TRUE to reset * @tc.desc Function test */ - it('Telephony_CallManager_getCallWaitingStatus_Promise_0100', 0, async function (done) { + it('Telephony_CallManager_getCallWaitingStatus_Promise_0400', 0, async function (done) { try { + await call.setCallWaiting(SLOT_0, ACTIVATE_FALSE); let data = await call.getCallWaitingStatus(SLOT_0); - expect(data === STATUS_ON).assertTrue(); - console.log('Telephony_CallManager_getCallWaitingStatus_Promise_0100 data = ' + data); - console.log('Telephony_CallManager_getCallWaitingStatus_Promise_0100 finish'); - done(); - } catch (err) { + console.log(`Telephony_CallManager_getCallWaitingStatus_Promise_0400 data = ${data}`); + expect(data === call.CALL_WAITING_DISABLE).assertTrue(); + console.log('Telephony_CallManager_getCallWaitingStatus_Promise_0400 finish'); + } catch (error) { + console.log(`Telephony_CallManager_getCallWaitingStatus_Promise_0400 fail error = ${error}`); expect().assertFail(); - console.log('Telephony_CallManager_getCallWaitingStatus_Promise_0100 fail err =' + err); - done(); } - }) + try { + await call.setCallWaiting(SLOT_0, ACTIVATE_TRUE); + } catch (error) { + + } + done(); + }); }) diff --git a/telephony/telephonyjstest/config.sh b/telephony/telephonyjstest/config.sh index 59be0dbab26298bdaf97f8cfc96e8a602531db34..351ded15f889023faba3d4fe1c5a9b7dda3ddebe 100644 --- a/telephony/telephonyjstest/config.sh +++ b/telephony/telephonyjstest/config.sh @@ -16,7 +16,21 @@ # 配置发送短信的电话号码 config_const_var[0]="const SMS_SEND_DST_NUMBER = '138xxxxxxxx';" +#配置通话管理自动接听号码 +config_const_var[1]="const CALLMANAGER_TEST_PHONY_NUMBER = '10086';" +# 短信测试中使用到的短信中心服务地址 +config_const_var[2]="const OTHER_SMSC_NUMBER = '+86138xxxxxxxx';" +config_const_var[3]="const USABLE_SMSC_NUMBER = '+86138xxxxxxxx';" + +#通话管理用例使用号码 +config_const_var[4]="const INVALID_NUMBER = '138xxxxxxxx';" +config_const_var[5]="const THE_THREE_NUMBER = '112';" +config_const_var[6]="const EIGHTEEN_DIGITS = '123456789123456789';" +config_const_var[7]="const WITH_LETTER_NUMBER = 'abcde123456';" +config_const_var[8]="const EIGHT_NUMBER = '00000000';" +config_const_var[9]="const EIGHT_NUMBER_WITH_AN_AREA_CODE = '0898 0000 0000';" +config_const_var[10]="const MORE_THAN_30_NUMBERS = '12345678901234567890012345678901';" for((i = 0; i < ${#config_const_var}; i++)) do @@ -27,7 +41,7 @@ do key=`echo ${config_const_var[i]}| awk -F= '{print $1}'` for line in `grep -nr "${key}"| sed 's/ //g'|grep -v "config.sh"` do - + file=`echo ${line}|awk -F: '{print $1}'` line_no=`echo ${line}|awk -F: '{print $2}'` echo $file $line_no diff --git a/telephony/telephonyjstest/network_search/BUILD.gn b/telephony/telephonyjstest/network_search/BUILD.gn index fd92605ad422e191bc1301e1ebb789ddc16a4a66..14d5bee8e4329339a9b8a197430e85885e1212a4 100644 --- a/telephony/telephonyjstest/network_search/BUILD.gn +++ b/telephony/telephonyjstest/network_search/BUILD.gn @@ -23,4 +23,4 @@ group("network_search") { "network_search_selection_mode:NetworkSearchSelectionMoce", ] } -} +} \ No newline at end of file diff --git a/telephony/telephonyjstest/network_search/network_search_information/BUILD.gn b/telephony/telephonyjstest/network_search/network_search_information/BUILD.gn index 13676f0cef445ef030e41b4882e59ef3b858d07b..22297bf6073bd49c57200c8f20ca83b856c64c72 100644 --- a/telephony/telephonyjstest/network_search/network_search_information/BUILD.gn +++ b/telephony/telephonyjstest/network_search/network_search_information/BUILD.gn @@ -27,4 +27,4 @@ ohos_js_assets("hjs_demo_js_assets") { ohos_resources("hjs_demo_resources") { sources = [ "./entry/src/main/js/resources" ] hap_profile = "./entry/src/main/config.json" -} +} \ No newline at end of file diff --git a/telephony/telephonyjstest/network_search/network_search_information/entry/src/main/js/test/NetworkSearchInformation.test.js b/telephony/telephonyjstest/network_search/network_search_information/entry/src/main/js/test/NetworkSearchInformation.test.js index 47fbf1df623921337aeda2c7514f289bfd498e17..c1a537d284266295bc0556acb4dec6e5f93771cb 100644 --- a/telephony/telephonyjstest/network_search/network_search_information/entry/src/main/js/test/NetworkSearchInformation.test.js +++ b/telephony/telephonyjstest/network_search/network_search_information/entry/src/main/js/test/NetworkSearchInformation.test.js @@ -65,7 +65,6 @@ describe('NetworkSearchTest', function () { const ISO_COUNTRY_CODE = 'cn'; const PLMN_SIZE = 5; - /** * @tc.number Telephony_NetworkSearch_getNetworkState_Async_0100 * @tc.name Test the getNetworkState() query function and return the default card 0 network registration status @@ -97,8 +96,8 @@ describe('NetworkSearchTest', function () { data.plmnNumeric != null ).assertTrue(); expect(data.plmnNumeric.length == 5 && data.plmnNumeric.substr(0, 3) === '460').assertTrue(); - expect(garrRegState).assertContain(data.regStatus); - expect(data.nsaState === 1).assertTrue(); + expect(data.regStatus === radio.REG_STATE_IN_SERVICE).assertTrue(); + expect(data.nsaState === radio.NSA_STATE_NOT_SUPPORT).assertTrue(); expect(data.isRoaming === false).assertTrue(); expect(data.isCaActive === false).assertTrue(); expect(data.isEmergency === false).assertTrue(); @@ -129,8 +128,8 @@ describe('NetworkSearchTest', function () { data.shortOperatorName != undefined && data.shortOperatorName != '' && data.shortOperatorName != null ).assertTrue(); expect(data.plmnNumeric.length === PLMN_SIZE && data.plmnNumeric.substr(0, 3) === '460').assertTrue(); - expect(garrRegState).assertContain(data.regStatus); - expect(data.nsaState === 1).assertTrue(); + expect(data.regStatus === radio.REG_STATE_IN_SERVICE).assertTrue(); + expect(data.nsaState === radio.NSA_STATE_NOT_SUPPORT).assertTrue(); expect(data.isRoaming === false).assertTrue(); expect(data.isCaActive === false).assertTrue(); expect(data.isEmergency === false).assertTrue(); @@ -174,8 +173,7 @@ describe('NetworkSearchTest', function () { done(); return; } - console.log(`Telephony_NetworkSearch_getRadioTech_Async_0100 finish psRadioTech: ${psRadioTech} - csRadioTech: ${csRadioTech}`); + console.log(`Telephony_NetworkSearch_getRadioTech_Async_0100 finish ps: ${psRadioTech} cs: ${csRadioTech}`); expect(garrRadioTech).assertContain(psRadioTech); expect(garrRadioTech).assertContain(csRadioTech); done(); @@ -249,7 +247,7 @@ describe('NetworkSearchTest', function () { return; } console.log(`Telephony_NetworkSearch_getSignalInformation_Async_0400 finish data: ${JSON.stringify(data)}`); - expect(data === undefined || data.length === 0).assertTrue(); + expect(data.length === 0).assertTrue(); done(); }); }); @@ -271,8 +269,8 @@ describe('NetworkSearchTest', function () { data.shortOperatorName != undefined && data.shortOperatorName != '' && data.shortOperatorName != null ).assertTrue(); expect(data.plmnNumeric.length === PLMN_SIZE && data.plmnNumeric.substr(0, 3) === '460').assertTrue(); - expect(garrRegState).assertContain(data.regStatus); - expect(data.nsaState === 1).assertTrue(); + expect(data.regStatus === radio.REG_STATE_IN_SERVICE).assertTrue(); + expect(data.nsaState === radio.NSA_STATE_NOT_SUPPORT).assertTrue(); expect(data.isRoaming === false).assertTrue(); expect(data.isCaActive === false).assertTrue(); expect(data.isEmergency === false).assertTrue(); @@ -304,8 +302,8 @@ describe('NetworkSearchTest', function () { data.shortOperatorName != undefined && data.shortOperatorName != '' && data.shortOperatorName != null ).assertTrue(); expect(data.plmnNumeric.length === PLMN_SIZE && data.plmnNumeric.substr(0, 3) === '460').assertTrue(); - expect(garrRegState).assertContain(data.regStatus); - expect(data.nsaState === 1).assertTrue(); + expect(data.regStatus === radio.REG_STATE_IN_SERVICE).assertTrue(); + expect(data.nsaState === radio.NSA_STATE_NOT_SUPPORT).assertTrue(); expect(data.isRoaming === false).assertTrue(); expect(data.isCaActive === false).assertTrue(); expect(data.isEmergency === false).assertTrue(); @@ -419,7 +417,7 @@ describe('NetworkSearchTest', function () { let data = await radio.getSignalInformation(slotId); console.log( `Telephony_NetworkSearch_getSignalInformation_Promise_0400 finish data: ${JSON.stringify(data)}`); - expect(data === undefined || data.length === 0).assertTrue(); + expect(data.length === 0).assertTrue(); } catch (err) { console.log(`Telephony_NetworkSearch_getSignalInformation_Promise_0400 fail err: ${err}`); expect().assertFail(); @@ -485,7 +483,7 @@ describe('NetworkSearchTest', function () { } console.log( `Telephony_NetworkSearch_getISOCountryCodeForNetwork_Async_0400 finish data: ${JSON.stringify(data)}`); - expect(data === undefined || data.length === 0).assertTrue(); + expect(data.length === 0).assertTrue(); done(); }); }); @@ -501,7 +499,7 @@ describe('NetworkSearchTest', function () { let data = await radio.getISOCountryCodeForNetwork(slotId); console.log( `Telephony_NetworkSearch_getISOCountryCodeForNetwork_Promise_0400 finish data:${JSON.stringify(data)}`); - expect(data === undefined || data.length === 0).assertTrue(); + expect(data.length === 0).assertTrue(); } catch (err) { console.log(`Telephony_NetworkSearch_getISOCountryCodeForNetwork_Promise_0400 fail err: ${err}`); expect().assertFail(); diff --git a/telephony/telephonyjstest/network_search/network_search_radio/BUILD.gn b/telephony/telephonyjstest/network_search/network_search_radio/BUILD.gn index b41b1e59d6d8a3e5c4ea0100942b34b9923f92ff..60eee5da764ee42887e573265717000edf974030 100644 --- a/telephony/telephonyjstest/network_search/network_search_radio/BUILD.gn +++ b/telephony/telephonyjstest/network_search/network_search_radio/BUILD.gn @@ -27,4 +27,4 @@ ohos_js_assets("hjs_demo_js_assets") { ohos_resources("hjs_demo_resources") { sources = [ "./entry/src/main/js/resources" ] hap_profile = "./entry/src/main/config.json" -} +} \ No newline at end of file diff --git a/telephony/telephonyjstest/network_search/network_search_radio/entry/src/main/js/test/NetworkSearchRadio.test.js b/telephony/telephonyjstest/network_search/network_search_radio/entry/src/main/js/test/NetworkSearchRadio.test.js index e8c344c21b3e8d0c3dcc6fb94b864413dacc2085..261a51bdc3fce0102d853a8bbfefe78ff5325e40 100644 --- a/telephony/telephonyjstest/network_search/network_search_radio/entry/src/main/js/test/NetworkSearchRadio.test.js +++ b/telephony/telephonyjstest/network_search/network_search_radio/entry/src/main/js/test/NetworkSearchRadio.test.js @@ -53,7 +53,7 @@ describe('NetworkSearchTest', function () { return; } console.log('Telephony_NetworkSearch_turnOnRadio_Async_0100 turnOn finish'); - radio.isRadioOn((err, data) => { + radio.isRadioOn(async (err, data) => { if (err) { console.log(`Telephony_NetworkSearch_turnOnRadio_Async_0100 isOn fail: ${err}`); expect().assertFail(); @@ -62,6 +62,15 @@ describe('NetworkSearchTest', function () { } console.log(`Telephony_NetworkSearch_turnOnRadio_Async_0100 finish data: ${data}`); expect(data).assertTrue(); + try { + await radio.turnOnRadio(); + console.log('Telephony_NetworkSearch_recoverRadioState success'); + } catch (err) { + console.log(`Telephony_NetworkSearch_recoverRadioState fail ${err}`); + expect().assertFail(); + done(); + return; + } done(); }); }); @@ -145,7 +154,7 @@ describe('NetworkSearchTest', function () { return; } console.log('Telephony_NetworkSearch_turnOffRadio_Async_0100 turnOff finish'); - radio.isRadioOn((err, data) => { + radio.isRadioOn(async (err, data) => { if (err) { console.log(`Telephony_NetworkSearch_turnOffRadio_Async_0100 isOn fail: ${err}`); expect().assertFail(); @@ -154,6 +163,15 @@ describe('NetworkSearchTest', function () { } console.log(`Telephony_NetworkSearch_turnOffRadio_Async_0100 finish data: ${data}`) expect(data).assertFalse(); + try { + await radio.turnOnRadio(); + console.log('Telephony_NetworkSearch_recoverRadioState success'); + } catch (err) { + console.log(`Telephony_NetworkSearch_recoverRadioState fail ${err}`); + expect().assertFail(); + done(); + return; + } done(); }); }); @@ -191,7 +209,7 @@ describe('NetworkSearchTest', function () { return; } console.log('Telephony_NetworkSearch_turnOffRadio_Async_0200 turnOff2 finish'); - radio.isRadioOn((err, data) => { + radio.isRadioOn(async (err, data) => { if (err) { console.log(`Telephony_NetworkSearch_turnOffRadio_Async_0200 isOn fail: ${err}`); expect().assertFail(); @@ -200,6 +218,15 @@ describe('NetworkSearchTest', function () { } console.log(`Telephony_NetworkSearch_turnOffRadio_Async_0200 finish data: ${data}`) expect(data).assertFalse(); + try { + await radio.turnOnRadio(); + console.log('Telephony_NetworkSearch_recoverRadioState success'); + } catch (err) { + console.log(`Telephony_NetworkSearch_recoverRadioState fail ${err}`); + expect().assertFail(); + done(); + return; + } done(); }); }); @@ -233,7 +260,7 @@ describe('NetworkSearchTest', function () { return; } console.log('Telephony_NetworkSearch_turnOffRadio_Async_0500 turnOff finish'); - radio.getNetworkState((err, data) => { + radio.getNetworkState(async (err, data) => { if (err) { console.log(`Telephony_NetworkSearch_turnOffRadio_Async_0500 get fail err: ${err}`); expect().assertFail(); @@ -241,21 +268,23 @@ describe('NetworkSearchTest', function () { return; } console.log(`Telephony_NetworkSearch_turnOffRadio_Async_0500 finish data: ${JSON.stringify(data)}`); - expect( - data.longOperatorName === undefined || data.longOperatorName === '' || - data.longOperatorName === null - ).assertTrue(); - expect( - data.shortOperatorName === undefined || data.shortOperatorName === '' || - data.shortOperatorName === null - ).assertTrue(); - expect(data.plmnNumeric === undefined || data.plmnNumeric === '' || - data.plmnNumeric === null).assertTrue(); + expect(data.longOperatorName === '').assertTrue(); + expect(data.shortOperatorName === '').assertTrue(); + expect(data.plmnNumeric === '').assertTrue(); expect(data.regStatus === radio.REG_STATE_POWER_OFF).assertTrue(); expect(data.nsaState === radio.NSA_STATE_NOT_SUPPORT).assertTrue(); expect(data.isRoaming === false).assertTrue(); expect(data.isCaActive === false).assertTrue(); expect(data.isEmergency === false).assertTrue(); + try { + await radio.turnOnRadio(); + console.log('Telephony_NetworkSearch_recoverRadioState success'); + } catch (err) { + console.log(`Telephony_NetworkSearch_recoverRadioState fail ${err}`); + expect().assertFail(); + done(); + return; + } done(); }); }); @@ -284,7 +313,7 @@ describe('NetworkSearchTest', function () { return; } console.log('Telephony_NetworkSearch_turnOffRadio_Async_0600 turnOff finish'); - radio.getSignalInformation(SLOT_0, (err, data) => { + radio.getSignalInformation(SLOT_0, async (err, data) => { if (err) { console.log(`Telephony_NetworkSearch_turnOffRadio_Async_0600 get fail err: ${err}`); expect().assertFail(); @@ -294,6 +323,15 @@ describe('NetworkSearchTest', function () { console.log(`Telephony_NetworkSearch_turnOffRadio_Async_0600 finish data: ${JSON.stringify(data)}`); expect(data != null && data != undefined).assertTrue(); expect(data.length === 0).assertTrue(); + try { + await radio.turnOnRadio(); + console.log('Telephony_NetworkSearch_recoverRadioState success'); + } catch (err) { + console.log(`Telephony_NetworkSearch_recoverRadioState fail ${err}`); + expect().assertFail(); + done(); + return; + } done(); }); }); @@ -323,7 +361,7 @@ describe('NetworkSearchTest', function () { return; } console.log('Telephony_NetworkSearch_turnOffRadio_Async_0700 turnOff finish'); - radio.getRadioTech(SLOT_0, (err, { psRadioTech, + radio.getRadioTech(SLOT_0, async (err, { psRadioTech, csRadioTech }) => { if (err) { console.log(`Telephony_NetworkSearch_turnOffRadio_Async_0700 get fail err: ${err}`); @@ -331,10 +369,19 @@ describe('NetworkSearchTest', function () { done(); return; } - console.log(`Telephony_NetworkSearch_turnOffRadio_Async_0700 finish psRadioTech: ${psRadioTech} - csRadioTech: ${csRadioTech}`); + console.log( + `Telephony_NetworkSearch_turnOffRadio_Async_0700 finish ps: ${psRadioTech} cs: ${csRadioTech}`); expect(psRadioTech === radio.RADIO_TECHNOLOGY_UNKNOWN).assertTrue(); expect(csRadioTech === radio.RADIO_TECHNOLOGY_UNKNOWN).assertTrue(); + try { + await radio.turnOnRadio(); + console.log('Telephony_NetworkSearch_recoverRadioState success'); + } catch (err) { + console.log(`Telephony_NetworkSearch_recoverRadioState fail ${err}`); + expect().assertFail(); + done(); + return; + } done(); }); }); @@ -342,7 +389,7 @@ describe('NetworkSearchTest', function () { /** * @tc.number Telephony_NetworkSearch_isRadioOn_Async_0100 - * @tc.name Turn off Radio, input slotId parameter as 1, test isRadioOn() returns 'false' + * @tc.name Turn off Radio, test isRadioOn() returns 'false' * @tc.desc Function test */ it('Telephony_NetworkSearch_isRadioOn_Async_0100', 0, async function (done) { @@ -363,7 +410,7 @@ describe('NetworkSearchTest', function () { return; } console.log('Telephony_NetworkSearch_isRadioOn_Async_0100 turnOff finish'); - radio.isRadioOn((err, data) => { + radio.isRadioOn(async (err, data) => { if (err) { console.log(`Telephony_NetworkSearch_isRadioOn_Async_0100 isOn fail err: ${err}`); expect().assertFail(); @@ -372,6 +419,15 @@ describe('NetworkSearchTest', function () { } console.log(`Telephony_NetworkSearch_isRadioOn_Async_0100 finish data: ${data}`); expect(data === false).assertTrue(); + try { + await radio.turnOnRadio(); + console.log('Telephony_NetworkSearch_recoverRadioState success'); + } catch (err) { + console.log(`Telephony_NetworkSearch_recoverRadioState fail ${err}`); + expect().assertFail(); + done(); + return; + } done(); }); @@ -380,7 +436,7 @@ describe('NetworkSearchTest', function () { /** * @tc.number Telephony_NetworkSearch_isRadioOn_Async_0200 - * @tc.name Turn on Radio, input slotId parameter as 1, test isRadioOn() returns 'true' + * @tc.name Turn on Radio, test isRadioOn() returns 'true' * @tc.desc Function test */ it('Telephony_NetworkSearch_isRadioOn_Async_0200', 0, async function (done) { @@ -458,7 +514,6 @@ describe('NetworkSearchTest', function () { done(); return; } - done(); }); @@ -532,6 +587,15 @@ describe('NetworkSearchTest', function () { done(); return; } + try { + await radio.turnOnRadio(); + console.log('Telephony_NetworkSearch_recoverRadioState success'); + } catch (err) { + console.log(`Telephony_NetworkSearch_recoverRadioState fail ${err}`); + expect().assertFail(); + done(); + return; + } done(); }); @@ -563,11 +627,11 @@ describe('NetworkSearchTest', function () { await radio.turnOffRadio(); console.log('Telephony_NetworkSearch_turnOffRadio_Promise_0200 turnOff2 finish'); done(); - return; } catch (err) { console.log(`Telephony_NetworkSearch_turnOffRadio_Promise_0200 turnOff2 fail: ${err}`); expect().assertFail(); done(); + return; } try { let data = await radio.isRadioOn(); @@ -579,6 +643,15 @@ describe('NetworkSearchTest', function () { done(); return; } + try { + await radio.turnOnRadio(); + console.log('Telephony_NetworkSearch_recoverRadioState success'); + } catch (err) { + console.log(`Telephony_NetworkSearch_recoverRadioState fail ${err}`); + expect().assertFail(); + done(); + return; + } done(); }); @@ -613,13 +686,9 @@ describe('NetworkSearchTest', function () { let data = await radio.getNetworkState(); console.log(`Telephony_NetworkSearch_turnOffRadio_Promise_0500 finish data: ${JSON.stringify(data)}`); expect(data != null && data != undefined).assertTrue(); - expect( - data.longOperatorName === undefined || data.longOperatorName === '' || data.longOperatorName === null - ).assertTrue(); - expect( - data.shortOperatorName === undefined || data.shortOperatorName === '' || data.shortOperatorName === null - ).assertTrue(); - expect(data.plmnNumeric === undefined || data.plmnNumeric === '' || data.plmnNumeric === null).assertTrue(); + expect(data.longOperatorName === '').assertTrue(); + expect(data.shortOperatorName === '').assertTrue(); + expect(data.plmnNumeric === '').assertTrue(); expect(data.regStatus === radio.REG_STATE_POWER_OFF).assertTrue(); expect(data.nsaState === radio.NSA_STATE_NOT_SUPPORT).assertTrue(); expect(data.isRoaming === false).assertTrue(); @@ -632,6 +701,15 @@ describe('NetworkSearchTest', function () { done(); return; } + try { + await radio.turnOnRadio(); + console.log('Telephony_NetworkSearch_recoverRadioState success'); + } catch (err) { + console.log(`Telephony_NetworkSearch_recoverRadioState fail ${err}`); + expect().assertFail(); + done(); + return; + } done(); }); @@ -661,7 +739,7 @@ describe('NetworkSearchTest', function () { } try { let data = await radio.getSignalInformation(SLOT_0); - console.log(`Telephony_NetworkSearch_turnOffRadio_Promise_0600 finish data: ${data}`); + console.log(`Telephony_NetworkSearch_turnOffRadio_Promise_0600 finish data: ${JSON.stringify(data)}`); expect(data != null && data != undefined).assertTrue(); expect(data.length === 0).assertTrue(); } catch (err) { @@ -670,6 +748,15 @@ describe('NetworkSearchTest', function () { done(); return; } + try { + await radio.turnOnRadio(); + console.log('Telephony_NetworkSearch_recoverRadioState success'); + } catch (err) { + console.log(`Telephony_NetworkSearch_recoverRadioState fail ${err}`); + expect().assertFail(); + done(); + return; + } done(); }); @@ -710,12 +797,21 @@ describe('NetworkSearchTest', function () { done(); return; } + try { + await radio.turnOnRadio(); + console.log('Telephony_NetworkSearch_recoverRadioState success'); + } catch (err) { + console.log(`Telephony_NetworkSearch_recoverRadioState fail ${err}`); + expect().assertFail(); + done(); + return; + } done(); }); /** * @tc.number Telephony_NetworkSearch_isRadioOn_Promise_0100 - * @tc.name Turn off Radio, input slotId parameter as 1, test isRadioOn() returns 'false' + * @tc.name Turn off Radio, test isRadioOn() returns 'false' * @tc.desc Function test */ it('Telephony_NetworkSearch_isRadioOn_Promise_0100', 0, async function (done) { @@ -747,12 +843,21 @@ describe('NetworkSearchTest', function () { done(); return; } + try { + await radio.turnOnRadio(); + console.log('Telephony_NetworkSearch_recoverRadioState success'); + } catch (err) { + console.log(`Telephony_NetworkSearch_recoverRadioState fail ${err}`); + expect().assertFail(); + done(); + return; + } done(); }); /** * @tc.number Telephony_NetworkSearch_isRadioOn_Promise_0200 - * @tc.name Turn on Radio, input slotId parameter as 1, test isRadioOn() returns 'true' + * @tc.name Turn on Radio, test isRadioOn() returns 'true' * @tc.desc Function test */ it('Telephony_NetworkSearch_isRadioOn_Promise_0200', 0, async function (done) { @@ -780,7 +885,7 @@ describe('NetworkSearchTest', function () { /** * @tc.number Telephony_NetworkSearch_getISOCountryCodeForNetwork_Async_0500 - * @tc.name Radio is off, test the getISOCountryCodeForNetwork() return the data is 'cn' + * @tc.name Radio is off, test the getISOCountryCodeForNetwork() return the data is not 'cn' * @tc.desc Function test */ it('Telephony_NetworkSearch_getISOCountryCodeForNetwork_Async_0500', 0, async function (done) { @@ -801,16 +906,25 @@ describe('NetworkSearchTest', function () { return; } console.log('Telephony_NetworkSearch_getISOCountryCodeForNetwork_Async_0500 turnOff finish'); - radio.getISOCountryCodeForNetwork(SLOT_0, (err, data) => { + radio.getISOCountryCodeForNetwork(SLOT_0, async (err, data) => { if (err) { console.log(`Telephony_NetworkSearch_getISOCountryCodeForNetwork_Async_0500 get fail: ${err}`); expect().assertFail(); done(); return; } - console.log(`Telephony_NetworkSearch_getISOCountryCodeForNetwork_Async_0500 finish - data: ${JSON.stringify(data)}`); - expect(data === "" || data === undefined || data === null).assertTrue(); + console.log( + `Telephony_NetworkSearch_getISOCountryCodeForNetwork_Async_0500 finish data: ${JSON.stringify(data)}`); + expect(data === '').assertTrue(); + try { + await radio.turnOnRadio(); + console.log('Telephony_NetworkSearch_recoverRadioState success'); + } catch (err) { + console.log(`Telephony_NetworkSearch_recoverRadioState fail ${err}`); + expect().assertFail(); + done(); + return; + } done(); }); }); @@ -818,7 +932,7 @@ describe('NetworkSearchTest', function () { /** * @tc.number Telephony_NetworkSearch_getISOCountryCodeForNetwork_Promise_0500 - * @tc.name Radio is off, test the getISOCountryCodeForNetwork() return the data is 'cn' + * @tc.name Radio is off, test the getISOCountryCodeForNetwork() return the data is not 'cn' * @tc.desc Function test */ it('Telephony_NetworkSearch_getISOCountryCodeForNetwork_Promise_0500', 0, async function (done) { @@ -843,7 +957,7 @@ describe('NetworkSearchTest', function () { try { let data = await radio.getISOCountryCodeForNetwork(SLOT_0); console.log(`Telephony_NetworkSearch_getISOCountryCodeForNetwork_Promise_0500 finish: ${data}`); - expect(data === "" || data === undefined || data === null).assertTrue(); + expect(data === '').assertTrue(); } catch (err) { console.log(`Telephony_NetworkSearch_getISOCountryCodeForNetwork_Promise_0500 fail: ${err}`); expect().assertFail(); @@ -852,9 +966,9 @@ describe('NetworkSearchTest', function () { } try { await radio.turnOnRadio(); - console.log('Telephony_NetworkSearch_getISOCountryCodeForNetwork_Promise_0500 turnOn success'); + console.log('Telephony_NetworkSearch_recoverRadioState success'); } catch (err) { - console.log(`Telephony_NetworkSearch_getISOCountryCodeForNetwork_Promise_0500 turnOff fail ${err}`); + console.log(`Telephony_NetworkSearch_recoverRadioState fail ${err}`); expect().assertFail(); done(); return; diff --git a/telephony/telephonyjstest/network_search/network_search_selection_mode/BUILD.gn b/telephony/telephonyjstest/network_search/network_search_selection_mode/BUILD.gn index a5af3ac607eb491d5306e0bb36ba660ef208e9b3..04ad1fe67d59c4679c69b3fea3b8d16f9ba8269e 100644 --- a/telephony/telephonyjstest/network_search/network_search_selection_mode/BUILD.gn +++ b/telephony/telephonyjstest/network_search/network_search_selection_mode/BUILD.gn @@ -27,4 +27,4 @@ ohos_js_assets("hjs_demo_js_assets") { ohos_resources("hjs_demo_resources") { sources = [ "./entry/src/main/js/resources" ] hap_profile = "./entry/src/main/config.json" -} +} \ No newline at end of file diff --git a/telephony/telephonyjstest/network_search/network_search_selection_mode/entry/src/main/js/test/NetworkSelectionMode.test.js b/telephony/telephonyjstest/network_search/network_search_selection_mode/entry/src/main/js/test/NetworkSelectionMode.test.js index 7cb5e82ecfb1ab6f117e847f215a784648cdf5a0..271a27f020b02a74fe2eb92c727b369f1ebf2a91 100644 --- a/telephony/telephonyjstest/network_search/network_search_selection_mode/entry/src/main/js/test/NetworkSelectionMode.test.js +++ b/telephony/telephonyjstest/network_search/network_search_selection_mode/entry/src/main/js/test/NetworkSelectionMode.test.js @@ -18,14 +18,15 @@ import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from describe('NetworkSearchTest', function () { let gslot = 0; - let gradioTech = '2'; - let goperatorName = '46000'; + let gradioTech = radio.RADIO_TECHNOLOGY_GSM.toString(); + let goperatorName = ''; + let goperatorNumeric = ''; let gnetworkSMode = { slotId: gslot, selectMode: radio.NETWORK_SELECTION_AUTOMATIC, networkInformation: { - operatorName: '46000', - operatorNumeric: '46011', + operatorName: goperatorName, + operatorNumeric: goperatorNumeric, state: radio.NETWORK_AVAILABLE, radioTech: gradioTech, }, @@ -38,18 +39,16 @@ describe('NetworkSearchTest', function () { radio.NETWORK_CURRENT, radio.NETWORK_FORBIDDEN, ]; - //Network system + //NetworkRadioTech let garrNetworkRadioTech = [ - 'UNKNOWN','GSM','1XRTT','WCDMA', - 'HSPA','HSPAP', 'TD_SCDMA','EVDO', - 'EHRPD','LTE','LTE_CA','IWLAN','NR']; + 'UNKNOWN', 'GSM', '1XRTT', 'WCDMA', + 'HSPA', 'HSPAP', 'TD_SCDMA', 'EVDO', + 'EHRPD', 'LTE', 'LTE_CA', 'IWLAN', 'NR']; const SLOT_0 = 0; const OPERATOR_NUMERIC_SSSSS = 'SSSSS'; const ERR_VALUE_5 = 5; - - async function recoverNetworkSelectionMode() { try { await radio.setNetworkSelectionMode(gnetworkSMode); @@ -81,18 +80,19 @@ describe('NetworkSearchTest', function () { done(); return; } - try{ + try { let data = await radio.getNetworkState(SLOT_0); console.log(`Telephony_NetworkSearch_getNetworkState data: ${JSON.stringify(data)}`) - if(data.plmnNumeric != '' && data.plmnNumeric != undefined){ - gnetworkSMode.networkInformation.operatorNumeric = data.plmnNumeric; - }else{ + if (data.plmnNumeric != '' && data.plmnNumeric != undefined) { + goperatorNumeric = data.plmnNumeric; + goperatorName = data.longOperatorName; + } else { console.log(`Telephony_NetworkSearch_getNetworkState fail`) expect().assertFail(); done(); return; } - }catch(err){ + } catch (err) { console.log(`Telephony_NetworkSearch_getNetworkSelectionMode_Async_0100 init err: ${err}`); expect().assertFail(); done(); @@ -103,7 +103,7 @@ describe('NetworkSearchTest', function () { selectMode: radio.NETWORK_SELECTION_AUTOMATIC, networkInformation: { operatorName: goperatorName, - operatorNumeric: gnetworkSMode.networkInformation.operatorNumeric, + operatorNumeric: goperatorNumeric, state: radio.NETWORK_AVAILABLE, radioTech: gradioTech, }, @@ -140,18 +140,19 @@ describe('NetworkSearchTest', function () { * @tc.desc Function test */ it('Telephony_NetworkSearch_getNetworkSelectionMode_Async_0200', 0, async function (done) { - try{ + try { let data = await radio.getNetworkState(SLOT_0); - console.log(`Telephony_NetworkSearch_getNetworkState data: ${JSON.stringify(data)}`) - if(data.plmnNumeric != '' && data.plmnNumeric != undefined){ - gnetworkSMode.networkInformation.operatorNumeric = data.plmnNumeric; - }else{ - console.log(`Telephony_NetworkSearch_getNetworkState fail`) + console.log(`Telephony_NetworkSearch_getNetworkState data: ${JSON.stringify(data)}`); + if (data.plmnNumeric != '' && data.plmnNumeric != undefined) { + goperatorNumeric = data.plmnNumeric; + goperatorName = data.longOperatorName; + } else { + console.log(`Telephony_NetworkSearch_getNetworkState fail`); expect().assertFail(); done(); return; } - }catch(err){ + } catch (err) { expect().assertFail(); done(); return; @@ -161,7 +162,7 @@ describe('NetworkSearchTest', function () { selectMode: radio.NETWORK_SELECTION_MANUAL, networkInformation: { operatorName: goperatorName, - operatorNumeric: gnetworkSMode.networkInformation.operatorNumeric, + operatorNumeric: goperatorNumeric, state: radio.NETWORK_AVAILABLE, radioTech: gradioTech, }, @@ -218,18 +219,19 @@ describe('NetworkSearchTest', function () { * @tc.desc Function test */ it('Telephony_NetworkSearch_getNetworkSelectionMode_Promise_0100', 0, async function (done) { - try{ + try { let data = await radio.getNetworkState(SLOT_0); - console.log(`Telephony_NetworkSearch_getNetworkState data: ${JSON.stringify(data)}`) - if(data.plmnNumeric != '' && data.plmnNumeric != undefined){ - gnetworkSMode.networkInformation.operatorNumeric = data.plmnNumeric; - }else{ - console.log(`Telephony_NetworkSearch_getNetworkState fail`) + console.log(`Telephony_NetworkSearch_getNetworkState data: ${JSON.stringify(data)}`); + if (data.plmnNumeric != '' && data.plmnNumeric != undefined) { + goperatorNumeric = data.plmnNumeric; + goperatorName = data.longOperatorName; + } else { + console.log(`Telephony_NetworkSearch_getNetworkState fail`); expect().assertFail(); done(); return; } - }catch(err){ + } catch (err) { expect().assertFail(); done(); return; @@ -239,7 +241,7 @@ describe('NetworkSearchTest', function () { selectMode: radio.NETWORK_SELECTION_AUTOMATIC, networkInformation: { operatorName: goperatorName, - operatorNumeric: gnetworkSMode.networkInformation.operatorNumeric, + operatorNumeric: goperatorNumeric, state: radio.NETWORK_AVAILABLE, radioTech: gradioTech, }, @@ -276,18 +278,19 @@ describe('NetworkSearchTest', function () { * @tc.desc Function test */ it('Telephony_NetworkSearch_getNetworkSelectionMode_Promise_0200', 0, async function (done) { - try{ + try { let data = await radio.getNetworkState(SLOT_0); console.log(`Telephony_NetworkSearch_getNetworkState data: ${JSON.stringify(data)}`) - if(data.plmnNumeric != '' && data.plmnNumeric != undefined){ - gnetworkSMode.networkInformation.operatorNumeric = data.plmnNumeric; - }else{ - console.log(`Telephony_NetworkSearch_getNetworkState fail`) + if (data.plmnNumeric != '' && data.plmnNumeric != undefined) { + goperatorNumeric = data.plmnNumeric; + goperatorName = data.longOperatorName; + } else { + console.log(`Telephony_NetworkSearch_getNetworkState fail`); expect().assertFail(); done(); return; } - }catch(err){ + } catch (err) { expect().assertFail(); done(); return; @@ -297,7 +300,7 @@ describe('NetworkSearchTest', function () { selectMode: radio.NETWORK_SELECTION_MANUAL, networkInformation: { operatorName: goperatorName, - operatorNumeric: gnetworkSMode.networkInformation.operatorNumeric, + operatorNumeric: goperatorNumeric, state: radio.NETWORK_AVAILABLE, radioTech: gradioTech, }, @@ -354,19 +357,20 @@ describe('NetworkSearchTest', function () { * @tc.desc Function test */ it('Telephony_NetworkSearch_setNetworkSelectionMode_Async_0100', 0, async function (done) { - try{ + try { let data = await radio.getNetworkState(SLOT_0); console.log(`Telephony_NetworkSearch_getNetworkState data: ${JSON.stringify(data)}`) - if(data.plmnNumeric != '' && data.plmnNumeric != undefined){ - gnetworkSMode.networkInformation.operatorNumeric = data.plmnNumeric; - }else{ - console.log(`Telephony_NetworkSearch_getNetworkState fail`) + if (data.plmnNumeric != '' && data.plmnNumeric != undefined) { + goperatorNumeric = data.plmnNumeric; + goperatorName = data.longOperatorName; + } else { + console.log(`Telephony_NetworkSearch_getNetworkState fail`); expect().assertFail(); done(); return; } - }catch(err){ + } catch (err) { expect().assertFail(); done(); return; @@ -377,7 +381,7 @@ describe('NetworkSearchTest', function () { selectMode: radio.NETWORK_SELECTION_UNKNOWN, networkInformation: { operatorName: goperatorName, - operatorNumeric: gnetworkSMode.networkInformation.operatorNumeric, + operatorNumeric: goperatorNumeric, state: radio.NETWORK_AVAILABLE, radioTech: gradioTech, }, @@ -414,18 +418,19 @@ describe('NetworkSearchTest', function () { * @tc.desc Function test */ it('Telephony_NetworkSearch_setNetworkSelectionMode_Async_0200', 0, async function (done) { - try{ + try { let data = await radio.getNetworkState(SLOT_0); console.log(`Telephony_NetworkSearch_getNetworkState data: ${JSON.stringify(data)}`) - if(data.plmnNumeric != '' && data.plmnNumeric != undefined){ - gnetworkSMode.networkInformation.operatorNumeric = data.plmnNumeric; - }else{ - console.log(`Telephony_NetworkSearch_getNetworkState fail`) + if (data.plmnNumeric != '' && data.plmnNumeric != undefined) { + goperatorNumeric = data.plmnNumeric; + goperatorName = data.longOperatorName; + } else { + console.log(`Telephony_NetworkSearch_getNetworkState fail`); expect().assertFail(); done(); return; } - }catch(err){ + } catch (err) { expect().assertFail(); done(); return; @@ -436,7 +441,7 @@ describe('NetworkSearchTest', function () { selectMode: ERR_VALUE_5, networkInformation: { operatorName: goperatorName, - operatorNumeric: gnetworkSMode.networkInformation.operatorNumeric, + operatorNumeric: goperatorNumeric, state: radio.NETWORK_AVAILABLE, radioTech: gradioTech, }, @@ -474,18 +479,19 @@ describe('NetworkSearchTest', function () { * @tc.desc Function test */ it('Telephony_NetworkSearch_setNetworkSelectionMode_Async_0300', 0, async function (done) { - try{ + try { let data = await radio.getNetworkState(SLOT_0); console.log(`Telephony_NetworkSearch_getNetworkState data: ${JSON.stringify(data)}`) - if(data.plmnNumeric != '' && data.plmnNumeric != undefined){ - gnetworkSMode.networkInformation.operatorNumeric = data.plmnNumeric; - }else{ - console.log(`Telephony_NetworkSearch_getNetworkState fail`) + if (data.plmnNumeric != '' && data.plmnNumeric != undefined) { + goperatorNumeric = data.plmnNumeric; + goperatorName = data.longOperatorName; + } else { + console.log(`Telephony_NetworkSearch_getNetworkState fail`); expect().assertFail(); done(); return; } - }catch(err){ + } catch (err) { expect().assertFail(); done(); return; @@ -534,18 +540,19 @@ describe('NetworkSearchTest', function () { * @tc.desc Function test */ it('Telephony_NetworkSearch_setNetworkSelectionMode_Async_0400', 0, async function (done) { - try{ + try { let data = await radio.getNetworkState(SLOT_0); console.log(`Telephony_NetworkSearch_getNetworkState data: ${JSON.stringify(data)}`) - if(data.plmnNumeric != '' && data.plmnNumeric != undefined){ - gnetworkSMode.networkInformation.operatorNumeric = data.plmnNumeric; - }else{ - console.log(`Telephony_NetworkSearch_getNetworkState fail`) + if (data.plmnNumeric != '' && data.plmnNumeric != undefined) { + goperatorNumeric = data.plmnNumeric; + goperatorName = data.longOperatorName; + } else { + console.log(`Telephony_NetworkSearch_getNetworkState fail`); expect().assertFail(); done(); return; } - }catch(err){ + } catch (err) { expect().assertFail(); done(); return; @@ -556,7 +563,7 @@ describe('NetworkSearchTest', function () { selectMode: radio.NETWORK_SELECTION_MANUAL, networkInformation: { operatorName: goperatorName, - operatorNumeric: gnetworkSMode.networkInformation.operatorNumeric, + operatorNumeric: goperatorNumeric, state: radio.NETWORK_AVAILABLE, radioTech: gradioTech, }, @@ -592,18 +599,19 @@ describe('NetworkSearchTest', function () { * @tc.desc Function test */ it('Telephony_NetworkSearch_setNetworkSelectionMode_Async_0700', 0, async function (done) { - try{ + try { let data = await radio.getNetworkState(SLOT_0); console.log(`Telephony_NetworkSearch_getNetworkState data: ${JSON.stringify(data)}`) - if(data.plmnNumeric != '' && data.plmnNumeric != undefined){ - gnetworkSMode.networkInformation.operatorNumeric = data.plmnNumeric; - }else{ - console.log(`Telephony_NetworkSearch_getNetworkState fail`) + if (data.plmnNumeric != '' && data.plmnNumeric != undefined) { + goperatorNumeric = data.plmnNumeric; + goperatorName = data.longOperatorName; + } else { + console.log(`Telephony_NetworkSearch_getNetworkState fail`); expect().assertFail(); done(); return; } - }catch(err){ + } catch (err) { expect().assertFail(); done(); return; @@ -614,7 +622,7 @@ describe('NetworkSearchTest', function () { selectMode: radio.NETWORK_SELECTION_AUTOMATIC, networkInformation: { operatorName: goperatorName, - operatorNumeric: gnetworkSMode.networkInformation.operatorNumeric, + operatorNumeric: goperatorNumeric, state: radio.NETWORK_AVAILABLE, radioTech: gradioTech, }, @@ -642,37 +650,38 @@ describe('NetworkSearchTest', function () { * @tc.desc Function test */ it('Telephony_NetworkSearch_setNetworkSelectionMode_Promise_0100', 0, async function (done) { - try{ + try { let data = await radio.getNetworkState(SLOT_0); console.log(`Telephony_NetworkSearch_getNetworkState data: ${JSON.stringify(data)}`) - if(data.plmnNumeric != '' && data.plmnNumeric != undefined){ - gnetworkSMode.networkInformation.operatorNumeric = data.plmnNumeric; - }else{ - console.log(`Telephony_NetworkSearch_getNetworkState fail`) + if (data.plmnNumeric != '' && data.plmnNumeric != undefined) { + goperatorNumeric = data.plmnNumeric; + goperatorName = data.longOperatorName; + } else { + console.log(`Telephony_NetworkSearch_getNetworkState fail`); expect().assertFail(); done(); return; } - }catch(err){ + } catch (err) { + expect().assertFail(); + done(); + return; + } + try { + await radio.setNetworkSelectionMode(gnetworkSMode); + console.log('Telephony_NetworkSearch_recoverNetworkSelectionMode success'); + } catch (err) { + console.log('Telephony_NetworkSearch_recoverNetworkSelectionMode fail'); expect().assertFail(); done(); return; } - try { - await radio.setNetworkSelectionMode(gnetworkSMode); - console.log('Telephony_NetworkSearch_recoverNetworkSelectionMode success'); - } catch (err) { - console.log('Telephony_NetworkSearch_recoverNetworkSelectionMode fail'); - expect().assertFail(); - done(); - return; - } let networkSMode = { slotId: SLOT_0, selectMode: radio.NETWORK_SELECTION_UNKNOWN, networkInformation: { operatorName: goperatorName, - operatorNumeric: gnetworkSMode.networkInformation.operatorNumeric, + operatorNumeric: goperatorNumeric, state: radio.NETWORK_AVAILABLE, radioTech: gradioTech, }, @@ -712,18 +721,19 @@ describe('NetworkSearchTest', function () { * @tc.desc Function test */ it('Telephony_NetworkSearch_setNetworkSelectionMode_Promise_0200', 0, async function (done) { - try{ + try { let data = await radio.getNetworkState(SLOT_0); console.log(`Telephony_NetworkSearch_getNetworkState data: ${JSON.stringify(data)}`) - if(data.plmnNumeric != '' && data.plmnNumeric != undefined){ - gnetworkSMode.networkInformation.operatorNumeric = data.plmnNumeric; - }else{ - console.log(`Telephony_NetworkSearch_getNetworkState fail`) + if (data.plmnNumeric != '' && data.plmnNumeric != undefined) { + goperatorNumeric = data.plmnNumeric; + goperatorName = data.longOperatorName; + } else { + console.log(`Telephony_NetworkSearch_getNetworkState fail`); expect().assertFail(); done(); return; } - }catch(err){ + } catch (err) { expect().assertFail(); done(); return; @@ -742,7 +752,7 @@ describe('NetworkSearchTest', function () { selectMode: ERR_VALUE_5, networkInformation: { operatorName: goperatorName, - operatorNumeric: gnetworkSMode.networkInformation.operatorNumeric, + operatorNumeric: goperatorNumeric, state: radio.NETWORK_AVAILABLE, radioTech: gradioTech, }, @@ -775,23 +785,24 @@ describe('NetworkSearchTest', function () { /** * @tc.number Telephony_NetworkSearch_setNetworkSelectionMode_Promise_0300 - * @tc.name Test the setNetworkSelectionMode() and enter an outlier operatorNumeric: '46001' + * @tc.name Test the setNetworkSelectionMode() and enter an outlier operatorNumeric * return value is 'False' and the network selection mode update fails * @tc.desc Function test */ it('Telephony_NetworkSearch_setNetworkSelectionMode_Promise_0300', 0, async function (done) { - try{ + try { let data = await radio.getNetworkState(SLOT_0); console.log(`Telephony_NetworkSearch_getNetworkState data: ${JSON.stringify(data)}`) - if(data.plmnNumeric != '' && data.plmnNumeric != undefined){ - gnetworkSMode.networkInformation.operatorNumeric = data.plmnNumeric; - }else{ - console.log(`Telephony_NetworkSearch_getNetworkState fail`) + if (data.plmnNumeric != '' && data.plmnNumeric != undefined) { + goperatorNumeric = data.plmnNumeric; + goperatorName = data.longOperatorName; + } else { + console.log(`Telephony_NetworkSearch_getNetworkState fail`); expect().assertFail(); done(); return; } - }catch(err){ + } catch (err) { expect().assertFail(); done(); return; @@ -849,18 +860,19 @@ describe('NetworkSearchTest', function () { * @tc.desc Function test */ it('Telephony_NetworkSearch_setNetworkSelectionMode_Promise_0400', 0, async function (done) { - try{ + try { let data = await radio.getNetworkState(SLOT_0); console.log(`Telephony_NetworkSearch_getNetworkState data: ${JSON.stringify(data)}`) - if(data.plmnNumeric != '' && data.plmnNumeric != undefined){ - gnetworkSMode.networkInformation.operatorNumeric = data.plmnNumeric; - }else{ - console.log(`Telephony_NetworkSearch_getNetworkState fail`) + if (data.plmnNumeric != '' && data.plmnNumeric != undefined) { + goperatorNumeric = data.plmnNumeric; + goperatorName = data.longOperatorName; + } else { + console.log(`Telephony_NetworkSearch_getNetworkState fail`); expect().assertFail(); done(); return; } - }catch(err){ + } catch (err) { expect().assertFail(); done(); return; @@ -879,7 +891,7 @@ describe('NetworkSearchTest', function () { selectMode: radio.NETWORK_SELECTION_MANUAL, networkInformation: { operatorName: goperatorName, - operatorNumeric: gnetworkSMode.networkInformation.operatorNumeric, + operatorNumeric: goperatorNumeric, state: radio.NETWORK_AVAILABLE, radioTech: gradioTech, }, @@ -914,18 +926,19 @@ describe('NetworkSearchTest', function () { * @tc.desc Function test */ it('Telephony_NetworkSearch_setNetworkSelectionMode_Promise_0700', 0, async function (done) { - try{ + try { let data = await radio.getNetworkState(SLOT_0); console.log(`Telephony_NetworkSearch_getNetworkState data: ${JSON.stringify(data)}`) - if(data.plmnNumeric != '' && data.plmnNumeric != undefined){ - gnetworkSMode.networkInformation.operatorNumeric = data.plmnNumeric; - }else{ - console.log(`Telephony_NetworkSearch_getNetworkState fail`) + if (data.plmnNumeric != '' && data.plmnNumeric != undefined) { + goperatorNumeric = data.plmnNumeric; + goperatorName = data.longOperatorName; + } else { + console.log(`Telephony_NetworkSearch_getNetworkState fail`); expect().assertFail(); done(); return; } - }catch(err){ + } catch (err) { expect().assertFail(); done(); return; @@ -944,7 +957,7 @@ describe('NetworkSearchTest', function () { selectMode: radio.NETWORK_SELECTION_AUTOMATIC, networkInformation: { operatorName: goperatorName, - operatorNumeric: gnetworkSMode.networkInformation.operatorNumeric, + operatorNumeric: goperatorNumeric, state: radio.NETWORK_AVAILABLE, radioTech: gradioTech, }, @@ -971,18 +984,19 @@ describe('NetworkSearchTest', function () { * @tc.desc Function test */ it('Telephony_NetworkSearch_getNetworkSearchInformation_Async_0100', 0, async function (done) { - try{ + try { let data = await radio.getNetworkState(SLOT_0); console.log(`Telephony_NetworkSearch_getNetworkState data: ${JSON.stringify(data)}`) - if(data.plmnNumeric != '' && data.plmnNumeric != undefined){ - gnetworkSMode.networkInformation.operatorNumeric = data.plmnNumeric; - }else{ - console.log(`Telephony_NetworkSearch_getNetworkState fail`) + if (data.plmnNumeric != '' && data.plmnNumeric != undefined) { + goperatorNumeric = data.plmnNumeric; + goperatorName = data.longOperatorName; + } else { + console.log(`Telephony_NetworkSearch_getNetworkState fail`); expect().assertFail(); done(); return; } - }catch(err){ + } catch (err) { expect().assertFail(); done(); return; @@ -1033,18 +1047,19 @@ describe('NetworkSearchTest', function () { * @tc.desc Function test */ it('Telephony_NetworkSearch_getNetworkSearchInformation_Promise_0100', 0, async function (done) { - try{ + try { let data = await radio.getNetworkState(SLOT_0); console.log(`Telephony_NetworkSearch_getNetworkState data: ${JSON.stringify(data)}`) - if(data.plmnNumeric != '' && data.plmnNumeric != undefined){ - gnetworkSMode.networkInformation.operatorNumeric = data.plmnNumeric; - }else{ - console.log(`Telephony_NetworkSearch_getNetworkState fail`) + if (data.plmnNumeric != '' && data.plmnNumeric != undefined) { + goperatorNumeric = data.plmnNumeric; + goperatorName = data.longOperatorName; + } else { + console.log(`Telephony_NetworkSearch_getNetworkState fail`); expect().assertFail(); done(); return; } - }catch(err){ + } catch (err) { expect().assertFail(); done(); return; @@ -1094,22 +1109,6 @@ describe('NetworkSearchTest', function () { * @tc.desc Function test */ it('Telephony_NetworkSearch_getNetworkSearchInformation_Async_0400', 0, async function (done) { - try{ - let data = await radio.getNetworkState(SLOT_0); - console.log(`Telephony_NetworkSearch_getNetworkState data: ${JSON.stringify(data)}`) - if(data.plmnNumeric != '' && data.plmnNumeric != undefined){ - gnetworkSMode.networkInformation.operatorNumeric = data.plmnNumeric; - }else{ - console.log(`Telephony_NetworkSearch_getNetworkState fail`) - expect().assertFail(); - done(); - return; - } - }catch(err){ - expect().assertFail(); - done(); - return; - } let slotId = 33; radio.getNetworkSearchInformation(slotId, (err, data) => { if (err) { diff --git a/telephony/telephonyjstest/sim/BUILD.gn b/telephony/telephonyjstest/sim/BUILD.gn index 15d6a3d32b419744d92c0a9afbc612082cd4e39d..e72e613b91b079acc294de7fce1011cc09451b02 100644 --- a/telephony/telephonyjstest/sim/BUILD.gn +++ b/telephony/telephonyjstest/sim/BUILD.gn @@ -25,4 +25,4 @@ group("sim") { "sim_state_manager_function_test:SimStateManagerFunctionTest", ] } -} +} \ No newline at end of file diff --git a/telephony/telephonyjstest/sim/sim_file_manager_function_test/BUILD.gn b/telephony/telephonyjstest/sim/sim_file_manager_function_test/BUILD.gn index a24cfecae7b1612f41992ce92a5e32a6bbeb6fec..066399ac02e216660d1c2ba9e4b762c71213cbdd 100644 --- a/telephony/telephonyjstest/sim/sim_file_manager_function_test/BUILD.gn +++ b/telephony/telephonyjstest/sim/sim_file_manager_function_test/BUILD.gn @@ -28,4 +28,4 @@ ohos_js_assets("hjs_demo_js_assets") { ohos_resources("hjs_demo_resources") { sources = [ "./entry/src/main/js/resources" ] hap_profile = "./entry/src/main/config.json" -} +} \ No newline at end of file diff --git a/telephony/telephonyjstest/sim/sim_file_manager_function_test/entry/src/main/js/test/SimFileManagerFunction.test.js b/telephony/telephonyjstest/sim/sim_file_manager_function_test/entry/src/main/js/test/SimFileManagerFunction.test.js index 5e6a96698e53376e2ff85dca9d1a07be96b21d31..b92df042b867538457669b098303b0693bfc36bf 100644 --- a/telephony/telephonyjstest/sim/sim_file_manager_function_test/entry/src/main/js/test/SimFileManagerFunction.test.js +++ b/telephony/telephonyjstest/sim/sim_file_manager_function_test/entry/src/main/js/test/SimFileManagerFunction.test.js @@ -49,6 +49,7 @@ describe('SimFileManagerFunction', function () { sim.getIMSI(simSlotId.SLOT_ID_4, (err, data) => { if (err) { // Enter the exception ID to enter err. + console.log(`Telephony_Sim_getIMSI_Async_0200, err: ${err.message}`); console.log('Telephony_Sim_getIMSI_Async_0200 finish'); done(); return; @@ -66,7 +67,7 @@ describe('SimFileManagerFunction', function () { */ it('Telephony_Sim_getIMSI_Promise_0100', 0, async function (done) { try { - var data = await sim.getIMSI(simSlotId.SLOT_ID_0); + let data = await sim.getIMSI(simSlotId.SLOT_ID_0); console.log(`Telephony_Sim_getIMSI_Promise_0100 data = ${data}`); expect(data !== '' || data !== undefined).assertTrue(); expect(data.length === IMSI_LENGTH).assertTrue(); @@ -86,8 +87,10 @@ describe('SimFileManagerFunction', function () { */ it('Telephony_Sim_getIMSI_Promise_0200', 0, async function (done) { try { - var data = await sim.getIMSI(simSlotId.SLOT_ID_4); + let data = await sim.getIMSI(simSlotId.SLOT_ID_4); } catch (err) { + // Enter the exception ID to enter err. + console.log(`Telephony_Sim_getIMSI_Promise_0200, err: ${err.message}`); console.log('Telephony_Sim_getIMSI_Promise_0200 finish'); done(); return; @@ -127,6 +130,7 @@ describe('SimFileManagerFunction', function () { sim.getSimIccId(simSlotId.SLOT_ID_4, (err, data) => { if (err) { // Enter the exception ID to enter err. + console.log(`Telephony_Sim_getSimIccId_Async_0200, err: ${err.message}`); console.log('Telephony_Sim_getSimIccId_Async_0200 finish'); done(); return; @@ -144,7 +148,7 @@ describe('SimFileManagerFunction', function () { */ it('Telephony_Sim_getSimIccId_Promise_0100', 0, async function (done) { try { - var data = await sim.getSimIccId(simSlotId.SLOT_ID_0); + let data = await sim.getSimIccId(simSlotId.SLOT_ID_0); console.log(`Telephony_Sim_getSimIccId_Promise_0100 data${data}`); expect(data !== '' || data !== undefined).assertTrue(); expect(data.length === ICC_LENGTH).assertTrue(); @@ -164,8 +168,9 @@ describe('SimFileManagerFunction', function () { */ it('Telephony_Sim_getSimIccId_Promise_0200', 0, async function (done) { try { - var data = await sim.getSimIccId(simSlotId.SLOT_ID_4); + let data = await sim.getSimIccId(simSlotId.SLOT_ID_4); } catch (err) { + console.log(`Telephony_Sim_getSimIccId_Promise_0200, err: ${err.message}`); console.log('Telephony_Sim_getSimIccId_Promise_0200 finish'); done(); return; @@ -182,7 +187,7 @@ describe('SimFileManagerFunction', function () { * @tc.desc Function test */ it('Telephony_Sim_getISOCountryCodeForSim_Async_0100', 0, async function (done) { - var countryCode = 'cn'; + let countryCode = 'cn'; sim.getISOCountryCodeForSim(simSlotId.SLOT_ID_0, (err, data) => { if (err) { console.log(`Telephony_Sim_getISOCountryCodeForSim_Async_0100 fail, err: ${err.message}`); @@ -208,6 +213,7 @@ describe('SimFileManagerFunction', function () { sim.getISOCountryCodeForSim(simSlotId.SLOT_ID_4, (err, data) => { if (err) { // Expect slot id 4 return err here. + console.log(`Telephony_Sim_getISOCountryCodeForSim_Async_0200, err: ${err.message}`); console.log('Telephony_Sim_getISOCountryCodeForSim_Async_0200 finish'); done(); return; @@ -225,9 +231,9 @@ describe('SimFileManagerFunction', function () { * @tc.desc Function test */ it('Telephony_Sim_getISOCountryCodeForSim_Promise_0100', 0, async function (done) { - var countryCode = 'cn'; + let countryCode = 'cn'; try { - var data = await sim.getISOCountryCodeForSim(simSlotId.SLOT_ID_0); + let data = await sim.getISOCountryCodeForSim(simSlotId.SLOT_ID_0); console.log(`Telephony_Sim_getISOCountryCodeForSim_Promise_0100, data = ${data}`); // The country code for mainland China is cn. expect(data === countryCode).assertTrue(); @@ -252,6 +258,7 @@ describe('SimFileManagerFunction', function () { var data = await sim.getISOCountryCodeForSim(simSlotId.SLOT_ID_4); } catch (err) { // Expect slotid 4 return err here. + console.log(`Telephony_Sim_getISOCountryCodeForSim_Promise_0200, err: ${err.message}`); console.log('Telephony_Sim_getISOCountryCodeForSim_Promise_0200 finish'); done(); return; @@ -268,7 +275,7 @@ describe('SimFileManagerFunction', function () { * @tc.desc Function test */ it('Telephony_Sim_getSimOperatorNumeric_Async_0100', 0, async function (done) { - var operatorNumTopThree = '460'; + let operatorNumTopThree = '460'; sim.getSimOperatorNumeric(simSlotId.SLOT_ID_0, (err, data) => { if (err) { console.log(`Telephony_Sim_getSimOperatorNumeric_Async_0100 fail, err: ${err.message}`); @@ -297,6 +304,7 @@ describe('SimFileManagerFunction', function () { sim.getSimOperatorNumeric(simSlotId.SLOT_ID_4, (err, data) => { if (err) { // Expect slotid 4 return err here. + console.log(`Telephony_Sim_getSimOperatorNumeric_Async_0200, err: ${err.message}`); console.log('Telephony_Sim_getSimOperatorNumeric_Async_0200 finish'); done(); return; @@ -314,9 +322,9 @@ describe('SimFileManagerFunction', function () { * @tc.desc Function test */ it('Telephony_Sim_getSimOperatorNumeric_Promise_0100', 0, async function (done) { - var operatorNumTopThree = '460'; + let operatorNumTopThree = '460'; try { - var data = await sim.getSimOperatorNumeric(simSlotId.SLOT_ID_0); + let data = await sim.getSimOperatorNumeric(simSlotId.SLOT_ID_0); console.log(`Telephony_Sim_getSimOperatorNumeric_Promise_0100, data = ${data}`); expect(data !== '' && data !== undefined).assertTrue(); // The length of operator numeric in mainland China is 5. @@ -344,6 +352,7 @@ describe('SimFileManagerFunction', function () { var data = await sim.getSimOperatorNumeric(simSlotId.SLOT_ID_4); } catch (err) { // Expect slotid 4 return err here. + console.log(`Telephony_Sim_getSimOperatorNumeric_Promise_0200, err: ${err.message}`); console.log('Telephony_Sim_getSimOperatorNumeric_Promise_0200 finish'); done(); return; @@ -359,9 +368,9 @@ describe('SimFileManagerFunction', function () { * @tc.desc Function test */ it('Telephony_Sim_getSimSpn_Async_0100', 0, async function (done) { - var mobileSpn = '00434D4343FFFFFFFFFFFFFFFFFFFFFFFF'; - var unicomSpn = '00FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF'; - var telecomSpn = '01804E2D56FD75354FE1FFFFFFFFFFFFFF'; + let mobileSpn = '00434D4343FFFFFFFFFFFFFFFFFFFFFFFF'; + let unicomSpn = '00FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF'; + let telecomSpn = '01804E2D56FD75354FE1FFFFFFFFFFFFFF'; sim.getSimSpn(simSlotId.SLOT_ID_0, (err, data) => { if (err) { console.log(`Telephony_Sim_getSimSpn_Async_0100 fail, err: ${err.message}`); @@ -404,6 +413,7 @@ describe('SimFileManagerFunction', function () { sim.getSimSpn(simSlotId.SLOT_ID_4, (err, data) => { if (err) { // Expect slotid 4 return err here. + console.log(`Telephony_Sim_getSimSpn_Async_0200 fail: ${err.message}`); console.log('Telephony_Sim_getSimSpn_Async_0200 finish'); done(); return; @@ -420,15 +430,15 @@ describe('SimFileManagerFunction', function () { * @tc.desc Function test */ it('Telephony_Sim_getSimSpn_Promise_0100', 0, async function (done) { - var mobileSpn = '00434D4343FFFFFFFFFFFFFFFFFFFFFFFF'; - var unicomSpn = '00FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF'; - var telecomSpn = '01804E2D56FD75354FE1FFFFFFFFFFFFFF'; + let mobileSpn = '00434D4343FFFFFFFFFFFFFFFFFFFFFFFF'; + let unicomSpn = '00FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF'; + let telecomSpn = '01804E2D56FD75354FE1FFFFFFFFFFFFFF'; try { - var data = await sim.getSimSpn(simSlotId.SLOT_ID_0); + let data = await sim.getSimSpn(simSlotId.SLOT_ID_0); console.log(`Telephony_Sim_getSimSpn_Promise_0100, data = ${data}`); expect(data !== '' && data !== undefined).assertTrue(); try { - var value = await sim.getSimOperatorNumeric(simSlotId.SLOT_ID_0); + let value = await sim.getSimOperatorNumeric(simSlotId.SLOT_ID_0); console.log(`Telephony_Sim_getSimSpn_Promise_0100, value : ${value}`); if ((value === operatorCode.MOBILE_CODE_1) || (value === operatorCode.MOBILE_CODE_2) || (value === operatorCode.MOBILE_CODE_3) || (value === operatorCode.MOBILE_CODE_4)) { @@ -466,6 +476,7 @@ describe('SimFileManagerFunction', function () { var data = await sim.getSimSpn(simSlotId.SLOT_ID_4); } catch (err) { // Expect slotid 4 return err here. + console.log(`Telephony_Sim_getSimSpn_Promise_0200, err: ${err.message}`); console.log('Telephony_Sim_getSimSpn_Promise_0200 finish'); done(); return; @@ -481,7 +492,7 @@ describe('SimFileManagerFunction', function () { * @tc.desc Function test */ it('Telephony_Sim_getSimGid1_Async_0100', 0, async function (done) { - var minLength = 1; + let minLength = 1; sim.getSimGid1(simSlotId.SLOT_ID_0, (err, data) => { if (err) { console.log(`Telephony_Sim_getSimGid1_Async_0100 fail, err: ${err.message}`); @@ -506,6 +517,7 @@ describe('SimFileManagerFunction', function () { sim.getSimGid1(simSlotId.SLOT_ID_4, (err, data) => { if (err) { // Expect slotid 4 return err here. + console.log(`Telephony_Sim_getSimGid1_Async_0200, err: ${err.message}`); console.log('Telephony_Sim_getSimGid1_Async_0200 finish'); done(); return; @@ -522,9 +534,9 @@ describe('SimFileManagerFunction', function () { * @tc.desc Function test */ it('Telephony_Sim_getSimGid1_Promise_0100', 0, async function (done) { - var minLength = 1; + let minLength = 1; try { - var data = await sim.getSimGid1(simSlotId.SLOT_ID_0); + let data = await sim.getSimGid1(simSlotId.SLOT_ID_0); console.log(`Telephony_Sim_getSimGid1_Promise_0100, data = ${data}`); expect(data !== '' && data !== undefined).assertTrue(); expect((data.length >= minLength)).assertTrue(); @@ -548,6 +560,7 @@ describe('SimFileManagerFunction', function () { var data = await sim.getSimGid1(simSlotId.SLOT_ID_4); } catch (err) { // Expect slotid 4 return err here. + console.log(`Telephony_Sim_getSimGid1_Promise_0200, err: ${err.message}`); console.log('Telephony_Sim_getSimGid1_Promise_0200 finish'); done(); return; diff --git a/telephony/telephonyjstest/sim/sim_manager_function_test/BUILD.gn b/telephony/telephonyjstest/sim/sim_manager_function_test/BUILD.gn index 328cfbab0647661432a2eceff1e09682ae209f5a..8e8b35391a66b39cbbf2ba1d8c1ec6b1c87c3bc0 100644 --- a/telephony/telephonyjstest/sim/sim_manager_function_test/BUILD.gn +++ b/telephony/telephonyjstest/sim/sim_manager_function_test/BUILD.gn @@ -28,4 +28,4 @@ ohos_js_assets("hjs_demo_js_assets") { ohos_resources("hjs_demo_resources") { sources = [ "./entry/src/main/js/resources" ] hap_profile = "./entry/src/main/config.json" -} +} \ No newline at end of file diff --git a/telephony/telephonyjstest/sim/sim_manager_function_test/entry/src/main/js/test/SimManagerFunction.test.js b/telephony/telephonyjstest/sim/sim_manager_function_test/entry/src/main/js/test/SimManagerFunction.test.js index 9783379f3190c34caefcefdc25fa0c7cceb9aacb..616d88d55208077bcc3ccb42c05c3cfd5f0b05a1 100644 --- a/telephony/telephonyjstest/sim/sim_manager_function_test/entry/src/main/js/test/SimManagerFunction.test.js +++ b/telephony/telephonyjstest/sim/sim_manager_function_test/entry/src/main/js/test/SimManagerFunction.test.js @@ -19,6 +19,13 @@ import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from ' describe('SimManagerFunction', function () { + var defaultValue = 0; + beforeAll(async function () { + // Gets the default calling card ID. + let result = await sim.getDefaultVoiceSlotId(); + defaultValue = result; + }) + /** * @tc.number Telephony_Sim_getSimAccountInfo_Async_0100 * @tc.name Enter normal parameters to test whether the getSimAccountInfo @@ -26,8 +33,8 @@ describe('SimManagerFunction', function () { * @tc.desc Function test */ it('Telephony_Sim_getSimAccountInfo_Async_0100', 0, async function (done) { - var defaultName = 'simDefaultDisplayName'; - var defaultNumber = 'simDefaultDisplayNumber'; + let defaultName = 'simDefaultDisplayName'; + let defaultNumber = 'simDefaultDisplayNumber'; sim.getSimAccountInfo(simSlotId.SLOT_ID_0, (err, data) => { if (err) { console.log(`Telephony_Sim_getSimAccountInfo_Async_0100 fail, err: ${err.message}`); @@ -55,6 +62,7 @@ describe('SimManagerFunction', function () { sim.getSimAccountInfo(simSlotId.SLOT_ID_4, (err, data) => { if (err) { // Enter the exception ID to enter err. + console.log(`Telephony_Sim_getSimAccountInfo_Async_0200, err: ${err.message}`); console.log('Telephony_Sim_getSimAccountInfo_Async_0200 finish'); done(); return; @@ -72,10 +80,10 @@ describe('SimManagerFunction', function () { * @tc.desc Function test */ it('Telephony_Sim_getSimAccountInfo_Promise_0100', 0, async function (done) { - var defaultName = 'simDefaultDisplayName'; - var defaultNumber = 'simDefaultDisplayNumber'; + let defaultName = 'simDefaultDisplayName'; + let defaultNumber = 'simDefaultDisplayNumber'; try { - var data = await sim.getSimAccountInfo(simSlotId.SLOT_ID_0); + let data = await sim.getSimAccountInfo(simSlotId.SLOT_ID_0); expect(data.slotIndex === simSlotId.SLOT_ID_0).assertTrue(); // return the default piling data as simDefaultDisplayName. expect(data.showName === defaultName).assertTrue(); @@ -100,9 +108,10 @@ describe('SimManagerFunction', function () { */ it('Telephony_Sim_getSimAccountInfo_Promise_0200', 0, async function (done) { try { - var data = await sim.getSimAccountInfo(simSlotId.SLOT_ID_4); + let data = await sim.getSimAccountInfo(simSlotId.SLOT_ID_4); } catch (err) { // Enter the exception ID to enter err. + console.log(`Telephony_Sim_getSimAccountInfo_Promise_0200, err: ${err.message}`); console.log('Telephony_Sim_getSimAccountInfo_Promise_0200 finish'); done(); return; @@ -119,16 +128,6 @@ describe('SimManagerFunction', function () { * @tc.desc Function test */ it('Telephony_Sim_getDefaultVoiceSlotId_Async_0100', 0, async function (done) { - var defaultValue = 0; - sim.getDefaultVoiceSlotId((err, result) => { - if (err) { - console.log(`Telephony_Sim_getDefaultVoiceSlotId_Async_0100 fail, err: ${err.message}`); - expect().assertFail(); - done(); - return; - } - defaultValue = result; - }); sim.setDefaultVoiceSlotId(simSlotId.SLOT_ID_0, (err) => { if (err) { console.log(`Telephony_Sim_getDefaultVoiceSlotId_Async_0100 setDefaultVoiceSLOT_ID_err: ${err.message}`); @@ -168,16 +167,6 @@ describe('SimManagerFunction', function () { * @tc.desc Function test */ it('Telephony_Sim_getDefaultVoiceSlotId_Async_0200', 0, async function (done) { - var defaultValue = 0; - sim.getDefaultVoiceSlotId((err, result) => { - if (err) { - console.log(`Telephony_Sim_getDefaultVoiceSlotId_Async_0200 fail, err: ${err.message}`); - expect().assertFail(); - done(); - return; - } - defaultValue = result; - }); sim.setDefaultVoiceSlotId(simSlotId.SLOT_ID_2, (err) => { if (err) { console.log(`Telephony_Sim_getDefaultVoiceSlotId_Async_0200:setDefaultVoiceSLOT_ID_err: ${ @@ -218,13 +207,10 @@ describe('SimManagerFunction', function () { * @tc.desc Function test */ it('Telephony_Sim_getDefaultVoiceSlotId_Promise_0100', 0, async function (done) { - var defaultValue = 0; - var result = await sim.getDefaultVoiceSlotId(); - defaultValue = result; try { await sim.setDefaultVoiceSlotId(simSlotId.SLOT_ID_2); try { - var data = await sim.getDefaultVoiceSlotId(); + let data = await sim.getDefaultVoiceSlotId(); expect(data === simSlotId.SLOT_ID_2).assertTrue(); } catch (err) { console.log(`Telephony_Sim_getDefaultVoiceSlotId_Promise_0100 fail, err: ${err.message}`); @@ -250,13 +236,10 @@ describe('SimManagerFunction', function () { * @tc.desc Function test */ it('Telephony_Sim_getDefaultVoiceSlotId_Promise_0200', 0, async function (done) { - var defaultValue = 0; - var result = await sim.getDefaultVoiceSlotId(); - defaultValue = result; try { await sim.setDefaultVoiceSlotId(simSlotId.SLOT_ID_0); try { - var data = await sim.getDefaultVoiceSlotId(); + let data = await sim.getDefaultVoiceSlotId(); console.log(`Telephony_Sim_getDefaultVoiceSlotId_Promise_0200, data = ${data}`); expect(data === simSlotId.SLOT_ID_0).assertTrue(); // Restore Settings @@ -295,6 +278,7 @@ describe('SimManagerFunction', function () { } expect(result !== simSlotId.SLOT_ID_4).assertTrue(); }); + console.log(`Telephony_Sim_setDefaultVoiceSlotId_Async_0100, err: ${err.message}`); console.log('Telephony_Sim_setDefaultVoiceSlotId_Async_0100 finish'); done(); return; @@ -312,11 +296,12 @@ describe('SimManagerFunction', function () { */ it('Telephony_Sim_setDefaultVoiceSlotId_Promise_0100', 0, async function (done) { try { - var data = await sim.setDefaultVoiceSlotId(simSlotId.SLOT_ID_4); + let data = await sim.setDefaultVoiceSlotId(simSlotId.SLOT_ID_4); } catch (err) { // Expect slotid 4 return err here. - var result = await sim.getDefaultVoiceSlotId(); + let result = await sim.getDefaultVoiceSlotId(); expect(result !== simSlotId.SLOT_ID_4).assertTrue(); + console.log(`Telephony_Sim_setDefaultVoiceSlotId_Promise_0100, err: ${err.message}`); console.log('Telephony_Sim_setDefaultVoiceSlotId_Promise_0100 finish'); done(); return; diff --git a/telephony/telephonyjstest/sim/sim_no_sim_function_test/BUILD.gn b/telephony/telephonyjstest/sim/sim_no_sim_function_test/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..69ad8680c20274ff359a09378acef322ee1ad576 --- /dev/null +++ b/telephony/telephonyjstest/sim/sim_no_sim_function_test/BUILD.gn @@ -0,0 +1,31 @@ +# Copyright (c) 2021 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//test/xts/tools/build/suite.gni") + +ohos_js_hap_suite("SimNoSimFunctionTest") { + hap_profile = "./entry/src/main/config.json" + deps = [ + ":hjs_demo_js_assets", + ":hjs_demo_resources", + ] + certificate_profile = "./signature/openharmony_sx.p7b" + hap_name = "SimNoSimFunctionTest" +} +ohos_js_assets("hjs_demo_js_assets") { + source_dir = "./entry/src/main/js/default" +} +ohos_resources("hjs_demo_resources") { + sources = [ "./entry/src/main/js/resources" ] + hap_profile = "./entry/src/main/config.json" +} \ No newline at end of file diff --git a/telephony/telephonyjstest/sim/sim_no_sim_function_test/Test.json b/telephony/telephonyjstest/sim/sim_no_sim_function_test/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..c07d06dc6246b2194ca472abd13f6b6a81d9eaa2 --- /dev/null +++ b/telephony/telephonyjstest/sim/sim_no_sim_function_test/Test.json @@ -0,0 +1,19 @@ +{ + "description": "Configuration for sim no sim function Tests", + "driver": { + "type": "JSUnitTest", + "test-timeout": "240000", + "package": "com.ohos.simnosimfunction", + "shell-timeout": "240000", + "native-test-timeout":"240000" + }, + "kits": [ + { + "test-file-name": [ + "$module.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + } + ] +} diff --git a/telephony/telephonyjstest/sim/sim_no_sim_function_test/entry/package.json b/telephony/telephonyjstest/sim/sim_no_sim_function_test/entry/package.json new file mode 100644 index 0000000000000000000000000000000000000000..3fd1454b442611e11a40611d80b13c98a56d6bd0 --- /dev/null +++ b/telephony/telephonyjstest/sim/sim_no_sim_function_test/entry/package.json @@ -0,0 +1,15 @@ +{ + "name": "formate", + "version": "1.0.0", + "description": "", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1", + "lint":"eslint --fix ./src/main/js/**/**.js" + }, + "author": "", + "license": "ISC", + "devDependencies": { + "eslint": "^7.32.0" + } +} diff --git a/telephony/telephonyjstest/sim/sim_no_sim_function_test/entry/src/main/config.json b/telephony/telephonyjstest/sim/sim_no_sim_function_test/entry/src/main/config.json new file mode 100644 index 0000000000000000000000000000000000000000..d490b016dfc7fd7cc9cd027d8a755db0e224ebbb --- /dev/null +++ b/telephony/telephonyjstest/sim/sim_no_sim_function_test/entry/src/main/config.json @@ -0,0 +1,61 @@ +{ + "app": { + "bundleName": "com.ohos.simnosimfunction", + "vendor": "ohos", + "version": { + "code": 1000000, + "name": "1.0.0" + }, + "apiVersion": { + "compatible": 4, + "target": 5, + "releaseType": "Release" + } + }, + "deviceConfig": {}, + "module": { + "package": "com.ohos.simnosimfunction", + "name": ".MyApplication", + "deviceType": [ + "phone" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "entry", + "moduleType": "entry" + }, + "abilities": [ + { + "visible": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "name": "com.ohos.simnosimfunction.MainAbility", + "icon": "$media:icon", + "description": "$string:mainability_description", + "label": "$string:app_name", + "type": "page", + "launchType": "standard" + } + ], + "js": [ + { + "pages": [ + "pages/index/index" + ], + "name": "default", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + } + ] + } +} \ No newline at end of file diff --git a/telephony/telephonyjstest/sim/sim_no_sim_function_test/entry/src/main/js/default/app.js b/telephony/telephonyjstest/sim/sim_no_sim_function_test/entry/src/main/js/default/app.js new file mode 100644 index 0000000000000000000000000000000000000000..d61b8caa653cfb8b0cdceb353771c56284c50051 --- /dev/null +++ b/telephony/telephonyjstest/sim/sim_no_sim_function_test/entry/src/main/js/default/app.js @@ -0,0 +1,23 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export default { + onCreate () { + console.info('TestApplication onCreate'); + }, + onDestroy () { + console.info('TestApplication onDestroy'); + } +}; diff --git a/telephony/telephonyjstest/sim/sim_no_sim_function_test/entry/src/main/js/default/i18n/en-US.json b/telephony/telephonyjstest/sim/sim_no_sim_function_test/entry/src/main/js/default/i18n/en-US.json new file mode 100644 index 0000000000000000000000000000000000000000..55561b83737c3c31d082fbfa11e5fc987a351104 --- /dev/null +++ b/telephony/telephonyjstest/sim/sim_no_sim_function_test/entry/src/main/js/default/i18n/en-US.json @@ -0,0 +1,8 @@ +{ + "strings": { + "hello": "Hello", + "world": "World" + }, + "Files": { + } +} \ No newline at end of file diff --git a/telephony/telephonyjstest/sim/sim_no_sim_function_test/entry/src/main/js/default/i18n/zh-CN.json b/telephony/telephonyjstest/sim/sim_no_sim_function_test/entry/src/main/js/default/i18n/zh-CN.json new file mode 100644 index 0000000000000000000000000000000000000000..cce1af06761a42add0cac1a0567aa3237eda8cb4 --- /dev/null +++ b/telephony/telephonyjstest/sim/sim_no_sim_function_test/entry/src/main/js/default/i18n/zh-CN.json @@ -0,0 +1,8 @@ +{ + "strings": { + "hello": "您好", + "world": "世界" + }, + "Files": { + } +} \ No newline at end of file diff --git a/telephony/telephonyjstest/sim/sim_no_sim_function_test/entry/src/main/js/default/pages/index/index.css b/telephony/telephonyjstest/sim/sim_no_sim_function_test/entry/src/main/js/default/pages/index/index.css new file mode 100644 index 0000000000000000000000000000000000000000..6fda792753f2e15f22b529c7b90a82185b2770bf --- /dev/null +++ b/telephony/telephonyjstest/sim/sim_no_sim_function_test/entry/src/main/js/default/pages/index/index.css @@ -0,0 +1,9 @@ +.container { + flex-direction: column; + justify-content: center; + align-items: center; +} + +.title { + font-size: 100px; +} diff --git a/telephony/telephonyjstest/sim/sim_no_sim_function_test/entry/src/main/js/default/pages/index/index.hml b/telephony/telephonyjstest/sim/sim_no_sim_function_test/entry/src/main/js/default/pages/index/index.hml new file mode 100644 index 0000000000000000000000000000000000000000..371603e8dea03f96bec7d7d0692c22592a838671 --- /dev/null +++ b/telephony/telephonyjstest/sim/sim_no_sim_function_test/entry/src/main/js/default/pages/index/index.hml @@ -0,0 +1,5 @@ +