提交 bcd707a7 编写于 作者: Z zwx1016320 提交者: 张育帅
上级 6a1e0d79
......@@ -14,7 +14,7 @@
* limitations under the License.
*/
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
import { Hypium } from 'hypium/index'
import { Hypium } from '@ohos/hypium'
import testsuite from '../test/List.test'
export default {
......
......@@ -673,5 +673,313 @@ export default function requestDownloadJSUnit() {
done();
});
/**
* @tc.number SUB_REQUEST_DOWNLOAD_API_DELETE_0001
* @tc.desc Delete the download task.
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
*/
it('SUB_REQUEST_DOWNLOAD_API_DELETE_0001', 0, async function (done) {
console.info("-----------------------SUB_REQUEST_DOWNLOAD_API_delete_0001 is starting-----------------------");
try {
request.download(downloadConfig, (data) => {
downloadTask = data;
console.info("SUB_REQUEST_DOWNLOAD_API_DELETE_0001 downloadTask: " + downloadTask);
expect(downloadTask != undefined).assertEqual(true);
downloadTask.delete((err, data) => {
if (err) {
console.error('SUB_REQUEST_DOWNLOAD_API_DELETE_0001 Failed to delete the download task.');
expect().assertFail();
}
console.info('SUB_REQUEST_DOWNLOAD_API_DELETE_0001 Download task delete success.');
expect(typeof data == "boolean").assertTrue();
});
})
} catch (error) {
console.error('SUB_REQUEST_DOWNLOAD_API_DELETE_0001 delete catch error' + error);
expect().assertFail();
}
console.info("-----------------------SUB_REQUEST_DOWNLOAD_API_DELETE_0001 end-----------------------");
done();
});
/**
* @tc.number SUB_REQUEST_DOWNLOAD_API_DELETE_0002
* @tc.desc Delete the download task.
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
*/
it('SUB_REQUEST_DOWNLOAD_API_DELETE_0002', 0, async function (done) {
console.info("-----------------------SUB_REQUEST_DOWNLOAD_API_DELETE_0002 is starting-----------------------");
try {
request.download(downloadConfig, (data) => {
downloadTask = data;
console.info("SUB_REQUEST_DOWNLOAD_API_DELETE_0002 downloadTask: " + downloadTask);
expect(downloadTask != undefined).assertEqual(true);
downloadTask.delete().then(data => {
console.info('SUB_REQUEST_DOWNLOAD_API_DELETE_0002 Download task delete success.');
expect(data == true).assertTrue();
}).catch((err) => {
console.info('SUB_REQUEST_DOWNLOAD_API_DELETE_0002 Failed to delete the download task.');
expect().assertFail();
})
})
} catch (error) {
console.error('SUB_REQUEST_DOWNLOAD_API_DELETE_0002 delete catch error');
expect().assertFail();
}
console.info("-----------------------SUB_REQUEST_DOWNLOAD_API_DELETE_0002 end-----------------------");
done();
});
/**
* @tc.number SUB_REQUEST_DOWNLOAD_API_SUSPEND_0001
* @tc.desc Suspend the download task
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
*/
it('SUB_REQUEST_DOWNLOAD_API_SUSPEND_0001', 0, async function (done) {
console.info("-----------------------SUB_REQUEST_DOWNLOAD_API_SUSPEND_0001 is starting-----------------------");
try {
request.download(downloadConfig, (data) => {
downloadTask = data;
console.info("SUB_REQUEST_DOWNLOAD_API_SUSPEND_0001 downloadTask: " + downloadTask);
expect(downloadTask != undefined).assertEqual(true);
downloadTask.suspend((err, data) => {
if (err) {
console.error('SUB_REQUEST_DOWNLOAD_API_SUSPEND_0001 Failed to suspend the download task.');
expect().assertFail();
}
console.info('SUB_REQUEST_DOWNLOAD_API_SUSPEND_0001 Download task suspend success.');
expect(data == true).assertTrue();
});
})
}
catch(error) {
console.error('SUB_REQUEST_DOWNLOAD_API_SUSPEND_0001 suspend catch error' + error);
expect().assertFail();
}
console.info("-----------------------SUB_REQUEST_DOWNLOAD_API_SUSPEND_0001 end-----------------------");
done();
});
/**
* @tc.number SUB_REQUEST_DOWNLOAD_API_SUSPEND_0002
* @tc.desc Suspend the download task
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
*/
it('SUB_REQUEST_DOWNLOAD_API_SUSPEND_0002', 0, async function (done) {
console.info("-----------------------SUB_REQUEST_DOWNLOAD_API_SUSPEND_0002 is starting-----------------------");
try {
request.download(downloadConfig, (data) => {
downloadTask = data;
console.info("SUB_REQUEST_DOWNLOAD_API_SUSPEND_0002 downloadTask: " + downloadTask);
expect(downloadTask != undefined).assertEqual(true);
downloadTask.suspend().then(data => {
console.info('SUB_REQUEST_DOWNLOAD_API_SUSPEND_0001 Download task suspend success.');
expect(data == true).assertTrue();
}).catch((err) => {
console.info('SUB_REQUEST_DOWNLOAD_API_SUSPEND_0002 Failed to suspend the download task.');
expect().assertFail();
})
})
}
catch(error){
console.error('SUB_REQUEST_DOWNLOAD_API_SUSPEND_0001 suspend catch error' + error);
expect().assertFail();
}
console.info("-----------------------SUB_REQUEST_DOWNLOAD_API_SUSPEND_0002 end-----------------------");
done();
});
/**
* @tc.number SUB_REQUEST_DOWNLOAD_API_RESTORE_0001
* @tc.desc Restore the download task
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
*/
it('SUB_REQUEST_DOWNLOAD_API_RESTORE_0001', 0, async function (done) {
console.info("-----------------------SUB_REQUEST_DOWNLOAD_API_RESTORE_0001 is starting-----------------------");
try{
request.download(downloadConfig, (data) => {
downloadTask = data;
console.info("SUB_REQUEST_DOWNLOAD_API_RESTORE_0001 downloadTask: " + downloadTask);
expect(downloadTask != undefined).assertEqual(true);
downloadTask.restore((err, data) => {
if (err) {
console.error('SUB_REQUEST_DOWNLOAD_API_RESTORE_0001 Failed to restore the download task.');
expect().assertFail();
}
console.info('SUB_REQUEST_DOWNLOAD_API_RESTORE_0001 Download restore success.');
expect(data == true).assertTrue();
});
});
}catch(error){
console.error('SUB_REQUEST_DOWNLOAD_API_RESTORE_0001 restore catch error' + error);
expect().assertFail();
}
console.info("-----------------------SUB_REQUEST_DOWNLOAD_API_RESTORE_0001 end-----------------------");
done();
});
/**
* @tc.number SUB_REQUEST_DOWNLOAD_API_RESTORE_0002
* @tc.desc Restore the download task
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
*/
it('SUB_REQUEST_DOWNLOAD_API_RESTORE_0002', 0, async function (done) {
console.info("-----------------------SUB_REQUEST_DOWNLOAD_API_RESTORE_0002 is starting-----------------------");
try{
request.download(downloadConfig, (data) => {
downloadTask = data;
console.info("SUB_REQUEST_DOWNLOAD_API_RESTORE_0002 downloadTask: " + downloadTask);
expect(downloadTask != undefined).assertEqual(true);
downloadTask.restore().then(data => {
console.info('SUB_REQUEST_DOWNLOAD_API_RESTORE_0002 Download task restore.');
expect(data == true).assertTrue();
}).catch((err) => {
console.info('SUB_REQUEST_DOWNLOAD_API_RESTORE_0002 Failed to restore the download task.');
expect().assertFail();
});
});
}catch(error){
console.error('SUB_REQUEST_DOWNLOAD_API_RESTORE_0001 restore catch error' + error);
expect().assertFail();
}
console.info("-----------------------SUB_REQUEST_DOWNLOAD_API_RESTORE_0002 end-----------------------");
done();
});
/**
* @tc.number SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0001
* @tc.desc Get the download task info
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
*/
it('SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0001', 0, async function (done) {
console.info("---------------------SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0001 is starting---------------------");
try{
request.download(downloadConfig, (data) => {
downloadTask = data;
console.info("SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0001 downloadTask: " + downloadTask);
expect(downloadTask != undefined).assertEqual(true);
downloadTask.getTaskInfo((err, data) => {
if (err) {
console.error('SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0001 Failed to getTaskInfo the download task.');
expect().assertFail();
}
console.info('SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0001 Download getTaskInfo success.');
expect(typeof data == "object").assertTrue();
});
});
}catch(error){
console.error('SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0001 getTaskInfo catch error' + error);
expect().assertFail();
}
console.info("-----------------------SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0001 end-----------------------");
done();
});
/**
* @tc.number SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0002
* @tc.desc Get the download task info
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
*/
it('SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0002', 0, async function (done) {
console.info("-------------------SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0002 is starting----------------------");
try{
request.download(downloadConfig, (data) => {
downloadTask = data;
console.info("SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0002 downloadTask: " + downloadTask);
expect(downloadTask != undefined).assertEqual(true);
downloadTask.getTaskInfo().then(data => {
console.info('SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0002 Download task getTaskInfo success.');
expect(typeof data == "object").assertTrue();
}).catch((err) => {
console.error('SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0002 Failed to getTaskInfo the download task.');
expect().assertFail();
});
});
}catch(error){
console.error('SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0001 getTaskInfo catch error' + error);
expect().assertFail();
}
console.info("-----------------------SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0002 end-----------------------");
done();
});
/**
* @tc.number SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0001
* @tc.desc Get mimetype of the download task
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
*/
it('SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0001', 0, async function (done) {
console.info("---------------------SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0001 is starting---------------------");
try{
request.download(downloadConfig, (data) => {
downloadTask = data;
console.info("SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0001 downloadTask: " + downloadTask);
expect(downloadTask != undefined).assertEqual(true);
downloadTask.getTaskMimeType((err, data) => {
if (err) {
console.error('SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0001 Failed to getTaskMimeType the download task.');
expect().assertFail();
}
console.info('SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0001 Download task getTaskMimeType success.');
expect(typeof data == "string").assertTrue();
});
});
}catch(error){
console.error('SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0001 getTaskMimeType catch error' + error);
expect().assertFail();
}
console.info("-----------------------SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0001 end-----------------------");
done();
});
/**
* @tc.number SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0002
* @tc.desc Get mimetype of the download task
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
*/
it('SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0002', 0, async function (done) {
console.info("-------------------SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0002 is starting----------------------");
try{
request.download(downloadConfig, (data) => {
downloadTask = data;
console.info("SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0002 downloadTask: " + downloadTask);
expect(downloadTask != undefined).assertEqual(true);
downloadTask.getTaskMimeType().then(data => {
console.info('SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0002 Download getTaskMimeType success.');
expect(typeof data == "string").assertTrue();
}).catch((err) => {
console.error('SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0002 Failed to getTaskMimeType the download task.');
expect().assertFail();
});
});
}catch(error){
console.error('SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0001 getTaskMimeType catch error' + error);
expect().assertFail();
}
console.info("-----------------------SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0002 end-----------------------");
done();
});
})
}
......@@ -376,5 +376,67 @@ export default function requestUploadJSUnit() {
done();
});
/**
* @tc.number SUB_REQUEST_UPLOAD_API_DELETE_0001
* @tc.desc Delete the upload task.
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
*/
it('SUB_REQUEST_UPLOAD_API_DELETE_0001', 0, async function (done) {
console.info("-----------------------SUB_REQUEST_UPLOAD_API_DELETE_0001 is starting-----------------------");
try {
request.upload(uploadConfig, (data) => {
uploadTask = data;
console.info("SUB_REQUEST_UPLOAD_API_DELETE_0001 uploadTask: " + uploadTask);
expect(uploadTask != undefined).assertEqual(true);
uploadTask.delete((err, data) => {
if (err) {
console.error('SUB_REQUEST_UPLOAD_API_DELETE_0001 Failed to delete the uploadTask task.');
expect().assertFail();
}
console.info('SUB_REQUEST_UPLOAD_API_DELETE_0001 uploadTask task delete success.');
expect(typeof data == "boolean").assertTrue();
});
})
} catch (error) {
console.error('SUB_REQUEST_UPLOAD_API_DELETE_0001 delete catch error' + error);
expect().assertFail();
}
console.info("-----------------------SUB_REQUEST_UPLOAD_API_DELETE_0001 end-----------------------");
done();
});
/**
* @tc.number SUB_REQUEST_UPLOAD_API_DELETE_0002
* @tc.desc Delete the upload task.
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
*/
it('SUB_REQUEST_UPLOAD_API_DELETE_0002', 0, async function (done) {
console.info("-----------------------SUB_REQUEST_UPLOAD_API_DELETE_0002 is starting-----------------------");
try {
request.upload(uploadConfig, (data) => {
uploadTask = data;
console.info("SUB_REQUEST_UPLOAD_API_DELETE_0002 uploadTask: " + uploadTask);
expect(uploadTask != undefined).assertEqual(true);
uploadTask.delete().then(data => {
console.info('SUB_REQUEST_UPLOAD_API_DELETE_0002 uploadTask task delete success.');
expect(data == true).assertTrue();
}).catch((err) => {
console.info('SUB_REQUEST_UPLOAD_API_DELETE_0002 Failed to delete the uploadTask task.');
expect().assertFail();
})
})
} catch (error) {
console.error('SUB_REQUEST_UPLOAD_API_DELETE_0002 delete catch error');
expect().assertFail();
}
console.info("-----------------------SUB_REQUEST_UPLOAD_API_DELETE_0002 end-----------------------");
done();
});
})
}
......@@ -33,6 +33,59 @@ export default function screenLockJSUnit() {
return;
}
}
/*
* @tc.number SUB_MISC_THEME_screenLock_API_0012
* @tc.name Test unlock() to Unlocks the screen.
* @tc.desc Function test
* @tc.level 0
*/
it('SUB_MISC_THEME_screenLock_API_0012', 0, async function (done) {
console.info('------------------SUB_MISC_THEME_screenLock_API_0012 start----------------------');
try{
screenLock.unlock((error, data) => {
if (error) {
console.error(`SUB_MISC_THEME_screenLock_API_0012 failed because: ` + JSON.stringify(error));
expect().assertFail();
done();
}
console.log(`SUB_MISC_THEME_screenLock_API_0012 success.`);
expect(true).assertTrue();
done();
});
}catch(err){
console.info('SUB_MISC_THEME_screenLock_API_0012 catch err : ' + JSON.stringify(err));
expect().assertFail();
done();
}
console.info('------------------SUB_MISC_THEME_screenLock_API_0012 end----------------------');
})
/*
* @tc.number SUB_MISC_THEME_screenLock_API_0013
* @tc.name Test unlock() to Unlocks the screen.
* @tc.desc Function test
* @tc.level 0
*/
it('SUB_MISC_THEME_screenLock_API_0013', 0, async function (done) {
console.info('------------------SUB_MISC_THEME_screenLock_API_0013 start----------------------');
try{
screenLock.unlock().then((data) => {
console.log(`SUB_MISC_THEME_screenLock_API_0013 success.`);
expect(true).assertTrue();
done();
}).catch( err => {
console.error(`SUB_MISC_THEME_screenLock_API_0013 failed because: ` + JSON.stringify(err));
expect().assertFail();
done();
});
}catch(err){
console.info('SUB_MISC_THEME_screenLock_API_0013 catch err : ' + JSON.stringify(err));
expect().assertFail();
done();
}
console.info('------------------SUB_MISC_THEME_screenLock_API_0013 end----------------------');
});
/*
* @tc.number SUB_MISC_THEME_screenLock_API_0001
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册