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 93ef631cabbdb092966a5e33f27cc8a1f7a7af81..efc79063e5bcbe345f37eda7b2b19d2d85db1317 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 @@ -115,6 +115,93 @@ export default function requestDownloadJSUnit() { console.info("====>------------------SUB_REQUEST_DOWNLOAD_STAGE_API_PROMISE_0001 end-----------------------"); done(); },5000) - }); + }); + + /** + * @tc.number SUB_REQUEST_downloadFile_STAGE_API_CALLBACK_0001 + * @tc.desc Starts a download session. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + 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 downloadFileConfig = { + 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: downloadFilePath, + title: 'XTS download test!', + background: true + } + 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(); + }); + + /** + * @tc.number SUB_REQUEST_downloadFile_STAGE_API_PROMISE_0001 + * @tc.desc Starts a download session. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + 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 downloadFileConfig = { + 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: downloadFilePath, + title: 'XTS download test!', + background: true + } + try{ + request.downloadFile(globalThis.abilityContext, downloadFileConfig).then(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); + } + }).catch(err => { + console.error("SUB_REQUEST_downloadFile_STAGE_API_PROMISE_0001 error: " + err); + expect().assertFail(); + }) + }catch(err){ + console.error("SUB_REQUEST_downloadFile_STAGE_API_PROMISE_0001 catch error: " + err); + } + console.info("-----------------------SUB_REQUEST_downloadFile_STAGE_API_PROMISE_0001 end-----------------------"); + 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 58913856576de380a27c63aad200b8002935d0e6..e46c71d2586070dc36e022ae593c168a4a61fb44 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 @@ -268,5 +268,66 @@ export default function requestUploadJSUnit() { done(); }, 10000) }); + + /** + * @tc.number SUB_REQUEST_uploadFile_STAGE_API_CALLBACK_0001 + * @tc.desc Starts a upload task. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_REQUEST_uploadFile_STAGE_API_CALLBACK_0001', 0, async function (done) { + console.info("-----------------------SUB_REQUEST_uploadFile_STAGE_API_CALLBACK_0001 is starting-----------------------"); + try { + request.uploadFile(globalThis.abilityContext, uploadConfig, (err, data)=>{ + uploadTask = data; + 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); + } + }); + } catch (err) { + console.error("SUB_REQUEST_uploadFile_STAGE_API_CALLBACK_0001 error: " + err); + expect().assertFail(); + }; + setTimeout(()=>{ + console.info("-----------------------SUB_REQUEST_uploadFile_STAGE_API_CALLBACK_0001 end-----------------------"); + done(); + }, 10000); + }); + + /** + * @tc.number SUB_REQUEST_uploadFile_STAGE_API_PROMISE_0001 + * @tc.desc Starts a upload task. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_REQUEST_uploadFile_STAGE_API_PROMISE_0001', 0, async function (done) { + console.info("-----------------------SUB_REQUEST_uploadFile_STAGE_API_PROMISE_0001 is starting-----------------------"); + try{ + request.uploadFile(globalThis.abilityContext, uploadConfig).then(data => { + uploadTask = data; + 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); + } + }).catch(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); + } + setTimeout(()=>{ + console.info("-----------------------SUB_REQUEST_uploadFile_STAGE_API_PROMISE_0001 end-----------------------"); + done(); + }, 10000); + }); + }) }