提交 7fb31083 编写于 作者: G gaoxi

add netmanager_base test suite

Signed-off-by: Ngaoxi <gaoxi785@huawei.com>
上级 e6da9f19
......@@ -16,12 +16,13 @@ group("telephonyjstest") {
deps = [
"call_manager:call_manager",
"cellular_data:cellular_data",
"netmanager_base:netmanager_base",
"netmanager_http:ActsNetManagerHttpEtsTest",
#"contact_function:ActsContactFunctionEtsTest",
#"contact_function_merge:ActsContactFunctionMergeEtsTest",
#"contact_performance:ActsContactPerformanceEtsTest",
#"contact_stability:ActsContactStabilityEtsTest",
"netmanager_http:ActsNetManagerHttpEtsTest",
"netmanager_socket:ActsNetManagerSocketEtsTest",
"network_search:network_search",
"observer:ActsObserverEtsTest",
......
# Copyright (C) 2021 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//build/ohos_var.gni")
group("netmanager_base") {
testonly = true
if (is_standard_system) {
deps = [
"dns:ActsDNSTest",
"jshttp:ActsJSHTTPTest",
"register:ActsRegisterTest",
"socket:ActsSocketTest",
]
}
}
# Copyright (c) 2021 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("ActsDNSTest") {
hap_profile = "./entry/src/main/config.json"
deps = [
":hjs_demo_js_assets",
":hjs_demo_resources",
]
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "ActsDNSTest"
}
ohos_js_assets("hjs_demo_js_assets") {
source_dir = "./entry/src/main/js/default"
}
ohos_resources("hjs_demo_resources") {
sources = [ "./entry/src/main/js/resources" ]
hap_profile = "./entry/src/main/config.json"
}
{
"description": "Function test of sim manager interface",
"driver": {
"type": "JSUnitTest",
"test-timeout": "1800000",
"package": "com.ohos.dns",
"shell-timeout": "60000"
},
"kits": [
{
"test-file-name": [
"$module.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
{
"app": {
"bundleName": "com.ohos.dns",
"vendor": "ohos",
"version": {
"code": 1000000,
"name": "1.0.0"
},
"apiVersion": {
"compatible": 4,
"target": 5,
"releaseType": "Release"
}
},
"deviceConfig": {},
"module": {
"package": "com.ohos.dns",
"name": ".MyApplication",
"deviceType": [
"phone"
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "entry",
"moduleType": "entry"
},
"abilities": [
{
"visible": true,
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"name": "com.ohos.dns.MainAbility",
"icon": "$media:icon",
"description": "$string:mainability_description",
"label": "$string:app_name",
"type": "page",
"launchType": "standard"
}
],
"reqPermissions": [
{
"name": "ohos.permission.LOCATION",
"reason": "need use ohos.permission.LOCATION"
},
{
"name":"ohos.permission.SET_TELEPHONY_STATE",
"reason":"need use ohos.permission.SET_TELEPHONY_STATE"
},
{
"name":"ohos.permission.GET_TELEPHONY_STATE",
"reason":"need use ohos.permission.GET_TELEPHONY_STATE"
},
{
"name":"ohos.permission.PLACE_CALL",
"reason":"need use ohos.permission.PLACE_CALL"
},
{
"name":"ohos.permission.READ_CONTACTS",
"reason":"need use ohos.permission.READ_CONTACTS"
},
{
"name":"ohos.permission.WRITE_CONTACTS",
"reason":"need use ohos.permission.WRITE_CONTACTS"
},
{
"name":"ohos.permission.SEND_MESSAGES",
"reason":"need use ohos.permission.SEND_MESSAGES"
},
{
"name":"ohos.permission.RECEIVE_SMS",
"reason":"need use ohos.permission.RECEIVE_SMS"
},
{
"name":"ohos.permission.READ_CALL_LOG",
"reason":"need use ohos.permission.READ_CALL_LOG"
},
{
"name":"ohos.permission.GET_NETWORK_INFO",
"reason":"need use ohos.permission.GET_NETWORK_INFO"
},
{
"name":"ohos.permission.INTERNET",
"reason":"need use ohos.permission.INTERNET"
}
],
"js": [
{
"pages": [
"pages/index/index"
],
"name": "default",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
}
]
}
}
\ No newline at end of file
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export default {
onCreate () {
console.info('TestApplication onCreate');
},
onDestroy () {
console.info('TestApplication onDestroy');
}
};
{
"strings": {
"hello": "Hello",
"world": "World"
},
"Files": {
}
}
\ No newline at end of file
{
"strings": {
"hello": "您好",
"world": "世界"
},
"Files": {
}
}
\ No newline at end of file
.container {
flex-direction: column;
justify-content: center;
align-items: center;
}
.title {
font-size: 100px;
}
<div class="container">
<text class="title">
SIM TEST
</text>
</div>
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import file from '@system.file';
import app from '@system.app';
import device from '@system.device';
import router from '@system.router';
import {Core, ExpectExtend} from 'deccjsunit/index';
const injectRef = Object.getPrototypeOf(global) || global
injectRef.regeneratorRuntime = require('@babel/runtime/regenerator')
export default {
data: {
title: ''
},
onInit () {
this.title = this.$t('strings.world');
},
onShow () {
console.info('onShow finish!');
const core = Core.getInstance();
const expectExtend = new ExpectExtend({
'id': 'extend'
});
core.addService('expect', expectExtend);
core.init();
const configService = core.getDefaultService('config');
this.timeout = 30000
configService.setConfig(this);
require('../../../test/List.test');
core.execute();
},
onReady () {
},
};
\ No newline at end of file
{
"string": [
{
"name": "app_name",
"value": "Sim Test"
},
{
"name": "mainability_description",
"value": "Sim Test - sim manager interface test"
}
]
}
\ No newline at end of file
/**
* Copyright (C) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
require('./NetworkManagerDNS.test');
\ No newline at end of file
/**
* Copyright (C) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License")
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import netConnection from '@ohos.net.connection';
import {describe, afterAll, it, expect, beforeAll, afterEach} from 'deccjsunit/index';
describe('Telephony_NETMANAGER_TestDNSTest',function(){
it('Telephony_NETMANAGER_TestDNS_Test0100', 0, function(done){
netConnection.getDefaultNet().then(function(netHandle){
netHandle.getAddressesByName("www.zhihu.com").then(function(addresses){
if(addresses === undefined || addresses.length == 0 ){
console.log('Telephony_NETMANAGER_TestDNS_Test0100 addresses id undefined '+addresses);
expect(false).assertFail();
}else{
console.log('Telephony_NETMANAGER_TestDNS_Test0100 is success');
expect(true).assertTrue();
}
done();
})
})
});
it('Telephony_NETMANAGER_TestDNS_Test0200', 0, function(done){
netConnection.getDefaultNet().then(function(netHandle){
netHandle.getAddressesByName("www.zhihu.com", function(err, addresses){
if(addresses === undefined || addresses.length == 0 ){
console.log('Telephony_NETMANAGER_TestDNS_Test0200 addresses id undefined '+addresses);
expect(false).assertFail();
}else{
console.log('Telephony_NETMANAGER_TestDNS_Test0200 is success');
expect(true).assertTrue();
}
done();
})
})
});
it('Telephony_NETMANAGER_TestDNS_Test0300', 0, function(done){
netConnection.getDefaultNet().then(function(netHandle){
netHandle.getAddressByName("www.zhihu.com").then(function(address){
if(address === undefined){
console.log('Telephony_NETMANAGER_TestDNS_Test0300 addresses id undefined '+address);
expect(false).assertFail();
}else{
console.log('Telephony_NETMANAGER_TestDNS_Test0300 is success');
expect(true).assertTrue();
}
done();
})
})
});
it('Telephony_NETMANAGER_TestDNS_Test0400', 0, function(done){
netConnection.getDefaultNet().then(function(netHandle){
netHandle.getAddressByName("www.baidu.com", function(err, address){
if(address === undefined ){
console.log('Telephony_NETMANAGER_TestDNS_Test0400 addresses id undefined '+address);
expect(false).assertFail();
}else{
console.log('Telephony_NETMANAGER_TestDNS_Test0400 is success');
expect(true).assertTrue();
}
done();
})
})
});
it('Telephony_NETMANAGER_TestDNS_Test0500', 0, function(done){
netConnection.getDefaultNet().then(function(netHandle){
netHandle.getAddressesByName("www.askjdbaksjnhd.com").catch(function(error){
if(error === undefined){
expect(false).assertTrue();
}else{
expect(true).assertTrue()
}
done();
})
})
});
it('Telephony_NETMANAGER_TestDNS_Test0600', 0, function(done){
netConnection.getDefaultNet().then(function(netHandle){
netHandle.getAddressesByName("www.askjdbaksjnhd.com", function(err, addresses){
if(addresses instanceof Array && addresses.length !== 0 ){
console.log('Telephony_NETMANAGER_TestDNS_Test0600 addresses id undefined '+addresses);
expect(false).assertFail();
}else{
console.log('Telephony_NETMANAGER_TestDNS_Test0600 is success');
expect(true).assertTrue();
}
done();
})
})
});
it('Telephony_NETMANAGER_TestDNS_Test0700', 0, function(done){
netConnection.getDefaultNet().then(function(netHandle){
netHandle.getAddressesByName("www.askjdbaksjnhd.com").catch(function(error){
if(error === undefined){
expect(false).assertTrue();
}else{
expect(true).assertTrue()
}
done();
})
})
});
it('Telephony_NETMANAGER_TestDNS_Test0800', 0, function(done){
netConnection.getDefaultNet().then(function(netHandle){
netHandle.getAddressesByName("www.askjdbaksjnhd.com", function(err, address){
if(address !== undefined ){
console.log('Telephony_NETMANAGER_TestDNS_Test0800 addresses id undefined '+address);
expect(false).assertFail();
}else{
console.log('Telephony_NETMANAGER_TestDNS_Test0800 is success');
expect(true).assertTrue();
}
done();
})
})
});
});
\ No newline at end of file
{
"string": [
{
"name": "app_name",
"value": "Sim Test"
},
{
"name": "mainability_description",
"value": "Sim Test - sim manager interface test"
}
]
}
\ No newline at end of file
# Copyright (c) 2021 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("ActsJSHTTPTest") {
hap_profile = "./entry/src/main/config.json"
deps = [
":hjs_demo_js_assets",
":hjs_demo_resources",
]
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "ActsJSHTTPTest"
}
ohos_js_assets("hjs_demo_js_assets") {
source_dir = "./entry/src/main/js/default"
}
ohos_resources("hjs_demo_resources") {
sources = [ "./entry/src/main/js/resources" ]
hap_profile = "./entry/src/main/config.json"
}
{
"description": "Function test of sim manager interface",
"driver": {
"type": "JSUnitTest",
"test-timeout": "1800000",
"package": "com.ohos.jshttp",
"shell-timeout": "60000"
},
"kits": [
{
"test-file-name": [
"$module.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
{
"app": {
"bundleName": "com.ohos.jshttp",
"vendor": "ohos",
"version": {
"code": 1000000,
"name": "1.0.0"
},
"apiVersion": {
"compatible": 4,
"target": 5,
"releaseType": "Release"
}
},
"deviceConfig": {},
"module": {
"package": "com.ohos.jshttp",
"name": ".MyApplication",
"deviceType": [
"phone"
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "entry",
"moduleType": "entry"
},
"abilities": [
{
"visible": true,
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"name": "com.ohos.jshttp.MainAbility",
"icon": "$media:icon",
"description": "$string:mainability_description",
"label": "$string:app_name",
"type": "page",
"launchType": "standard"
}
],
"reqPermissions": [
{
"name": "ohos.permission.LOCATION",
"reason": "need use ohos.permission.LOCATION"
},
{
"name":"ohos.permission.SET_TELEPHONY_STATE",
"reason":"need use ohos.permission.SET_TELEPHONY_STATE"
},
{
"name":"ohos.permission.GET_TELEPHONY_STATE",
"reason":"need use ohos.permission.GET_TELEPHONY_STATE"
},
{
"name":"ohos.permission.PLACE_CALL",
"reason":"need use ohos.permission.PLACE_CALL"
},
{
"name":"ohos.permission.READ_CONTACTS",
"reason":"need use ohos.permission.READ_CONTACTS"
},
{
"name":"ohos.permission.WRITE_CONTACTS",
"reason":"need use ohos.permission.WRITE_CONTACTS"
},
{
"name":"ohos.permission.SEND_MESSAGES",
"reason":"need use ohos.permission.SEND_MESSAGES"
},
{
"name":"ohos.permission.RECEIVE_SMS",
"reason":"need use ohos.permission.RECEIVE_SMS"
},
{
"name":"ohos.permission.READ_CALL_LOG",
"reason":"need use ohos.permission.READ_CALL_LOG"
},
{
"name":"ohos.permission.GET_NETWORK_INFO",
"reason":"need use ohos.permission.GET_NETWORK_INFO"
},
{
"name":"ohos.permission.INTERNET",
"reason":"need use ohos.permission.INTERNET"
}
],
"js": [
{
"pages": [
"pages/index/index"
],
"name": "default",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
}
]
}
}
\ No newline at end of file
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export default {
onCreate () {
console.info('TestApplication onCreate');
},
onDestroy () {
console.info('TestApplication onDestroy');
}
};
{
"strings": {
"hello": "Hello",
"world": "World"
},
"Files": {
}
}
\ No newline at end of file
{
"strings": {
"hello": "您好",
"world": "世界"
},
"Files": {
}
}
\ No newline at end of file
.container {
flex-direction: column;
justify-content: center;
align-items: center;
}
.title {
font-size: 100px;
}
<div class="container">
<text class="title">
SIM TEST
</text>
</div>
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import file from '@system.file';
import app from '@system.app';
import device from '@system.device';
import router from '@system.router';
import {Core, ExpectExtend} from 'deccjsunit/index';
const injectRef = Object.getPrototypeOf(global) || global
injectRef.regeneratorRuntime = require('@babel/runtime/regenerator')
export default {
data: {
title: ''
},
onInit () {
this.title = this.$t('strings.world');
},
onShow () {
console.info('onShow finish!');
const core = Core.getInstance();
const expectExtend = new ExpectExtend({
'id': 'extend'
});
core.addService('expect', expectExtend);
core.init();
const configService = core.getDefaultService('config');
this.timeout = 30000
configService.setConfig(this);
require('../../../test/List.test');
core.execute();
},
onReady () {
},
};
\ No newline at end of file
{
"string": [
{
"name": "app_name",
"value": "Sim Test"
},
{
"name": "mainability_description",
"value": "Sim Test - sim manager interface test"
}
]
}
\ No newline at end of file
/**
* Copyright (C) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
require('./NetworkManagerHttp.test');
/**
* Copyright (C) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License")
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import netHttp from '@ohos.net.http';
import {describe, afterAll, it, expect, beforeAll, afterEach} from 'deccjsunit/index';
describe('Telephony_NETSTACK_HTTPTest',function(){
/**
* @tc.number Telephony_NETSTACK_HttpTestBasicGet_0100
* @tc.name 基本场景,测试能否GET一个网址
* @tc.desc Function test`
*/
it('Telephony_NETSTACK_HttpTestBasicGet_0100', 0, function(done){
let http = netHttp.createHttp()
http.request("https://httpbin.org/anything").then(function(data){
expect(data.responseCode === net_http.ResponseCode.OK).assertTrue();
done();
})
});
/**
* @tc.number Telephony_NETSTACK_HttpTestUserAgent_0100
* @tc.name 返回用户代理
* @tc.desc Function test`
*/
it('Telephony_NETSTACK_HttpTestUserAgent_0100', 0, function(done){
let http = netHttp.createHttp()
http.request("https://httpbin.org/user-agent").then(function(data){
expect(data.responseCode === net_http.ResponseCode.OK).assertTrue();
expect(JSON.parse(data.result)["user-agent"] === "libcurl-agent/1.0").assertTrue();
done();
})
});
/**
* @tc.number Telephony_NETSTACK_HttpTestHeader_0100
* @tc.name 返回Header
* @tc.desc Function test`
*/
it('Telephony_NETSTACK_HttpTestHeader_0100', 0, function(done){
let http = netHttp.createHttp();
http.request("https://httpbin.org/headers").then(function(data){
expect(data.responseCode === net_http.ResponseCode.OK).assertTrue()
console.info("NETSTACK ####" + JSON.stringify(JSON.parse(data.result)))
expect(JSON.parse(data.result)["headers"]["Content-Type"] === "application/json").assertTrue()
done()
})
});
/**
* @tc.number Telephony_NETSTACK_HttpTestPost
* @tc.name 返回post内容
* @tc.desc Function test`
*/
it('Telephony_NETSTACK_HttpTestPost_0100', 0, function(done){
let http = netHttp.createHttp()
http.request("https://httpbin.org/post" ,{
method : net_http.RequestMethod.POST,
extraData : "MineMine"
}).then(function(data){
expect(data.responseCode === net_http.ResponseCode.OK).assertTrue()
expect(JSON.parse(data.result)["data"] === "MineMine").assertTrue()
done();
})
});
/**
* @tc.number Telephony_NETSTACK_HttpTestPUT
* @tc.name 返回put内容
* @tc.desc Function test`
*/
it('Telephony_NETSTACK_HttpTestPut_0100', 0, function(done){
let http = netHttp.createHttp()
http.request("https://httpbin.org/put" ,{
method : net_http.RequestMethod.PUT,
extraData : "MineMine"
}).then(function(data){
expect(data.responseCode === net_http.ResponseCode.OK).assertTrue()
expect(JSON.parse(data.result)["data"] === "MineMine").assertTrue()
done();
})
});
/**
* @tc.number Telephony_NETSTACK_HttpTestCookies
* @tc.name 返回Cookies内容
* @tc.desc Function test`
*/
it('Telephony_NETSTACK_HttpTestCookies_0100', 0, function(done){
let http = netHttp.createHttp()
http.request("https://httpbin.org/cookies/set/name/value").then(function(data){
expect(data.responseCode === net_http.ResponseCode.OK).assertTrue()
expect(data.cookies !== "").assertTrue()
done();
})
});
/**
* @tc.number Telephony_NETSTACK_HttpTestEncode
* @tc.name 返回Cookies内容
* @tc.desc Function test`
*/
it('Telephony_NETSTACK_HttpTestEncode_0100', 0, function(done){
let http = netHttp.createHttp()
http.request("https://httpbin.org/response-headers?key1=val1&key2=val2",{
extraData : {
"name1" : "mine1",
"name2" : "mine2",
}
}).then(function(data){
expect(data.responseCode === net_http.ResponseCode.OK).assertTrue()
expect(JSON.parse(data.result)["key1"] === "val1").assertTrue()
expect(JSON.parse(data.result)["key2"] === "val2").assertTrue()
expect(JSON.parse(data.result)["name1"] === "mine1").assertTrue()
expect(JSON.parse(data.result)["name2"] === "mine2").assertTrue()
done();
})
});
});
{
"string": [
{
"name": "app_name",
"value": "Sim Test"
},
{
"name": "mainability_description",
"value": "Sim Test - sim manager interface test"
}
]
}
\ No newline at end of file
# Copyright (c) 2021 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("ActsRegisterTest") {
hap_profile = "./entry/src/main/config.json"
deps = [
":hjs_demo_js_assets",
":hjs_demo_resources",
]
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "ActsRegisterTest"
}
ohos_js_assets("hjs_demo_js_assets") {
source_dir = "./entry/src/main/js/default"
}
ohos_resources("hjs_demo_resources") {
sources = [ "./entry/src/main/js/resources" ]
hap_profile = "./entry/src/main/config.json"
}
{
"description": "Function test of sim manager interface",
"driver": {
"type": "JSUnitTest",
"test-timeout": "1800000",
"package": "com.ohos.register",
"shell-timeout": "60000"
},
"kits": [
{
"test-file-name": [
"$module.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
{
"app": {
"bundleName": "com.ohos.register",
"vendor": "ohos",
"version": {
"code": 1000000,
"name": "1.0.0"
},
"apiVersion": {
"compatible": 4,
"target": 5,
"releaseType": "Release"
}
},
"deviceConfig": {},
"module": {
"package": "com.ohos.register",
"name": ".MyApplication",
"deviceType": [
"phone"
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "entry",
"moduleType": "entry"
},
"abilities": [
{
"visible": true,
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"name": "com.ohos.register.MainAbility",
"icon": "$media:icon",
"description": "$string:mainability_description",
"label": "$string:app_name",
"type": "page",
"launchType": "standard"
}
],
"reqPermissions": [
{
"name": "ohos.permission.LOCATION",
"reason": "need use ohos.permission.LOCATION"
},
{
"name":"ohos.permission.SET_TELEPHONY_STATE",
"reason":"need use ohos.permission.SET_TELEPHONY_STATE"
},
{
"name":"ohos.permission.GET_TELEPHONY_STATE",
"reason":"need use ohos.permission.GET_TELEPHONY_STATE"
},
{
"name":"ohos.permission.PLACE_CALL",
"reason":"need use ohos.permission.PLACE_CALL"
},
{
"name":"ohos.permission.READ_CONTACTS",
"reason":"need use ohos.permission.READ_CONTACTS"
},
{
"name":"ohos.permission.WRITE_CONTACTS",
"reason":"need use ohos.permission.WRITE_CONTACTS"
},
{
"name":"ohos.permission.SEND_MESSAGES",
"reason":"need use ohos.permission.SEND_MESSAGES"
},
{
"name":"ohos.permission.RECEIVE_SMS",
"reason":"need use ohos.permission.RECEIVE_SMS"
},
{
"name":"ohos.permission.READ_CALL_LOG",
"reason":"need use ohos.permission.READ_CALL_LOG"
},
{
"name":"ohos.permission.GET_NETWORK_INFO",
"reason":"need use ohos.permission.GET_NETWORK_INFO"
},
{
"name":"ohos.permission.INTERNET",
"reason":"need use ohos.permission.INTERNET"
}
],
"js": [
{
"pages": [
"pages/index/index"
],
"name": "default",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
}
]
}
}
\ No newline at end of file
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export default {
onCreate () {
console.info('TestApplication onCreate');
},
onDestroy () {
console.info('TestApplication onDestroy');
}
};
{
"strings": {
"hello": "Hello",
"world": "World"
},
"Files": {
}
}
\ No newline at end of file
{
"strings": {
"hello": "您好",
"world": "世界"
},
"Files": {
}
}
\ No newline at end of file
.container {
flex-direction: column;
justify-content: center;
align-items: center;
}
.title {
font-size: 100px;
}
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import file from '@system.file';
import app from '@system.app';
import device from '@system.device';
import router from '@system.router';
import {Core, ExpectExtend} from 'deccjsunit/index';
const injectRef = Object.getPrototypeOf(global) || global
injectRef.regeneratorRuntime = require('@babel/runtime/regenerator')
export default {
data: {
title: ''
},
onInit () {
this.title = this.$t('strings.world');
},
onShow () {
console.info('onShow finish!');
const core = Core.getInstance();
const expectExtend = new ExpectExtend({
'id': 'extend'
});
core.addService('expect', expectExtend);
core.init();
const configService = core.getDefaultService('config');
this.timeout = 30000
configService.setConfig(this);
require('../../test/List.test');
core.execute();
},
onReady () {
},
};
\ No newline at end of file
/**
* Copyright (C) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
require('./NetworkManagerRegister.test.js');
\ No newline at end of file
/**
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License")
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import connection from '@ohos.net.connection';
import {describe, afterAll, it, expect, beforeAll, afterEach} from 'deccjsunit/index';
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;
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.handle.netId);
expect(value.handle.netId).assertEqual(ETH_100);
}
});
netConn.on('netConnectionPropertiesChange', (value) => {
if (value === undefined) {
console.info(`${caseName} netConnectionPropertiesChange fail`);
expect().assertFail();
done();
} else {
console.info(`${caseName} netConnectionPropertiesChange handle = :` + value.handle.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();
});
/**
*@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;
}
});
netConn.on('netCapabilitiesChange', (value) => {
if (value === undefined) {
console.info(`${caseName} netCapabilitiesChange fail`);
expect().assertFail();
done();
} else {
console.info(`${caseName} netCapabilitiesChange handle =:` + value.handle.netId);
expect(value.handle.netId).assertEqual(ETH_100);
}
});
netConn.on('netConnectionPropertiesChange', (value) => {
if (value === undefined) {
console.info(`${caseName} netConnectionPropertiesChange fail`);
expect().assertFail();
done();
} else {
console.info(`${caseName} netConnectionPropertiesChange handle =:` + value.handle.netId);
}
});
netConn.on('netLost', (value) => {
if (error) {
console.info(`${caseName} netLost fail`);
expect().assertFail();
done();
} else {
console.info(`${caseName} netLost : ` + value.netId);
}
});
netConn.on('netUnavailable', (value) => {
if (error) {
console.info(`${caseName} netUnavailable fail`);
expect().assertFail();
done();
} else {
console.info(`${caseName} netUnavailable: ` + value.netId);
}
});
netConn.on('netBlockStatuschange', (value) => {
if (error) {
console.info(`${caseName} netBlockStatusChange fail`);
expect().assertFail();
done();
} else {
console.info(`${caseName} netBlockStatusChange : ` + value.netId);
}
});
netConn.register((error) => {
if (error) {
console.info(`${caseName} register fail: ${error}`);
}
});
await sleep(DELAY);
netConn.unregister((error) => {
if (error) {
console.info(`${caseName} unregisterresult: ${error}` + JSON.stringify(error));
done();
}
});
done();
});
/*
*@tc.number Telephony_NetworkManager_register_Async_0300
*@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
*@tc.desc Function test
*/
it('Telephony_NetworkManager_register_Async_0300', 0, async function (done) {
let caseName = 'Telephony_NetworkManager_register_Async_0300';
let netSpecifier = {
netCapabilities: {
linkUpBandwidthKbps: 0,
linkDownBandwidthKbps: 0,
bearerTypes: [0],
networkCap: [11],
}, 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.handle.netId);
}
});
netConn.on('netBlockStatusChange', (error, value) => {
if (error) {
console.info(`${caseName} register fail: ${error}`);
expect().assertFail();
done();
} else {
console.info(`${caseName} netBlockStatusChange handle = :` + value.handle.netId);
}
});
netConn.on('netConnectionPropertiesChange', (error, value) => {
if (error) {
console.info(`${caseName} register fail: ${error}`);
expect().assertFail();
done();
} else {
console.info(`${caseName} netConnectionPropertiesChange handle = :` + value.handle.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.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
*@tc.desc Function test
*/
it('Telephony_NetworkManager_register_Async_0400', 0, async function (done) {
let caseName = 'Telephony_NetworkManager_register_Async_0400';
let netId = 0;
let netSpecifier = {
netCapabilities: {
linkUpBandwidthKbps: 0,
linkDownBandwidthKbps: 0,
bearerTypes: [0],
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);
}
});
netConn.on('netBlockStatusChange', (error, value) => {
if (error) {
console.info(`${caseName} register fail: ${error}`);
expect().assertFail();
done();
} else {
console.info(`${caseName} netBlockStatusChange handle = :` + value.handle.netId);
}
});
netConn.on('netCapabilitiesChange', (error, value) => {
if (error) {
console.info(`${caseName} register fail: ${error}`);
expect().assertFail();
done();
} else {
console.info(`${caseName} netCapabilitiesChange handle = :` + value.handle.netId);
}
});
netConn.on('netConnectionPropertiesChange', (error, value) => {
if (error) {
console.info(`${caseName} register fail: ${error}`);
expect().assertFail();
done();
} else {
console.info(`${caseName} netConnectionPropertiesChange handle = :` + value.handle.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.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
*@tc.desc Function test
*/
it('Telephony_NetworkManager_register_Async_0500', 0, async function (done) {
let caseName = 'Telephony_NetworkManager_rgister_Async_0500';
let netSpecifier = {
netCapabilities: {
linkUpBandwidthKbps: 0,
linkDownBandwidthKbps: 0,
bearerTypes: [0],
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.handle.netId);
}
});
netConn.on('netCapabilitiesChange', (error, value) => {
if (error) {
console.info(`${caseName} register fail: ${error}`);
expect().assertFail();
done();
} else {
console.info(`${caseName} netCapabilitiesChange handle = :` + value.handle.netId);
}
});
netConn.on('netConnectionPropertiesChange', (error, value) => {
if (error) {
console.info(`${caseName} register fail: ${error}`);
expect().assertFail();
done();
} else {
console.info(`${caseName} netConnectionPropertiesChange handle = :` + value.handle.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.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
*@tc.desc Function test
*/
it('Telephony_NetworkManager_register_Async_0600', 0, async function (done) {
let caseName = 'Telephony_NetworkManager_rgister_Async_0600';
let netSpecifier = {
netCapabilities: {
linkUpBandwidthKbps: 0,
linkDownBandwidthKbps: 0,
bearerTypes: [0],
networkCap: [16],
}, bearerPrivateIdentifier: '123'
}
let netConn = connection.createNetConnection(netSpecifier, TIMEOUT);
let netId = 0;
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.handle.netId);
}
});
netConn.on('netCapabilitiesChange', (error, value) => {
if (error) {
console.info(`${caseName} register fail: ${error}`);
expect().assertFail();
done();
} else {
console.info(`${caseName} netCapabilitiesChange handle = :` + value.handle.netId);
}
});
netConn.on('netConnectionPropertiesChange', (error, value) => {
if (error) {
console.info(`${caseName} register fail: ${error}`);
expect().assertFail();
done();
} else {
console.info(`${caseName} netConnectionPropertiesChange handle = :` + value.handle.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.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
*@tc.desc Function test
*/
it('Telephony_NetworkManager_register_Async_0700', 0, async function (done) {
let caseName = 'Telephony_NetworkManager_rgister_Async_0700';
let netSpecifier = {
netCapabilities: {
linkUpBandwidthKbps: 0,
linkDownBandwidthKbps: 0,
bearerTypes: [0],
networkCap: [17],
}, bearerPrivateIdentifier: '123'
}
let netConn = connection.createNetConnection(netSpecifier, TIMEOUT);
let netId = 0;
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.handle.netId);
}
});
netConn.on('netCapabilitiesChange', (error, value) => {
if (error) {
console.info(`${caseName} register fail: ${error}`);
expect().assertFail();
done();
} else {
console.info(`${caseName} netCapabilitiesChange handle = :` + value.handle.netId);
}
});
netConn.on('netConnectionPropertiesChange', (error, value) => {
if (error) {
console.info(`${caseName} register fail: ${error}`);
expect().assertFail();
done();
} else {
console.info(`${caseName} netConnectionPropertiesChange handle = :` + value.handle.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.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
*@tc.desc Function test
*/
it('Telephony_NetworkManager_register_Async_0800', 0, async function (done) {
let caseName = 'Telephony_NetworkManager_rgister_Async_0800';
let netSpecifier = {
netCapabilities: {
linkUpBandwidthKbps: 0,
linkDownBandwidthKbps: 0,
bearerTypes: [1],
networkCap: [0],
}, bearerPrivateIdentifier: '123'
}
let netConn = connection.createNetConnection(netSpecifier, TIMEOUT);
let netId = 0;
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.handle.netId);
}
});
netConn.on('netCapabilitiesChange', (error, value) => {
if (error) {
console.info(`${caseName} register fail: ${error}`);
expect().assertFail();
done();
} else {
console.info(`${caseName} netCapabilitiesChange handle = :` + value.handle.netId);
}
});
netConn.on('netConnectionPropertiesChange', (error, value) => {
if (error) {
console.info(`${caseName} register fail: ${error}`);
expect().assertFail();
done();
} else {
console.info(`${caseName} netConnectionPropertiesChange handle = :` + value.handle.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.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
*@tc.desc Function test
*/
it('Telephony_NetworkManager_register_Async_0900', 0, async function (done) {
let caseName = 'Telephony_NetworkManager_rgister_Async_0900';
let netSpecifier = {
netCapabilities: {
linkUpBandwidthKbps: 0,
linkDownBandwidthKbps: 0,
bearerTypes: [1],
networkCap: [12],
}, bearerPrivateIdentifier: '123'
}
let netConn = connection.createNetConnection(netSpecifier, TIMEOUT);
let netId = 0;
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.handle.netId);
expect(value.netId).assertEqual(ETH_100);
}
});
netConn.on('netCapabilitiesChange', (error, value) => {
if (error) {
console.info(`${caseName} register fail: ${error}`);
expect().assertFail();
done();
} else {
console.info(`${caseName} netCapabilitiesChange handle = :` + value.handle.netId);
expect(value.netId).assertEqual(ETH_100);
}
});
netConn.on('netConnectionPropertiesChange', (error, value) => {
if (error) {
console.info(`${caseName} register fail: ${error}`);
expect().assertFail();
done();
} else {
console.info(`${caseName} netConnectionPropertiesChange handle = :` + value.handle.netId);
expect(value.netId).assertEqual(ETH_100);
}
});
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.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
*@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);
let netId = 0;
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.handle.netId);
expect(value.netId).assertEqual(ETH_100);
}
});
netConn.on('netCapabilitiesChange', (error, value) => {
if (error) {
console.info(`${caseName} register fail: ${error}`);
expect().assertFail();
done();
} else {
console.info(`${caseName} netCapabilitiesChange handle = :` + value.handle.netId);
}
});
netConn.on('netConnectionPropertiesChange', (error, value) => {
if (error) {
console.info(`${caseName} register fail: ${error}`);
expect().assertFail();
done();
} else {
console.info(`${caseName} netConnectionPropertiesChange handle = :` + value.handle.netId);
expect(value.netId).assertEqual(ETH_100);
}
});
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_1100
* @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_1100', 0, async function (done) {
let caseName = 'Telephony_NetworkManager_register_Async_1100';
let netSpecifier = {
netCapabilities: {
linkUpBandwidthKbps: 0,
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.handle.netId);
}
});
netConn.on('netCapabilitiesChange', (error, value) => {
if (error) {
console.info(`${caseName} register fail :${error}`);
expect().assertFail();
done();
} else {
console.info(`${caseName} netCapabilitiesChange handle = :` + value.handle.netId);
}
});
netConn.on('netConnectionPropertiesChange', (error, value) => {
if (error) {
console.info(`${caseName} register fail :${error}`);
expect().assertFail();
done();
} else {
console.info(`${caseName} netConnectionPropertiesChange handle = :` + value.handle.netId);
expect(value.netId).assertEqual(ETH_100);
}
});
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();
});
/**
* @tc.number Telephony_NetworkManager_register_Async_1200
* @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_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 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.handle.netId);
expect(value.netId).assertEqual(ETH_100);
}
});
netConn.on('netCapabilitiesChange', (error, value) => {
if (error) {
console.info(`${caseName} register fail :${error}`);
expect().assertFail();
done();
} else {
console.info(`${caseName} netCapabilitiesChange handle = :` + value.handle.netId);
expect(value.netId).assertEqual(ETH_100);
}
});
netConn.on('netConnectionPropertiesChange', (error, value) => {
if (error) {
console.info(`${caseName} register fail :${error}`);
expect().assertFail();
done();
} else {
console.info(`${caseName} netConnectionPropertiesChange handle = :` + value.handle.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();
});
/**
* @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';
let netSpecifier = {
netCapabilities: {
linkUpBandwidthKbps: 0,
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.handle.netId);
expect(value.handle.netId).assertEqual(ETH_100);
}
});
netConn.on('netCapabilitiesChange', (error, value) => {
if (error) {
console.info(`${caseName} register fail :${error}`);
expect().assertFail();
done();
} else {
console.info(`${caseName} netCapabilitiesChange handle = :` + value.handle.netId);
expect(value.handle.netId).assertEqual(ETH_100);
}
});
netConn.on('netConnectionPropertiesChange', (error, value) => {
if (error) {
console.info(`${caseName} register fail :${error}`);
expect().assertFail();
done();
} else {
console.info(`${caseName} netConnectionPropertiesChange handle = :` + value.handle.netId);
expect(value.handle.netId).assertEqual(ETH_100);
}
});
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();
});
/**
* @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';
let netSpecifier = {
netCapabilities: {
linkUpBandwidthKbps: 0,
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.handle.netId);
}
});
netConn.on('netCapabilitiesChange', (error, value) => {
if (error) {
console.info(`${caseName} register fail :${error}`);
expect().assertFail();
done();
} else {
console.info(`${caseName} netCapabilitiesChange handle = :` + value.handle.netId);
}
});
netConn.on('netConnectionPropertiesChange', (error, value) => {
if (error) {
console.info(`${caseName} register fail :${error}`);
expect().assertFail();
done();
} else {
console.info(`${caseName} netConnectionPropertiesChange handle = :` + value.handle.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();
});
/**
* @tc.number Telephony_NetworkManager_register_Async_1500
* @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_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.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).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.handle.netId);
}
});
netConn.on('netCapabilitiesChange', (error, value) => {
if (error) {
console.info(`${caseName} register fail :${error}`);
expect().assertFail();
done();
} else {
console.info(`${caseName} netCapabilitiesChange handle = :` + value.handle.netId);
}
});
netConn.on('netConnectionPropertiesChange', (error, value) => {
if (error) {
console.info(`${caseName} register fail :${error}`);
expect().assertFail();
done();
} else {
console.info(`${caseName} netConnectionPropertiesChange handle = :` + value.handle.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();
});
/**
* @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';
let netSpecifier = {
netCapabilities: {
linkUpBandwidthKbps: 0,
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.handle.netId);
}
});
netConn.on('netCapabilitiesChange', (error, value) => {
if (error) {
console.info(`${caseName} register fail :${error}`);
expect().assertFail();
done();
} else {
console.info(`${caseName} netCapabilitiesChange handle = :` + value.handle.netId);
}
});
netConn.on('netConnectionPropertiesChange', (error, value) => {
if (error) {
console.info(`${caseName} register fail :${error}`);
expect().assertFail();
done();
} else {
console.info(`${caseName} netConnectionPropertiesChange handle = :` + value.handle.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_1700
* @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_1700', 0, async function (done) {
let caseName = 'Telephony_NetworkManager_register_Async_1700';
let netSpecifier = {
netCapabilities: {
linkUpBandwidthKbps: 0,
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.handle.netId);
}
});
netConn.on('netCapabilitiesChange', (error, value) => {
if (error) {
console.info(`${caseName} register fail :${error}`);
expect().assertFail();
done();
} else {
console.info(`${caseName} netCapabilitiesChange handle = :` + value.handle.netId);
}
});
netConn.on('netConnectionPropertiesChange', (error, value) => {
if (error) {
console.info(`${caseName} register fail :${error}`);
expect().assertFail();
done();
} else {
console.info(`${caseName} netConnectionPropertiesChange handle = :` + value.handle.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_1800
* @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_1800', 0, async function (done) {
let caseName = 'Telephony_NetworkManager_register_Async_1800';
let netSpecifier = {
netCapabilities: {
linkUpBandwidthKbps: 0,
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.handle.netId);
}
});
netConn.on('netCapabilitiesChange', (error, value) => {
if (error) {
console.info(`${caseName} register fail :${error}`);
expect().assertFail();
done();
} else {
console.info(`${caseName} netCapabilitiesChange handle = :` + value.handle.netId);
}
});
netConn.on('netConnectionPropertiesChange', (error, value) => {
if (error) {
console.info(`${caseName} register fail :${error}`);
expect().assertFail();
done();
} else {
console.info(`${caseName} netConnectionPropertiesChange handle = :` + value.handle.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.handle.netId);
}
});
netConn1.on('netCapabilitiesChange', (error, value) => {
if (error) {
console.info(`${caseName} register fail :${error}`);
expect().assertFail();
done();
} else {
console.info(`${caseName} netCapabilitiesChange handle = :` + value.handle.netId);
}
});
netConn1.on('netConnectionPropertiesChange', (error, value) => {
if (error) {
console.info(`${caseName} register fail :${error}`);
expect().assertFail();
done();
} else {
console.info(`${caseName} netConnectionPropertiesChange handle = :` + value.handle.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_1900
* @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_1900', 0, async function (done) {
let caseName = 'Telephony_NetworkManager_register_Async_1900';
let netSpecifier = {
netCapabilities: {
linkUpBandwidthKbps: 0,
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.handle.netId);
}
});
netConn.on('netCapabilitiesChange', (error, value) => {
if (error) {
console.info(`${caseName} register fail :${error}`);
expect().assertFail();
done();
} else {
console.info(`${caseName} netCapabilitiesChange handle = :` + value.handle.netId);
}
});
netConn.on('netConnectionPropertiesChange', (error, value) => {
if (error) {
console.info(`${caseName} register fail :${error}`);
expect().assertFail();
done();
} else {
console.info(`${caseName} netConnectionPropertiesChange handle = :` + value.handle.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();
}
done();
});
done();
});
/**
* @tc.number Telephony_NetworkManager_register_Async_2000
* @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_2000', 0, async function (done) {
let caseName = 'Telephony_NetworkManager_register_Async_2000';
let netSpecifier = {
netCapabilities: {
linkUpBandwidthKbps: 0,
linkDownBandwidthKbps: 0,
bearerTypes: [0],
networkCap: [0],
}, bearerPrivateIdentifier: '123'
}
let netId = 0;
let netConn = connection.createNetConnection(netSpecifier, TIMEOUT);
netConn.on('netAvailable', (error, value) => {
expect(false).assertTrue()
done();
});
netConn.on('netBlockStatusChange', (error, value) => {
expect(false).assertTrue()
done();
});
netConn.on('netCapabilitiesChange', (error, value) => {
expect(false).assertTrue()
done();
});
netConn.on('netConnectionPropertiesChange', (error, value) => {
expect(false).assertTrue()
done();
});
netConn.on('netLost', (error, value) => {
expect(false).assertTrue()
done();
});
netConn.on('netUnavailable', (error, value) => {
done();
});
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();
});
/**
* @tc.number Telephony_NetworkManager_register_Async_2100
* @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_2100', 0, async function (done) {
let caseName = 'Telephony_NetworkManager_register_Async_2100';
let netSpecifier = {
netCapabilities: {
linkUpBandwidthKbps: 0,
linkDownBandwidthKbps: 0,
bearerTypes: [0],
networkCap: [0],
}, 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.handle.netId);
}
});
netConn.on('netCapabilitiesChange', (error, value) => {
if (error) {
console.info(`${caseName} register fail :${error}`);
expect().assertFail();
done();
} else {
console.info(`${caseName} netCapabilitiesChange handle = :` + value.handle.netId);
}
});
netConn.on('netConnectionPropertiesChange', (error, value) => {
if (error) {
console.info(`${caseName} register fail :${error}`);
expect().assertFail();
done();
} else {
console.info(`${caseName} netConnectionPropertiesChange handle = :` + value.handle.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();
});
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.handle.netId);
}
});
netConn1.on('netCapabilitiesChange', (error, value) => {
if (error) {
console.info(`${caseName} register fail :${error}`);
expect().assertFail();
done();
} else {
console.info(`${caseName} netCapabilitiesChange handle = :` + value.handle.netId);
}
});
netConn1.on('netConnectionPropertiesChange', (error, value) => {
if (error) {
console.info(`${caseName} register fail :${error}`);
expect().assertFail();
done();
} else {
console.info(`${caseName} netConnectionPropertiesChange handle = :` + value.handle.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.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_2200', 0, async function (done) {
let caseName = 'Telephony_NetworkManager_register_Async_2200';
let netSpecifier = {
netCapabilities: {
linkUpBandwidthKbps: 0,
linkDownBandwidthKbps: 0,
bearerTypes: [0],
networkCap: [0],
}, 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.handle.netId);
}
});
netConn.on('netCapabilitiesChange', (error, value) => {
if (error) {
console.info(`${caseName} register fail :${error}`);
expect().assertFail();
done();
} else {
console.info(`${caseName} netCapabilitiesChange handle = :` + value.handle.netId);
}
});
netConn.on('netConnectionPropertiesChange', (error, value) => {
if (error) {
console.info(`${caseName} register fail :${error}`);
expect().assertFail();
done();
} else {
console.info(`${caseName} netConnectionPropertiesChange handle = :` + value.handle.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();
});
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.handle.netId);
}
});
netConn1.on('netCapabilitiesChange', (error, value) => {
if (error) {
console.info(`${caseName} register fail :${error}`);
expect().assertFail();
done();
} else {
console.info(`${caseName} netCapabilitiesChange handle = :` + value.handle.netId);
}
});
netConn1.on('netConnectionPropertiesChange', (error, value) => {
if (error) {
console.info(`${caseName} register fail :${error}`);
expect().assertFail();
done();
} else {
console.info(`${caseName} netConnectionPropertiesChange handle = :` + value.handle.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.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_2300', 0, async function (done) {
let caseName = 'Telephony_NetworkManager_register_Async_2300';
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} on 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} on netConnectionPropertiesChange fail`);
expect().assertFail();
done();
} else {
console.info(`${caseName} netConnectionPropertiesChange hdndle` + 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(`${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.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_0100', 0, async function (done) {
let caseName = 'Telephony_NetworkManager_unregister_Async_0100';
let netSpecifier = {
netCapabilities: {
linkUpBandwidthKbps: 0,
linkDownBandwidthKbps: 0,
bearerTypes: [0],
networkCap: [0],
}, bearerPrivateIdentifier: '123'
}
let netConn = connection.createNetConnection(netSpecifier, TIMEOUT_1);
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.handle.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.handle.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.handle.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.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.handle.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.handle.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.handle.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) {
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.handle.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.handle.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.handle.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
{
"string": [
{
"name": "app_name",
"value": "Sim Test"
},
{
"name": "mainability_description",
"value": "Sim Test - sim manager interface test"
}
]
}
\ No newline at end of file
/**
* Copyright (C) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
require('./NetworkManagerRegister.test.js');
\ No newline at end of file
/**
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License")
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import connection from '@ohos.net.connection';
import {describe, afterAll, it, expect, beforeAll, afterEach} from 'deccjsunit/index';
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;
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.handle.netId);
expect(value.handle.netId).assertEqual(ETH_100);
}
});
netConn.on('netConnectionPropertiesChange', (value) => {
if (value === undefined) {
console.info(`${caseName} netConnectionPropertiesChange fail`);
expect().assertFail();
done();
} else {
console.info(`${caseName} netConnectionPropertiesChange handle = :` + value.handle.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();
});
/**
*@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;
}
});
netConn.on('netCapabilitiesChange', (value) => {
if (value === undefined) {
console.info(`${caseName} netCapabilitiesChange fail`);
expect().assertFail();
done();
} else {
console.info(`${caseName} netCapabilitiesChange handle =:` + value.handle.netId);
expect(value.handle.netId).assertEqual(ETH_100);
}
});
netConn.on('netConnectionPropertiesChange', (value) => {
if (value === undefined) {
console.info(`${caseName} netConnectionPropertiesChange fail`);
expect().assertFail();
done();
} else {
console.info(`${caseName} netConnectionPropertiesChange handle =:` + value.handle.netId);
}
});
netConn.on('netLost', (value) => {
if (error) {
console.info(`${caseName} netLost fail`);
expect().assertFail();
done();
} else {
console.info(`${caseName} netLost : ` + value.netId);
}
});
netConn.on('netUnavailable', (value) => {
if (error) {
console.info(`${caseName} netUnavailable fail`);
expect().assertFail();
done();
} else {
console.info(`${caseName} netUnavailable: ` + value.netId);
}
});
netConn.on('netBlockStatuschange', (value) => {
if (error) {
console.info(`${caseName} netBlockStatusChange fail`);
expect().assertFail();
done();
} else {
console.info(`${caseName} netBlockStatusChange : ` + value.netId);
}
});
netConn.register((error) => {
if (error) {
console.info(`${caseName} register fail: ${error}`);
}
});
await sleep(DELAY);
netConn.unregister((error) => {
if (error) {
console.info(`${caseName} unregisterresult: ${error}` + JSON.stringify(error));
done();
}
});
done();
});
/*
*@tc.number Telephony_NetworkManager_register_Async_0300
*@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
*@tc.desc Function test
*/
it('Telephony_NetworkManager_register_Async_0300', 0, async function (done) {
let caseName = 'Telephony_NetworkManager_register_Async_0300';
let netSpecifier = {
netCapabilities: {
linkUpBandwidthKbps: 0,
linkDownBandwidthKbps: 0,
bearerTypes: [0],
networkCap: [11],
}, bearPrivateIdentifier: '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.handle.netId);
}
});
netConn.on('netBlockStatusChange', (error, value) => {
if (error) {
console.info(`${caseName} register fail: ${error}`);
expect().assertFail();
done();
} else {
console.info(`${caseName} netBlockStatusChange handle = :` + value.handle.netId);
}
});
netConn.on('netConnectionPropertiesChange', (error, value) => {
if (error) {
console.info(`${caseName} register fail: ${error}`);
expect().assertFail();
done();
} else {
console.info(`${caseName} netConnectionPropertiesChange handle = :` + value.handle.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.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
*@tc.desc Function test
*/
it('Telephony_NetworkManager_register_Async_0400', 0, async function (done) {
let caseName = 'Telephony_NetworkManager_register_Async_0400';
let netId = 0;
let netSpecifier = {
netCapabilities: {
linkUpBandwidthKbps: 0,
linkDownBandwidthKbps: 0,
bearerTypes: [0],
networkCap: [12],
}, bearPrivateIdentifier: '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.handle.netId);
}
});
netConn.on('netCapabilitiesChange', (error, value) => {
if (error) {
console.info(`${caseName} register fail: ${error}`);
expect().assertFail();
done();
} else {
console.info(`${caseName} netCapabilitiesChange handle = :` + value.handle.netId);
}
});
netConn.on('netConnectionPropertiesChange', (error, value) => {
if (error) {
console.info(`${caseName} register fail: ${error}`);
expect().assertFail();
done();
} else {
console.info(`${caseName} netConnectionPropertiesChange handle = :` + value.handle.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.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
*@tc.desc Function test
*/
it('Telephony_NetworkManager_register_Async_0500', 0, async function (done) {
let caseName = 'Telephony_NetworkManager_rgister_Async_0500';
let netSpecifier = {
netCapabilities: {
linkUpBandwidthKbps: 0,
linkDownBandwidthKbps: 0,
bearerTypes: [0],
networkCap: [15],
}, bearPrivateIdentifier: '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.handle.netId);
}
});
netConn.on('netCapabilitiesChange', (error, value) => {
if (error) {
console.info(`${caseName} register fail: ${error}`);
expect().assertFail();
done();
} else {
console.info(`${caseName} netCapabilitiesChange handle = :` + value.handle.netId);
}
});
netConn.on('netConnectionPropertiesChange', (error, value) => {
if (error) {
console.info(`${caseName} register fail: ${error}`);
expect().assertFail();
done();
} else {
console.info(`${caseName} netConnectionPropertiesChange handle = :` + value.handle.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.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
*@tc.desc Function test
*/
it('Telephony_NetworkManager_register_Async_0600', 0, async function (done) {
let caseName = 'Telephony_NetworkManager_rgister_Async_0600';
let netSpecifier = {
netCapabilities: {
linkUpBandwidthKbps: 0,
linkDownBandwidthKbps: 0,
bearerTypes: [0],
networkCap: [16],
}, bearPrivateIdentifier: '123'
}
let netConn = connection.createNetConnection(netSpecifier, TIMEOUT);
let netId = 0;
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.handle.netId);
}
});
netConn.on('netCapabilitiesChange', (error, value) => {
if (error) {
console.info(`${caseName} register fail: ${error}`);
expect().assertFail();
done();
} else {
console.info(`${caseName} netCapabilitiesChange handle = :` + value.handle.netId);
}
});
netConn.on('netConnectionPropertiesChange', (error, value) => {
if (error) {
console.info(`${caseName} register fail: ${error}`);
expect().assertFail();
done();
} else {
console.info(`${caseName} netConnectionPropertiesChange handle = :` + value.handle.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.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
*@tc.desc Function test
*/
it('Telephony_NetworkManager_register_Async_0700', 0, async function (done) {
let caseName = 'Telephony_NetworkManager_rgister_Async_0700';
let netSpecifier = {
netCapabilities: {
linkUpBandwidthKbps: 0,
linkDownBandwidthKbps: 0,
bearerTypes: [0],
networkCap: [17],
}, bearPrivateIdentifier: '123'
}
let netConn = connection.createNetConnection(netSpecifier, TIMEOUT);
let netId = 0;
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.handle.netId);
}
});
netConn.on('netCapabilitiesChange', (error, value) => {
if (error) {
console.info(`${caseName} register fail: ${error}`);
expect().assertFail();
done();
} else {
console.info(`${caseName} netCapabilitiesChange handle = :` + value.handle.netId);
}
});
netConn.on('netConnectionPropertiesChange', (error, value) => {
if (error) {
console.info(`${caseName} register fail: ${error}`);
expect().assertFail();
done();
} else {
console.info(`${caseName} netConnectionPropertiesChange handle = :` + value.handle.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.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
*@tc.desc Function test
*/
it('Telephony_NetworkManager_register_Async_0800', 0, async function (done) {
let caseName = 'Telephony_NetworkManager_rgister_Async_0800';
let netSpecifier = {
netCapabilities: {
linkUpBandwidthKbps: 0,
linkDownBandwidthKbps: 0,
bearerTypes: [1],
networkCap: [0],
}, bearPrivateIdentifier: '123'
}
let netConn = connection.createNetConnection(netSpecifier, TIMEOUT);
let netId = 0;
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.handle.netId);
}
});
netConn.on('netCapabilitiesChange', (error, value) => {
if (error) {
console.info(`${caseName} register fail: ${error}`);
expect().assertFail();
done();
} else {
console.info(`${caseName} netCapabilitiesChange handle = :` + value.handle.netId);
}
});
netConn.on('netConnectionPropertiesChange', (error, value) => {
if (error) {
console.info(`${caseName} register fail: ${error}`);
expect().assertFail();
done();
} else {
console.info(`${caseName} netConnectionPropertiesChange handle = :` + value.handle.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.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
*@tc.desc Function test
*/
it('Telephony_NetworkManager_register_Async_0900', 0, async function (done) {
let caseName = 'Telephony_NetworkManager_rgister_Async_0900';
let netSpecifier = {
netCapabilities: {
linkUpBandwidthKbps: 0,
linkDownBandwidthKbps: 0,
bearerTypes: [1],
networkCap: [12],
}, bearPrivateIdentifier: '123'
}
let netConn = connection.createNetConnection(netSpecifier, TIMEOUT);
let netId = 0;
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.handle.netId);
expect(value.netId).assertEqual(ETH_100);
}
});
netConn.on('netCapabilitiesChange', (error, value) => {
if (error) {
console.info(`${caseName} register fail: ${error}`);
expect().assertFail();
done();
} else {
console.info(`${caseName} netCapabilitiesChange handle = :` + value.handle.netId);
expect(value.netId).assertEqual(ETH_100);
}
});
netConn.on('netConnectionPropertiesChange', (error, value) => {
if (error) {
console.info(`${caseName} register fail: ${error}`);
expect().assertFail();
done();
} else {
console.info(`${caseName} netConnectionPropertiesChange handle = :` + value.handle.netId);
expect(value.netId).assertEqual(ETH_100);
}
});
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_1000
*@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
*@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],
}, bearPrivateIdentifier: '123'
}
let netConn = connection.createNetConnection(netSpecifier, TIMEOUT);
let netId = 0;
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.handle.netId);
expect(value.netId).assertEqual(ETH_100);
}
});
netConn.on('netCapabilitiesChange', (error, value) => {
if (error) {
console.info(`${caseName} register fail: ${error}`);
expect().assertFail();
done();
} else {
console.info(`${caseName} netCapabilitiesChange handle = :` + value.handle.netId);
}
});
netConn.on('netConnectionPropertiesChange', (error, value) => {
if (error) {
console.info(`${caseName} register fail: ${error}`);
expect().assertFail();
done();
} else {
console.info(`${caseName} netConnectionPropertiesChange handle = :` + value.handle.netId);
expect(value.netId).assertEqual(ETH_100);
}
});
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_1100
* @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_1100', 0, async function (done) {
let caseName = 'Telephony_NetworkManager_register_Async_1100';
let netSpecifier = {
netCapabilities: {
linkUpBandwidthKbps: 0,
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.handle.netId);
}
});
netConn.on('netCapabilitiesChange', (error, value) => {
if (error) {
console.info(`${caseName} register fail :${error}`);
expect().assertFail();
done();
} else {
console.info(`${caseName} netCapabilitiesChange handle = :` + value.handle.netId);
}
});
netConn.on('netConnectionPropertiesChange', (error, value) => {
if (error) {
console.info(`${caseName} register fail :${error}`);
expect().assertFail();
done();
} else {
console.info(`${caseName} netConnectionPropertiesChange handle = :` + value.handle.netId);
expect(value.netId).assertEqual(ETH_100);
}
});
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();
});
/**
* @tc.number Telephony_NetworkManager_register_Async_1200
* @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_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 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.handle.netId);
expect(value.netId).assertEqual(ETH_100);
}
});
netConn.on('netCapabilitiesChange', (error, value) => {
if (error) {
console.info(`${caseName} register fail :${error}`);
expect().assertFail();
done();
} else {
console.info(`${caseName} netCapabilitiesChange handle = :` + value.handle.netId);
expect(value.netId).assertEqual(ETH_100);
}
});
netConn.on('netConnectionPropertiesChange', (error, value) => {
if (error) {
console.info(`${caseName} register fail :${error}`);
expect().assertFail();
done();
} else {
console.info(`${caseName} netConnectionPropertiesChange handle = :` + value.handle.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();
});
/**
* @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';
let netSpecifier = {
netCapabilities: {
linkUpBandwidthKbps: 0,
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.handle.netId);
expect(value.handle.netId).assertEqual(ETH_100);
}
});
netConn.on('netCapabilitiesChange', (error, value) => {
if (error) {
console.info(`${caseName} register fail :${error}`);
expect().assertFail();
done();
} else {
console.info(`${caseName} netCapabilitiesChange handle = :` + value.handle.netId);
expect(value.handle.netId).assertEqual(ETH_100);
}
});
netConn.on('netConnectionPropertiesChange', (error, value) => {
if (error) {
console.info(`${caseName} register fail :${error}`);
expect().assertFail();
done();
} else {
console.info(`${caseName} netConnectionPropertiesChange handle = :` + value.handle.netId);
expect(value.handle.netId).assertEqual(ETH_100);
}
});
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();
});
/**
* @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';
let netSpecifier = {
netCapabilities: {
linkUpBandwidthKbps: 0,
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.handle.netId);
}
});
netConn.on('netCapabilitiesChange', (error, value) => {
if (error) {
console.info(`${caseName} register fail :${error}`);
expect().assertFail();
done();
} else {
console.info(`${caseName} netCapabilitiesChange handle = :` + value.handle.netId);
}
});
netConn.on('netConnectionPropertiesChange', (error, value) => {
if (error) {
console.info(`${caseName} register fail :${error}`);
expect().assertFail();
done();
} else {
console.info(`${caseName} netConnectionPropertiesChange handle = :` + value.handle.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();
});
/**
* @tc.number Telephony_NetworkManager_register_Async_1500
* @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_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.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).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.handle.netId);
}
});
netConn.on('netCapabilitiesChange', (error, value) => {
if (error) {
console.info(`${caseName} register fail :${error}`);
expect().assertFail();
done();
} else {
console.info(`${caseName} netCapabilitiesChange handle = :` + value.handle.netId);
}
});
netConn.on('netConnectionPropertiesChange', (error, value) => {
if (error) {
console.info(`${caseName} register fail :${error}`);
expect().assertFail();
done();
} else {
console.info(`${caseName} netConnectionPropertiesChange handle = :` + value.handle.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();
});
/**
* @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';
let netSpecifier = {
netCapabilities: {
linkUpBandwidthKbps: 0,
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.handle.netId);
}
});
netConn.on('netCapabilitiesChange', (error, value) => {
if (error) {
console.info(`${caseName} register fail :${error}`);
expect().assertFail();
done();
} else {
console.info(`${caseName} netCapabilitiesChange handle = :` + value.handle.netId);
}
});
netConn.on('netConnectionPropertiesChange', (error, value) => {
if (error) {
console.info(`${caseName} register fail :${error}`);
expect().assertFail();
done();
} else {
console.info(`${caseName} netConnectionPropertiesChange handle = :` + value.handle.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_1700
* @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_1700', 0, async function (done) {
let caseName = 'Telephony_NetworkManager_register_Async_1700';
let netSpecifier = {
netCapabilities: {
linkUpBandwidthKbps: 0,
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.handle.netId);
}
});
netConn.on('netCapabilitiesChange', (error, value) => {
if (error) {
console.info(`${caseName} register fail :${error}`);
expect().assertFail();
done();
} else {
console.info(`${caseName} netCapabilitiesChange handle = :` + value.handle.netId);
}
});
netConn.on('netConnectionPropertiesChange', (error, value) => {
if (error) {
console.info(`${caseName} register fail :${error}`);
expect().assertFail();
done();
} else {
console.info(`${caseName} netConnectionPropertiesChange handle = :` + value.handle.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_1800
* @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_1800', 0, async function (done) {
let caseName = 'Telephony_NetworkManager_register_Async_1800';
let netSpecifier = {
netCapabilities: {
linkUpBandwidthKbps: 0,
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.handle.netId);
}
});
netConn.on('netCapabilitiesChange', (error, value) => {
if (error) {
console.info(`${caseName} register fail :${error}`);
expect().assertFail();
done();
} else {
console.info(`${caseName} netCapabilitiesChange handle = :` + value.handle.netId);
}
});
netConn.on('netConnectionPropertiesChange', (error, value) => {
if (error) {
console.info(`${caseName} register fail :${error}`);
expect().assertFail();
done();
} else {
console.info(`${caseName} netConnectionPropertiesChange handle = :` + value.handle.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.handle.netId);
}
});
netConn1.on('netCapabilitiesChange', (error, value) => {
if (error) {
console.info(`${caseName} register fail :${error}`);
expect().assertFail();
done();
} else {
console.info(`${caseName} netCapabilitiesChange handle = :` + value.handle.netId);
}
});
netConn1.on('netConnectionPropertiesChange', (error, value) => {
if (error) {
console.info(`${caseName} register fail :${error}`);
expect().assertFail();
done();
} else {
console.info(`${caseName} netConnectionPropertiesChange handle = :` + value.handle.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_1900
* @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_1900', 0, async function (done) {
let caseName = 'Telephony_NetworkManager_register_Async_1900';
let netSpecifier = {
netCapabilities: {
linkUpBandwidthKbps: 0,
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.handle.netId);
}
});
netConn.on('netCapabilitiesChange', (error, value) => {
if (error) {
console.info(`${caseName} register fail :${error}`);
expect().assertFail();
done();
} else {
console.info(`${caseName} netCapabilitiesChange handle = :` + value.handle.netId);
}
});
netConn.on('netConnectionPropertiesChange', (error, value) => {
if (error) {
console.info(`${caseName} register fail :${error}`);
expect().assertFail();
done();
} else {
console.info(`${caseName} netConnectionPropertiesChange handle = :` + value.handle.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();
}
done();
});
done();
});
/**
* @tc.number Telephony_NetworkManager_register_Async_2000
* @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_2000', 0, async function (done) {
let caseName = 'Telephony_NetworkManager_register_Async_2000';
let netSpecifier = {
netCapabilities: {
linkUpBandwidthKbps: 0,
linkDownBandwidthKbps: 0,
bearerTypes: [0],
networkCap: [0],
}, bearerPrivateIdentifier: '123'
}
let netId = 0;
let netConn = connection.createNetConnection(netSpecifier, TIMEOUT);
netConn.on('netAvailable', (error, value) => {
expect(false).assertTrue()
done();
});
netConn.on('netBlockStatusChange', (error, value) => {
expect(false).assertTrue()
done();
});
netConn.on('netCapabilitiesChange', (error, value) => {
expect(false).assertTrue()
done();
});
netConn.on('netConnectionPropertiesChange', (error, value) => {
expect(false).assertTrue()
done();
});
netConn.on('netLost', (error, value) => {
expect(false).assertTrue()
done();
});
netConn.on('netUnavailable', (error, value) => {
done();
});
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();
});
/**
* @tc.number Telephony_NetworkManager_register_Async_2100
* @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_2100', 0, async function (done) {
let caseName = 'Telephony_NetworkManager_register_Async_2100';
let netSpecifier = {
netCapabilities: {
linkUpBandwidthKbps: 0,
linkDownBandwidthKbps: 0,
bearerTypes: [0],
networkCap: [0],
}, 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.handle.netId);
}
});
netConn.on('netCapabilitiesChange', (error, value) => {
if (error) {
console.info(`${caseName} register fail :${error}`);
expect().assertFail();
done();
} else {
console.info(`${caseName} netCapabilitiesChange handle = :` + value.handle.netId);
}
});
netConn.on('netConnectionPropertiesChange', (error, value) => {
if (error) {
console.info(`${caseName} register fail :${error}`);
expect().assertFail();
done();
} else {
console.info(`${caseName} netConnectionPropertiesChange handle = :` + value.handle.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();
});
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.handle.netId);
}
});
netConn1.on('netCapabilitiesChange', (error, value) => {
if (error) {
console.info(`${caseName} register fail :${error}`);
expect().assertFail();
done();
} else {
console.info(`${caseName} netCapabilitiesChange handle = :` + value.handle.netId);
}
});
netConn1.on('netConnectionPropertiesChange', (error, value) => {
if (error) {
console.info(`${caseName} register fail :${error}`);
expect().assertFail();
done();
} else {
console.info(`${caseName} netConnectionPropertiesChange handle = :` + value.handle.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.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_2200', 0, async function (done) {
let caseName = 'Telephony_NetworkManager_register_Async_2200';
let netSpecifier = {
netCapabilities: {
linkUpBandwidthKbps: 0,
linkDownBandwidthKbps: 0,
bearerTypes: [0],
networkCap: [0],
}, 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.handle.netId);
}
});
netConn.on('netCapabilitiesChange', (error, value) => {
if (error) {
console.info(`${caseName} register fail :${error}`);
expect().assertFail();
done();
} else {
console.info(`${caseName} netCapabilitiesChange handle = :` + value.handle.netId);
}
});
netConn.on('netConnectionPropertiesChange', (error, value) => {
if (error) {
console.info(`${caseName} register fail :${error}`);
expect().assertFail();
done();
} else {
console.info(`${caseName} netConnectionPropertiesChange handle = :` + value.handle.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();
});
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.handle.netId);
}
});
netConn1.on('netCapabilitiesChange', (error, value) => {
if (error) {
console.info(`${caseName} register fail :${error}`);
expect().assertFail();
done();
} else {
console.info(`${caseName} netCapabilitiesChange handle = :` + value.handle.netId);
}
});
netConn1.on('netConnectionPropertiesChange', (error, value) => {
if (error) {
console.info(`${caseName} register fail :${error}`);
expect().assertFail();
done();
} else {
console.info(`${caseName} netConnectionPropertiesChange handle = :` + value.handle.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.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_2300', 0, async function (done) {
let caseName = 'Telephony_NetworkManager_register_Async_2300';
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} on 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} on netConnectionPropertiesChange fail`);
expect().assertFail();
done();
} else {
console.info(`${caseName} netConnectionPropertiesChange hdndle` + 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(`${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.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_0100', 0, async function (done) {
let caseName = 'Telephony_NetworkManager_unregister_Async_0100';
let netSpecifier = {
netCapabilities: {
linkUpBandwidthKbps: 0,
linkDownBandwidthKbps: 0,
bearerTypes: [0],
networkCap: [0],
}, bearerPrivateIdentifier: '123'
}
let netConn = connection.createNetConnection(netSpecifier, TIMEOUT_1);
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.handle.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.handle.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.handle.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.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.handle.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.handle.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.handle.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) {
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.handle.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.handle.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.handle.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
{
"string": [
{
"name": "app_name",
"value": "Sim Test"
},
{
"name": "mainability_description",
"value": "Sim Test - sim manager interface test"
}
]
}
\ No newline at end of file
# Copyright (c) 2021 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("ActsSocketTest") {
hap_profile = "./entry/src/main/config.json"
deps = [
":hjs_demo_js_assets",
":hjs_demo_resources",
]
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "ActsSocketTest"
}
ohos_js_assets("hjs_demo_js_assets") {
source_dir = "./entry/src/main/js/default"
}
ohos_resources("hjs_demo_resources") {
sources = [ "./entry/src/main/js/resources" ]
hap_profile = "./entry/src/main/config.json"
}
{
"description": "Function test of sim manager interface",
"driver": {
"type": "JSUnitTest",
"test-timeout": "1800000",
"package": "com.ohos.socket",
"shell-timeout": "60000"
},
"kits": [
{
"test-file-name": [
"$module.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
{
"app": {
"bundleName": "com.ohos.socket",
"vendor": "ohos",
"version": {
"code": 1000000,
"name": "1.0.0"
},
"apiVersion": {
"compatible": 4,
"target": 5,
"releaseType": "Release"
}
},
"deviceConfig": {},
"module": {
"package": "com.ohos.socket",
"name": ".MyApplication",
"deviceType": [
"phone"
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "entry",
"moduleType": "entry"
},
"abilities": [
{
"visible": true,
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"name": "com.ohos.socket.MainAbility",
"icon": "$media:icon",
"description": "$string:mainability_description",
"label": "$string:app_name",
"type": "page",
"launchType": "standard"
}
],
"reqPermissions": [
{
"name": "ohos.permission.LOCATION",
"reason": "need use ohos.permission.LOCATION"
},
{
"name":"ohos.permission.SET_TELEPHONY_STATE",
"reason":"need use ohos.permission.SET_TELEPHONY_STATE"
},
{
"name":"ohos.permission.GET_TELEPHONY_STATE",
"reason":"need use ohos.permission.GET_TELEPHONY_STATE"
},
{
"name":"ohos.permission.PLACE_CALL",
"reason":"need use ohos.permission.PLACE_CALL"
},
{
"name":"ohos.permission.READ_CONTACTS",
"reason":"need use ohos.permission.READ_CONTACTS"
},
{
"name":"ohos.permission.WRITE_CONTACTS",
"reason":"need use ohos.permission.WRITE_CONTACTS"
},
{
"name":"ohos.permission.SEND_MESSAGES",
"reason":"need use ohos.permission.SEND_MESSAGES"
},
{
"name":"ohos.permission.RECEIVE_SMS",
"reason":"need use ohos.permission.RECEIVE_SMS"
},
{
"name":"ohos.permission.READ_CALL_LOG",
"reason":"need use ohos.permission.READ_CALL_LOG"
},
{
"name":"ohos.permission.GET_NETWORK_INFO",
"reason":"need use ohos.permission.GET_NETWORK_INFO"
},
{
"name":"ohos.permission.INTERNET",
"reason":"need use ohos.permission.INTERNET"
}
],
"js": [
{
"pages": [
"pages/index/index"
],
"name": "default",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
}
]
}
}
\ No newline at end of file
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export default {
onCreate () {
console.info('TestApplication onCreate');
},
onDestroy () {
console.info('TestApplication onDestroy');
}
};
{
"strings": {
"hello": "Hello",
"world": "World"
},
"Files": {
}
}
\ No newline at end of file
{
"strings": {
"hello": "您好",
"world": "世界"
},
"Files": {
}
}
\ No newline at end of file
.container {
flex-direction: column;
justify-content: center;
align-items: center;
}
.title {
font-size: 100px;
}
<div class="container">
<text class="title">
SIM TEST
</text>
</div>
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import file from '@system.file';
import app from '@system.app';
import device from '@system.device';
import router from '@system.router';
import {Core, ExpectExtend} from 'deccjsunit/index';
const injectRef = Object.getPrototypeOf(global) || global
injectRef.regeneratorRuntime = require('@babel/runtime/regenerator')
export default {
data: {
title: ''
},
onInit () {
this.title = this.$t('strings.world');
},
onShow () {
console.info('onShow finish!');
const core = Core.getInstance();
const expectExtend = new ExpectExtend({
'id': 'extend'
});
core.addService('expect', expectExtend);
core.init();
const configService = core.getDefaultService('config');
this.timeout = 30000
configService.setConfig(this);
require('../../../test/List.test');
core.execute();
},
onReady () {
},
};
\ No newline at end of file
{
"string": [
{
"name": "app_name",
"value": "Sim Test"
},
{
"name": "mainability_description",
"value": "Sim Test - sim manager interface test"
}
]
}
\ No newline at end of file
/**
* Copyright (C) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
require('./NetStackSocket.test');
\ No newline at end of file
/**
* Copyright (C) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License")
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import netSocket from '@ohos.net.socket';
import {describe, afterAll, it, expect, beforeAll, afterEach} from 'deccjsunit/index';
describe('Telephony_NETSTACK_SocketTest',function(){
/**
* @tc.number Telephony_NetStack_UDPTest0100
* @tc.name UDP bind,callback方式,预计无异常,错误码为undefined
* @tc.desc Function test`
*/
it('Telephony_NetStack_UDPTest0100', 0, function(done){
let udp = netSocket.constructUDPSocketInstance()
udp.bind({
address : "127.0.0.1",
family : 1,
port : 0
},function(err,data){
expect(err === undefined).assertTure()
done()
})
done()
});
/**
* @tc.number Telephony_NetStack_UDPTest0200
* @tc.name UDP bind,promise方式,预计无异常,错误码为undefined
* @tc.desc Function test`
*/
it('Telephony_NetStack_UDPTest0200', 0, function(done){
let udp = netSocket.constructUDPSocketInstance()
udp.bind({
address : "127.0.0.1",
family : 1,
port : 0
}).then(function(data){
expect(data === undefined).assertTure()
done()
})
done()
});
/**
* @tc.number Telephony_NetStack_UDPTest0300
* @tc.name UDP send,callback方式,预计无异常,错误码为undefined
* @tc.desc Function test`
*/
it('Telephony_NetStack_UDPTest0300', 0, function(done){
let udp = netSocket.constructUDPSocketInstance()
udp.send({
address: {
address : "127.0.0.1",
family : 1,
port : 0
},
data : "Hello"
},function(err,data){
expect(err !== undefined).assertTure()
done()
})
done()
});
/**
* @tc.number Telephony_NetStack_UDPTest0400
* @tc.name UDP send,promise方式,预计无异常,错误码为undefined
* @tc.desc Function test`
*/
it('Telephony_NetStack_UDPTest0400', 0, function(done){
let udp = netSocket.constructUDPSocketInstance()
udp.send({
address:{
address : "127.0.0.1",
family : 1,
port : 0
},
data : "Hello"
}).then(function(data){
expect(data !== undefined).assertTure()
done()
})
done()
});
/**
* @tc.number Telephony_NetStack_UDPTest0500
* @tc.name UDP close,callback方式,预计无异常,错误码为undefined
* @tc.desc Function test`
*/
it('Telephony_NetStack_UDPTest0500', 0, function(done){
let udp = netSocket.constructUDPSocketInstance()
udp.close(function(err,data){
expect(err !== undefined).assertTrue()
done()
})
done()
});
/**
* @tc.number Telephony_NetStack_UDPTest0600
* @tc.name UDP close,promise方式,预计无异常,错误码为undefined
* @tc.desc Function test`
*/
it('Telephony_NetStack_UDPTest0600', 0, function(done){
let udp = netSocket.constructUDPSocketInstance()
udp.close().then(function(data){
expect(data !== undefined).assertTrue()
done()
})
done()
});
/**
* @tc.number Telephony_NetStack_UDPTest0700
* @tc.name UDP getState,callback方式,预计无异常,错误码为undefined
* @tc.desc Function test`
*/
it('Telephony_NetStack_UDPTest0700', 0, function(done){
let udp = netSocket.constructUDPSocketInstance()
udp.getState(function(err,data){
expect(err !== undefined).assertTrue()
done()
})
done()
});
/**
* @tc.number Telephony_NetStack_UDPTest0800
* @tc.name UDP getState,promise方式,预计无异常,错误码为undefined
* @tc.desc Function test`
*/
it('Telephony_NetStack_UDPTest0800', 0, function(done){
let udp = netSocket.constructUDPSocketInstance()
udp.getState().then(function(data){
expect(data !== undefined).assertTure()
done()
})
done()
});
/**
* @tc.number Telephony_NetStack_UDPTest0900
* @tc.name UDP setExtraOptions,callback方式,预计无异常,错误码为undefined
* @tc.desc Function test`
*/
it('Telephony_NetStack_UDPTest0900', 0, function(done){
let udp = netSocket.constructUDPSocketInstance()
udp.setExtraOptions({},function(err,data){
expect(err !==undefined).assertTure()
done()
})
done()
});
/**
* @tc.number Telephony_NetStack_UDPTest1000
* @tc.name UDP setExtraOptions,promise方式,预计无异常,错误码为undefined
* @tc.desc Function test`
*/
it('Telephony_NetStack_UDPTest1000', 0, function(done){
let udp = netSocket.constructUDPSocketInstance()
udp.setExtraOptions({},).then(function(date){
expect(date !== undefined).assertTrue()
done()
})
done()
});
/**
* @tc.number Telephony_NetStack_UDPTest1100
* @tc.name UDP on,预计callback不被调用
* @tc.desc Function test`
*/
it('Telephony_NetStack_UDPTest1100', 0, function(done){
let udp =netSocket.constructUDPSocketInstance()
udp.on('message',function(){
expect().assertFail()
done()
})
udp.on('listening',function(){
expect().assertFail()
done()
})
udp.on('close',function(){
expect().assertFail()
done()
})
udp.on('error',function(){
expect().assertFail()
done()
})
done()
});
/**
* @tc.number Telephony_NetStack_UDPTest1100
* @tc.name UDP on,预计callback不被调用
* @tc.desc Function test`
*/
it('Telephony_NetStack_UDPTest1100', 0, function(done){
let udp =netSocket.constructUDPSocketInstance()
udp.on('message',function(){
expect().assertFail()
done()
})
udp.on('listening',function(){
expect().assertFail()
done()
})
udp.on('close',function(){
expect().assertFail()
done()
})
udp.on('error',function(){
expect().assertFail()
done()
})
done()
});
/**
* @tc.number Telephony_NetStack_UDPTest1200
* @tc.name UDP off,预计callback不被调用
* @tc.desc Function test`
*/
it('Telephony_NetStack_UDPTest1200', 0, function(done){
let udp =netSocket.constructUDPSocketInstance()
udp.off('message',function(){
expect().assertFail()
done()
})
udp.off('listening',function(){
expect().assertFail()
done()
})
udp.off('close',function(){
expect().assertFail()
done()
})
udp.off('error',function(){
expect().assertFail()
done()
})
done()
});
/**
* @tc.number Telephony_NetStack_TCPTest0100
* @tc.name TCP bind,callback方式,预计无异常,错误码为undefined
* @tc.desc Function test`
*/
it('Telephony_NetStack_TCPTest0100', 0, function(done){
let tcp = netSocket.constructTCPSocketInstance()
tcp.bind({
address : "127.0.0.1",
family : 1,
port : 0
},function(err,data){
expect(err === undefined).assertTure()
done()
})
done()
});
/**
* @tc.number Telephony_NetStack_TCPTest0200
* @tc.name TCP bind,promise方式,预计无异常,错误码为undefined
* @tc.desc Function test`
*/
it('Telephony_NetStack_TCPTest0200', 0, function(done){
let tcp = netSocket.constructTCPSocketInstance()
tcp.bind({
address : "127.0.0.1",
family : 1,
port : 0
}).then(function(data){
expect(data === undefined).assertTure()
done()
})
done()
});
/**
* @tc.number Telephony_NetStack_TCPTest0300
* @tc.name TCP send,callback方式,预计无异常,错误码为undefined
* @tc.desc Function test`
*/
it('Telephony_NetStack_TCPTest0300', 0, function(done){
let tcp = netSocket.constructTCPSocketInstance()
tcp.send({
data : "Hello"
},function(err,data){
expect(err !== undefined).assertTure()
done()
})
done()
});
/**
* @tc.number Telephony_NetStack_TCPTest0400
* @tc.name TCP send,promise方式,预计无异常,错误码为undefined
* @tc.desc Function test`
*/
it('Telephony_NetStack_TCPTest0400', 0, function(done){
let tcp =netSocket.constructTCPSocketInstance()
tcp.send({
data : "Hello"
}).then(function(data){
expect(data !== undefined).assertTure()
done()
})
done()
});
/**
* @tc.number Telephony_NetStack_TCPTest0500
* @tc.name TCP close,callback方式,预计无异常,错误码为undefined
* @tc.desc Function test`
*/
it('Telephony_NetStack_TCPTest0500', 0, function(done){
let tcp = netSocket.constructTCPSocketInstance()
tcp.close(function(err,data){
expect(err !== undefined).assertTrue()
done()
})
done()
});
/**
* @tc.number Telephony_NetStack_TCPTest0600
* @tc.name TCP close,promise方式,预计无异常,错误码为undefined
* @tc.desc Function test`
*/
it('Telephony_NetStack_TCPTest0600', 0, function(done){
let tcp = netSocket.constructTCPSocketInstance()
tcp.close().then(function(data){
expect(data !== undefined).assertTrue()
done()
})
done()
});
/**
* @tc.number Telephony_NetStack_TCPTest0700
* @tc.name TCP getState,callback方式,预计无异常,错误码为undefined
* @tc.desc Function test`
*/
it('Telephony_NetStack_TCPTest0700', 0, function(done){
let tcp = netSocket.constructTCPSocketInstance()
tcp.getState(function(err,data){
expect(err !== undefined).assertTrue()
done()
})
done()
});
/**
* @tc.number Telephony_NetStack_TCPTest0800
* @tc.name TCP getState,promise方式,预计无异常,错误码为undefined
* @tc.desc Function test`
*/
it('Telephony_NetStack_TCPTest0800', 0, function(done){
let tcp =netSocket.constructTCPSocketInstance()
tcp.getState().then(function(data){
expect(data !== undefined).assertTure()
done()
})
done()
});
/**
* @tc.number Telephony_NetStack_TCPTest0900
* @tc.name TCP setExtraOptions,callback方式,预计无异常,错误码为undefined
* @tc.desc Function test`
*/
it('Telephony_NetStack_TCPTest0900', 0, function(done){
let tcp = netSocket.constructTCPSocketInstance()
tcp.setExtraOptions({},function(err,data){
expect(err !==undefined).assertTure()
done()
})
done()
});
/**
* @tc.number Telephony_NetStack_TCPTest1000
* @tc.name TCP setExtraOptions,promise方式,预计无异常,错误码为undefined
* @tc.desc Function test`
*/
it('Telephony_NetStack_TCPTest1000', 0, function(done){
let tcp = netSocket.constructTCPSocketInstance()
tcp.setExtraOptions({},).then(function(date){
expect(date !== undefined).assertTrue()
done()
})
done()
});
/**
* @tc.number Telephony_NetStack_TCPTest1100
* @tc.name TCP on,预计callback不被调用
* @tc.desc Function test`
*/
it('Telephony_NetStack_TCPTest1100', 0, function(done){
let tcp = netSocket.constructTCPSocketInstance()
tcp.on('message',function(){
expect().assertFail()
done()
})
tcp.on('listening',function(){
expect().assertFail()
done()
})
tcp.on('close',function(){
expect().assertFail()
done()
})
tcp.on('error',function(){
expect().assertFail()
done()
})
done()
});
/**
* @tc.number Telephony_NetStack_TCPTest1100
* @tc.name TCP on,预计callback不被调用
* @tc.desc Function test`
*/
it('Telephony_NetStack_TCPTest1100', 0, function(done){
let tcp = netSocket.constructTCPSocketInstance()
tcp.on('message',function(){
expect().assertFail()
done()
})
tcp.on('listening',function(){
expect().assertFail()
done()
})
tcp.on('close',function(){
expect().assertFail()
done()
})
tcp.on('error',function(){
expect().assertFail()
done()
})
done()
});
/**
* @tc.number Telephony_NetStack_TCPTest1200
* @tc.name TCP off,预计callback不被调用
* @tc.desc Function test`
*/
it('Telephony_NetStack_TCPTest1200', 0, function(done){
let tcp = netSocket.constructTCPSocketInstance()
tcp.off('message',function(){
expect().assertFail()
done()
})
tcp.off('listening',function(){
expect().assertFail()
done()
})
tcp.off('close',function(){
expect().assertFail()
done()
})
tcp.off('error',function(){
expect().assertFail()
done()
})
done()
});
});
\ No newline at end of file
{
"string": [
{
"name": "app_name",
"value": "Sim Test"
},
{
"name": "mainability_description",
"value": "Sim Test - sim manager interface test"
}
]
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册