提交 491a7a70 编写于 作者: Z zhangyushuai

合并monthly20221018落后的PR 002

Signed-off-by: Nzhangyushuai <zhangyushuai1@huawei.com>
上级 22264e99
...@@ -24,13 +24,6 @@ export default function imeAbilityTest(abilityContext) { ...@@ -24,13 +24,6 @@ export default function imeAbilityTest(abilityContext) {
id:'', id:'',
extra:{} extra:{}
} }
/**
* sleep function.
*/
function sleep(date, time){
while(Date.now() - date <= time);
}
/** /**
* beforeEach: Prerequisites at the test case level, which are executed before each test case is executed. * beforeEach: Prerequisites at the test case level, which are executed before each test case is executed.
...@@ -75,12 +68,14 @@ export default function imeAbilityTest(abilityContext) { ...@@ -75,12 +68,14 @@ export default function imeAbilityTest(abilityContext) {
} }
inputMethod.switchInputMethod(imExtAbilityProperty).then((data)=>{ inputMethod.switchInputMethod(imExtAbilityProperty).then((data)=>{
console.info('====>SUB_InputMethod_IMEAbility_0004 switchInputMethod to IME :' + data); console.info('====>SUB_InputMethod_IMEAbility_0001 switchInputMethod to IME :' + data);
expect(data == true).assertTrue(); expect(data == true).assertTrue();
}); });
sleep(Date.now(), 3000); let t = setTimeout(() => {
console.info('====>----------SUB_InputMethod_IMEAbility_0001 end-------------'); console.info('====>----------SUB_InputMethod_IMEAbility_0001 end-------------' + t);
clearTimeout(t);
done(); done();
}, 500);
}) })
/** /**
...@@ -105,9 +100,11 @@ export default function imeAbilityTest(abilityContext) { ...@@ -105,9 +100,11 @@ export default function imeAbilityTest(abilityContext) {
console.info('====>SUB_InputMethod_IMEAbility_0002 switchInputMethod to IME :' + data); console.info('====>SUB_InputMethod_IMEAbility_0002 switchInputMethod to IME :' + data);
expect(data == true).assertTrue(); expect(data == true).assertTrue();
}); });
sleep(Date.now(), 2500); let t = setTimeout(() => {
console.info('====>-----------SUB_InputMethod_IMEAbility_0002 end-------------'); console.info('====>----------SUB_InputMethod_IMEAbility_0001 end-------------' + t);
clearTimeout(t);
done(); done();
}, 500);
}) })
}) })
} }
...@@ -196,11 +196,16 @@ export default function inputMethodJSUnit() { ...@@ -196,11 +196,16 @@ export default function inputMethodJSUnit() {
let inputMethodCtrl = inputMethod.getInputMethodController() let inputMethodCtrl = inputMethod.getInputMethodController()
inputMethodCtrl.showSoftKeyboard((err) => { inputMethodCtrl.showSoftKeyboard((err) => {
try { try {
if(err == undefined){
expect().assertFail()
done();
}else{
expect(err.code).assertEqual(12800003) expect(err.code).assertEqual(12800003)
console.info("====>************* inputmethod_test_showSoftKeyboard_001 Test end*************"); console.info("====>************* inputmethod_test_showSoftKeyboard_001 Test end*************");
done(); done();
}
} catch (err) { } catch (err) {
expect().assertFail() console.info("====>inputmethod_test_showSoftKeyboard_001 err tests fail" + JSON.stringify(err));
done(); done();
} }
}); });
...@@ -215,12 +220,17 @@ export default function inputMethodJSUnit() { ...@@ -215,12 +220,17 @@ export default function inputMethodJSUnit() {
it('inputmethod_test_showSoftKeyboard_002', 0, async function (done) { it('inputmethod_test_showSoftKeyboard_002', 0, async function (done) {
let inputMethodCtrl = inputMethod.getInputMethodController() let inputMethodCtrl = inputMethod.getInputMethodController()
inputMethodCtrl.showSoftKeyboard().then(() => { inputMethodCtrl.showSoftKeyboard().then(() => {
try {
expect().assertFail() expect().assertFail()
done(); done();
} catch (err) {
console.info("====>inputmethod_test_showSoftKeyboard_002 err tests fail" + JSON.stringify(err));
done();
}
}).catch((err) => { }).catch((err) => {
console.info('====>showSoftKeyboard promise failed : ' + JSON.stringify(err)) console.info('====>inputmethod_test_showSoftKeyboard_002 promise failed : ' + JSON.stringify(err))
console.info('====>showSoftKeyboard typeof(err.code): ' + typeof(err.code)) console.info('====>inputmethod_test_showSoftKeyboard_002 typeof(err.code): ' + typeof(err.code))
console.info('====>showSoftKeyboard typeof(err.code): ' + err.code) console.info('====>inputmethod_test_showSoftKeyboard_002 typeof(err.code): ' + err.code)
expect(err.code).assertEqual(12800003) expect(err.code).assertEqual(12800003)
console.info("====>************* inputmethod_test_showSoftKeyboard_002 Test end*************"); console.info("====>************* inputmethod_test_showSoftKeyboard_002 Test end*************");
done(); done();
...@@ -237,12 +247,17 @@ export default function inputMethodJSUnit() { ...@@ -237,12 +247,17 @@ export default function inputMethodJSUnit() {
let inputMethodCtrl = inputMethod.getInputMethodController() let inputMethodCtrl = inputMethod.getInputMethodController()
inputMethodCtrl.hideSoftKeyboard((err) => { inputMethodCtrl.hideSoftKeyboard((err) => {
try { try {
console.info('====>hideSoftKeyboard callbacek failed : ' + JSON.stringify(err)) if(err == undefined){
expect().assertFail()
done();
}else{
console.info('====>inputmethod_test_hideSoftKeyboard_001 callbacek failed : ' + JSON.stringify(err))
expect(err.code).assertEqual(12800003) expect(err.code).assertEqual(12800003)
console.info("====>************* inputmethod_test_hideSoftKeyboard_001 Test end*************"); console.info("====>************* inputmethod_test_hideSoftKeyboard_001 Test end*************");
done(); done();
}
} catch (err) { } catch (err) {
expect().assertFail(); console.info('====>inputmethod_test_hideSoftKeyboard_001 callbacek failed : ' + JSON.stringify(err))
done(); done();
} }
}) })
...@@ -257,10 +272,15 @@ export default function inputMethodJSUnit() { ...@@ -257,10 +272,15 @@ export default function inputMethodJSUnit() {
it('inputmethod_test_hideSoftKeyboard_002', 0, async function (done) { it('inputmethod_test_hideSoftKeyboard_002', 0, async function (done) {
let inputMethodCtrl = inputMethod.getInputMethodController() let inputMethodCtrl = inputMethod.getInputMethodController()
inputMethodCtrl.hideSoftKeyboard().then(() => { inputMethodCtrl.hideSoftKeyboard().then(() => {
expect().assertFail(); try {
expect().assertFail()
done();
} catch (err) {
console.info("====>inputmethod_test_hideSoftKeyboard_002 err tests fail" + JSON.stringify(err));
done(); done();
}
}).catch((err) => { }).catch((err) => {
console.info('====>hideSoftKeyboard promise failed : ' + JSON.stringify(err)) console.info('====>inputmethod_test_hideSoftKeyboard_002 promise failed : ' + JSON.stringify(err))
expect(err.code).assertEqual(12800003); expect(err.code).assertEqual(12800003);
console.info("====>************* inputmethod_test_hideSoftKeyboard_002 Test end*************"); console.info("====>************* inputmethod_test_hideSoftKeyboard_002 Test end*************");
done(); done();
......
...@@ -59,7 +59,7 @@ export default class OpenHarmonyTestRunner implements TestRunner { ...@@ -59,7 +59,7 @@ export default class OpenHarmonyTestRunner implements TestRunner {
} }
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', 'cmd : %{public}s', cmd); 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", abilityDelegator.executeShellCommand("echo \"123456\" > /data/app/el2/100/base/com.acts.request.test/haps/entry_test/cache/test.txt",
(err: any, d: any) => { (err: any, d: any) => {
console.info('executeShellCommand : err : ' + JSON.stringify(err)); console.info('executeShellCommand : err : ' + JSON.stringify(err));
console.info('executeShellCommand : data : ' + d.stdResult); console.info('executeShellCommand : data : ' + d.stdResult);
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
*/ */
import request from "@ohos.request"; import request from "@ohos.request";
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'; import fileio from '@ohos.fileio';
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium';
export default function requestDownloadJSUnit() { export default function requestDownloadJSUnit() {
...@@ -49,7 +49,6 @@ export default function requestDownloadJSUnit() { ...@@ -49,7 +49,6 @@ export default function requestDownloadJSUnit() {
console.info('====>afterAll: Test suite-level cleanup condition is executed'); console.info('====>afterAll: Test suite-level cleanup condition is executed');
}); });
let downloadTask;
/** /**
* @tc.number SUB_REQUEST_downloadFile_STAGE_API_CALLBACK_0001 * @tc.number SUB_REQUEST_downloadFile_STAGE_API_CALLBACK_0001
...@@ -63,7 +62,7 @@ export default function requestDownloadJSUnit() { ...@@ -63,7 +62,7 @@ export default function requestDownloadJSUnit() {
let downloadFilePath = `${globalThis.abilityContext.tempDir}/SUB_REQUEST_downloadFile_STAGE_API_CALLBACK_0001.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`) console.debug("====>downloadFileConfig:" + `${globalThis.abilityContext.tempDir}/SUB_REQUEST_downloadFile_STAGE_API_CALLBACK_0001.txt`)
let downloadFileConfig = { let downloadFileConfig = {
url: 'https://www.baidu.com/img/PCtm_d9c8750bed0b3c7d089fa7d55720d6cf.png', url: 'https://gitee.com/chenzhixue/downloadTest/releases/download/v1.0/test.apk',
header: { header: {
headers: 'http' headers: 'http'
}, },
...@@ -75,15 +74,15 @@ export default function requestDownloadJSUnit() { ...@@ -75,15 +74,15 @@ export default function requestDownloadJSUnit() {
title: 'XTS download test!', title: 'XTS download test!',
background: false background: false
} }
request.downloadFile(globalThis.abilityContext, downloadFileConfig, async (err, data)=>{ request.downloadFile(globalThis.abilityContext, downloadFileConfig, async (err, downloadTask)=>{
downloadTask = data;
console.info("====>SUB_REQUEST_downloadFile_STAGE_API_CALLBACK_0001 downloadTask: " + downloadTask); console.info("====>SUB_REQUEST_downloadFile_STAGE_API_CALLBACK_0001 downloadTask: " + downloadTask);
try{ try{
expect(true).assertEqual(downloadTask != undefined); expect(downloadTask != undefined).assertEqual(true);
await downloadTask.delete()
}catch(e){ }catch(e){
console.info("====>SUB_REQUEST_downloadFile_STAGE_API_CALLBACK_0001 except error: " + e); console.info("====>SUB_REQUEST_downloadFile_STAGE_API_CALLBACK_0001 except error: " + e);
} }
await downloadTask.delete();
fileio.unlinkSync(downloadFilePath);
console.info("-----------------------SUB_REQUEST_downloadFile_STAGE_API_CALLBACK_0001 end-----------------------"); console.info("-----------------------SUB_REQUEST_downloadFile_STAGE_API_CALLBACK_0001 end-----------------------");
done(); done();
}); });
...@@ -101,7 +100,7 @@ export default function requestDownloadJSUnit() { ...@@ -101,7 +100,7 @@ export default function requestDownloadJSUnit() {
let downloadFilePath = `${globalThis.abilityContext.tempDir}/SUB_REQUEST_downloadFile_STAGE_API_PROMISE_0001.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`) console.debug("====>downloadFileConfig:" + `${globalThis.abilityContext.tempDir}/SUB_REQUEST_downloadFile_STAGE_API_PROMISE_0001.txt`)
let downloadFileConfig = { let downloadFileConfig = {
url: 'https://www.baidu.com/img/PCtm_d9c8750bed0b3c7d089fa7d55720d6cf.png', url: 'https://gitee.com/chenzhixue/downloadTest/releases/download/v1.0/test.apk',
header: { header: {
headers: 'http' headers: 'http'
}, },
...@@ -114,21 +113,22 @@ export default function requestDownloadJSUnit() { ...@@ -114,21 +113,22 @@ export default function requestDownloadJSUnit() {
background: false background: false
} }
try{ try{
request.downloadFile(globalThis.abilityContext, downloadFileConfig).then(async (data) => { request.downloadFile(globalThis.abilityContext, downloadFileConfig).then(async (downloadTask) => {
downloadTask = data;
console.info("====>SUB_REQUEST_downloadFile_STAGE_API_PROMISE_0001 downloadTask: " + downloadTask); console.info("====>SUB_REQUEST_downloadFile_STAGE_API_PROMISE_0001 downloadTask: " + downloadTask);
expect(true).assertEqual(downloadTask != undefined); expect(downloadTask != undefined).assertEqual(true);
await downloadTask.delete() await downloadTask.delete();
fileio.unlinkSync(downloadFilePath);
done(); done();
}).catch(err => { }).catch(err => {
console.error("====>SUB_REQUEST_downloadFile_STAGE_API_PROMISE_0001 error: " + err); console.error("====>SUB_REQUEST_downloadFile_STAGE_API_PROMISE_0001 error: " + err);
fileio.unlinkSync(downloadFilePath);
done(); done();
}) })
}catch(err){ }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);
fileio.unlinkSync(downloadFilePath);
done(); done();
} }
}); });
/** /**
...@@ -143,7 +143,7 @@ export default function requestDownloadJSUnit() { ...@@ -143,7 +143,7 @@ export default function requestDownloadJSUnit() {
let downloadFilePath = `${globalThis.abilityContext.tempDir}/SUB_REQUEST_DOWNLOAD_API_DELETE_0001.txt` 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`) console.debug("====>downloadFileConfig:" + `${globalThis.abilityContext.tempDir}/SUB_REQUEST_DOWNLOAD_API_DELETE_0001.txt`)
let downloadFileConfig = { let downloadFileConfig = {
url: 'https://www.baidu.com/img/PCtm_d9c8750bed0b3c7d089fa7d55720d6cf.png', url: 'https://gitee.com/chenzhixue/downloadTest/releases/download/v1.0/test.apk',
header: { header: {
headers: 'http' headers: 'http'
}, },
...@@ -155,26 +155,30 @@ export default function requestDownloadJSUnit() { ...@@ -155,26 +155,30 @@ export default function requestDownloadJSUnit() {
title: 'XTS download test!', title: 'XTS download test!',
background: false background: false
} }
request.downloadFile(globalThis.abilityContext, downloadFileConfig, (err, data) => { request.downloadFile(globalThis.abilityContext, downloadFileConfig, async (err, downloadTask) => {
downloadTask = data;
console.info("====>SUB_REQUEST_DOWNLOAD_API_DELETE_0001 downloadTask: " + downloadTask); console.info("====>SUB_REQUEST_DOWNLOAD_API_DELETE_0001 downloadTask: " + downloadTask);
try { try {
expect(downloadTask != undefined).assertEqual(true); expect(downloadTask != undefined).assertEqual(true);
downloadTask.delete((err, data) => { downloadTask.delete(async (err, data) => {
try{ try{
if (err) { if (err) {
console.error('====>SUB_REQUEST_DOWNLOAD_API_DELETE_0001 Failed to delete the download task.'); console.error('====>SUB_REQUEST_DOWNLOAD_API_DELETE_0001 Failed to delete the download task.');
await downloadTask.delete();
expect().assertFail(); expect().assertFail();
} }
console.info('====>SUB_REQUEST_DOWNLOAD_API_DELETE_0001 Download task delete success.'); console.info('====>SUB_REQUEST_DOWNLOAD_API_DELETE_0001 Download task delete success.');
expect(typeof data == "boolean").assertTrue(); expect(typeof data == "boolean").assertTrue();
}catch(err){ }catch(err){
await downloadTask.delete();
console.error('====>SUB_REQUEST_DOWNLOAD_API_DELETE_0001 delete throw error' + err); console.error('====>SUB_REQUEST_DOWNLOAD_API_DELETE_0001 delete throw error' + err);
} }
fileio.unlinkSync(downloadFilePath);
done(); done();
}); });
} catch (error) { } catch (error) {
console.error('====>SUB_REQUEST_DOWNLOAD_API_DELETE_0001 delete catch error' + error); console.error('====>SUB_REQUEST_DOWNLOAD_API_DELETE_0001 delete catch error' + error);
await downloadTask.delete();
fileio.unlinkSync(downloadFilePath);
done(); done();
} }
}) })
...@@ -192,7 +196,7 @@ export default function requestDownloadJSUnit() { ...@@ -192,7 +196,7 @@ export default function requestDownloadJSUnit() {
let downloadFilePath = `${globalThis.abilityContext.tempDir}/SUB_REQUEST_DOWNLOAD_API_DELETE_0002.txt` 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`) console.debug("====>downloadFileConfig:" + `${globalThis.abilityContext.tempDir}/SUB_REQUEST_DOWNLOAD_API_DELETE_0002.txt`)
let downloadFileConfig = { let downloadFileConfig = {
url: 'https://www.baidu.com/img/PCtm_d9c8750bed0b3c7d089fa7d55720d6cf.png', url: 'https://gitee.com/chenzhixue/downloadTest/releases/download/v1.0/test.apk',
header: { header: {
headers: 'http' headers: 'http'
}, },
...@@ -204,23 +208,27 @@ export default function requestDownloadJSUnit() { ...@@ -204,23 +208,27 @@ export default function requestDownloadJSUnit() {
title: 'XTS download test!', title: 'XTS download test!',
background: false background: false
} }
request.downloadFile(globalThis.abilityContext, downloadFileConfig, (err, data) => { request.downloadFile(globalThis.abilityContext, downloadFileConfig, async (err, downloadTask) => {
downloadTask = data;
console.info("====>SUB_REQUEST_DOWNLOAD_API_DELETE_0002 downloadTask: " + downloadTask); console.info("====>SUB_REQUEST_DOWNLOAD_API_DELETE_0002 downloadTask: " + downloadTask);
try { try {
expect(downloadTask != undefined).assertEqual(true); expect(downloadTask != undefined).assertEqual(true);
downloadTask.delete().then(data => { downloadTask.delete().then(async data => {
console.info('====>SUB_REQUEST_DOWNLOAD_API_DELETE_0002 Download task delete success.'); console.info('====>SUB_REQUEST_DOWNLOAD_API_DELETE_0002 Download task delete success.');
expect(data).assertEqual(true); expect(data).assertEqual(true);
console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_DELETE_0002 end-----------------------"); console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_DELETE_0002 end-----------------------");
fileio.unlinkSync(downloadFilePath);
done(); done();
}).catch((err) => { }).catch(async (err) => {
console.info('====>SUB_REQUEST_DOWNLOAD_API_DELETE_0002 Failed to delete the download task.'); console.info('====>SUB_REQUEST_DOWNLOAD_API_DELETE_0002 Failed to delete the download task.');
await downloadTask.delete();
fileio.unlinkSync(downloadFilePath);
expect().assertFail(); expect().assertFail();
done(); done();
}) })
} catch (error) { } catch (error) {
console.error('====>SUB_REQUEST_DOWNLOAD_API_DELETE_0002 delete catch error'); console.error('====>SUB_REQUEST_DOWNLOAD_API_DELETE_0002 delete catch error');
await downloadTask.delete();
fileio.unlinkSync(downloadFilePath);
done(); done();
} }
}) })
...@@ -238,7 +246,7 @@ export default function requestDownloadJSUnit() { ...@@ -238,7 +246,7 @@ export default function requestDownloadJSUnit() {
let downloadFilePath = `${globalThis.abilityContext.tempDir}/SUB_REQUEST_DOWNLOAD_API_SUSPEND_0001.txt` 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`) console.debug("====>downloadFileConfig:" + `${globalThis.abilityContext.tempDir}/SUB_REQUEST_DOWNLOAD_API_SUSPEND_0001.txt`)
let downloadFileConfig = { let downloadFileConfig = {
url: 'https://www.baidu.com/img/PCtm_d9c8750bed0b3c7d089fa7d55720d6cf.png', url: 'https://gitee.com/chenzhixue/downloadTest/releases/download/v1.0/test.apk',
header: { header: {
headers: 'http' headers: 'http'
}, },
...@@ -250,12 +258,11 @@ export default function requestDownloadJSUnit() { ...@@ -250,12 +258,11 @@ export default function requestDownloadJSUnit() {
title: 'XTS download test!', title: 'XTS download test!',
background: false background: false
} }
request.downloadFile(globalThis.abilityContext, downloadFileConfig, (err, data) => { request.downloadFile(globalThis.abilityContext, downloadFileConfig, async (err, downloadTask) => {
downloadTask = data;
console.info("====>SUB_REQUEST_DOWNLOAD_API_SUSPEND_0001 downloadTask: " + downloadTask); console.info("====>SUB_REQUEST_DOWNLOAD_API_SUSPEND_0001 downloadTask: " + downloadTask);
try{ try{
expect(downloadTask != undefined).assertEqual(true); expect(downloadTask != undefined).assertEqual(true);
downloadTask.suspend((err, data) => { downloadTask.suspend(async (err, data) => {
try{ try{
if (err) { if (err) {
console.error('====>SUB_REQUEST_DOWNLOAD_API_SUSPEND_0001 Failed to suspend the download task.'); console.error('====>SUB_REQUEST_DOWNLOAD_API_SUSPEND_0001 Failed to suspend the download task.');
...@@ -266,14 +273,17 @@ export default function requestDownloadJSUnit() { ...@@ -266,14 +273,17 @@ export default function requestDownloadJSUnit() {
}catch(err){ }catch(err){
console.error("====>SUB_REQUEST_DOWNLOAD_API_SUSPEND_0001 throw_error: " + JSON.stringify(err)); console.error("====>SUB_REQUEST_DOWNLOAD_API_SUSPEND_0001 throw_error: " + JSON.stringify(err));
} }
await downloadTask.delete();
fileio.unlinkSync(downloadFilePath);
done(); done();
}); });
}catch(err){ }catch(err){
console.error('====>SUB_REQUEST_DOWNLOAD_API_SUSPEND_0001 suspend catch error' + JSON.stringify(err)); console.error('====>SUB_REQUEST_DOWNLOAD_API_SUSPEND_0001 suspend catch error' + JSON.stringify(err));
await downloadTask.delete();
fileio.unlinkSync(downloadFilePath);
done(); done();
} }
}) })
}); });
/** /**
...@@ -288,7 +298,7 @@ export default function requestDownloadJSUnit() { ...@@ -288,7 +298,7 @@ export default function requestDownloadJSUnit() {
let downloadFilePath = `${globalThis.abilityContext.tempDir}/SUB_REQUEST_DOWNLOAD_API_SUSPEND_0002.txt` 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`) console.debug("====>downloadFileConfig:" + `${globalThis.abilityContext.tempDir}/SUB_REQUEST_DOWNLOAD_API_SUSPEND_0002.txt`)
let downloadFileConfig = { let downloadFileConfig = {
url: 'https://www.baidu.com/img/PCtm_d9c8750bed0b3c7d089fa7d55720d6cf.png', url: 'https://gitee.com/chenzhixue/downloadTest/releases/download/v1.0/test.apk',
header: { header: {
headers: 'http' headers: 'http'
}, },
...@@ -300,21 +310,23 @@ export default function requestDownloadJSUnit() { ...@@ -300,21 +310,23 @@ export default function requestDownloadJSUnit() {
title: 'XTS download test!', title: 'XTS download test!',
background: false background: false
} }
request.downloadFile(globalThis.abilityContext, downloadFileConfig, (err, data) => { request.downloadFile(globalThis.abilityContext, downloadFileConfig, async (err, downloadTask) => {
downloadTask = data;
console.info("====>SUB_REQUEST_DOWNLOAD_API_SUSPEND_0002 downloadTask: " + downloadTask); console.info("====>SUB_REQUEST_DOWNLOAD_API_SUSPEND_0002 downloadTask: " + downloadTask);
try{ try{
expect(downloadTask != undefined).assertEqual(true); expect(downloadTask != undefined).assertEqual(true);
downloadTask.suspend().then(data => { try{
console.info('====>SUB_REQUEST_DOWNLOAD_API_SUSPEND_0002 Download task suspend success.'); let data = await downloadTask.suspend();
expect(data == true).assertTrue(); expect(data == true).assertTrue();
done(); }catch(err){
}).catch((err) => {
console.info('====>SUB_REQUEST_DOWNLOAD_API_SUSPEND_0002 throw_err:' + JSON.stringify(err)); console.info('====>SUB_REQUEST_DOWNLOAD_API_SUSPEND_0002 throw_err:' + JSON.stringify(err));
}
await downloadTask.delete();
fileio.unlinkSync(downloadFilePath);
done(); done();
})
}catch(err){ }catch(err){
console.error('====>SUB_REQUEST_DOWNLOAD_API_SUSPEND_0002 suspend catch error' + JSON.stringify(err)); console.error('====>SUB_REQUEST_DOWNLOAD_API_SUSPEND_0002 suspend catch error' + JSON.stringify(err));
await downloadTask.delete();
fileio.unlinkSync(downloadFilePath);
done(); done();
} }
}) })
...@@ -332,7 +344,7 @@ export default function requestDownloadJSUnit() { ...@@ -332,7 +344,7 @@ export default function requestDownloadJSUnit() {
let downloadFilePath = `${globalThis.abilityContext.tempDir}/SUB_REQUEST_DOWNLOAD_API_RESTORE_0001.txt` 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`) console.debug("====>downloadFileConfig:" + `${globalThis.abilityContext.tempDir}/SUB_REQUEST_DOWNLOAD_API_RESTORE_0001.txt`)
let downloadFileConfig = { let downloadFileConfig = {
url: 'https://www.baidu.com/img/PCtm_d9c8750bed0b3c7d089fa7d55720d6cf.png', url: 'https://gitee.com/chenzhixue/downloadTest/releases/download/v1.0/test.apk',
header: { header: {
headers: 'http' headers: 'http'
}, },
...@@ -344,12 +356,11 @@ export default function requestDownloadJSUnit() { ...@@ -344,12 +356,11 @@ export default function requestDownloadJSUnit() {
title: 'XTS download test!', title: 'XTS download test!',
background: false background: false
} }
request.downloadFile(globalThis.abilityContext, downloadFileConfig, (err, data) => { request.downloadFile(globalThis.abilityContext, downloadFileConfig, async (err, downloadTask) => {
downloadTask = data;
console.info("====>SUB_REQUEST_DOWNLOAD_API_RESTORE_0001 downloadTask: " + downloadTask); console.info("====>SUB_REQUEST_DOWNLOAD_API_RESTORE_0001 downloadTask: " + downloadTask);
try{ try{
expect(downloadTask != undefined).assertEqual(true); expect(downloadTask != undefined).assertEqual(true);
downloadTask.restore((err, data) => { downloadTask.restore(async (err, data) => {
try{ try{
if (err) { if (err) {
console.error('====>SUB_REQUEST_DOWNLOAD_API_RESTORE_0001 Failed to restore the download task.'); console.error('====>SUB_REQUEST_DOWNLOAD_API_RESTORE_0001 Failed to restore the download task.');
...@@ -360,10 +371,14 @@ export default function requestDownloadJSUnit() { ...@@ -360,10 +371,14 @@ export default function requestDownloadJSUnit() {
}catch(err){ }catch(err){
console.info('====>SUB_REQUEST_DOWNLOAD_API_RESTORE_0001 throw_err:' + JSON.stringify(err)); console.info('====>SUB_REQUEST_DOWNLOAD_API_RESTORE_0001 throw_err:' + JSON.stringify(err));
} }
await downloadTask.delete();
fileio.unlinkSync(downloadFilePath);
done(); done();
}); });
}catch(err){ }catch(err){
console.error('====>SUB_REQUEST_DOWNLOAD_API_RESTORE_0001 restore catch error' + JSON.stringify(err)); console.error('====>SUB_REQUEST_DOWNLOAD_API_RESTORE_0001 restore catch error' + JSON.stringify(err));
await downloadTask.delete();
fileio.unlinkSync(downloadFilePath);
done(); done();
} }
}); });
...@@ -381,7 +396,7 @@ export default function requestDownloadJSUnit() { ...@@ -381,7 +396,7 @@ export default function requestDownloadJSUnit() {
let downloadFilePath = `${globalThis.abilityContext.tempDir}/SUB_REQUEST_DOWNLOAD_API_RESTORE_0002.txt` 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`) console.debug("====>downloadFileConfig:" + `${globalThis.abilityContext.tempDir}/SUB_REQUEST_DOWNLOAD_API_RESTORE_0002.txt`)
let downloadFileConfig = { let downloadFileConfig = {
url: 'https://www.baidu.com/img/PCtm_d9c8750bed0b3c7d089fa7d55720d6cf.png', url: 'https://gitee.com/chenzhixue/downloadTest/releases/download/v1.0/test.apk',
header: { header: {
headers: 'http' headers: 'http'
}, },
...@@ -393,21 +408,26 @@ export default function requestDownloadJSUnit() { ...@@ -393,21 +408,26 @@ export default function requestDownloadJSUnit() {
title: 'XTS download test!', title: 'XTS download test!',
background: false background: false
} }
request.downloadFile(globalThis.abilityContext, downloadFileConfig, (err, data) => { request.downloadFile(globalThis.abilityContext, downloadFileConfig, async (err, downloadTask) => {
downloadTask = data;
console.info("====>SUB_REQUEST_DOWNLOAD_API_RESTORE_0002 downloadTask: " + downloadTask); console.info("====>SUB_REQUEST_DOWNLOAD_API_RESTORE_0002 downloadTask: " + downloadTask);
try{ try{
expect(downloadTask != undefined).assertEqual(true); expect(downloadTask != undefined).assertEqual(true);
downloadTask.restore().then(data => { downloadTask.restore().then(async data => {
console.info('====>SUB_REQUEST_DOWNLOAD_API_RESTORE_0002 Download task restore.'); console.info('====>SUB_REQUEST_DOWNLOAD_API_RESTORE_0002 Download task restore.');
expect(data == true).assertTrue(); expect(data == true).assertTrue();
await downloadTask.delete();
fileio.unlinkSync(downloadFilePath);
done(); done();
}).catch((err) => { }).catch(async (err) => {
console.info('====>SUB_REQUEST_DOWNLOAD_API_RESTORE_0002 Failed to restore the download task.'); console.info('====>SUB_REQUEST_DOWNLOAD_API_RESTORE_0002 Failed to restore the download task.');
await downloadTask.delete();
fileio.unlinkSync(downloadFilePath);
done(); done();
}); });
}catch(err){ }catch(err){
console.error('====>SUB_REQUEST_DOWNLOAD_API_RESTORE_0002 restore catch error' +JSON.stringify(err)); console.error('====>SUB_REQUEST_DOWNLOAD_API_RESTORE_0002 restore catch error' +JSON.stringify(err));
await downloadTask.delete();
fileio.unlinkSync(downloadFilePath);
done(); done();
} }
}); });
...@@ -425,7 +445,7 @@ export default function requestDownloadJSUnit() { ...@@ -425,7 +445,7 @@ export default function requestDownloadJSUnit() {
let downloadFilePath = `${globalThis.abilityContext.tempDir}/SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0001.txt` 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`) console.debug("====>downloadFileConfig:" + `${globalThis.abilityContext.tempDir}/SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0001.txt`)
let downloadFileConfig = { let downloadFileConfig = {
url: 'https://www.baidu.com/img/PCtm_d9c8750bed0b3c7d089fa7d55720d6cf.png', url: 'https://gitee.com/chenzhixue/downloadTest/releases/download/v1.0/test.apk',
header: { header: {
headers: 'http' headers: 'http'
}, },
...@@ -437,12 +457,11 @@ export default function requestDownloadJSUnit() { ...@@ -437,12 +457,11 @@ export default function requestDownloadJSUnit() {
title: 'XTS download test!', title: 'XTS download test!',
background: false background: false
} }
request.downloadFile(globalThis.abilityContext, downloadFileConfig, (err, data) => { request.downloadFile(globalThis.abilityContext, downloadFileConfig, async (err, downloadTask) => {
downloadTask = data;
console.info("====>SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0001 downloadTask: " + downloadTask); console.info("====>SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0001 downloadTask: " + downloadTask);
try{ try{
expect(downloadTask != undefined).assertEqual(true); expect(downloadTask != undefined).assertEqual(true);
downloadTask.getTaskInfo((err, data) => { downloadTask.getTaskInfo(async (err, data) => {
try{ try{
if (err) { if (err) {
console.error('====>SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0001 Failed to getTaskInfo the download task.'); console.error('====>SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0001 Failed to getTaskInfo the download task.');
...@@ -453,10 +472,14 @@ export default function requestDownloadJSUnit() { ...@@ -453,10 +472,14 @@ export default function requestDownloadJSUnit() {
}catch(err){ }catch(err){
console.error('====>SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0001 throw_error' +JSON.stringify(err)); console.error('====>SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0001 throw_error' +JSON.stringify(err));
} }
await downloadTask.delete();
fileio.unlinkSync(downloadFilePath);
done(); done();
}); });
}catch(err){ }catch(err){
console.error('====>SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0001 getTaskInfo catch error' + JSON.stringify(err)); console.error('====>SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0001 getTaskInfo catch error' + JSON.stringify(err));
await downloadTask.delete();
fileio.unlinkSync(downloadFilePath);
done(); done();
} }
}); });
...@@ -474,7 +497,7 @@ export default function requestDownloadJSUnit() { ...@@ -474,7 +497,7 @@ export default function requestDownloadJSUnit() {
let downloadFilePath = `${globalThis.abilityContext.tempDir}/SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0002.txt` 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`) console.debug("====>downloadFileConfig:" + `${globalThis.abilityContext.tempDir}/SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0002.txt`)
let downloadFileConfig = { let downloadFileConfig = {
url: 'https://www.baidu.com/img/PCtm_d9c8750bed0b3c7d089fa7d55720d6cf.png', url: 'https://gitee.com/chenzhixue/downloadTest/releases/download/v1.0/test.apk',
header: { header: {
headers: 'http' headers: 'http'
}, },
...@@ -486,21 +509,26 @@ export default function requestDownloadJSUnit() { ...@@ -486,21 +509,26 @@ export default function requestDownloadJSUnit() {
title: 'XTS download test!', title: 'XTS download test!',
background: false background: false
} }
request.downloadFile(globalThis.abilityContext, downloadFileConfig, (err, data) => { request.downloadFile(globalThis.abilityContext, downloadFileConfig, async (err, downloadTask) => {
downloadTask = data;
console.info("====>SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0002 downloadTask: " + downloadTask); console.info("====>SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0002 downloadTask: " + downloadTask);
try{ try{
expect(downloadTask != undefined).assertEqual(true); expect(downloadTask != undefined).assertEqual(true);
downloadTask.getTaskInfo().then(data => { downloadTask.getTaskInfo().then(async data => {
console.info('====>SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0002 Download task getTaskInfo success.'); console.info('====>SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0002 Download task getTaskInfo success.');
expect(typeof data == "object").assertTrue(); expect(typeof data == "object").assertTrue();
await downloadTask.delete();
fileio.unlinkSync(downloadFilePath);
done(); done();
}).catch((err) => { }).catch(async (err) => {
console.error('====>SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0002 Failed to getTaskInfo the download task.'); console.error('====>SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0002 Failed to getTaskInfo the download task.');
await downloadTask.delete();
fileio.unlinkSync(downloadFilePath);
done(); done();
}); });
}catch(err){ }catch(err){
console.error('====>SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0002 getTaskInfo catch error' + JSON.stringify(err)); console.error('====>SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0002 getTaskInfo catch error' + JSON.stringify(err));
await downloadTask.delete();
fileio.unlinkSync(downloadFilePath);
done(); done();
} }
}); });
...@@ -518,7 +546,7 @@ export default function requestDownloadJSUnit() { ...@@ -518,7 +546,7 @@ export default function requestDownloadJSUnit() {
let downloadFilePath = `${globalThis.abilityContext.tempDir}/SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0001.txt` 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`) console.debug("====>downloadFileConfig:" + `${globalThis.abilityContext.tempDir}/SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0001.txt`)
let downloadFileConfig = { let downloadFileConfig = {
url: 'https://www.baidu.com/img/PCtm_d9c8750bed0b3c7d089fa7d55720d6cf.png', url: 'https://gitee.com/chenzhixue/downloadTest/releases/download/v1.0/test.apk',
header: { header: {
headers: 'http' headers: 'http'
}, },
...@@ -530,18 +558,21 @@ export default function requestDownloadJSUnit() { ...@@ -530,18 +558,21 @@ export default function requestDownloadJSUnit() {
title: 'XTS download test!', title: 'XTS download test!',
background: false background: false
} }
request.downloadFile(globalThis.abilityContext, downloadFileConfig, (err, data) => { let flag = false;
downloadTask = data; request.downloadFile(globalThis.abilityContext, downloadFileConfig, async (err, downloadTask) => {
console.info("====>SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0001 downloadTask: " + downloadTask); console.info("====>SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0001 downloadTask: " + downloadTask);
try{ try{
expect(downloadTask != undefined).assertEqual(true); expect(downloadTask != undefined).assertEqual(true);
downloadTask.on('progress',(data1, data2) => { downloadTask.on('progress', async (data1, data2) => {
try{ try{
if (data1 > 0){ if (data1 > 0 && flag == false){
flag = true;
downloadTask.off('progress');
downloadTask.getTaskMimeType(async (err, data)=>{ downloadTask.getTaskMimeType(async (err, data)=>{
try{ try{
if(err) { if(err) {
console.error('====>SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0001 err:'+ JSON.stringify(err)); console.error('====>SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0001 err:'+ JSON.stringify(err));
fileio.unlinkSync(downloadFilePath);
expect().assertFail(); expect().assertFail();
done(); done();
} }
...@@ -555,18 +586,25 @@ export default function requestDownloadJSUnit() { ...@@ -555,18 +586,25 @@ export default function requestDownloadJSUnit() {
}catch(err){ }catch(err){
console.error("====>SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0001 throw_error: " + JSON.stringify(err)); console.error("====>SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0001 throw_error: " + JSON.stringify(err));
} }
setTimeout(()=>{ let t = setTimeout(async ()=>{
await downloadTask.delete();
fileio.unlinkSync(downloadFilePath);
clearTimeout(t);
done(); done();
},1000) },1000)
}); });
} }
}catch(err){ }catch(err){
console.error("====>SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0001 error: " + JSON.stringify(err)); console.error("====>SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0001 error: " + JSON.stringify(err));
await downloadTask.delete();
fileio.unlinkSync(downloadFilePath);
done(); done();
} }
}) })
}catch(err){ }catch(err){
console.error("====>SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0001 error: " + JSON.stringify(err)); console.error("====>SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0001 error: " + JSON.stringify(err));
await downloadTask.delete();
fileio.unlinkSync(downloadFilePath);
done(); done();
} }
}) })
...@@ -584,7 +622,7 @@ export default function requestDownloadJSUnit() { ...@@ -584,7 +622,7 @@ export default function requestDownloadJSUnit() {
let downloadFilePath = `${globalThis.abilityContext.tempDir}/SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0002.txt` 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`) console.debug("====>downloadFileConfig:" + `${globalThis.abilityContext.tempDir}/SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0002.txt`)
let downloadFileConfig = { let downloadFileConfig = {
url: 'https://www.baidu.com/img/PCtm_d9c8750bed0b3c7d089fa7d55720d6cf.png', url: 'https://gitee.com/chenzhixue/downloadTest/releases/download/v1.0/test.apk',
header: { header: {
headers: 'http' headers: 'http'
}, },
...@@ -596,28 +634,36 @@ export default function requestDownloadJSUnit() { ...@@ -596,28 +634,36 @@ export default function requestDownloadJSUnit() {
title: 'XTS download test!', title: 'XTS download test!',
background: false background: false
} }
request.downloadFile(globalThis.abilityContext, downloadFileConfig, async (err, data) => { let flag = false;
downloadTask = data; request.downloadFile(globalThis.abilityContext, downloadFileConfig, async (err, downloadTask) => {
console.info("====>SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0002 downloadTask: " + downloadTask); console.info("====>SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0002 downloadTask: " + downloadTask);
try{ try{
expect(downloadTask != undefined).assertEqual(true); expect(downloadTask != undefined).assertEqual(true);
downloadTask.on('progress', async (data1, data2) => { downloadTask.on('progress', async (data1, data2) => {
try{ try{
if(data1 > 0){ if(data1 > 0 && flag == false){
flag = true;
downloadTask.off('progress');
let data = await downloadTask.getTaskMimeType() let data = await downloadTask.getTaskMimeType()
console.info('====>SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0002 data:' + JSON.stringify(data)); console.info('====>SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0002 data:' + JSON.stringify(data));
expect(typeof data == "string").assertTrue(); expect(typeof data == "string").assertTrue();
} }
setTimeout(()=>{ let t = setTimeout(async ()=>{
await downloadTask.delete();
fileio.unlinkSync(downloadFilePath);
clearTimeout(t);
done(); done();
},1000) },1000)
}catch(err){ }catch(err){
console.error("====>SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0002 throw_error: " + JSON.stringify(err)); console.error("====>SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0002 throw_error: " + JSON.stringify(err));
await downloadTask.delete();
fileio.unlinkSync(downloadFilePath);
done(); done();
} }
}) })
}catch(err){ }catch(err){
console.error("====>SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0002 error: " + JSON.stringify(err)); console.error("====>SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0002 error: " + JSON.stringify(err));
await downloadTask.delete();
done(); done();
} }
}) })
......
...@@ -89,8 +89,7 @@ export default function requestUploadJSUnit() { ...@@ -89,8 +89,7 @@ export default function requestUploadJSUnit() {
it('SUB_REQUEST_uploadFile_STAGE_API_CALLBACK_0001', 0, async function (done) { it('SUB_REQUEST_uploadFile_STAGE_API_CALLBACK_0001', 0, async function (done) {
console.info("-----------------------SUB_REQUEST_uploadFile_STAGE_API_CALLBACK_0001 is starting-----------------------"); console.info("-----------------------SUB_REQUEST_uploadFile_STAGE_API_CALLBACK_0001 is starting-----------------------");
try { try {
request.uploadFile(globalThis.abilityContext, uploadConfig, (err, data)=>{ request.uploadFile(globalThis.abilityContext, uploadConfig, (err, uploadTask)=>{
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{ try{
expect(true).assertEqual(uploadTask != undefined); expect(true).assertEqual(uploadTask != undefined);
...@@ -101,8 +100,9 @@ export default function requestUploadJSUnit() { ...@@ -101,8 +100,9 @@ export default function requestUploadJSUnit() {
} catch (err) { } catch (err) {
console.error("====>SUB_REQUEST_uploadFile_STAGE_API_CALLBACK_0001 error: " + err); console.error("====>SUB_REQUEST_uploadFile_STAGE_API_CALLBACK_0001 error: " + err);
}; };
setTimeout(()=>{ let t = setTimeout(()=>{
console.info("-----------------------SUB_REQUEST_uploadFile_STAGE_API_CALLBACK_0001 end-----------------------"); console.info("-----------------------SUB_REQUEST_uploadFile_STAGE_API_CALLBACK_0001 end-----------------------");
clearTimeout(t);
done(); done();
}, 10000); }, 10000);
}); });
...@@ -117,8 +117,7 @@ export default function requestUploadJSUnit() { ...@@ -117,8 +117,7 @@ export default function requestUploadJSUnit() {
it('SUB_REQUEST_uploadFile_STAGE_API_PROMISE_0001', 0, async function (done) { it('SUB_REQUEST_uploadFile_STAGE_API_PROMISE_0001', 0, async function (done) {
console.info("-----------------------SUB_REQUEST_uploadFile_STAGE_API_PROMISE_0001 is starting-----------------------"); console.info("-----------------------SUB_REQUEST_uploadFile_STAGE_API_PROMISE_0001 is starting-----------------------");
try{ try{
request.uploadFile(globalThis.abilityContext, uploadConfig).then(data => { request.uploadFile(globalThis.abilityContext, uploadConfig).then(uploadTask => {
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{ try{
expect(true).assertEqual(uploadTask != undefined); expect(true).assertEqual(uploadTask != undefined);
...@@ -132,8 +131,9 @@ export default function requestUploadJSUnit() { ...@@ -132,8 +131,9 @@ export default function requestUploadJSUnit() {
}catch(err){ }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(()=>{ let t = setTimeout(()=>{
console.info("-----------------------SUB_REQUEST_uploadFile_STAGE_API_PROMISE_0001 end-----------------------"); console.info("-----------------------SUB_REQUEST_uploadFile_STAGE_API_PROMISE_0001 end-----------------------");
clearTimeout(t);
done(); done();
}, 10000); }, 10000);
}); });
...@@ -147,9 +147,8 @@ export default function requestUploadJSUnit() { ...@@ -147,9 +147,8 @@ export default function requestUploadJSUnit() {
*/ */
it('SUB_REQUEST_UPLOAD_API_DELETE_0001', 0, async function (done) { it('SUB_REQUEST_UPLOAD_API_DELETE_0001', 0, async function (done) {
console.info("====>-----------------------SUB_REQUEST_UPLOAD_API_DELETE_0001 is starting-----------------------"); console.info("====>-----------------------SUB_REQUEST_UPLOAD_API_DELETE_0001 is starting-----------------------");
request.uploadFile(globalThis.abilityContext, uploadConfig, (err, data) => { request.uploadFile(globalThis.abilityContext, uploadConfig, (err, uploadTask) => {
try{ try{
uploadTask = data;
console.info("====>SUB_REQUEST_UPLOAD_API_DELETE_0001 uploadTask: " + uploadTask); console.info("====>SUB_REQUEST_UPLOAD_API_DELETE_0001 uploadTask: " + uploadTask);
expect(uploadTask != undefined).assertEqual(true); expect(uploadTask != undefined).assertEqual(true);
uploadTask.delete((err, data) => { uploadTask.delete((err, data) => {
...@@ -184,8 +183,7 @@ export default function requestUploadJSUnit() { ...@@ -184,8 +183,7 @@ export default function requestUploadJSUnit() {
*/ */
it('SUB_REQUEST_UPLOAD_API_DELETE_0002', 0, async function (done) { it('SUB_REQUEST_UPLOAD_API_DELETE_0002', 0, async function (done) {
console.info("====>-----------------------SUB_REQUEST_UPLOAD_API_DELETE_0002 is starting-----------------------"); console.info("====>-----------------------SUB_REQUEST_UPLOAD_API_DELETE_0002 is starting-----------------------");
request.uploadFile(globalThis.abilityContext, uploadConfig, (err, data) => { request.uploadFile(globalThis.abilityContext, uploadConfig, (err, uploadTask) => {
uploadTask = data;
console.info("====>SUB_REQUEST_UPLOAD_API_DELETE_0002 uploadTask: " + uploadTask); console.info("====>SUB_REQUEST_UPLOAD_API_DELETE_0002 uploadTask: " + uploadTask);
try{ try{
expect(uploadTask != undefined).assertEqual(true); expect(uploadTask != undefined).assertEqual(true);
......
...@@ -5,7 +5,8 @@ ...@@ -5,7 +5,8 @@
"test-timeout": "600000", "test-timeout": "600000",
"bundle-name": "com.acts.requesttest", "bundle-name": "com.acts.requesttest",
"package-name": "com.acts.requesttest", "package-name": "com.acts.requesttest",
"shell-timeout": "600000" "shell-timeout": "600000",
"testcase-timeout": 15000
}, },
"kits": [ "kits": [
{ {
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
import request from "@ohos.request"; import request from "@ohos.request";
import featureAbility from '@ohos.ability.featureAbility' import featureAbility from '@ohos.ability.featureAbility'
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'; import fileio from '@ohos.fileio';
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "hypium/index"; import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "hypium/index";
export default function requestDownloadJSUnit() { export default function requestDownloadJSUnit() {
...@@ -51,12 +51,11 @@ export default function requestDownloadJSUnit() { ...@@ -51,12 +51,11 @@ export default function requestDownloadJSUnit() {
console.info('====>afterAll: Test suite-level cleanup condition is executed'); console.info('====>afterAll: Test suite-level cleanup condition is executed');
}); });
let downloadTask;
let downloadConfig let downloadConfig
async function setDownLoadConfig(){ async function setDownLoadConfig(){
let downloadFilePath = await featureAbility.getContext().getFilesDir() let downloadFilePath = await featureAbility.getContext().getFilesDir()
downloadConfig = { downloadConfig = {
url: 'https://www.baidu.com/img/PCtm_d9c8750bed0b3c7d089fa7d55720d6cf.png', url: 'https://gitee.com/chenzhixue/downloadTest/releases/download/v1.0/test.apk',
header: { header: {
headers: 'http' headers: 'http'
}, },
...@@ -79,28 +78,39 @@ export default function requestDownloadJSUnit() { ...@@ -79,28 +78,39 @@ export default function requestDownloadJSUnit() {
*/ */
it('SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0001', 0, async function (done) { it('SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0001', 0, async function (done) {
console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0001 is starting-----------------------"); console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0001 is starting-----------------------");
downloadConfig.filePath += 'SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0001.txt' downloadConfig.filePath += 'SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0001.txt';
request.download(downloadConfig, (err, data)=>{ let flag = false;
let filePath = downloadConfig.filePath;
request.download(downloadConfig, async (err, downloadTask)=>{
try{ try{
downloadTask = data;
console.info("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0001 downloadTask: " + JSON.stringify(downloadTask) ); console.info("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0001 downloadTask: " + JSON.stringify(downloadTask) );
expect(true).assertEqual(downloadTask != undefined); expect(downloadTask != undefined).assertEqual(true);
downloadTask.on('progress', (data1, data2) => { downloadTask.on('progress', async (data1, data2) => {
if (data1 == data2 && flag == false){
flag = true;
try{ try{
console.info("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0001 on data1 =" + data1); console.info("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0001 on data1 =" + data1);
console.info("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0001 on data2 =" + data2); console.info("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0001 on data2 =" + data2);
expect(true).assertEqual(data1 != undefined); expect(true).assertEqual(data1 != undefined);
expect(true).assertEqual(data2 != undefined); expect(true).assertEqual(data2 != undefined);
if (data1 == data2){
downloadTask.off('progress');
await downloadTask.remove();
fileio.unlinkSync(filePath);
done(); done();
}
}catch(err){ }catch(err){
console.error("====>SUB_REQUEST_DOWNLOAD_API_PROMISE_0001 throw_error: " + err); console.error("====>SUB_REQUEST_DOWNLOAD_API_PROMISE_0001 throw_error: " + err);
downloadTask.off('progress');
await downloadTask.remove();
fileio.unlinkSync(filePath);
done(); done();
} }
}
}); });
}catch(err){ }catch(err){
console.error("====>SUB_REQUEST_DOWNLOAD_API_PROMISE_0001 error: " + err); console.error("====>SUB_REQUEST_DOWNLOAD_API_PROMISE_0001 error: " + err);
await downloadTask.remove();
fileio.unlinkSync(filePath);
done(); done();
} }
}); });
...@@ -115,24 +125,34 @@ export default function requestDownloadJSUnit() { ...@@ -115,24 +125,34 @@ export default function requestDownloadJSUnit() {
*/ */
it('SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0002', 0, async function (done) { it('SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0002', 0, async function (done) {
console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0002 is starting-----------------------"); console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0002 is starting-----------------------");
downloadConfig.filePath += 'SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0002.txt' downloadConfig.filePath += 'SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0002.txt';
request.download(downloadConfig, (err, data)=>{ let flag = false;
downloadTask = data; let filePath = downloadConfig.filePath;
request.download(downloadConfig, async (err, downloadTask)=>{
console.info("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0002 downloadTask: " + downloadTask); console.info("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0002 downloadTask: " + downloadTask);
try{ try{
expect(true).assertEqual(downloadTask != undefined); expect(downloadTask != undefined).assertEqual(true);
downloadTask.on('complete', async () => { downloadTask.on('complete', async () => {
if (flag == false){
flag = true;
downloadTask.off('complete');
try{ try{
console.info('====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0002 task completed.') console.info('====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0002 task completed.')
expect(true).assertTrue(); expect(true).assertTrue();
}catch(err){ }catch(err){
console.error("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0002 throw_error: " + err); console.error("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0002 throw_error: " + err);
} }
await downloadTask.remove() downloadTask.off('complete');
await downloadTask.remove();
fileio.unlinkSync(filePath);
done(); done();
}
}); });
}catch(err){ }catch(err){
console.error("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0002 error: " + err); console.error("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0002 error: " + err);
downloadTask.off('complete');
await downloadTask.remove();
fileio.unlinkSync(filePath);
done(); done();
} }
}); });
...@@ -147,29 +167,36 @@ export default function requestDownloadJSUnit() { ...@@ -147,29 +167,36 @@ export default function requestDownloadJSUnit() {
*/ */
it('SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0003', 0, async function (done) { it('SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0003', 0, async function (done) {
console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0003 is starting-----------------------"); console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0003 is starting-----------------------");
downloadConfig.filePath += 'SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0003.txt' downloadConfig.filePath += 'SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0003.txt';
request.download(downloadConfig, (err, data)=>{ let flag = false;
downloadTask = data; let filePath = downloadConfig.filePath;
request.download(downloadConfig, async (err, downloadTask)=>{
console.info("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0003 downloadTask: " + downloadTask); console.info("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0003 downloadTask: " + downloadTask);
try{ try{
expect(true).assertEqual(downloadTask != undefined); expect(downloadTask != undefined).assertEqual(true);
downloadTask.on('pause', async () => { downloadTask.on('pause', async () => {
try{ try{
console.info('====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0003 task completed.') console.info('====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0003 task pause.')
expect(true).assertTrue(); expect(true).assertTrue();
}catch(err){ }catch(err){
console.error("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0003 throw_error: " + err); console.error("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0003 throw_error: " + err);
} }
await downloadTask.remove() downloadTask.off('pause');
await downloadTask.remove();
fileio.unlinkSync(filePath);
done(); done();
}); });
downloadTask.on('progress', (data1, data2) => { downloadTask.on('progress', async (data1, data2) => {
if(data1 > 0){ if (flag == false){
downloadTask.pause() flag = true
await downloadTask.pause();
downloadTask.off('progress');
} }
}); });
}catch(err){ }catch(err){
console.error("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0003 error: " + err); console.error("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0003 error: " + err);
await downloadTask.remove();
fileio.unlinkSync(filePath);
done(); done();
} }
}); });
...@@ -184,28 +211,35 @@ export default function requestDownloadJSUnit() { ...@@ -184,28 +211,35 @@ export default function requestDownloadJSUnit() {
*/ */
it('SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0004', 0, async function (done) { it('SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0004', 0, async function (done) {
console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0004 is starting-----------------------"); console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0004 is starting-----------------------");
downloadConfig.filePath += 'SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0004.txt' downloadConfig.filePath += 'SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0004.txt';
request.download(downloadConfig, (err, data)=>{ let flag = false;
downloadTask = data; let filePath = downloadConfig.filePath;
request.download(downloadConfig, async (err, downloadTask)=>{
console.info("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0004 downloadTask: " + downloadTask); console.info("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0004 downloadTask: " + downloadTask);
try{ try{
expect(downloadTask != undefined).assertEqual(true); expect(downloadTask != undefined).assertEqual(true);
downloadTask.on('remove', () => { downloadTask.on('remove', () => {
try{ try{
console.info('====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0004 remove completed') console.info('====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0004 remove remove')
expect(true).assertTrue(); expect(true).assertTrue();
}catch(err){ }catch(err){
console.error("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0004 throw_error: " + err); console.error("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0004 throw_error: " + err);
} }
downloadTask.off('remove');
fileio.unlinkSync(filePath);
done(); done();
}); });
downloadTask.on('progress', (data1, data2) => { downloadTask.on('progress', async (data1, data2) => {
if(data1 > 0){ if(flag == false){
downloadTask.remove() flag = true;
await downloadTask.remove();
downloadTask.off('progress');
} }
}); });
}catch(err){ }catch(err){
console.error("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0004 error: " + err); console.error("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0004 error: " + err);
await downloadTask.remove();
fileio.unlinkSync(filePath);
done(); done();
} }
}); });
...@@ -220,25 +254,30 @@ export default function requestDownloadJSUnit() { ...@@ -220,25 +254,30 @@ export default function requestDownloadJSUnit() {
*/ */
it('SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0005', 0, async function (done) { it('SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0005', 0, async function (done) {
console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0005 is starting-----------------------"); console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0005 is starting-----------------------");
downloadConfig.filePath += 'SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0005.txt' downloadConfig.filePath += 'SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0005.txt';
downloadConfig.url += 'xxxxxxxxxx' downloadConfig.url = 'https://www.baidu.com/xxxxxx.jpg';
request.download(downloadConfig, (err, data)=>{ let flag = false;
downloadTask = data; let filePath = downloadConfig.filePath;
request.download(downloadConfig, async (err, downloadTask)=>{
console.info("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0005 downloadTask: " + downloadTask); console.info("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0005 downloadTask: " + downloadTask);
try{ try{
expect(downloadTask != undefined).assertEqual(true); expect(downloadTask != undefined).assertEqual(true);
downloadTask.on('fail', async()=>{ downloadTask.on('fail', async (err) =>{
try{ try{
console.info('====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0005 fail completed') console.info('====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0005 fail fail' + err)
expect(true).assertTrue(); expect(true).assertTrue();
}catch(err){ }catch(err){
console.error("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0005 throw_error: " + err); console.error("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0005 throw_error: " + err);
} }
await downloadTask.remove() downloadTask.off('fail');
await downloadTask.remove();
fileio.unlinkSync(filePath);
done(); done();
}) })
}catch(err){ }catch(err){
console.error("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0005 error: " + err); console.error("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0005 error: " + err);
await downloadTask.remove();
fileio.unlinkSync(filePath);
done(); done();
} }
}); });
...@@ -253,25 +292,29 @@ export default function requestDownloadJSUnit() { ...@@ -253,25 +292,29 @@ export default function requestDownloadJSUnit() {
*/ */
it('SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0006', 0, async function (done) { it('SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0006', 0, async function (done) {
console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0006 is starting-----------------------"); console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0006 is starting-----------------------");
downloadConfig.filePath += 'SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0006.txt' downloadConfig.filePath += 'SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0006.txt';
request.download(downloadConfig, (err, data)=>{ let flag = false;
downloadTask = data; let filePath = downloadConfig.filePath;
request.download(downloadConfig, async (err, downloadTask)=>{
console.info("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0006 downloadTask: " + downloadTask); console.info("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0006 downloadTask: " + downloadTask);
try{ try{
expect(downloadTask != undefined).assertEqual(true); expect(downloadTask != undefined).assertEqual(true);
downloadTask.on('complete', async () => { downloadTask.on('complete', async () => {
try{ try{
request.download(downloadConfig, (err, data)=>{ await request.download(downloadConfig);
})
}catch(err){ }catch(err){
console.error("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0006 second throw_error: " + err); console.error("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0006 second throw_error: " + err);
expect(err.code).assertEqual(13400002) expect(err.code).assertEqual(13400002);
await downloadTask.remove() downloadTask.off('complete');
await downloadTask.remove();
fileio.unlinkSync(filePath);
done(); done();
} }
}); });
}catch(err){ }catch(err){
console.error("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0006 error: " + err); console.error("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0006 error: " + err);
await downloadTask.remove();
fileio.unlinkSync(filePath);
done(); done();
} }
}); });
...@@ -286,27 +329,36 @@ export default function requestDownloadJSUnit() { ...@@ -286,27 +329,36 @@ export default function requestDownloadJSUnit() {
*/ */
it('SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0001', 0, async function (done) { it('SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0001', 0, async function (done) {
console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0001 is starting-----------------------"); console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0001 is starting-----------------------");
downloadConfig.filePath += 'SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0001.txt' downloadConfig.filePath += 'SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0001.txt';
request.download(downloadConfig, (err, data)=>{ let flag = false;
let filePath = downloadConfig.filePath;
request.download(downloadConfig, async (err, downloadTask)=>{
try{ try{
downloadTask = data;
console.info("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0001 downloadTask: " + downloadTask); console.info("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0001 downloadTask: " + downloadTask);
expect(downloadTask != undefined).assertEqual(true); expect(downloadTask != undefined).assertEqual(true);
downloadTask.on('progress', (data1, data2) => {}); downloadTask.on('progress', async (data1, data2) => {
downloadTask.off('progress', async (data1, data2) => { downloadTask.off('progress', async (data1, data2) => {
if (flag == false){
flag = true;
try{ try{
console.info("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0001 on data1 =" + data1); console.info("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0001 off data1 =" + data1);
console.info("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0001 on data2 =" + data2); console.info("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0001 off data2 =" + data2);
expect(data1).assertEqual(0); expect(data1).assertEqual(0);
expect(data2).assertEqual(0); expect(data2).assertEqual(0);
}catch(err){ }catch(err){
console.error("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0001 off_err: " + err); console.error("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0001 off_err: " + err);
} }
await downloadTask.remove() downloadTask.off('progress');
await downloadTask.remove();
fileio.unlinkSync(filePath);
done(); done();
}
});
}); });
}catch(err){ }catch(err){
console.error("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0001 error: " + err); console.error("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0001 error: " + err);
await downloadTask.remove();
fileio.unlinkSync(filePath);
done(); done();
} }
}); });
...@@ -321,24 +373,29 @@ export default function requestDownloadJSUnit() { ...@@ -321,24 +373,29 @@ export default function requestDownloadJSUnit() {
*/ */
it('SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0002', 0, async function (done) { it('SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0002', 0, async function (done) {
console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0002 is starting-----------------------"); console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0002 is starting-----------------------");
downloadConfig.filePath += 'SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0002.txt' downloadConfig.filePath += 'SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0002.txt';
request.download(downloadConfig, (err, data)=>{ let filePath = downloadConfig.filePath;
downloadTask = data; request.download(downloadConfig, async (err, downloadTask)=>{
console.info("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0002 downloadTask: " + downloadTask); console.info("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0002 downloadTask: " + downloadTask);
try{ try{
expect(downloadTask != undefined).assertEqual(true); expect(downloadTask != undefined).assertEqual(true);
downloadTask.on('complete', () => {});
downloadTask.off('complete',async () => { downloadTask.off('complete',async () => {
try{ try{
console.info('====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0002 task complete.') console.info('====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0002 task complete.')
expect(true).assertTrue(); expect(true).assertTrue();
done();
}catch(err){ }catch(err){
console.error("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0002 off_err: " + err); console.error("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0002 off_err: " + err);
} }
await downloadTask.remove() await downloadTask.remove();
fileio.unlinkSync(filePath);
done(); done();
}); });
}catch(err){ }catch(err){
console.error("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0002 error: " + err); console.error("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0002 error: " + err);
await downloadTask.remove();
fileio.unlinkSync(filePath);
done(); done();
} }
}); });
...@@ -353,24 +410,29 @@ export default function requestDownloadJSUnit() { ...@@ -353,24 +410,29 @@ export default function requestDownloadJSUnit() {
*/ */
it('SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0003', 0, async function (done) { it('SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0003', 0, async function (done) {
console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0003 is starting-----------------------"); console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0003 is starting-----------------------");
downloadConfig.filePath += 'SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0003.txt' downloadConfig.filePath += 'SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0003.txt';
request.download( downloadConfig, (err, data)=>{ let filePath = downloadConfig.filePath;
downloadTask = data; request.download( downloadConfig, async (err, downloadTask)=>{
console.info("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0003 downloadTask: " + downloadTask); console.info("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0003 downloadTask: " + downloadTask);
try{ try{
expect(downloadTask != undefined).assertEqual(true); expect(downloadTask != undefined).assertEqual(true);
downloadTask.on('pause', () => {});
downloadTask.off('pause', async () => { downloadTask.off('pause', async () => {
try{ try{
console.info('====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0003 task complete.') console.info('====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0003 task pause.')
expect(true).assertTrue(); expect(true).assertTrue();
done();
}catch(err){ }catch(err){
console.error("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0003 off_err: " + err); console.error("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0003 off_err: " + err);
} }
await downloadTask.remove() await downloadTask.remove();
fileio.unlinkSync(filePath);
done(); done();
}); });
}catch(err){ }catch(err){
console.error("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0003 error: " + err); console.error("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0003 error: " + err);
await downloadTask.remove();
fileio.unlinkSync(filePath);
done(); done();
} }
}); });
...@@ -385,24 +447,28 @@ export default function requestDownloadJSUnit() { ...@@ -385,24 +447,28 @@ export default function requestDownloadJSUnit() {
*/ */
it('SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0004', 0, async function (done) { it('SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0004', 0, async function (done) {
console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0004 is starting-----------------------"); console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0004 is starting-----------------------");
downloadConfig.filePath += 'SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0004.txt' downloadConfig.filePath += 'SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0004.txt';
request.download( downloadConfig, (err, data)=>{ let filePath = downloadConfig.filePath;
downloadTask = data; request.download( downloadConfig, async (err, downloadTask)=>{
console.info("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0004 downloadTask: " + downloadTask); console.info("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0004 downloadTask: " + downloadTask);
try{ try{
expect(downloadTask != undefined).assertEqual(true); expect(downloadTask != undefined).assertEqual(true);
downloadTask.off('remove', async (data) => { downloadTask.on('remove', () => {});
downloadTask.off('remove', async () => {
try{ try{
console.info('====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0003 remove data:' +JSON.stringify(data)) console.info('====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0003 remove success')
expect(true).assertTrue(); expect(true).assertTrue();
}catch(err){ }catch(err){
console.error("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0003 off_err: " + err); console.error("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0003 off_err: " + err);
} }
await downloadTask.remove() await downloadTask.remove();
fileio.unlinkSync(filePath);
done(); done();
}); });
}catch(err){ }catch(err){
console.error("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0004 error: " + err); console.error("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0004 error: " + err);
await downloadTask.remove();
fileio.unlinkSync(filePath);
done(); done();
} }
}); });
...@@ -417,26 +483,29 @@ export default function requestDownloadJSUnit() { ...@@ -417,26 +483,29 @@ export default function requestDownloadJSUnit() {
*/ */
it('SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0005', 0, async function (done) { it('SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0005', 0, async function (done) {
console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0005 is starting-----------------------"); console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0005 is starting-----------------------");
downloadConfig.filePath += 'SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0005.txt' downloadConfig.filePath += 'SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0005.txt';
request.download( downloadConfig, (err, data)=>{ let filePath = downloadConfig.filePath;
downloadTask = data; request.download( downloadConfig, async (err, downloadTask)=>{
console.info("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0005 downloadTask: " + downloadTask); console.info("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0005 downloadTask: " + downloadTask);
try{ try{
expect(downloadTask != undefined).assertEqual(true); expect(downloadTask != undefined).assertEqual(true);
downloadTask.on('fail', (data) => {}); downloadTask.on('fail', (data) => {});
downloadTask.off('fail', async (data) => { downloadTask.off('fail', async (err) => {
try{ try{
console.info('====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0005 fail_data:' + JSON.stringify(data)) console.info('====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0005 fail_data:' + JSON.stringify(err))
expect(data).assertEqual(0) expect(err).assertEqual(0)
console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0005 end-----------------------"); console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0005 end-----------------------");
}catch(err){ }catch(err){
console.error("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0005 fail_error: " + err); console.error("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0005 fail_error: " + err);
} }
await downloadTask.remove() await downloadTask.remove();
fileio.unlinkSync(filePath);
done(); done();
}); });
}catch(err){ }catch(err){
console.error("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0005 error: " + err); console.error("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0005 error: " + err);
await downloadTask.remove();
fileio.unlinkSync(filePath);
done(); done();
} }
}); });
...@@ -451,9 +520,9 @@ export default function requestDownloadJSUnit() { ...@@ -451,9 +520,9 @@ export default function requestDownloadJSUnit() {
*/ */
it('SUB_REQUEST_DOWNLOAD_API_REMOVE_0001', 0, async function (done) { it('SUB_REQUEST_DOWNLOAD_API_REMOVE_0001', 0, async function (done) {
console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_REMOVE_0001 is starting-----------------------"); console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_REMOVE_0001 is starting-----------------------");
downloadConfig.filePath += 'SUB_REQUEST_DOWNLOAD_API_REMOVE_0001.txt' downloadConfig.filePath += 'SUB_REQUEST_DOWNLOAD_API_REMOVE_0001.txt';
request.download( downloadConfig, (err, data)=>{ let filePath = downloadConfig.filePath;
downloadTask = data; request.download( downloadConfig, async (err, downloadTask)=>{
console.info("====>SUB_REQUEST_DOWNLOAD_API_REMOVE_0001 downloadTask: " + downloadTask); console.info("====>SUB_REQUEST_DOWNLOAD_API_REMOVE_0001 downloadTask: " + downloadTask);
try{ try{
expect(downloadTask != undefined).assertEqual(true); expect(downloadTask != undefined).assertEqual(true);
...@@ -473,10 +542,13 @@ export default function requestDownloadJSUnit() { ...@@ -473,10 +542,13 @@ export default function requestDownloadJSUnit() {
}catch(err){ }catch(err){
console.info('====>SUB_REQUEST_DOWNLOAD_API_REMOVE_0001 remove_throw_err:' + JSON.stringify(err)) console.info('====>SUB_REQUEST_DOWNLOAD_API_REMOVE_0001 remove_throw_err:' + JSON.stringify(err))
} }
fileio.unlinkSync(filePath);
done(); done();
}); });
}catch(err){ }catch(err){
console.error("====>SUB_REQUEST_DOWNLOAD_API_REMOVE_0001 error: " + err); console.error("====>SUB_REQUEST_DOWNLOAD_API_REMOVE_0001 error: " + err);
await downloadTask.remove();
fileio.unlinkSync(filePath);
done(); done();
} }
}) })
...@@ -491,31 +563,24 @@ export default function requestDownloadJSUnit() { ...@@ -491,31 +563,24 @@ export default function requestDownloadJSUnit() {
*/ */
it('SUB_REQUEST_DOWNLOAD_API_REMOVE_0002', 0, async function (done) { it('SUB_REQUEST_DOWNLOAD_API_REMOVE_0002', 0, async function (done) {
console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_REMOVE_0002 is starting-----------------------"); console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_REMOVE_0002 is starting-----------------------");
downloadConfig.filePath += 'SUB_REQUEST_DOWNLOAD_API_REMOVE_0002.txt' downloadConfig.filePath += 'SUB_REQUEST_DOWNLOAD_API_REMOVE_0002.txt';
request.download( downloadConfig, (err, data)=>{ let filePath = downloadConfig.filePath;
downloadTask = data; request.download( downloadConfig, async (err, downloadTask)=>{
console.info("====>SUB_REQUEST_DOWNLOAD_API_REMOVE_0002 downloadTask: " + downloadTask); console.info("====>SUB_REQUEST_DOWNLOAD_API_REMOVE_0002 downloadTask: " + downloadTask);
try{ try{
expect(downloadTask != undefined).assertEqual(true); expect(downloadTask != undefined).assertEqual(true);
downloadTask.remove().then(data => { let data = await downloadTask.remove();
if (data) {
console.info('====>SUB_REQUEST_DOWNLOAD_API_REMOVE_0002 removed data:' + JSON.stringify(data)); console.info('====>SUB_REQUEST_DOWNLOAD_API_REMOVE_0002 removed data:' + JSON.stringify(data));
expect(data == true).assertTrue(); expect(data == true).assertTrue();
} else { fileio.unlinkSync(filePath);
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(); done();
})
}catch(err){ }catch(err){
console.error("====>SUB_REQUEST_DOWNLOAD_API_REMOVE_0002 error: " + err); console.error("====>SUB_REQUEST_DOWNLOAD_API_REMOVE_0002 error: " + err);
await downloadTask.remove();
fileio.unlinkSync(filePath);
done(); done();
} }
}) })
}); });
/** /**
...@@ -527,9 +592,9 @@ export default function requestDownloadJSUnit() { ...@@ -527,9 +592,9 @@ export default function requestDownloadJSUnit() {
*/ */
it('SUB_REQUEST_DOWNLOAD_API_PAUSE_0001', 0, async function (done) { it('SUB_REQUEST_DOWNLOAD_API_PAUSE_0001', 0, async function (done) {
console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_PAUSE_0001 is starting-----------------------"); console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_PAUSE_0001 is starting-----------------------");
downloadConfig.filePath += 'SUB_REQUEST_DOWNLOAD_API_PAUSE_0001.txt' downloadConfig.filePath += 'SUB_REQUEST_DOWNLOAD_API_PAUSE_0001.txt';
request.download( downloadConfig, (err, data)=>{ let filePath = downloadConfig.filePath;
downloadTask = data; request.download( downloadConfig, async (err, downloadTask)=>{
console.info("====>SUB_REQUEST_DOWNLOAD_API_PAUSE_0001 downloadTask: " + downloadTask); console.info("====>SUB_REQUEST_DOWNLOAD_API_PAUSE_0001 downloadTask: " + downloadTask);
expect(downloadTask != undefined).assertEqual(true); expect(downloadTask != undefined).assertEqual(true);
try{ try{
...@@ -540,11 +605,14 @@ export default function requestDownloadJSUnit() { ...@@ -540,11 +605,14 @@ export default function requestDownloadJSUnit() {
}catch(err){ }catch(err){
console.info('====>SUB_REQUEST_DOWNLOAD_API_PAUSE_0001 pause_throw_err:' + JSON.stringify(err)) console.info('====>SUB_REQUEST_DOWNLOAD_API_PAUSE_0001 pause_throw_err:' + JSON.stringify(err))
} }
await downloadTask.remove() await downloadTask.remove();
fileio.unlinkSync(filePath);
done(); done();
}) })
}catch(err){ }catch(err){
console.error("====>SUB_REQUEST_DOWNLOAD_API_PAUSE_0001 error: " + JSON.stringify(err)); console.error("====>SUB_REQUEST_DOWNLOAD_API_PAUSE_0001 error: " + JSON.stringify(err));
await downloadTask.remove();
fileio.unlinkSync(filePath);
done(); done();
} }
}) })
...@@ -559,23 +627,20 @@ export default function requestDownloadJSUnit() { ...@@ -559,23 +627,20 @@ export default function requestDownloadJSUnit() {
*/ */
it('SUB_REQUEST_DOWNLOAD_API_PAUSE_0002', 0, async function (done) { it('SUB_REQUEST_DOWNLOAD_API_PAUSE_0002', 0, async function (done) {
console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_PAUSE_0002 is starting-----------------------"); console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_PAUSE_0002 is starting-----------------------");
downloadConfig.filePath += 'SUB_REQUEST_DOWNLOAD_API_PAUSE_0002.txt' downloadConfig.filePath += 'SUB_REQUEST_DOWNLOAD_API_PAUSE_0002.txt';
request.download( downloadConfig, (err, data)=>{ let filePath = downloadConfig.filePath;
downloadTask = data; request.download( downloadConfig, async (err, downloadTask)=>{
console.info("====>SUB_REQUEST_DOWNLOAD_API_PAUSE_0002 downloadTask: " + downloadTask); console.info("====>SUB_REQUEST_DOWNLOAD_API_PAUSE_0002 downloadTask: " + downloadTask);
try{ try{
expect(downloadTask != undefined).assertEqual(true); expect(downloadTask != undefined).assertEqual(true);
downloadTask.pause().then(async () => { await downloadTask.pause();
console.info('====>SUB_REQUEST_DOWNLOAD_API_PAUSE_0002 Download task pause success.');
expect(true).assertTrue();
await downloadTask.remove() await downloadTask.remove()
fileio.unlinkSync(filePath);
done(); done();
}).catch((err) => {
console.error("====>SUB_REQUEST_DOWNLOAD_API_PAUSE_0002 throw_error: " + JSON.stringify(err));
done();
})
}catch(err){ }catch(err){
console.error("====>SUB_REQUEST_DOWNLOAD_API_PAUSE_0002 error: " + JSON.stringify(err)); console.error("====>SUB_REQUEST_DOWNLOAD_API_PAUSE_0002 error: " + JSON.stringify(err));
await downloadTask.remove()
fileio.unlinkSync(filePath);
done(); done();
} }
}) })
...@@ -590,9 +655,9 @@ export default function requestDownloadJSUnit() { ...@@ -590,9 +655,9 @@ export default function requestDownloadJSUnit() {
*/ */
it('SUB_REQUEST_DOWNLOAD_API_REMUSE_0001', 0, async function (done) { it('SUB_REQUEST_DOWNLOAD_API_REMUSE_0001', 0, async function (done) {
console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_REMUSE_0001 is starting-----------------------"); console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_REMUSE_0001 is starting-----------------------");
downloadConfig.filePath += 'SUB_REQUEST_DOWNLOAD_API_REMUSE_0001.txt' downloadConfig.filePath += 'SUB_REQUEST_DOWNLOAD_API_REMUSE_0001.txt';
request.download( downloadConfig, (err, data)=>{ let filePath = downloadConfig.filePath;
downloadTask = data; request.download( downloadConfig, async (err, downloadTask)=>{
console.info("====>SUB_REQUEST_DOWNLOAD_API_REMUSE_0001 downloadTask: " + downloadTask); console.info("====>SUB_REQUEST_DOWNLOAD_API_REMUSE_0001 downloadTask: " + downloadTask);
expect(downloadTask != undefined).assertEqual(true); expect(downloadTask != undefined).assertEqual(true);
try{ try{
...@@ -603,11 +668,14 @@ export default function requestDownloadJSUnit() { ...@@ -603,11 +668,14 @@ export default function requestDownloadJSUnit() {
}catch(err){ }catch(err){
console.info('====>SUB_REQUEST_DOWNLOAD_API_REMUSE_0001 pause_throw_err:' + JSON.stringify(err)) console.info('====>SUB_REQUEST_DOWNLOAD_API_REMUSE_0001 pause_throw_err:' + JSON.stringify(err))
} }
await downloadTask.remove() await downloadTask.remove();
fileio.unlinkSync(downloadConfig.filePath);
done(); done();
}) })
}catch(err){ }catch(err){
console.error("====>SUB_REQUEST_DOWNLOAD_API_REMUSE_0001 error: " + JSON.stringify(err)); console.error("====>SUB_REQUEST_DOWNLOAD_API_REMUSE_0001 error: " + JSON.stringify(err));
await downloadTask.remove();
fileio.unlinkSync(downloadConfig.filePath);
done(); done();
} }
}) })
...@@ -622,23 +690,20 @@ export default function requestDownloadJSUnit() { ...@@ -622,23 +690,20 @@ export default function requestDownloadJSUnit() {
*/ */
it('SUB_REQUEST_DOWNLOAD_API_REMUSE_0002', 0, async function (done) { it('SUB_REQUEST_DOWNLOAD_API_REMUSE_0002', 0, async function (done) {
console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_REMUSE_0002 is starting-----------------------"); console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_REMUSE_0002 is starting-----------------------");
downloadConfig.filePath += 'SUB_REQUEST_DOWNLOAD_API_REMUSE_0002.txt' downloadConfig.filePath += 'SUB_REQUEST_DOWNLOAD_API_REMUSE_0002.txt';
request.download( downloadConfig, (err, data)=>{ let filePath = downloadConfig.filePath;
downloadTask = data; request.download( downloadConfig, async (err, downloadTask)=>{
console.info("====>SUB_REQUEST_DOWNLOAD_API_REMUSE_0002 downloadTask: " + downloadTask); console.info("====>SUB_REQUEST_DOWNLOAD_API_REMUSE_0002 downloadTask: " + downloadTask);
try{ try{
expect(downloadTask != undefined).assertEqual(true); expect(downloadTask != undefined).assertEqual(true);
downloadTask.resume().then(async () => { await downloadTask.resume();
console.info('====>SUB_REQUEST_DOWNLOAD_API_REMUSE_0002 Download task resume success.'); await downloadTask.remove();
expect(true).assertTrue(); fileio.unlinkSync(filePath);
await downloadTask.remove()
done()
}).catch((err) => {
console.error("====>SUB_REQUEST_DOWNLOAD_API_REMUSE_0002 throw_error: " + JSON.stringify(err));
done(); done();
})
}catch(err){ }catch(err){
console.error("====>SUB_REQUEST_DOWNLOAD_API_REMUSE_0002 error: " + JSON.stringify(err)); console.error("====>SUB_REQUEST_DOWNLOAD_API_REMUSE_0002 error: " + JSON.stringify(err));
await downloadTask.remove();
fileio.unlinkSync(filePath);
done(); done();
} }
}) })
...@@ -653,9 +718,9 @@ export default function requestDownloadJSUnit() { ...@@ -653,9 +718,9 @@ export default function requestDownloadJSUnit() {
*/ */
it('SUB_REQUEST_DOWNLOAD_API_QUERY_0001', 0, async function (done) { it('SUB_REQUEST_DOWNLOAD_API_QUERY_0001', 0, async function (done) {
console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_QUERY_0001 is starting-----------------------"); console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_QUERY_0001 is starting-----------------------");
downloadConfig.filePath += 'SUB_REQUEST_DOWNLOAD_API_QUERY_0001.txt' downloadConfig.filePath += 'SUB_REQUEST_DOWNLOAD_API_QUERY_0001.txt';
request.download( downloadConfig, (err, data)=>{ let filePath = downloadConfig.filePath;
downloadTask = data; request.download( downloadConfig, async (err, downloadTask)=>{
console.info("====>SUB_REQUEST_DOWNLOAD_API_QUERY_0001 downloadTask: " + downloadTask); console.info("====>SUB_REQUEST_DOWNLOAD_API_QUERY_0001 downloadTask: " + downloadTask);
try{ try{
expect(downloadTask != undefined).assertEqual(true); expect(downloadTask != undefined).assertEqual(true);
...@@ -681,11 +746,14 @@ export default function requestDownloadJSUnit() { ...@@ -681,11 +746,14 @@ export default function requestDownloadJSUnit() {
}catch(err){ }catch(err){
console.error("====>SUB_REQUEST_DOWNLOAD_API_QUERY_0001 throw_error: " + JSON.stringify(err)); console.error("====>SUB_REQUEST_DOWNLOAD_API_QUERY_0001 throw_error: " + JSON.stringify(err));
} }
await downloadTask.remove() await downloadTask.remove();
fileio.unlinkSync(filePath);
done(); done();
}) })
}catch(err){ }catch(err){
console.error("====>SUB_REQUEST_DOWNLOAD_API_QUERY_0001 error: " + JSON.stringify(err)); console.error("====>SUB_REQUEST_DOWNLOAD_API_QUERY_0001 error: " + JSON.stringify(err));
await downloadTask.remove();
fileio.unlinkSync(filePath);
done(); done();
} }
}) })
...@@ -700,9 +768,9 @@ export default function requestDownloadJSUnit() { ...@@ -700,9 +768,9 @@ export default function requestDownloadJSUnit() {
*/ */
it('SUB_REQUEST_DOWNLOAD_API_QUERY_0002', 0, async function (done) { it('SUB_REQUEST_DOWNLOAD_API_QUERY_0002', 0, async function (done) {
console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_QUERY_0002 is starting-----------------------"); console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_QUERY_0002 is starting-----------------------");
downloadConfig.filePath += 'SUB_REQUEST_DOWNLOAD_API_QUERY_0002.txt' downloadConfig.filePath += 'SUB_REQUEST_DOWNLOAD_API_QUERY_0002.txt';
request.download( downloadConfig, (err, data)=>{ let filePath = downloadConfig.filePath;
downloadTask = data; request.download( downloadConfig, async (err, downloadTask)=>{
console.info("====>SUB_REQUEST_DOWNLOAD_API_QUERY_0002 downloadTask: " + downloadTask); console.info("====>SUB_REQUEST_DOWNLOAD_API_QUERY_0002 downloadTask: " + downloadTask);
try{ try{
expect(downloadTask != undefined).assertEqual(true); expect(downloadTask != undefined).assertEqual(true);
...@@ -725,19 +793,26 @@ export default function requestDownloadJSUnit() { ...@@ -725,19 +793,26 @@ export default function requestDownloadJSUnit() {
console.info('====>SUB_REQUEST_DOWNLOAD_API_QUERY_0002 query info: '+ downloadInfo.downloadTotalBytes); console.info('====>SUB_REQUEST_DOWNLOAD_API_QUERY_0002 query info: '+ downloadInfo.downloadTotalBytes);
expect(true).assertTrue(); expect(true).assertTrue();
} }
await downloadTask.remove() await downloadTask.remove();
fileio.unlinkSync(filePath);
done(); done();
}catch(err){ }catch(err){
console.error("====>SUB_REQUEST_DOWNLOAD_API_QUERY_0002 error: " + JSON.stringify(err)); console.error("====>SUB_REQUEST_DOWNLOAD_API_QUERY_0002 error: " + JSON.stringify(err));
await downloadTask.remove();
fileio.unlinkSync(filePath);
done(); done();
} }
}).catch((err)=>{ }).catch(async (err)=>{
console.error("====>SUB_REQUEST_DOWNLOAD_API_QUERY_0002 catch_error: " + JSON.stringify(err)); console.error("====>SUB_REQUEST_DOWNLOAD_API_QUERY_0002 catch_error: " + JSON.stringify(err));
await downloadTask.remove();
fileio.unlinkSync(filePath);
expect().assertFail(); expect().assertFail();
done(); done();
}) })
}catch(err){ }catch(err){
console.error("====>SUB_REQUEST_DOWNLOAD_API_QUERY_0002 error: " + JSON.stringify(err)); console.error("====>SUB_REQUEST_DOWNLOAD_API_QUERY_0002 error: " + JSON.stringify(err));
await downloadTask.remove();
fileio.unlinkSync(downloadConfig.filePath);
done(); done();
} }
}) })
...@@ -752,46 +827,55 @@ export default function requestDownloadJSUnit() { ...@@ -752,46 +827,55 @@ export default function requestDownloadJSUnit() {
*/ */
it('SUB_REQUEST_DOWNLOAD_API_QUERYMINETYPE_0001', 0, async function (done) { it('SUB_REQUEST_DOWNLOAD_API_QUERYMINETYPE_0001', 0, async function (done) {
console.info("====>---------------------SUB_REQUEST_DOWNLOAD_API_QUERYMINETYPE_0001 is starting---------------------"); console.info("====>---------------------SUB_REQUEST_DOWNLOAD_API_QUERYMINETYPE_0001 is starting---------------------");
downloadConfig.filePath += 'SUB_REQUEST_DOWNLOAD_API_QUERYMINETYPE_0001.txt' downloadConfig.filePath += 'SUB_REQUEST_DOWNLOAD_API_QUERYMINETYPE_0001.txt';
request.download( downloadConfig, (err, data)=>{ let flag = false;
downloadTask = data; let filePath = downloadConfig.filePath;
request.download( downloadConfig, async (err, downloadTask)=>{
console.info("====>SUB_REQUEST_DOWNLOAD_API_QUERYMINETYPE_0001 downloadTask: " + downloadTask); console.info("====>SUB_REQUEST_DOWNLOAD_API_QUERYMINETYPE_0001 downloadTask: " + downloadTask);
try{ try{
expect(downloadTask != undefined).assertEqual(true); expect(downloadTask != undefined).assertEqual(true);
downloadTask.on('progress', async (data1, data2)=>{ downloadTask.on('progress', async (data1, data2)=>{
try{ try {
if (data1 > 0 && downloadTask != null){ if (data1 > 0 && flag == false) {
downloadTask.queryMimeType((err, data) => { flag = true;
try{ downloadTask.off('progress');
if(err) { downloadTask.queryMimeType(async (err, data) => {
console.error('====>SUB_REQUEST_DOWNLOAD_API_QUERYMINETYPE_0001 return_err:'+ JSON.stringify(err)); try {
if (err) {
console.error('====>SUB_REQUEST_DOWNLOAD_API_QUERYMINETYPE_0001 return_err:' + JSON.stringify(err));
fileio.unlinkSync(downloadConfig.filePath);
expect().assertFail(); expect().assertFail();
done(); done();
} }
if (data) { if (data) {
console.info('====>SUB_REQUEST_DOWNLOAD_API_QUERYMINETYPE_0001 data:' + JSON.stringify(data)); console.info('====>SUB_REQUEST_DOWNLOAD_API_QUERYMINETYPE_0001 data:' + JSON.stringify(data));
expect(typeof data == "string").assertTrue(); expect(typeof data == "string").assertTrue();
await downloadTask.remove();
fileio.unlinkSync(filePath);
done();
} else { } else {
console.error("====>SUB_REQUEST_DOWNLOAD_API_QUERYMINETYPE_0001 data_error: " + JSON.stringify(err)); console.error("====>SUB_REQUEST_DOWNLOAD_API_QUERYMINETYPE_0001 data_error: " + JSON.stringify(err));
expect().assertFail(); expect().assertFail();
} }
}catch(err){ } catch (err) {
console.error("====>SUB_REQUEST_DOWNLOAD_API_QUERYMINETYPE_0001 throw_error: " + JSON.stringify(err)); console.error("====>SUB_REQUEST_DOWNLOAD_API_QUERYMINETYPE_0001 throw_error: " + JSON.stringify(err));
await downloadTask.remove();
fileio.unlinkSync(filePath);
done();
} }
}); });
} }
if (data1 == data2){ } catch (err) {
downloadTask = null
await downloadTask.remove()
done();
}
}catch(err){
console.error("====>SUB_REQUEST_DOWNLOAD_API_QUERYMINETYPE_0001 error: " + JSON.stringify(err)); console.error("====>SUB_REQUEST_DOWNLOAD_API_QUERYMINETYPE_0001 error: " + JSON.stringify(err));
await downloadTask.remove();
fileio.unlinkSync(filePath);
done(); done();
} }
}) })
}catch(err){ }catch(err){
console.error("====>SUB_REQUEST_DOWNLOAD_API_QUERYMINETYPE_0001 error: " + JSON.stringify(err)); console.error("====>SUB_REQUEST_DOWNLOAD_API_QUERYMINETYPE_0001 error: " + JSON.stringify(err));
await downloadTask.remove();
fileio.unlinkSync(filePath);
done(); done();
} }
}) })
...@@ -806,31 +890,37 @@ export default function requestDownloadJSUnit() { ...@@ -806,31 +890,37 @@ export default function requestDownloadJSUnit() {
*/ */
it('SUB_REQUEST_DOWNLOAD_API_QUERYMINETYPE_0002', 0, async function (done) { it('SUB_REQUEST_DOWNLOAD_API_QUERYMINETYPE_0002', 0, async function (done) {
console.info("====>-------------------SUB_REQUEST_DOWNLOAD_API_QUERYMINETYPE_0002 is starting----------------------"); console.info("====>-------------------SUB_REQUEST_DOWNLOAD_API_QUERYMINETYPE_0002 is starting----------------------");
downloadConfig.filePath += 'SUB_REQUEST_DOWNLOAD_API_QUERYMINETYPE_0002.txt' downloadConfig.filePath += 'SUB_REQUEST_DOWNLOAD_API_QUERYMINETYPE_0002.txt';
request.download( downloadConfig, (err, data)=>{ let flag = false;
downloadTask = data; let filePath = downloadConfig.filePath;
request.download( downloadConfig, async (err, downloadTask)=>{
console.info("====>SUB_REQUEST_DOWNLOAD_API_QUERYMINETYPE_0002 downloadTask: " + downloadTask); console.info("====>SUB_REQUEST_DOWNLOAD_API_QUERYMINETYPE_0002 downloadTask: " + downloadTask);
try{ try{
expect(downloadTask != undefined).assertEqual(true); expect(downloadTask != undefined).assertEqual(true);
downloadTask.on('progress', async (data1, data2) => { downloadTask.on('progress', async (data1, data2) => {
try{ try{
if(data1 > 0 && downloadTask != null){ if(data1 > 0 && flag == false){
flag = true;
downloadTask.off('progress');
let data = await downloadTask.queryMimeType() let data = await downloadTask.queryMimeType()
console.info('====>SUB_REQUEST_DOWNLOAD_API_QUERYMINETYPE_0002 Download task queryMimeType.'); console.info('====>SUB_REQUEST_DOWNLOAD_API_QUERYMINETYPE_0002 Download task queryMimeType.');
expect(typeof data == "string").assertTrue(); expect(typeof data == "string").assertTrue();
} downloadTask.off('progress');
if(data1 == data2){ await downloadTask.remove();
downloadTask = null fileio.unlinkSync(filePath);
await downloadTask.remove()
done(); done();
} }
}catch(err){ }catch(err){
console.error("====>SUB_REQUEST_DOWNLOAD_API_QUERYMINETYPE_0002 throw_error: " + JSON.stringify(err)); console.error("====>SUB_REQUEST_DOWNLOAD_API_QUERYMINETYPE_0002 throw_error: " + err);
await downloadTask.remove();
fileio.unlinkSync(filePath);
done(); done();
} }
}) })
}catch(err){ }catch(err){
console.error("====>SUB_REQUEST_DOWNLOAD_API_QUERYMINETYPE_0002 error: " + JSON.stringify(err)); console.error("====>SUB_REQUEST_DOWNLOAD_API_QUERYMINETYPE_0002 error: " + JSON.stringify(err));
await downloadTask.remove();
fileio.unlinkSync(filePath);
done(); done();
} }
}) })
......
...@@ -49,13 +49,6 @@ export default function requestUploadJSUnit() { ...@@ -49,13 +49,6 @@ export default function requestUploadJSUnit() {
console.info('====>afterAll: Test suite-level cleanup condition is executed'); console.info('====>afterAll: Test suite-level cleanup condition is executed');
}); });
/**
* sleep function.
*/
function sleep(date, time){
while(Date.now() - date <= time);
}
let uploadTask; let uploadTask;
let RequestData = { let RequestData = {
name: 'name', name: 'name',
...@@ -265,11 +258,9 @@ export default function requestUploadJSUnit() { ...@@ -265,11 +258,9 @@ export default function requestUploadJSUnit() {
console.info("====>-----------------------SUB_REQUEST_UPLOAD_API_CALLBACK_0001 is starting-----------------------"); console.info("====>-----------------------SUB_REQUEST_UPLOAD_API_CALLBACK_0001 is starting-----------------------");
try { try {
console.info("====>SUB_REQUEST_UPLOAD_API_CALLBACK_0001 uploadConfig = " + JSON.stringify(uploadConfig)); console.info("====>SUB_REQUEST_UPLOAD_API_CALLBACK_0001 uploadConfig = " + JSON.stringify(uploadConfig));
request.upload(uploadConfig, (err, data) => { request.upload(uploadConfig, (err, uploadTask) => {
uploadTask = data;
console.info("====>SUB_REQUEST_UPLOAD_API_CALLBACK_0001 progress uploadTask =" + JSON.stringify(uploadTask)); console.info("====>SUB_REQUEST_UPLOAD_API_CALLBACK_0001 progress uploadTask =" + JSON.stringify(uploadTask));
expect(uploadTask != undefined).assertEqual(true); expect(uploadTask != undefined).assertEqual(true);
uploadTask.on('progress', function (data1, data2) { uploadTask.on('progress', function (data1, data2) {
console.info("====>SUB_REQUEST_UPLOAD_API_CALLBACK_0001 on data1 =" + data1); console.info("====>SUB_REQUEST_UPLOAD_API_CALLBACK_0001 on data1 =" + data1);
console.info("====>SUB_REQUEST_UPLOAD_API_CALLBACK_0001 on data2 =" + data2); console.info("====>SUB_REQUEST_UPLOAD_API_CALLBACK_0001 on data2 =" + data2);
...@@ -282,15 +273,15 @@ export default function requestUploadJSUnit() { ...@@ -282,15 +273,15 @@ export default function requestUploadJSUnit() {
uploadTask.remove((err, data) => { uploadTask.remove((err, data) => {
console.info("====>SUB_REQUEST_UPLOAD_API_CALLBACK_0001 remove =" + data); console.info("====>SUB_REQUEST_UPLOAD_API_CALLBACK_0001 remove =" + data);
expect(data).assertEqual(true);
console.info("====>-----------------------SUB_REQUEST_UPLOAD_API_CALLBACK_0001 end-----------------------");
done();
}); });
}); });
} catch (err) { } catch (err) {
console.error("====>SUB_REQUEST_UPLOAD_API_CALLBACK_0001 error: " + err); console.error("====>SUB_REQUEST_UPLOAD_API_CALLBACK_0001 error: " + err);
expect().assertFail(); expect().assertFail();
} }
sleep(Date.now(), 20000);
console.info("====>-----------------------SUB_REQUEST_UPLOAD_API_CALLBACK_0001 end-----------------------");
done();
}); });
/** /**
...@@ -305,33 +296,30 @@ export default function requestUploadJSUnit() { ...@@ -305,33 +296,30 @@ export default function requestUploadJSUnit() {
console.info("====>-----------------------SUB_REQUEST_UPLOAD_API_PROMISE_0001 is starting-----------------------"); console.info("====>-----------------------SUB_REQUEST_UPLOAD_API_PROMISE_0001 is starting-----------------------");
try { try {
console.info("====>SUB_REQUEST_UPLOAD_API_PROMISE_0001 UploadConfig = " + JSON.stringify(uploadConfig)); console.info("====>SUB_REQUEST_UPLOAD_API_PROMISE_0001 UploadConfig = " + JSON.stringify(uploadConfig));
request.upload(uploadConfig).then((data) => { request.upload(uploadConfig).then((uploadTask) => {
uploadTask = data;
console.info("====>SUB_REQUEST_UPLOAD_API_PROMISE_0001 uploadTask = " + uploadTask); console.info("====>SUB_REQUEST_UPLOAD_API_PROMISE_0001 uploadTask = " + uploadTask);
expect(true).assertEqual((uploadTask != undefined) || (uploadTask != "") || (uploadTask != {})); expect(true).assertEqual((uploadTask != undefined));
uploadTask.on('headerReceive', (header) => { uploadTask.on('headerReceive', (header) => {
console.info("====>SUB_REQUEST_UPLOAD_API_PROMISE_0001 header = " + header); console.info("====>SUB_REQUEST_UPLOAD_API_PROMISE_0001 header = " + header);
expect(true).assertEqual((header != undefined) || (header != "") || (header != {})); expect(true).assertEqual((header != {} || header != undefined));
}); });
uploadTask.off('headerReceive', (header) => { uploadTask.off('headerReceive', (header) => {
console.info("====>SUB_REQUEST_UPLOAD_API_PROMISE_0001 header = " + header); console.info("====>SUB_REQUEST_UPLOAD_API_PROMISE_0001 header = " + header);
expect(true).assertEqual((header != undefined) || (header != "") || (header != {})); expect(true).assertEqual((header != {} || header != undefined));
}); });
uploadTask.remove().then((result)=>{ uploadTask.remove().then((result)=>{
console.info("====>SUB_REQUEST_UPLOAD_API_PROMISE_0001 remove result = " + result); console.info("====>SUB_REQUEST_UPLOAD_API_PROMISE_0001 remove result = " + result);
expect(result).assertEqual(true); expect(result).assertEqual(true);
console.info("====>-----------------------SUB_REQUEST_UPLOAD_API_PROMISE_0001 end-----------------------");
done();
}); });
}); });
} catch (e) { } 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); expect(true).assertFail(true);
} }
sleep(Date.now(), 20000);
console.info("====>-----------------------SUB_REQUEST_UPLOAD_API_PROMISE_0001 end-----------------------");
done();
}); });
}) })
} }
...@@ -170,7 +170,7 @@ export default function screenLockJSUnit() { ...@@ -170,7 +170,7 @@ export default function screenLockJSUnit() {
screenLock.isSecureMode((err, data) => { screenLock.isSecureMode((err, data) => {
try{ try{
console.info("====>SUB_MISC_THEME_screenLock_API_0003 secureMode's result is " + data); console.info("====>SUB_MISC_THEME_screenLock_API_0003 secureMode's result is " + data);
expect(data == result).assertTrue(); expect(data == false).assertTrue();
console.info("====>------------------end SUB_MISC_THEME_screenLock_API_0003-------------------"); console.info("====>------------------end SUB_MISC_THEME_screenLock_API_0003-------------------");
done(); done();
}catch(err){ }catch(err){
...@@ -288,7 +288,7 @@ export default function screenLockJSUnit() { ...@@ -288,7 +288,7 @@ export default function screenLockJSUnit() {
try{ try{
secured = screenLock.isSecure() secured = screenLock.isSecure()
console.info('====>SUB_MISC_THEME_screenLock_API_0011 data : ' + JSON.stringify(secured)); console.info('====>SUB_MISC_THEME_screenLock_API_0011 data : ' + JSON.stringify(secured));
if (typeof secured == "boolean") { if (secured == false) {
expect(true).assertTrue(); expect(true).assertTrue();
console.info('====>-------------SUB_MISC_THEME_screenLock_API_0011 end----------------------'); console.info('====>-------------SUB_MISC_THEME_screenLock_API_0011 end----------------------');
done() done()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册