未验证 提交 519d67c5 编写于 作者: O openharmony_ci 提交者: Gitee

!6777 电话服务register用例整改

Merge pull request !6777 from zhangfuzhi/cherry-pick-1669963077
/** /**
* Copyright (C) 2021 Huawei Device Co., Ltd. * Copyright (C) 2021-2022 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
...@@ -13,2523 +13,1340 @@ ...@@ -13,2523 +13,1340 @@
* limitations under the License. * limitations under the License.
*/ */
import connection from '@ohos.net.connection';
import { describe, expect, it } from '@ohos/hypium';
import connection from '@ohos.net.connection'; export default function Telephony_NetworkManagerRegisterTest() {
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
export default function Telephony_NetworkManagerRegisterTest() {
describe('Telephony_NetworkManagerRegisterTest', function () {
const ETH_100 = 100;
const TEST_RUN_TIME_2 = 2;
const TEST_RUN_TIME_5 = 5;
const TEST_RUN_TIME_1000 = 1000;
const DELAY = 1000;
const DELAY_TIME = 1000;
const TIMEOUT = 100;
const TIMEOUT_1 = 1000;
let VALUE = 0;
let envReady = false;
function sleep(timeout) {
return new Promise((resolve, reject) => {
setTimeout(() => {
resolve();
}, timeout);
})
}
function sleepOther(timeout) {
for (var t = Date.now(); Date.now() - t <= timeout;) ;
}
/**
*@tc.number Telephony_NetworkManager_register_Async_0100
*@tc.name Enter bearerTypes and networkCap asempty, set class NetConnection,
* call Register() to activate the default network, and see if the callback information is generated
@tc.desc Function test
*/
it('Telephony_NetworkManager_register_Async_0100', 0, async function (done) {
let caseName = 'Telephony_NetworkManager_register_Async_0100';
let netConn = connection.createNetConnection();
let returnValue = 0;
netConn.on('netAvailable', (value) => {
if (value === undefined) {
console.info("${caseName} on netAvailable fail");
expect().assertFail();
done();
} else {
console.info("${caseName} netAvailable :" + value.netId);
returnValue = value.netId;
}
});
netConn.on('netCapabilitiesChange', (value) => {
if (value === undefined) {
console.info("${caseName} netCapabilitiesChange fail");
expect().assertFail();
done();
} else {
console.info("${caseName} netCapabilitiesChange handle =:" + value.netHandle.netId);
expect(value.netHandle.netId >= ETH_100).assertTrue();
}
});
netConn.on('netConnectionPropertiesChange', (value) => {
if (value === undefined) {
console.info("${caseName} netConnectionPropertiesChange fail");
expect().assertFail();
done();
} else {
console.info("${caseName} netConnectionPropertiesChange handle = :" + value.netHandle.netId);
}
});
netConn.on('netLost', (value) => {
if (error) {
console.info("${caseName} netLost fail");
expect().assertFail();
done();
} else {
console.info("${caseName} netLost: " + value.netId);
}
});
netConn.register((error) => {
if (error) {
console.info(JSON.stringify(error) + "${caseName} register fail: ${error}");
done();
}
});
await sleep(DELAY);
console.info("${caseName} returnVaule : " + returnValue);
netConn.unregister((error) => {
if (error) {
console.info("${caseName} register fail: ${error}");
done();
}
done();
});
done();
});
/** describe('Telephony_NetworkManagerRegisterTest', function () {
*@tc.number Telephony_NetworkManager_register_Async_0200
*@tc.name Enter bearerTypes and networkCap asempty, set class NetConnection,
* call Register() to activate the default network, and see if the callback information is generated
@tc.desc Function test
*/
it('Telephony_NetworkManager_register_Async_0200', 0, async function (done) {
let caseName = 'Telephony_NetworkManager_register_Async_0200';
let netSpecifier = {
netCapabilities: {
bearerTypes: [1],
}
}
let netId = 0;
let netConn = connection.createNetConnection(netSpecifier, TIMEOUT);
netConn.on('netAvailable', (value) => {
if (value === undefined) {
console.info("${caseName} on netAvailable fail");
expect().assertFail();
done();
} else {
console.info("${caseName} netAvailable : " + value.netId);
returnValue = value.netId;
}
});
console.info("netAvailable end");
netConn.on('netCapabilitiesChange', (value) => {
if (value === undefined) {
console.info("${caseName} netCapabilitiesChange fail");
expect().assertFail();
done();
} else {
console.info("${caseName} netCapabilitiesChange handle =:" + value.netHandle.netId);
expect(value.netHandle.netId >= ETH_100).assertTrue();
} const TIMEOUT = 1000;
});
console.info("netCapabilitiesChange end");
netConn.on('netConnectionPropertiesChange', (value) => {
if (value === undefined) {
console.info("${caseName} netConnectionPropertiesChange fail");
expect().assertFail();
done();
} else {
console.info("${caseName} netConnectionPropertiesChange handle =:" + value.netHandle.netId);
}
});
console.info("netConnectionPropertiesChange end");
netConn.on('netLost', (value) => {
if (error) {
console.info("${caseName} netLost fail");
expect().assertFail();
done();
} else {
console.info("${caseName} netLost : " + value.netId);
}
});
console.info("netLost end");
netConn.on('netUnavailable', (value) => {
if (error) {
console.info("${caseName} netUnavailable fail");
expect().assertFail();
done();
} else {
console.info("${caseName} netUnavailable: " + value.netId);
}
});
console.info("netUnavailable end");
netConn.on('netBlockStatuschange', (value) => {
if (error) {
console.info("${caseName} netBlockStatusChange fail");
expect().assertFail();
done();
} else {
console.info("${caseName} netBlockStatusChange : " + value.netHandle.netId);
}
});
console.info("netBlockStatuschange end");
netConn.register((error) => {
if (error) {
console.info("${caseName} register fail: ${error}");
}
});
console.info("register end");
await sleep(DELAY);
netConn.unregister((error) => {
if (error) {
console.info("${caseName} unregisterresult: ${error}" + JSON.stringify(error));
done();
}
});
console.info("unregister end");
done();
});
/* /**
*@tc.number Telephony_NetworkManager_register_Async_0300 * @tc.number Telephony_NetworkManager_register_Async_0100
*@tc.name Enter bearerTypes and networkCap as empty, set class NetConnection, * @tc.name Enter bearerTypes and networkCap asempty, set class NetConnection,
* call Register ()to activate the default network,and see if the callback information is generated * call Register() to activate the default network, and see if the callback information is generated
*@tc.desc Function test @tc.desc Function test
*/ */
it('Telephony_NetworkManager_register_Async_0300', 0, async function (done) { it('Telephony_NetworkManager_register_Async_0100', 0, async function (done) {
let caseName = 'Telephony_NetworkManager_register_Async_0300'; let caseName = 'Telephony_NetworkManager_register_Async_0100';
let netSpecifier = { let netConn = connection.createNetConnection();
netCapabilities: { netConn.register(function (error) {
linkUpBandwidthKbps: 0, console.log("Telephony_NetworkManager_register_Async_0100 register ");
linkDownBandwidthKbps: 0, if (error) {
bearerTypes: [0], console.info(caseName + " register fail: " + JSON.stringify(error));
networkCap: [11], expect().assertFail();
}, bearerPrivateIdentifier: '123' done();
} return;
let netId = 0; }
let netConn = connection.createNetConnection(netSpecifier, TIMEOUT); netConn.on('netAvailable', function (value) {
netConn.on('netAvailable', (error, value) => { console.log("netAvailable " + JSON.stringify(value));
if (error) { });
console.info("${caseName} register fail: ${error}"); netConn.on('netCapabilitiesChange', function (value) {
expect().assertFail(); console.log("netCapabilitiesChange " + JSON.stringify(value));
done(); });
} else { netConn.on('netConnectionPropertiesChange', function (value) {
console.info("${caseName} netAvailable:" + value.netId); console.log("netConnectionPropertiesChange" + JSON.stringify(value));
} });
}); netConn.on('netLost', function (value) {
netConn.on('netBlockStatusChange', (error, value) => { console.log("netLost" + JSON.stringify(value));
if (error) { });
console.info("${caseName} register fail: ${error}"); console.log("Telephony_NetworkManager_register_Async_0100 netLost end");
expect().assertFail(); console.log("Telephony_NetworkManager_register_Async_0100 unregister start");
done(); netConn.unregister(function (error) {
} else { console.log("Telephony_NetworkManager_register_Async_0100 unregister ");
console.info("${caseName} netBlockStatusChange handle = :" + value.netHandle.netId); if (error) {
} console.info(caseName + " register fail: " + JSON.stringify(error));
}); expect().assertFail();
netConn.on('netBlockStatusChange', (error, value) => { done();
if (error) { }
console.info("${caseName} register fail: ${error}"); done();
expect().assertFail(); });
done(); });
} else { });
console.info("${caseName} netBlockStatusChange handle = :" + value.netHandle.netId);
}
});
netConn.on('netConnectionPropertiesChange', (error, value) => {
if (error) {
console.info("${caseName} register fail: ${error}");
expect().assertFail();
done();
} else {
console.info("${caseName} netConnectionPropertiesChange handle = :" + value.netHandle.netId);
}
});
netConn.on('netLost', (error, value) => {
if (error) {
console.info("${caseName} register fail: ${error}");
expect().assertFail();
done();
} else {
console.info("${caseName} netLost = :" + value.netId);
}
});
netConn.on('netUnavailable', (error, value) => {
if (error) {
console.info("${caseName} register fail: ${error}");
expect().assertFail();
done();
} else {
console.info("${caseName} netUnavailable = :" + value);
netId = true;
}
});
netConn.register((error) => {
if (error) {
console.info("${caseName} register fail: ${error}");
}
});
await sleep(DELAY);
console.info("${caseName} netId : ${netId}");
expect(true).assertTrue()
netConn.unregister((error) => {
if (error) {
console.info("${caseName} unregister result: ${error}");
}
});
done();
});
/* /**
*@tc.number Telephony_NetworkManager_register_Async_0400 * @tc.number Telephony_NetworkManager_register_Async_0200
*@tc.name Enter bearerTypes and networkCap as empty, set class NetConnection, * @tc.name Enter bearerTypes and networkCap asempty, set class NetConnection,
* call Register ()to activate the default network,and see if the callback information is generated * call Register() to activate the default network, and see if the callback information is generated
*@tc.desc Function test @tc.desc Function test
*/ */
it('Telephony_NetworkManager_register_Async_0400', 0, async function (done) { it('Telephony_NetworkManager_register_Async_0200', 0, async function (done) {
let caseName = 'Telephony_NetworkManager_register_Async_0400'; let caseName = 'Telephony_NetworkManager_register_Async_0200';
let netId = 0; let netSpecifier = {
let netSpecifier = { netCapabilities: {
netCapabilities: { bearerTypes: [1],
linkUpBandwidthKbps: 0, }
linkDownBandwidthKbps: 0, }
bearerTypes: [0], let netConn = connection.createNetConnection(netSpecifier, TIMEOUT);
networkCap: [12], netConn.register(function (error) {
}, bearerPrivateIdentifier: '123' if (error) {
} console.info(caseName + " register fail: " + JSON.stringify(error));
let netConn = connection.createNetConnection(netSpecifier, TIMEOUT); done();
netConn.on('netAvailable', (error, value) => { return;
if (error) { }
console.info("${caseName} register fail: ${error}"); netConn.on('netAvailable', function (value) {
expect().assertFail(); console.log("netAvailable " + JSON.stringify(value));
done(); });
} else { netConn.on('netCapabilitiesChange', function (value) {
console.info("${caseName} netAvailable:" + value.netId); console.log("netCapabilitiesChange " + JSON.stringify(value));
} });
}); netConn.on('netConnectionPropertiesChange', function (value) {
netConn.on('netBlockStatusChange', (error, value) => { console.log("netConnectionPropertiesChange" + JSON.stringify(value));
if (error) { });
console.info("${caseName} register fail: ${error}"); netConn.on('netLost', function (value) {
expect().assertFail(); console.log("netLost" + JSON.stringify(value));
done(); });
} else { netConn.on('netUnavailable', function (value) {
console.info("${caseName} netBlockStatusChange handle = :" + value.netHandle.netId); console.log("netUnavailable" + JSON.stringify(value));
} });
}); netConn.on('netBlockStatusChange', function (value) {
netConn.on('netCapabilitiesChange', (error, value) => { console.log("netBlockStatusChange " + JSON.stringify(value));
if (error) { });
console.info("${caseName} register fail: ${error}"); netConn.unregister((error) => {
expect().assertFail(); if (error) {
done(); console.info(caseName + " unregisterresult: " + JSON.stringify(error));
} else { expect().assertFail();
console.info("${caseName} netCapabilitiesChange handle = :" + value.netHandle.netId); done();
} }
}); done();
netConn.on('netConnectionPropertiesChange', (error, value) => { });
if (error) { });
console.info("${caseName} register fail: ${error}"); });
expect().assertFail();
done();
} else {
console.info("${caseName} netConnectionPropertiesChange handle = :" + value.netHandle.netId);
}
});
netConn.on('netLost', (error, value) => {
if (error) {
console.info("${caseName} register fail: ${error}");
expect().assertFail();
done();
} else {
console.info("${caseName} netLost = :" + value.netId);
}
});
netConn.on('netUnavailable', (error, value) => {
if (error) {
console.info("${caseName} register fail: ${error}");
expect().assertFail();
done();
} else {
console.info("${caseName} netUnavailable = :" + value);
netId = true;
}
});
netConn.register((error) => {
if (error) {
console.info("${caseName} register fail: ${error}");
}
});
await sleep(DELAY);
expect(true).assertTrue()
netConn.unregister((error) => {
if (error) {
console.info("${caseName} unregister result: ${error.code},${error.message}");
}
});
done();
});
/* /*
*@tc.number Telephony_NetworkManager_register_Async_0500 *@tc.number Telephony_NetworkManager_register_Async_0300
*@tc.name Enter bearerTypes and networkCap as empty, set class NetConnection, *@tc.name Enter bearerTypes and networkCap as empty, set class NetConnection,
* call Register() to activate the default network,and see if the callback information is generated * call Register ()to activate the default network,and see if the callback information is generated
*@tc.desc Function test *@tc.desc Function test
*/ */
it('Telephony_NetworkManager_register_Async_0500', 0, async function (done) { it('Telephony_NetworkManager_register_Async_0300', 0, async function (done) {
let caseName = 'Telephony_NetworkManager_rgister_Async_0500'; let caseName = 'Telephony_NetworkManager_register_Async_0300';
let netSpecifier = { let netSpecifier = {
netCapabilities: { netCapabilities: {
linkUpBandwidthKbps: 0, linkUpBandwidthKbps: 0,
linkDownBandwidthKbps: 0, linkDownBandwidthKbps: 0,
bearerTypes: [0], bearerTypes: [0],
networkCap: [15], networkCap: [11],
}, bearerPrivateIdentifier: '123' }, bearerPrivateIdentifier: '123'
} }
let netId = 0; let netConn = connection.createNetConnection(netSpecifier, TIMEOUT);
let netConn = connection.createNetConnection(netSpecifier, TIMEOUT); netConn.register(function (error) {
netConn.on('netAvailable', (error, value) => { if (error) {
if (error) { console.info(caseName + " register fail: " + JSON.stringify(error));
console.info("${caseName} register fail: ${error}"); done();
expect().assertFail(); return;
done(); }
} else { netConn.on('netAvailable', function (value) {
console.info("${caseName} netAvailable:" + value.netId); console.log("netAvailable " + JSON.stringify(value));
} });
}); netConn.on('netBlockStatusChange', function (value) {
netConn.on('netBlockStatusChange', (error, value) => { console.log("netBlockStatusChange " + JSON.stringify(value));
if (error) { });
console.info("${caseName} register fail: ${error}"); netConn.on('netCapabilitiesChange', function (value) {
expect().assertFail(); console.log("netCapabilitiesChange " + JSON.stringify(value));
done(); });
} else { netConn.on('netConnectionPropertiesChange', function (value) {
console.info("${caseName} netBlockStatusChange handle = :" + value.netHandle.netId); console.log("netConnectionPropertiesChange" + JSON.stringify(value));
} });
}); netConn.on('netLost', function (value) {
netConn.on('netCapabilitiesChange', (error, value) => { console.log("netLost" + JSON.stringify(value));
if (error) { });
console.info("${caseName} register fail: ${error}"); netConn.on('netUnavailable', function (value) {
expect().assertFail(); console.info(caseName + " register fail: " + JSON.stringify(value));
done(); });
} else { netConn.unregister((error) => {
console.info("${caseName} netCapabilitiesChange handle = :" + value.netHandle.netId); if (error) {
} console.info(caseName + " unregister result: " + JSON.stringify(error));
}); expect().assertFail();
netConn.on('netConnectionPropertiesChange', (error, value) => { done();
if (error) { }
console.info("${caseName} register fail: ${error}"); done();
expect().assertFail(); });
done(); });
} else { });
console.info("${caseName} netConnectionPropertiesChange handle = :" + value.netHandle.netId);
}
});
netConn.on('netLost', (error, value) => {
if (error) {
console.info("${caseName} register fail: ${error}");
expect().assertFail();
done();
} else {
console.info("${caseName} netLost = :" + value.netId);
}
});
netConn.on('netUnavailable', (error, value) => {
if (error) {
console.info("${caseName} register fail: ${error}");
expect().assertFail();
done();
} else {
console.info("${caseName} netUnavailable = :" + value);
netId = true;
}
});
netConn.register((error) => {
if (error) {
console.info("${caseName} register fail: ${error}");
}
});
await sleep(DELAY);
expect(true).assertTrue()
netConn.unregister((error) => {
if (error) {
console.info("${caseName} unregister result: ${error}");
}
done();
});
done();
});
/* /*
*@tc.number Telephony_NetworkManager_register_Async_0600 *@tc.number Telephony_NetworkManager_register_Async_0400
*@tc.name Enter bearerTypes and networkCap as empty, set class NetConnection, *@tc.name Enter bearerTypes and networkCap as empty, set class NetConnection,
* call Register() to activate the default network,and see if the callback information is generated * call Register ()to activate the default network,and see if the callback information is generated
*@tc.desc Function test *@tc.desc Function test
*/ */
it('Telephony_NetworkManager_register_Async_0600', 0, async function (done) { it('Telephony_NetworkManager_register_Async_0400', 0, async function (done) {
let caseName = 'Telephony_NetworkManager_rgister_Async_0600'; let caseName = 'Telephony_NetworkManager_register_Async_0400';
let netSpecifier = { let netSpecifier = {
netCapabilities: { netCapabilities: {
linkUpBandwidthKbps: 0, linkUpBandwidthKbps: 0,
linkDownBandwidthKbps: 0, linkDownBandwidthKbps: 0,
bearerTypes: [0], bearerTypes: [0],
networkCap: [16], networkCap: [12],
}, bearerPrivateIdentifier: '123' }, bearerPrivateIdentifier: '123'
} }
let netConn = connection.createNetConnection(netSpecifier, TIMEOUT); let netConn = connection.createNetConnection(netSpecifier, TIMEOUT);
let netId = 0; netConn.register(function (error) {
netConn.on('netAvailable', (error, value) => { if (error) {
if (error) { console.info(caseName + " register fail: " + JSON.stringify(error));
console.info("${caseName} register fail: ${error}"); done();
expect().assertFail(); return;
done(); }
} else { netConn.on('netAvailable', function (value) {
console.info("${caseName} netAvailable:" + value.netId); console.log("netAvailable" + JSON.stringify(value))
} });
}); netConn.on('netCapabilitiesChange', function (value) {
netConn.on('netBlockStatusChange', (error, value) => { console.log("netCapabilitiesChange" + JSON.stringify(value))
if (error) { });
console.info("${caseName} register fail: ${error}"); netConn.on('netConnectionPropertiesChange', function (value) {
expect().assertFail(); console.log("netConnectionPropertiesChange" + JSON.stringify(value));
done(); });
} else { netConn.on('netLost', function (value) {
console.info("${caseName} netBlockStatusChange handle = :" + value.netHandle.netId); console.log("netLost" + JSON.stringify(value));
} });
}); netConn.on('netUnavailable', function (value) {
netConn.on('netCapabilitiesChange', (error, value) => { console.log("netUnavailable" + JSON.stringify(value));
if (error) { });
console.info("${caseName} register fail: ${error}"); netConn.on('netBlockStatusChange', function (value) {
expect().assertFail(); console.log("netBlockStatusChange " + JSON.stringify(value));
done(); });
} else { netConn.unregister((error) => {
console.info("${caseName} netCapabilitiesChange handle = :" + value.netHandle.netId); if (error) {
} console.info(caseName + " unregisterresult: " + JSON.stringify(error));
}); expect().assertFail();
netConn.on('netConnectionPropertiesChange', (error, value) => { done();
if (error) { }
console.info("${caseName} register fail: ${error}"); done();
expect().assertFail(); });
done(); });
} else { });
console.info("${caseName} netConnectionPropertiesChange handle = :" + value.netHandle.netId);
}
});
netConn.on('netLost', (error, value) => {
if (error) {
console.info("${caseName} register fail: ${error}");
expect().assertFail();
done();
} else {
console.info("${caseName} netLost = :" + value.netId);
}
});
netConn.on('netUnavailable', (error, value) => {
if (error) {
console.info("${caseName} register fail: ${error}");
expect().assertFail();
done();
} else {
console.info("${caseName} netUnavailable = :" + value);
netId = true;
}
});
netConn.register((error) => {
if (error) {
console.info("${caseName} register fail: ${error}");
}
});
await sleep(DELAY);
expect(true).assertTrue()
netConn.unregister((error) => {
if (error) {
console.info("${caseName} unregister result: ${error}");
}
done();
});
done();
});
/* /*
*@tc.number Telephony_NetworkManager_register_Async_0700 *@tc.number Telephony_NetworkManager_register_Async_0500
*@tc.name Enter bearerTypes and networkCap as empty, set class NetConnection, *@tc.name Enter bearerTypes and networkCap as empty, set class NetConnection,
* call Register() to activate the default network,and see if the callback information is generated * call Register() to activate the default network,and see if the callback information is generated
*@tc.desc Function test *@tc.desc Function test
*/ */
it('Telephony_NetworkManager_register_Async_0700', 0, async function (done) { it('Telephony_NetworkManager_register_Async_0500', 0, async function (done) {
let caseName = 'Telephony_NetworkManager_rgister_Async_0700'; let caseName = 'Telephony_NetworkManager_rgister_Async_0500';
let netSpecifier = { let netSpecifier = {
netCapabilities: { netCapabilities: {
linkUpBandwidthKbps: 0, linkUpBandwidthKbps: 0,
linkDownBandwidthKbps: 0, linkDownBandwidthKbps: 0,
bearerTypes: [0], bearerTypes: [0],
networkCap: [17], networkCap: [15],
}, bearerPrivateIdentifier: '123' }, bearerPrivateIdentifier: '123'
} }
let netConn = connection.createNetConnection(netSpecifier, TIMEOUT); let netConn = connection.createNetConnection(netSpecifier, TIMEOUT);
let netId = 0; netConn.register(function (error) {
netConn.on('netAvailable', (error, value) => { if (error) {
if (error) { console.info(caseName + " register fail: " + JSON.stringify(error));
console.info("${caseName} register fail: ${error}"); done();
expect().assertFail(); return;
done(); }
} else { netConn.on('netAvailable', function (value) {
console.info("${caseName} netAvailable:" + value.netId); console.log("netAvailable " + JSON.stringify(value));
} });
}); netConn.on('netCapabilitiesChange', function (value) {
netConn.on('netBlockStatusChange', (error, value) => { console.log("netCapabilitiesChange " + JSON.stringify(value));
if (error) { });
console.info("${caseName} register fail: ${error}"); netConn.on('netConnectionPropertiesChange', function (value) {
expect().assertFail(); console.log("netConnectionPropertiesChange" + JSON.stringify(value));
done(); });
} else { netConn.on('netLost', function (value) {
console.info("${caseName} netBlockStatusChange handle = :" + value.netHandle.netId); console.log("netLost" + JSON.stringify(value));
} });
}); netConn.on('netUnavailable', function (value) {
netConn.on('netCapabilitiesChange', (error, value) => { console.log("netUnavailable" + JSON.stringify(value));
if (error) { });
console.info("${caseName} register fail: ${error}"); netConn.on('netBlockStatusChange', function (value) {
expect().assertFail(); console.log("netBlockStatusChange " + JSON.stringify(value));
done(); });
} else { netConn.unregister((error) => {
console.info("${caseName} netCapabilitiesChange handle = :" + value.netHandle.netId); if (error) {
} console.info(caseName + " unregister result: " + JSON.stringify(error));
}); expect().assertFail();
netConn.on('netConnectionPropertiesChange', (error, value) => { done();
if (error) { }
console.info("${caseName} register fail: ${error}"); done();
expect().assertFail(); });
done(); });
} else { });
console.info("${caseName} netConnectionPropertiesChange handle = :" + value.netHandle.netId);
}
});
netConn.on('netLost', (error, value) => {
if (error) {
console.info("${caseName} register fail: ${error}");
expect().assertFail();
done();
} else {
console.info("${caseName} netLost = :" + value.netId);
}
});
netConn.on('netUnavailable', (error, value) => {
if (error) {
console.info("${caseName} register fail: ${error}");
expect().assertFail();
done();
} else {
console.info("${caseName} netUnavailable = :" + value);
netId = true;
}
});
netConn.register((error) => {
if (error) {
console.info("${caseName} register fail: ${error}");
}
});
await sleep(DELAY);
expect(true).assertTrue()
netConn.unregister((error) => {
if (error) {
console.info("${caseName} unregister result: ${error}");
}
done();
});
done();
});
/* /*
*@tc.number Telephony_NetworkManager_register_Async_0800 *@tc.number Telephony_NetworkManager_register_Async_0600
*@tc.name Enter bearerTypes and networkCap as empty, set class NetConnection, *@tc.name Enter bearerTypes and networkCap as empty, set class NetConnection,
* call Register() to activate the default network,and see if the callback information is generated * call Register() to activate the default network,and see if the callback information is generated
*@tc.desc Function test *@tc.desc Function test
*/ */
it('Telephony_NetworkManager_register_Async_0800', 0, async function (done) { it('Telephony_NetworkManager_register_Async_0600', 0, async function (done) {
let caseName = 'Telephony_NetworkManager_rgister_Async_0800'; let caseName = 'Telephony_NetworkManager_rgister_Async_0600';
let netSpecifier = { let netSpecifier = {
netCapabilities: { netCapabilities: {
linkUpBandwidthKbps: 0, linkUpBandwidthKbps: 0,
linkDownBandwidthKbps: 0, linkDownBandwidthKbps: 0,
bearerTypes: [1], bearerTypes: [0],
networkCap: [0], networkCap: [16],
}, bearerPrivateIdentifier: '123' }, bearerPrivateIdentifier: '123'
} }
let netConn = connection.createNetConnection(netSpecifier, TIMEOUT); let netConn = connection.createNetConnection(netSpecifier, TIMEOUT);
let netId = 0; netConn.register(function (error) {
netConn.on('netAvailable', (error, value) => { if (error) {
if (error) { console.info(caseName + " register fail: " + JSON.stringify(error));
console.info("${caseName} register fail: ${error}"); done();
expect().assertFail(); return;
done(); }
} else { netConn.on('netAvailable', function (value) {
console.info("${caseName} netAvailable:" + value.netId); console.log("netAvailable " + JSON.stringify(value));
} });
}); netConn.on('netCapabilitiesChange', function (value) {
netConn.on('netBlockStatusChange', (error, value) => { console.log("netCapabilitiesChange " + JSON.stringify(value));
if (error) { });
console.info("${caseName} register fail: ${error}"); netConn.on('netConnectionPropertiesChange', function (value) {
expect().assertFail(); console.log("netConnectionPropertiesChange" + JSON.stringify(value));
done(); });
} else { netConn.on('netLost', function (value) {
console.info("${caseName} netBlockStatusChange handle = :" + value.netHandle.netId); console.log("netLost" + JSON.stringify(value));
} });
}); netConn.on('netUnavailable', function (value) {
netConn.on('netCapabilitiesChange', (error, value) => { console.log("netUnavailable" + JSON.stringify(value));
if (error) { });
console.info("${caseName} register fail: ${error}"); netConn.on('netBlockStatusChange', function (value) {
expect().assertFail(); console.log("netBlockStatusChange " + JSON.stringify(value));
done(); });
} else { netConn.unregister((error) => {
console.info("${caseName} netCapabilitiesChange handle = :" + value.netHandle.netId); if (error) {
} console.info(caseName + " unregisterresult: " + JSON.stringify(error));
}); expect().assertFail();
netConn.on('netConnectionPropertiesChange', (error, value) => { done();
if (error) { }
console.info("${caseName} register fail: ${error}"); done();
expect().assertFail(); });
done(); });
} else { });
console.info("${caseName} netConnectionPropertiesChange handle = :" + value.netHandle.netId);
}
});
netConn.on('netLost', (error, value) => {
if (error) {
console.info("${caseName} register fail: ${error}");
expect().assertFail();
done();
} else {
console.info("${caseName} netLost = :" + value.netId);
}
});
netConn.on('netUnavailable', (error, value) => {
if (error) {
console.info("${caseName} register fail: ${error}");
expect().assertFail();
done();
} else {
console.info("${caseName} netUnavailable = :" + value);
netId = true;
}
});
netConn.register((error) => {
if (error) {
console.info("${caseName} register fail: ${error}");
}
});
await sleep(DELAY);
expect(true).assertTrue()
netConn.unregister((error) => {
if (error) {
console.info("${caseName} unregister result: ${error}");
}
done();
});
done();
});
/* /*
*@tc.number Telephony_NetworkManager_register_Async_0900 *@tc.number Telephony_NetworkManager_register_Async_0700
*@tc.name Enter bearerTypes and networkCap as empty, set class NetConnection, *@tc.name Enter bearerTypes and networkCap as empty, set class NetConnection,
* call Register() to activate the default network,and see if the callback information is generated * call Register() to activate the default network,and see if the callback information is generated
*@tc.desc Function test *@tc.desc Function test
*/ */
it('Telephony_NetworkManager_register_Async_0900', 0, async function (done) { it('Telephony_NetworkManager_register_Async_0700', 0, async function (done) {
let caseName = 'Telephony_NetworkManager_rgister_Async_0900'; let caseName = 'Telephony_NetworkManager_rgister_Async_0700';
let netSpecifier = { let netSpecifier = {
netCapabilities: { netCapabilities: {
linkUpBandwidthKbps: 0, linkUpBandwidthKbps: 0,
linkDownBandwidthKbps: 0, linkDownBandwidthKbps: 0,
bearerTypes: [1], bearerTypes: [0],
networkCap: [12], networkCap: [17],
}, bearerPrivateIdentifier: '123' }, bearerPrivateIdentifier: '123'
} }
let netConn = connection.createNetConnection(netSpecifier, TIMEOUT); let netConn = connection.createNetConnection(netSpecifier, TIMEOUT);
let netId = 0; netConn.register(function (error) {
netConn.on('netAvailable', (error, value) => { if (error) {
if (error) { console.info(caseName + " register fail: " + JSON.stringify(error));
console.info("${caseName} register fail: ${error}"); done();
expect().assertFail(); return;
done(); }
} else { netConn.on('netAvailable', function (value) {
console.info("${caseName} netAvailable:" + value.netId); console.log("netAvailable " + JSON.stringify(value));
} });
}); netConn.on('netBlockStatusChange', function (value) {
netConn.on('netBlockStatusChange', (error, value) => { console.log("netBlockStatusChange " + JSON.stringify(value));
if (error) { });
console.info("${caseName} register fail: ${error}"); netConn.on('netCapabilitiesChange', function (value) {
expect().assertFail(); console.log("netCapabilitiesChange " + JSON.stringify(value));
done(); });
} else { netConn.on('netConnectionPropertiesChange', function (value) {
console.info("${caseName} netBlockStatusChange handle = :" + value.netHandle.netId); console.log("netConnectionPropertiesChange" + JSON.stringify(value));
expect(value.netHandle.netId >= ETH_100).assertTrue(); });
} netConn.on('netLost', function (value) {
}); console.log("netLost" + JSON.stringify(value));
netConn.on('netCapabilitiesChange', (error, value) => { });
if (error) { netConn.on('netUnavailable', function (value) {
console.info("${caseName} register fail: ${error}"); console.log("netUnavailable" + JSON.stringify(value));
expect().assertFail(); });
done(); netConn.unregister((error) => {
} else { if (error) {
console.info("${caseName} netCapabilitiesChange handle = :" + value.netHandle.netId); console.info(caseName + " unregister result: " + JSON.stringify(error));
expect(value.netHandle.netId >= ETH_100).assertTrue(); expect().assertFail();
} done();
}); }
netConn.on('netConnectionPropertiesChange', (error, value) => { done();
if (error) { });
console.info("${caseName} register fail: ${error}"); });
expect().assertFail(); });
done();
} else {
console.info("${caseName} netConnectionPropertiesChange handle = :" + value.netHandle.netId);
expect(value.netHandle.netId >= ETH_100).assertTrue();
}
});
netConn.on('netLost', (error, value) => {
if (error) {
console.info("${caseName} register fail: ${error}");
expect().assertFail();
done();
} else {
console.info("${caseName} netLost = :" + value.netId);
}
});
netConn.on('netUnavailable', (error, value) => {
if (error) {
console.info("${caseName} register fail: ${error}");
expect().assertFail();
done();
} else {
console.info("${caseName} netUnavailable = :" + value);
netId = true;
}
});
netConn.register((error) => {
if (error) {
console.info("${caseName} register fail: ${error}");
}
});
await sleep(10000);
expect(true).assertTrue()
netConn.unregister((error) => {
if (error) {
console.info("${caseName} unregister result: ${error}");
}
done();
});
done();
});
/* /*
*@tc.number Telephony_NetworkManager_register_Async_1000 *@tc.number Telephony_NetworkManager_register_Async_0800
*@tc.name Enter bearerTypes and networkCap as empty, set class NetConnection, *@tc.name Enter bearerTypes and networkCap as empty, set class NetConnection,
* call Register() to activate the default network,and see if the callback information is generated * call Register() to activate the default network,and see if the callback information is generated
*@tc.desc Function test *@tc.desc Function test
*/ */
it('Telephony_NetworkManager_register_Async_1000', 0, async function (done) { it('Telephony_NetworkManager_register_Async_0800', 0, async function (done) {
let caseName = 'Telephony_NetworkManager_rgister_Async_1000'; let caseName = 'Telephony_NetworkManager_rgister_Async_0800';
let netSpecifier = { let netSpecifier = {
netCapabilities: { netCapabilities: {
linkUpBandwidthKbps: 0, linkUpBandwidthKbps: 0,
linkDownBandwidthKbps: 0, linkDownBandwidthKbps: 0,
bearerTypes: [1], bearerTypes: [1],
networkCap: [12], networkCap: [0],
}, bearerPrivateIdentifier: '123' }, bearerPrivateIdentifier: '123'
} }
let netConn = connection.createNetConnection(netSpecifier, TIMEOUT); let netConn = connection.createNetConnection(netSpecifier, TIMEOUT);
let netId = 0; netConn.register(function (error) {
netConn.on('netAvailable', (error, value) => { if (error) {
if (error) { console.info(caseName + " register fail: " + JSON.stringify(error));
console.info("${caseName} register fail: ${error}"); done();
expect().assertFail(); return;
done(); }
} else { netConn.on('netAvailable', function (value) {
console.info("${caseName} netAvailable:" + value.netId); console.log("netAvailable " + JSON.stringify(value));
expect(value.netId >= ETH_100).assertTrue(); });
} netConn.on('netBlockStatusChange', function (value) {
}); console.log("netBlockStatusChange " + JSON.stringify(value));
netConn.on('netBlockStatusChange', (error, value) => { });
if (error) { netConn.on('netCapabilitiesChange', function (value) {
console.info("${caseName} register fail: ${error}"); console.log("netCapabilitiesChange " + JSON.stringify(value));
expect().assertFail(); });
done(); netConn.on('netConnectionPropertiesChange', function (value) {
} else { console.log("netConnectionPropertiesChange" + JSON.stringify(value));
console.info("${caseName} netBlockStatusChange handle = :" + value.netHandle.netId); });
expect(value.netHandle.netId >= ETH_100).assertTrue(); netConn.on('netLost', function (value) {
} console.log("netLost" + JSON.stringify(value));
}); });
netConn.on('netCapabilitiesChange', (error, value) => { netConn.on('netUnavailable', function (value) {
if (error) { console.log("netUnavailable" + JSON.stringify(value));
console.info("${caseName} register fail: ${error}"); });
expect().assertFail(); netConn.unregister((error) => {
done(); if (error) {
} else { console.info(caseName + " unregister result: " + JSON.stringify(error));
console.info("${caseName} netCapabilitiesChange handle = :" + value.netHandle.netId); expect().assertFail();
} done();
}); }
netConn.on('netConnectionPropertiesChange', (error, value) => { done();
if (error) { });
console.info("${caseName} register fail: ${error}"); });
expect().assertFail(); });
done(); /*
} else { *@tc.number Telephony_NetworkManager_register_Async_0900
console.info("${caseName} netConnectionPropertiesChange handle = :" + value.netHandle.netId); *@tc.name Enter bearerTypes and networkCap as empty, set class NetConnection,
expect(value.netHandle.netId >= ETH_100).assertTrue(); * call Register() to activate the default network,and see if the callback information is generated
} *@tc.desc Function test
}); */
netConn.on('netLost', (error, value) => { it('Telephony_NetworkManager_register_Async_0900', 0, async function (done) {
if (error) { let caseName = 'Telephony_NetworkManager_rgister_Async_0900';
console.info("${caseName} register fail: ${error}"); let netSpecifier = {
expect().assertFail(); netCapabilities: {
done(); linkUpBandwidthKbps: 0,
} else { linkDownBandwidthKbps: 0,
console.info("${caseName} netLost = :" + value.netId); bearerTypes: [1],
} networkCap: [12],
}); }, bearerPrivateIdentifier: '123'
netConn.on('netUnavailable', (error, value) => { }
if (error) { let netConn = connection.createNetConnection(netSpecifier, TIMEOUT);
console.info("${caseName} register fail: ${error}"); netConn.register(function (error) {
expect().assertFail(); if (error) {
done(); console.info(caseName + " register fail: " + JSON.stringify(error));
} else { done();
console.info("${caseName} netUnavailable = :" + value); return;
netId = true; }
} netConn.on('netAvailable', function (value) {
}); console.log("netAvailable " + JSON.stringify(value));
netConn.register((error) => { });
if (error) { netConn.on('netBlockStatusChange', function (value) {
console.info("${caseName} register fail: ${error}"); console.log("netBlockStatusChange " + JSON.stringify(value));
} });
}); netConn.on('netCapabilitiesChange', function (value) {
await sleep(DELAY); console.log("netCapabilitiesChange " + JSON.stringify(value));
expect(true).assertTrue() });
netConn.unregister((error) => { netConn.on('netConnectionPropertiesChange', function (value) {
if (error) { console.log("netCapabilitiesChange " + JSON.stringify(value));
console.info("${caseName} unregister result: ${error}"); });
} netConn.on('netLost', function (value) {
done(); console.log("netLost" + JSON.stringify(value));
}); });
done(); netConn.on('netUnavailable', function (value) {
}); console.log("netUnavailable" + JSON.stringify(value));
});
netConn.unregister((error) => {
if (error) {
console.info(caseName + " unregister result: " + JSON.stringify(error));
expect().assertFail();
done();
}
done();
});
});
});
/** /*
* @tc.number Telephony_NetworkManager_register_Async_1100 *@tc.number Telephony_NetworkManager_register_Async_1000
* @tc.name Enter bearerTypes add networkCap as empty ,set class NetConnection, *@tc.name Enter bearerTypes and networkCap as empty, set class NetConnection,
* call Register () to activate the default network ,and see if the callback information is generated * call Register() to activate the default network,and see if the callback information is generated
* @tc.desc Function test *@tc.desc Function test
*/ */
it('Telephony_NetworkManager_register_Async_1000', 0, async function (done) {
let caseName = 'Telephony_NetworkManager_rgister_Async_1000';
let netSpecifier = {
netCapabilities: {
linkUpBandwidthKbps: 0,
linkDownBandwidthKbps: 0,
bearerTypes: [1],
networkCap: [12],
}, bearerPrivateIdentifier: '123'
}
let netConn = connection.createNetConnection(netSpecifier, TIMEOUT);
netConn.register(function (error) {
if (error) {
console.info(caseName + " register fail: " + JSON.stringify(error));
done();
return;
}
netConn.on('netAvailable', function (value) {
console.log("netAvailable " + JSON.stringify(value));
});
netConn.on('netBlockStatusChange', function (value) {
console.log("netBlockStatusChange " + JSON.stringify(value));
});
netConn.on('netCapabilitiesChange', function (value) {
console.log("netCapabilitiesChange " + JSON.stringify(value));
});
netConn.on('netConnectionPropertiesChange', function (value) {
console.log("netConnectionPropertiesChange" + JSON.stringify(value));
});
netConn.on('netLost', function (value) {
console.log("netLost" + JSON.stringify(value));
});
netConn.on('netUnavailable', function (value) {
console.log("netUnavailable" + JSON.stringify(value));
});
netConn.unregister((error) => {
if (error) {
console.info(caseName + " unregister result: " + JSON.stringify(error));
expect().assertFail();
done();
}
done();
});
});
});
it('Telephony_NetworkManager_register_Async_1100', 0, async function (done) { /**
let caseName = 'Telephony_NetworkManager_register_Async_1100'; * @tc.number Telephony_NetworkManager_register_Async_1100
let netSpecifier = { * @tc.name Enter bearerTypes add networkCap as empty ,set class NetConnection,
netCapabilities: { * call Register () to activate the default network ,and see if the callback information is generated
linkUpBandwidthKbps: 0, * @tc.desc Function test
linkDownBandwidthKbps: 0, */
bearerTypes: [1],
networkCap: [15],
}, bearerPrivateIdentifier: '123'
}
let netId = 0;
let netConn = connection.createNetConnection(netSpecifier, TIMEOUT);
netConn.on('netAvailable', (error, value) => {
if (error) {
console.info("${caseName} register fail: ${error}");
expect().assertFail();
done();
} else {
console.info("${caseName} netAvailable : " + value.netId);
}
});
netConn.on('netBlockStatusChange', (error, value) => {
if (error) {
console.info("${caseName} register fail :${error}");
expect().assertFail();
done();
} else {
console.info("${caseName} netBlockStatusChange handle = :" + value.netHandle.netId);
}
});
netConn.on('netCapabilitiesChange', (error, value) => {
if (error) {
console.info("${caseName} register fail :${error}");
expect().assertFail();
done();
} else {
console.info("${caseName} netCapabilitiesChange handle = :" + value.netHandle.netId);
}
});
netConn.on('netConnectionPropertiesChange', (error, value) => {
if (error) {
console.info("${caseName} register fail :${error}");
expect().assertFail();
done();
} else {
console.info("${caseName} netConnectionPropertiesChange handle = :" + value.netHandle.netId);
expect(value.netHandle.netId >= ETH_100).assertTrue();
}
});
netConn.on('netLost', (error, value) => {
if (error) {
console.info("${caseName} register fail :${error}");
expect().assertFail();
done();
} else {
console.info("${caseName} netLost " + value.netId);
}
});
netConn.on('netUnavailable', (error, value) => {
if (error) {
console.info("${caseName} register fail :${error}");
expect().assertFail();
done();
} else {
console.info("${caseName} netUnavailable " + value.netId);
netId = true;
}
});
netConn.register((error) => {
if (error) {
console.info("${caseName} register fail ${error}");
}
});
await sleep(DELAY);
expect(true).assertTrue()
netConn.unregister((error) => {
if (error) {
console.info("${caseName} unregister result : ${error}");
}
done();
});
done();
});
/** it('Telephony_NetworkManager_register_Async_1100', 0, async function (done) {
* @tc.number Telephony_NetworkManager_register_Async_1200 let caseName = 'Telephony_NetworkManager_register_Async_1100';
* @tc.name Enter bearerTypes add networkCap as empty ,set class NetConnection, let netSpecifier = {
* call Register () to activate the default network ,and see if the callback information is generated netCapabilities: {
* @tc.desc Function test linkUpBandwidthKbps: 0,
*/ linkDownBandwidthKbps: 0,
bearerTypes: [1],
networkCap: [15],
}, bearerPrivateIdentifier: '123'
}
let netConn = connection.createNetConnection(netSpecifier, TIMEOUT);
netConn.register(function (error) {
if (error) {
console.info(caseName + " register fail: " + JSON.stringify(error));
done();
return;
}
netConn.on('netAvailable', function (value) {
console.log("netAvailable " + JSON.stringify(value));
});
netConn.on('netBlockStatusChange', function (value) {
console.log("netBlockStatusChange " + JSON.stringify(value));
});
netConn.on('netCapabilitiesChange', function (value) {
console.log("netCapabilitiesChange " + JSON.stringify(value));
});
netConn.on('netConnectionPropertiesChange', function (value) {
console.log("netConnectionPropertiesChange" + JSON.stringify(value));
});
netConn.on('netLost', function (value) {
console.log("netLost" + JSON.stringify(value));
});
netConn.on('netUnavailable', function (value) {
console.log("netUnavailable" + JSON.stringify(value));
});
netConn.unregister((error) => {
if (error) {
console.info(caseName + " unregister result: " + JSON.stringify(error));
expect().assertFail();
done();
}
done();
});
});
});
it('Telephony_NetworkManager_register_Async_1200', 0, async function (done) { /**
let caseName = 'Telephony_NetworkManager_register_Async_1200'; * @tc.number Telephony_NetworkManager_register_Async_1200
let netSpecifier = { * @tc.name Enter bearerTypes add networkCap as empty ,set class NetConnection,
netCapabilities: { * call Register () to activate the default network ,and see if the callback information is generated
linkUpBandwidthKbps: 0, * @tc.desc Function test
linkDownBandwidthKbps: 0, */
bearerTypes: [1],
networkCap: [16],
}, bearerPrivateIdentifier: '123'
}
let netId = 0;
let netConn = connection.createNetConnection(netSpecifier, TIMEOUT);
netConn.on('netAvailable', (error, value) => {
if (error) {
console.info("${caseName} register fail: ${error}");
expect().assertFail();
done();
} else {
console.info("${caseName} netAvailable : " + value.netId);
}
});
netConn.on('netBlockStatusChange', (error, value) => {
if (error) {
console.info("${caseName} register fail :${error}");
expect().assertFail();
done();
} else {
console.info("${caseName} netBlockStatusChange handle = :" + value.netHandle.netId);
expect(value.netHandle.netId >= ETH_100).assertTrue();
}
});
netConn.on('netCapabilitiesChange', (error, value) => {
if (error) {
console.info("${caseName} register fail :${error}");
expect().assertFail();
done();
} else {
console.info("${caseName} netCapabilitiesChange handle = :" + value.netHandle.netId);
expect(value.netHandle.netId >= ETH_100).assertTrue();
}
});
netConn.on('netConnectionPropertiesChange', (error, value) => {
if (error) {
console.info("${caseName} register fail :${error}");
expect().assertFail();
done();
} else {
console.info("${caseName} netConnectionPropertiesChange handle = :" + value.netHandle.netId);
}
});
netConn.on('netLost', (error, value) => {
if (error) {
console.info("${caseName} register fail :${error}");
expect().assertFail();
done();
} else {
console.info("${caseName} netLost " + value.netId);
}
});
netConn.on('netUnavailable', (error, value) => {
if (error) {
console.info("${caseName} register fail :${error}");
expect().assertFail();
done();
} else {
console.info("${caseName} netUnavailable " + value.netId);
netId = true;
}
});
netConn.register((error) => {
if (error) {
console.info("${caseName} register fail ${error}");
}
});
await sleep(DELAY);
expect(true).assertTrue()
netConn.unregister((error) => {
if (error) {
console.info("${caseName} unregister result : ${error}");
}
done();
});
done();
});
it('Telephony_NetworkManager_register_Async_1200', 0, async function (done) {
let caseName = 'Telephony_NetworkManager_register_Async_1200';
let netSpecifier = {
netCapabilities: {
linkUpBandwidthKbps: 0,
linkDownBandwidthKbps: 0,
bearerTypes: [1],
networkCap: [16],
}, bearerPrivateIdentifier: '123'
}
let netConn = connection.createNetConnection(netSpecifier, TIMEOUT);
netConn.register(function (error) {
if (error) {
console.info(caseName + " register fail: " + JSON.stringify(error));
done();
return;
}
netConn.on('netAvailable', function (value) {
console.log("netAvailable " + JSON.stringify(value));
});
netConn.on('netBlockStatusChange', function (value) {
console.log("netBlockStatusChange " + JSON.stringify(value));
});
netConn.on('netCapabilitiesChange', function (value) {
console.log("netCapabilitiesChange " + JSON.stringify(value));
});
netConn.on('netConnectionPropertiesChange', function (value) {
console.log("netConnectionPropertiesChange" + JSON.stringify(value));
});
netConn.on('netLost', function (value) {
console.log("netLost" + JSON.stringify(value));
});
netConn.on('netUnavailable', function (value) {
console.log("netUnavailable" + JSON.stringify(value));
});
netConn.unregister((error) => {
if (error) {
console.info(caseName + " unregister result: " + JSON.stringify(error));
expect().assertFail();
done();
}
done();
});
});
});
/**
* @tc.number Telephony_NetworkManager_register_Async_1300
* @tc.name Enter bearerTypes add networkCap as empty ,set class NetConnection,
* call Register () to activate the default network ,and see if the callback information is generated
* @tc.desc Function test
*/
it('Telephony_NetworkManager_register_Async_1300', 0, async function (done) { /**
let caseName = 'Telephony_NetworkManager_register_Async_1300'; * @tc.number Telephony_NetworkManager_register_Async_1300
let netSpecifier = { * @tc.name Enter bearerTypes add networkCap as empty ,set class NetConnection,
netCapabilities: { * call Register () to activate the default network ,and see if the callback information is generated
linkUpBandwidthKbps: 0, * @tc.desc Function test
linkDownBandwidthKbps: 0, */
bearerTypes: [1],
networkCap: [17],
}, bearerPrivateIdentifier: '123'
}
let netConn = connection.createNetConnection(netSpecifier, TIMEOUT);
netConn.on('netAvailable', (error, value) => {
if (error) {
console.info("${caseName} register fail: ${error}");
expect().assertFail();
done();
} else {
console.info("${caseName} netAvailable : " + value.netId);
expect(value.netId).assertEqual(ETH_100);
}
});
netConn.on('netBlockStatusChange', (error, value) => {
if (error) {
console.info("${caseName} register fail :${error}");
expect().assertFail();
done();
} else {
console.info("${caseName} netBlockStatusChange handle = :" + value.netHandle.netId);
expect(value.netHandle.netId >= ETH_100).assertTrue();
}
});
netConn.on('netCapabilitiesChange', (error, value) => {
if (error) {
console.info("${caseName} register fail :${error}");
expect().assertFail();
done();
} else {
console.info("${caseName} netCapabilitiesChange handle = :" + value.netHandle.netId);
expect(value.netHandle.netId >= ETH_100).assertTrue();
}
});
netConn.on('netConnectionPropertiesChange', (error, value) => {
if (error) {
console.info("${caseName} register fail :${error}");
expect().assertFail();
done();
} else {
console.info("${caseName} netConnectionPropertiesChange handle = :" + value.netHandle.netId);
expect(value.netHandle.netId >= ETH_100).assertTrue();
}
});
netConn.on('netLost', (error, value) => {
if (error) {
console.info("${caseName} register fail :${error}");
expect().assertFail();
done();
} else {
console.info("${caseName} netLost " + value.netId);
}
});
netConn.on('netUnavailable', (error, value) => {
if (error) {
console.info("${caseName} register fail :${error}");
expect().assertFail();
done();
} else {
console.info("${caseName} netUnavailable " + value);
}
});
netConn.register((error) => {
if (error) {
console.info("${caseName} register fail ${error}");
}
});
await sleep(DELAY);
netConn.unregister((error) => {
if (error) {
console.info("${caseName} unregister result : ${error}");
}
done();
});
done();
});
it('Telephony_NetworkManager_register_Async_1300', 0, async function (done) {
let caseName = 'Telephony_NetworkManager_register_Async_1300';
let netSpecifier = {
netCapabilities: {
linkUpBandwidthKbps: 0,
linkDownBandwidthKbps: 0,
bearerTypes: [1],
networkCap: [17],
}, bearerPrivateIdentifier: '123'
}
let netConn = connection.createNetConnection(netSpecifier, TIMEOUT);
netConn.register(function (error) {
if (error) {
console.info(caseName + " register fail: " + JSON.stringify(error));
done();
return;
}
netConn.on('netAvailable', function (value) {
console.log("netAvailable " + JSON.stringify(value));
});
netConn.on('netBlockStatusChange', function (value) {
console.log("netBlockStatusChange " + JSON.stringify(value));
});
netConn.on('netCapabilitiesChange', function (value) {
console.log("netCapabilitiesChange " + JSON.stringify(value));
});
netConn.on('netConnectionPropertiesChange', function (value) {
console.log("netConnectionPropertiesChange " + JSON.stringify(value));
});
netConn.on('netLost', function (value) {
console.log("netLost" + JSON.stringify(value));
});
netConn.on('netUnavailable', function (value) {
console.log("netUnavailable " + JSON.stringify(value));
});
netConn.unregister((error) => {
if (error) {
console.info(caseName + " unregister result: " + JSON.stringify(error));
expect().assertFail();
done();
}
done();
});
});
});
/**
* @tc.number Telephony_NetworkManager_register_Async_1400
* @tc.name Enter bearerTypes add networkCap as empty ,set class NetConnection,
* call Register () to activate the default network ,and see if the callback information is generated
* @tc.desc Function test
*/
it('Telephony_NetworkManager_register_Async_1400', 0, async function (done) { /**
let caseName = 'Telephony_NetworkManager_register_Async_1400'; * @tc.number Telephony_NetworkManager_register_Async_1400
let netSpecifier = { * @tc.name Enter bearerTypes add networkCap as empty ,set class NetConnection,
netCapabilities: { * call Register () to activate the default network ,and see if the callback information is generated
linkUpBandwidthKbps: 0, * @tc.desc Function test
linkDownBandwidthKbps: 0, */
bearerTypes: [2],
networkCap: [12],
}, bearerPrivateIdentifier: '123'
}
let netId = 0;
let netConn = connection.createNetConnection(netSpecifier, TIMEOUT);
netConn.on('netAvailable', (error, value) => {
if (error) {
console.info("${caseName} register fail: ${error}");
expect().assertFail();
done();
} else {
console.info("${caseName} netAvailable : " + value.netId);
}
});
netConn.on('netBlockStatusChange', (error, value) => {
if (error) {
console.info("${caseName} register fail :${error}");
expect().assertFail();
done();
} else {
console.info("${caseName} netBlockStatusChange handle = :" + value.netHandle.netId);
}
});
netConn.on('netCapabilitiesChange', (error, value) => {
if (error) {
console.info("${caseName} register fail :${error}");
expect().assertFail();
done();
} else {
console.info("${caseName} netCapabilitiesChange handle = :" + value.netHandle.netId);
}
});
netConn.on('netConnectionPropertiesChange', (error, value) => {
if (error) {
console.info("${caseName} register fail :${error}");
expect().assertFail();
done();
} else {
console.info("${caseName} netConnectionPropertiesChange handle = :" + value.netHandle.netId);
}
});
netConn.on('netLost', (error, value) => {
if (error) {
console.info("${caseName} register fail :${error}");
expect().assertFail();
done();
} else {
console.info("${caseName} netLost " + value.netId);
}
});
netConn.on('netUnavailable', (error, value) => {
if (error) {
console.info("${caseName} register fail :${error}");
expect().assertFail();
done();
} else {
console.info("${caseName} netUnavailable " + value.netId);
netId = true;
}
});
netConn.register((error) => {
if (error) {
console.info("${caseName} register fail ${error}");
}
});
await sleep(DELAY);
expect(true).assertTrue()
netConn.unregister((error) => {
if (error) {
console.info("${caseName} unregister result : ${error}");
}
done();
});
done();
});
/** it('Telephony_NetworkManager_register_Async_1400', 0, async function (done) {
* @tc.number Telephony_NetworkManager_register_Async_1500 let caseName = 'Telephony_NetworkManager_register_Async_1400';
* @tc.name Enter bearerTypes add networkCap as empty ,set class NetConnection, let netSpecifier = {
* call Register () to activate the default network ,and see if the callback information is generated netCapabilities: {
* @tc.desc Function test linkUpBandwidthKbps: 0,
*/ linkDownBandwidthKbps: 0,
bearerTypes: [2],
networkCap: [12],
}, bearerPrivateIdentifier: '123'
}
let netConn = connection.createNetConnection(netSpecifier, TIMEOUT);
netConn.register(function (error) {
if (error) {
console.info(caseName + " register fail: " + JSON.stringify(error));
done();
return;
}
netConn.on('netAvailable', function (value) {
console.log("netAvailable " + JSON.stringify(value));
});
netConn.on('netBlockStatusChange', function (value) {
console.log("netBlockStatusChange " + JSON.stringify(value));
});
netConn.on('netCapabilitiesChange', function (value) {
console.log("netCapabilitiesChange " + JSON.stringify(value));
});
netConn.on('netConnectionPropertiesChange', function (value) {
console.log("netConnectionPropertiesChange" + JSON.stringify(value));
});
netConn.on('netLost', function (value) {
console.log("netLost" + JSON.stringify(value));
});
netConn.on('netUnavailable', function (value) {
console.log("netUnavailable" + JSON.stringify(value));
});
netConn.unregister((error) => {
if (error) {
console.info(caseName + " unregister result: " + JSON.stringify(error));
expect().assertFail();
done();
}
done();
});
});
});
it('Telephony_NetworkManager_register_Async_1500', 0, async function (done) { /**
let caseName = 'Telephony_NetworkManager_register_Async_1500'; * @tc.number Telephony_NetworkManager_register_Async_1500
let netSpecifier = { * @tc.name Enter bearerTypes add networkCap as empty ,set class NetConnection,
netCapabilities: { * call Register () to activate the default network ,and see if the callback information is generated
linkUpBandwidthKbps: 0, * @tc.desc Function test
linkDownBandwidthKbps: 0, */
bearerTypes: [3],
networkCap: [12],
}, bearerPrivateIdentifier: '123'
}
let netConn = connection.createNetConnection(netSpecifier, TIMEOUT);
netConn.on('netAvailable', (error, value) => {
if (error) {
console.info("${caseName} register fail: ${error}");
expect().assertFail();
done();
} else {
console.info("${caseName} netAvailable : " + value.netId);
VALUE = value.netId;
expect(VALUE >= ETH_100).assertTrue();
}
});
netConn.on('netBlockStatusChange', (error, value) => {
if (error) {
console.info("${caseName} register fail :${error}");
expect().assertFail();
done();
} else {
console.info("${caseName} netBlockStatusChange handle = :" + value.netHandle.netId);
}
});
netConn.on('netCapabilitiesChange', (error, value) => {
if (error) {
console.info("${caseName} register fail :${error}");
expect().assertFail();
done();
} else {
console.info("${caseName} netCapabilitiesChange handle = :" + value.netHandle.netId);
}
});
netConn.on('netConnectionPropertiesChange', (error, value) => {
if (error) {
console.info("${caseName} register fail :${error}");
expect().assertFail();
done();
} else {
console.info("${caseName} netConnectionPropertiesChange handle = :" + value.netHandle.netId);
}
});
netConn.on('netLost', (error, value) => {
if (error) {
console.info("${caseName} register fail :${error}");
expect().assertFail();
done();
} else {
console.info("${caseName} netLost " + value.netId);
}
});
netConn.on('netUnavailable', (error, value) => {
if (error) {
console.info("${caseName} register fail :${error}");
expect().assertFail();
done();
} else {
console.info("${caseName} netUnavailable " + value);
}
});
netConn.register((error) => {
if (error) {
console.info("${caseName} register fail ${error}");
}
});
await sleep(DELAY);
netConn.unregister((error) => {
if (error) {
console.info("${caseName} unregister result : ${error}");
}
done();
});
done();
});
it('Telephony_NetworkManager_register_Async_1500', 0, async function (done) {
let caseName = 'Telephony_NetworkManager_register_Async_1500';
let netSpecifier = {
netCapabilities: {
linkUpBandwidthKbps: 0,
linkDownBandwidthKbps: 0,
bearerTypes: [3],
networkCap: [12],
}, bearerPrivateIdentifier: '123'
}
let netConn = connection.createNetConnection(netSpecifier, TIMEOUT);
netConn.register(function (error) {
if (error) {
console.info(caseName + " register fail: " + JSON.stringify(error));
done();
return;
}
netConn.on('netAvailable', function (value) {
console.log("netAvailable " + JSON.stringify(value));
});
netConn.on('netBlockStatusChange', function (value) {
console.log("netBlockStatusChange " + JSON.stringify(value));
});
netConn.on('netCapabilitiesChange', function (value) {
console.log("netCapabilitiesChange " + JSON.stringify(value));
});
netConn.on('netConnectionPropertiesChange', function (value) {
console.log("netConnectionPropertiesChange" + JSON.stringify(value));
});
netConn.on('netLost', function (value) {
console.log("netLost" + JSON.stringify(value));
});
netConn.on('netUnavailable', function (value) {
console.log("netUnavailable" + JSON.stringify(value));
});
netConn.unregister((error) => {
if (error) {
console.info(caseName + " unregister result: " + JSON.stringify(error));
expect().assertFail();
done();
}
done();
});
});
});
/**
* @tc.number Telephony_NetworkManager_register_Async_1600
* @tc.name Enter bearerTypes add networkCap as empty ,set class NetConnection,
* call Register () to activate the default network ,and see if the callback information is generated
* @tc.desc Function test
*/
it('Telephony_NetworkManager_register_Async_1600', 0, async function (done) { /**
let caseName = 'Telephony_NetworkManager_register_Async_1600'; * @tc.number Telephony_NetworkManager_register_Async_1600
let netSpecifier = { * @tc.name Enter bearerTypes add networkCap as empty ,set class NetConnection,
netCapabilities: { * call Register () to activate the default network ,and see if the callback information is generated
linkUpBandwidthKbps: 0, * @tc.desc Function test
linkDownBandwidthKbps: 0, */
bearerTypes: [4],
networkCap: [12],
}, bearerPrivateIdentifier: '123'
}
let netId = 0;
let netConn = connection.createNetConnection(netSpecifier, TIMEOUT);
netConn.on('netAvailable', (error, value) => {
if (error) {
console.info("${caseName} register fail: ${error}");
expect().assertFail();
done();
} else {
console.info("${caseName} netAvailable : " + value.netId);
}
});
netConn.on('netBlockStatusChange', (error, value) => {
if (error) {
console.info("${caseName} register fail :${error}");
expect().assertFail();
done();
} else {
console.info("${caseName} netBlockStatusChange handle = :" + value.netHandle.netId);
}
});
netConn.on('netCapabilitiesChange', (error, value) => {
if (error) {
console.info("${caseName} register fail :${error}");
expect().assertFail();
done();
} else {
console.info("${caseName} netCapabilitiesChange handle = :" + value.netHandle.netId);
}
});
netConn.on('netConnectionPropertiesChange', (error, value) => {
if (error) {
console.info("${caseName} register fail :${error}");
expect().assertFail();
done();
} else {
console.info("${caseName} netConnectionPropertiesChange handle = :" + value.netHandle.netId);
}
});
netConn.on('netLost', (error, value) => {
if (error) {
console.info("${caseName} register fail :${error}");
expect().assertFail();
done();
} else {
console.info("${caseName} netLost " + value.netId);
}
});
netConn.on('netUnavailable', (error, value) => {
if (error) {
console.info("${caseName} register fail :${error}");
expect().assertFail();
done();
} else {
console.info("${caseName} netUnavailable " + value);
netId = true;
}
});
netConn.register((error) => {
if (error) {
console.info("${caseName} register fail ${error}");
}
});
await sleep(DELAY);
expect(true).assertTrue()
netConn.unregister((error) => {
if (error) {
console.info("${caseName} unregister result : ${error}");
}
done();
});
done();
});
/** it('Telephony_NetworkManager_register_Async_1600', 0, async function (done) {
* @tc.number Telephony_NetworkManager_register_Async_1700 let caseName = 'Telephony_NetworkManager_register_Async_1600';
* @tc.name Enter bearerTypes add networkCap as empty ,set class NetConnection, let netSpecifier = {
* call Register () to activate the default network ,and see if the callback information is generated netCapabilities: {
* @tc.desc Function test linkUpBandwidthKbps: 0,
*/ linkDownBandwidthKbps: 0,
bearerTypes: [4],
networkCap: [12],
}, bearerPrivateIdentifier: '123'
}
let netConn = connection.createNetConnection(netSpecifier, TIMEOUT);
netConn.register(function (error) {
if (error) {
console.info(caseName + " register fail: " + JSON.stringify(error));
done();
return;
}
netConn.on('netAvailable', function (value) {
console.log("netAvailable " + JSON.stringify(value));
});
netConn.on('netBlockStatusChange', function (value) {
console.log("netBlockStatusChange " + JSON.stringify(value));
});
netConn.on('netCapabilitiesChange', function (value) {
console.log("netCapabilitiesChange " + JSON.stringify(value));
});
netConn.on('netConnectionPropertiesChange', function (value) {
console.log("netConnectionPropertiesChange" + JSON.stringify(value));
});
netConn.on('netLost', function (value) {
console.log("netLost" + JSON.stringify(value));
});
netConn.on('netUnavailable', function (value) {
console.log("netUnavailable" + JSON.stringify(value));
});
netConn.unregister((error) => {
if (error) {
console.info(caseName + " unregister result: " + JSON.stringify(error));
expect().assertFail();
done();
}
done();
});
});
});
it('Telephony_NetworkManager_register_Async_1700', 0, async function (done) { /**
let caseName = 'Telephony_NetworkManager_register_Async_1700'; * @tc.number Telephony_NetworkManager_register_Async_1700
let netSpecifier = { * @tc.name Enter bearerTypes add networkCap as empty ,set class NetConnection,
netCapabilities: { * call Register () to activate the default network ,and see if the callback information is generated
linkUpBandwidthKbps: 0, * @tc.desc Function test
linkDownBandwidthKbps: 0, */
bearerTypes: [5],
networkCap: [17],
}, bearerPrivateIdentifier: '123'
}
let netId = 0;
let netConn = connection.createNetConnection(netSpecifier, TIMEOUT);
netConn.on('netAvailable', (error, value) => {
if (error) {
console.info("${caseName} register fail: ${error}");
expect().assertFail();
done();
} else {
console.info("${caseName} netAvailable : " + value.netId);
}
});
netConn.on('netBlockStatusChange', (error, value) => {
if (error) {
console.info("${caseName} register fail :${error}");
expect().assertFail();
done();
} else {
console.info("${caseName} netBlockStatusChange handle = :" + value.netHandle.netId);
}
});
netConn.on('netCapabilitiesChange', (error, value) => {
if (error) {
console.info("${caseName} register fail :${error}");
expect().assertFail();
done();
} else {
console.info("${caseName} netCapabilitiesChange handle = :" + value.netHandle.netId);
}
});
netConn.on('netConnectionPropertiesChange', (error, value) => {
if (error) {
console.info("${caseName} register fail :${error}");
expect().assertFail();
done();
} else {
console.info("${caseName} netConnectionPropertiesChange handle = :" + value.netHandle.netId);
}
});
netConn.on('netLost', (error, value) => {
if (error) {
console.info("${caseName} register fail :${error}");
expect().assertFail();
done();
} else {
console.info("${caseName} netLost " + value.netId);
}
});
netConn.on('netUnavailable', (error, value) => {
if (error) {
console.info("${caseName} register fail :${error}");
expect().assertFail();
done();
} else {
console.info("${caseName} netUnavailable " + value);
netId = true;
}
});
netConn.register((error) => {
if (error) {
console.info("${caseName} register fail ${error}");
}
});
await sleep(DELAY);
expect(true).assertTrue()
netConn.unregister((error) => {
if (error) {
console.info("${caseName} unregister result : ${error}");
}
done();
});
done();
});
/** it('Telephony_NetworkManager_register_Async_1700', 0, async function (done) {
* @tc.number Telephony_NetworkManager_register_Async_1800 let caseName = 'Telephony_NetworkManager_register_Async_1700';
* @tc.name Enter bearerTypes add networkCap as empty ,set class NetConnection, let netSpecifier = {
* call Register () to activate the default network ,and see if the callback information is generated netCapabilities: {
* @tc.desc Function test linkUpBandwidthKbps: 0,
*/ linkDownBandwidthKbps: 0,
bearerTypes: [5],
networkCap: [17],
}, bearerPrivateIdentifier: '123'
}
let netConn = connection.createNetConnection(netSpecifier, TIMEOUT);
netConn.register(function (error) {
if (error) {
console.info(caseName + " register fail: " + JSON.stringify(error));
done();
return;
}
netConn.on('netAvailable', function (value) {
console.log("netAvailable " + JSON.stringify(value));
});
netConn.on('netBlockStatusChange', function (value) {
console.log("netBlockStatusChange " + JSON.stringify(value));
});
netConn.on('netCapabilitiesChange', function (value) {
console.log("netCapabilitiesChange " + JSON.stringify(value));
});
netConn.on('netConnectionPropertiesChange', function (value) {
console.log("netConnectionPropertiesChange" + JSON.stringify(value));
});
netConn.on('netLost', function (value) {
console.log("netLost" + JSON.stringify(value));
});
netConn.on('netUnavailable', function (value) {
console.log("netUnavailable" + JSON.stringify(value));
});
netConn.unregister((error) => {
if (error) {
console.info(caseName + " unregister result: " + JSON.stringify(error));
expect().assertFail();
done();
}
done();
});
});
});
it('Telephony_NetworkManager_register_Async_1800', 0, async function (done) { /**
let caseName = 'Telephony_NetworkManager_register_Async_1800'; * @tc.number Telephony_NetworkManager_register_Async_1800
let netSpecifier = { * @tc.name Enter bearerTypes add networkCap as empty ,set class NetConnection,
netCapabilities: { * call Register () to activate the default network ,and see if the callback information is generated
linkUpBandwidthKbps: 0, * @tc.desc Function test
linkDownBandwidthKbps: 0, */
bearerTypes: [4],
networkCap: [12],
}, bearerPrivateIdentifier: '123'
}
let netId = 0;
let netConn = connection.createNetConnection(netSpecifier, TIMEOUT);
netConn.on('netAvailable', (error, value) => {
if (error) {
console.info("${caseName} register fail: ${error}");
expect().assertFail();
done();
} else {
console.info("${caseName} netAvailable : " + value.netId);
}
});
netConn.on('netBlockStatusChange', (error, value) => {
if (error) {
console.info("${caseName} register fail :${error}");
expect().assertFail();
done();
} else {
console.info("${caseName} netBlockStatusChange handle = :" + value.netHandle.netId);
}
});
netConn.on('netCapabilitiesChange', (error, value) => {
if (error) {
console.info("${caseName} register fail :${error}");
expect().assertFail();
done();
} else {
console.info("${caseName} netCapabilitiesChange handle = :" + value.netHandle.netId);
}
});
netConn.on('netConnectionPropertiesChange', (error, value) => {
if (error) {
console.info("${caseName} register fail :${error}");
expect().assertFail();
done();
} else {
console.info("${caseName} netConnectionPropertiesChange handle = :" + value.netHandle.netId);
}
});
netConn.on('netLost', (error, value) => {
if (error) {
console.info("${caseName} register fail :${error}");
expect().assertFail();
done();
} else {
console.info("${caseName} netLost " + value.netId);
}
});
netConn.on('netUnavailable', (error, value) => {
if (error) {
console.info("${caseName} register fail :${error}");
expect().assertFail();
done();
} else {
console.info("${caseName} netUnavailable " + value);
netId = true;
}
});
netConn.register((error) => {
if (error) {
console.info("${caseName} register fail ${error}");
}
});
await sleep(DELAY);
expect(true).assertTrue()
netConn.unregister((error) => {
if (error) {
console.info("${caseName} unregister result : ${error}");
}
done();
});
await sleep(DELAY);
let netConn1 = connection.createNetConnection(netSpecifier, TIMEOUT);
netConn1.on('netAvailable', (error, value) => {
if (error) {
console.info("${caseName} register fail: ${error}");
expect().assertFail();
done();
} else {
console.info("${caseName} netAvailable : " + value.netId);
}
});
netConn.on('netBlockStatusChange', (error, value) => {
if (error) {
console.info("${caseName} register fail :${error}");
expect().assertFail();
done();
} else {
console.info("${caseName} netBlockStatusChange handle = :" + value.netHandle.netId);
}
});
netConn1.on('netCapabilitiesChange', (error, value) => {
if (error) {
console.info("${caseName} register fail :${error}");
expect().assertFail();
done();
} else {
console.info("${caseName} netCapabilitiesChange handle = :" + value.netHandle.netId);
}
});
netConn1.on('netConnectionPropertiesChange', (error, value) => {
if (error) {
console.info("${caseName} register fail :${error}");
expect().assertFail();
done();
} else {
console.info("${caseName} netConnectionPropertiesChange handle = :" + value.netHandle.netId);
}
});
netConn1.on('netLost', (error, value) => {
if (error) {
console.info("${caseName} register fail :${error}");
expect().assertFail();
done();
} else {
console.info("${caseName} netLost " + value.netId);
}
});
netConn1.on('netUnavailable', (error, value) => {
if (error) {
console.info("${caseName} register fail :${error}");
expect().assertFail();
done();
} else {
console.info("${caseName} netUnavailable " + value);
netId = true;
}
});
netConn1.register((error) => {
if (error) {
console.info("${caseName} register fail ${error}");
}
});
await sleep(DELAY);
expect(true).assertTrue()
netConn1.unregister((error) => {
if (error) {
console.info("${caseName} unregister result : ${error}");
}
done();
});
done();
});
/** it('Telephony_NetworkManager_register_Async_1800', 0, async function (done) {
* @tc.number Telephony_NetworkManager_register_Async_1900 let caseName = 'Telephony_NetworkManager_register_Async_1800';
* @tc.name Enter bearerTypes add networkCap as empty ,set class NetConnection, let netSpecifier = {
* call Register () to activate the default network ,and see if the callback information is generated netCapabilities: {
* @tc.desc Function test linkUpBandwidthKbps: 0,
*/ linkDownBandwidthKbps: 0,
bearerTypes: [4],
networkCap: [12],
}, bearerPrivateIdentifier: '123'
}
let netConn = connection.createNetConnection(netSpecifier, TIMEOUT);
netConn.register(function (error) {
if (error) {
console.info(caseName + " register fail: " + JSON.stringify(error));
done();
return;
}
netConn.unregister((error) => {
if (error) {
console.info(caseName + " unregister result: " + JSON.stringify(error));
expect().assertFail();
done();
return;
}
let netConn1 = connection.createNetConnection(netSpecifier, TIMEOUT);
netConn1.register(function (error) {
if (error) {
console.info(caseName + " register fail: " + JSON.stringify(error));
done();
return;
}
netConn1.unregister((error) => {
if (error) {
console.info(caseName + " unregister result: " + JSON.stringify(error));
expect().assertFail();
done();
}
done();
});
});
});
});
});
it('Telephony_NetworkManager_register_Async_1900', 0, async function (done) { /**
let caseName = 'Telephony_NetworkManager_register_Async_1900'; * @tc.number Telephony_NetworkManager_register_Async_1900
let netSpecifier = { * @tc.name Enter bearerTypes add networkCap as empty ,set class NetConnection,
netCapabilities: { * call Register () to activate the default network ,and see if the callback information is generated
linkUpBandwidthKbps: 0, * @tc.desc Function test
linkDownBandwidthKbps: 0, */
bearerTypes: [6],
networkCap: [18],
}, bearerPrivateIdentifier: '123'
}
let netConn = connection.createNetConnection(netSpecifier, TIMEOUT);
netConn.on('netAvailable', (error, value) => {
if (error) {
console.info("${caseName} register fail: ${error}");
expect().assertFail();
done();
} else {
console.info("${caseName} netAvailable : " + value.netId);
}
});
netConn.on('netBlockStatusChange', (error, value) => {
if (error) {
console.info("${caseName} register fail :${error}");
expect().assertFail();
done();
} else {
console.info("${caseName} netBlockStatusChange handle = :" + value.netHandle.netId);
}
});
netConn.on('netCapabilitiesChange', (error, value) => {
if (error) {
console.info("${caseName} register fail :${error}");
expect().assertFail();
done();
} else {
console.info("${caseName} netCapabilitiesChange handle = :" + value.netHandle.netId);
}
});
netConn.on('netConnectionPropertiesChange', (error, value) => {
if (error) {
console.info("${caseName} register fail :${error}");
expect().assertFail();
done();
} else {
console.info("${caseName} netConnectionPropertiesChange handle = :" + value.netHandle.netId);
}
});
netConn.on('netLost', (error, value) => {
if (error) {
console.info("${caseName} register fail :${error}");
expect().assertFail();
done();
} else {
console.info("${caseName} netLost " + value.netId);
}
});
netConn.on('netUnavailable', (error, value) => {
if (error) {
console.info("${caseName} register fail :${error}");
expect().assertFail();
done();
} else {
console.info("${caseName} netUnavailable " + value);
}
});
netConn.register((error) => {
if (error) {
done(); it('Telephony_NetworkManager_register_Async_1900', 0, async function (done) {
} let caseName = 'Telephony_NetworkManager_register_Async_1900';
done(); let netSpecifier = {
}); netCapabilities: {
done(); linkUpBandwidthKbps: 0,
}); linkDownBandwidthKbps: 0,
bearerTypes: [6],
networkCap: [18],
}, bearerPrivateIdentifier: '123'
}
let netConn = connection.createNetConnection(netSpecifier, TIMEOUT);
netConn.register(function (error) {
if (error) {
console.info(caseName + " register finish: " + JSON.stringify(error));
done();
return;
}
netConn.unregister((error) => {
if (error) {
console.info(caseName + " unregister result: " + JSON.stringify(error));
expect().assertFail();
done();
}
done();
});
});
});
/** /**
* @tc.number Telephony_NetworkManager_register_Async_2000 * @tc.number Telephony_NetworkManager_register_Async_2000
* @tc.name Enter bearerTypes add networkCap as empty ,set class NetConnection, * @tc.name Enter bearerTypes add networkCap as empty ,set class NetConnection,
* call Register () to activate the default network ,and see if the callback information is generated * call Register () to activate the default network ,and see if the callback information is generated
* @tc.desc Function test * @tc.desc Function test
*/ */
it('Telephony_NetworkManager_register_Async_2000', 0, async function (done) { it('Telephony_NetworkManager_register_Async_2000', 0, async function (done) {
let caseName = 'Telephony_NetworkManager_register_Async_2000'; let caseName = 'Telephony_NetworkManager_register_Async_2000';
let netSpecifier = { let netSpecifier = {
netCapabilities: { netCapabilities: {
linkUpBandwidthKbps: 0, linkUpBandwidthKbps: 0,
linkDownBandwidthKbps: 0, linkDownBandwidthKbps: 0,
bearerTypes: [0], bearerTypes: [0],
networkCap: [0], networkCap: [0],
}, bearerPrivateIdentifier: '123' }, bearerPrivateIdentifier: '123'
} }
let netId = 0; let netConn = connection.createNetConnection(netSpecifier, TIMEOUT);
let netConn = connection.createNetConnection(netSpecifier, TIMEOUT); netConn.register(function (error) {
netConn.on('netAvailable', (error, value) => { if (error) {
expect(false).assertTrue() console.info(caseName + " register fail " + error);
done(); done();
}); return;
netConn.on('netBlockStatusChange', (error, value) => { }
expect(false).assertTrue() netConn.on('netAvailable', function (value) {
done(); console.log("netAvailable " + JSON.stringify(value));
}); });
netConn.on('netCapabilitiesChange', (error, value) => { netConn.on('netBlockStatusChange', function (value) {
expect(false).assertTrue() console.log("netBlockStatusChange " + JSON.stringify(value));
done(); });
}); netConn.on('netCapabilitiesChange', function (value) {
netConn.on('netConnectionPropertiesChange', (error, value) => { console.log("netCapabilitiesChange " + JSON.stringify(value));
expect(false).assertTrue() });
done(); netConn.on('netConnectionPropertiesChange', function (value) {
}); console.log("netConnectionPropertiesChange " + JSON.stringify(value));
netConn.on('netLost', (error, value) => { });
expect(false).assertTrue() netConn.on('netLost', function (value) {
done(); console.log("netLost " + JSON.stringify(value));
}); });
netConn.on('netUnavailable', (error, value) => { netConn.on('netUnavailable', function (value) {
done(); console.log("netUnavailable " + JSON.stringify(value));
}); });
netConn.register((error) => { netConn.unregister((error) => {
if (error) { if (error) {
console.info("${caseName} register fail ${error}"); console.info(caseName + " unregister fail " + error);
} expect().assertFail();
}); done();
await sleep(DELAY); }
netConn.unregister((error) => { done();
if (error) { });
console.info("${caseName} unregister result : ${error}"); });
} });
});
done();
});
/** /**
* @tc.number Telephony_NetworkManager_register_Async_2100 * @tc.number Telephony_NetworkManager_register_Async_2100
* @tc.name Enter bearerTypes add networkCap as empty ,set class NetConnection, * @tc.name Enter bearerTypes add networkCap as empty ,set class NetConnection,
* call Register () to activate the default network ,and see if the callback information is generated * call Register () to activate the default network ,and see if the callback information is generated
* @tc.desc Function test * @tc.desc Function test
*/ */
it('Telephony_NetworkManager_register_Async_2100', 0, async function (done) { it('Telephony_NetworkManager_register_Async_2100', 0, async function (done) {
let caseName = 'Telephony_NetworkManager_register_Async_2100'; let caseName = 'Telephony_NetworkManager_register_Async_2100';
let netSpecifier = { let netSpecifier = {
netCapabilities: { netCapabilities: {
linkUpBandwidthKbps: 0, linkUpBandwidthKbps: 0,
linkDownBandwidthKbps: 0, linkDownBandwidthKbps: 0,
bearerTypes: [0], bearerTypes: [0],
networkCap: [0], networkCap: [0],
}, bearerPrivateIdentifier: '123' }, bearerPrivateIdentifier: '123'
} }
let netId = 0; let netConn = connection.createNetConnection(netSpecifier, TIMEOUT);
let netConn = connection.createNetConnection(netSpecifier, TIMEOUT); netConn.register(function (error) {
netConn.on('netAvailable', (error, value) => { if (error) {
if (error) { console.info(caseName + " register fail: " + JSON.stringify(error));
console.info("${caseName} register fail: ${error}"); done();
expect().assertFail(); return;
done(); }
} else { netConn.unregister((error) => {
console.info("${caseName} netAvailable : " + value.netId); if (error) {
} console.info(caseName + " unregister result: " + JSON.stringify(error));
}); expect().assertFail();
netConn.on('netBlockStatusChange', (error, value) => { done();
if (error) { return;
console.info("${caseName} register fail :${error}"); }
expect().assertFail(); let netSpecifier1 = {
done(); netCapabilities: {
} else { linkUpBandwidthKbps: 0,
console.info("${caseName} netBlockStatusChange handle = :" + value.netHandle.netId); linkDownBandwidthKbps: 0,
} bearerTypes: [0],
}); networkCap: [12],
netConn.on('netCapabilitiesChange', (error, value) => { }, bearerPrivateIdentifier: '123'
if (error) { }
console.info("${caseName} register fail :${error}"); let netConn1 = connection.createNetConnection(netSpecifier1, TIMEOUT);
expect().assertFail(); netConn1.register(function (error) {
done(); if (error) {
} else { console.info(caseName + " register fail: " + JSON.stringify(error));
console.info("${caseName} netCapabilitiesChange handle = :" + value.netHandle.netId); expect().assertFail();
} done();
}); return;
netConn.on('netConnectionPropertiesChange', (error, value) => { }
if (error) { netConn1.unregister((error) => {
console.info("${caseName} register fail :${error}"); if (error) {
expect().assertFail(); console.info(caseName + " unregister result: " + JSON.stringify(error));
done(); expect().assertFail();
} else { done();
console.info("${caseName} netConnectionPropertiesChange handle = :" + value.netHandle.netId); }
} done();
}); });
netConn.on('netLost', (error, value) => { });
if (error) { });
console.info("${caseName} register fail :${error}"); });
expect().assertFail(); });
done();
} else {
console.info("${caseName} netLost " + value.netId);
}
});
netConn.on('netUnavailable', (error, value) => {
if (error) {
console.info("${caseName} register fail :${error}");
expect().assertFail();
done();
} else {
console.info("${caseName} netUnavailable " + value);
netId = true;
}
});
netConn.register((error) => {
if (error) {
console.info("${caseName} register fail ${error}");
}
});
await sleep(DELAY);
expect(true).assertTrue()
netConn.unregister((error) => {
if (error) {
console.info("${caseName} unregister result : ${error}");
}
done();
});
let netSpecifier1 = {
netCapabilities: {
linkUpBandwidthKbps: 0,
linkDownBandwidthKbps: 0,
bearerTypes: [0],
networkCap: [12],
}, bearerPrivateIdentifier: '123'
}
let netConn1 = connection.createNetConnection(netSpecifier1, TIMEOUT);
netConn1.on('netAvailable', (error, value) => {
if (error) {
console.info("${caseName} register fail: ${error}");
expect().assertFail();
done();
} else {
console.info("${caseName} netAvailable : " + value.netId);
}
});
netConn1.on('netBlockStatusChange', (error, value) => {
if (error) {
console.info("${caseName} register fail :${error}");
expect().assertFail();
done();
} else {
console.info("${caseName} netBlockStatusChange handle = :" + value.netHandle.netId);
}
});
netConn1.on('netCapabilitiesChange', (error, value) => {
if (error) {
console.info("${caseName} register fail :${error}");
expect().assertFail();
done();
} else {
console.info("${caseName} netCapabilitiesChange handle = :" + value.netHandle.netId);
}
});
netConn1.on('netConnectionPropertiesChange', (error, value) => {
if (error) {
console.info("${caseName} register fail :${error}");
expect().assertFail();
done();
} else {
console.info("${caseName} netConnectionPropertiesChange handle = :" + value.netHandle.netId);
}
});
netConn1.on('netLost', (error, value) => {
if (error) {
console.info("${caseName} register fail :${error}");
expect().assertFail();
done();
} else {
console.info("${caseName} netLost " + value.netId);
}
});
netConn1.on('netUnavailable', (error, value) => {
if (error) {
console.info("${caseName} register fail :${error}");
expect().assertFail();
done();
} else {
console.info("${caseName} netUnavailable " + value);
netId = true;
}
});
netConn1.register((error) => {
if (error) {
console.info("${caseName} register fail ${error}");
}
});
await sleep(DELAY);
expect(true).assertTrue()
netConn1.unregister((error) => {
if (error) {
console.info("${caseName} unregister result : ${error}");
}
done();
});
done();
});
/** /**
* @tc.number Telephony_NetworkManager_register_Async_2200 * @tc.number Telephony_NetworkManager_register_Async_2200
* @tc.name Enter bearerTypes add networkCap as empty ,set class NetConnection, * @tc.name Enter bearerTypes add networkCap as empty ,set class NetConnection,
* call Register () to activate the default network ,and see if the callback information is generated * call Register () to activate the default network ,and see if the callback information is generated
* @tc.desc Function test * @tc.desc Function test
*/ */
it('Telephony_NetworkManager_register_Async_2200', 0, async function (done) { it('Telephony_NetworkManager_register_Async_2200', 0, async function (done) {
let caseName = 'Telephony_NetworkManager_register_Async_2200'; let caseName = 'Telephony_NetworkManager_register_Async_2200';
let netSpecifier = { let netSpecifier = {
netCapabilities: { netCapabilities: {
linkUpBandwidthKbps: 0, linkUpBandwidthKbps: 0,
linkDownBandwidthKbps: 0, linkDownBandwidthKbps: 0,
bearerTypes: [0], bearerTypes: [0],
networkCap: [0], networkCap: [0],
}, bearerPrivateIdentifier: '123' }, bearerPrivateIdentifier: '123'
} }
let netId = 0; let netConn = connection.createNetConnection(netSpecifier, TIMEOUT);
let netConn = connection.createNetConnection(netSpecifier, TIMEOUT); netConn.register(function (error) {
netConn.on('netAvailable', (error, value) => { if (error) {
if (error) { console.info(caseName + " register fail: " + JSON.stringify(error));
console.info("${caseName} register fail: ${error}"); done();
expect().assertFail(); return;
done(); }
} else { netConn.unregister((error) => {
console.info("${caseName} netAvailable : " + value.netId); if (error) {
} console.info(caseName + " unregister result: " + JSON.stringify(error));
}); expect().assertFail();
netConn.on('netBlockStatusChange', (error, value) => { done();
if (error) { return;
console.info("${caseName} register fail :${error}"); }
expect().assertFail(); let netSpecifier1 = {
done(); netCapabilities: {
} else { linkUpBandwidthKbps: 0,
console.info("${caseName} netBlockStatusChange handle = :" + value.netHandle.netId); linkDownBandwidthKbps: 0,
} bearerTypes: [1],
}); networkCap: [12],
netConn.on('netCapabilitiesChange', (error, value) => { }, bearerPrivateIdentifier: '123'
if (error) { }
console.info("${caseName} register fail :${error}"); let netConn1 = connection.createNetConnection(netSpecifier1, TIMEOUT);
expect().assertFail(); netConn1.register(function (error) {
done(); if (error) {
} else { console.info(caseName + " register fail: " + JSON.stringify(error));
console.info("${caseName} netCapabilitiesChange handle = :" + value.netHandle.netId); expect().assertFail();
} done();
}); return;
netConn.on('netConnectionPropertiesChange', (error, value) => { }
if (error) { netConn1.unregister((error) => {
console.info("${caseName} register fail :${error}"); if (error) {
expect().assertFail(); console.info(caseName + " unregister result: " + JSON.stringify(error));
done(); expect().assertFail();
} else { done();
console.info("${caseName} netConnectionPropertiesChange handle = :" + value.netHandle.netId); }
} done();
}); });
netConn.on('netLost', (error, value) => { });
if (error) { });
console.info("${caseName} register fail :${error}"); });
expect().assertFail(); });
done();
} else {
console.info("${caseName} netLost " + value.netId);
}
});
netConn.on('netUnavailable', (error, value) => {
if (error) {
console.info("${caseName} register fail :${error}");
expect().assertFail();
done();
} else {
console.info("${caseName} netUnavailable " + value.netId);
netId = true;
}
});
netConn.register((error) => {
if (error) {
console.info("${caseName} register fail ${error}");
}
});
await sleep(DELAY);
expect(true).assertTrue()
netConn.unregister((error) => {
if (error) {
console.info("${caseName} unregister result : ${error}");
}
done();
});
let netSpecifier1 = {
netCapabilities: {
linkUpBandwidthKbps: 0,
linkDownBandwidthKbps: 0,
bearerTypes: [1],
networkCap: [12],
}, bearerPrivateIdentifier: '123'
}
let netConn1 = connection.createNetConnection(netSpecifier1, TIMEOUT);
netConn1.on('netAvailable', (error, value) => {
if (error) {
console.info("${caseName} register fail: ${error}");
expect().assertFail();
done();
} else {
console.info("${caseName} netAvailable : " + value.netId);
}
});
netConn1.on('netBlockStatusChange', (error, value) => {
if (error) {
console.info("${caseName} register fail :${error}");
expect().assertFail();
done();
} else {
console.info("${caseName} netBlockStatusChange handle = :" + value.netHandle.netId);
}
});
netConn1.on('netCapabilitiesChange', (error, value) => {
if (error) {
console.info("${caseName} register fail :${error}");
expect().assertFail();
done();
} else {
console.info("${caseName} netCapabilitiesChange handle = :" + value.netHandle.netId);
}
});
netConn1.on('netConnectionPropertiesChange', (error, value) => {
if (error) {
console.info("${caseName} register fail :${error}");
expect().assertFail();
done();
} else {
console.info("${caseName} netConnectionPropertiesChange handle = :" + value.netHandle.netId);
}
});
netConn1.on('netLost', (error, value) => {
if (error) {
console.info("${caseName} register fail :${error}");
expect().assertFail();
done();
} else {
console.info("${caseName} netLost " + value.netId);
}
});
netConn1.on('netUnavailable', (error, value) => {
if (error) {
console.info("${caseName} register fail :${error}");
expect().assertFail();
done();
} else {
console.info("${caseName} netUnavailable " + value.netId);
netId = true;
}
});
netConn1.register((error) => {
if (error) {
console.info("${caseName} register fail ${error}");
}
});
await sleep(DELAY);
expect(true).assertTrue()
netConn1.unregister((error) => {
if (error) {
console.info("${caseName} unregister result : ${error}");
}
done();
});
done();
});
/** /**
* @tc.number Telephony_NetworkManager_register_Async_2300 * @tc.number Telephony_NetworkManager_register_Async_2300
* @tc.name Enter bearerTypes add networkCap as empty ,set class NetConnection, * @tc.name Enter bearerTypes add networkCap as empty ,set class NetConnection,
* call Register () to activate the default network ,and see if the callback information is generated * call Register () to activate the default network ,and see if the callback information is generated
* @tc.desc Function test * @tc.desc Function test
*/ */
it('Telephony_NetworkManager_register_Async_2300', 0, async function (done) { it('Telephony_NetworkManager_register_Async_2300', 0, async function (done) {
let caseName = 'Telephony_NetworkManager_register_Async_2300'; let caseName = 'Telephony_NetworkManager_register_Async_2300';
let netConn = connection.createNetConnection(); let netConn = connection.createNetConnection();
let returnValue = 0; netConn.register(function (error) {
netConn.on('netAvailable', (value) => { if (error) {
if (value === undefined) { console.info(caseName + " register fail: " + JSON.stringify(error));
console.info("${caseName} on netAvailable fail"); expect().assertFail();
expect().assertFail(); done();
done(); return;
} else { }
console.info("${caseName} netAvailable" + value.netId); netConn.on('netAvailable', function (value) {
returnValue = value.netId; console.log("netAvailable " + JSON.stringify(value));
} });
}); netConn.on('netBlockStatusChange', function (value) {
netConn.on('netCapabilitiesChange', (value) => { console.log("netBlockStatusChange " + JSON.stringify(value));
if (value === undefined) { });
console.info("${caseName} on netCapabilitiesChange fail"); netConn.on('netCapabilitiesChange', function (value) {
expect().assertFail(); console.log("netCapabilitiesChange " + JSON.stringify(value));
done(); });
} else { netConn.on('netConnectionPropertiesChange', function (value) {
console.info("${caseName} netCapabilitiesChange handle " + value.netHandle.netId); console.log("netConnectionPropertiesChange" + JSON.stringify(value));
expect(value.netHandle.netId >= ETH_100 ).assertTrue(); });
} netConn.on('netLost', function (value) {
}); console.log("netLost" + JSON.stringify(value));
netConn.on('netConnectionPropertiesChange', (value) => { });
if (value === undefined) { netConn.on('netUnavailable', function (value) {
console.info("${caseName} on netConnectionPropertiesChange fail"); console.log("netUnavailable" + JSON.stringify(value));
expect().assertFail(); });
done(); netConn.unregister((error) => {
} else { if (error) {
console.info("${caseName} netConnectionPropertiesChange hdndle" + value.netHandle.netId); console.info(caseName + " unregister result: " + JSON.stringify(error));
} expect().assertFail();
}); done();
netConn.on('netLost', (value) => { }
if (error) { done();
console.info("${caseName} netLost fail"); });
expect().assertFail(); });
done(); });
} else {
console.info("${caseName} netLost " + value.netId);
}
});
netConn.register((error) => {
if (error) {
console.info("${caseName} register fail ${error}");
}
});
await sleep(DELAY);
console.info("${caseName} returnValue " + returnValue);
netConn.unregister((error) => {
if (error) {
console.info("${caseName} unregister result : ${error}");
done();
}
done();
});
done();
});
/** /**
* @tc.number Telephony_NetworkManager_unregister_Async_0100 * @tc.number Telephony_NetworkManager_unregister_Async_0100
* @tc.name Enter bearerTypes add networkCap as empty ,set class NetConnection, * @tc.name Enter bearerTypes add networkCap as empty ,set class NetConnection,
* call Register () to activate the default network ,and see if the callback information is generated * call Register () to activate the default network ,and see if the callback information is generated
* @tc.desc Function test * @tc.desc Function test
*/ */
it('Telephony_NetworkManager_unregister_Async_0100', 0, async function (done) { it('Telephony_NetworkManager_unregister_Async_0100', 0, async function (done) {
if (!envReady) { let caseName = 'Telephony_NetworkManager_unregister_Async_0100';
console.info("The environment was not ready"); let netSpecifier = {
done(); netCapabilities: {
return; linkUpBandwidthKbps: 0,
} linkDownBandwidthKbps: 0,
let caseName = 'Telephony_NetworkManager_unregister_Async_0100'; bearerTypes: [0],
let netSpecifier = { networkCap: [0],
netCapabilities: { }, bearerPrivateIdentifier: '123'
linkUpBandwidthKbps: 0, }
linkDownBandwidthKbps: 0, let netConn = connection.createNetConnection(netSpecifier, TIMEOUT);
bearerTypes: [0], netConn.register(function (error) {
networkCap: [0], if (error) {
}, bearerPrivateIdentifier: '123' console.info(caseName + " register fail: " + JSON.stringify(error));
} done();
let netConn = connection.createNetConnection(netSpecifier, TIMEOUT_1); return;
netConn.on('netAvailable', (error, value) => { }
if (error) { netConn.on('netAvailable', function (value) {
console.info("${caseName} register fail: ${error}"); console.log("netAvailable " + JSON.stringify(value));
expect().assertFail(); });
done(); netConn.on('netBlockStatusChange', function (value) {
} else { console.log("netBlockStatusChange " + JSON.stringify(value));
console.info("${caseName} netAvailable : " + value.netId); });
done(); netConn.on('netCapabilitiesChange', function (value) {
} console.log("netCapabilitiesChange " + JSON.stringify(value));
}); });
netConn.on('netBlockStatusChange', (error, value) => { netConn.on('netConnectionPropertiesChange', function (value) {
if (error) { console.log("netConnectionPropertiesChange" + JSON.stringify(value));
console.info("${caseName} register fail :${error}"); });
expect().assertFail(); netConn.on('netLost', function (value) {
done(); console.log("netLost" + JSON.stringify(value));
} else { });
console.info("${caseName} netBlockStatusChange handle = :" + value.netHandle.netId); netConn.on('netUnavailable', function (value) {
done(); console.log("netUnavailable" + JSON.stringify(value));
} });
}); netConn.unregister((error) => {
netConn.on('netCapabilitiesChange', (error, value) => { if (error) {
if (error) { console.info(caseName + " unregister result: " + JSON.stringify(error));
console.info("${caseName} register fail :${error}"); expect().assertFail();
expect().assertFail(); done();
done(); }
} else { done();
console.info("${caseName} netCapabilitiesChange handle = :" + value.netHandle.netId); });
done(); });
} });
});
netConn.on('netConnectionPropertiesChange', (error, value) => {
if (error) {
console.info("${caseName} register fail :${error}");
expect().assertFail();
done();
} else {
console.info("${caseName} netConnectionPropertiesChange handle = :" + value.netHandle.netId);
done();
}
});
netConn.on('netLost', (error, value) => {
if (error) {
console.info("${caseName} register fail :${error}");
expect().assertFail();
done();
} else {
console.info("${caseName} netLost " + value.netId);
done();
}
});
netConn.on('netUnavailable', (error, value) => {
if (error) {
console.info("${caseName} register fail :${error}");
expect().assertFail();
done();
} else {
console.info("${caseName} netUnavailable " + value.netId);
done();
}
});
netConn.register((error) => {
if (error) {
console.info("${caseName} register fail ${error}");
}
});
netConn.unregister((error) => {
if (error) {
console.info("${caseName} unregister result : ${error}");
expect().assertFail();
done();
}
done();
});
done();
});
/**
* @tc.number Telephony_NetworkManager_unregister_Async_0200
* @tc.name Enter bearerTypes add networkCap as empty ,set class NetConnection,
* call Register () to activate the default network ,and see if the callback information is generated
* @tc.desc Function test
*/
it('Telephony_NetworkManager_unregister_Async_0200', 0, async function (done) {
let caseName = 'Telephony_NetworkManager_unregister_Async_0200';
let netConn = connection.createNetConnection();
netConn.register(function (error) {
if (error) {
console.info(caseName + " register fail: " + JSON.stringify(error));
expect().assertFail();
done();
return;
}
netConn.on('netAvailable', function (value) {
console.log("netAvailable " + JSON.stringify(value));
});
netConn.on('netBlockStatusChange', function (value) {
console.log("netBlockStatusChange " + JSON.stringify(value));
});
netConn.on('netCapabilitiesChange', function (value) {
console.log("netCapabilitiesChange " + JSON.stringify(value));
});
netConn.on('netConnectionPropertiesChange', function (value) {
console.log("netConnectionPropertiesChange" + JSON.stringify(value));
});
netConn.on('netLost', function (value) {
console.log("netLost" + JSON.stringify(value));
});
netConn.on('netUnavailable', function (value) {
console.log("netUnavailable" + JSON.stringify(value));
});
netConn.unregister((error) => {
if (error) {
console.info(caseName + " unregister result: " + JSON.stringify(error));
expect().assertFail();
done();
}
done();
});
});
});
/** /**
* @tc.number Telephony_NetworkManager_unregister_Async_0200 * @tc.number Telephony_NetworkManager_unregister_Async_0300
* @tc.name Enter bearerTypes add networkCap as empty ,set class NetConnection, * @tc.name Enter bearerTypes add networkCap as empty ,set class NetConnection,
* call Register () to activate the default network ,and see if the callback information is generated * call Register () to activate the default network ,and see if the callback information is generated
* @tc.desc Function test * @tc.desc Function test
*/ */
it('Telephony_NetworkManager_unregister_Async_0200', 0, async function (done) { it('Telephony_NetworkManager_unregister_Async_0300', 0, async function (done) {
if (!envReady) { let caseName = 'Telephony_NetworkManager_unregister_Async_0300';
console.info("The environment was not ready"); let netConn = connection.createNetConnection();
done(); netConn.register(function (error) {
return; if (error) {
} console.info(caseName + " register fail: " + JSON.stringify(error));
let caseName = 'Telephony_NetworkManager_unregister_Async_0200'; expect().assertFail();
let netConn = connection.createNetConnection(); done();
netConn.on('netAvailable', (error, value) => { return;
if (error) { }
console.info("${caseName} register fail: ${error}"); netConn.on('netAvailable', function (value) {
expect().assertFail(); console.log("netAvailable " + JSON.stringify(value));
done(); });
} else { netConn.on('netBlockStatusChange', function (value) {
console.info("${caseName} netAvailable : " + value.netId); console.log("netBlockStatusChange " + JSON.stringify(value));
done(); });
} netConn.on('netCapabilitiesChange', function (value) {
}); console.log("netCapabilitiesChange " + JSON.stringify(value));
netConn.on('netBlockStatusChange', (error, value) => { });
if (error) { netConn.on('netConnectionPropertiesChange', function (value) {
console.info("${caseName} register fail :${error}"); console.log("netConnectionPropertiesChange" + JSON.stringify(value));
expect().assertFail(); });
done(); netConn.on('netLost', function (value) {
} else { console.log("netLost" + JSON.stringify(value));
console.info("${caseName} netBlockStatusChange handle = :" + value.netHandle.netId); });
done(); netConn.on('netUnavailable', function (value) {
} console.log("netUnavailable" + JSON.stringify(value));
}); });
netConn.on('netCapabilitiesChange', (error, value) => { expect(true).assertTrue();
if (error) { netConn.unregister((error) => {
console.info("${caseName} register fail :${error}"); if (error) {
expect().assertFail(); console.info(caseName + " unregister result: " + JSON.stringify(error));
done(); expect().assertFail();
} else { done();
console.info("${caseName} netCapabilitiesChange handle = :" + value.netHandle.netId); }
done(); done();
} });
}); });
netConn.on('netConnectionPropertiesChange', (error, value) => { });
if (error) { });
console.info("${caseName} register fail :${error}"); }
expect().assertFail(); \ No newline at end of file
done();
} else {
console.info("${caseName} netConnectionPropertiesChange handle = :" + value.netHandle.netId);
done();
}
});
netConn.on('netLost', (error, value) => {
if (error) {
console.info("${caseName} register fail :${error}");
expect().assertFail();
done();
} else {
console.info("${caseName} netLost " + value.netId);
done();
}
});
netConn.on('netUnavailable', (error, value) => {
if (error) {
console.info("${caseName} register fail :${error}");
expect().assertFail();
done();
} else {
console.info("${caseName} netUnavailable " + value.netId);
done();
}
});
netConn.register((error) => {
if (error) {
console.info("${caseName} register fail ${error}");
}
});
netConn.unregister((error) => {
if (error) {
console.info("${caseName} unregister result : ${error}");
expect().assertFail();
done();
}
done();
});
done();
});
/**
* @tc.number Telephony_NetworkManager_unregister_Async_0300
* @tc.name Enter bearerTypes add networkCap as empty ,set class NetConnection,
* call Register () to activate the default network ,and see if the callback information is generated
* @tc.desc Function test
*/
it('Telephony_NetworkManager_unregister_Async_0300', 0, async function (done) {
if (!envReady) {
console.info("The environment was not ready");
done();
return;
}
let caseName = 'Telephony_NetworkManager_unregister_Async_0300';
let netConn = connection.createNetConnection();
netConn.on('netAvailable', (error, value) => {
if (error) {
console.info("${caseName} register fail: ${error}");
expect().assertFail();
done();
} else {
console.info("${caseName} netAvailable : " + value.netId);
done();
}
});
netConn.on('netBlockStatusChange', (error, value) => {
if (error) {
console.info("${caseName} register fail :${error}");
expect().assertFail();
done();
} else {
console.info("${caseName} netBlockStatusChange handle = :" + value.netHandle.netId);
done();
}
});
netConn.on('netCapabilitiesChange', (error, value) => {
if (error) {
console.info("${caseName} register fail :${error}");
expect().assertFail();
done();
} else {
console.info("${caseName} netCapabilitiesChange handle = :" + value.netHandle.netId);
done();
}
});
netConn.on('netConnectionPropertiesChange', (error, value) => {
if (error) {
console.info("${caseName} register fail :${error}");
expect().assertFail();
done();
} else {
console.info("${caseName} netConnectionPropertiesChange handle = :" + value.netHandle.netId);
done();
}
});
netConn.on('netLost', (error, value) => {
if (error) {
console.info("${caseName} register fail :${error}");
expect().assertFail();
done();
} else {
console.info("${caseName} netLost " + value.netId);
done();
}
});
netConn.on('netUnavailable', (error, value) => {
if (error) {
console.info("${caseName} register fail :${error}");
expect().assertFail();
done();
} else {
console.info("${caseName} netUnavailable " + value.netId);
done();
}
});
netConn.unregister((error) => {
if (error) {
console.info("${caseName} unregister result : ${error}");
expect().assertFail();
done();
}
done();
});
done();
});
});
}
\ No newline at end of file
...@@ -19,7 +19,6 @@ import observer from '@ohos.telephony.observer'; ...@@ -19,7 +19,6 @@ import observer from '@ohos.telephony.observer';
export default function ObserverJsunit() { export default function ObserverJsunit() {
describe('ObserverJsunit', function () { describe('ObserverJsunit', function () {
console.log("************* Observer Test start *************"); console.log("************* Observer Test start *************");
let envReady = false;
/* /*
* @tc.number : Telephony_observer_observer_DataConnectState_0100 * @tc.number : Telephony_observer_observer_DataConnectState_0100
...@@ -446,11 +445,6 @@ export default function ObserverJsunit() { ...@@ -446,11 +445,6 @@ export default function ObserverJsunit() {
* @tc.desc : check the SIM_NONE property of LockReason * @tc.desc : check the SIM_NONE property of LockReason
*/ */
it('Telephony_observer_LockReason_SIM_NONE_0100', 0, function (done) { it('Telephony_observer_LockReason_SIM_NONE_0100', 0, function (done) {
if (!envReady) {
console.info("The environment was not ready");
done();
return;
}
console.log("************* Telephony_observer_LockReason_SIM_NONE_0100 Test start *************") console.log("************* Telephony_observer_LockReason_SIM_NONE_0100 Test start *************")
expect(0).assertEqual(observer.LockReason.SIM_NONE); expect(0).assertEqual(observer.LockReason.SIM_NONE);
done(); done();
...@@ -463,11 +457,6 @@ export default function ObserverJsunit() { ...@@ -463,11 +457,6 @@ export default function ObserverJsunit() {
* @tc.desc : check the SIM_PIN property of LockReason * @tc.desc : check the SIM_PIN property of LockReason
*/ */
it('Telephony_observer_LockReason_SIM_PIN_0100', 0, function (done) { it('Telephony_observer_LockReason_SIM_PIN_0100', 0, function (done) {
if (!envReady) {
console.info("The environment was not ready");
done();
return;
}
console.log("************* Telephony_observer_LockReason_SIM_PIN_0100 Test start *************"); console.log("************* Telephony_observer_LockReason_SIM_PIN_0100 Test start *************");
expect(1).assertEqual(observer.LockReason.SIM_PIN); expect(1).assertEqual(observer.LockReason.SIM_PIN);
done(); done();
...@@ -480,11 +469,6 @@ export default function ObserverJsunit() { ...@@ -480,11 +469,6 @@ export default function ObserverJsunit() {
* @tc.desc : check the SIM_PUK property of LockReason * @tc.desc : check the SIM_PUK property of LockReason
*/ */
it('Telephony_observer_LockReason_SIM_PUK_0100', 0, function (done) { it('Telephony_observer_LockReason_SIM_PUK_0100', 0, function (done) {
if (!envReady) {
console.info("The environment was not ready");
done();
return;
}
console.log("************* Telephony_observer_LockReason_SIM_PUK_0100 Test start *************"); console.log("************* Telephony_observer_LockReason_SIM_PUK_0100 Test start *************");
expect(2).assertEqual(observer.LockReason.SIM_PUK); expect(2).assertEqual(observer.LockReason.SIM_PUK);
done(); done();
...@@ -497,11 +481,6 @@ export default function ObserverJsunit() { ...@@ -497,11 +481,6 @@ export default function ObserverJsunit() {
* @tc.desc : check the SIM_PN_PIN property of LockReason * @tc.desc : check the SIM_PN_PIN property of LockReason
*/ */
it('Telephony_observer_LockReason_SIM_PN_PIN_0100', 0, function (done) { it('Telephony_observer_LockReason_SIM_PN_PIN_0100', 0, function (done) {
if (!envReady) {
console.info("The environment was not ready");
done();
return;
}
console.log("************* Telephony_observer_LockReason_SIM_PN_PIN_0100 Test start *************"); console.log("************* Telephony_observer_LockReason_SIM_PN_PIN_0100 Test start *************");
expect(3).assertEqual(observer.LockReason.SIM_PN_PIN); expect(3).assertEqual(observer.LockReason.SIM_PN_PIN);
done(); done();
...@@ -513,11 +492,6 @@ export default function ObserverJsunit() { ...@@ -513,11 +492,6 @@ export default function ObserverJsunit() {
* @tc.desc : check the SIM_PN_PUK property of LockReason * @tc.desc : check the SIM_PN_PUK property of LockReason
*/ */
it('Telephony_observer_LockReason_SIM_PN_PUK_0100', 0, function (done) { it('Telephony_observer_LockReason_SIM_PN_PUK_0100', 0, function (done) {
if (!envReady) {
console.info("The environment was not ready");
done();
return;
}
console.log("************* Telephony_observer_LockReason_SIM_PN_PUK_0100 Test start *************"); console.log("************* Telephony_observer_LockReason_SIM_PN_PUK_0100 Test start *************");
expect(4).assertEqual(observer.LockReason.SIM_PN_PUK); expect(4).assertEqual(observer.LockReason.SIM_PN_PUK);
done(); done();
...@@ -530,11 +504,6 @@ export default function ObserverJsunit() { ...@@ -530,11 +504,6 @@ export default function ObserverJsunit() {
* @tc.desc : check the SIM_PU_PIN property of LockReason * @tc.desc : check the SIM_PU_PIN property of LockReason
*/ */
it('Telephony_observer_LockReason_SIM_PU_PIN_0100', 0, function (done) { it('Telephony_observer_LockReason_SIM_PU_PIN_0100', 0, function (done) {
if (!envReady) {
console.info("The environment was not ready");
done();
return;
}
console.log("************* Telephony_observer_LockReason_SIM_PU_PIN_0100 Test start *************"); console.log("************* Telephony_observer_LockReason_SIM_PU_PIN_0100 Test start *************");
expect(5).assertEqual(observer.LockReason.SIM_PU_PIN); expect(5).assertEqual(observer.LockReason.SIM_PU_PIN);
done(); done();
...@@ -547,11 +516,6 @@ export default function ObserverJsunit() { ...@@ -547,11 +516,6 @@ export default function ObserverJsunit() {
* @tc.desc : check the SIM_PU_PUK property of LockReason * @tc.desc : check the SIM_PU_PUK property of LockReason
*/ */
it('Telephony_observer_LockReason_SIM_PU_PUK_0100', 0, function (done) { it('Telephony_observer_LockReason_SIM_PU_PUK_0100', 0, function (done) {
if (!envReady) {
console.info("The environment was not ready");
done();
return;
}
console.log("************* Telephony_observer_LockReason_SIM_PU_PUK_0100 Test start *************"); console.log("************* Telephony_observer_LockReason_SIM_PU_PUK_0100 Test start *************");
expect(6).assertEqual(observer.LockReason.SIM_PU_PUK); expect(6).assertEqual(observer.LockReason.SIM_PU_PUK);
done(); done();
...@@ -564,11 +528,6 @@ export default function ObserverJsunit() { ...@@ -564,11 +528,6 @@ export default function ObserverJsunit() {
* @tc.desc : check the SIM_PP_PIN property of LockReason * @tc.desc : check the SIM_PP_PIN property of LockReason
*/ */
it('Telephony_observer_LockReason_SIM_PP_PIN_0100', 0, function (done) { it('Telephony_observer_LockReason_SIM_PP_PIN_0100', 0, function (done) {
if (!envReady) {
console.info("The environment was not ready");
done();
return;
}
console.log("************* Telephony_observer_LockReason_SIM_PP_PIN_0100 Test start *************"); console.log("************* Telephony_observer_LockReason_SIM_PP_PIN_0100 Test start *************");
expect(7).assertEqual(observer.LockReason.SIM_PP_PIN); expect(7).assertEqual(observer.LockReason.SIM_PP_PIN);
done(); done();
...@@ -581,11 +540,6 @@ export default function ObserverJsunit() { ...@@ -581,11 +540,6 @@ export default function ObserverJsunit() {
* @tc.desc : check the SIM_PP_PUK property of LockReason * @tc.desc : check the SIM_PP_PUK property of LockReason
*/ */
it('Telephony_observer_LockReason_SIM_PP_PUK_0100', 0, function (done) { it('Telephony_observer_LockReason_SIM_PP_PUK_0100', 0, function (done) {
if (!envReady) {
console.info("The environment was not ready");
done();
return;
}
console.log("************* Telephony_observer_LockReason_SIM_PP_PUK_0100 Test start *************"); console.log("************* Telephony_observer_LockReason_SIM_PP_PUK_0100 Test start *************");
expect(8).assertEqual(observer.LockReason.SIM_PP_PUK); expect(8).assertEqual(observer.LockReason.SIM_PP_PUK);
done(); done();
...@@ -598,11 +552,6 @@ export default function ObserverJsunit() { ...@@ -598,11 +552,6 @@ export default function ObserverJsunit() {
* @tc.desc : check the SIM_PC_PIN property of LockReason * @tc.desc : check the SIM_PC_PIN property of LockReason
*/ */
it('Telephony_observer_LockReason_SIM_PC_PIN_0100', 0, function (done) { it('Telephony_observer_LockReason_SIM_PC_PIN_0100', 0, function (done) {
if (!envReady) {
console.info("The environment was not ready");
done();
return;
}
console.log("************* Telephony_observer_LockReason_SIM_PC_PIN_0100 Test start *************"); console.log("************* Telephony_observer_LockReason_SIM_PC_PIN_0100 Test start *************");
expect(9).assertEqual(observer.LockReason.SIM_PC_PIN); expect(9).assertEqual(observer.LockReason.SIM_PC_PIN);
done(); done();
...@@ -615,11 +564,6 @@ export default function ObserverJsunit() { ...@@ -615,11 +564,6 @@ export default function ObserverJsunit() {
* @tc.desc : check the SIM_PC_PUK property of LockReason * @tc.desc : check the SIM_PC_PUK property of LockReason
*/ */
it('Telephony_observer_LockReason_SIM_PC_PUK_0100', 0, function (done) { it('Telephony_observer_LockReason_SIM_PC_PUK_0100', 0, function (done) {
if (!envReady) {
console.info("The environment was not ready");
done();
return;
}
console.log("************* Telephony_observer_LockReason_SIM_PC_PUK_0100 Test start *************"); console.log("************* Telephony_observer_LockReason_SIM_PC_PUK_0100 Test start *************");
expect(10).assertEqual(observer.LockReason.SIM_PC_PUK); expect(10).assertEqual(observer.LockReason.SIM_PC_PUK);
done(); done();
...@@ -632,11 +576,6 @@ export default function ObserverJsunit() { ...@@ -632,11 +576,6 @@ export default function ObserverJsunit() {
* @tc.desc : check the SIM_SIM_PIN property of LockReason * @tc.desc : check the SIM_SIM_PIN property of LockReason
*/ */
it('Telephony_observer_LockReason_SIM_SIM_PIN_0100', 0, function (done) { it('Telephony_observer_LockReason_SIM_SIM_PIN_0100', 0, function (done) {
if (!envReady) {
console.info("The environment was not ready");
done();
return;
}
console.log("************* Telephony_observer_LockReason_SIM_SIM_PIN_0100 Test start *************"); console.log("************* Telephony_observer_LockReason_SIM_SIM_PIN_0100 Test start *************");
expect(11).assertEqual(observer.LockReason.SIM_SIM_PIN); expect(11).assertEqual(observer.LockReason.SIM_SIM_PIN);
done(); done();
...@@ -649,11 +588,6 @@ export default function ObserverJsunit() { ...@@ -649,11 +588,6 @@ export default function ObserverJsunit() {
* @tc.desc : check the SIM_SIM_PUK property of LockReason * @tc.desc : check the SIM_SIM_PUK property of LockReason
*/ */
it('Telephony_observer_LockReason_SIM_SIM_PUK_0100', 0, function (done) { it('Telephony_observer_LockReason_SIM_SIM_PUK_0100', 0, function (done) {
if (!envReady) {
console.info("The environment was not ready");
done();
return;
}
console.log("************* Telephony_observer_LockReason_SIM_SIM_PUK_0100 Test start *************"); console.log("************* Telephony_observer_LockReason_SIM_SIM_PUK_0100 Test start *************");
expect(12).assertEqual(observer.LockReason.SIM_SIM_PUK); expect(12).assertEqual(observer.LockReason.SIM_SIM_PUK);
done(); done();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册