未验证 提交 333449b4 编写于 作者: O openharmony_ci 提交者: Gitee

!8711 【杂散】【上传下载】off用例修改,错误码修改

Merge pull request !8711 from 张育帅/master
...@@ -304,7 +304,7 @@ export default function requestDownloadJSUnit() { ...@@ -304,7 +304,7 @@ export default function requestDownloadJSUnit() {
await request.download(downloadConfig); 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(undefined);
downloadTask.off('complete'); downloadTask.off('complete');
await downloadTask.remove(); await downloadTask.remove();
fileio.unlinkSync(filePath); fileio.unlinkSync(filePath);
...@@ -337,24 +337,12 @@ export default function requestDownloadJSUnit() { ...@@ -337,24 +337,12 @@ export default function requestDownloadJSUnit() {
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', async (data1, data2) => { downloadTask.on('progress', async (data1, data2) => {
downloadTask.off('progress', async (data1, data2) => { downloadTask.off('progress', async (data1, data2) => {});
if (flag == false){ await downloadTask.remove();
flag = true; fileio.unlinkSync(filePath);
try{ done();
console.info("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0001 off data1 =" + data1);
console.info("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0001 off data2 =" + data2);
expect(data1).assertEqual(0);
expect(data2).assertEqual(0);
}catch(err){
console.error("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0001 off_err: " + err);
}
downloadTask.off('progress');
await downloadTask.remove();
fileio.unlinkSync(filePath);
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(); await downloadTask.remove();
...@@ -380,18 +368,10 @@ export default function requestDownloadJSUnit() { ...@@ -380,18 +368,10 @@ export default function requestDownloadJSUnit() {
try{ try{
expect(downloadTask != undefined).assertEqual(true); expect(downloadTask != undefined).assertEqual(true);
downloadTask.on('complete', () => {}); downloadTask.on('complete', () => {});
downloadTask.off('complete',async () => { downloadTask.off('complete',async () => {});
try{ await downloadTask.remove();
console.info('====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0002 task complete.') fileio.unlinkSync(filePath);
expect(true).assertTrue(); done();
done();
}catch(err){
console.error("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0002 off_err: " + err);
}
await downloadTask.remove();
fileio.unlinkSync(filePath);
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(); await downloadTask.remove();
...@@ -417,18 +397,10 @@ export default function requestDownloadJSUnit() { ...@@ -417,18 +397,10 @@ export default function requestDownloadJSUnit() {
try{ try{
expect(downloadTask != undefined).assertEqual(true); expect(downloadTask != undefined).assertEqual(true);
downloadTask.on('pause', () => {}); downloadTask.on('pause', () => {});
downloadTask.off('pause', async () => { downloadTask.off('pause', async () => {});
try{ await downloadTask.remove();
console.info('====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0003 task pause.') fileio.unlinkSync(filePath);
expect(true).assertTrue(); done();
done();
}catch(err){
console.error("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0003 off_err: " + err);
}
await downloadTask.remove();
fileio.unlinkSync(filePath);
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(); await downloadTask.remove();
...@@ -454,17 +426,10 @@ export default function requestDownloadJSUnit() { ...@@ -454,17 +426,10 @@ export default function requestDownloadJSUnit() {
try{ try{
expect(downloadTask != undefined).assertEqual(true); expect(downloadTask != undefined).assertEqual(true);
downloadTask.on('remove', () => {}); downloadTask.on('remove', () => {});
downloadTask.off('remove', async () => { downloadTask.off('remove', async () => {});
try{ await downloadTask.remove();
console.info('====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0003 remove success') fileio.unlinkSync(filePath);
expect(true).assertTrue(); done();
}catch(err){
console.error("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0003 off_err: " + err);
}
await downloadTask.remove();
fileio.unlinkSync(filePath);
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(); await downloadTask.remove();
...@@ -490,18 +455,10 @@ export default function requestDownloadJSUnit() { ...@@ -490,18 +455,10 @@ export default function requestDownloadJSUnit() {
try{ try{
expect(downloadTask != undefined).assertEqual(true); expect(downloadTask != undefined).assertEqual(true);
downloadTask.on('fail', (data) => {}); downloadTask.on('fail', (data) => {});
downloadTask.off('fail', async (err) => { downloadTask.off('fail', async (err) => {});
try{ await downloadTask.remove();
console.info('====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0005 fail_data:' + JSON.stringify(err)) fileio.unlinkSync(filePath);
expect(err).assertEqual(0) done();
console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0005 end-----------------------");
}catch(err){
console.error("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0005 fail_error: " + err);
}
await downloadTask.remove();
fileio.unlinkSync(filePath);
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(); await downloadTask.remove();
...@@ -854,7 +811,7 @@ export default function requestDownloadJSUnit() { ...@@ -854,7 +811,7 @@ export default function requestDownloadJSUnit() {
fileio.unlinkSync(filePath); fileio.unlinkSync(filePath);
done(); 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: ");
expect().assertFail(); expect().assertFail();
} }
} catch (err) { } catch (err) {
......
...@@ -261,12 +261,12 @@ export default function requestUploadJSUnit() { ...@@ -261,12 +261,12 @@ export default function requestUploadJSUnit() {
request.upload(uploadConfig, (err, uploadTask) => { request.upload(uploadConfig, (err, uploadTask) => {
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', (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);
}); });
uploadTask.off('progress', function (data1, data2) { uploadTask.off('progress', (data1, data2) => {
console.info("====>SUB_REQUEST_UPLOAD_API_CALLBACK_0001 off data1 =" + data1); console.info("====>SUB_REQUEST_UPLOAD_API_CALLBACK_0001 off data1 =" + data1);
console.info("====>SUB_REQUEST_UPLOAD_API_CALLBACK_0001 off data2 =" + data2); console.info("====>SUB_REQUEST_UPLOAD_API_CALLBACK_0001 off data2 =" + data2);
}); });
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册