From de6363ce99b30164d3b7c658e6f754c0e14206ee Mon Sep 17 00:00:00 2001 From: 15829070344 Date: Mon, 28 Nov 2022 17:31:32 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E4=B8=8A=E4=BC=A0=E4=B8=8B=E8=BD=BD?= =?UTF-8?q?=E3=80=91=E8=AE=A2=E9=98=85=E4=BA=8B=E4=BB=B6=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?XTS=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 15829070344 Change-Id: I09a193c5ac24dbf6689aad6bd0e96d986854235c --- .../main/ets/Application/MyAbilityStage.ts | 2 +- .../src/main/ets/MainAbility/MainAbility.ts | 2 +- .../ets/TestRunner/OpenHarmonyTestRunner.ts | 6 + .../entry/src/main/ets/test/List.test.ets | 4 +- .../main/ets/test/requestDownload.test.ets | 637 ++++++++-- .../src/main/ets/test/requestUpload.test.ets | 104 +- request/RequestTest_ets/Test.json | 2 - .../ets/TestRunner/OpenHarmonyTestRunner.ts | 12 +- .../main/ets/test/requestDownload.test.ets | 1107 +++++++---------- .../src/main/ets/test/requestUpload.test.ets | 83 +- 10 files changed, 1160 insertions(+), 799 deletions(-) diff --git a/request/RequestTest_Stage/entry/src/main/ets/Application/MyAbilityStage.ts b/request/RequestTest_Stage/entry/src/main/ets/Application/MyAbilityStage.ts index 63c0efb17..4bea34b35 100644 --- a/request/RequestTest_Stage/entry/src/main/ets/Application/MyAbilityStage.ts +++ b/request/RequestTest_Stage/entry/src/main/ets/Application/MyAbilityStage.ts @@ -1,5 +1,5 @@ import hilog from '@ohos.hilog'; -import AbilityStage from "@ohos.app.ability.AbilityStage" +import AbilityStage from "@ohos.application.AbilityStage" export default class MyAbilityStage extends AbilityStage { onCreate() { diff --git a/request/RequestTest_Stage/entry/src/main/ets/MainAbility/MainAbility.ts b/request/RequestTest_Stage/entry/src/main/ets/MainAbility/MainAbility.ts index ef31b9080..ad865b2b2 100644 --- a/request/RequestTest_Stage/entry/src/main/ets/MainAbility/MainAbility.ts +++ b/request/RequestTest_Stage/entry/src/main/ets/MainAbility/MainAbility.ts @@ -2,7 +2,7 @@ import hilog from '@ohos.hilog'; import Window from '@ohos.window'; import { Hypium } from '@ohos/hypium'; import testsuite from '../test/List.test'; -import Ability from '@ohos.app.ability.UIAbility'; +import Ability from '@ohos.application.Ability'; import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'; export default class MainAbility extends Ability { diff --git a/request/RequestTest_Stage/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts b/request/RequestTest_Stage/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts index 1b7461ea5..c085dc5e0 100644 --- a/request/RequestTest_Stage/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts +++ b/request/RequestTest_Stage/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts @@ -59,6 +59,12 @@ export default class OpenHarmonyTestRunner implements TestRunner { } hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); hilog.info(0x0000, 'testTag', 'cmd : %{public}s', cmd); + abilityDelegator.executeShellCommand("echo \"123456\" > /data/app/el2/100/base/com.acts.requesttest.test/haps/entry_test/cache/test.txt", + (err: any, d: any) => { + console.info('executeShellCommand : err : ' + JSON.stringify(err)); + console.info('executeShellCommand : data : ' + d.stdResult); + console.info('executeShellCommand : data : ' + d.exitCode); + }) abilityDelegator.executeShellCommand(cmd, (err: any, d: any) => { hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); diff --git a/request/RequestTest_Stage/entry/src/main/ets/test/List.test.ets b/request/RequestTest_Stage/entry/src/main/ets/test/List.test.ets index 7011a1bda..c4e084fa5 100644 --- a/request/RequestTest_Stage/entry/src/main/ets/test/List.test.ets +++ b/request/RequestTest_Stage/entry/src/main/ets/test/List.test.ets @@ -16,7 +16,7 @@ import requestUploadJSUnit from './requestUpload.test'; import requestDownloadJSUnit from './requestDownload.test'; -export default function testsuite() { - requestUploadJSUnit() +export default function testsuite() { requestDownloadJSUnit() + requestUploadJSUnit() } \ No newline at end of file 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 efc79063e..29a381471 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,19 +50,6 @@ export default function requestDownloadJSUnit() { }); let downloadTask; - let downloadConfig = { - url: 'http://download.ci.openharmony.cn/version/Daily_Version/', - header: { - headers: 'http' - }, - enableMetered: false, - enableRoaming: false, - description: 'XTS download test!', - networkType: request.NETWORK_WIFI, - filePath: 'internal://cache/test.txt', - title: 'XTS download test!', - background: true - } /** * @tc.number SUB_REQUEST_DOWNLOAD_STAGE_API_CALLBACK_0001 @@ -73,22 +60,32 @@ export default function requestDownloadJSUnit() { */ it('SUB_REQUEST_DOWNLOAD_STAGE_API_CALLBACK_0001', 0, async function (done) { console.info("====>------------------SUB_REQUEST_DOWNLOAD_STAGE_API_CALLBACK_0001 is starting-----------------------"); - let abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); - let context = abilityDelegator.getAppContext(); - try { - request.download(context, downloadConfig, (err, data)=>{ - downloadTask = data; - console.info("====>SUB_REQUEST_DOWNLOAD_STAGE_API_CALLBACK_0001 downloadTask: " + downloadTask); + 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.downloadFile(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); - }); - } catch (err) { - console.info("====>SUB_REQUEST_DOWNLOAD_STAGE_API_CALLBACK_0001 error: " + err); - expect().assertFail(); - } - setTimeout(()=>{ - console.info("====>------------------SUB_REQUEST_DOWNLOAD_STAGE_API_CALLBACK_0001 end-----------------------"); + await downloadTask.delete() + } catch (err) { + console.info("====>SUB_REQUEST_DOWNLOAD_STAGE_API_CALLBACK_0001 error: " + err); + } done(); - },5000) + }); }); @@ -101,20 +98,31 @@ export default function requestDownloadJSUnit() { */ it('SUB_REQUEST_DOWNLOAD_STAGE_API_PROMISE_0001', 0, async function (done) { console.info("====>------------------SUB_REQUEST_DOWNLOAD_STAGE_API_PROMISE_0001 is starting-----------------------"); - let abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); - let context = abilityDelegator.getAppContext(); - request.download(context, downloadConfig).then(data => { + 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.downloadFile(globalThis.abilityContext, downloadConfig).then(async (data) => { downloadTask = data; console.info("====>SUB_REQUEST_DOWNLOAD_STAGE_API_PROMISE_0001 downloadTask: " + downloadTask); - expect(true).assertEqual(downloadTask != undefined); + expect(true).assertEqual(downloadTask != undefined); + await downloadTask.delete() + done(); }).catch(err => { console.info("====>SUB_REQUEST_DOWNLOAD_STAGE_API_PROMISE_0001 error: " + err); - expect().assertFail(); - }) - setTimeout(()=>{ - console.info("====>------------------SUB_REQUEST_DOWNLOAD_STAGE_API_PROMISE_0001 end-----------------------"); done(); - },5000) + }) }); /** @@ -126,10 +134,10 @@ export default function requestDownloadJSUnit() { */ it('SUB_REQUEST_downloadFile_STAGE_API_CALLBACK_0001', 0, async function (done) { console.info("-----------------------SUB_REQUEST_downloadFile_STAGE_API_CALLBACK_0001 is starting-----------------------"); - let downloadFilePath = `${globalThis.abilityContext.tempDir}/test.txt` - console.debug("downloadFileConfig:" + `${globalThis.abilityContext.tempDir}/test.txt`) + let downloadFilePath = `${globalThis.abilityContext.tempDir}/SUB_REQUEST_downloadFile_STAGE_API_CALLBACK_0001.txt` + console.debug("====>downloadFileConfig:" + `${globalThis.abilityContext.tempDir}/SUB_REQUEST_downloadFile_STAGE_API_CALLBACK_0001.txt`) let downloadFileConfig = { - url: 'http://download.ci.openharmony.cn/version/Daily_Version/', + url: 'https://www.baidu.com/img/PCtm_d9c8750bed0b3c7d089fa7d55720d6cf.png', header: { headers: 'http' }, @@ -139,24 +147,20 @@ export default function requestDownloadJSUnit() { networkType: request.NETWORK_WIFI, filePath: downloadFilePath, title: 'XTS download test!', - background: true + background: false } - try { - request.downloadFile(globalThis.abilityContext, downloadFileConfig, (err, data)=>{ - downloadTask = data; - console.info("SUB_REQUEST_downloadFile_STAGE_API_CALLBACK_0001 downloadTask: " + downloadTask); - try{ - expect(true).assertEqual(downloadTask != undefined); - }catch(e){ - console.info("SUB_REQUEST_downloadFile_STAGE_API_CALLBACK_0001 except error: " + e); - } - }); - } catch (err) { - console.error("SUB_REQUEST_downloadFile_STAGE_API_CALLBACK_0001 error: " + err); - expect().assertFail(); - } - console.info("-----------------------SUB_REQUEST_downloadFile_STAGE_API_CALLBACK_0001 end-----------------------"); - done(); + request.downloadFile(globalThis.abilityContext, downloadFileConfig, async (err, data)=>{ + downloadTask = data; + console.info("====>SUB_REQUEST_downloadFile_STAGE_API_CALLBACK_0001 downloadTask: " + downloadTask); + try{ + expect(true).assertEqual(downloadTask != undefined); + await downloadTask.delete() + }catch(e){ + console.info("====>SUB_REQUEST_downloadFile_STAGE_API_CALLBACK_0001 except error: " + e); + } + console.info("-----------------------SUB_REQUEST_downloadFile_STAGE_API_CALLBACK_0001 end-----------------------"); + done(); + }); }); /** @@ -168,10 +172,10 @@ export default function requestDownloadJSUnit() { */ it('SUB_REQUEST_downloadFile_STAGE_API_PROMISE_0001', 0, async function (done) { console.info("-----------------------SUB_REQUEST_downloadFile_STAGE_API_PROMISE_0001 is starting-----------------------"); - let downloadFilePath = `${globalThis.abilityContext.tempDir}/test.txt` - console.debug("downloadFileConfig:" + `${globalThis.abilityContext.tempDir}/test.txt`) + let downloadFilePath = `${globalThis.abilityContext.tempDir}/SUB_REQUEST_downloadFile_STAGE_API_PROMISE_0001.txt` + console.debug("====>downloadFileConfig:" + `${globalThis.abilityContext.tempDir}/SUB_REQUEST_downloadFile_STAGE_API_PROMISE_0001.txt`) let downloadFileConfig = { - url: 'http://download.ci.openharmony.cn/version/Daily_Version/', + url: 'https://www.baidu.com/img/PCtm_d9c8750bed0b3c7d089fa7d55720d6cf.png', header: { headers: 'http' }, @@ -181,27 +185,516 @@ export default function requestDownloadJSUnit() { networkType: request.NETWORK_WIFI, filePath: downloadFilePath, title: 'XTS download test!', - background: true + background: false } try{ - request.downloadFile(globalThis.abilityContext, downloadFileConfig).then(data => { + request.downloadFile(globalThis.abilityContext, downloadFileConfig).then(async (data) => { downloadTask = data; - console.info("SUB_REQUEST_downloadFile_STAGE_API_PROMISE_0001 downloadTask: " + downloadTask); - try{ - expect(true).assertEqual(downloadTask != undefined); - }catch(e){ - console.info("SUB_REQUEST_downloadFile_STAGE_API_PROMISE_0001 except error: " + e); - } + console.info("====>SUB_REQUEST_downloadFile_STAGE_API_PROMISE_0001 downloadTask: " + downloadTask); + expect(true).assertEqual(downloadTask != undefined); + await downloadTask.delete() + done(); }).catch(err => { - console.error("SUB_REQUEST_downloadFile_STAGE_API_PROMISE_0001 error: " + err); - expect().assertFail(); + console.error("====>SUB_REQUEST_downloadFile_STAGE_API_PROMISE_0001 error: " + err); + done(); }) }catch(err){ - console.error("SUB_REQUEST_downloadFile_STAGE_API_PROMISE_0001 catch error: " + err); + console.error("====>SUB_REQUEST_downloadFile_STAGE_API_PROMISE_0001 catch error: " + err); + done(); + } + + }); + + /** + * @tc.number SUB_REQUEST_DOWNLOAD_API_DELETE_0001 + * @tc.desc Delete the download task. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_REQUEST_DOWNLOAD_API_DELETE_0001', 0, async function (done) { + console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_delete_0001 is starting-----------------------"); + let downloadFilePath = `${globalThis.abilityContext.tempDir}/SUB_REQUEST_DOWNLOAD_API_DELETE_0001.txt` + console.debug("====>downloadFileConfig:" + `${globalThis.abilityContext.tempDir}/SUB_REQUEST_DOWNLOAD_API_DELETE_0001.txt`) + let downloadFileConfig = { + 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.downloadFile(globalThis.abilityContext, downloadFileConfig, (err, data) => { + downloadTask = data; + console.info("====>SUB_REQUEST_DOWNLOAD_API_DELETE_0001 downloadTask: " + downloadTask); + try { + expect(downloadTask != undefined).assertEqual(true); + downloadTask.delete((err, data) => { + try{ + if (err) { + console.error('====>SUB_REQUEST_DOWNLOAD_API_DELETE_0001 Failed to delete the download task.'); + expect().assertFail(); + } + console.info('====>SUB_REQUEST_DOWNLOAD_API_DELETE_0001 Download task delete success.'); + expect(typeof data == "boolean").assertTrue(); + }catch(err){ + console.error('====>SUB_REQUEST_DOWNLOAD_API_DELETE_0001 delete throw error' + err); + } + done(); + }); + } catch (error) { + console.error('====>SUB_REQUEST_DOWNLOAD_API_DELETE_0001 delete catch error' + error); + done(); + } + }) + }); + + /** + * @tc.number SUB_REQUEST_DOWNLOAD_API_DELETE_0002 + * @tc.desc Delete the download task. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_REQUEST_DOWNLOAD_API_DELETE_0002', 0, async function (done) { + console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_DELETE_0002 is starting-----------------------"); + let downloadFilePath = `${globalThis.abilityContext.tempDir}/SUB_REQUEST_DOWNLOAD_API_DELETE_0002.txt` + console.debug("====>downloadFileConfig:" + `${globalThis.abilityContext.tempDir}/SUB_REQUEST_DOWNLOAD_API_DELETE_0002.txt`) + let downloadFileConfig = { + 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.downloadFile(globalThis.abilityContext, downloadFileConfig, (err, data) => { + downloadTask = data; + console.info("====>SUB_REQUEST_DOWNLOAD_API_DELETE_0002 downloadTask: " + downloadTask); + try { + expect(downloadTask != undefined).assertEqual(true); + downloadTask.delete().then(data => { + console.info('====>SUB_REQUEST_DOWNLOAD_API_DELETE_0002 Download task delete success.'); + expect(data).assertEqual(true); + console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_DELETE_0002 end-----------------------"); + done(); + }).catch((err) => { + console.info('====>SUB_REQUEST_DOWNLOAD_API_DELETE_0002 Failed to delete the download task.'); + expect().assertFail(); + done(); + }) + } catch (error) { + console.error('====>SUB_REQUEST_DOWNLOAD_API_DELETE_0002 delete catch error'); + done(); + } + }) + }); + + /** + * @tc.number SUB_REQUEST_DOWNLOAD_API_SUSPEND_0001 + * @tc.desc Suspend the download task + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_REQUEST_DOWNLOAD_API_SUSPEND_0001', 0, async function (done) { + console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_SUSPEND_0001 is starting-----------------------"); + let downloadFilePath = `${globalThis.abilityContext.tempDir}/SUB_REQUEST_DOWNLOAD_API_SUSPEND_0001.txt` + console.debug("====>downloadFileConfig:" + `${globalThis.abilityContext.tempDir}/SUB_REQUEST_DOWNLOAD_API_SUSPEND_0001.txt`) + let downloadFileConfig = { + 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.downloadFile(globalThis.abilityContext, downloadFileConfig, (err, data) => { + downloadTask = data; + console.info("====>SUB_REQUEST_DOWNLOAD_API_SUSPEND_0001 downloadTask: " + downloadTask); + try{ + expect(downloadTask != undefined).assertEqual(true); + downloadTask.suspend((err, data) => { + try{ + if (err) { + console.error('====>SUB_REQUEST_DOWNLOAD_API_SUSPEND_0001 Failed to suspend the download task.'); + expect().assertFail(); + } + console.info('====>SUB_REQUEST_DOWNLOAD_API_SUSPEND_0001 Download task suspend success.'); + expect(data == true).assertTrue(); + }catch(err){ + console.error("====>SUB_REQUEST_DOWNLOAD_API_SUSPEND_0001 throw_error: " + JSON.stringify(err)); + } + done(); + }); + }catch(err){ + console.error('====>SUB_REQUEST_DOWNLOAD_API_SUSPEND_0001 suspend catch error' + JSON.stringify(err)); + done(); + } + }) + + }); + + /** + * @tc.number SUB_REQUEST_DOWNLOAD_API_SUSPEND_0002 + * @tc.desc Suspend the download task + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_REQUEST_DOWNLOAD_API_SUSPEND_0002', 0, async function (done) { + console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_SUSPEND_0002 is starting-----------------------"); + let downloadFilePath = `${globalThis.abilityContext.tempDir}/SUB_REQUEST_DOWNLOAD_API_SUSPEND_0002.txt` + console.debug("====>downloadFileConfig:" + `${globalThis.abilityContext.tempDir}/SUB_REQUEST_DOWNLOAD_API_SUSPEND_0002.txt`) + let downloadFileConfig = { + 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 } - console.info("-----------------------SUB_REQUEST_downloadFile_STAGE_API_PROMISE_0001 end-----------------------"); - done(); + request.downloadFile(globalThis.abilityContext, downloadFileConfig, (err, data) => { + downloadTask = data; + console.info("====>SUB_REQUEST_DOWNLOAD_API_SUSPEND_0002 downloadTask: " + downloadTask); + try{ + expect(downloadTask != undefined).assertEqual(true); + downloadTask.suspend().then(data => { + console.info('====>SUB_REQUEST_DOWNLOAD_API_SUSPEND_0002 Download task suspend success.'); + expect(data == true).assertTrue(); + done(); + }).catch((err) => { + console.info('====>SUB_REQUEST_DOWNLOAD_API_SUSPEND_0002 throw_err:' + JSON.stringify(err)); + done(); + }) + }catch(err){ + console.error('====>SUB_REQUEST_DOWNLOAD_API_SUSPEND_0002 suspend catch error' + JSON.stringify(err)); + done(); + } + }) }); + /** + * @tc.number SUB_REQUEST_DOWNLOAD_API_RESTORE_0001 + * @tc.desc Restore the download task + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_REQUEST_DOWNLOAD_API_RESTORE_0001', 0, async function (done) { + console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_RESTORE_0001 is starting-----------------------"); + let downloadFilePath = `${globalThis.abilityContext.tempDir}/SUB_REQUEST_DOWNLOAD_API_RESTORE_0001.txt` + console.debug("====>downloadFileConfig:" + `${globalThis.abilityContext.tempDir}/SUB_REQUEST_DOWNLOAD_API_RESTORE_0001.txt`) + let downloadFileConfig = { + 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.downloadFile(globalThis.abilityContext, downloadFileConfig, (err, data) => { + downloadTask = data; + console.info("====>SUB_REQUEST_DOWNLOAD_API_RESTORE_0001 downloadTask: " + downloadTask); + try{ + expect(downloadTask != undefined).assertEqual(true); + downloadTask.restore((err, data) => { + try{ + if (err) { + console.error('====>SUB_REQUEST_DOWNLOAD_API_RESTORE_0001 Failed to restore the download task.'); + expect().assertFail(); + } + console.info('====>SUB_REQUEST_DOWNLOAD_API_RESTORE_0001 Download restore success.'); + expect(data == true).assertTrue(); + }catch(err){ + console.info('====>SUB_REQUEST_DOWNLOAD_API_RESTORE_0001 throw_err:' + JSON.stringify(err)); + } + done(); + }); + }catch(err){ + console.error('====>SUB_REQUEST_DOWNLOAD_API_RESTORE_0001 restore catch error' + JSON.stringify(err)); + done(); + } + }); + }); + + /** + * @tc.number SUB_REQUEST_DOWNLOAD_API_RESTORE_0002 + * @tc.desc Restore the download task + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_REQUEST_DOWNLOAD_API_RESTORE_0002', 0, async function (done) { + console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_RESTORE_0002 is starting-----------------------"); + let downloadFilePath = `${globalThis.abilityContext.tempDir}/SUB_REQUEST_DOWNLOAD_API_RESTORE_0002.txt` + console.debug("====>downloadFileConfig:" + `${globalThis.abilityContext.tempDir}/SUB_REQUEST_DOWNLOAD_API_RESTORE_0002.txt`) + let downloadFileConfig = { + 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.downloadFile(globalThis.abilityContext, downloadFileConfig, (err, data) => { + downloadTask = data; + console.info("====>SUB_REQUEST_DOWNLOAD_API_RESTORE_0002 downloadTask: " + downloadTask); + try{ + expect(downloadTask != undefined).assertEqual(true); + downloadTask.restore().then(data => { + console.info('====>SUB_REQUEST_DOWNLOAD_API_RESTORE_0002 Download task restore.'); + expect(data == true).assertTrue(); + done(); + }).catch((err) => { + console.info('====>SUB_REQUEST_DOWNLOAD_API_RESTORE_0002 Failed to restore the download task.'); + done(); + }); + }catch(err){ + console.error('====>SUB_REQUEST_DOWNLOAD_API_RESTORE_0002 restore catch error' +JSON.stringify(err)); + done(); + } + }); + }); + + /** + * @tc.number SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0001 + * @tc.desc Get the download task info + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0001', 0, async function (done) { + console.info("====>---------------------SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0001 is starting---------------------"); + let downloadFilePath = `${globalThis.abilityContext.tempDir}/SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0001.txt` + console.debug("====>downloadFileConfig:" + `${globalThis.abilityContext.tempDir}/SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0001.txt`) + let downloadFileConfig = { + 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.downloadFile(globalThis.abilityContext, downloadFileConfig, (err, data) => { + downloadTask = data; + console.info("====>SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0001 downloadTask: " + downloadTask); + try{ + expect(downloadTask != undefined).assertEqual(true); + downloadTask.getTaskInfo((err, data) => { + try{ + if (err) { + console.error('====>SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0001 Failed to getTaskInfo the download task.'); + expect().assertFail(); + } + console.info('====>SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0001 Download getTaskInfo success.'); + expect(typeof data == "object").assertTrue(); + }catch(err){ + console.error('====>SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0001 throw_error' +JSON.stringify(err)); + } + done(); + }); + }catch(err){ + console.error('====>SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0001 getTaskInfo catch error' + JSON.stringify(err)); + done(); + } + }); + }); + + /** + * @tc.number SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0002 + * @tc.desc Get the download task info + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0002', 0, async function (done) { + console.info("====>-------------------SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0002 is starting----------------------"); + let downloadFilePath = `${globalThis.abilityContext.tempDir}/SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0002.txt` + console.debug("====>downloadFileConfig:" + `${globalThis.abilityContext.tempDir}/SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0002.txt`) + let downloadFileConfig = { + 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.downloadFile(globalThis.abilityContext, downloadFileConfig, (err, data) => { + downloadTask = data; + console.info("====>SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0002 downloadTask: " + downloadTask); + try{ + expect(downloadTask != undefined).assertEqual(true); + downloadTask.getTaskInfo().then(data => { + console.info('====>SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0002 Download task getTaskInfo success.'); + expect(typeof data == "object").assertTrue(); + done(); + }).catch((err) => { + console.error('====>SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0002 Failed to getTaskInfo the download task.'); + done(); + }); + }catch(err){ + console.error('====>SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0002 getTaskInfo catch error' + JSON.stringify(err)); + done(); + } + }); + }); + + /** + * @tc.number SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0001 + * @tc.desc Get mimetype of the download task + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0001', 0, async function (done) { + console.info("====>---------------------SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0001 is starting---------------------"); + let downloadFilePath = `${globalThis.abilityContext.tempDir}/SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0001.txt` + console.debug("====>downloadFileConfig:" + `${globalThis.abilityContext.tempDir}/SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0001.txt`) + let downloadFileConfig = { + 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.downloadFile(globalThis.abilityContext, downloadFileConfig, (err, data) => { + downloadTask = data; + console.info("====>SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0001 downloadTask: " + downloadTask); + try{ + expect(downloadTask != undefined).assertEqual(true); + downloadTask.on('progress',(data1, data2) => { + try{ + if (data1 > 0){ + downloadTask.getTaskMimeType(async (err, data)=>{ + try{ + if(err) { + console.error('====>SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0001 err:'+ JSON.stringify(err)); + expect().assertFail(); + done(); + } + if (data) { + console.info('====>SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0001 data:' + JSON.stringify(data)); + expect(typeof data == "string").assertTrue(); + } else { + console.error("====>SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0001 error: " + JSON.stringify(err)); + expect().assertFail(); + } + }catch(err){ + console.error("====>SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0001 throw_error: " + JSON.stringify(err)); + } + setTimeout(()=>{ + done(); + },1000) + }); + } + }catch(err){ + console.error("====>SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0001 error: " + JSON.stringify(err)); + done(); + } + }) + }catch(err){ + console.error("====>SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0001 error: " + JSON.stringify(err)); + done(); + } + }) + }); + + /** + * @tc.number SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0002 + * @tc.desc Get mimetype of the download task + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0002', 0, async function (done) { + console.info("====>-------------------SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0002 is starting----------------------"); + let downloadFilePath = `${globalThis.abilityContext.tempDir}/SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0002.txt` + console.debug("====>downloadFileConfig:" + `${globalThis.abilityContext.tempDir}/SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0002.txt`) + let downloadFileConfig = { + 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.downloadFile(globalThis.abilityContext, downloadFileConfig, async (err, data) => { + downloadTask = data; + console.info("====>SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0002 downloadTask: " + downloadTask); + try{ + expect(downloadTask != undefined).assertEqual(true); + downloadTask.on('progress', async (data1, data2) => { + try{ + if(data1 > 0){ + let data = await downloadTask.getTaskMimeType() + console.info('====>SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0002 data:' + JSON.stringify(data)); + expect(typeof data == "string").assertTrue(); + } + setTimeout(()=>{ + done(); + },1000) + }catch(err){ + console.error("====>SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0002 throw_error: " + JSON.stringify(err)); + done(); + } + }) + }catch(err){ + console.error("====>SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0002 error: " + JSON.stringify(err)); + done(); + } + }) + }); }); } \ No newline at end of file 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 e46c71d25..2dd93f246 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 @@ -114,7 +114,6 @@ export default function requestUploadJSUnit() { }); } catch (err) { console.info("====>SUB_REQUEST_UPLOAD_STAGE_API_CALLBACK_0001 error: " + err); - expect().assertFail(); } setTimeout(()=>{ console.info("====>------------------SUB_REQUEST_UPLOAD_STAGE_API_CALLBACK_0001 end-----------------------"); @@ -157,7 +156,6 @@ export default function requestUploadJSUnit() { }); } catch (e) { console.info("====>SUB_REQUEST_UPLOAD_STAGE_API_PROMISE_0001 error: " + JSON.stringify(e)); - expect(e).assertFail(); } setTimeout(()=>{ console.info("====>------------------SUB_REQUEST_UPLOAD_STAGE_API_PROMISE_0001 end-----------------------"); @@ -245,19 +243,28 @@ export default function requestUploadJSUnit() { expect(true).assertEqual((uploadTask != undefined) || (uploadTask != "") || (uploadTask != {})); uploadTask.off('complete', () => { - console.info("====>SUB_REQUEST_UPLOAD_API_PROMISE_0003 TaskState success"); - expect(true).assertEqual(true); + 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', () => { - console.info("====>SUB_REQUEST_UPLOAD_API_PROMISE_0003 TaskState success"); - expect(true).assertEqual(true); + 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)); @@ -281,16 +288,15 @@ export default function requestUploadJSUnit() { try { request.uploadFile(globalThis.abilityContext, uploadConfig, (err, data)=>{ uploadTask = data; - console.info("SUB_REQUEST_uploadFile_STAGE_API_CALLBACK_0001 uploadFile: " + uploadTask); + console.info("====>SUB_REQUEST_uploadFile_STAGE_API_CALLBACK_0001 uploadFile: " + uploadTask); try{ expect(true).assertEqual(uploadTask != undefined); }catch(e){ - console.info("SUB_REQUEST_uploadFile_STAGE_API_CALLBACK_0001 except error: " + e); + console.info("====>SUB_REQUEST_uploadFile_STAGE_API_CALLBACK_0001 except error: " + e); } }); } catch (err) { - console.error("SUB_REQUEST_uploadFile_STAGE_API_CALLBACK_0001 error: " + err); - expect().assertFail(); + console.error("====>SUB_REQUEST_uploadFile_STAGE_API_CALLBACK_0001 error: " + err); }; setTimeout(()=>{ console.info("-----------------------SUB_REQUEST_uploadFile_STAGE_API_CALLBACK_0001 end-----------------------"); @@ -310,18 +316,18 @@ export default function requestUploadJSUnit() { try{ request.uploadFile(globalThis.abilityContext, uploadConfig).then(data => { uploadTask = data; - console.info("SUB_REQUEST_uploadFile_STAGE_API_PROMISE_0001 uploadFile: " + uploadTask); + console.info("====>SUB_REQUEST_uploadFile_STAGE_API_PROMISE_0001 uploadFile: " + uploadTask); try{ expect(true).assertEqual(uploadTask != undefined); }catch(e){ - console.info("SUB_REQUEST_uploadFile_STAGE_API_PROMISE_0001 except error: " + e); + console.info("====>SUB_REQUEST_uploadFile_STAGE_API_PROMISE_0001 except error: " + e); } }).catch(err => { - console.error("SUB_REQUEST_uploadFile_STAGE_API_PROMISE_0001 error: " + err); + console.error("====>SUB_REQUEST_uploadFile_STAGE_API_PROMISE_0001 error: " + err); expect().assertFail(); }) }catch(err){ - console.error("SUB_REQUEST_uploadFile_STAGE_API_PROMISE_0001 catch error: " + err); + console.error("====>SUB_REQUEST_uploadFile_STAGE_API_PROMISE_0001 catch error: " + err); } setTimeout(()=>{ console.info("-----------------------SUB_REQUEST_uploadFile_STAGE_API_PROMISE_0001 end-----------------------"); @@ -329,5 +335,71 @@ export default function requestUploadJSUnit() { }, 10000); }); + /** + * @tc.number SUB_REQUEST_UPLOAD_API_DELETE_0001 + * @tc.desc Delete the upload task. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_REQUEST_UPLOAD_API_DELETE_0001', 0, async function (done) { + console.info("====>-----------------------SUB_REQUEST_UPLOAD_API_DELETE_0001 is starting-----------------------"); + request.uploadFile(globalThis.abilityContext, uploadConfig, (err, data) => { + try{ + uploadTask = data; + console.info("====>SUB_REQUEST_UPLOAD_API_DELETE_0001 uploadTask: " + uploadTask); + expect(uploadTask != undefined).assertEqual(true); + uploadTask.delete((err, data) => { + try{ + if (err) { + console.error('====>SUB_REQUEST_UPLOAD_API_DELETE_0001 Failed to delete the uploadTask task.'); + expect().assertFail(); + done(); + } + console.info('====>SUB_REQUEST_UPLOAD_API_DELETE_0001 uploadTask task delete success.'); + expect(typeof data == "boolean").assertTrue(); + console.info("====>-----------------------SUB_REQUEST_UPLOAD_API_DELETE_0001 end-----------------------"); + done(); + }catch(err){ + console.error('====>SUB_REQUEST_UPLOAD_API_DELETE_0001 delete error' + err); + done(); + } + }); + } catch (error) { + console.error('====>SUB_REQUEST_UPLOAD_API_DELETE_0001 delete catch error' + error); + done(); + } + }) + }); + + /** + * @tc.number SUB_REQUEST_UPLOAD_API_DELETE_0002 + * @tc.desc Delete the upload task. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_REQUEST_UPLOAD_API_DELETE_0002', 0, async function (done) { + console.info("====>-----------------------SUB_REQUEST_UPLOAD_API_DELETE_0002 is starting-----------------------"); + request.uploadFile(globalThis.abilityContext, uploadConfig, (err, data) => { + uploadTask = data; + console.info("====>SUB_REQUEST_UPLOAD_API_DELETE_0002 uploadTask: " + uploadTask); + try{ + expect(uploadTask != undefined).assertEqual(true); + uploadTask.delete().then(data => { + console.info('====>SUB_REQUEST_UPLOAD_API_DELETE_0002 delete data:' + JSON.stringify(data)); + expect(data).assertEqual(true); + done(); + }).catch((err) => { + console.info('====>SUB_REQUEST_UPLOAD_API_DELETE_0002 Failed to delete the uploadTask task.'); + expect().assertFail(); + done(); + }) + }catch(err){ + console.error('====>SUB_REQUEST_UPLOAD_API_DELETE_0002 delete catch err'); + done(); + } + }) + }); }) } diff --git a/request/RequestTest_ets/Test.json b/request/RequestTest_ets/Test.json index d987eb48c..9a3c20b26 100644 --- a/request/RequestTest_ets/Test.json +++ b/request/RequestTest_ets/Test.json @@ -16,8 +16,6 @@ { "type": "ShellKit", "run-command": [ - "mkdir -p /data/app/el2/100/base/com.acts.requesttest/haps/entry/cache", - "echo \"123456\" > /data/app/el2/100/base/com.acts.requesttest/haps/entry/cache/test.txt" ] } ] diff --git a/request/RequestTest_ets/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts b/request/RequestTest_ets/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts index 07cb0b784..c814bb927 100644 --- a/request/RequestTest_ets/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts +++ b/request/RequestTest_ets/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts @@ -54,15 +54,21 @@ export default class OpenHarmonyTestRunner implements TestRunner { console.log('OpenHarmonyTestRunner onRun run') abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() - + let lMonitor = { abilityName: testAbilityName, onAbilityCreate: onAbilityCreateCallback, }; var testAbilityName = abilityDelegatorArguments.parameters['-p'] + '.MainAbility' - abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback) + abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback) + abilityDelegator.executeShellCommand("echo 123456 > /data/app/el2/100/base/com.acts.requesttest/haps/entry/cache/test.txt", + (err: any, d: any) => { + console.info('executeShellCommand : err : ' + JSON.stringify(err)); + console.info('executeShellCommand : data : ' + d.stdResult); + console.info('executeShellCommand : data : ' + d.exitCode); + }) var cmd = 'aa start -d 0 -a ' + testAbilityName + ' -b ' + abilityDelegatorArguments.bundleName - cmd += ' '+translateParamsToString(abilityDelegatorArguments.parameters) + cmd += ' '+translateParamsToString(abilityDelegatorArguments.parameters) console.info('cmd : '+cmd) abilityDelegator.executeShellCommand(cmd, (err: any, d: any) => { diff --git a/request/RequestTest_ets/entry/src/main/ets/test/requestDownload.test.ets b/request/RequestTest_ets/entry/src/main/ets/test/requestDownload.test.ets index bb1a5b8b3..8ed3a9558 100644 --- a/request/RequestTest_ets/entry/src/main/ets/test/requestDownload.test.ets +++ b/request/RequestTest_ets/entry/src/main/ets/test/requestDownload.test.ets @@ -14,6 +14,7 @@ */ import request from "@ohos.request"; +import featureAbility from '@ohos.ability.featureAbility' import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'; import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "hypium/index"; @@ -24,15 +25,16 @@ export default function requestDownloadJSUnit() { /** * beforeAll: Prerequisites at the test suite level, which are executed before the test suite is executed. */ - beforeAll(function () { + beforeAll(async function () { console.info('====>beforeAll: Prerequisites are executed.'); }); /** * beforeEach: Prerequisites at the test case level, which are executed before each test case is executed. */ - beforeEach(function () { - console.info('====>beforeEach: Prerequisites is executed.'); + beforeEach(async function () { + console.info('====>beforeEach: Prerequisites is executed.'); + await setDownLoadConfig() }); /** @@ -50,63 +52,23 @@ export default function requestDownloadJSUnit() { }); let downloadTask; - let downloadConfig = { - url: 'http://127.0.0.1', - header: { - headers: 'http' - }, - enableMetered: false, - enableRoaming: false, - description: 'XTS download test!', - networkType: request.NETWORK_WIFI, - filePath: 'test.txt', - title: 'XTS download test!', - background: true - } - - /** - * @tc.number SUB_REQUEST_DOWNLOAD_API_CALLBACK_0001 - * @tc.desc Starts a download session. - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_REQUEST_DOWNLOAD_API_CALLBACK_0001', 0, async function (done) { - console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_CALLBACK_0001 is starting-----------------------"); - try { - request.download(downloadConfig, (data)=>{ - downloadTask = data; - console.info("====>SUB_REQUEST_DOWNLOAD_API_CALLBACK_0001 downloadTask: " + downloadTask); - expect(downloadTask != undefined).assertEqual(true); - }); - } catch (err) { - console.error("SUB_REQUEST_DOWNLOAD_API_CALLBACK_0001 error: " + err); - expect().assertFail(); + let downloadConfig + async function setDownLoadConfig(){ + let downloadFilePath = await featureAbility.getContext().getFilesDir() + 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 } - console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_CALLBACK_0001 end-----------------------"); - done(); - }); - - /** - * @tc.number SUB_REQUEST_DOWNLOAD_API_PROMISE_0001 - * @tc.desc Starts a download session. - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_REQUEST_DOWNLOAD_API_PROMISE_0001', 0, async function (done) { - console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_PROMISE_0001 is starting-----------------------"); - request.download(downloadConfig).then(data => { - downloadTask = data; - console.info("====>SUB_REQUEST_DOWNLOAD_API_PROMISE_0001 downloadTask: " + downloadTask); - expect(downloadTask != undefined).assertEqual(true); - }).catch(err => { - console.error("SUB_REQUEST_DOWNLOAD_API_PROMISE_0001 error: " + err); - expect().assertFail(); - }) - console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_PROMISE_0001 end-----------------------"); - done(); - }); + } /** * @tc.number SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0001 @@ -117,20 +79,31 @@ export default function requestDownloadJSUnit() { */ it('SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0001', 0, async function (done) { console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0001 is starting-----------------------"); - request.download( downloadConfig, (data)=>{ - downloadTask = data; - console.info("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0001 downloadTask: " + downloadTask); - expect(true).assertEqual(downloadTask != undefined); - downloadTask.on('progress', (data1, data2) => { - console.info("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0001 on data1 =" + data1); - console.info("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0001 on data2 =" + data2); - expect(true).assertEqual(data1 != undefined); - expect(true).assertEqual(data2 != undefined); - }); - }); - - console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0001 end-----------------------"); - done(); + downloadConfig.filePath += 'SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0001.txt' + request.download(downloadConfig, (err, data)=>{ + try{ + downloadTask = data; + console.info("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0001 downloadTask: " + JSON.stringify(downloadTask) ); + expect(true).assertEqual(downloadTask != undefined); + downloadTask.on('progress', (data1, data2) => { + try{ + console.info("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0001 on data1 =" + data1); + console.info("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0001 on data2 =" + data2); + expect(true).assertEqual(data1 != undefined); + expect(true).assertEqual(data2 != undefined); + if (data1 == data2){ + done(); + } + }catch(err){ + console.error("====>SUB_REQUEST_DOWNLOAD_API_PROMISE_0001 throw_error: " + err); + done(); + } + }); + }catch(err){ + console.error("====>SUB_REQUEST_DOWNLOAD_API_PROMISE_0001 error: " + err); + done(); + } + }); }); /** @@ -142,21 +115,27 @@ export default function requestDownloadJSUnit() { */ it('SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0002', 0, async function (done) { console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0002 is starting-----------------------"); - request.download( downloadConfig, (data)=>{ + downloadConfig.filePath += 'SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0002.txt' + request.download(downloadConfig, (err, data)=>{ downloadTask = data; console.info("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0002 downloadTask: " + downloadTask); try{ expect(true).assertEqual(downloadTask != undefined); - downloadTask.on('complete', () => { - console.info('====>SUB_REQUEST_DOWNLOAD_API_CALLBACK_0002 task completed.') + downloadTask.on('complete', async () => { + try{ + console.info('====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0002 task completed.') + expect(true).assertTrue(); + }catch(err){ + console.error("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0002 throw_error: " + err); + } + await downloadTask.remove() + done(); }); }catch(err){ - console.error("SUB_REQUEST_DOWNLOAD_API_CALLBACK_0002 error: " + err); - expect().assertFail(); - } + console.error("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0002 error: " + err); + done(); + } }); - console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0002 end-----------------------"); - done(); }); /** @@ -168,21 +147,32 @@ export default function requestDownloadJSUnit() { */ it('SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0003', 0, async function (done) { console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0003 is starting-----------------------"); - request.download( downloadConfig, (data)=>{ + downloadConfig.filePath += 'SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0003.txt' + request.download(downloadConfig, (err, data)=>{ downloadTask = data; console.info("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0003 downloadTask: " + downloadTask); try{ expect(true).assertEqual(downloadTask != undefined); - downloadTask.on('pause', () => { - console.info('====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0003 task pause.') + downloadTask.on('pause', async () => { + try{ + console.info('====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0003 task completed.') + expect(true).assertTrue(); + }catch(err){ + console.error("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0003 throw_error: " + err); + } + await downloadTask.remove() + done(); }); + downloadTask.on('progress', (data1, data2) => { + if(data1 > 0){ + downloadTask.pause() + } + }); }catch(err){ - console.error("SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0003 error: " + err); - expect().assertFail(); + console.error("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0003 error: " + err); + done(); } - }); - console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0003 end-----------------------"); - done(); + }); }); /** @@ -194,22 +184,31 @@ export default function requestDownloadJSUnit() { */ it('SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0004', 0, async function (done) { console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0004 is starting-----------------------"); - request.download( downloadConfig, (data)=>{ + downloadConfig.filePath += 'SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0004.txt' + request.download(downloadConfig, (err, data)=>{ downloadTask = data; - console.info("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0004 downloadTask: " + downloadTask); - + console.info("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0004 downloadTask: " + downloadTask); try{ expect(downloadTask != undefined).assertEqual(true); downloadTask.on('remove', () => { - console.info('====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0004 task remove.') + try{ + console.info('====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0004 remove completed') + expect(true).assertTrue(); + }catch(err){ + console.error("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0004 throw_error: " + err); + } + done(); }); + downloadTask.on('progress', (data1, data2) => { + if(data1 > 0){ + downloadTask.remove() + } + }); }catch(err){ - console.error("SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0004 error: " + err); - expect().assertFail(); + console.error("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0004 error: " + err); + done(); } - }); - console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0004 end-----------------------"); - done(); + }); }); /** @@ -221,21 +220,61 @@ export default function requestDownloadJSUnit() { */ it('SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0005', 0, async function (done) { console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0005 is starting-----------------------"); - request.download( downloadConfig, (data)=>{ + downloadConfig.filePath += 'SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0005.txt' + downloadConfig.url += 'xxxxxxxxxx' + request.download(downloadConfig, (err, data)=>{ downloadTask = data; - console.info("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0005 downloadTask: " + downloadTask); - expect(downloadTask != undefined).assertEqual(true); + console.info("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0005 downloadTask: " + downloadTask); try{ - downloadTask.on('remove', () => { - console.info('====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0005 task remove.') + expect(downloadTask != undefined).assertEqual(true); + downloadTask.on('fail', async()=>{ + try{ + console.info('====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0005 fail completed') + expect(true).assertTrue(); + }catch(err){ + console.error("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0005 throw_error: " + err); + } + await downloadTask.remove() + done(); + }) + }catch(err){ + console.error("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0005 error: " + err); + done(); + } + }); + }); + + /** + * @tc.number SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0006 + * @tc.desc Called when the current download session fails. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0006', 0, async function (done) { + console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0006 is starting-----------------------"); + downloadConfig.filePath += 'SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0006.txt' + request.download(downloadConfig, (err, data)=>{ + downloadTask = data; + console.info("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0006 downloadTask: " + downloadTask); + try{ + expect(downloadTask != undefined).assertEqual(true); + downloadTask.on('complete', async () => { + try{ + request.download(downloadConfig, (err, data)=>{ + }) + }catch(err){ + console.error("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0006 second throw_error: " + err); + expect(err.code).assertEqual('13400002') + await downloadTask.remove() + done(); + } }); }catch(err){ - console.error("SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0005 error: " + err); - expect().assertFail(); + console.error("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0006 error: " + err); + done(); } - }); - console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0005 end-----------------------"); - done(); + }); }); /** @@ -247,19 +286,30 @@ export default function requestDownloadJSUnit() { */ it('SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0001', 0, async function (done) { console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0001 is starting-----------------------"); - request.download( downloadConfig, (data)=>{ - downloadTask = data; - console.info("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0001 downloadTask: " + downloadTask); - expect(downloadTask != undefined).assertEqual(true); - downloadTask.off('progress', (data1, data2) => { - console.info("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0001 on data1 =" + data1); - console.info("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0001 on data2 =" + data2); - expect(data1 != undefined).assertEqual(true); - expect(data2 != undefined).assertEqual(true); - }); + downloadConfig.filePath += 'SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0001.txt' + request.download(downloadConfig, (err, data)=>{ + try{ + downloadTask = data; + console.info("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0001 downloadTask: " + downloadTask); + expect(downloadTask != undefined).assertEqual(true); + downloadTask.on('progress', (data1, data2) => {}); + downloadTask.off('progress', async (data1, data2) => { + try{ + console.info("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0001 on data1 =" + data1); + console.info("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0001 on data2 =" + data2); + expect(data1).assertEqual(0); + expect(data2).assertEqual(0); + }catch(err){ + console.error("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0001 off_err: " + err); + } + await downloadTask.remove() + done(); + }); + }catch(err){ + console.error("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0001 error: " + err); + done(); + } }); - console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0001 end-----------------------"); - done(); }); /** @@ -271,21 +321,27 @@ export default function requestDownloadJSUnit() { */ it('SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0002', 0, async function (done) { console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0002 is starting-----------------------"); - request.download( downloadConfig, (data)=>{ + downloadConfig.filePath += 'SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0002.txt' + request.download(downloadConfig, (err, data)=>{ downloadTask = data; - console.info("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0002 downloadTask: " + downloadTask); - expect(downloadTask != undefined).assertEqual(true); + console.info("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0002 downloadTask: " + downloadTask); try{ - downloadTask.off('complete', () => { - console.info('====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0002 task complete.') + expect(downloadTask != undefined).assertEqual(true); + downloadTask.off('complete',async () => { + try{ + console.info('====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0002 task complete.') + expect(true).assertTrue(); + }catch(err){ + console.error("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0002 off_err: " + err); + } + await downloadTask.remove() + done(); }); }catch(err){ - console.error("SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0002 error: " + err); - expect().assertFail(); + console.error("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0002 error: " + err); + done(); } - }); - console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0002 end-----------------------"); - done(); + }); }); /** @@ -297,21 +353,27 @@ export default function requestDownloadJSUnit() { */ it('SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0003', 0, async function (done) { console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0003 is starting-----------------------"); - request.download( downloadConfig, (data)=>{ + downloadConfig.filePath += 'SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0003.txt' + request.download( downloadConfig, (err, data)=>{ downloadTask = data; - console.info("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0003 downloadTask: " + downloadTask); - expect(downloadTask != undefined).assertEqual(true); + console.info("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0003 downloadTask: " + downloadTask); try{ - downloadTask.off('pause', () => { - console.info('====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0003 task pause.') + expect(downloadTask != undefined).assertEqual(true); + downloadTask.off('pause', async () => { + try{ + console.info('====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0003 task complete.') + expect(true).assertTrue(); + }catch(err){ + console.error("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0003 off_err: " + err); + } + await downloadTask.remove() + done(); }); }catch(err){ - console.error("SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0003 error: " + err); - expect().assertFail(); + console.error("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0003 error: " + err); + done(); } }); - console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0002 end-----------------------"); - done(); }); /** @@ -323,21 +385,27 @@ export default function requestDownloadJSUnit() { */ it('SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0004', 0, async function (done) { console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0004 is starting-----------------------"); - request.download( downloadConfig, (data)=>{ + downloadConfig.filePath += 'SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0004.txt' + request.download( downloadConfig, (err, data)=>{ downloadTask = data; - console.info("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0004 downloadTask: " + downloadTask); - expect(downloadTask != undefined).assertEqual(true); + console.info("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0004 downloadTask: " + downloadTask); try{ - downloadTask.off('remove', () => { - console.info('====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0004 task remove.') + expect(downloadTask != undefined).assertEqual(true); + downloadTask.off('remove', async (data) => { + try{ + console.info('====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0003 remove data:' +JSON.stringify(data)) + expect(true).assertTrue(); + }catch(err){ + console.error("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0003 off_err: " + err); + } + await downloadTask.remove() + done(); }); }catch(err){ - console.error("SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0004 error: " + err); - expect().assertFail(); + console.error("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0004 error: " + err); + done(); } }); - console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0004 end-----------------------"); - done(); }); /** @@ -349,21 +417,29 @@ export default function requestDownloadJSUnit() { */ it('SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0005', 0, async function (done) { console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0005 is starting-----------------------"); - request.download( downloadConfig, (data)=>{ + downloadConfig.filePath += 'SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0005.txt' + request.download( downloadConfig, (err, data)=>{ downloadTask = data; console.info("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0005 downloadTask: " + downloadTask); - expect(downloadTask != undefined).assertEqual(true); try{ - downloadTask.off('pause', () => { - console.info('====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0005 task complete.') + expect(downloadTask != undefined).assertEqual(true); + downloadTask.on('fail', (data) => {}); + downloadTask.off('fail', async (data) => { + try{ + console.info('====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0005 fail_data:' + JSON.stringify(data)) + expect(data).assertEqual(0) + console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0005 end-----------------------"); + }catch(err){ + console.error("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0005 fail_error: " + err); + } + await downloadTask.remove() + done(); }); }catch(err){ - console.error("SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0005 error: " + err); - expect().assertFail(); - } + console.error("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0005 error: " + err); + done(); + } }); - console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0002 end-----------------------"); - done(); }); /** @@ -375,26 +451,35 @@ export default function requestDownloadJSUnit() { */ it('SUB_REQUEST_DOWNLOAD_API_REMOVE_0001', 0, async function (done) { console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_REMOVE_0001 is starting-----------------------"); - request.download( downloadConfig, (data)=>{ + downloadConfig.filePath += 'SUB_REQUEST_DOWNLOAD_API_REMOVE_0001.txt' + request.download( downloadConfig, (err, data)=>{ downloadTask = data; - console.info("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0005 downloadTask: " + downloadTask); - expect(downloadTask != undefined).assertEqual(true); - downloadTask.remove((err, data)=>{ - if(err) { - console.error('SUB_REQUEST_DOWNLOAD_API_REMOVE_0001 Failed to remove the download task.'); - expect().assertFail(); - } - if (data) { - console.info('====>SUB_REQUEST_DOWNLOAD_API_REMOVE_0001 Download task removed.'); - expect(data == true).assertTrue(); - } else { - console.error('SUB_REQUEST_DOWNLOAD_API_REMOVE_0001 Failed to remove the download task.'); - expect().assertFail(); - } - }); + console.info("====>SUB_REQUEST_DOWNLOAD_API_REMOVE_0001 downloadTask: " + downloadTask); + try{ + expect(downloadTask != undefined).assertEqual(true); + downloadTask.remove((err, data)=>{ + try{ + if(err) { + console.error('====>SUB_REQUEST_DOWNLOAD_API_REMOVE_0001 Failed to remove the download task.'); + expect().assertFail(); + } + if (data) { + console.info('====>SUB_REQUEST_DOWNLOAD_API_REMOVE_0001 removed data:' + JSON.stringify(data)); + expect(data == true).assertTrue(); + } else { + console.error('====>SUB_REQUEST_DOWNLOAD_API_REMOVE_0001 Failed to remove the download task.'); + expect().assertFail(); + } + }catch(err){ + console.info('====>SUB_REQUEST_DOWNLOAD_API_REMOVE_0001 remove_throw_err:' + JSON.stringify(err)) + } + done(); + }); + }catch(err){ + console.error("====>SUB_REQUEST_DOWNLOAD_API_REMOVE_0001 error: " + err); + done(); + } }) - console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_REMOVE_0001 end-----------------------"); - done(); }); /** @@ -406,25 +491,31 @@ export default function requestDownloadJSUnit() { */ it('SUB_REQUEST_DOWNLOAD_API_REMOVE_0002', 0, async function (done) { console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_REMOVE_0002 is starting-----------------------"); - request.download( downloadConfig, (data)=>{ + downloadConfig.filePath += 'SUB_REQUEST_DOWNLOAD_API_REMOVE_0002.txt' + request.download( downloadConfig, (err, data)=>{ downloadTask = data; - console.info("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0005 downloadTask: " + downloadTask); - expect(downloadTask != undefined).assertEqual(true); - downloadTask.remove().then(data => { - if (data) { - console.info('====>SUB_REQUEST_DOWNLOAD_API_REMOVE_0002 Download task removed.'); - expect(data == true).assertTrue(); - } else { - console.error('SUB_REQUEST_DOWNLOAD_API_REMOVE_0002 Failed to remove the download task.'); - expect().assertFail(); - } - }).catch((err) => { - console.error('SUB_REQUEST_DOWNLOAD_API_REMOVE_0002 Failed to remove the download task.'); - expect().assertFail(); - }) + console.info("====>SUB_REQUEST_DOWNLOAD_API_REMOVE_0002 downloadTask: " + downloadTask); + try{ + expect(downloadTask != undefined).assertEqual(true); + downloadTask.remove().then(data => { + if (data) { + console.info('====>SUB_REQUEST_DOWNLOAD_API_REMOVE_0002 removed data:' + JSON.stringify(data)); + expect(data == true).assertTrue(); + } else { + console.error('====>SUB_REQUEST_DOWNLOAD_API_REMOVE_0002 Failed to remove the download task.'); + expect().assertFail(); + } + done(); + }).catch((err) => { + console.error('====>SUB_REQUEST_DOWNLOAD_API_REMOVE_0002 Failed to remove the download task.'); + done(); + }) + }catch(err){ + console.error("====>SUB_REQUEST_DOWNLOAD_API_REMOVE_0002 error: " + err); + done(); + } }) - console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_REMOVE_0002 end-----------------------"); - done(); + }); /** @@ -436,22 +527,27 @@ export default function requestDownloadJSUnit() { */ it('SUB_REQUEST_DOWNLOAD_API_PAUSE_0001', 0, async function (done) { console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_PAUSE_0001 is starting-----------------------"); - request.download( downloadConfig, (data)=>{ + downloadConfig.filePath += 'SUB_REQUEST_DOWNLOAD_API_PAUSE_0001.txt' + request.download( downloadConfig, (err, data)=>{ downloadTask = data; - console.info("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0005 downloadTask: " + downloadTask); + console.info("====>SUB_REQUEST_DOWNLOAD_API_PAUSE_0001 downloadTask: " + downloadTask); expect(downloadTask != undefined).assertEqual(true); try{ - downloadTask.pause(()=>{ - console.info('====>SUB_REQUEST_DOWNLOAD_API_PAUSE_0001 Download task pause success.'); - expect(true).assertTrue(); + downloadTask.pause(async ()=>{ + try{ + console.info('====>SUB_REQUEST_DOWNLOAD_API_PAUSE_0001 Download task pause success.'); + expect(true).assertTrue(); + }catch(err){ + console.info('====>SUB_REQUEST_DOWNLOAD_API_PAUSE_0001 pause_throw_err:' + JSON.stringify(err)) + } + await downloadTask.remove() + done(); }) }catch(err){ - console.error('Failed to pause the download task pause. because: ' + JSON.stringify(err)); - expect().assertFail(); + console.error("====>SUB_REQUEST_DOWNLOAD_API_PAUSE_0001 error: " + JSON.stringify(err)); + done(); } }) - console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_PAUSE_0001 end-----------------------"); - done(); }); /** @@ -463,20 +559,26 @@ export default function requestDownloadJSUnit() { */ it('SUB_REQUEST_DOWNLOAD_API_PAUSE_0002', 0, async function (done) { console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_PAUSE_0002 is starting-----------------------"); - request.download( downloadConfig, (data)=>{ + downloadConfig.filePath += 'SUB_REQUEST_DOWNLOAD_API_PAUSE_0002.txt' + request.download( downloadConfig, (err, data)=>{ downloadTask = data; - console.info("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0005 downloadTask: " + downloadTask); - expect(downloadTask != undefined).assertEqual(true); - downloadTask.pause().then(() => { - console.info('====>SUB_REQUEST_DOWNLOAD_API_PAUSE_0002 Download task pause success.'); - expect(true).assertTrue(); - }).catch((err) => { - console.error('Failed to pause the download task pause. because: ' + JSON.stringify(err)); - expect().assertFail(); - }) + console.info("====>SUB_REQUEST_DOWNLOAD_API_PAUSE_0002 downloadTask: " + downloadTask); + try{ + expect(downloadTask != undefined).assertEqual(true); + downloadTask.pause().then(async () => { + console.info('====>SUB_REQUEST_DOWNLOAD_API_PAUSE_0002 Download task pause success.'); + expect(true).assertTrue(); + await downloadTask.remove() + done(); + }).catch((err) => { + console.error("====>SUB_REQUEST_DOWNLOAD_API_PAUSE_0002 throw_error: " + JSON.stringify(err)); + done(); + }) + }catch(err){ + console.error("====>SUB_REQUEST_DOWNLOAD_API_PAUSE_0002 error: " + JSON.stringify(err)); + done(); + } }) - console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_PAUSE_0002 end-----------------------"); - done(); }); /** @@ -488,22 +590,27 @@ export default function requestDownloadJSUnit() { */ it('SUB_REQUEST_DOWNLOAD_API_REMUSE_0001', 0, async function (done) { console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_REMUSE_0001 is starting-----------------------"); - request.download( downloadConfig, (data)=>{ + downloadConfig.filePath += 'SUB_REQUEST_DOWNLOAD_API_REMUSE_0001.txt' + request.download( downloadConfig, (err, data)=>{ downloadTask = data; - console.info("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0005 downloadTask: " + downloadTask); + console.info("====>SUB_REQUEST_DOWNLOAD_API_REMUSE_0001 downloadTask: " + downloadTask); expect(downloadTask != undefined).assertEqual(true); try{ - downloadTask.resume(()=>{ - console.info('====>SUB_REQUEST_DOWNLOAD_API_REMUSE_0001 Download task resume success.'); - expect(true).assertTrue(); + downloadTask.resume(async ()=>{ + try{ + console.info('====>SUB_REQUEST_DOWNLOAD_API_REMUSE_0001 Download task resume success.'); + expect(true).assertTrue(); + }catch(err){ + console.info('====>SUB_REQUEST_DOWNLOAD_API_REMUSE_0001 pause_throw_err:' + JSON.stringify(err)) + } + await downloadTask.remove() + done(); }) }catch(err){ - console.error('Failed to pause the download task resume. because: ' + JSON.stringify(err)); - expect().assertFail(); + console.error("====>SUB_REQUEST_DOWNLOAD_API_REMUSE_0001 error: " + JSON.stringify(err)); + done(); } }) - console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_REMUSE_0001 end-----------------------"); - done(); }); /** @@ -515,20 +622,26 @@ export default function requestDownloadJSUnit() { */ it('SUB_REQUEST_DOWNLOAD_API_REMUSE_0002', 0, async function (done) { console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_REMUSE_0002 is starting-----------------------"); - request.download( downloadConfig, (data)=>{ + downloadConfig.filePath += 'SUB_REQUEST_DOWNLOAD_API_REMUSE_0002.txt' + request.download( downloadConfig, (err, data)=>{ downloadTask = data; - console.info("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0005 downloadTask: " + downloadTask); - expect(downloadTask != undefined).assertEqual(true); - downloadTask.resume().then(() => { - console.info('====>SUB_REQUEST_DOWNLOAD_API_REMUSE_0002 Download task resume success.'); - expect(true).assertTrue(); - }).catch((err) => { - console.error('Failed to pause the download task resume. because: ' + JSON.stringify(err)); - expect().assertFail(); - }) + console.info("====>SUB_REQUEST_DOWNLOAD_API_REMUSE_0002 downloadTask: " + downloadTask); + try{ + expect(downloadTask != undefined).assertEqual(true); + downloadTask.resume().then(async () => { + console.info('====>SUB_REQUEST_DOWNLOAD_API_REMUSE_0002 Download task resume success.'); + expect(true).assertTrue(); + await downloadTask.remove() + done() + }).catch((err) => { + console.error("====>SUB_REQUEST_DOWNLOAD_API_REMUSE_0002 throw_error: " + JSON.stringify(err)); + done(); + }) + }catch(err){ + console.error("====>SUB_REQUEST_DOWNLOAD_API_REMUSE_0002 error: " + JSON.stringify(err)); + done(); + } }) - console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_REMUSE_0002 end-----------------------"); - done(); }); /** @@ -540,37 +653,42 @@ export default function requestDownloadJSUnit() { */ it('SUB_REQUEST_DOWNLOAD_API_QUERY_0001', 0, async function (done) { console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_QUERY_0001 is starting-----------------------"); - request.download( downloadConfig, (data)=>{ + downloadConfig.filePath += 'SUB_REQUEST_DOWNLOAD_API_QUERY_0001.txt' + request.download( downloadConfig, (err, data)=>{ downloadTask = data; - console.info("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0005 downloadTask: " + downloadTask); - expect(downloadTask != undefined).assertEqual(true); + console.info("====>SUB_REQUEST_DOWNLOAD_API_QUERY_0001 downloadTask: " + downloadTask); try{ - downloadTask.query((err, downloadInfo)=>{ - if(err) { - console.error('SUB_REQUEST_DOWNLOAD_API_QUERY_0001 Failed to query: ' + JSON.stringify(err)); - expect().assertFail(); - } else { - console.info('====>SUB_REQUEST_DOWNLOAD_API_QUERY_0001 query info: '+ downloadInfo.description); - console.info('====>SUB_REQUEST_DOWNLOAD_API_QUERY_0001 query info: '+ downloadInfo.downloadedBytes); - console.info('====>SUB_REQUEST_DOWNLOAD_API_QUERY_0001 query info: '+ downloadInfo.downloadId); - console.info('====>SUB_REQUEST_DOWNLOAD_API_QUERY_0001 query info: '+ downloadInfo.failedReason); - console.info('====>SUB_REQUEST_DOWNLOAD_API_QUERY_0001 query info: '+ downloadInfo.fileName); - console.info('====>SUB_REQUEST_DOWNLOAD_API_QUERY_0001 query info: '+ downloadInfo.filePath); - console.info('====>SUB_REQUEST_DOWNLOAD_API_QUERY_0001 query info: '+ downloadInfo.pausedReason); - console.info('====>SUB_REQUEST_DOWNLOAD_API_QUERY_0001 query info: '+ downloadInfo.status); - console.info('====>SUB_REQUEST_DOWNLOAD_API_QUERY_0001 query info: '+ downloadInfo.targetURI); - console.info('====>SUB_REQUEST_DOWNLOAD_API_QUERY_0001 query info: '+ downloadInfo.downloadTitle); - console.info('====>SUB_REQUEST_DOWNLOAD_API_QUERY_0001 query info: '+ downloadInfo.downloadTotalBytes); - expect(true).assertTrue(); + expect(downloadTask != undefined).assertEqual(true); + downloadTask.query(async (err, downloadInfo)=>{ + try{ + if(err) { + console.error('====>SUB_REQUEST_DOWNLOAD_API_QUERY_0001 Failed to query: ' + JSON.stringify(err)); + expect().assertFail(); + } else { + console.info('====>SUB_REQUEST_DOWNLOAD_API_QUERY_0001 query info: '+ downloadInfo.description); + console.info('====>SUB_REQUEST_DOWNLOAD_API_QUERY_0001 query info: '+ downloadInfo.downloadedBytes); + console.info('====>SUB_REQUEST_DOWNLOAD_API_QUERY_0001 query info: '+ downloadInfo.downloadId); + console.info('====>SUB_REQUEST_DOWNLOAD_API_QUERY_0001 query info: '+ downloadInfo.failedReason); + console.info('====>SUB_REQUEST_DOWNLOAD_API_QUERY_0001 query info: '+ downloadInfo.fileName); + console.info('====>SUB_REQUEST_DOWNLOAD_API_QUERY_0001 query info: '+ downloadInfo.filePath); + console.info('====>SUB_REQUEST_DOWNLOAD_API_QUERY_0001 query info: '+ downloadInfo.pausedReason); + console.info('====>SUB_REQUEST_DOWNLOAD_API_QUERY_0001 query info: '+ downloadInfo.status); + console.info('====>SUB_REQUEST_DOWNLOAD_API_QUERY_0001 query info: '+ downloadInfo.targetURI); + console.info('====>SUB_REQUEST_DOWNLOAD_API_QUERY_0001 query info: '+ downloadInfo.downloadTitle); + console.info('====>SUB_REQUEST_DOWNLOAD_API_QUERY_0001 query info: '+ downloadInfo.downloadTotalBytes); + expect(true).assertTrue(); + } + }catch(err){ + console.error("====>SUB_REQUEST_DOWNLOAD_API_QUERY_0001 throw_error: " + JSON.stringify(err)); } + await downloadTask.remove() + done(); }) }catch(err){ - console.error('Failed to pause the download task query. because: ' + JSON.stringify(err)); - expect().assertFail(); + console.error("====>SUB_REQUEST_DOWNLOAD_API_QUERY_0001 error: " + JSON.stringify(err)); + done(); } }) - console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_QUERY_0001 end-----------------------"); - done(); }); /** @@ -582,35 +700,47 @@ export default function requestDownloadJSUnit() { */ it('SUB_REQUEST_DOWNLOAD_API_QUERY_0002', 0, async function (done) { console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_QUERY_0002 is starting-----------------------"); - request.download( downloadConfig, (data)=>{ + downloadConfig.filePath += 'SUB_REQUEST_DOWNLOAD_API_QUERY_0002.txt' + request.download( downloadConfig, (err, data)=>{ downloadTask = data; - console.info("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0005 downloadTask: " + downloadTask); - expect(downloadTask != undefined).assertEqual(true); - downloadTask.query().then((err, downloadInfo)=>{ - if(err) { - console.error('SUB_REQUEST_DOWNLOAD_API_QUERY_0002 Failed to query: ' + JSON.stringify(err)); + console.info("====>SUB_REQUEST_DOWNLOAD_API_QUERY_0002 downloadTask: " + downloadTask); + try{ + expect(downloadTask != undefined).assertEqual(true); + downloadTask.query().then(async (downloadInfo)=>{ + try{ + if(err) { + console.error('====>SUB_REQUEST_DOWNLOAD_API_QUERY_0002 Failed to query: ' + JSON.stringify(err)); + expect().assertFail(); + } else { + console.info('====>SUB_REQUEST_DOWNLOAD_API_QUERY_0002 query info: '+ downloadInfo.description); + console.info('====>SUB_REQUEST_DOWNLOAD_API_QUERY_0002 query info: '+ downloadInfo.downloadedBytes); + console.info('====>SUB_REQUEST_DOWNLOAD_API_QUERY_0002 query info: '+ downloadInfo.downloadId); + console.info('====>SUB_REQUEST_DOWNLOAD_API_QUERY_0002 query info: '+ downloadInfo.failedReason); + console.info('====>SUB_REQUEST_DOWNLOAD_API_QUERY_0002 query info: '+ downloadInfo.fileName); + console.info('====>SUB_REQUEST_DOWNLOAD_API_QUERY_0002 query info: '+ downloadInfo.filePath); + console.info('====>SUB_REQUEST_DOWNLOAD_API_QUERY_0002 query info: '+ downloadInfo.pausedReason); + console.info('====>SUB_REQUEST_DOWNLOAD_API_QUERY_0002 query info: '+ downloadInfo.status); + console.info('====>SUB_REQUEST_DOWNLOAD_API_QUERY_0002 query info: '+ downloadInfo.targetURI); + console.info('====>SUB_REQUEST_DOWNLOAD_API_QUERY_0002 query info: '+ downloadInfo.downloadTitle); + console.info('====>SUB_REQUEST_DOWNLOAD_API_QUERY_0002 query info: '+ downloadInfo.downloadTotalBytes); + expect(true).assertTrue(); + } + await downloadTask.remove() + done(); + }catch(err){ + console.error("====>SUB_REQUEST_DOWNLOAD_API_QUERY_0002 error: " + JSON.stringify(err)); + done(); + } + }).catch((err)=>{ + console.error("====>SUB_REQUEST_DOWNLOAD_API_QUERY_0002 catch_error: " + JSON.stringify(err)); expect().assertFail(); - } else { - console.info('====>SUB_REQUEST_DOWNLOAD_API_QUERY_0001 query info: '+ downloadInfo.description); - console.info('====>SUB_REQUEST_DOWNLOAD_API_QUERY_0001 query info: '+ downloadInfo.downloadedBytes); - console.info('====>SUB_REQUEST_DOWNLOAD_API_QUERY_0001 query info: '+ downloadInfo.downloadId); - console.info('====>SUB_REQUEST_DOWNLOAD_API_QUERY_0001 query info: '+ downloadInfo.failedReason); - console.info('====>SUB_REQUEST_DOWNLOAD_API_QUERY_0001 query info: '+ downloadInfo.fileName); - console.info('====>SUB_REQUEST_DOWNLOAD_API_QUERY_0001 query info: '+ downloadInfo.filePath); - console.info('====>SUB_REQUEST_DOWNLOAD_API_QUERY_0001 query info: '+ downloadInfo.pausedReason); - console.info('====>SUB_REQUEST_DOWNLOAD_API_QUERY_0001 query info: '+ downloadInfo.status); - console.info('====>SUB_REQUEST_DOWNLOAD_API_QUERY_0001 query info: '+ downloadInfo.targetURI); - console.info('====>SUB_REQUEST_DOWNLOAD_API_QUERY_0001 query info: '+ downloadInfo.downloadTitle); - console.info('====>SUB_REQUEST_DOWNLOAD_API_QUERY_0001 query info: '+ downloadInfo.downloadTotalBytes); - expect(true).assertTrue(); - } - }).catch(err => { - console.error('Failed to pause the download task query. because: ' + JSON.stringify(err)); - expect().assertFail(); - }) + done(); + }) + }catch(err){ + console.error("====>SUB_REQUEST_DOWNLOAD_API_QUERY_0002 error: " + JSON.stringify(err)); + done(); + } }) - console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_QUERY_0002 end-----------------------"); - done(); }); /** @@ -622,26 +752,48 @@ export default function requestDownloadJSUnit() { */ it('SUB_REQUEST_DOWNLOAD_API_QUERYMINETYPE_0001', 0, async function (done) { console.info("====>---------------------SUB_REQUEST_DOWNLOAD_API_QUERYMINETYPE_0001 is starting---------------------"); - request.download( downloadConfig, (data)=>{ + downloadConfig.filePath += 'SUB_REQUEST_DOWNLOAD_API_QUERYMINETYPE_0001.txt' + request.download( downloadConfig, (err, data)=>{ downloadTask = data; - console.info("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0005 downloadTask: " + downloadTask); - expect(downloadTask != undefined).assertEqual(true); - downloadTask.queryMimeType((err, data)=>{ - if(err) { - console.error('SUB_REQUEST_DOWNLOAD_API_QUERYMINETYPE_0001 Failed to queryMimeType the download task.'); - expect().assertFail(); - } - if (data) { - console.info('====>SUB_REQUEST_DOWNLOAD_API_QUERYMINETYPE_0001 Download task queryMimeType.'); - expect(typeof data == "string").assertTrue(); - } else { - console.error('SUB_REQUEST_DOWNLOAD_API_QUERYMINETYPE_0001 Failed to queryMimeType the download task.'); - expect().assertFail(); - } - }); + console.info("====>SUB_REQUEST_DOWNLOAD_API_QUERYMINETYPE_0001 downloadTask: " + downloadTask); + try{ + expect(downloadTask != undefined).assertEqual(true); + downloadTask.on('progress', (data1, data2)=>{ + try{ + if (data1 > 0){ + downloadTask.queryMimeType((err, data) => { + try{ + if(err) { + console.error('====>SUB_REQUEST_DOWNLOAD_API_QUERYMINETYPE_0001 err:'+ JSON.stringify(err)); + expect().assertFail(); + done(); + } + if (data) { + console.info('====>SUB_REQUEST_DOWNLOAD_API_QUERYMINETYPE_0001 data:' + JSON.stringify(data)); + expect(typeof data == "string").assertTrue(); + } else { + console.error("====>SUB_REQUEST_DOWNLOAD_API_QUERYMINETYPE_0001 error: " + JSON.stringify(err)); + expect().assertFail(); + } + }catch(err){ + console.error("====>SUB_REQUEST_DOWNLOAD_API_QUERYMINETYPE_0001 throw_error: " + JSON.stringify(err)); + } + setTimeout(async ()=>{ + await downloadTask.remove() + done(); + },1000) + }); + } + }catch(err){ + console.error("====>SUB_REQUEST_DOWNLOAD_API_QUERYMINETYPE_0001 error: " + JSON.stringify(err)); + done(); + } + }) + }catch(err){ + console.error("====>SUB_REQUEST_DOWNLOAD_API_QUERYMINETYPE_0001 error: " + JSON.stringify(err)); + done(); + } }) - console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_QUERYMINETYPE_0001 end-----------------------"); - done(); }); /** @@ -653,334 +805,33 @@ export default function requestDownloadJSUnit() { */ it('SUB_REQUEST_DOWNLOAD_API_QUERYMINETYPE_0002', 0, async function (done) { console.info("====>-------------------SUB_REQUEST_DOWNLOAD_API_QUERYMINETYPE_0002 is starting----------------------"); - request.download( downloadConfig, (data)=>{ + downloadConfig.filePath += 'SUB_REQUEST_DOWNLOAD_API_QUERYMINETYPE_0002.txt' + request.download( downloadConfig, (err, data)=>{ downloadTask = data; - console.info("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0005 downloadTask: " + downloadTask); - expect(downloadTask != undefined).assertEqual(true); - downloadTask.queryMimeType().then(data => { - if (data) { - console.info('====>SUB_REQUEST_DOWNLOAD_API_QUERYMINETYPE_0002 Download task queryMimeType.'); - expect(data == true).assertTrue(); - } else { - console.error('SUB_REQUEST_DOWNLOAD_API_QUERYMINETYPE_0002 Failed to queryMimeType the download task.'); - expect().assertFail(); - } - }).catch((err) => { - console.error('SUB_REQUEST_DOWNLOAD_API_QUERYMINETYPE_0002 Failed to queryMimeType the download task.'); - expect().assertFail(); - }) - }) - console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_QUERYMINETYPE_0002 end-----------------------"); - done(); - }); - - /** - * @tc.number SUB_REQUEST_DOWNLOAD_API_DELETE_0001 - * @tc.desc Delete the download task. - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_REQUEST_DOWNLOAD_API_DELETE_0001', 0, async function (done) { - console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_delete_0001 is starting-----------------------"); - try { - request.download(downloadConfig, (data) => { - downloadTask = data; - console.info("====>SUB_REQUEST_DOWNLOAD_API_DELETE_0001 downloadTask: " + downloadTask); - expect(downloadTask != undefined).assertEqual(true); - downloadTask.delete((err, data) => { - if (err) { - console.error('SUB_REQUEST_DOWNLOAD_API_DELETE_0001 Failed to delete the download task.'); - expect().assertFail(); - } - console.info('====>SUB_REQUEST_DOWNLOAD_API_DELETE_0001 Download task delete success.'); - expect(typeof data == "boolean").assertTrue(); - }); - }) - } catch (error) { - console.error('SUB_REQUEST_DOWNLOAD_API_DELETE_0001 delete catch error' + error); - expect().assertFail(); - } - console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_DELETE_0001 end-----------------------"); - done(); - }); - - /** - * @tc.number SUB_REQUEST_DOWNLOAD_API_DELETE_0002 - * @tc.desc Delete the download task. - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_REQUEST_DOWNLOAD_API_DELETE_0002', 0, async function (done) { - console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_DELETE_0002 is starting-----------------------"); - try { - request.download(downloadConfig, (data) => { - downloadTask = data; - console.info("====>SUB_REQUEST_DOWNLOAD_API_DELETE_0002 downloadTask: " + downloadTask); - expect(downloadTask != undefined).assertEqual(true); - downloadTask.delete().then(data => { - console.info('====>SUB_REQUEST_DOWNLOAD_API_DELETE_0002 Download task delete success.'); - expect(data == true).assertTrue(); - }).catch((err) => { - console.info('====>SUB_REQUEST_DOWNLOAD_API_DELETE_0002 Failed to delete the download task.'); - expect().assertFail(); - }) - }) - } catch (error) { - console.error('SUB_REQUEST_DOWNLOAD_API_DELETE_0002 delete catch error'); - expect().assertFail(); - } - console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_DELETE_0002 end-----------------------"); - done(); - }); - - /** - * @tc.number SUB_REQUEST_DOWNLOAD_API_SUSPEND_0001 - * @tc.desc Suspend the download task - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_REQUEST_DOWNLOAD_API_SUSPEND_0001', 0, async function (done) { - console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_SUSPEND_0001 is starting-----------------------"); - try { - request.download(downloadConfig, (data) => { - downloadTask = data; - console.info("====>SUB_REQUEST_DOWNLOAD_API_SUSPEND_0001 downloadTask: " + downloadTask); - expect(downloadTask != undefined).assertEqual(true); - downloadTask.suspend((err, data) => { - if (err) { - console.error('SUB_REQUEST_DOWNLOAD_API_SUSPEND_0001 Failed to suspend the download task.'); - expect().assertFail(); - } - console.info('====>SUB_REQUEST_DOWNLOAD_API_SUSPEND_0001 Download task suspend success.'); - expect(data == true).assertTrue(); - }); - }) - } - catch(error) { - console.error('SUB_REQUEST_DOWNLOAD_API_SUSPEND_0001 suspend catch error' + error); - expect().assertFail(); - } - console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_SUSPEND_0001 end-----------------------"); - done(); - }); - - /** - * @tc.number SUB_REQUEST_DOWNLOAD_API_SUSPEND_0002 - * @tc.desc Suspend the download task - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_REQUEST_DOWNLOAD_API_SUSPEND_0002', 0, async function (done) { - console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_SUSPEND_0002 is starting-----------------------"); - try { - request.download(downloadConfig, (data) => { - downloadTask = data; - console.info("====>SUB_REQUEST_DOWNLOAD_API_SUSPEND_0002 downloadTask: " + downloadTask); - expect(downloadTask != undefined).assertEqual(true); - downloadTask.suspend().then(data => { - console.info('====>SUB_REQUEST_DOWNLOAD_API_SUSPEND_0001 Download task suspend success.'); - expect(data == true).assertTrue(); - }).catch((err) => { - console.info('====>SUB_REQUEST_DOWNLOAD_API_SUSPEND_0002 Failed to suspend the download task.'); - expect().assertFail(); - }) - }) - } - catch(error){ - console.error('SUB_REQUEST_DOWNLOAD_API_SUSPEND_0001 suspend catch error' + error); - expect().assertFail(); - } - console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_SUSPEND_0002 end-----------------------"); - done(); - }); - - /** - * @tc.number SUB_REQUEST_DOWNLOAD_API_RESTORE_0001 - * @tc.desc Restore the download task - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_REQUEST_DOWNLOAD_API_RESTORE_0001', 0, async function (done) { - console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_RESTORE_0001 is starting-----------------------"); - try{ - request.download(downloadConfig, (data) => { - downloadTask = data; - console.info("====>SUB_REQUEST_DOWNLOAD_API_RESTORE_0001 downloadTask: " + downloadTask); - expect(downloadTask != undefined).assertEqual(true); - downloadTask.restore((err, data) => { - if (err) { - console.error('SUB_REQUEST_DOWNLOAD_API_RESTORE_0001 Failed to restore the download task.'); - expect().assertFail(); - } - console.info('====>SUB_REQUEST_DOWNLOAD_API_RESTORE_0001 Download restore success.'); - expect(data == true).assertTrue(); - }); - }); - }catch(error){ - console.error('SUB_REQUEST_DOWNLOAD_API_RESTORE_0001 restore catch error' + error); - expect().assertFail(); - } - console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_RESTORE_0001 end-----------------------"); - done(); - }); - - /** - * @tc.number SUB_REQUEST_DOWNLOAD_API_RESTORE_0002 - * @tc.desc Restore the download task - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_REQUEST_DOWNLOAD_API_RESTORE_0002', 0, async function (done) { - console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_RESTORE_0002 is starting-----------------------"); - try{ - request.download(downloadConfig, (data) => { - downloadTask = data; - console.info("====>SUB_REQUEST_DOWNLOAD_API_RESTORE_0002 downloadTask: " + downloadTask); - expect(downloadTask != undefined).assertEqual(true); - downloadTask.restore().then(data => { - console.info('====>SUB_REQUEST_DOWNLOAD_API_RESTORE_0002 Download task restore.'); - expect(data == true).assertTrue(); - }).catch((err) => { - console.info('====>SUB_REQUEST_DOWNLOAD_API_RESTORE_0002 Failed to restore the download task.'); - expect().assertFail(); - }); - }); - }catch(error){ - console.error('SUB_REQUEST_DOWNLOAD_API_RESTORE_0001 restore catch error' + error); - expect().assertFail(); - } - console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_RESTORE_0002 end-----------------------"); - done(); - }); - - /** - * @tc.number SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0001 - * @tc.desc Get the download task info - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0001', 0, async function (done) { - console.info("====>---------------------SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0001 is starting---------------------"); - try{ - request.download(downloadConfig, (data) => { - downloadTask = data; - console.info("====>SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0001 downloadTask: " + downloadTask); - expect(downloadTask != undefined).assertEqual(true); - downloadTask.getTaskInfo((err, data) => { - if (err) { - console.error('SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0001 Failed to getTaskInfo the download task.'); - expect().assertFail(); - } - console.info('====>SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0001 Download getTaskInfo success.'); - expect(typeof data == "object").assertTrue(); - }); - }); - }catch(error){ - console.error('SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0001 getTaskInfo catch error' + error); - expect().assertFail(); - } - console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0001 end-----------------------"); - done(); - }); - - /** - * @tc.number SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0002 - * @tc.desc Get the download task info - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0002', 0, async function (done) { - console.info("====>-------------------SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0002 is starting----------------------"); - try{ - request.download(downloadConfig, (data) => { - downloadTask = data; - console.info("====>SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0002 downloadTask: " + downloadTask); - expect(downloadTask != undefined).assertEqual(true); - downloadTask.getTaskInfo().then(data => { - console.info('====>SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0002 Download task getTaskInfo success.'); - expect(typeof data == "object").assertTrue(); - }).catch((err) => { - console.error('SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0002 Failed to getTaskInfo the download task.'); - expect().assertFail(); - }); - }); - }catch(error){ - console.error('SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0001 getTaskInfo catch error' + error); - expect().assertFail(); - } - console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0002 end-----------------------"); - done(); - }); - - /** - * @tc.number SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0001 - * @tc.desc Get mimetype of the download task - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0001', 0, async function (done) { - console.info("====>---------------------SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0001 is starting---------------------"); - try{ - request.download(downloadConfig, (data) => { - downloadTask = data; - console.info("====>SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0001 downloadTask: " + downloadTask); - expect(downloadTask != undefined).assertEqual(true); - downloadTask.getTaskMimeType((err, data) => { - if (err) { - console.error('SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0001 Failed to getTaskMimeType the download task.'); - expect().assertFail(); - } - console.info('====>SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0001 Download task getTaskMimeType success.'); - expect(typeof data == "string").assertTrue(); - }); - }); - }catch(error){ - console.error('SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0001 getTaskMimeType catch error' + error); - expect().assertFail(); - } - console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0001 end-----------------------"); - done(); - }); - - /** - * @tc.number SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0002 - * @tc.desc Get mimetype of the download task - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0002', 0, async function (done) { - console.info("====>-------------------SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0002 is starting----------------------"); - try{ - request.download(downloadConfig, (data) => { - downloadTask = data; - console.info("====>SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0002 downloadTask: " + downloadTask); + console.info("====>SUB_REQUEST_DOWNLOAD_API_QUERYMINETYPE_0002 downloadTask: " + downloadTask); + try{ expect(downloadTask != undefined).assertEqual(true); - downloadTask.getTaskMimeType().then(data => { - console.info('====>SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0002 Download getTaskMimeType success.'); - expect(typeof data == "string").assertTrue(); - }).catch((err) => { - console.error('SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0002 Failed to getTaskMimeType the download task.'); - expect().assertFail(); - }); - }); - }catch(error){ - console.error('SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0001 getTaskMimeType catch error' + error); - expect().assertFail(); - } - console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0002 end-----------------------"); - done(); + downloadTask.on('progress', async (data1, data2) => { + try{ + if(data1 > 0){ + let data = await downloadTask.queryMimeType() + console.info('====>SUB_REQUEST_DOWNLOAD_API_QUERYMINETYPE_0002 Download task queryMimeType.'); + expect(typeof data == "string").assertTrue(); + setTimeout(async ()=>{ + await downloadTask.remove() + done(); + },1000) + } + }catch(err){ + console.error("====>SUB_REQUEST_DOWNLOAD_API_QUERYMINETYPE_0002 throw_error: " + JSON.stringify(err)); + done(); + } + }) + }catch(err){ + console.error("====>SUB_REQUEST_DOWNLOAD_API_QUERYMINETYPE_0002 error: " + JSON.stringify(err)); + done(); + } + }) }); - - }) } diff --git a/request/RequestTest_ets/entry/src/main/ets/test/requestUpload.test.ets b/request/RequestTest_ets/entry/src/main/ets/test/requestUpload.test.ets index 0b87999db..3ac432815 100644 --- a/request/RequestTest_ets/entry/src/main/ets/test/requestUpload.test.ets +++ b/request/RequestTest_ets/entry/src/main/ets/test/requestUpload.test.ets @@ -100,7 +100,7 @@ export default function requestUploadJSUnit() { expect(request.ERROR_DEVICE_NOT_FOUND).assertEqual(1); } catch (err) { expect(true).assertEqual(true); - console.error("SUB_REQUEST_UPLOAD_API_0001 error: " + err); + console.error("====>SUB_REQUEST_UPLOAD_API_0001 error: " + err); } console.info("====>-----------------------SUB_REQUEST_UPLOAD_API_0001 end-----------------------"); done(); @@ -127,7 +127,7 @@ export default function requestUploadJSUnit() { expect(request.ERROR_INSUFFICIENT_SPACE).assertEqual(5); } catch (err) { expect(true).assertEqual(true); - console.error("SUB_REQUEST_UPLOAD_API_0002 error: " + err); + console.error("====>SUB_REQUEST_UPLOAD_API_0002 error: " + err); } console.info("====>-----------------------SUB_REQUEST_UPLOAD_API_0002 end-----------------------"); done(); @@ -154,7 +154,7 @@ export default function requestUploadJSUnit() { expect(request.PAUSED_QUEUED_FOR_WIFI).assertEqual(0); } catch (err) { expect(true).assertEqual(true); - console.error("SUB_REQUEST_UPLOAD_API_0003 error: " + err); + console.error("====>SUB_REQUEST_UPLOAD_API_0003 error: " + err); } console.info("====>-----------------------SUB_REQUEST_UPLOAD_API_0003 end-----------------------"); done(); @@ -181,7 +181,7 @@ export default function requestUploadJSUnit() { expect(request.SESSION_FAILED).assertEqual(4); } catch (err) { expect(true).assertEqual(true); - console.error("SUB_REQUEST_UPLOAD_API_0004 error: " + err); + console.error("====>SUB_REQUEST_UPLOAD_API_0004 error: " + err); } console.info("====>-----------------------SUB_REQUEST_UPLOAD_API_0004 end-----------------------"); done(); @@ -208,7 +208,7 @@ export default function requestUploadJSUnit() { expect(request.SESSION_SUCCESSFUL).assertEqual(0); } catch (err) { expect(true).assertEqual(true); - console.error("SUB_REQUEST_UPLOAD_API_0005 error: " + err); + console.error("====>SUB_REQUEST_UPLOAD_API_0005 error: " + err); } console.info("====>-----------------------SUB_REQUEST_UPLOAD_API_0005 end-----------------------"); done(); @@ -245,7 +245,7 @@ export default function requestUploadJSUnit() { expect(request.ERROR_UNSUPPORTED_NETWORK_TYPE).assertEqual(10); } catch (err) { expect(true).assertEqual(true); - console.error("SUB_REQUEST_UPLOAD_API_0006 error: " + err); + console.error("====>SUB_REQUEST_UPLOAD_API_0006 error: " + err); } console.info("====>-----------------------SUB_REQUEST_UPLOAD_API_0006 end-----------------------"); done(); @@ -263,7 +263,7 @@ export default function requestUploadJSUnit() { console.info("====>-----------------------SUB_REQUEST_UPLOAD_API_CALLBACK_0001 is starting-----------------------"); try { console.info("====>SUB_REQUEST_UPLOAD_API_CALLBACK_0001 uploadConfig = " + JSON.stringify(uploadConfig)); - request.upload(uploadConfig, (data) => { + request.upload(uploadConfig, (err, data) => { uploadTask = data; console.info("====>SUB_REQUEST_UPLOAD_API_CALLBACK_0001 progress uploadTask =" + JSON.stringify(uploadTask)); expect(uploadTask != undefined).assertEqual(true); @@ -283,7 +283,7 @@ export default function requestUploadJSUnit() { }); }); } catch (err) { - console.error("SUB_REQUEST_UPLOAD_API_CALLBACK_0001 error: " + err); + console.error("====>SUB_REQUEST_UPLOAD_API_CALLBACK_0001 error: " + err); expect().assertFail(); } sleep(Date.now(), 20000); @@ -324,77 +324,12 @@ export default function requestUploadJSUnit() { }); }); } catch (e) { - console.error("SUB_REQUEST_UPLOAD_API_PROMISE_0001 error: " + JSON.stringify(e)); + console.error("====>SUB_REQUEST_UPLOAD_API_PROMISE_0001 error: " + JSON.stringify(e)); expect(true).assertFail(true); } sleep(Date.now(), 20000); console.info("====>-----------------------SUB_REQUEST_UPLOAD_API_PROMISE_0001 end-----------------------"); done(); }); - - - - /** - * @tc.number SUB_REQUEST_UPLOAD_API_DELETE_0001 - * @tc.desc Delete the upload task. - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_REQUEST_UPLOAD_API_DELETE_0001', 0, async function (done) { - console.info("====>-----------------------SUB_REQUEST_UPLOAD_API_DELETE_0001 is starting-----------------------"); - try { - request.upload(uploadConfig, (data) => { - uploadTask = data; - console.info("====>SUB_REQUEST_UPLOAD_API_DELETE_0001 uploadTask: " + uploadTask); - expect(uploadTask != undefined).assertEqual(true); - uploadTask.delete((err, data) => { - if (err) { - console.error('SUB_REQUEST_UPLOAD_API_DELETE_0001 Failed to delete the uploadTask task.'); - expect().assertFail(); - } - console.info('====>SUB_REQUEST_UPLOAD_API_DELETE_0001 uploadTask task delete success.'); - expect(typeof data == "boolean").assertTrue(); - }); - }) - } catch (error) { - console.error('SUB_REQUEST_UPLOAD_API_DELETE_0001 delete catch error' + error); - expect().assertFail(); - } - console.info("====>-----------------------SUB_REQUEST_UPLOAD_API_DELETE_0001 end-----------------------"); - done(); - }); - - /** - * @tc.number SUB_REQUEST_UPLOAD_API_DELETE_0002 - * @tc.desc Delete the upload task. - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_REQUEST_UPLOAD_API_DELETE_0002', 0, async function (done) { - console.info("====>-----------------------SUB_REQUEST_UPLOAD_API_DELETE_0002 is starting-----------------------"); - try { - request.upload(uploadConfig, (data) => { - uploadTask = data; - console.info("====>SUB_REQUEST_UPLOAD_API_DELETE_0002 uploadTask: " + uploadTask); - expect(uploadTask != undefined).assertEqual(true); - uploadTask.delete().then(data => { - console.info('====>SUB_REQUEST_UPLOAD_API_DELETE_0002 uploadTask task delete success.'); - expect(data == true).assertTrue(); - }).catch((err) => { - console.info('====>SUB_REQUEST_UPLOAD_API_DELETE_0002 Failed to delete the uploadTask task.'); - expect().assertFail(); - }) - }) - } catch (error) { - console.error('SUB_REQUEST_UPLOAD_API_DELETE_0002 delete catch error'); - expect().assertFail(); - } - console.info("====>-----------------------SUB_REQUEST_UPLOAD_API_DELETE_0002 end-----------------------"); - done(); - }); - - }) } -- GitLab