diff --git a/request/RequestTest_Stage/entry/src/main/ets/test/requestDownload.test.ets b/request/RequestTest_Stage/entry/src/main/ets/test/requestDownload.test.ets index f9d7fc89b9acd3b655ef49ea019e536626046994..b50ebc73f4774a85def6bc1871d05b5f591dd356 100644 --- a/request/RequestTest_Stage/entry/src/main/ets/test/requestDownload.test.ets +++ b/request/RequestTest_Stage/entry/src/main/ets/test/requestDownload.test.ets @@ -50,81 +50,7 @@ export default function requestDownloadJSUnit() { }); let downloadTask; - - /** - * @tc.number SUB_REQUEST_DOWNLOAD_STAGE_API_CALLBACK_0001 - * @tc.desc Starts a download session. - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_REQUEST_DOWNLOAD_STAGE_API_CALLBACK_0001', 0, async function (done) { - console.info("====>------------------SUB_REQUEST_DOWNLOAD_STAGE_API_CALLBACK_0001 is starting-----------------------"); - let downloadFilePath = `${globalThis.abilityContext.tempDir}/SUB_REQUEST_DOWNLOAD_STAGE_API_CALLBACK_0001.txt` - console.debug("====>downloadFileConfig:" + `${globalThis.abilityContext.tempDir}/SUB_REQUEST_DOWNLOAD_STAGE_API_CALLBACK_0001.txt`) - let downloadConfig = { - url: 'https://www.baidu.com/img/PCtm_d9c8750bed0b3c7d089fa7d55720d6cf.png', - header: { - headers: 'http' - }, - enableMetered: false, - enableRoaming: false, - description: 'XTS download test!', - networkType: request.NETWORK_WIFI, - filePath: downloadFilePath, - title: 'XTS download test!', - background: false - } - request.download(globalThis.abilityContext, downloadConfig, async (err, data)=>{ - downloadTask = data; - console.info("====>SUB_REQUEST_DOWNLOAD_STAGE_API_CALLBACK_0001 downloadTask: " + downloadTask); - try { - expect(true).assertEqual(downloadTask != undefined); - await downloadTask.delete() - } catch (err) { - console.info("====>SUB_REQUEST_DOWNLOAD_STAGE_API_CALLBACK_0001 error: " + err); - } - done(); - }); - - }); - - /** - * @tc.number SUB_REQUEST_DOWNLOAD_STAGE_API_PROMISE_0001 - * @tc.desc Starts a download session. - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_REQUEST_DOWNLOAD_STAGE_API_PROMISE_0001', 0, async function (done) { - console.info("====>------------------SUB_REQUEST_DOWNLOAD_STAGE_API_PROMISE_0001 is starting-----------------------"); - let downloadFilePath = `${globalThis.abilityContext.tempDir}/SUB_REQUEST_DOWNLOAD_STAGE_API_PROMISE_0001.txt` - console.debug("====>downloadFileConfig:" + `${globalThis.abilityContext.tempDir}/SUB_REQUEST_DOWNLOAD_STAGE_API_PROMISE_0001.txt`) - let downloadConfig = { - url: 'https://www.baidu.com/img/PCtm_d9c8750bed0b3c7d089fa7d55720d6cf.png', - header: { - headers: 'http' - }, - enableMetered: false, - enableRoaming: false, - description: 'XTS download test!', - networkType: request.NETWORK_WIFI, - filePath: downloadFilePath, - title: 'XTS download test!', - background: false - } - request.download(globalThis.abilityContext, downloadConfig).then(async (data) => { - downloadTask = data; - console.info("====>SUB_REQUEST_DOWNLOAD_STAGE_API_PROMISE_0001 downloadTask: " + downloadTask); - expect(true).assertEqual(downloadTask != undefined); - await downloadTask.delete() - done(); - }).catch(err => { - console.info("====>SUB_REQUEST_DOWNLOAD_STAGE_API_PROMISE_0001 error: " + err); - done(); - }) - }); - + /** * @tc.number SUB_REQUEST_downloadFile_STAGE_API_CALLBACK_0001 * @tc.desc Starts a download session. diff --git a/request/RequestTest_Stage/entry/src/main/ets/test/requestUpload.test.ets b/request/RequestTest_Stage/entry/src/main/ets/test/requestUpload.test.ets index 2dd93f246b703b9ddf6f8df55254ede9124048e3..0ae3541cf3dbc800cc0e92b941d4b8c20361ebe3 100644 --- a/request/RequestTest_Stage/entry/src/main/ets/test/requestUpload.test.ets +++ b/request/RequestTest_Stage/entry/src/main/ets/test/requestUpload.test.ets @@ -77,205 +77,8 @@ export default function requestUploadJSUnit() { method: 'POST', files: [File], data: [RequestData] - }; - - /** - * @tc.number SUB_REQUEST_UPLOAD_STAGE_API_CALLBACK_0001 - * @tc.name Test requestUploadTest type = TIMER_TYPE_REALTIME - * @tc.desc Test requestUploadTest API functionality. - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 1 - */ - it('SUB_REQUEST_UPLOAD_STAGE_API_CALLBACK_0001', 0, async function (done) { - console.info("====>------------------SUB_REQUEST_UPLOAD_STAGE_API_CALLBACK_0001 is starting-----------------------"); - try { - console.info("====>SUB_REQUEST_UPLOAD_STAGE_API_CALLBACK_0001 uploadConfig = " + JSON.stringify(uploadConfig)); - let abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); - request.upload(globalThis.abilityContext, uploadConfig, (err, data) => { - uploadTask = data; - console.info("====>SUB_REQUEST_UPLOAD_STAGE_API_CALLBACK_0001 progress uploadTask =" + JSON.stringify(uploadTask)); - console.info("====>SUB_REQUEST_UPLOAD_STAGE_API_CALLBACK_0001 progress uploadTask =" + uploadTask); - expect(true).assertEqual(uploadTask != undefined); - - uploadTask.on('progress', function (data1, data2) { - console.info("====>SUB_REQUEST_UPLOAD_STAGE_API_CALLBACK_0001 on data1 =" + data1); - console.info("====>SUB_REQUEST_UPLOAD_STAGE_API_CALLBACK_0001 on data2 =" + data2); - }); - - uploadTask.off('progress', function (data1, data2) { - console.info("====>SUB_REQUEST_UPLOAD_STAGE_API_CALLBACK_0001 off data1 =" + data1); - console.info("====>SUB_REQUEST_UPLOAD_STAGE_API_CALLBACK_0001 off data2 =" + data2); - }); - - uploadTask.remove((err, data) => { - console.info("====>SUB_REQUEST_UPLOAD_STAGE_API_CALLBACK_0001 remove =" + data); - }); - }); - } catch (err) { - console.info("====>SUB_REQUEST_UPLOAD_STAGE_API_CALLBACK_0001 error: " + err); - } - setTimeout(()=>{ - console.info("====>------------------SUB_REQUEST_UPLOAD_STAGE_API_CALLBACK_0001 end-----------------------"); - done(); - }, 10000) - }); - - /* - * @tc.number : SUB_REQUEST_UPLOAD_STAGE_API_PROMISE_0001 - * @tc.name : Use getEntries get the value by mixing the string key - * @tc.desc : Mixed strings value can be obtained correctly - * @tc.size : MediumTest - * @tc.type : Function - * @tc.level : Level 1 - */ - it('SUB_REQUEST_UPLOAD_STAGE_API_PROMISE_0001', 0, async function (done) { - console.info("====>------------------SUB_REQUEST_UPLOAD_STAGE_API_PROMISE_0001 is starting-----------------------"); - try { - console.info("====>SUB_REQUEST_UPLOAD_STAGE_API_PROMISE_0001 UploadConfig = " + JSON.stringify(uploadConfig)); - let abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); - request.upload(globalThis.abilityContext, uploadConfig).then((data) => { - uploadTask = data; - console.info("====>SUB_REQUEST_UPLOAD_STAGE_API_PROMISE_0001 uploadTask = " + uploadTask); - expect(true).assertEqual(uploadTask != undefined); - - uploadTask.on('headerReceive', (header) => { - console.info("====>SUB_REQUEST_UPLOAD_STAGE_API_PROMISE_0001 header = " + header); - expect(true).assertEqual((header != undefined) || (header != "") || (header != {})); - }); - - uploadTask.off('headerReceive', (header) => { - console.info("====>SUB_REQUEST_UPLOAD_STAGE_API_PROMISE_0001 header = " + header); - expect(true).assertEqual((header != undefined) || (header != "") || (header != {})); - }); - - uploadTask.remove().then((result)=>{ - console.info("====>SUB_REQUEST_UPLOAD_STAGE_API_PROMISE_0001 remove result = " + result); - expect(result).assertEqual(true); - }); - }); - } catch (e) { - console.info("====>SUB_REQUEST_UPLOAD_STAGE_API_PROMISE_0001 error: " + JSON.stringify(e)); - } - setTimeout(()=>{ - console.info("====>------------------SUB_REQUEST_UPLOAD_STAGE_API_PROMISE_0001 end-----------------------"); - done(); - }, 10000) - }); - - /** - * @tc.number : SUB_REQUEST_UPLOAD_API_PROMISE_0002 - * @tc.name : Use getEntries get the value by mixing the string key - * @tc.desc : Called when the current upload session complete or fail. - * @tc.size : MediumTest - * @tc.type : Function - * @tc.level : Level 1 - */ - it('SUB_REQUEST_UPLOAD_API_PROMISE_0002', 0, async function (done) { - console.info("====>------------------SUB_REQUEST_UPLOAD_API_PROMISE_0002 is starting-----------------------"); - try { - console.info("====>SUB_REQUEST_UPLOAD_API_PROMISE_0002 UploadConfig = " + JSON.stringify(uploadConfig)); - request.upload(globalThis.abilityContext, uploadConfig).then((data) => { - try{ - uploadTask = data; - console.info("====>SUB_REQUEST_UPLOAD_API_PROMISE_0002 uploadTask = " + uploadTask); - expect(true).assertEqual((uploadTask != undefined) || (uploadTask != "") || (uploadTask != {})); - - uploadTask.on('complete', (TaskState) => { - for(let i = 0; i < TaskState.length; i++){ - console.info("====>SUB_REQUEST_UPLOAD_API_PROMISE_0002 complete TaskState = " + JSON.stringify(TaskState[i])) - console.info("====>SUB_REQUEST_UPLOAD_API_PROMISE_0002 complete TaskState.path = " + TaskState[i].path); - console.info("====>SUB_REQUEST_UPLOAD_API_PROMISE_0002 complete TaskState.responseCode = " + TaskState[i].responseCode); - console.info("====>SUB_REQUEST_UPLOAD_API_PROMISE_0002 complete TaskState.TaskState.message = " + TaskState[i].message); - expect(typeof(TaskState[i].path) == "string").assertEqual(true); - expect(typeof(TaskState[i].responseCode) == "number").assertEqual(true); - expect(typeof(TaskState[i].message) == "string").assertEqual(true); - } - done(); - }); - - uploadTask.on('fail', (TaskState) => { - for(let i = 0; i < TaskState.length; i++){ - console.info("====>SUB_REQUEST_UPLOAD_API_PROMISE_0002 fail TaskState = " + JSON.stringify(TaskState[i])) - console.info("====>SUB_REQUEST_UPLOAD_API_PROMISE_0002 fail TaskState.path = " + TaskState[i].path); - console.info("====>SUB_REQUEST_UPLOAD_API_PROMISE_0002 fail TaskState.responseCode = " + TaskState[i].responseCode); - console.info("====>SUB_REQUEST_UPLOAD_API_PROMISE_0002 fail TaskState.TaskState.message = " + TaskState[i].message); - expect(typeof(TaskState[i].path) == "string").assertEqual(true); - expect(typeof(TaskState[i].responseCode) == "number").assertEqual(true); - expect(typeof(TaskState[i].message) == "string").assertEqual(true); - } - expect(true).assertEqual(true); - }); - }catch(err){ - console.info("====>SUB_REQUEST_UPLOAD_API_PROMISE_0002 error: " + JSON.stringify(err)); - expect(true).assertFail(true); - } - }).catch((err)=>{ - console.info("====>SUB_REQUEST_UPLOAD_API_PROMISE_0002 error: " + JSON.stringify(err)); - expect(true).assertFail(true); - }) - } catch (e) { - console.info("====>SUB_REQUEST_UPLOAD_API_PROMISE_0002 throw_error: " + JSON.stringify(e)); - expect(true).assertFail(true); - } - setTimeout(()=>{ - console.info("====>------------------SUB_REQUEST_UPLOAD_API_PROMISE_0002 end-----------------------"); - done(); - }, 10000) - }); - - /** - * @tc.number : SUB_REQUEST_UPLOAD_API_PROMISE_0003 - * @tc.name : Use getEntries get the value by mixing the string key - * @tc.desc : Called when the current upload session complete or fail. - * @tc.size : MediumTest - * @tc.type : Function - * @tc.level : Level 1 - */ - it('SUB_REQUEST_UPLOAD_API_PROMISE_0003', 0, async function (done) { - console.info("====>------------------SUB_REQUEST_UPLOAD_API_PROMISE_0003 is starting-----------------------"); - try { - console.info("====>SUB_REQUEST_UPLOAD_API_PROMISE_0003 UploadConfig = " + JSON.stringify(uploadConfig)); - request.upload(globalThis.abilityContext, uploadConfig).then((data) => { - try{ - uploadTask = data; - console.info("====>SUB_REQUEST_UPLOAD_API_PROMISE_0003 uploadTask = " + uploadTask); - expect(true).assertEqual((uploadTask != undefined) || (uploadTask != "") || (uploadTask != {})); - - uploadTask.off('complete', () => { - try{ - console.info("====>SUB_REQUEST_UPLOAD_API_PROMISE_0003 TaskState success"); - expect(true).assertEqual(true); - }catch(err){ - console.debug("====>SUB_REQUEST_UPLOAD_API_PROMISE_0003 complete err"+ JSON.stringify(err)); - done(); - } - }); - - uploadTask.off('fail', () => { - try{ - console.info("====>SUB_REQUEST_UPLOAD_API_PROMISE_0003 TaskState success"); - expect(true).assertEqual(true); - }catch(err){ - console.debug("====>SUB_REQUEST_UPLOAD_API_PROMISE_0003 fail err" + JSON.stringify(err)); - done(); - } - }); - }catch(err){ - expect().assertFail(); - done(); - } - }); - } catch (e) { - console.info("====>SUB_REQUEST_UPLOAD_API_PROMISE_0003 error: " + JSON.stringify(e)); - expect(true).assertFail(true); - } - setTimeout(()=>{ - console.info("====>------------------SUB_REQUEST_UPLOAD_API_PROMISE_0003 end-----------------------"); - done(); - }, 10000) - }); - + }; + /** * @tc.number SUB_REQUEST_uploadFile_STAGE_API_CALLBACK_0001 * @tc.desc Starts a upload task. diff --git a/time/timeTest/entry/src/main/ets/test/systemTimer.test.ets b/time/timeTest/entry/src/main/ets/test/systemTimer.test.ets index db00d91b8bc0b5cc434ab48e2bc9bb88f1d6f3f2..8ffb16a032620ff129d9430baa6efa21b6661f62 100644 --- a/time/timeTest/entry/src/main/ets/test/systemTimer.test.ets +++ b/time/timeTest/entry/src/main/ets/test/systemTimer.test.ets @@ -91,7 +91,7 @@ export default function systemTimerTest() { repeat: false }; console.info('====>SUB_time_systemTimer_createTimer_0000 create timer.'); - systemTimer.createTimer(options, function (err, timerID) { + systemTimer.createTimer(options, async (err, timerID) => { try { if (err) { console.info('====>SUB_time_systemTimer_createTimer_0000 create fail: ' + err); @@ -100,6 +100,7 @@ export default function systemTimerTest() { } console.info('====>SUB_time_systemTimer_createTimer_0000 timerID: ' + timerID); expect(Number.isInteger(timerID)).assertTrue(); + await systemTimer.destroyTimer(timerID) done(); } catch (error) { console.info('====>SUB_time_systemTimer_createTimer_0000 catch err ' + error); @@ -124,7 +125,7 @@ export default function systemTimerTest() { repeat: false }; console.info('====>SUB_time_systemTimer_createTimer_0001 create timer.'); - systemTimer.createTimer(options, function (err, timerID) { + systemTimer.createTimer(options, async (err, timerID) => { try { if (err) { console.info('====>SUB_time_systemTimer_createTimer_0001 create fail: ' + err); @@ -133,6 +134,7 @@ export default function systemTimerTest() { } console.info('====>SUB_time_systemTimer_createTimer_0001 timerID: ' + timerID); expect(Number.isInteger(timerID)).assertTrue(); + await systemTimer.destroyTimer(timerID) done(); } catch (error) { console.info('====>SUB_time_systemTimer_createTimer_0001 catch err ' + error); @@ -162,7 +164,7 @@ export default function systemTimerTest() { interval: interval_time }; console.info('====>SUB_time_systemTimer_createTimer_0002 create timer.'); - systemTimer.createTimer(options, function (err, timerID) { + systemTimer.createTimer(options, async (err, timerID) => { try { if (err) { console.info('====>SUB_time_systemTimer_createTimer_0002 create fail: ' + err); @@ -171,6 +173,7 @@ export default function systemTimerTest() { } console.info('====>SUB_time_systemTimer_createTimer_0002 timerID: ' + timerID); expect(Number.isInteger(timerID)).assertTrue(); + await systemTimer.destroyTimer(timerID) done(); } catch (error) { console.info('====>SUB_time_systemTimer_createTimer_0002 catch err ' + error); @@ -195,7 +198,7 @@ export default function systemTimerTest() { repeat: false }; console.info('====>SUB_time_systemTimer_createTimer_0003 create timer.'); - systemTimer.createTimer(options, function (err, timerID) { + systemTimer.createTimer(options, async (err, timerID) => { try { if (err) { console.info('====>SUB_time_systemTimer_createTimer_0003 create fail: ' + err); @@ -204,6 +207,7 @@ export default function systemTimerTest() { } console.info('====>SUB_time_systemTimer_createTimer_0003 timerID: ' + timerID); expect(Number.isInteger(timerID)).assertTrue(); + await systemTimer.destroyTimer(timerID) done(); } catch (error) { console.info('====>SUB_time_systemTimer_createTimer_0003 catch err ' + error); @@ -233,7 +237,7 @@ export default function systemTimerTest() { interval: interval_time }; console.info('====>SUB_time_systemTimer_createTimer_0004 create timer.'); - systemTimer.createTimer(options, function (err, timerID) { + systemTimer.createTimer(options, async (err, timerID) => { try { if (err) { console.info('====>SUB_time_systemTimer_createTimer_0004 create fail: ' + err); @@ -242,6 +246,7 @@ export default function systemTimerTest() { } console.info('====>SUB_time_systemTimer_createTimer_0004 timerID: ' + timerID); expect(Number.isInteger(timerID)).assertTrue(); + await systemTimer.destroyTimer(timerID) done(); } catch (error) { console.info('====>SUB_time_systemTimer_createTimer_0004 catch err ' + error); @@ -265,16 +270,19 @@ export default function systemTimerTest() { type: systemTimer.TIMER_TYPE_REALTIME, repeat: false }; + let globalTimerID; await systemTimer.createTimer(options).then((timerID) => { console.info('====>SUB_time_systemTimer_createTimer_0005 timerID: ' + timerID); + globalTimerID = timerID; expect(Number.isInteger(timerID)).assertTrue(); - done(); }).catch(err => { console.info('====>SUB_time_systemTimer_createTimer_0005 createTimer fail: ' + err); expect().assertTrue(); done(); }); console.info('====>SUB_time_systemTimer_createTimer_0005 end.'); + await systemTimer.destroyTimer(globalTimerID) + done(); }); /** @@ -291,16 +299,19 @@ export default function systemTimerTest() { type: systemTimer.TIMER_TYPE_IDLE, repeat: false }; + let globalTimerID; await systemTimer.createTimer(options).then((timerID) => { console.info('====>SUB_time_systemTimer_createTimer_0006 timerID: ' + timerID); + globalTimerID = timerID; expect(Number.isInteger(timerID)).assertTrue(); - done(); }).catch(err => { console.info('====>SUB_time_systemTimer_createTimer_0006 createTimer fail: ' + err); expect().assertTrue(); done(); }); console.info('====>SUB_time_systemTimer_createTimer_0006 end.'); + await systemTimer.destroyTimer(globalTimerID) + done(); }); /** @@ -322,16 +333,19 @@ export default function systemTimerTest() { wantAgent: wantAgent, interval: interval_time }; + let globalTimerID; await systemTimer.createTimer(options).then((timerID) => { console.info('====>SUB_time_systemTimer_createTimer_0007 timerID: ' + timerID); + globalTimerID = timerID; expect(Number.isInteger(timerID)).assertTrue(); - done(); }).catch(err => { console.info('====>SUB_time_systemTimer_createTimer_0007 createTimer fail: ' + err); expect().assertTrue(); done(); }); console.info('====>SUB_time_systemTimer_createTimer_0007 end.'); + await systemTimer.destroyTimer(globalTimerID) + done(); }); /** @@ -348,16 +362,19 @@ export default function systemTimerTest() { type: systemTimer.TIMER_TYPE_EXACT, repeat: false }; + let globalTimerID; await systemTimer.createTimer(options).then((timerID) => { console.info('====>SUB_time_systemTimer_createTimer_0008 timerID: ' + timerID); + globalTimerID = timerID; expect(Number.isInteger(timerID)).assertTrue(); - done(); }).catch(err => { console.info('====>SUB_time_systemTimer_createTimer_0008 createTimer fail: ' + err); expect().assertTrue(); done(); }); console.info('====>SUB_time_systemTimer_createTimer_0008 end.'); + await systemTimer.destroyTimer(globalTimerID) + done(); }); /** @@ -379,16 +396,19 @@ export default function systemTimerTest() { wantAgent: wantAgent, interval: interval_time }; + let globalTimerID; await systemTimer.createTimer(options).then((timerID) => { console.info('====>SUB_time_systemTimer_createTimer_0009 timerID: ' + timerID); + globalTimerID = timerID; expect(Number.isInteger(timerID)).assertTrue(); - done(); }).catch(err => { console.info('====>SUB_time_systemTimer_createTimer_0009 createTimer fail: ' + err); expect().assertTrue(); done(); }); console.info('====>SUB_time_systemTimer_createTimer_0009 end.'); + await systemTimer.destroyTimer(globalTimerID) + done(); }); /** @@ -413,7 +433,7 @@ export default function systemTimerTest() { }).catch(err => { console.info('====>SUB_time_systemTimer_createTimer_0009 createTimer fail: ' + err); }); - systemTimer.startTimer(globalTimerID, triggerTime, function (err, data) { + systemTimer.startTimer(globalTimerID, triggerTime, async (err, data) => { try { if (err) { console.info('====>SUB_time_systemTimer_startTimer_0001 wrong since ' + err.code); @@ -422,6 +442,7 @@ export default function systemTimerTest() { } console.info("====>SUB_time_systemTimer_startTimer_0001 success to start timerID: " + globalTimerID); expect(true).assertTrue(); + await systemTimer.destroyTimer(globalTimerID) done(); } catch (e) { console.info('====>SUB_time_systemTimer_startTimer_0001 has failed for ' + e); @@ -452,7 +473,7 @@ export default function systemTimerTest() { }).catch(err => { console.info('====>SUB_time_systemTimer_createTimer_0009 createTimer fail: ' + err); }); - systemTimer.stopTimer(globalTimerID, function (err, data) { + systemTimer.stopTimer(globalTimerID, async (err, data) => { try { if (err) { console.info("====>SUB_time_systemTimer_stopTimer_0001 stop fail timerID: " + globalTimerID); @@ -461,6 +482,7 @@ export default function systemTimerTest() { }; console.info("====>SUB_time_systemTimer_stopTimer_0001 success to stop timerID: " + globalTimerID); expect(true).assertTrue(); + await systemTimer.destroyTimer(globalTimerID) done(); } catch (e) { console.info('====>SUB_time_systemTimer_stopTimer_0001 has failed for ' + e); @@ -523,16 +545,19 @@ export default function systemTimerTest() { type: systemTimer.TIMER_TYPE_REALTIME, repeat: false }; + let globalTimerID; console.info('====>SUB_time_systemTimer_createTimerPromise_0001 create timer.'); await systemTimer.createTimer(options).then((timerID) => { console.info('====>SUB_time_systemTimer_createTimerPromise_0001 timerID:' + timerID); + globalTimerID = timerID; expect(Number.isInteger(timerID)).assertTrue(); - done(); }).catch(error => { console.info('====>SUB_time_systemTimer_createTimerPromise_0001 failed to create timer: ' + error); expect().assertTrue(); done(); }); + await systemTimer.destroyTimer(globalTimerID) + done(); }); /** @@ -560,13 +585,14 @@ export default function systemTimerTest() { await systemTimer.startTimer(globalTimerID, triggerTime).then(() => { console.info('====>SUB_time_systemTimer_startTimer_0002 timerID:' + globalTimerID); expect(true).assertTrue(); - done(); }).catch((err) => { console.info('====>SUB_time_systemTimer_startTimer_0002 failed to start timer: ' + err); expect().assertTrue(); done(); }); console.info('====>SUB_time_systemTimer_startTimer_0002 end.'); + await systemTimer.destroyTimer(globalTimerID) + done(); }); /** @@ -593,13 +619,14 @@ export default function systemTimerTest() { await systemTimer.stopTimer(globalTimerID).then(() => { console.info('====>SUB_time_systemTimer_stopTimer_0002 timerID:' + globalTimerID); expect(true).assertTrue(); - done(); }).catch((err) => { console.info('====>SUB_time_systemTimer_stopTimer_0002 failed to stop timer:' + err); expect().assertTrue(); done(); }); console.info('====>SUB_time_systemTimer_stopTimer_0002 end.'); + await systemTimer.destroyTimer(globalTimerID) + done(); }); /** @@ -663,7 +690,7 @@ export default function systemTimerTest() { try { systemTimer.stopTimer(timerID) .then(() => { - systemTimer.destroyTimer(timerID, function (err, data) { + systemTimer.destroyTimer(timerID, async (err, data) => { console.info('====>SUB_time_systemTimer_ALL_Promise_0008 destroyTimer: ' + timerID); done(); });