未验证 提交 87f19506 编写于 作者: 高曦 提交者: Gitee

update HttpJsunit.test.ets.

Signed-off-by: N高曦 <gaoxi785@huawei.com>
上级 17d57c40
/* /*
* Copyright (C) 2021-2022 Huawei Device Co., Ltd. * Copyright (C) 2021-2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the 'License') * Licensed under the Apache License, Version 2.0 (the 'License')
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
...@@ -16,6 +16,7 @@ import {describe, it, expect} from '@ohos/hypium'; ...@@ -16,6 +16,7 @@ import {describe, it, expect} from '@ohos/hypium';
import http from '@ohos.net.http'; import http from '@ohos.net.http';
import connection from "@ohos.net.connection"; import connection from "@ohos.net.connection";
import socket from '@ohos.net.socket'; import socket from '@ohos.net.socket';
import ethernet from '@ohos.net.ethernet';
export default function httpJsunit() { export default function httpJsunit() {
describe("httpJsunitTest", function () { describe("httpJsunitTest", function () {
...@@ -108,7 +109,6 @@ export default function httpJsunit() { ...@@ -108,7 +109,6 @@ export default function httpJsunit() {
} else { } else {
console.log(`${caseName} getDefaultHttpProxy success`); console.log(`${caseName} getDefaultHttpProxy success`);
expect(error).assertEqual(undefined); expect(error).assertEqual(undefined);
expect(data != '').assertTrue();
done(); done();
} }
}); });
...@@ -123,7 +123,6 @@ export default function httpJsunit() { ...@@ -123,7 +123,6 @@ export default function httpJsunit() {
let caseName = 'Telephony_NetworkManager_getDefaultHttpProxy_Promise_0100'; let caseName = 'Telephony_NetworkManager_getDefaultHttpProxy_Promise_0100';
connection.getDefaultHttpProxy().then((data) => { connection.getDefaultHttpProxy().then((data) => {
console.log(`${caseName} getDefaultHttpProxy success`); console.log(`${caseName} getDefaultHttpProxy success`);
expect(data != '').assertTrue();
done(); done();
}).catch((error) => { }).catch((error) => {
console.log(JSON.stringify(error)); console.log(JSON.stringify(error));
...@@ -150,7 +149,6 @@ export default function httpJsunit() { ...@@ -150,7 +149,6 @@ export default function httpJsunit() {
done(); done();
} else { } else {
console.log(`${caseName} getDefaultHttpProxy success`); console.log(`${caseName} getDefaultHttpProxy success`);
expect(data != '').assertTrue();
done(); done();
} }
}); });
...@@ -179,7 +177,6 @@ export default function httpJsunit() { ...@@ -179,7 +177,6 @@ export default function httpJsunit() {
console.log("setAppNet success"); console.log("setAppNet success");
connection.getDefaultHttpProxy().then((data) => { connection.getDefaultHttpProxy().then((data) => {
console.log(`${caseName} getDefaultHttpProxy success`); console.log(`${caseName} getDefaultHttpProxy success`);
expect(data != '').assertTrue();
done(); done();
}).catch((error) => { }).catch((error) => {
console.log(JSON.stringify(error)); console.log(JSON.stringify(error));
...@@ -204,20 +201,27 @@ export default function httpJsunit() { ...@@ -204,20 +201,27 @@ export default function httpJsunit() {
* @tc.desc Function test * @tc.desc Function test
*/ */
it('Telephony_Connection_Request_Socket_0100', 0, async function (done) { it('Telephony_Connection_Request_Socket_0100', 0, async function (done) {
try{
let caseName = 'Telephony_Connection_Request_Socket_0100'; let caseName = 'Telephony_Connection_Request_Socket_0100';
type HttpRequest = http.HttpRequest;
type HttpProxy = connection.HttpProxy; type HttpProxy = connection.HttpProxy;
type TCPSocket = socket.TCPSocket; type TCPSocket = socket.TCPSocket;
type UDPSocket = socket.UDPSocket; type UDPSocket = socket.UDPSocket;
Test(http.createHttp(),socket.constructTCPSocketInstance(),socket.constructUDPSocketInstance()); Test(http.createHttp(),socket.constructTCPSocketInstance(),socket.constructUDPSocketInstance());
function Test(httpProxy:HttpProxy,tcpSocket:TCPSocket,udpSocket:UDPSocket){ function Test(httpRequest :HttpRequest,tcpSocket:TCPSocket,udpSocket:UDPSocket){
except(httpProxy != null).assertTrue(); except(httpRequest != null).assertTrue();
except(tcpSocket != null).assertTrue(); except(tcpSocket != null).assertTrue();
except(udpSocket != null).assertTrue(); except(udpSocket != null).assertTrue();
httpRequest.destroy(); httpRequest.destroy();
tcpSocket.close(); tcpSocket.close();
udp.close(); udpSocket.close();
done(); done();
} }
} catch (error) {
console.info("Telephony_Connection_Request_Socket_0100 catch " + error);
done();
}
});
}); });
} }
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册