diff --git a/telephony/telephonyjstest/BUILD.gn b/telephony/telephonyjstest/BUILD.gn index ec73d6e22617ba9db396a3a22256d17a49a0c008..3f1521c0479686014afd4ccd8f68d091aa9b8c8a 100644 --- a/telephony/telephonyjstest/BUILD.gn +++ b/telephony/telephonyjstest/BUILD.gn @@ -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", diff --git a/telephony/telephonyjstest/netmanager_base/BUILD.gn b/telephony/telephonyjstest/netmanager_base/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..fc10a2bff911df047fe2f22f47c16c5cb9852aab --- /dev/null +++ b/telephony/telephonyjstest/netmanager_base/BUILD.gn @@ -0,0 +1,26 @@ +# 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", + ] + } +} diff --git a/telephony/telephonyjstest/netmanager_base/dns/BUILD.gn b/telephony/telephonyjstest/netmanager_base/dns/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..2dba821ee4bb85fed1612b796a7007779008b32c --- /dev/null +++ b/telephony/telephonyjstest/netmanager_base/dns/BUILD.gn @@ -0,0 +1,31 @@ +# 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" +} diff --git a/telephony/telephonyjstest/netmanager_base/dns/Test.json b/telephony/telephonyjstest/netmanager_base/dns/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..e0d8ef8a0d800fc4424af33024108fb8c29d134f --- /dev/null +++ b/telephony/telephonyjstest/netmanager_base/dns/Test.json @@ -0,0 +1,18 @@ +{ + "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 + } + ] +} diff --git a/telephony/telephonyjstest/netmanager_base/dns/entry/src/main/config.json b/telephony/telephonyjstest/netmanager_base/dns/entry/src/main/config.json new file mode 100644 index 0000000000000000000000000000000000000000..eda9132f4b2046246ae0b47cd522778f36c7d364 --- /dev/null +++ b/telephony/telephonyjstest/netmanager_base/dns/entry/src/main/config.json @@ -0,0 +1,107 @@ +{ + "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 diff --git a/telephony/telephonyjstest/netmanager_base/dns/entry/src/main/js/default/app.js b/telephony/telephonyjstest/netmanager_base/dns/entry/src/main/js/default/app.js new file mode 100644 index 0000000000000000000000000000000000000000..d61b8caa653cfb8b0cdceb353771c56284c50051 --- /dev/null +++ b/telephony/telephonyjstest/netmanager_base/dns/entry/src/main/js/default/app.js @@ -0,0 +1,23 @@ +/* + * 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'); + } +}; diff --git a/telephony/telephonyjstest/netmanager_base/dns/entry/src/main/js/default/i18n/en-US.json b/telephony/telephonyjstest/netmanager_base/dns/entry/src/main/js/default/i18n/en-US.json new file mode 100644 index 0000000000000000000000000000000000000000..55561b83737c3c31d082fbfa11e5fc987a351104 --- /dev/null +++ b/telephony/telephonyjstest/netmanager_base/dns/entry/src/main/js/default/i18n/en-US.json @@ -0,0 +1,8 @@ +{ + "strings": { + "hello": "Hello", + "world": "World" + }, + "Files": { + } +} \ No newline at end of file diff --git a/telephony/telephonyjstest/netmanager_base/dns/entry/src/main/js/default/i18n/zh-CN.json b/telephony/telephonyjstest/netmanager_base/dns/entry/src/main/js/default/i18n/zh-CN.json new file mode 100644 index 0000000000000000000000000000000000000000..cce1af06761a42add0cac1a0567aa3237eda8cb4 --- /dev/null +++ b/telephony/telephonyjstest/netmanager_base/dns/entry/src/main/js/default/i18n/zh-CN.json @@ -0,0 +1,8 @@ +{ + "strings": { + "hello": "您好", + "world": "世界" + }, + "Files": { + } +} \ No newline at end of file diff --git a/telephony/telephonyjstest/netmanager_base/dns/entry/src/main/js/default/pages/index/index.css b/telephony/telephonyjstest/netmanager_base/dns/entry/src/main/js/default/pages/index/index.css new file mode 100644 index 0000000000000000000000000000000000000000..6fda792753f2e15f22b529c7b90a82185b2770bf --- /dev/null +++ b/telephony/telephonyjstest/netmanager_base/dns/entry/src/main/js/default/pages/index/index.css @@ -0,0 +1,9 @@ +.container { + flex-direction: column; + justify-content: center; + align-items: center; +} + +.title { + font-size: 100px; +} diff --git a/telephony/telephonyjstest/netmanager_base/dns/entry/src/main/js/default/pages/index/index.hml b/telephony/telephonyjstest/netmanager_base/dns/entry/src/main/js/default/pages/index/index.hml new file mode 100644 index 0000000000000000000000000000000000000000..1761ec52614d15e232d2e5ba45299eff2b1179f9 --- /dev/null +++ b/telephony/telephonyjstest/netmanager_base/dns/entry/src/main/js/default/pages/index/index.hml @@ -0,0 +1,5 @@ +
+ + SIM TEST + +
diff --git a/telephony/telephonyjstest/netmanager_base/dns/entry/src/main/js/default/pages/index/index.js b/telephony/telephonyjstest/netmanager_base/dns/entry/src/main/js/default/pages/index/index.js new file mode 100644 index 0000000000000000000000000000000000000000..9c3a39b84c5e2f2e6aad998b78c81367954094ba --- /dev/null +++ b/telephony/telephonyjstest/netmanager_base/dns/entry/src/main/js/default/pages/index/index.js @@ -0,0 +1,50 @@ +/* + * 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 diff --git a/telephony/telephonyjstest/netmanager_base/dns/entry/src/main/js/resources/base/element/string.json b/telephony/telephonyjstest/netmanager_base/dns/entry/src/main/js/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..4a597eff5e394f532d992554bc080451926e8275 --- /dev/null +++ b/telephony/telephonyjstest/netmanager_base/dns/entry/src/main/js/resources/base/element/string.json @@ -0,0 +1,12 @@ +{ + "string": [ + { + "name": "app_name", + "value": "Sim Test" + }, + { + "name": "mainability_description", + "value": "Sim Test - sim manager interface test" + } + ] +} \ No newline at end of file diff --git a/telephony/telephonyjstest/netmanager_base/dns/entry/src/main/js/resources/base/media/icon.png b/telephony/telephonyjstest/netmanager_base/dns/entry/src/main/js/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/telephony/telephonyjstest/netmanager_base/dns/entry/src/main/js/resources/base/media/icon.png differ diff --git a/telephony/telephonyjstest/netmanager_base/dns/entry/src/main/js/test/List.test.js b/telephony/telephonyjstest/netmanager_base/dns/entry/src/main/js/test/List.test.js new file mode 100644 index 0000000000000000000000000000000000000000..d1ece5bac86b842a2eb69e37df3ed088b08dd6fc --- /dev/null +++ b/telephony/telephonyjstest/netmanager_base/dns/entry/src/main/js/test/List.test.js @@ -0,0 +1,17 @@ +/** + * 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 diff --git a/telephony/telephonyjstest/netmanager_base/dns/entry/src/main/js/test/NetworkManagerDNS.test.js b/telephony/telephonyjstest/netmanager_base/dns/entry/src/main/js/test/NetworkManagerDNS.test.js new file mode 100644 index 0000000000000000000000000000000000000000..25c3a2deb7b6041e2ddae939943df55f73d7d997 --- /dev/null +++ b/telephony/telephonyjstest/netmanager_base/dns/entry/src/main/js/test/NetworkManagerDNS.test.js @@ -0,0 +1,149 @@ +/** + * 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 diff --git a/telephony/telephonyjstest/netmanager_base/dns/entry/src/main/resources/base/element/string.json b/telephony/telephonyjstest/netmanager_base/dns/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..4a597eff5e394f532d992554bc080451926e8275 --- /dev/null +++ b/telephony/telephonyjstest/netmanager_base/dns/entry/src/main/resources/base/element/string.json @@ -0,0 +1,12 @@ +{ + "string": [ + { + "name": "app_name", + "value": "Sim Test" + }, + { + "name": "mainability_description", + "value": "Sim Test - sim manager interface test" + } + ] +} \ No newline at end of file diff --git a/telephony/telephonyjstest/netmanager_base/dns/entry/src/main/resources/base/media/icon.png b/telephony/telephonyjstest/netmanager_base/dns/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/telephony/telephonyjstest/netmanager_base/dns/entry/src/main/resources/base/media/icon.png differ diff --git a/telephony/telephonyjstest/netmanager_base/dns/signature/openharmony_sx.p7b b/telephony/telephonyjstest/netmanager_base/dns/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..66b4457a8a81fb8d3356cf46d67226c850944858 Binary files /dev/null and b/telephony/telephonyjstest/netmanager_base/dns/signature/openharmony_sx.p7b differ diff --git a/telephony/telephonyjstest/netmanager_base/jshttp/BUILD.gn b/telephony/telephonyjstest/netmanager_base/jshttp/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..037a22441fd53f15dbe098ea13cb2540b167532f --- /dev/null +++ b/telephony/telephonyjstest/netmanager_base/jshttp/BUILD.gn @@ -0,0 +1,31 @@ +# 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" +} diff --git a/telephony/telephonyjstest/netmanager_base/jshttp/Test.json b/telephony/telephonyjstest/netmanager_base/jshttp/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..c09c93e8521456fd8678f2a3d90bf070c5bf2b50 --- /dev/null +++ b/telephony/telephonyjstest/netmanager_base/jshttp/Test.json @@ -0,0 +1,18 @@ +{ + "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 + } + ] +} diff --git a/telephony/telephonyjstest/netmanager_base/jshttp/entry/src/main/config.json b/telephony/telephonyjstest/netmanager_base/jshttp/entry/src/main/config.json new file mode 100644 index 0000000000000000000000000000000000000000..c8b53fb73d0b74a47a98bf7e39feeea461e7b96a --- /dev/null +++ b/telephony/telephonyjstest/netmanager_base/jshttp/entry/src/main/config.json @@ -0,0 +1,107 @@ +{ + "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 diff --git a/telephony/telephonyjstest/netmanager_base/jshttp/entry/src/main/js/default/app.js b/telephony/telephonyjstest/netmanager_base/jshttp/entry/src/main/js/default/app.js new file mode 100644 index 0000000000000000000000000000000000000000..d61b8caa653cfb8b0cdceb353771c56284c50051 --- /dev/null +++ b/telephony/telephonyjstest/netmanager_base/jshttp/entry/src/main/js/default/app.js @@ -0,0 +1,23 @@ +/* + * 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'); + } +}; diff --git a/telephony/telephonyjstest/netmanager_base/jshttp/entry/src/main/js/default/i18n/en-US.json b/telephony/telephonyjstest/netmanager_base/jshttp/entry/src/main/js/default/i18n/en-US.json new file mode 100644 index 0000000000000000000000000000000000000000..55561b83737c3c31d082fbfa11e5fc987a351104 --- /dev/null +++ b/telephony/telephonyjstest/netmanager_base/jshttp/entry/src/main/js/default/i18n/en-US.json @@ -0,0 +1,8 @@ +{ + "strings": { + "hello": "Hello", + "world": "World" + }, + "Files": { + } +} \ No newline at end of file diff --git a/telephony/telephonyjstest/netmanager_base/jshttp/entry/src/main/js/default/i18n/zh-CN.json b/telephony/telephonyjstest/netmanager_base/jshttp/entry/src/main/js/default/i18n/zh-CN.json new file mode 100644 index 0000000000000000000000000000000000000000..cce1af06761a42add0cac1a0567aa3237eda8cb4 --- /dev/null +++ b/telephony/telephonyjstest/netmanager_base/jshttp/entry/src/main/js/default/i18n/zh-CN.json @@ -0,0 +1,8 @@ +{ + "strings": { + "hello": "您好", + "world": "世界" + }, + "Files": { + } +} \ No newline at end of file diff --git a/telephony/telephonyjstest/netmanager_base/jshttp/entry/src/main/js/default/pages/index/index.css b/telephony/telephonyjstest/netmanager_base/jshttp/entry/src/main/js/default/pages/index/index.css new file mode 100644 index 0000000000000000000000000000000000000000..6fda792753f2e15f22b529c7b90a82185b2770bf --- /dev/null +++ b/telephony/telephonyjstest/netmanager_base/jshttp/entry/src/main/js/default/pages/index/index.css @@ -0,0 +1,9 @@ +.container { + flex-direction: column; + justify-content: center; + align-items: center; +} + +.title { + font-size: 100px; +} diff --git a/telephony/telephonyjstest/netmanager_base/jshttp/entry/src/main/js/default/pages/index/index.hml b/telephony/telephonyjstest/netmanager_base/jshttp/entry/src/main/js/default/pages/index/index.hml new file mode 100644 index 0000000000000000000000000000000000000000..1761ec52614d15e232d2e5ba45299eff2b1179f9 --- /dev/null +++ b/telephony/telephonyjstest/netmanager_base/jshttp/entry/src/main/js/default/pages/index/index.hml @@ -0,0 +1,5 @@ +
+ + SIM TEST + +
diff --git a/telephony/telephonyjstest/netmanager_base/jshttp/entry/src/main/js/default/pages/index/index.js b/telephony/telephonyjstest/netmanager_base/jshttp/entry/src/main/js/default/pages/index/index.js new file mode 100644 index 0000000000000000000000000000000000000000..9c3a39b84c5e2f2e6aad998b78c81367954094ba --- /dev/null +++ b/telephony/telephonyjstest/netmanager_base/jshttp/entry/src/main/js/default/pages/index/index.js @@ -0,0 +1,50 @@ +/* + * 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 diff --git a/telephony/telephonyjstest/netmanager_base/jshttp/entry/src/main/js/resources/base/element/string.json b/telephony/telephonyjstest/netmanager_base/jshttp/entry/src/main/js/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..4a597eff5e394f532d992554bc080451926e8275 --- /dev/null +++ b/telephony/telephonyjstest/netmanager_base/jshttp/entry/src/main/js/resources/base/element/string.json @@ -0,0 +1,12 @@ +{ + "string": [ + { + "name": "app_name", + "value": "Sim Test" + }, + { + "name": "mainability_description", + "value": "Sim Test - sim manager interface test" + } + ] +} \ No newline at end of file diff --git a/telephony/telephonyjstest/netmanager_base/jshttp/entry/src/main/js/resources/base/media/icon.png b/telephony/telephonyjstest/netmanager_base/jshttp/entry/src/main/js/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/telephony/telephonyjstest/netmanager_base/jshttp/entry/src/main/js/resources/base/media/icon.png differ diff --git a/telephony/telephonyjstest/netmanager_base/jshttp/entry/src/main/js/test/List.test.js b/telephony/telephonyjstest/netmanager_base/jshttp/entry/src/main/js/test/List.test.js new file mode 100644 index 0000000000000000000000000000000000000000..bd92f95b7150c154f4bec6fe2e9cb31aba9015b1 --- /dev/null +++ b/telephony/telephonyjstest/netmanager_base/jshttp/entry/src/main/js/test/List.test.js @@ -0,0 +1,18 @@ +/** + * 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'); diff --git a/telephony/telephonyjstest/netmanager_base/jshttp/entry/src/main/js/test/NetworkManagerHttp.test.js b/telephony/telephonyjstest/netmanager_base/jshttp/entry/src/main/js/test/NetworkManagerHttp.test.js new file mode 100644 index 0000000000000000000000000000000000000000..43c4bb2efbf7db806a9297e26e2a2b3d8129e1bb --- /dev/null +++ b/telephony/telephonyjstest/netmanager_base/jshttp/entry/src/main/js/test/NetworkManagerHttp.test.js @@ -0,0 +1,139 @@ +/** + * 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(); + }) + }); +}); diff --git a/telephony/telephonyjstest/netmanager_base/jshttp/entry/src/main/resources/base/element/string.json b/telephony/telephonyjstest/netmanager_base/jshttp/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..4a597eff5e394f532d992554bc080451926e8275 --- /dev/null +++ b/telephony/telephonyjstest/netmanager_base/jshttp/entry/src/main/resources/base/element/string.json @@ -0,0 +1,12 @@ +{ + "string": [ + { + "name": "app_name", + "value": "Sim Test" + }, + { + "name": "mainability_description", + "value": "Sim Test - sim manager interface test" + } + ] +} \ No newline at end of file diff --git a/telephony/telephonyjstest/netmanager_base/jshttp/entry/src/main/resources/base/media/icon.png b/telephony/telephonyjstest/netmanager_base/jshttp/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/telephony/telephonyjstest/netmanager_base/jshttp/entry/src/main/resources/base/media/icon.png differ diff --git a/telephony/telephonyjstest/netmanager_base/jshttp/signature/openharmony_sx.p7b b/telephony/telephonyjstest/netmanager_base/jshttp/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..66b4457a8a81fb8d3356cf46d67226c850944858 Binary files /dev/null and b/telephony/telephonyjstest/netmanager_base/jshttp/signature/openharmony_sx.p7b differ diff --git a/telephony/telephonyjstest/netmanager_base/register/BUILD.gn b/telephony/telephonyjstest/netmanager_base/register/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..91ba75105658c72fc4a749f45bd57cf4392c9189 --- /dev/null +++ b/telephony/telephonyjstest/netmanager_base/register/BUILD.gn @@ -0,0 +1,31 @@ +# 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" +} diff --git a/telephony/telephonyjstest/netmanager_base/register/Test.json b/telephony/telephonyjstest/netmanager_base/register/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..20d624219d021e5aa8669646d856832ce811f45c --- /dev/null +++ b/telephony/telephonyjstest/netmanager_base/register/Test.json @@ -0,0 +1,18 @@ +{ + "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 + } + ] +} diff --git a/telephony/telephonyjstest/netmanager_base/register/entry/src/main/config.json b/telephony/telephonyjstest/netmanager_base/register/entry/src/main/config.json new file mode 100644 index 0000000000000000000000000000000000000000..28f3af21fffc3fda3dcc068ba8ad874305fb6aa6 --- /dev/null +++ b/telephony/telephonyjstest/netmanager_base/register/entry/src/main/config.json @@ -0,0 +1,107 @@ +{ + "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 diff --git a/telephony/telephonyjstest/netmanager_base/register/entry/src/main/js/default/app.js b/telephony/telephonyjstest/netmanager_base/register/entry/src/main/js/default/app.js new file mode 100644 index 0000000000000000000000000000000000000000..d61b8caa653cfb8b0cdceb353771c56284c50051 --- /dev/null +++ b/telephony/telephonyjstest/netmanager_base/register/entry/src/main/js/default/app.js @@ -0,0 +1,23 @@ +/* + * 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'); + } +}; diff --git a/telephony/telephonyjstest/netmanager_base/register/entry/src/main/js/default/i18n/en-US.json b/telephony/telephonyjstest/netmanager_base/register/entry/src/main/js/default/i18n/en-US.json new file mode 100644 index 0000000000000000000000000000000000000000..55561b83737c3c31d082fbfa11e5fc987a351104 --- /dev/null +++ b/telephony/telephonyjstest/netmanager_base/register/entry/src/main/js/default/i18n/en-US.json @@ -0,0 +1,8 @@ +{ + "strings": { + "hello": "Hello", + "world": "World" + }, + "Files": { + } +} \ No newline at end of file diff --git a/telephony/telephonyjstest/netmanager_base/register/entry/src/main/js/default/i18n/zh-CN.json b/telephony/telephonyjstest/netmanager_base/register/entry/src/main/js/default/i18n/zh-CN.json new file mode 100644 index 0000000000000000000000000000000000000000..cce1af06761a42add0cac1a0567aa3237eda8cb4 --- /dev/null +++ b/telephony/telephonyjstest/netmanager_base/register/entry/src/main/js/default/i18n/zh-CN.json @@ -0,0 +1,8 @@ +{ + "strings": { + "hello": "您好", + "world": "世界" + }, + "Files": { + } +} \ No newline at end of file diff --git a/telephony/telephonyjstest/netmanager_base/register/entry/src/main/js/default/pages/index/index.css b/telephony/telephonyjstest/netmanager_base/register/entry/src/main/js/default/pages/index/index.css new file mode 100644 index 0000000000000000000000000000000000000000..6fda792753f2e15f22b529c7b90a82185b2770bf --- /dev/null +++ b/telephony/telephonyjstest/netmanager_base/register/entry/src/main/js/default/pages/index/index.css @@ -0,0 +1,9 @@ +.container { + flex-direction: column; + justify-content: center; + align-items: center; +} + +.title { + font-size: 100px; +} diff --git a/telephony/telephonyjstest/netmanager_base/register/entry/src/main/js/default/pages/index/index.hml b/telephony/telephonyjstest/netmanager_base/register/entry/src/main/js/default/pages/index/index.hml new file mode 100644 index 0000000000000000000000000000000000000000..1761ec52614d15e232d2e5ba45299eff2b1179f9 --- /dev/null +++ b/telephony/telephonyjstest/netmanager_base/register/entry/src/main/js/default/pages/index/index.hml @@ -0,0 +1,5 @@ +
+ + SIM TEST + +
diff --git a/telephony/telephonyjstest/netmanager_base/register/entry/src/main/js/default/pages/index/index.js b/telephony/telephonyjstest/netmanager_base/register/entry/src/main/js/default/pages/index/index.js new file mode 100644 index 0000000000000000000000000000000000000000..b9a9ded45169f5efaba2f0c8bcfd42e63de37b89 --- /dev/null +++ b/telephony/telephonyjstest/netmanager_base/register/entry/src/main/js/default/pages/index/index.js @@ -0,0 +1,50 @@ +/* + * 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 diff --git a/telephony/telephonyjstest/netmanager_base/register/entry/src/main/js/default/test/List.test.js b/telephony/telephonyjstest/netmanager_base/register/entry/src/main/js/default/test/List.test.js new file mode 100644 index 0000000000000000000000000000000000000000..896449e39e7aa7e130022b05534d7a11a549a962 --- /dev/null +++ b/telephony/telephonyjstest/netmanager_base/register/entry/src/main/js/default/test/List.test.js @@ -0,0 +1,17 @@ +/** + * 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 diff --git a/telephony/telephonyjstest/netmanager_base/register/entry/src/main/js/default/test/NetworkManagerRegister.test.js b/telephony/telephonyjstest/netmanager_base/register/entry/src/main/js/default/test/NetworkManagerRegister.test.js new file mode 100644 index 0000000000000000000000000000000000000000..baa67913f0af46fe75f903234c8dfa8faabfd94b --- /dev/null +++ b/telephony/telephonyjstest/netmanager_base/register/entry/src/main/js/default/test/NetworkManagerRegister.test.js @@ -0,0 +1,2509 @@ +/** + * 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 diff --git a/telephony/telephonyjstest/netmanager_base/register/entry/src/main/js/resources/base/element/string.json b/telephony/telephonyjstest/netmanager_base/register/entry/src/main/js/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..4a597eff5e394f532d992554bc080451926e8275 --- /dev/null +++ b/telephony/telephonyjstest/netmanager_base/register/entry/src/main/js/resources/base/element/string.json @@ -0,0 +1,12 @@ +{ + "string": [ + { + "name": "app_name", + "value": "Sim Test" + }, + { + "name": "mainability_description", + "value": "Sim Test - sim manager interface test" + } + ] +} \ No newline at end of file diff --git a/telephony/telephonyjstest/netmanager_base/register/entry/src/main/js/resources/base/media/icon.png b/telephony/telephonyjstest/netmanager_base/register/entry/src/main/js/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/telephony/telephonyjstest/netmanager_base/register/entry/src/main/js/resources/base/media/icon.png differ diff --git a/telephony/telephonyjstest/netmanager_base/register/entry/src/main/js/test/List.test.js b/telephony/telephonyjstest/netmanager_base/register/entry/src/main/js/test/List.test.js new file mode 100644 index 0000000000000000000000000000000000000000..896449e39e7aa7e130022b05534d7a11a549a962 --- /dev/null +++ b/telephony/telephonyjstest/netmanager_base/register/entry/src/main/js/test/List.test.js @@ -0,0 +1,17 @@ +/** + * 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 diff --git a/telephony/telephonyjstest/netmanager_base/register/entry/src/main/js/test/NetworkManagerRegister.test.js b/telephony/telephonyjstest/netmanager_base/register/entry/src/main/js/test/NetworkManagerRegister.test.js new file mode 100644 index 0000000000000000000000000000000000000000..1e4f84680c4841794adad0c345d1d9bb4c23085e --- /dev/null +++ b/telephony/telephonyjstest/netmanager_base/register/entry/src/main/js/test/NetworkManagerRegister.test.js @@ -0,0 +1,2509 @@ +/** + * 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 diff --git a/telephony/telephonyjstest/netmanager_base/register/entry/src/main/resources/base/element/string.json b/telephony/telephonyjstest/netmanager_base/register/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..4a597eff5e394f532d992554bc080451926e8275 --- /dev/null +++ b/telephony/telephonyjstest/netmanager_base/register/entry/src/main/resources/base/element/string.json @@ -0,0 +1,12 @@ +{ + "string": [ + { + "name": "app_name", + "value": "Sim Test" + }, + { + "name": "mainability_description", + "value": "Sim Test - sim manager interface test" + } + ] +} \ No newline at end of file diff --git a/telephony/telephonyjstest/netmanager_base/register/entry/src/main/resources/base/media/icon.png b/telephony/telephonyjstest/netmanager_base/register/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/telephony/telephonyjstest/netmanager_base/register/entry/src/main/resources/base/media/icon.png differ diff --git a/telephony/telephonyjstest/netmanager_base/register/signature/openharmony_sx.p7b b/telephony/telephonyjstest/netmanager_base/register/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..66b4457a8a81fb8d3356cf46d67226c850944858 Binary files /dev/null and b/telephony/telephonyjstest/netmanager_base/register/signature/openharmony_sx.p7b differ diff --git a/telephony/telephonyjstest/netmanager_base/socket/BUILD.gn b/telephony/telephonyjstest/netmanager_base/socket/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..a05010f9d3056577a079ee3ef0d3a9e5568d0441 --- /dev/null +++ b/telephony/telephonyjstest/netmanager_base/socket/BUILD.gn @@ -0,0 +1,31 @@ +# 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" +} diff --git a/telephony/telephonyjstest/netmanager_base/socket/Test.json b/telephony/telephonyjstest/netmanager_base/socket/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..e4001e83ed87074801312ae381d8204d5694416e --- /dev/null +++ b/telephony/telephonyjstest/netmanager_base/socket/Test.json @@ -0,0 +1,18 @@ +{ + "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 + } + ] +} diff --git a/telephony/telephonyjstest/netmanager_base/socket/entry/src/main/config.json b/telephony/telephonyjstest/netmanager_base/socket/entry/src/main/config.json new file mode 100644 index 0000000000000000000000000000000000000000..ac65907ca70bfb994bd8c9f3f7281b73f0cf5a94 --- /dev/null +++ b/telephony/telephonyjstest/netmanager_base/socket/entry/src/main/config.json @@ -0,0 +1,107 @@ +{ + "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 diff --git a/telephony/telephonyjstest/netmanager_base/socket/entry/src/main/js/default/app.js b/telephony/telephonyjstest/netmanager_base/socket/entry/src/main/js/default/app.js new file mode 100644 index 0000000000000000000000000000000000000000..d61b8caa653cfb8b0cdceb353771c56284c50051 --- /dev/null +++ b/telephony/telephonyjstest/netmanager_base/socket/entry/src/main/js/default/app.js @@ -0,0 +1,23 @@ +/* + * 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'); + } +}; diff --git a/telephony/telephonyjstest/netmanager_base/socket/entry/src/main/js/default/i18n/en-US.json b/telephony/telephonyjstest/netmanager_base/socket/entry/src/main/js/default/i18n/en-US.json new file mode 100644 index 0000000000000000000000000000000000000000..55561b83737c3c31d082fbfa11e5fc987a351104 --- /dev/null +++ b/telephony/telephonyjstest/netmanager_base/socket/entry/src/main/js/default/i18n/en-US.json @@ -0,0 +1,8 @@ +{ + "strings": { + "hello": "Hello", + "world": "World" + }, + "Files": { + } +} \ No newline at end of file diff --git a/telephony/telephonyjstest/netmanager_base/socket/entry/src/main/js/default/i18n/zh-CN.json b/telephony/telephonyjstest/netmanager_base/socket/entry/src/main/js/default/i18n/zh-CN.json new file mode 100644 index 0000000000000000000000000000000000000000..cce1af06761a42add0cac1a0567aa3237eda8cb4 --- /dev/null +++ b/telephony/telephonyjstest/netmanager_base/socket/entry/src/main/js/default/i18n/zh-CN.json @@ -0,0 +1,8 @@ +{ + "strings": { + "hello": "您好", + "world": "世界" + }, + "Files": { + } +} \ No newline at end of file diff --git a/telephony/telephonyjstest/netmanager_base/socket/entry/src/main/js/default/pages/index/index.css b/telephony/telephonyjstest/netmanager_base/socket/entry/src/main/js/default/pages/index/index.css new file mode 100644 index 0000000000000000000000000000000000000000..6fda792753f2e15f22b529c7b90a82185b2770bf --- /dev/null +++ b/telephony/telephonyjstest/netmanager_base/socket/entry/src/main/js/default/pages/index/index.css @@ -0,0 +1,9 @@ +.container { + flex-direction: column; + justify-content: center; + align-items: center; +} + +.title { + font-size: 100px; +} diff --git a/telephony/telephonyjstest/netmanager_base/socket/entry/src/main/js/default/pages/index/index.hml b/telephony/telephonyjstest/netmanager_base/socket/entry/src/main/js/default/pages/index/index.hml new file mode 100644 index 0000000000000000000000000000000000000000..1761ec52614d15e232d2e5ba45299eff2b1179f9 --- /dev/null +++ b/telephony/telephonyjstest/netmanager_base/socket/entry/src/main/js/default/pages/index/index.hml @@ -0,0 +1,5 @@ +
+ + SIM TEST + +
diff --git a/telephony/telephonyjstest/netmanager_base/socket/entry/src/main/js/default/pages/index/index.js b/telephony/telephonyjstest/netmanager_base/socket/entry/src/main/js/default/pages/index/index.js new file mode 100644 index 0000000000000000000000000000000000000000..9c3a39b84c5e2f2e6aad998b78c81367954094ba --- /dev/null +++ b/telephony/telephonyjstest/netmanager_base/socket/entry/src/main/js/default/pages/index/index.js @@ -0,0 +1,50 @@ +/* + * 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 diff --git a/telephony/telephonyjstest/netmanager_base/socket/entry/src/main/js/resources/base/element/string.json b/telephony/telephonyjstest/netmanager_base/socket/entry/src/main/js/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..4a597eff5e394f532d992554bc080451926e8275 --- /dev/null +++ b/telephony/telephonyjstest/netmanager_base/socket/entry/src/main/js/resources/base/element/string.json @@ -0,0 +1,12 @@ +{ + "string": [ + { + "name": "app_name", + "value": "Sim Test" + }, + { + "name": "mainability_description", + "value": "Sim Test - sim manager interface test" + } + ] +} \ No newline at end of file diff --git a/telephony/telephonyjstest/netmanager_base/socket/entry/src/main/js/resources/base/media/icon.png b/telephony/telephonyjstest/netmanager_base/socket/entry/src/main/js/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/telephony/telephonyjstest/netmanager_base/socket/entry/src/main/js/resources/base/media/icon.png differ diff --git a/telephony/telephonyjstest/netmanager_base/socket/entry/src/main/js/test/List.test.js b/telephony/telephonyjstest/netmanager_base/socket/entry/src/main/js/test/List.test.js new file mode 100644 index 0000000000000000000000000000000000000000..61765d85f5e517b6ed58a2d230bd8251bdacd36c --- /dev/null +++ b/telephony/telephonyjstest/netmanager_base/socket/entry/src/main/js/test/List.test.js @@ -0,0 +1,17 @@ +/** + * 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 diff --git a/telephony/telephonyjstest/netmanager_base/socket/entry/src/main/js/test/NetStackSocket.test.js b/telephony/telephonyjstest/netmanager_base/socket/entry/src/main/js/test/NetStackSocket.test.js new file mode 100644 index 0000000000000000000000000000000000000000..45179e69c066c3e8c5f66d69a29f684484111272 --- /dev/null +++ b/telephony/telephonyjstest/netmanager_base/socket/entry/src/main/js/test/NetStackSocket.test.js @@ -0,0 +1,522 @@ +/** + * 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 diff --git a/telephony/telephonyjstest/netmanager_base/socket/entry/src/main/resources/base/element/string.json b/telephony/telephonyjstest/netmanager_base/socket/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..4a597eff5e394f532d992554bc080451926e8275 --- /dev/null +++ b/telephony/telephonyjstest/netmanager_base/socket/entry/src/main/resources/base/element/string.json @@ -0,0 +1,12 @@ +{ + "string": [ + { + "name": "app_name", + "value": "Sim Test" + }, + { + "name": "mainability_description", + "value": "Sim Test - sim manager interface test" + } + ] +} \ No newline at end of file diff --git a/telephony/telephonyjstest/netmanager_base/socket/entry/src/main/resources/base/media/icon.png b/telephony/telephonyjstest/netmanager_base/socket/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/telephony/telephonyjstest/netmanager_base/socket/entry/src/main/resources/base/media/icon.png differ diff --git a/telephony/telephonyjstest/netmanager_base/socket/signature/openharmony_sx.p7b b/telephony/telephonyjstest/netmanager_base/socket/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..66b4457a8a81fb8d3356cf46d67226c850944858 Binary files /dev/null and b/telephony/telephonyjstest/netmanager_base/socket/signature/openharmony_sx.p7b differ