提交 02526510 编写于 作者: H hu0475

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

Signed-off-by: Nhu0475 <huyanqiang5@huawei.com>
上级 1d7a6a1d
...@@ -14,8 +14,8 @@ ...@@ -14,8 +14,8 @@
group("telephony") { group("telephony") {
testonly = true testonly = true
deps = [ deps = [
"crossplatform/telephony_http_test:ActsCrossplatformTelephonyHttpEtsTest",
"crossplatform:crossplatform", "crossplatform:crossplatform",
"crossplatform/telephony_http_test:ActsCrossplatformTelephonyHttpEtsTest",
"telephonyjstest:telephonyjstest", "telephonyjstest:telephonyjstest",
] ]
} }
...@@ -20,6 +20,7 @@ ohos_js_hap_suite("ActsCrossplatformConnectionTest") { ...@@ -20,6 +20,7 @@ ohos_js_hap_suite("ActsCrossplatformConnectionTest") {
] ]
ets2abc = true ets2abc = true
certificate_profile = "./signature/openharmony_sx.p7b" certificate_profile = "./signature/openharmony_sx.p7b"
# hap_name: HAP的名字,可选,默认为目标名 # hap_name: HAP的名字,可选,默认为目标名
hap_name = "ActsCrossplatformConnectionTest" hap_name = "ActsCrossplatformConnectionTest"
subsystem_name = "communication" subsystem_name = "communication"
...@@ -28,6 +29,7 @@ ohos_js_hap_suite("ActsCrossplatformConnectionTest") { ...@@ -28,6 +29,7 @@ ohos_js_hap_suite("ActsCrossplatformConnectionTest") {
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"
# sources: 资源文件路径 # sources: 资源文件路径
sources = [ "AppScope/resources" ] sources = [ "AppScope/resources" ]
} }
...@@ -38,8 +40,10 @@ ohos_js_assets("windowStage_js_assets") { ...@@ -38,8 +40,10 @@ ohos_js_assets("windowStage_js_assets") {
ohos_resources("windowStage_resources") { ohos_resources("windowStage_resources") {
# sources: 资源文件路径 # sources: 资源文件路径
sources = [ "src/main/resources" ] sources = [ "src/main/resources" ]
# deps: 当前目标的依赖 # deps: 当前目标的依赖
deps = [ ":windowStage_app_profile" ] deps = [ ":windowStage_app_profile" ]
# 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"
} }
\ No newline at end of file
...@@ -52,24 +52,24 @@ export default function connectionTest() { ...@@ -52,24 +52,24 @@ export default function connectionTest() {
* @tc.level : Level 2 * @tc.level : Level 2
*/ */
it('testHasDefaultNet001', 0, function (done) { it('testHasDefaultNet001', 0, function (done) {
console.log('testHasDefaultNet001 1') console.log('testHasDefaultNet001 1');
connection.hasDefaultNet((error, value) => { connection.hasDefaultNet((error, value) => {
console.log('testHasDefaultNet001 2') console.log('testHasDefaultNet001 2');
if (!error) { if (!error) {
console.log('testHasDefaultNet001 3') console.log('testHasDefaultNet001 3');
console.log(`testHasDefaultNet001 case success,data:` + value); console.log(`testHasDefaultNet001 case success,data:` + value);
console.log('testHasDefaultNet001 4') console.log('testHasDefaultNet001 4');
expect(value).assertTrue(); expect(value).assertTrue();
done(); done();
} else { } else {
console.log('testHasDefaultNet001 6') console.log('testHasDefaultNet001 6');
console.log(`testHasDefaultNet001 error, case failed,errCode:` + error.code); console.log(`testHasDefaultNet001 error, case failed,errCode:` + error.code);
console.log('testHasDefaultNet001 7') console.log('testHasDefaultNet001 7');
expect().assertFail(); expect().assertFail();
done(); done();
} }
}); });
console.log('testHasDefaultNet001 9') console.log('testHasDefaultNet001 9');
}); });
/* /*
...@@ -176,34 +176,6 @@ export default function connectionTest() { ...@@ -176,34 +176,6 @@ export default function connectionTest() {
} }
}); });
/**
* @tc.number: TEST_ON_NET_BLOCK_STATUS_CHANGE_001
* @tc.name : testOn_NetBlockStatusChange001
* @tc.desc : Subscribe to network blocking status events, using the callback method as an asynchronous method.
* @tc.size : MediumTest
* @tc.type : Method
* @tc.level : Level 2
*/
it('testOn_NetBlockStatusChange001', 0, function (done) {
let netConn = connection.createNetConnection();
netConn.register((error) => {
if (!error) {
netConn.on('netBlockStatusChange',(data) => {
console.log("success11:" + data);
});
netConn.unregister((error) => {
console.log("result11:" + error);
});
expect(true).assertTrue();
done();
} else {
console.log(`register failed,errCode:` + error.code);
expect().assertFail();
done();
}
});
});
/** /**
* @tc.number: TEST_ON_NET_CAPABILITIES_CHANGE_001 * @tc.number: TEST_ON_NET_CAPABILITIES_CHANGE_001
* @tc.name : testOn_NetCapabilitiesChange001 * @tc.name : testOn_NetCapabilitiesChange001
...@@ -218,34 +190,7 @@ export default function connectionTest() { ...@@ -218,34 +190,7 @@ export default function connectionTest() {
if (!error) { if (!error) {
netConn.on('netCapabilitiesChange',(data) => { netConn.on('netCapabilitiesChange',(data) => {
console.log("success11:" + data); console.log("success11:" + data);
}); expect(data.netCap.bearerTypes.length >= 0).assertTrue();
netConn.unregister((error) => {
console.log("result11:" + error);
});
expect(true).assertTrue();
done();
} else {
console.log(`register failed,errCode:` + error.code);
expect().assertFail();
done();
}
});
});
/**
* @tc.number: TEST_ON_NET_CONNECTION_PROPERTIES_CHANGE_001
* @tc.name : testOn_NetConnectionPropertiesChange001
* @tc.desc : Subscribe to network connection information change events.
* @tc.size : MediumTest
* @tc.type : Method
* @tc.level : Level 2
*/
it('testOn_NetConnectionPropertiesChange001', 0, function (done) {
let netConn = connection.createNetConnection();
netConn.register((error) => {
if (!error) {
netConn.on('netConnectionPropertiesChange',(data) => {
console.log("success11:" + data);
}); });
netConn.unregister((error) => { netConn.unregister((error) => {
console.log("result11:" + error); console.log("result11:" + error);
...@@ -358,6 +303,5 @@ export default function connectionTest() { ...@@ -358,6 +303,5 @@ export default function connectionTest() {
done(); done();
}); });
}) })
} }
...@@ -20,6 +20,7 @@ ohos_js_hap_suite("ActsCrossplatformWebSocketTest") { ...@@ -20,6 +20,7 @@ ohos_js_hap_suite("ActsCrossplatformWebSocketTest") {
] ]
ets2abc = true ets2abc = true
certificate_profile = "./signature/openharmony_sx.p7b" certificate_profile = "./signature/openharmony_sx.p7b"
# hap_name: HAP的名字,可选,默认为目标名 # hap_name: HAP的名字,可选,默认为目标名
hap_name = "ActsCrossplatformWebSocketTest" hap_name = "ActsCrossplatformWebSocketTest"
subsystem_name = "communication" subsystem_name = "communication"
...@@ -28,6 +29,7 @@ ohos_js_hap_suite("ActsCrossplatformWebSocketTest") { ...@@ -28,6 +29,7 @@ ohos_js_hap_suite("ActsCrossplatformWebSocketTest") {
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"
# sources: 资源文件路径 # sources: 资源文件路径
sources = [ "AppScope/resources" ] sources = [ "AppScope/resources" ]
} }
...@@ -38,8 +40,10 @@ ohos_js_assets("windowStage_js_assets") { ...@@ -38,8 +40,10 @@ ohos_js_assets("windowStage_js_assets") {
ohos_resources("windowStage_resources") { ohos_resources("windowStage_resources") {
# sources: 资源文件路径 # sources: 资源文件路径
sources = [ "src/main/resources" ] sources = [ "src/main/resources" ]
# deps: 当前目标的依赖 # deps: 当前目标的依赖
deps = [ ":windowStage_app_profile" ] deps = [ ":windowStage_app_profile" ]
# 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"
} }
\ No newline at end of file
...@@ -19,8 +19,6 @@ export default function webSocketTest() { ...@@ -19,8 +19,6 @@ export default function webSocketTest() {
describe('webSocketTest', function () { describe('webSocketTest', function () {
console.log("************* webSocket Test start*************"); console.log("************* webSocket Test start*************");
let serverIpAddress: string = "ws://192.168.1.100:8081/string";
/* /*
* @tc.number: TEST_CREATE_WEB_SOCKET_001 * @tc.number: TEST_CREATE_WEB_SOCKET_001
* @tc.name : testCreateWebSocket001 * @tc.name : testCreateWebSocket001
...@@ -32,6 +30,17 @@ export default function webSocketTest() { ...@@ -32,6 +30,17 @@ export default function webSocketTest() {
it('testCreateWebSocket001', 0, async function (done) { it('testCreateWebSocket001', 0, async function (done) {
var mWebSocket = webSocket.createWebSocket(); var mWebSocket = webSocket.createWebSocket();
expect(mWebSocket != null).assertTrue(); expect(mWebSocket != null).assertTrue();
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();
}
});
done(); done();
}); });
...@@ -161,6 +170,54 @@ export default function webSocketTest() { ...@@ -161,6 +170,54 @@ export default function webSocketTest() {
}); });
}); });
/*
* @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(null).then(value => {
console.log(`case success11:` + value);
expect(value).assertTrue();
done();
}).catch((error) => {
console.log(`error, case failed,errCode:` + error.code);
expect(error.code).assertEqual(401);
done();
});
});
/*
* @tc.number: TEST_CONNECT_005
* @tc.name : testConnect005
* @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('testConnect005', 0, async function (done) {
let mWebSocket = webSocket.createWebSocket();
let webSocketRequestOptions: webSocket.WebSocketRequestOptions = {
header: {
key: "value",
key2: "value2"
}
}
mWebSocket.connect("ws://19211.16811.1.100:8081/string", webSocketRequestOptions).then(value => {
console.log(`case success11:` + value);
expect(value).assertTrue();
done();
}).catch((error) => {
console.log(`error, case failed,errCode:` + error.code);
expect(error.code).assertEqual(-1);
done();
});
});
/* /*
* @tc.number: TEST_SEND_001 * @tc.number: TEST_SEND_001
* @tc.name : testSend001 * @tc.name : testSend001
...@@ -234,6 +291,35 @@ export default function webSocketTest() { ...@@ -234,6 +291,35 @@ export default function webSocketTest() {
}); });
}); });
/*
* @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();
var str = "Hello, server!(arrayBuffer promise mode)";
var buf = new ArrayBuffer(str.length);
var message = new Uint8Array(buf);
for (var i = 0, strLen = str.length; i < strLen; i++) {
message[i] = str.charCodeAt(i);
}
mWebSocket.send(message.buffer, (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();
}
});
});
/* /*
* @tc.number: TEST_CLOSE_001 * @tc.number: TEST_CLOSE_001
* @tc.name : testClose001 * @tc.name : testClose001
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册