提交 8bd1584f 编写于 作者: B bayanxing

add test cases

Signed-off-by: Nbayanxing <bayanxing@kaihongdigi.com>
上级 45164681
...@@ -335,5 +335,177 @@ export default function requestDownloadJsunit() { ...@@ -335,5 +335,177 @@ export default function requestDownloadJsunit() {
done(); done();
}); });
/**
* @tc.number requestDownload_test_015
* @tc.name Test The request DownloadTask
* @tc.desc Function test
*/
it('requestDownload_test_015', 0, async function (done) {
try {
request.download(downloadConfig, (downloadTask) => {
console.log("downloadConfig result:" + JSON.stringify(downloadTask))
downloadTask.remove().then((result) => {
console.info('requestDownload_test_015 Download task removed result=' + result);
expect(true).assertTrue();
}).catch ((err) => {
console.log("requestDownload_test_015 downloadTask remove err:" + err);
expect(true).assertTrue();
});
});
} catch (exception) {
console.log("requestDownload_test_015 failed due to execute timeout 5s");
expect(true).assertTrue();
}
done();
});
/**
* @tc.number requestDownload_test_016
* @tc.name Test The request DownloadTask
* @tc.desc Function test
*/
it('requestDownload_test_016', 0, async function (done) {
try {
request.download(downloadConfig, (downloadTask) => {
console.log("downloadConfig result:" + JSON.stringify(downloadTask))
downloadTask.query().then((downloadInfo) => {
console.info('requestDownload_test_016 Data:' + JSON.stringify(downloadInfo));
expect(true).assertTrue();
}) .catch((err) => {
console.log("downloadTask query err:" + err);
expect(true).assertTrue();
});
});
} catch (err) {
console.log("requestDownload_test_016 invoke download error : " + JSON.stringify(err));
expect(true).assertTrue();
}
done();
});
/**
* @tc.number requestDownload_test_017
* @tc.name Test The request DownloadTask
* @tc.desc Function test
*/
it('requestDownload_test_017', 0, async function (done) {
try {
request.download(downloadConfig, (downloadTask) => {
console.log("downloadConfig result:" + JSON.stringify(downloadTask))
downloadTask.queryMimeType().then((data) => {
console.info('requestDownload_test_017. Data:' + JSON.stringify(data));
expect(true).assertTrue();
}).catch((err) => {
console.log("downloadTask queryMimeType err:" + err);
expect(true).assertTrue();
});
});
} catch (exception) {
console.log("requestDownload_test_017 failed due to execute timeout 5s");
expect(true).assertTrue();
}
done();
});
/**
* @tc.number requestDownload_test_018
* @tc.name Test The request DownloadTask
* @tc.desc Function test
*/
it('requestDownload_test_018', 0, async function (done) {
try {
request.download(downloadConfig, (downloadTask) => {
console.log("downloadConfig result:" + JSON.stringify(downloadTask))
downloadTask.pause().then((data) => {
console.info('requestDownload_test_018. Data:' + JSON.stringify(data));
expect(true).assertTrue();
}).catch((err) => {
console.log("requestDownload_test_018 err:" + err);
expect(true).assertTrue();
});
});
} catch (exception) {
console.log("requestDownload_test_018 failed due to execute timeout 5s");
expect(true).assertTrue();
}
done();
});
/**
* @tc.number requestDownload_test_019
* @tc.name Test The request DownloadTask
* @tc.desc Function test
*/
it('requestDownload_test_019', 0, async function (done) {
try {
request.download(downloadConfig, (downloadTask) => {
console.log("downloadConfig result:" + JSON.stringify(downloadTask))
downloadTask.pause((err, result)=>{
if(err) {
console.error('requestDownload_test_019 error:' + JSON.stringify(err));
expect(true).assertTrue();
} else {
console.info('requestDownload_test_019. result:' + JSON.stringify(result));
expect(true).assertTrue();
}
});
});
} catch (exception) {
console.log("requestDownload_test_019 failed due to execute timeout 5s");
expect(true).assertTrue();
}
done();
});
/**
* @tc.number requestDownload_test_020
* @tc.name Test The request DownloadTask
* @tc.desc Function test
*/
it('requestDownload_test_020', 0, async function (done) {
try {
request.download(downloadConfig, (downloadTask) => {
console.log("downloadConfig result:" + JSON.stringify(downloadTask))
downloadTask.resume().then((data) => {
console.info('requestDownload_test_020. Data:' + JSON.stringify(data));
expect(true).assertTrue();
}).catch((err) => {
console.log("requestDownload_test_020 err:" + err);
expect(true).assertTrue();
});
});
} catch (exception) {
console.log("requestDownload_test_020 failed due to execute timeout 5s");
expect(true).assertTrue();
}
done();
});
/**
* @tc.number requestDownload_test_021
* @tc.name Test The request DownloadTask
* @tc.desc Function test
*/
it('requestDownload_test_021', 0, async function (done) {
try {
request.download(downloadConfig, (downloadTask) => {
console.log("downloadConfig result:" + JSON.stringify(downloadTask))
downloadTask.resume((err, result)=>{
if(err) {
console.error('requestDownload_test_021 error:' + JSON.stringify(err));
expect(true).assertTrue();
} else {
console.info('requestDownload_test_021. result:' + JSON.stringify(result));
expect(true).assertTrue();
}
});
});
} catch (exception) {
console.log("requestDownload_test_021 failed due to execute timeout 5s");
expect(true).assertTrue();
}
done();
});
}) })
} }
\ No newline at end of file
...@@ -196,7 +196,44 @@ export default function requestJsunit() { ...@@ -196,7 +196,44 @@ export default function requestJsunit() {
console.log("-----------------------request_upload_0006 end-----------------------"); console.log("-----------------------request_upload_0006 end-----------------------");
done(); done();
}) })
});
/**
* @tc.name: ohos.request_request_upload_0007
* @tc.desc: request_upload Method detection
*/
it('request_upload_0007', 0, async function (done) {
console.log("-----------------------request_upload_0007 is starting-----------------------");
try {
console.log("request_upload_0007 getUploadConfig() " + getUploadConfig());
request.upload(getUploadConfig(), (err, uploadTask) => {
if (err) {
expect().assertFail();
} else {
console.log("request_upload_0007 progress uploadTask =" + JSON.stringify(uploadTask));
uploadTask.on('headerReceive', function (data1, data2) {
console.log("request_upload_0007 headerReceive on data1 =" + data1);
console.log("request_upload_0007 headerReceive on data2 =" + data2);
}) })
uploadTask.off('headerReceive', function (data1, data2) {
console.log("request_upload_0007 headerReceive off data1 =" + data1);
console.log("request_upload_0007 headerReceive off data2 =" + data2);
})
uploadTask.remove().then((result) => {
console.log("request_upload_0006 remove =" + result);
}).catch((err) => {
console.error('Failed to remove the upload task. Cause: ' + JSON.stringify(err));
});
}
})
} catch (err) {
expect(true).assertEqual(true);
console.error("request_upload_0007 error: " + err);
}
console.log("-----------------------request_upload_0007 end-----------------------");
done();
})
});
function getUploadConfig() { function getUploadConfig() {
let file = { let file = {
......
...@@ -270,6 +270,58 @@ export default function httpRequestJsunit() { ...@@ -270,6 +270,58 @@ export default function httpRequestJsunit() {
} }
}); });
/**
* @tc.number Telephony_http_HttpRequest_off_headersReceive_0200
* @tc.name httprequest::off_headersReceive
* @tc.desc Test Test httprequest property.
*/
it("Telephony_http_HttpRequest_off_headersReceive_0200", 0, function (done) {
var casename = "Telephony_http_HttpRequest_off_headersReceive_0200"
console.log("-----------------------HttpRequest_off_headersReceive Test is starting-----------------------");
try {
var httpRequest = http.createHttp();
if (utils.notCheck) {
expect(true).assertTrue();
done();
return;
}
httpRequest.off('headersReceive');
expect(true).assertTrue();
console.log("-----------------------HttpRequest_off_headersReceive_0200 Test end-----------------------");
done();
} catch (error) {
console.log("Telephony_http_HttpRequest_off_headersReceive_0200 : error = " + error);
done();
}
});
/**
* @tc.number Telephony_http_HttpRequest_once_headersReceive_0100
* @tc.name httprequest::once_headersReceive
* @tc.desc Test Test httprequest property.
*/
it("Telephony_http_HttpRequest_once_headersReceive_0100", 0, function (done) {
var casename = "Telephony_http_HttpRequest_once_headersReceive_0100"
console.log("-----------------------HttpRequest_once_headersReceive Test is starting-----------------------");
try {
var httpRequest = http.createHttp();
if (utils.notCheck) {
expect(true).assertTrue();
done();
return;
}
httpRequest.once('headersReceive', (data) => {
console.log(casename + " data: " + JSON.stringify(data));
expect(true).assertTrue();
console.log("-----------------------HttpRequest_on_headersReceive Test end-----------------------");
done();
});
} catch (error) {
console.log("Telephony_http_HttpRequest_once_headersReceive_010 : error = " + error);
done();
}
});
}) })
......
...@@ -113,6 +113,47 @@ export default function connectionSecondJsUnit() { ...@@ -113,6 +113,47 @@ export default function connectionSecondJsUnit() {
done(); done();
}); });
/**
* @tc.name: 'Telephony_connection_getConnectionProperties_Promise_0200
* @tc.desc: getConnectionProperties detection
*/
it('Telephony_connection_getConnectionProperties_Promise_0200', 0, function (done) {
console.log("----------Telephony_connection_getConnectionProperties_Promise_0200 Test is starting------");
if(false){
expect(true).assertTrue();
done();
return;
}
let caseName = 'Telephony_connection_getConnectionProperties_Promise_0200';
connection.getAllNets((error, data) => {
if (error) {
console.log(`${caseName} get data fail: ${error}`);
expect().assertTrue();
done();
} else {
console.log(`${caseName} get netID value : ${JSON.stringify(data[0])}`);
connection.getConnectionProperties(data[0]).then((value) => {
console.log(`${caseName} get value success: ${JSON.stringify(value)}`);
console.log(caseName + " ifaceName: " + value.ifaceName);
console.log(caseName + " mtu: " + value.mtu);
console.log(caseName + " netAddrList.length: " + value.netAddrList.length);
expect(value.ifaceName == "").assertTrue();
expect(value.domain == "").assertTrue();
expect(value.mtu == 0).assertTrue();
expect(value.netAddrList.length == 0).assertTrue();
expect(value.dnsList.length == 0).assertTrue();
expect(value.routeList.length == 0).assertTrue();
done();
}).catch((error) => {
console.log(`${caseName} getConnectionProperties fail: ${error}`);
expect().assertFail();
done();
});
}
console.log("-----------------------Telephony getConnectionProperties Test end-----------------------");
done();
});
/** /**
* @tc.name: Telephony_connection_RouteInfo_0300 * @tc.name: Telephony_connection_RouteInfo_0300
* @tc.desc: RouteInfo Properties detection * @tc.desc: RouteInfo Properties detection
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册