提交 e1b70d01 编写于 作者: H hu0475

完成telephony子系统Connection模块的跨平台测试套 完成telephony子系统WebSocket模块的跨平台测试套

Signed-off-by: Nhu0475 <huyanqiang5@huawei.com>
上级 3c0a9009
...@@ -14,13 +14,7 @@ ...@@ -14,13 +14,7 @@
group("telephony") { group("telephony") {
testonly = true testonly = true
deps = [ deps = [
<<<<<<< HEAD
"telephonyjstest:telephonyjstest",
"crossplatform:crossplatform",
]
=======
"crossplatform:crossplatform", "crossplatform:crossplatform",
"telephonyjstest:telephonyjstest", "telephonyjstest:telephonyjstest",
] ]
>>>>>>> c661a9d77ed4eae4068dadf859aa14d46767d4a4
} }
...@@ -16,13 +16,8 @@ group("crossplatform") { ...@@ -16,13 +16,8 @@ group("crossplatform") {
testonly = true testonly = true
if (is_standard_system) { if (is_standard_system) {
deps = [ deps = [
<<<<<<< HEAD
"telephonyConnectionetstest:ActsCrossPlatformConnectionTest", "telephonyConnectionetstest:ActsCrossPlatformConnectionTest",
"telephonyWebSocketetstest:ActsCrossPlatformWebSocketTest", "telephonyWebSocketetstest:ActsCrossPlatformWebSocketTest",
=======
"telephonyConnectionetstest:Connection_ets_test",
"telephonyWebSocketetstest:WebSocket_ets_test",
>>>>>>> c661a9d77ed4eae4068dadf859aa14d46767d4a4
] ]
} }
} }
...@@ -6,17 +6,10 @@ ...@@ -6,17 +6,10 @@
"versionName": "1.0.0", "versionName": "1.0.0",
"icon": "$media:app_icon", "icon": "$media:app_icon",
"label": "$string:app_name", "label": "$string:app_name",
<<<<<<< HEAD
"minAPIVersion": 10, "minAPIVersion": 10,
"targetAPIVersion": 10, "targetAPIVersion": 10,
"car": { "car": {
"apiCompatibleVersion": 10, "apiCompatibleVersion": 10,
=======
"minAPIVersion": 9,
"targetAPIVersion": 9,
"car": {
"apiCompatibleVersion": 9,
>>>>>>> c661a9d77ed4eae4068dadf859aa14d46767d4a4
"singleUser": false "singleUser": false
} }
} }
......
<<<<<<< HEAD
# Copyright (C) 2023 Huawei Device Co., Ltd. # Copyright (C) 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.
...@@ -14,11 +13,6 @@ ...@@ -14,11 +13,6 @@
import("//test/xts/tools/build/suite.gni") import("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("ActsCrossPlatformConnectionTest") { ohos_js_hap_suite("ActsCrossPlatformConnectionTest") {
=======
import("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("Connection_ets_test") {
>>>>>>> c661a9d77ed4eae4068dadf859aa14d46767d4a4
hap_profile = "src/main/module.json" hap_profile = "src/main/module.json"
deps = [ deps = [
":windowStage_js_assets", ":windowStage_js_assets",
...@@ -26,24 +20,16 @@ ohos_js_hap_suite("Connection_ets_test") { ...@@ -26,24 +20,16 @@ ohos_js_hap_suite("Connection_ets_test") {
] ]
ets2abc = true ets2abc = true
certificate_profile = "./signature/openharmony_sx.p7b" certificate_profile = "./signature/openharmony_sx.p7b"
<<<<<<< HEAD
# hap_name: HAP的名字,可选,默认为目标名
hap_name = "ActsCrossPlatformConnectionTest"
=======
# hap_name: HAP的名字,可选,默认为目标名 # hap_name: HAP的名字,可选,默认为目标名
hap_name = "Connection_ets_test" hap_name = "ActsCrossPlatformConnectionTest"
>>>>>>> c661a9d77ed4eae4068dadf859aa14d46767d4a4
subsystem_name = "communication" subsystem_name = "communication"
part_name = "netstack" part_name = "netstack"
} }
ohos_app_scope("windowStage_app_profile") { ohos_app_scope("windowStage_app_profile") {
# app_profile: HAP的AppScope中的app.json,只在Stage模型下使用 # app_profile: HAP的AppScope中的app.json,只在Stage模型下使用
app_profile = "AppScope/app.json" app_profile = "AppScope/app.json"
<<<<<<< HEAD
=======
>>>>>>> c661a9d77ed4eae4068dadf859aa14d46767d4a4
# sources: 资源文件路径 # sources: 资源文件路径
sources = [ "AppScope/resources" ] sources = [ "AppScope/resources" ]
} }
...@@ -54,13 +40,6 @@ ohos_js_assets("windowStage_js_assets") { ...@@ -54,13 +40,6 @@ ohos_js_assets("windowStage_js_assets") {
ohos_resources("windowStage_resources") { ohos_resources("windowStage_resources") {
# sources: 资源文件路径 # sources: 资源文件路径
sources = [ "src/main/resources" ] sources = [ "src/main/resources" ]
<<<<<<< HEAD
# deps: 当前目标的依赖
deps = [ ":windowStage_app_profile" ]
# hap_profile: HAP的config.json,Stage模型对应module.json
hap_profile = "src/main/module.json"
}
=======
# deps: 当前目标的依赖 # deps: 当前目标的依赖
deps = [ ":windowStage_app_profile" ] deps = [ ":windowStage_app_profile" ]
...@@ -68,4 +47,3 @@ ohos_resources("windowStage_resources") { ...@@ -68,4 +47,3 @@ ohos_resources("windowStage_resources") {
# hap_profile: HAP的config.json,Stage模型对应module.json # hap_profile: HAP的config.json,Stage模型对应module.json
hap_profile = "src/main/module.json" hap_profile = "src/main/module.json"
} }
>>>>>>> c661a9d77ed4eae4068dadf859aa14d46767d4a4
<<<<<<< HEAD
/** /**
* Copyright (c) 2023 Huawei Device Co., Ltd. * Copyright (c) 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");
...@@ -13,8 +12,6 @@ ...@@ -13,8 +12,6 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
=======
>>>>>>> c661a9d77ed4eae4068dadf859aa14d46767d4a4
import UIAbility from '@ohos.app.ability.UIAbility'; import UIAbility from '@ohos.app.ability.UIAbility';
import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry'; import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry';
import hilog from '@ohos.hilog'; import hilog from '@ohos.hilog';
......
<<<<<<< HEAD
/** /**
* Copyright (c) 2023 Huawei Device Co., Ltd. * Copyright (c) 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");
...@@ -13,8 +12,6 @@ ...@@ -13,8 +12,6 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
=======
>>>>>>> c661a9d77ed4eae4068dadf859aa14d46767d4a4
import hilog from '@ohos.hilog'; import hilog from '@ohos.hilog';
@Entry @Entry
......
...@@ -6,17 +6,10 @@ ...@@ -6,17 +6,10 @@
"versionName": "1.0.0", "versionName": "1.0.0",
"icon": "$media:app_icon", "icon": "$media:app_icon",
"label": "$string:app_name", "label": "$string:app_name",
<<<<<<< HEAD
"minAPIVersion": 10, "minAPIVersion": 10,
"targetAPIVersion": 10, "targetAPIVersion": 10,
"car": { "car": {
"apiCompatibleVersion": 10, "apiCompatibleVersion": 10,
=======
"minAPIVersion": 9,
"targetAPIVersion": 9,
"car": {
"apiCompatibleVersion": 9,
>>>>>>> c661a9d77ed4eae4068dadf859aa14d46767d4a4
"singleUser": false "singleUser": false
} }
} }
......
<<<<<<< HEAD
# Copyright (C) 2023 Huawei Device Co., Ltd. # Copyright (C) 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.
...@@ -14,11 +13,6 @@ ...@@ -14,11 +13,6 @@
import("//test/xts/tools/build/suite.gni") import("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("ActsCrossPlatformWebSocketTest") { ohos_js_hap_suite("ActsCrossPlatformWebSocketTest") {
=======
import("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("WebSocket_ets_test") {
>>>>>>> c661a9d77ed4eae4068dadf859aa14d46767d4a4
hap_profile = "src/main/module.json" hap_profile = "src/main/module.json"
deps = [ deps = [
":windowStage_js_assets", ":windowStage_js_assets",
...@@ -26,24 +20,16 @@ ohos_js_hap_suite("WebSocket_ets_test") { ...@@ -26,24 +20,16 @@ ohos_js_hap_suite("WebSocket_ets_test") {
] ]
ets2abc = true ets2abc = true
certificate_profile = "./signature/openharmony_sx.p7b" certificate_profile = "./signature/openharmony_sx.p7b"
<<<<<<< HEAD
# hap_name: HAP的名字,可选,默认为目标名
hap_name = "ActsCrossPlatformWebSocketTest"
=======
# hap_name: HAP的名字,可选,默认为目标名 # hap_name: HAP的名字,可选,默认为目标名
hap_name = "WebSocket_ets_test" hap_name = "ActsCrossPlatformWebSocketTest"
>>>>>>> c661a9d77ed4eae4068dadf859aa14d46767d4a4
subsystem_name = "communication" subsystem_name = "communication"
part_name = "netstack" part_name = "netstack"
} }
ohos_app_scope("windowStage_app_profile") { ohos_app_scope("windowStage_app_profile") {
# app_profile: HAP的AppScope中的app.json,只在Stage模型下使用 # app_profile: HAP的AppScope中的app.json,只在Stage模型下使用
app_profile = "AppScope/app.json" app_profile = "AppScope/app.json"
<<<<<<< HEAD
=======
>>>>>>> c661a9d77ed4eae4068dadf859aa14d46767d4a4
# sources: 资源文件路径 # sources: 资源文件路径
sources = [ "AppScope/resources" ] sources = [ "AppScope/resources" ]
} }
...@@ -54,13 +40,6 @@ ohos_js_assets("windowStage_js_assets") { ...@@ -54,13 +40,6 @@ ohos_js_assets("windowStage_js_assets") {
ohos_resources("windowStage_resources") { ohos_resources("windowStage_resources") {
# sources: 资源文件路径 # sources: 资源文件路径
sources = [ "src/main/resources" ] sources = [ "src/main/resources" ]
<<<<<<< HEAD
# deps: 当前目标的依赖
deps = [ ":windowStage_app_profile" ]
# hap_profile: HAP的config.json,Stage模型对应module.json
hap_profile = "src/main/module.json"
}
=======
# deps: 当前目标的依赖 # deps: 当前目标的依赖
deps = [ ":windowStage_app_profile" ] deps = [ ":windowStage_app_profile" ]
...@@ -68,4 +47,3 @@ ohos_resources("windowStage_resources") { ...@@ -68,4 +47,3 @@ ohos_resources("windowStage_resources") {
# hap_profile: HAP的config.json,Stage模型对应module.json # hap_profile: HAP的config.json,Stage模型对应module.json
hap_profile = "src/main/module.json" hap_profile = "src/main/module.json"
} }
>>>>>>> c661a9d77ed4eae4068dadf859aa14d46767d4a4
<<<<<<< HEAD
/** /**
* Copyright (c) 2023 Huawei Device Co., Ltd. * Copyright (c) 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");
...@@ -13,8 +12,6 @@ ...@@ -13,8 +12,6 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
=======
>>>>>>> c661a9d77ed4eae4068dadf859aa14d46767d4a4
import UIAbility from '@ohos.app.ability.UIAbility'; import UIAbility from '@ohos.app.ability.UIAbility';
import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry'; import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry';
import hilog from '@ohos.hilog'; import hilog from '@ohos.hilog';
......
<<<<<<< HEAD
/** /**
* Copyright (c) 2023 Huawei Device Co., Ltd. * Copyright (c) 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");
...@@ -13,8 +12,6 @@ ...@@ -13,8 +12,6 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
=======
>>>>>>> c661a9d77ed4eae4068dadf859aa14d46767d4a4
import hilog from '@ohos.hilog'; import hilog from '@ohos.hilog';
@Entry @Entry
......
...@@ -12,10 +12,6 @@ ...@@ -12,10 +12,6 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
<<<<<<< HEAD
=======
>>>>>>> c661a9d77ed4eae4068dadf859aa14d46767d4a4
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '@ohos/hypium' import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '@ohos/hypium'
import webSocket from '@ohos.net.webSocket' import webSocket from '@ohos.net.webSocket'
...@@ -99,24 +95,14 @@ export default function webSocketTest() { ...@@ -99,24 +95,14 @@ export default function webSocketTest() {
*/ */
it('testConnect001', 0, async function (done) { it('testConnect001', 0, async function (done) {
let mWebSocket = webSocket.createWebSocket(); let mWebSocket = webSocket.createWebSocket();
<<<<<<< HEAD
mWebSocket.connect(null, (error, value) => { mWebSocket.connect(null, (error, value) => {
if (!error) { if (!error) {
console.log(`case success11:` + value); console.log(`case success11:` + value);
=======
mWebSocket.connect(serverIpAddress, (error, value) => {
if (!error) {
console.log(`case success11:` + value); //自动化脚本调用所有的跨平台的接口!!!
>>>>>>> c661a9d77ed4eae4068dadf859aa14d46767d4a4
expect(value).assertTrue(); expect(value).assertTrue();
done(); done();
} else { } else {
console.log(`error, case failed,errCode:` + error.code); console.log(`error, case failed,errCode:` + error.code);
<<<<<<< HEAD
expect(error.code).assertEqual(401); expect(error.code).assertEqual(401);
=======
expect().assertFail();
>>>>>>> c661a9d77ed4eae4068dadf859aa14d46767d4a4
done(); done();
} }
}); });
...@@ -139,22 +125,14 @@ export default function webSocketTest() { ...@@ -139,22 +125,14 @@ export default function webSocketTest() {
} }
} }
console.info('webSocket: start11'); console.info('webSocket: start11');
<<<<<<< HEAD
mWebSocket.connect("ws://19211.16811.1.100:8081/string", webSocketRequestOptions, (error, value) => { mWebSocket.connect("ws://19211.16811.1.100:8081/string", webSocketRequestOptions, (error, value) => {
=======
mWebSocket.connect(serverIpAddress, webSocketRequestOptions, (error, value) => {
>>>>>>> c661a9d77ed4eae4068dadf859aa14d46767d4a4
if (!error) { if (!error) {
console.log(`case success11:` + value); console.log(`case success11:` + value);
expect(value).assertTrue(); expect(value).assertTrue();
done(); done();
} else { } else {
console.log(`error, case failed,errCode:` + error.code); console.log(`error, case failed,errCode:` + error.code);
<<<<<<< HEAD
expect(error.code).assertEqual(-1); expect(error.code).assertEqual(-1);
=======
expect().assertFail();
>>>>>>> c661a9d77ed4eae4068dadf859aa14d46767d4a4
done(); done();
} }
}); });
...@@ -170,7 +148,6 @@ export default function webSocketTest() { ...@@ -170,7 +148,6 @@ export default function webSocketTest() {
*/ */
it('testConnect003', 0, async function (done) { it('testConnect003', 0, async function (done) {
let mWebSocket = webSocket.createWebSocket(); let mWebSocket = webSocket.createWebSocket();
<<<<<<< HEAD
mWebSocket.connect("", (error, value) => { mWebSocket.connect("", (error, value) => {
if (!error) { if (!error) {
console.log(`case success11:` + value); console.log(`case success11:` + value);
...@@ -181,41 +158,6 @@ export default function webSocketTest() { ...@@ -181,41 +158,6 @@ export default function webSocketTest() {
expect(error.code).assertEqual(-1); expect(error.code).assertEqual(-1);
done(); done();
} }
=======
let webSocketRequestOptions: webSocket.WebSocketRequestOptions = {
header: "test header"
}
console.info('webSocket: start11');
mWebSocket.connect(serverIpAddress, webSocketRequestOptions).then(value => {
console.log(`case success,data:` + value);
expect(value).assertTrue();
done();
}).catch((error) => {
console.log(`error, case failed,errCode:` + error.code);
expect().assertFail();
done();
});
});
/*
* @tc.number: TEST_CONNECT_004
* @tc.name : testConnect004
* @tc.desc : Initiates a WebSocket request to establish a WebSocket connection to a given URL.
* @tc.size : MediumTest
* @tc.type : Method
* @tc.level : Level 2
*/
it('testConnect004', 0, async function (done) {
let mWebSocket = webSocket.createWebSocket();
mWebSocket.connect(serverIpAddress).then(value => {
console.log(`case success,data:` + value);
expect(value).assertTrue();
done();
}).catch((error) => {
console.log(`error, case failed,errCode:` + error.code);
expect().assertFail();
done();
>>>>>>> c661a9d77ed4eae4068dadf859aa14d46767d4a4
}); });
}); });
...@@ -229,7 +171,6 @@ export default function webSocketTest() { ...@@ -229,7 +171,6 @@ export default function webSocketTest() {
*/ */
it('testSend001', 0, async function (done) { it('testSend001', 0, async function (done) {
let mWebSocket = webSocket.createWebSocket(); let mWebSocket = webSocket.createWebSocket();
<<<<<<< HEAD
mWebSocket.send("test data", (error, value) => { mWebSocket.send("test data", (error, value) => {
if (!error) { if (!error) {
console.log(`case success,data:` + value); console.log(`case success,data:` + value);
...@@ -240,20 +181,6 @@ export default function webSocketTest() { ...@@ -240,20 +181,6 @@ export default function webSocketTest() {
expect(error.code).assertEqual(2302999); expect(error.code).assertEqual(2302999);
done(); done();
} }
=======
mWebSocket.connect(serverIpAddress, (error, data) => {
mWebSocket.send("test data", (error, value) => {
if (!error) {
console.log(`case success,data:` + value);
expect(value).assertTrue();
done();
} else {
console.log(`error, case failed,errCode:` + error.code);
expect().assertFail();
done();
}
});
>>>>>>> c661a9d77ed4eae4068dadf859aa14d46767d4a4
}); });
}); });
...@@ -267,7 +194,6 @@ export default function webSocketTest() { ...@@ -267,7 +194,6 @@ export default function webSocketTest() {
*/ */
it('testSend002', 0, async function (done) { it('testSend002', 0, async function (done) {
let mWebSocket = webSocket.createWebSocket(); let mWebSocket = webSocket.createWebSocket();
<<<<<<< HEAD
let promise = mWebSocket.send("test data"); let promise = mWebSocket.send("test data");
promise.then(value => { promise.then(value => {
console.log(`case success,data:` + value); console.log(`case success,data:` + value);
...@@ -277,19 +203,6 @@ export default function webSocketTest() { ...@@ -277,19 +203,6 @@ export default function webSocketTest() {
console.log(`error, case failed,errCode:` + error.code); console.log(`error, case failed,errCode:` + error.code);
expect(error.code).assertEqual(2302999); expect(error.code).assertEqual(2302999);
done(); done();
=======
mWebSocket.connect(serverIpAddress, (error, data) => {
let promise = mWebSocket.send("test data");
promise.then(value => {
console.log(`case success,data:` + value);
expect(value).assertTrue();
done();
}).catch((error) => {
console.log(`error, case failed,errCode:` + error.code);
expect().assertFail();
done();
});
>>>>>>> c661a9d77ed4eae4068dadf859aa14d46767d4a4
}); });
}); });
...@@ -303,44 +216,12 @@ export default function webSocketTest() { ...@@ -303,44 +216,12 @@ export default function webSocketTest() {
*/ */
it('testSend003', 0, async function (done) { it('testSend003', 0, async function (done) {
let mWebSocket = webSocket.createWebSocket(); let mWebSocket = webSocket.createWebSocket();
<<<<<<< HEAD
=======
var str = "Hello";
for (var i = 0; i < 200; i++) {
str += "Hello";
}
mWebSocket.connect(serverIpAddress, (error, data) => {
let promise = mWebSocket.send(str);
promise.then(value => {
console.log(`case success,data:` + value);
expect(value).assertTrue();
done();
}).catch((error) => {
console.log(`error, case failed,errCode:` + error.code);
expect().assertFail();
done();
});
});
});
/*
* @tc.number: TEST_SEND_004
* @tc.name : testSend004
* @tc.desc : Sends data through a WebSocket connection.
* @tc.size : MediumTest
* @tc.type : Method
* @tc.level : Level 2
*/
it('testSend004', 0, async function (done) {
let mWebSocket = webSocket.createWebSocket();
>>>>>>> c661a9d77ed4eae4068dadf859aa14d46767d4a4
var str = "Hello, server!(arrayBuffer promise mode)"; var str = "Hello, server!(arrayBuffer promise mode)";
var buf = new ArrayBuffer(str.length); var buf = new ArrayBuffer(str.length);
var message = new Uint8Array(buf); var message = new Uint8Array(buf);
for (var i = 0, strLen = str.length; i < strLen; i++) { for (var i = 0, strLen = str.length; i < strLen; i++) {
message[i] = str.charCodeAt(i); message[i] = str.charCodeAt(i);
} }
<<<<<<< HEAD
let promise = mWebSocket.send(message.buffer); let promise = mWebSocket.send(message.buffer);
promise.then(value => { promise.then(value => {
console.log(`case success,data:` + value); console.log(`case success,data:` + value);
...@@ -350,19 +231,6 @@ export default function webSocketTest() { ...@@ -350,19 +231,6 @@ export default function webSocketTest() {
console.log(`error, case failed,errCode:` + error.code); console.log(`error, case failed,errCode:` + error.code);
expect(error.code).assertEqual(2302999); expect(error.code).assertEqual(2302999);
done(); done();
=======
mWebSocket.connect(serverIpAddress, (error, data) => {
let promise = mWebSocket.send(message.buffer);
promise.then(value => {
console.log(`case success,data:` + value);
expect(value).assertTrue();
done();
}).catch((error) => {
console.log(`error, case failed,errCode:` + error.code);
expect().assertFail();
done();
});
>>>>>>> c661a9d77ed4eae4068dadf859aa14d46767d4a4
}); });
}); });
...@@ -376,90 +244,6 @@ export default function webSocketTest() { ...@@ -376,90 +244,6 @@ export default function webSocketTest() {
*/ */
it('testClose001', 0, async function (done) { it('testClose001', 0, async function (done) {
let mWebSocket = webSocket.createWebSocket(); let mWebSocket = webSocket.createWebSocket();
<<<<<<< HEAD
=======
mWebSocket.connect(serverIpAddress, (error, data) => {
mWebSocket.close((error, value) => {
if (!error) {
console.log(`case success:` + value);
expect(value).assertTrue();
done();
} else {
console.log(`error, case failed,errCode:` + error.code);
expect(error.code).assertEqual(2302999);
done(); //补上on、off的接口,触发10次,每次都能监听到!!!
}
});
});
});
/*
* @tc.number: TEST_CLOSE_002
* @tc.name : testClose002
* @tc.desc : Closes a WebSocket connection.
* @tc.size : MediumTest
* @tc.type : Method
* @tc.level : Level 2
*/
it('testClose002', 0, async function (done) {
let mWebSocket = webSocket.createWebSocket();
let webSocketCloseOptions: webSocket.WebSocketCloseOptions = {
code: 1,
reason: "test reason"
}
mWebSocket.connect(serverIpAddress, (error, data) => {
mWebSocket.close(webSocketCloseOptions, (error, value) => {
if (!error) {
console.log(`case success,data:` + value);
expect(value).assertTrue();
done();
} else {
console.log(`error, case failed,errCode:` + error.code);
expect().assertFail();
done();
}
});
});
});
/*
* @tc.number: TEST_CLOSE_003
* @tc.name : testClose003
* @tc.desc : Closes a WebSocket connection.
* @tc.size : MediumTest
* @tc.type : Method
* @tc.level : Level 2
*/
it('testClose003', 0, async function (done) {
let mWebSocket = webSocket.createWebSocket();
let webSocketCloseOptions: webSocket.WebSocketCloseOptions = {
code: 1,
reason: "test reason"
}
mWebSocket.connect(serverIpAddress, (error, data) => {
mWebSocket.close(webSocketCloseOptions).then(value => {
console.log(`case success,data:` + value);
expect(value).assertTrue();
done();
}).catch((error) => {
console.log(`error, case failed,errCode:` + error.code);
expect().assertFail();
done();
});
});
});
/*
* @tc.number: TEST_CLOSE_004
* @tc.name : testClose004
* @tc.desc : Closes a WebSocket connection.
* @tc.size : MediumTest
* @tc.type : Method
* @tc.level : Level 2
*/
it('testClose004', 0, async function (done) {
let mWebSocket = webSocket.createWebSocket();
>>>>>>> c661a9d77ed4eae4068dadf859aa14d46767d4a4
mWebSocket.close((error, value) => { mWebSocket.close((error, value) => {
if (!error) { if (!error) {
console.log(`case success:` + value); console.log(`case success:` + value);
...@@ -474,23 +258,14 @@ export default function webSocketTest() { ...@@ -474,23 +258,14 @@ export default function webSocketTest() {
}); });
/* /*
<<<<<<< HEAD
* @tc.number: TEST_CLOSE_002 * @tc.number: TEST_CLOSE_002
* @tc.name : testClose002 * @tc.name : testClose002
=======
* @tc.number: TEST_CLOSE_005
* @tc.name : testClose005
>>>>>>> c661a9d77ed4eae4068dadf859aa14d46767d4a4
* @tc.desc : Closes a WebSocket connection. * @tc.desc : Closes a WebSocket connection.
* @tc.size : MediumTest * @tc.size : MediumTest
* @tc.type : Method * @tc.type : Method
* @tc.level : Level 2 * @tc.level : Level 2
*/ */
<<<<<<< HEAD
it('testClose002', 0, async function (done) { it('testClose002', 0, async function (done) {
=======
it('testClose005', 0, async function (done) {
>>>>>>> c661a9d77ed4eae4068dadf859aa14d46767d4a4
let mWebSocket = webSocket.createWebSocket(); let mWebSocket = webSocket.createWebSocket();
let webSocketCloseOptions: webSocket.WebSocketCloseOptions = { let webSocketCloseOptions: webSocket.WebSocketCloseOptions = {
code: 1, code: 1,
...@@ -510,23 +285,14 @@ export default function webSocketTest() { ...@@ -510,23 +285,14 @@ export default function webSocketTest() {
}); });
/* /*
<<<<<<< HEAD
* @tc.number: TEST_CLOSE_003 * @tc.number: TEST_CLOSE_003
* @tc.name : testClose003 * @tc.name : testClose003
=======
* @tc.number: TEST_CLOSE_006
* @tc.name : testClose006
>>>>>>> c661a9d77ed4eae4068dadf859aa14d46767d4a4
* @tc.desc : Closes a WebSocket connection. * @tc.desc : Closes a WebSocket connection.
* @tc.size : MediumTest * @tc.size : MediumTest
* @tc.type : Method * @tc.type : Method
* @tc.level : Level 2 * @tc.level : Level 2
*/ */
<<<<<<< HEAD
it('testClose003', 0, async function (done) { it('testClose003', 0, async function (done) {
=======
it('testClose006', 0, async function (done) {
>>>>>>> c661a9d77ed4eae4068dadf859aa14d46767d4a4
let mWebSocket = webSocket.createWebSocket(); let mWebSocket = webSocket.createWebSocket();
let webSocketCloseOptions: webSocket.WebSocketCloseOptions = { let webSocketCloseOptions: webSocket.WebSocketCloseOptions = {
code: 1, code: 1,
...@@ -543,7 +309,6 @@ export default function webSocketTest() { ...@@ -543,7 +309,6 @@ export default function webSocketTest() {
}); });
}); });
<<<<<<< HEAD
/* /*
* @tc.number: TEST_ON_OPEN_001 * @tc.number: TEST_ON_OPEN_001
* @tc.name : testOn_Open001 * @tc.name : testOn_Open001
...@@ -681,8 +446,6 @@ export default function webSocketTest() { ...@@ -681,8 +446,6 @@ export default function webSocketTest() {
expect(true).assertTrue(); expect(true).assertTrue();
}); });
=======
>>>>>>> c661a9d77ed4eae4068dadf859aa14d46767d4a4
}) })
} }
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册