提交 5b12b339 编写于 作者: Q q00313334

quanli1@huawei.com

Signed-off-by: Nq00313334 <quanli1@huawei.com>
上级 99cea292
...@@ -17,10 +17,10 @@ group("communication") { ...@@ -17,10 +17,10 @@ group("communication") {
if (is_standard_system) { if (is_standard_system) {
deps = [ deps = [
"bluetooth_ble:ActsBluetoothBleJsTest", "bluetooth_ble:ActsBluetoothBleJsTest",
"bluetooth_hid:ActsBluetoothHidJsTest",
"bluetooth_on:ActsBluetoothOnJsTest", "bluetooth_on:ActsBluetoothOnJsTest",
"bluetooth_standard:ActsBluetoothJsTest", "bluetooth_standard:ActsBluetoothJsTest",
"dsoftbus/rpc:ActsRpcJsTest", "dsoftbus/rpc:ActsRpcJsTest",
"wifi_hotspot:ActsHotSpotJSTest",
"wifi_p2p:ActsP2PJSTest", "wifi_p2p:ActsP2PJSTest",
"wifi_standard:ActsWifiJSTest", "wifi_standard:ActsWifiJSTest",
] ]
......
# Copyright (C) 2022 Huawei Device Co., Ltd. # Copyright (C) 2021 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License"); # Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License. # you may not use this file except in compliance with the License.
# You may obtain a copy of the License at # You may obtain a copy of the License at
...@@ -12,20 +12,20 @@ ...@@ -12,20 +12,20 @@
# limitations under the License. # limitations under the License.
import("//test/xts/tools/build/suite.gni") import("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("ActsBluetoothHidJsTest") {
ohos_js_hap_suite("ActsHotSpotJSTest") {
hap_profile = "./src/main/config.json" hap_profile = "./src/main/config.json"
deps = [ deps = [
":wifi_js_assets", ":bluetooth_js_assets",
":wifi_resources", ":bluetooth_resources",
] ]
certificate_profile = "./signature/openharmony_sx.p7b" certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "ActsHotSpotJSApiTest" hap_name = "ActsBluetoothHidHapTest"
} }
ohos_js_assets("wifi_js_assets") { ohos_js_assets("bluetooth_js_assets") {
source_dir = "./src/main/js/default" source_dir = "./src/main/js/default"
} }
ohos_resources("wifi_resources") { ohos_resources("bluetooth_resources") {
sources = [ "./src/main/resources" ] sources = [ "./src/main/resources" ]
hap_profile = "./src/main/config.json" hap_profile = "./src/main/config.json"
} }
{ {
"description": "Configuration for wifi js api Tests", "description": "Configuration for bluetooth js api Tests",
"driver": { "driver": {
"type": "JSUnitTest", "type": "JSUnitTest",
"test-timeout": "600000", "test-timeout": "600000",
"package": "ohos.acts.communication.wifi.wifidevice", "package": "ohos.acts.communication.bluetooth.bluetoothhost",
"shell-timeout": "600000" "shell-timeout": "60000"
}, },
"kits": [ "kits": [
{ {
"test-file-name": [ "test-file-name": [
"ActsHotSpotJSApiTest.hap" "ActsBluetoothHidHapTest.hap"
], ],
"type": "AppInstallKit", "type": "AppInstallKit",
"cleanup-apps": true "cleanup-apps": true
......
{ {
"app": { "app": {
"bundleName": "ohos.acts.communication.wifi.wifidevice", "bundleName": "ohos.acts.communication.bluetooth.bluetoothhost",
"vendor": "acts", "vendor": "acts",
"version": { "version": {
"code": 1000000, "code": 1000000,
...@@ -13,15 +13,14 @@ ...@@ -13,15 +13,14 @@
}, },
"deviceConfig": {}, "deviceConfig": {},
"module": { "module": {
"package": "ohos.acts.communication.wifi.wifidevice", "package": "ohos.acts.communication.bluetooth.bluetoothhost",
"name": ".MyApplication", "name": ".MyApplication",
"mainAbility": "ohos.acts.communication.wifi.wifidevice.MainAbility",
"deviceType": [ "deviceType": [
"phone" "phone"
], ],
"distro": { "distro": {
"deliveryWithInstall": true, "deliveryWithInstall": true,
"moduleName": "wifi_standard", "moduleName": "entry",
"moduleType": "entry" "moduleType": "entry"
}, },
"abilities": [ "abilities": [
...@@ -37,7 +36,7 @@ ...@@ -37,7 +36,7 @@
] ]
} }
], ],
"name": "ohos.acts.communication.wifi.wifidevice.MainAbility", "name": "ohos.acts.communication.bluetooth.bluetoothhost.MainAbility",
"icon": "$media:icon", "icon": "$media:icon",
"description": "$string:mainability_description", "description": "$string:mainability_description",
"label": "$string:app_name", "label": "$string:app_name",
...@@ -59,41 +58,47 @@ ...@@ -59,41 +58,47 @@
], ],
"reqPermissions": [ "reqPermissions": [
{ {
"name" : "ohos.permission.GET_WIFI_INFO", "name": "ohos.permission.USE_BLUETOOTH",
"reason" : "use ohos.permission.GET_WIFI_INFO" "reason": "",
}, "usedScene": {
{ "ability": [
"name" : "ohos.permission.SET_WIFI_INFO", "ohos.acts.communication.bluetooth.bluetoothhost.MainAbility"
"reason" : "use ohos.permission.SET_WIFI_INFO" ],
}, "when": "inuse"
{ }
"name" : "ohos.permission.MANAGE_WIFI_CONNECTION",
"reason" : "use ohos.permission.MANAGE_WIFI_CONNECTION"
},
{
"name" : "ohos.permission.SET_WIFI_CONFIG",
"reason" : "use ohos.permission.SET_WIFI_CONFIG"
},
{
"name" : "ohos.permission.GET_WIFI_CONFIG",
"reason" : "use ohos.permission.GET_WIFI_CONFIG"
},
{
"name" : "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED",
"reason" : "use ohos.permission.GET_BUNDLE_INFO_PRIVILEGED"
}, },
{ {
"name" : "ohos.permission.GET_WIFI_LOCAL_MAC", "name": "ohos.permission.MANAGE_BLUETOOTH",
"reason" : "use ohos.permission.GET_WIFI_LOCAL_MAC" "reason": "",
"usedScene": {
"ability": [
"ohos.acts.communication.bluetooth.bluetoothhost.MainAbility"
],
"when": "inuse"
}
}, },
{ {
"name" : "ohos.permission.MANAGE_WIFI_HOTSPOT", "name": "ohos.permission.DISCOVER_BLUETOOTH",
"reason" : "use ohos.permission.MANAGE_WIFI_HOTSPOT" "reason": "",
"usedScene": {
"ability": [
"ohos.acts.communication.bluetooth.bluetoothhost.MainAbility"
],
"when": "inuse"
}
}, },
{ {
"name" : "ohos.permission.GET_WIFI_INFO_INTERNAL", "name": "ohos.permission.LOCATION",
"reason" : "use ohos.permission.GET_WIFI_INFO_INTERNAL" "reason": "",
"usedScene": {
"ability": [
"ohos.acts.communication.bluetooth.bluetoothhost.MainAbility"
],
"when": "inuse"
}
} }
] ]
} }
} }
/* /*
* Copyright (C) 2022 Huawei Device Co., Ltd. * Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
......
...@@ -13,7 +13,6 @@ ...@@ -13,7 +13,6 @@
* limitations under the License. * limitations under the License.
*/ */
.container { .container {
flex-direction: column; flex-direction: column;
justify-content: center; justify-content: center;
......
...@@ -13,7 +13,6 @@ ...@@ -13,7 +13,6 @@
* limitations under the License. * limitations under the License.
*/ */
<div class="container"> <div class="container">
<text class="title"> <text class="title">
{{ $t('strings.hello') }} {{ title }} {{ $t('strings.hello') }} {{ title }}
......
...@@ -14,13 +14,11 @@ ...@@ -14,13 +14,11 @@
*/ */
import {Core, ExpectExtend} from 'deccjsunit/index' import {Core, ExpectExtend} from 'deccjsunit/index'
export default { export default {
data: { data: {
title: '', title: ""
myTimeout: 25000
}, },
onInit() { onInit() {
this.title = this.$t('strings.world'); this.title = this.$t('strings.world');
...@@ -38,7 +36,6 @@ export default { ...@@ -38,7 +36,6 @@ export default {
core.init() core.init()
const configService = core.getDefaultService('config') const configService = core.getDefaultService('config')
this.timeout = this.myTimeout
configService.setConfig(this) configService.setConfig(this)
require('../../test/List.test') require('../../test/List.test')
......
/*
* Copyright (C) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import bluetooth from '@ohos.bluetooth';
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
let hidHostProfile = bluetooth.getProfile(6);
function on(ON_VALUE_TEST_ELEMENT) {
return new Promise((resolve, reject) => {
hidHostProfile.on(ON_VALUE_TEST_ELEMENT, function (err, data) {
if (err != undefined) {
reject(err);
} else {
resolve(data);
}
})
});
}
function off(OFF_VALUE_TEST_ELEMENT) {
return new Promise((resolve, reject) => {
hidHostProfile.off(OFF_VALUE_TEST_ELEMENT, function (err, data) {
if (err != undefined) {
reject(err);
} else {
resolve(data);
}
})
});
}
let ProfId = {
PROFILE_A2DP_SINK : 0,
PROFILE_A2DP_SOURCE : 1,
PROFILE_AVRCP_CT : 2,
PROFILE_AVRCP_TG : 3,
PROFILE_HANDS_FREE_AUDIO_GATEWAY : 4,
PROFILE_HANDS_FREE_UNIT : 5
}
describe('bluetoothhostTest', function () {
beforeAll(function () {
console.info('beforeAll called')
})
beforeEach(function () {
console.info('beforeEach called')
})
afterEach(function () {
console.info('afterEach called')
})
afterAll(function () {
console.info('afterAll called')
})
function sleep(delay) {
return new Promise(resovle => setTimeout(resovle, delay))
}
async function tryToEnableBt() {
let sta = bluetooth.getState();
switch(sta){
case 0:
console.info('[bluetooth_js] bt turn off:'+ JSON.stringify(sta));
bluetooth.enableBluetooth();
await sleep(3000);
break;
case 1:
console.info('[bluetooth_js] bt turning on:'+ JSON.stringify(sta));
await sleep(3000);
break;
case 2:
console.info('[bluetooth_js] bt turn on:'+ JSON.stringify(sta));
break;
case 3:
console.info('[bluetooth_js] bt turning off:'+ JSON.stringify(sta));
bluetooth.enableBluetooth();
await sleep(3000);
break;
default:
console.info('[bluetooth_js] enable success');
}
}
/**
* @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_GET_PROFILE_LOOP_0001
* @tc.name looptestgetprofile(set parameterless)
* @tc.desc Test getProfile api 1000 times.
* @tc.author defu.zheng
* @tc.size SMALL
* @tc.type Function
* @tc.level Level 0
*/
it('SUB_COMMUNACATION_bluetooth_DEVICE_JS_GET_PROFILE_LOOP_0001', 0, async function (done) {
console.info('[bluetooth_js] loop get profile start');
await tryToEnableBt();
let proFile = bluetooth.getProfile(6);
console.info('[bluetooth_js] loop get profile result:' + JSON.stringify(proFile));
expect(proFile != null).assertEqual(true);
done();
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_GET_CONN_DEV_LOOP_0001
* @tc.name looptestgetConnectionDevices(bluetooth mode is off)
* @tc.desc Test getConnectionDevices api 1000 times.
* @tc.author defu.zheng
* @tc.size SMALL
* @tc.type Function
* @tc.level Level 0
*/
it('SUB_COMMUNACATION_bluetooth_DEVICE_JS_GET_CONN_DEV_LOOP_0001', 0, async function (done) {
console.info('[bluetooth_js] loop get connection devices start');
await tryToEnableBt();
let arrDev = hidHostProfile.getConnectionDevices();
console.info('[bluetooth_js] loop getconndev:' + JSON.stringify(arrDev)+ 'length'+ arrDev.length);
expect(arrDev.length).assertEqual(0);
done();
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_GET_DEV_STATE_LOOP_0001
* @tc.name looptestgetDeviceState(set a null value)
* @tc.desc Test getDeviceState api 1000 times.
* @tc.author defu.zheng
* @tc.size SMALL
* @tc.type Function
* @tc.level Level 0
*/
it('SUB_COMMUNACATION_bluetooth_DEVICE_JS_GET_DEV_STATE_LOOP_0001', 0, async function (done) {
console.info('[bluetooth_js] loop get device state start');
await tryToEnableBt();
let devState = hidHostProfile.getDeviceState('');
console.info('[bluetooth_js] loop get device state result:' + JSON.stringify(devState));
expect(devState).assertEqual(3);
done();
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_HID_HOST_PROFILE_CONN_LOOP_0001
* @tc.name looptesthidhostprofileconnect(set a null value)
* @tc.desc Test hidHostProfile connect api 1000 times.
* @tc.author defu.zheng
* @tc.size SMALL
* @tc.type Function
* @tc.level Level 0
*/
it('SUB_COMMUNACATION_bluetooth_DEVICE_JS_HID_HOST_PROFILE_CONN_LOOP_0001', 0, async function (done) {
console.info('[bluetooth_js] loop HidHostProfile the connect start');
await tryToEnableBt();
let conn = hidHostProfile.connect('');
console.info('[bluetooth_js] loop HidHostProfile the connect result:' + JSON.stringify(conn));
expect(conn).assertFalse();
done();
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_HID_HOST_PROFILE_DISCONN_LOOP_0001
* @tc.name looptesthidhostprofiledisconnect(set a null value)
* @tc.desc Test hidHostProfile disconnect api 1000 times.
* @tc.author defu.zheng
* @tc.size SMALL
* @tc.type Function
* @tc.level Level 0
*/
it('SUB_COMMUNACATION_bluetooth_DEVICE_JS_HID_HOST_PROFILE_DISCONN_LOOP_0001', 0, async function (done) {
console.info('[bluetooth_js] loop HidHostProfile the disconnect start');
await tryToEnableBt();
let disConn = hidHostProfile.disconnect('');
console.info('[bluetooth_js] loop HidHostProfile the disconnect result:' + JSON.stringify(disConn));
expect(disConn).assertFalse();
done();
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_HID_HOST_PROFILE_ON_LOOP_0001
* @tc.name looptesthidhostprofileon
* @tc.desc Test hidHostProfile on api 1000 times.
* @tc.author defu.zheng
* @tc.size SMALL
* @tc.type Function
* @tc.level Level 0
*/
it('SUB_COMMUNACATION_bluetooth_DEVICE_JS_HID_HOST_PROFILE_ON_LOOP_0001', 0, async function (done) {
try {
await tryToEnableBt();
console.info('[bluetooth_js] loop HidHostProfile the on start');
on("connectionStateChange", function (data) {
console.info("[bluetooth_js] HidHostProfile_on data " + JSON.stringify(data));
expect(true).assertEqual(data !=null);
});
}catch(e) {
expect(null).assertFail();
}
try {
console.info('[bluetooth_js] HidHostProfile the off test start');
off("connectionStateChange", function (data) {
console.info("[bluetooth_js] HidHostProfile_off data-> " + JSON.stringify(data));
expect(true).assertEqual(data ==null);
});
}catch(e) {
expect(null).assertFail();
}
done();
})
})
/* /*
* Copyright (C) 2022 Huawei Device Co., Ltd. * Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
...@@ -12,7 +12,5 @@ ...@@ -12,7 +12,5 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
require('./WifiSoftAP.test.js')
require('./BluetoothHid.test.js')
...@@ -17,7 +17,8 @@ import {Core, ExpectExtend} from 'deccjsunit/index' ...@@ -17,7 +17,8 @@ import {Core, ExpectExtend} from 'deccjsunit/index'
export default { export default {
data: { data: {
title: "" title: "",
myTimeout:10000
}, },
onInit() { onInit() {
this.title = this.$t('strings.world'); this.title = this.$t('strings.world');
...@@ -35,6 +36,7 @@ export default { ...@@ -35,6 +36,7 @@ export default {
core.init() core.init()
const configService = core.getDefaultService('config') const configService = core.getDefaultService('config')
this.timeout = this.myTimeout
configService.setConfig(this) configService.setConfig(this)
require('../../test/List.test') require('../../test/List.test')
......
...@@ -166,20 +166,20 @@ describe('bluetoothhostTest', function() { ...@@ -166,20 +166,20 @@ describe('bluetoothhostTest', function() {
*/ */
it('SUB_COMMUNACATION_bluetooth_ENABLE_0001', 0, async function (done) { it('SUB_COMMUNACATION_bluetooth_ENABLE_0001', 0, async function (done) {
console.info('[bluetooth_js] enable start'); console.info('[bluetooth_js] enable start');
await bluetooth.on("stateChange", onReceiveEvent); bluetooth.on("stateChange", onReceiveEvent);
function onReceiveEvent(data) { function onReceiveEvent(data) {
if (data == bluetooth.BluetoothState.STATE_ON) { if (data == bluetooth.BluetoothState.STATE_ON) {
console.info('enable bluetooth'); console.info('enable bluetooth');
bluetooth.off('stateChange', result => {
expect(true).assertEqual(result ==null);
done(); done();
});
} }
} }
await tryToEnableBt(); await tryToEnableBt();
let state = bluetooth.getState(); let state = bluetooth.getState();
expect(state).assertEqual(2); expect(state).assertEqual(2);
await bluetooth.off('stateChange', result => {
expect(true).assertEqual(result ==null);
done(); done();
});
}) })
...@@ -192,54 +192,315 @@ describe('bluetoothhostTest', function() { ...@@ -192,54 +192,315 @@ describe('bluetoothhostTest', function() {
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('SUB_COMMUNACATION_bluetooth_START_BLUETOOTH_DISCOVERY_0001', 0, async function (done) { it('SUB_COMMUNACATION_bluetooth_START_BLUETOOTH_DISCOVERY_0001', 0, async function (done) {
console.info('[bluetooth_js] discovery start'); console.info('[bluetooth_js] discovery1 start');
await sleep(1000);
await tryToEnableBt(); await tryToEnableBt();
await bluetooth.on("bluetoothDeviceFind", onReceiveEvent) bluetooth.on("bluetoothDeviceFind", onReceiveEvent)
function onReceiveEvent(data) { function onReceiveEvent(data) {
console.info('[bluetooth_js] Device' + JSON.stringify(data)+ 'length' + data.length) console.info('[bluetooth_js] Device' + JSON.stringify(data)+ 'length' + data.length)
expect(data.length).assertLarger(0); expect(true).assertTrue(data.length >= 0);
bluetooth.off('bluetoothDeviceFind', result => {
console.info("[bluetooth_js] bluetoothDeviceFind off1:" + JSON.stringify(result));
expect(true).assertEqual(result ==null);
done(); done();
})
} }
await bluetooth.startBluetoothDiscovery(); bluetooth.startBluetoothDiscovery();
await bluetooth.off('bluetoothDeviceFind', result => { })
console.info("[bluetooth_js] bluetoothDeviceFind off:" + JSON.stringify(result));
/**
* @tc.number SUB_COMMUNACATION_bluetooth_START_BLESCAN_WITHOUT_PARAM_0001
* @tc.name testClassicStartBLEScan
* @tc.desc Test ClassicStartBLEScan api.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('SUB_COMMUNACATION_bluetooth_START_BLESCAN_WITHOUT_PARAM_0001', 0, async function (done) {
console.info('[bluetooth_js] BLE scan1 test start');
await sleep(1000);
await tryToEnableBt();
bluetooth.BLE.on("BLEDeviceFind", onReceiveEvent)
function onReceiveEvent(data) {
console.info('[bluetooth_js] BLE scan device find result1 = '+ JSON.stringify(data));
expect(true).assertTrue(data.length >= 0);
bluetooth.BLE.off('BLEDeviceFind', result => {
console.info("[bluetooth_js] BLE scan device find off1:" + JSON.stringify(result));
expect(true).assertEqual(result ==null); expect(true).assertEqual(result ==null);
let result1 = bluetooth.BLE.stopBLEScan();
console.info("[bluetooth_js] onStopBLEScan1 -> " + JSON.stringify(result1));
done(); done();
}); });
}
bluetooth.BLE.startBLEScan([{}]);
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_START_BLESCAN_WITHOUT_PARAM_0002
* @tc.name testClassicStartBLEScan
* @tc.desc Test ClassicStartBLEScan api.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('SUB_COMMUNACATION_bluetooth_START_BLESCAN_WITHOUT_PARAM_0002', 0, async function (done) {
console.info('[bluetooth_js] BLE scan2 test start');
await sleep(1000);
await tryToEnableBt();
bluetooth.BLE.on("BLEDeviceFind", onReceiveEvent)
function onReceiveEvent(data) {
console.info('[bluetooth_js] BLE scan device find result2 = '+ JSON.stringify(data));
expect(true).assertTrue(data.length >= 0);
bluetooth.BLE.off('BLEDeviceFind', result => {
console.info("[bluetooth_js] BLE scan device find off2:" + JSON.stringify(result));
expect(true).assertEqual(result ==null);
let result1 = bluetooth.BLE.stopBLEScan();
console.info("[bluetooth_js] onStopBLEScan2 -> " + JSON.stringify(result1));
done(); done();
});
}
bluetooth.BLE.startBLEScan([{deviceId:"00:00:00:00:00:00"}]);
}) })
/** /**
* @tc.number SUB_COMMUNACATION_bluetooth_START_BLESCAN_WITHOUT_PARAM_0001 * @tc.number SUB_COMMUNACATION_bluetooth_START_BLESCAN_WITHOUT_PARAM_0003
* @tc.name testClassicStartBLEScan * @tc.name testClassicStartBLEScan
* @tc.desc Test ClassicStartBLEScan api. * @tc.desc Test ClassicStartBLEScan api.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('SUB_COMMUNACATION_bluetooth_START_BLESCAN_WITHOUT_PARAM_0001', 0, async function (done) { it('SUB_COMMUNACATION_bluetooth_START_BLESCAN_WITHOUT_PARAM_0003', 0, async function (done) {
console.info('[bluetooth_js] BLE scan start without scan options start'); console.info('[bluetooth_js] BLE scan3 test start');
await sleep(1000);
await tryToEnableBt(); await tryToEnableBt();
let promise = new Promise((resolve) => {
bluetooth.BLE.on("BLEDeviceFind", onReceiveEvent) bluetooth.BLE.on("BLEDeviceFind", onReceiveEvent)
function onReceiveEvent(data) { function onReceiveEvent(data) {
console.info('[bluetooth_js] BLE scan device find result3 = '+ JSON.stringify(data)); console.info('[bluetooth_js] BLE scan device find result3 = '+ JSON.stringify(data));
expect(data.length).assertLarger(0); expect(true).assertTrue(data.length >= 0);
bluetooth.BLE.off('BLEDeviceFind', result => {
console.info("[bluetooth_js] BLE scan device find off3:" + JSON.stringify(result));
expect(true).assertEqual(result ==null);
let result1 = bluetooth.BLE.stopBLEScan();
console.info("[bluetooth_js] onStopBLEScan3 -> " + JSON.stringify(result1));
done(); done();
});
} }
bluetooth.BLE.startBLEScan([{}]); bluetooth.BLE.startBLEScan([{name:"bluetooth_test"}]);
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_START_BLESCAN_WITHOUT_PARAM_0004
* @tc.name testClassicStartBLEScan
* @tc.desc Test ClassicStartBLEScan api.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('SUB_COMMUNACATION_bluetooth_START_BLESCAN_WITHOUT_PARAM_0004', 0, async function (done) {
console.info('[bluetooth_js] BLE scan4 test start');
await sleep(1000);
await tryToEnableBt();
bluetooth.BLE.on("BLEDeviceFind", onReceiveEvent)
function onReceiveEvent(data) {
console.info('[bluetooth_js] BLE scan device find result4 = '+ JSON.stringify(data));
expect(true).assertTrue(data.length >= 0);
bluetooth.BLE.off('BLEDeviceFind', result => { bluetooth.BLE.off('BLEDeviceFind', result => {
console.info("[bluetooth_js] BLE scan device find off2:" + JSON.stringify(result)); console.info("[bluetooth_js] BLE scan device find off4:" + JSON.stringify(result));
expect(true).assertEqual(result ==null); expect(true).assertEqual(result ==null);
let result1 = bluetooth.BLE.stopBLEScan();
console.info("[bluetooth_js] onStopBLEScan4 -> " + JSON.stringify(result1));
done(); done();
}); });
let result = bluetooth.BLE.stopBLEScan(); }
console.info("[bluetooth_js] onStopBLEScan -> " + JSON.stringify(result)); bluetooth.BLE.startBLEScan([{serviceUuid:"00001888-0000-1000-8000-00805f9b34fb"}]);
console.info('[bluetooth_js] BLE scan start end');
resolve()
}) })
await promise.then(done)
/**
* @tc.number SUB_COMMUNACATION_bluetooth_START_BLESCAN_WITHOUT_PARAM_0005
* @tc.name testClassicStartBLEScan
* @tc.desc Test ClassicStartBLEScan api.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('SUB_COMMUNACATION_bluetooth_START_BLESCAN_WITHOUT_PARAM_0005', 0, async function (done) {
console.info('[bluetooth_js] BLE scan5 test start');
await sleep(1000);
await tryToEnableBt();
bluetooth.BLE.on("BLEDeviceFind", onReceiveEvent)
function onReceiveEvent(data) {
console.info('[bluetooth_js] BLE scan device find result5 = '+ JSON.stringify(data));
expect(true).assertTrue(data.length >= 0);
bluetooth.BLE.off('BLEDeviceFind', result => {
console.info("[bluetooth_js] BLE scan device find off5:" + JSON.stringify(result));
expect(true).assertEqual(result ==null);
let result1 = bluetooth.BLE.stopBLEScan();
console.info("[bluetooth_js] onStopBLEScan5 -> " + JSON.stringify(result1));
done();
});
}
bluetooth.BLE.startBLEScan(
[{}],
{
interval: 500,
dutyMode: bluetooth.ScanDuty.SCAN_MODE_LOW_POWER,
matchMode: bluetooth.MatchMode.MATCH_MODE_AGGRESSIVE,
}
);
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_START_BLESCAN_WITHOUT_PARAM_0006
* @tc.name testClassicStartBLEScan
* @tc.desc Test ClassicStartBLEScan api.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('SUB_COMMUNACATION_bluetooth_START_BLESCAN_WITHOUT_PARAM_0006', 0, async function (done) {
console.info('[bluetooth_js] BLE scan6 test start');
await sleep(1000);
await tryToEnableBt();
bluetooth.BLE.on("BLEDeviceFind", onReceiveEvent)
function onReceiveEvent(data) {
console.info('[bluetooth_js] BLE scan device find result6 = '+ JSON.stringify(data));
expect(true).assertTrue(data.length >= 0);
bluetooth.BLE.off('BLEDeviceFind', result => {
console.info("[bluetooth_js] BLE scan device find off6:" + JSON.stringify(result));
expect(true).assertEqual(result ==null);
let result1 = bluetooth.BLE.stopBLEScan();
console.info("[bluetooth_js] onStopBLEScan6 -> " + JSON.stringify(result1));
done();
});
}
bluetooth.BLE.startBLEScan(
[{}],
{
interval: 500,
dutyMode: bluetooth.ScanDuty.SCAN_MODE_BALANCED,
matchMode: bluetooth.MatchMode.MATCH_MODE_AGGRESSIVE,
}
);
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_START_BLESCAN_WITHOUT_PARAM_0007
* @tc.name testClassicStartBLEScan
* @tc.desc Test ClassicStartBLEScan api.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('SUB_COMMUNACATION_bluetooth_START_BLESCAN_WITHOUT_PARAM_0007', 0, async function (done) {
console.info('[bluetooth_js] BLE scan7 test start');
await sleep(1000);
await tryToEnableBt();
bluetooth.BLE.on("BLEDeviceFind", onReceiveEvent)
function onReceiveEvent(data) {
console.info('[bluetooth_js] BLE scan device find result7 = '+ JSON.stringify(data));
expect(true).assertTrue(data.length >= 0);
bluetooth.BLE.off('BLEDeviceFind', result => {
console.info("[bluetooth_js] BLE scan device find off7:" + JSON.stringify(result));
expect(true).assertEqual(result ==null);
let result1 = bluetooth.BLE.stopBLEScan();
console.info("[bluetooth_js] onStopBLEScan7 -> " + JSON.stringify(result1));
done();
});
}
bluetooth.BLE.startBLEScan(
[{}],
{
interval: 500,
dutyMode: bluetooth.ScanDuty.SCAN_MODE_LOW_LATENCY,
matchMode: bluetooth.MatchMode.MATCH_MODE_AGGRESSIVE,
}
);
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_START_BLESCAN_WITHOUT_PARAM_0008
* @tc.name testClassicStartBLEScan
* @tc.desc Test ClassicStartBLEScan api.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('SUB_COMMUNACATION_bluetooth_START_BLESCAN_WITHOUT_PARAM_0008', 0, async function (done) {
console.info('[bluetooth_js] BLE scan8 test start');
await sleep(1000);
await tryToEnableBt();
bluetooth.BLE.on("BLEDeviceFind", onReceiveEvent)
function onReceiveEvent(data) {
console.info('[bluetooth_js] BLE scan device find result8 = '+ JSON.stringify(data));
expect(true).assertTrue(data.length >= 0);
bluetooth.BLE.off('BLEDeviceFind', result => {
console.info("[bluetooth_js] BLE scan device find off8:" + JSON.stringify(result));
expect(true).assertEqual(result ==null);
let result1 = bluetooth.BLE.stopBLEScan();
console.info("[bluetooth_js] onStopBLEScan8 -> " + JSON.stringify(result1));
done();
});
}
bluetooth.BLE.startBLEScan(
[{}],
{
interval: 0,
dutyMode: bluetooth.ScanDuty.SCAN_MODE_LOW_POWER,
matchMode: bluetooth.MatchMode.MATCH_MODE_STICKY,
}
);
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_START_BLESCAN_WITHOUT_PARAM_0009
* @tc.name testClassicStartBLEScan
* @tc.desc Test ClassicStartBLEScan api.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('SUB_COMMUNACATION_bluetooth_START_BLESCAN_WITHOUT_PARAM_0009', 0, async function (done) {
console.info('[bluetooth_js] BLE scan9 test start');
await sleep(2000);
await tryToEnableBt();
let disable = bluetooth.disableBluetooth();
console.info('[bluetooth_js] stopScan disable:' + JSON.stringify(disable));
expect(disable).assertTrue();
await sleep(3100);
let result1 = bluetooth.BLE.stopBLEScan();
console.info("[bluetooth_js] onStopBLEScan9 -> " + JSON.stringify(result1));
expect(result1).assertNull();
done();
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_START_BLESCAN_WITHOUT_PARAM_0010
* @tc.name testClassicStartBLEScan
* @tc.desc Test ClassicStartBLEScan api.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('SUB_COMMUNACATION_bluetooth_START_BLESCAN_WITHOUT_PARAM_0010', 0, async function (done) {
console.info('[bluetooth_js] BLE scan10 test start');
await sleep(1000);
await tryToEnableBt();
let result1 = bluetooth.BLE.stopBLEScan();
console.info("[bluetooth_js] onStopBLEScan9 -> " + JSON.stringify(result1));
expect(result1).assertNull();
done(); done();
}) })
...@@ -255,7 +516,7 @@ describe('bluetoothhostTest', function() { ...@@ -255,7 +516,7 @@ describe('bluetoothhostTest', function() {
it('SUB_COMMUNACATION_bluetooth_PAIR_DEVICE_0001', 0, async function (done) { it('SUB_COMMUNACATION_bluetooth_PAIR_DEVICE_0001', 0, async function (done) {
console.info('[bluetooth_js] pair device start'); console.info('[bluetooth_js] pair device start');
await tryToEnableBt(); await tryToEnableBt();
await bluetooth.BLE.on('pinRequired', result => { bluetooth.BLE.on('pinRequired', result => {
console.info("[bluetooth_js] pinRequired on:" + JSON.stringify(result)); console.info("[bluetooth_js] pinRequired on:" + JSON.stringify(result));
bluetooth.setDevicePairingConfirmation(result,false); bluetooth.setDevicePairingConfirmation(result,false);
expect(true).assertEqual(result !=null); expect(true).assertEqual(result !=null);
...@@ -269,6 +530,7 @@ describe('bluetoothhostTest', function() { ...@@ -269,6 +530,7 @@ describe('bluetoothhostTest', function() {
}); });
}) })
/** /**
* @tc.number SUB_COMMUNACATION_bluetooth_PAIR_DEVICE_0002 * @tc.number SUB_COMMUNACATION_bluetooth_PAIR_DEVICE_0002
* @tc.name testClassicPairDevice * @tc.name testClassicPairDevice
...@@ -335,7 +597,7 @@ describe('bluetoothhostTest', function() { ...@@ -335,7 +597,7 @@ describe('bluetoothhostTest', function() {
try { try {
await tryToEnableBt(); await tryToEnableBt();
console.info('[bluetooth_js] CharacteristicReadOn test start'); console.info('[bluetooth_js] CharacteristicReadOn test start');
await gattServer.on('characteristicRead', function (data) { gattServer.on('characteristicRead', function (data) {
console.info('[bluetooth_js] CharRedReq deviceId: ' + data.deviceId + console.info('[bluetooth_js] CharRedReq deviceId: ' + data.deviceId +
'transId:' + data.transId + 'offset:' + data.offset + 'charUuid:' + 'transId:' + data.transId + 'offset:' + data.offset + 'charUuid:' +
data.characteristicUuid + 'serviceUuid:' + data.serviceUuid); data.characteristicUuid + 'serviceUuid:' + data.serviceUuid);
...@@ -352,10 +614,9 @@ describe('bluetoothhostTest', function() { ...@@ -352,10 +614,9 @@ describe('bluetoothhostTest', function() {
}catch(e) { }catch(e) {
expect(null).assertFail(); expect(null).assertFail();
} }
try { try {
console.info('[bluetooth_js] characteristicRead test1 start'); console.info('[bluetooth_js] characteristicRead test1 start');
await gattServer.off('characteristicRead', function (data) { gattServer.off('characteristicRead', function (data) {
console.info("[bluetooth_js] charaRead off data:" + JSON.stringify(data)); console.info("[bluetooth_js] charaRead off data:" + JSON.stringify(data));
expect(true).assertEqual(data ==null); expect(true).assertEqual(data ==null);
}); });
...@@ -365,6 +626,7 @@ describe('bluetoothhostTest', function() { ...@@ -365,6 +626,7 @@ describe('bluetoothhostTest', function() {
done(); done();
}) })
/** /**
* @tc.number SUB_COMMUNACATION_bluetoothble_CHARAC_WRITE_ON_0001 * @tc.number SUB_COMMUNACATION_bluetoothble_CHARAC_WRITE_ON_0001
* @tc.name testonCharacteristicwriteOn * @tc.name testonCharacteristicwriteOn
...@@ -377,8 +639,7 @@ describe('bluetoothhostTest', function() { ...@@ -377,8 +639,7 @@ describe('bluetoothhostTest', function() {
try { try {
await tryToEnableBt(); await tryToEnableBt();
console.info('[bluetooth_js] CharacteristicwriteOn test start'); console.info('[bluetooth_js] CharacteristicwriteOn test start');
await gattServer.on('characteristicWrite', function (data) { gattServer.on('characteristicWrite', function (data) {
console.info('[bluetooth_js] CharWriReq deviceId: ' + data.deviceId + console.info('[bluetooth_js] CharWriReq deviceId: ' + data.deviceId +
'transId:' + data.transId + 'offset:' + data.offset + 'isPrep:' + data.isPrep + 'transId:' + data.transId + 'offset:' + data.offset + 'isPrep:' + data.isPrep +
'charUuid:' + data.characteristicUuid + 'serviceUuid:' + data.serviceUuid + 'charUuid:' + data.characteristicUuid + 'serviceUuid:' + data.serviceUuid +
...@@ -403,10 +664,9 @@ describe('bluetoothhostTest', function() { ...@@ -403,10 +664,9 @@ describe('bluetoothhostTest', function() {
}catch(e) { }catch(e) {
expect(null).assertFail(); expect(null).assertFail();
} }
try { try {
console.info('[bluetooth_js] characteristicWrite test1 start'); console.info('[bluetooth_js] characteristicWrite test1 start');
await gattServer.off('characteristicWrite', function (data) { gattServer.off('characteristicWrite', function (data) {
console.info("[bluetooth_js] charaWrite off data2:" + JSON.stringify(data)); console.info("[bluetooth_js] charaWrite off data2:" + JSON.stringify(data));
expect(true).assertEqual(data ==null); expect(true).assertEqual(data ==null);
}); });
...@@ -416,6 +676,7 @@ describe('bluetoothhostTest', function() { ...@@ -416,6 +676,7 @@ describe('bluetoothhostTest', function() {
done(); done();
}) })
/** /**
* @tc.number SUB_COMMUNACATION_bluetooth_DESC_READ_ON_0001 * @tc.number SUB_COMMUNACATION_bluetooth_DESC_READ_ON_0001
* @tc.name testDescriptorReadOn * @tc.name testDescriptorReadOn
...@@ -428,21 +689,19 @@ describe('bluetoothhostTest', function() { ...@@ -428,21 +689,19 @@ describe('bluetoothhostTest', function() {
try { try {
await tryToEnableBt(); await tryToEnableBt();
console.info('[bluetooth_js] descriptorReadOn test start ...'); console.info('[bluetooth_js] descriptorReadOn test start ...');
await gattServer.on('descriptorRead', function (data) { gattServer.on('descriptorRead', function (data) {
console.info("[bluetooth_js] DesRedon jsondata:" + JSON.stringify(data) + console.info("[bluetooth_js] DesRedon jsondata:" + JSON.stringify(data) +
'deviceId:' + data.deviceId + 'transId:' + data.transId + 'offset:' + 'deviceId:' + data.deviceId + 'transId:' + data.transId + 'offset:' +
data.offset +'descriptorUuid:' + data.descriptorUuid + 'characteristicUuid:' + data.offset +'descriptorUuid:' + data.descriptorUuid + 'characteristicUuid:' +
data.characteristicUuid + 'serviceUuid:' + data.serviceUuid); data.characteristicUuid + 'serviceUuid:' + data.serviceUuid);
expect(true).assertEqual(data !=null); expect(true).assertEqual(data !=null);
}); });
}catch(e) { }catch(e) {
expect(null).assertFail(); expect(null).assertFail();
} }
try { try {
console.info('[bluetooth_js] descriptorReadOff test start ...'); console.info('[bluetooth_js] descriptorReadOff test start ...');
await gattServer.off('descriptorRead', function (data) { gattServer.off('descriptorRead', function (data) {
expect(true).assertEqual(data ==null); expect(true).assertEqual(data ==null);
}); });
}catch(e) { }catch(e) {
...@@ -464,7 +723,7 @@ describe('bluetoothhostTest', function() { ...@@ -464,7 +723,7 @@ describe('bluetoothhostTest', function() {
try { try {
await tryToEnableBt(); await tryToEnableBt();
console.info('[bluetooth_js] descriptorWriteOn test start ...'); console.info('[bluetooth_js] descriptorWriteOn test start ...');
await gattServer.on('descriptorWrite', function (data) { gattServer.on('descriptorWrite', function (data) {
console.info("[bluetooth_js] desWriOn jsondata: " + JSON.stringify(data) + console.info("[bluetooth_js] desWriOn jsondata: " + JSON.stringify(data) +
'deviceId: ' + data.deviceId + 'transId:' + data.transId + 'offset:' + 'deviceId: ' + data.deviceId + 'transId:' + data.transId + 'offset:' +
data.offset +'descriptorUuid:' + data.descriptorUuid + data.offset +'descriptorUuid:' + data.descriptorUuid +
...@@ -475,10 +734,9 @@ describe('bluetoothhostTest', function() { ...@@ -475,10 +734,9 @@ describe('bluetoothhostTest', function() {
}catch(e) { }catch(e) {
expect(null).assertFail(); expect(null).assertFail();
} }
try { try {
console.info('[bluetooth_js] descriptorWriteOff test start ...'); console.info('[bluetooth_js] descriptorWriteOff test start ...');
await gattServer.off('descriptorWrite', function (data) { gattServer.off('descriptorWrite', function (data) {
expect(true).assertEqual(data ==null); expect(true).assertEqual(data ==null);
}); });
}catch(e) { }catch(e) {
...@@ -500,7 +758,7 @@ describe('bluetoothhostTest', function() { ...@@ -500,7 +758,7 @@ describe('bluetoothhostTest', function() {
try { try {
await tryToEnableBt(); await tryToEnableBt();
console.info('[bluetooth_js] ConnectStateChangeOn test start ...'); console.info('[bluetooth_js] ConnectStateChangeOn test start ...');
await gattServer.on('connectStateChange', function (data) { gattServer.on('connectStateChange', function (data) {
console.info("[bluetooth_js] connectStaOn jsonData -> " + JSON.stringify(data) + console.info("[bluetooth_js] connectStaOn jsonData -> " + JSON.stringify(data) +
'deviceId: ' + data.deviceId + 'state:'+ data.state); 'deviceId: ' + data.deviceId + 'state:'+ data.state);
expect(true).assertEqual(data !=null); expect(true).assertEqual(data !=null);
...@@ -508,10 +766,9 @@ describe('bluetoothhostTest', function() { ...@@ -508,10 +766,9 @@ describe('bluetoothhostTest', function() {
}catch(e) { }catch(e) {
expect(null).assertFail(); expect(null).assertFail();
} }
try { try {
console.info('[bluetooth_js] ConnectStateChangeOff test start ...'); console.info('[bluetooth_js] ConnectStateChangeOff test start ...');
await gattServer.off('connectStateChange', function (data) { gattServer.off('connectStateChange', function (data) {
console.info("[bluetooth_js] connectStateChange_off Data:" + JSON.stringify(data)); console.info("[bluetooth_js] connectStateChange_off Data:" + JSON.stringify(data));
expect(true).assertEqual(data ==null); expect(true).assertEqual(data ==null);
}); });
...@@ -534,17 +791,16 @@ describe('bluetoothhostTest', function() { ...@@ -534,17 +791,16 @@ describe('bluetoothhostTest', function() {
try { try {
await tryToEnableBt(); await tryToEnableBt();
console.info('[bluetooth_js] BLECharacteristicChangeOn test start ...'); console.info('[bluetooth_js] BLECharacteristicChangeOn test start ...');
await gattClient.on('BLECharacteristicChange', function (data) { gattClient.on('BLECharacteristicChange', function (data) {
console.info("[bluetooth_js] BLECharacteristicChange data " + JSON.stringify(data)); console.info("[bluetooth_js] BLECharacteristicChange data " + JSON.stringify(data));
expect(true).assertEqual(data !=null); expect(true).assertEqual(data !=null);
}); });
}catch(e) { }catch(e) {
expect(null).assertFail(); expect(null).assertFail();
} }
try { try {
console.info('[bluetooth_js] BLECharacteristicChangeOff test start'); console.info('[bluetooth_js] BLECharacteristicChangeOff test start');
await gattClient.off('BLECharacteristicChange', function (data) { gattClient.off('BLECharacteristicChange', function (data) {
console.info("[bluetooth_js] BLECharcChange_off data-> " + JSON.stringify(data)); console.info("[bluetooth_js] BLECharcChange_off data-> " + JSON.stringify(data));
expect(true).assertEqual(data ==null); expect(true).assertEqual(data ==null);
}); });
...@@ -567,7 +823,7 @@ describe('bluetoothhostTest', function() { ...@@ -567,7 +823,7 @@ describe('bluetoothhostTest', function() {
try { try {
await tryToEnableBt(); await tryToEnableBt();
console.info('[bluetooth_js] BLEConnectionStateChangeOn test start'); console.info('[bluetooth_js] BLEConnectionStateChangeOn test start');
await gattClient.on('BLEConnectionStateChange', function (data) { gattClient.on('BLEConnectionStateChange', function (data) {
console.info("[bluetooth_js] BLEConnecStateChange_on data " + JSON.stringify(data) console.info("[bluetooth_js] BLEConnecStateChange_on data " + JSON.stringify(data)
+'deviceId: ' + data.deviceId + 'state:'+ data.state); +'deviceId: ' + data.deviceId + 'state:'+ data.state);
expect(true).assertEqual(data !=null); expect(true).assertEqual(data !=null);
...@@ -575,10 +831,9 @@ describe('bluetoothhostTest', function() { ...@@ -575,10 +831,9 @@ describe('bluetoothhostTest', function() {
}catch(e) { }catch(e) {
expect(null).assertFail(); expect(null).assertFail();
} }
try { try {
console.info('[bluetooth_js] BLEConnectionStateChangeOff test start'); console.info('[bluetooth_js] BLEConnectionStateChangeOff test start');
await gattClient.off('BLEConnectionStateChange', function (data) { gattClient.off('BLEConnectionStateChange', function (data) {
console.info("[bluetooth_js] BLEConneStateChange_off data-> " + JSON.stringify(data)); console.info("[bluetooth_js] BLEConneStateChange_off data-> " + JSON.stringify(data));
expect(true).assertEqual(data ==null); expect(true).assertEqual(data ==null);
}); });
...@@ -601,17 +856,16 @@ describe('bluetoothhostTest', function() { ...@@ -601,17 +856,16 @@ describe('bluetoothhostTest', function() {
try { try {
await tryToEnableBt(); await tryToEnableBt();
console.info('[bluetooth_js] sppReadOn test start'); console.info('[bluetooth_js] sppReadOn test start');
await bluetooth.on("sppRead",-1, (result) => { bluetooth.on("sppRead",-1, (result) => {
console.info("[bluetooth_js] sppReadOn json_result -> " + JSON.stringify(result)); console.info("[bluetooth_js] sppReadOn json_result -> " + JSON.stringify(result));
expect(true).assertEqual(result !=null); expect(true).assertEqual(result !=null);
}); });
}catch(e) { }catch(e) {
expect(null).assertFail(); expect(null).assertFail();
} }
try { try {
console.info('[bluetooth_js] sppReadOff test start ...'); console.info('[bluetooth_js] sppReadOff test start ...');
await bluetooth.off("sppRead",-1, (result) => { bluetooth.off("sppRead",-1, (result) => {
console.info("[bluetooth_js] sppReadOff json_result -> " + JSON.stringify(result)); console.info("[bluetooth_js] sppReadOff json_result -> " + JSON.stringify(result));
expect(true).assertEqual(result ==null); expect(true).assertEqual(result ==null);
}); });
...@@ -622,3 +876,4 @@ describe('bluetoothhostTest', function() { ...@@ -622,3 +876,4 @@ describe('bluetoothhostTest', function() {
}) })
}) })
...@@ -18,7 +18,8 @@ import {Core, ExpectExtend} from 'deccjsunit/index' ...@@ -18,7 +18,8 @@ import {Core, ExpectExtend} from 'deccjsunit/index'
export default { export default {
data: { data: {
title: "" title: "",
myTimeout:75000
}, },
onInit() { onInit() {
this.title = this.$t('strings.world'); this.title = this.$t('strings.world');
...@@ -36,6 +37,7 @@ export default { ...@@ -36,6 +37,7 @@ export default {
core.init() core.init()
const configService = core.getDefaultService('config') const configService = core.getDefaultService('config')
this.timeout = this.myTimeout
configService.setConfig(this) configService.setConfig(this)
require('../../test/List.test') require('../../test/List.test')
......
...@@ -419,24 +419,6 @@ describe('bluetoothhostTest', function() { ...@@ -419,24 +419,6 @@ describe('bluetoothhostTest', function() {
}) })
/**
* @tc.number SUB_COMMUNACATION_bluetooth_CANCEL_PAIRED_DEV_0001
* @tc.name testCancelPairedDevice
* @tc.desc Test CancelPairedDevice api.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('SUB_COMMUNACATION_bluetooth_CANCEL_PAIRED_DEV_0001', 0, async function (done) {
console.info('[bluetooth_js] cancelPairedDevice start');
await tryToEnableBt();
let ret = bluetooth.cancelPairedDevice("00:00:00:00:00:00");
console.info('[bluetooth_js] cancelPairedDevice ret2 : ' + JSON.stringify(ret));
expect(ret).assertFalse();
done();
})
/** /**
* @tc.number SUB_COMMUNACATION_bluetooth_SET_LOCAL_NAME_0001 * @tc.number SUB_COMMUNACATION_bluetooth_SET_LOCAL_NAME_0001
* @tc.name testsetLocalName * @tc.name testsetLocalName
...@@ -713,3 +695,4 @@ describe('bluetoothhostTest', function() { ...@@ -713,3 +695,4 @@ describe('bluetoothhostTest', function() {
}) })
}) })
/*
* 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 {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
import wifi from '@ohos.wifi'
function sleep(delay) {
return new Promise(resovle => setTimeout(resovle, delay))
}
async function tryToDisableWifi(){
if(wifi.isWifiActive()){
console.info("wifi_test/disable wifi:" + wifi.disableWifi());
await sleep(5000);
}
console.info("wifi_test/wifi status:" + wifi.isWifiActive());
}
let WifiSecurityType = {
WIFI_SEC_TYPE_INVALID : 0,
WIFI_SEC_TYPE_OPEN : 1,
WIFI_SEC_TYPE_WEP : 2,
WIFI_SEC_TYPE_PSK : 3,
WIFI_SEC_TYPE_SAE : 4,
}
let HotspotConfig = {
"ssid": "testWgr",
"band": 1,
"preSharedKey": "12345678",
"securityType": WifiSecurityType.WIFI_SEC_TYPE_PSK,
"maxConn": 8
}
describe('ACTS_WifiTest', function() {
beforeEach(function () {
})
afterEach(function () {
})
/**
* @tc.number OPEN_0002
* @tc.name SUB_Communication_WiFi_Hotspot_Open_0002
* @tc.desc Test wifi.enableHotspot and wifi.disableHotspot API functionality1.
* @tc.level Level 0
*/
it('SUB_Communication_WiFi_Hotspot_Open_0002', 0, async function (done) {
if (wifi.isWifiActive()) {
let disable = wifi.disableWifi();
await sleep(5000);
expect(disable).assertTrue();
}
let close =wifi.isWifiActive();
console.info("[wifi_test] wifi status result: " + close);
expect(close).assertFalse();
if (!wifi.isHotspotActive()) {
let on = wifi.enableHotspot();
await sleep(5000);
expect(on).assertTrue();
}
console.info("[wifi_test] Hotspot status result -> " + wifi.isHotspotActive());
expect(wifi.isHotspotActive()).assertTrue();
done();
})
/**
* @tc.number CONFIG_0001
* @tc.name SUB_Communication_WiFi_Hotspot_Config_0001
* @tc.desc Test set a valid 2.4G hotspot config
* @tc.level Level 0
*/
it('SUB_Communication_WiFi_Hotspot_Config_0001', 0, async function (done) {
await tryToDisableWifi();
if (wifi.isHotspotActive()) {
let off = wifi.disableHotspot();
await sleep(3000);
expect(off).assertTrue();
}
console.info("[wifi_test] Hotspot status result -> " + wifi.isHotspotActive());
expect(wifi.isHotspotActive()).assertFalse();
let isSuccess = wifi.setHotspotConfig(HotspotConfig);
expect(isSuccess).assertTrue();
let hotspotConfig = wifi.getHotspotConfig();
console.log("[wifi_test] getHotspotConfig result: " + JSON.stringify(hotspotConfig));
expect(hotspotConfig.band).assertEqual(1);
done()
})
/**
* @tc.number CONFIG_0002
* @tc.name SUB_Communication_WiFi_Hotspot_Config_0002
* @tc.desc Test set a valid 5G hotspot config
* @tc.level Level 1
*/
it('SUB_Communication_WiFi_Hotspot_Config_0002', 0, async function (done) {
await tryToDisableWifi();
if (wifi.isHotspotActive()) {
let off = wifi.disableHotspot();
await sleep(3000);
expect(off).assertTrue();
}
console.info("[wifi_test] Hotspot status result -> " + wifi.isHotspotActive());
let HotspotConfig5G = {
"ssid": "testWgr",
"band": 2,
"preSharedKey": "12345678",
"securityType": WifiSecurityType.WIFI_SEC_TYPE_PSK,
"maxConn": 8
};
let isSuccess5 = wifi.setHotspotConfig(HotspotConfig5G);
expect(isSuccess5).assertTrue();
let hotspotConfig5 = wifi.getHotspotConfig();
console.log("[wifi_test] getHotspotConfig result: " + JSON.stringify(hotspotConfig5));
expect(hotspotConfig5.band).assertEqual(2);
done()
})
/**
* @tc.number CONFIG_0003
* @tc.name SUB_Communication_WiFi_Hotspot_Config_0003
* @tc.desc Test set a invalid band hotspot config
* @tc.level Level 2
*/
it('SUB_Communication_WiFi_Hotspot_Config_0003', 0, async function (done) {
await tryToDisableWifi();
if (wifi.isHotspotActive()) {
let off = wifi.disableHotspot();
await sleep(3000);
console.info("[wifi_test] disableHotspot result -> " + off);
expect(off).assertTrue();
}
let HotspotConfig1= {
"ssid": "testWgr",
"band": 21,
"preSharedKey": "12345678",
"securityType": WifiSecurityType.WIFI_SEC_TYPE_PSK,
"maxConn": 8
};
let isSuccess1 = wifi.setHotspotConfig(HotspotConfig1);
console.log("[wifi_test] set invalid band hotspot config result1:" + isSuccess1);
expect(isSuccess1).assertFalse();
done();
})
/**
* @tc.number CONFIG_0004
* @tc.name SUB_Communication_WiFi_Hotspot_Config_0004
* @tc.desc Test set a max preSharedKey is hotspot config
* @tc.level Level 2
*/
it('SUB_Communication_WiFi_Hotspot_Config_0004', 0, async function (done) {
await tryToDisableWifi();
if (wifi.isHotspotActive()) {
let off = wifi.disableHotspot();
await sleep(5000);
expect(off).assertTrue();
}
let HotspotConfigM= {
"ssid": "testWgr",
"band": 1,
"preSharedKey": "123456789123456789123456789123456789123456789123456789123456789",
"securityType": WifiSecurityType.WIFI_SEC_TYPE_PSK,
"maxConn": 8
};
let isSuccess1 = wifi.setHotspotConfig(HotspotConfigM);
console.log("[wifi_test] set max preSharedKey valid hotspot config result: " + isSuccess1);
expect(isSuccess1).assertTrue();
let HotspotConfigM1= {
"ssid": "testWgr",
"band": 1,
"preSharedKey": "1234567891234567891234567891234567891234567891234567891234567891",
"securityType": WifiSecurityType.WIFI_SEC_TYPE_PSK,
"maxConn": 8
};
let isSuccess2 = wifi.setHotspotConfig(HotspotConfigM1);
expect(isSuccess2).assertFalse();
let hotspotConfigS= wifi.getHotspotConfig();
console.log("[wifi_test] getHotspotConfig result: " + JSON.stringify(hotspotConfigS));
expect(hotspotConfigS.preSharedKey.length).assertEqual(63);
done();
})
/**
* @tc.number CONFIG_0005
* @tc.name SUB_Communication_WiFi_Hotspot_Config_0005
* @tc.desc Test set a min preSharedKey is hotspot config
* @tc.level Level 2
*/
it('SUB_Communication_WiFi_Hotspot_Config_0005', 0, async function (done) {
await tryToDisableWifi();
if (wifi.isHotspotActive()) {
let off = wifi.disableHotspot();
await sleep(5000);
expect(off).assertTrue();
}
let HotspotConfigI= {
"ssid": "testWgr",
"band": 1,
"preSharedKey": "12345678",
"securityType": WifiSecurityType.WIFI_SEC_TYPE_PSK,
"maxConn": 8
};
let isSuccess1 = wifi.setHotspotConfig(HotspotConfigI);
expect(isSuccess1).assertTrue();
let config = wifi.getHotspotConfig();
console.info("[wifi_test] getHotspotConfig result -> " + JSON.stringify(config));
console.info("preSharedKey: " + config.preSharedKey);
expect(config.preSharedKey.length).assertEqual(8);
let HotspotConfigI2= {
"ssid": "testWgr",
"band": 1,
"preSharedKey": "1234567",
"securityType": WifiSecurityType.WIFI_SEC_TYPE_PSK,
"maxConn": 8
};
let isSuccess2 = wifi.setHotspotConfig(HotspotConfigI2);
expect(isSuccess2).assertFalse();
let config1 = wifi.getHotspotConfig();
console.info("[wifi_test] getHotspotConfig result -> " + JSON.stringify(config1));
expect(config1.preSharedKey.length).assertEqual(8);
done();
})
/**
* @tc.number CONFIG_0006
* @tc.name SUB_Communication_WiFi_Hotspot_Config_0006
* @tc.desc Test set a max ssid for hotspot config
* @tc.level Level 2
*/
it('SUB_Communication_WiFi_Hotspot_Config_0006', 0, async function (done) {
await tryToDisableWifi();
if (wifi.isHotspotActive()) {
let off = wifi.disableHotspot();
await sleep(5000);
expect(off).assertTrue();
}
let isHotspotActive = wifi.isHotspotActive();
console.info("[wifi_test] isHotspotActive -> " + isHotspotActive);
expect(isHotspotActive).assertFalse();
let HotspotConfigS= {
"ssid": "testWgr123testWgr123testWgr12356",
"band": 1,
"preSharedKey": "12345678",
"securityType": WifiSecurityType.WIFI_SEC_TYPE_PSK,
"maxConn": 8
};
let isSuccess1 = wifi.setHotspotConfig(HotspotConfigS);
expect(isSuccess1).assertTrue();
let HotspotConfigS1= {
"ssid": "testWgr123testWgr123testWgr123567",
"band": 1,
"preSharedKey": "12345678",
"securityType": WifiSecurityType.WIFI_SEC_TYPE_PSK,
"maxConn": 8
};
let isSuccess2 = wifi.setHotspotConfig(HotspotConfigS1);
console.log("[wifi_test] set 33bit ssid invalid hotspot config result: " + isSuccess2);
expect(isSuccess2).assertFalse();
let config = wifi.getHotspotConfig();
console.info("[wifi_test] getHotspotConfig result -> " + JSON.stringify(config));
expect(config.ssid.length).assertEqual(32);
done();
})
/**
* @tc.number CONFIG_0007
* @tc.name SUB_Communication_WiFi_Hotspot_Config_0007
* @tc.desc Test set a null ssid invalid hotspot config
* @tc.level Level 2
*/
it('SUB_Communication_WiFi_Hotspot_Config_0007', 0, async function(done) {
await tryToDisableWifi();
if (wifi.isHotspotActive()) {
let off = wifi.disableHotspot();
await sleep(2000);
expect(off).assertTrue();
}
let HotspotConfigN= {
"ssid": "",
"band": 1,
"preSharedKey": "12345678",
"securityType": WifiSecurityType.WIFI_SEC_TYPE_PSK,
"maxConn": 8
};
let isSuccess1 = wifi.setHotspotConfig(HotspotConfigN);
console.log("[wifi_test] set a null ssid invalid hotspot config result1:" + isSuccess1);
expect(isSuccess1).assertFalse();
done();
})
/**
* @tc.number CONFIG_0008
* @tc.name SUB_Communication_WiFi_Hotspot_Config_0008
* @tc.desc Test set a contains Chinese.special.digits valid hotspot config
* @tc.level Level 2
*/
it('SUB_Communication_WiFi_Hotspot_Config_0008', 0, async function(done) {
if (wifi.isHotspotActive()) {
let off = wifi.disableHotspot();
await sleep(3000);
expect(off).assertTrue();
}
let HotspotConfigC= {
"ssid": "测试123!@#¥%……&*( ",
"band": 1,
"preSharedKey": "12345678",
"securityType": WifiSecurityType.WIFI_SEC_TYPE_PSK,
"maxConn": 8
};
let isSuccess1 = wifi.setHotspotConfig(HotspotConfigC);
expect(isSuccess1).assertTrue();
let isHotspotActive = wifi.isHotspotActive();
console.info("[wifi_test] isHotspotActive -> " + isHotspotActive);
expect(isHotspotActive).assertFalse();
let config = wifi.getHotspotConfig();
console.info("[wifi_test] getHotspotConfig result -> " + JSON.stringify(config));
expect(true).assertEqual(config.ssid==HotspotConfigC.ssid);
done();
})
/**
* @tc.number CONFIG_0009
* @tc.name SUB_Communication_WiFi_Hotspot_Config_0009
* @tc.desc Test set a invalid preSharedKey hotspot config
* @tc.level Level 2
*/
it('SUB_Communication_WiFi_Hotspot_Config_0009', 0, async function (done) {
await tryToDisableWifi();
if (wifi.isHotspotActive()) {
let off = wifi.disableHotspot();
await sleep(3000);
expect(off).assertTrue();
}
let HotspotConfigWep= {
"ssid": "test123",
"band": 1,
"preSharedKey": "12345678",
"securityType":WifiSecurityType.WIFI_SEC_TYPE_WEP,
"maxConn": 8
};
let isSuccess1 = wifi.setHotspotConfig(HotspotConfigWep);
console.log("[wifi_test] set a invalid preSharedKey hotspot config result1: " + isSuccess1);
expect(isSuccess1).assertFalse();
let HotspotConfigSAE= {
"ssid": "test123",
"band": 1,
"preSharedKey": "12345678",
"securityType":WifiSecurityType.WIFI_SEC_TYPE_SAE,
"maxConn": 8
};
let isSuccess2 = wifi.setHotspotConfig(HotspotConfigSAE);
console.log("[wifi_test] set a invalid preSharedKey hotspot config result1: " + isSuccess2);
expect(isSuccess2).assertFalse();
let HotspotConfigC= {
"ssid": "test123",
"band": 1,
"preSharedKey": "12345678",
"securityType":12,
"maxConn": 8
};
let isSuccess3 = wifi.setHotspotConfig(HotspotConfigC);
console.log("[wifi_test] set a invalid preSharedKey hotspot config result1: " + isSuccess3);
expect(isSuccess3).assertFalse();
done();
})
/**
* @tc.number CONFIG_0010
* @tc.name SUB_Communication_WiFi_Hotspot_Config_0010
* @tc.desc Test set a valid PSK preSharedKey hotspot config
* @tc.level Level 2
*/
it('SUB_Communication_WiFi_Hotspot_Config_0010', 0, async function (done) {
await tryToDisableWifi();
if (wifi.isHotspotActive()) {
let off = wifi.disableHotspot();
await sleep(5000);
expect(off).assertTrue();
}
let HotspotConfigPSK= {
"ssid": "test123",
"band": 1,
"preSharedKey": "12345678",
"securityType":WifiSecurityType.WIFI_SEC_TYPE_PSK,
"maxConn": 8
}
let isSuccess1 = wifi.setHotspotConfig(HotspotConfigPSK);
expect(isSuccess1).assertTrue();
let config = wifi.getHotspotConfig();
console.info("[wifi_test] getHotspotConfig result -> " + JSON.stringify(config));
expect(config.securityType).assertEqual(3);
console.log("[wifi_test] check the state of Hotspot" );
let isHotspotActive = wifi.isHotspotActive();
console.info("[wifi_test] isHotspotActive -> " + isHotspotActive);
expect(isHotspotActive).assertFalse();
done();
})
/**
* @tc.number CONFIG_0011
* @tc.name SUB_Communication_WiFi_Hotspot_Config_0011
* @tc.desc Test set a valid OPEN preSharedKey hotspot config
* @tc.level Level 2
*/
it('SUB_Communication_WiFi_Hotspot_Config_0011', 0, async function (done) {
await tryToDisableWifi();
if (wifi.isHotspotActive()) {
let off = wifi.disableHotspot();
await sleep(5000);
expect(off).assertTrue();
}
let HotspotConfigO= {
"ssid": "test123",
"band": 1,
"preSharedKey": "",
"securityType":WifiSecurityType.WIFI_SEC_TYPE_OPEN,
"maxConn": 8
}
let isSuccess1 = wifi.setHotspotConfig(HotspotConfigO);
console.log("[wifi_test] set a open preSharedKey hotspot config result1: " + isSuccess1);
expect(isSuccess1).assertTrue();
let config = wifi.getHotspotConfig();
console.info("[wifi_test] getHotspotConfig result -> " + JSON.stringify(config));
expect(config.securityType).assertEqual(1);
done();
})
/**
* @tc.number CONN_0001
* @tc.name SUB_Communication_WiFi_Hotspot_Conn_0001
* @tc.desc Test set a maxConn and more maxConn hotspot config
* @tc.level Level 2
*/
it('SUB_Communication_WiFi_Hotspot_Conn_0001', 0, async function (done) {
await tryToDisableWifi();
if (wifi.isHotspotActive()) {
let off = wifi.disableHotspot();
await sleep(5000);
expect(off).assertTrue();
}
let HotspotConfigI= {
"ssid": "testWgr",
"band": 1,
"preSharedKey": "12345678",
"securityType": WifiSecurityType.WIFI_SEC_TYPE_PSK,
"maxConn": 8
};
let isSuccess1 = wifi.setHotspotConfig(HotspotConfigI);
console.log("[wifi_test] set maxConn valid hotspot config result: " + isSuccess1);
expect(isSuccess1).assertTrue();
let config = wifi.getHotspotConfig();
console.info("[wifi_test] getHotspotConfig result -> " + JSON.stringify(config));
expect(config.maxConn).assertEqual(8);
let HotspotConfigI2= {
"ssid": "testWgr",
"band": 1,
"preSharedKey": "1234567",
"securityType": WifiSecurityType.WIFI_SEC_TYPE_PSK,
"maxConn": 9
};
let isSuccess2 = wifi.setHotspotConfig(HotspotConfigI2);
console.log("[wifi_test] set more maxConn invalid hotspot config result: " + isSuccess2);
expect(isSuccess2).assertFalse();
let config1 = wifi.getHotspotConfig();
console.info("[wifi_test] getHotspotConfig result -> " + JSON.stringify(config1));
expect(config1.maxConn).assertEqual(8);
done();
})
/**
* @tc.number CONFIG_0012
* @tc.name SUB_Communication_WiFi_Hotspot_Config_0012
* @tc.desc Test set a valid hotspot config after open Hotspot
* @tc.level Level 2
*/
it('SUB_Communication_WiFi_Hotspot_Config_0012', 0, async function (done) {
await tryToDisableWifi();
if (!wifi.isHotspotActive()) {
let on = wifi.enableHotspot();
await sleep(5000);
expect(on).assertTrue();
}
let isHotspotActive = wifi.isHotspotActive();
console.info("[wifi_test] isHotspotActive -> " + isHotspotActive);
expect(isHotspotActive).assertTrue();
let HotspotConfigWO= {
"ssid": "WIFITEST",
"band": 1,
"preSharedKey": "123456789",
"securityType": WifiSecurityType.WIFI_SEC_TYPE_PSK,
"maxConn": 8
}
let isSuccess1 = wifi.setHotspotConfig(HotspotConfigWO);
console.log("[wifi_test] set a psk preSharedKey hotspot config result1: " + isSuccess1);
expect(isSuccess1).assertTrue();
await sleep(5000);
let config = wifi.getHotspotConfig();
console.info("[wifi_test] getHotspotConfig result -> " + JSON.stringify(config));
expect(config.ssid).assertEqual('WIFITEST');
done();
})
/**
* @tc.number CONN_0002
* @tc.name SUB_Communication_WiFi_Hotspot_Conn_0002
* @tc.desc Test Obtains the list of clients that are connected to a Wi-Fi hotspot.
* @tc.level Level 2
*/
it('SUB_Communication_WiFi_Hotspot_Conn_0002', 0, async function (done) {
await tryToDisableWifi();
if (!wifi.isHotspotActive()) {
let on = wifi.enableHotspot();
await sleep(5000);
expect(on).assertTrue();
}
let isHotspotActive = wifi.isHotspotActive();
console.info("[wifi_test] isHotspotActive -> " + isHotspotActive);
expect(isHotspotActive).assertTrue();
let stationInfo = wifi.getStations();
console.info("[wifi_test] getStations result ->" + JSON.stringify(stationInfo));
console.info("ssid: " + stationInfo.name +
"macAddress: " + stationInfo.macAddress +
"ipAddress: " + stationInfo.ipAddress);
expect(stationInfo.length).assertEqual(0);
done();
})
/**
* @tc.number SUB_Communication_WiFi_Hotspot_ON_0001
* @tc.name testhotspotStateChangeOn
* @tc.desc Test hotspotStateChangeOn api.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
*/
it('SUB_Communication_WiFi_Hotspot_ON_0001', 0, async function (done) {
console.info("[wifi_test]hotspotStateChange On test");
try {
await wifi.on('hotspotStateChange', (data) => {
console.info("[wifi_test] hotspotStateChange On ->" + data);
expect(true).assertEqual(data != null);
});
}catch(e) {
expect(null).assertFail();
}
done();
})
/**
* @tc.number SUB_Communication_WiFi_Hotspot_Off_0002
* @tc.name testhotspotStateChangeOff
* @tc.desc Test hotspotStateChange api.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
*/
it('SUB_Communication_WiFi_Sta_Off_0002', 0, async function (done) {
try {
await wifi.off('hotspotStateChange', (data) => {
console.info("[wifi_test] hotspotStateChange Off ->" + data);
expect(true).assertEqual(data != null);
console.info("[wifi_test] wifiRssiChange unregister end");
});
}catch(e) {
expect(null).assertFail();
}
done();
})
/**
* @tc.number SUB_Communication_WiFi_Hotspot_ON_0003
* @tc.name testhotspotStaJoinOn
* @tc.desc Test hotspotStaJoinOn api.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
*/
it('SUB_Communication_WiFi_Hotspot_ON_0003', 0, async function (done) {
console.info("[wifi_test]hotspotStaJoin On test");
try {
await wifi.on('hotspotStaJoin', (data) => {
console.info("[wifi_test] hotspotStaJoin On ->" + data);
expect(true).assertEqual(data != null);
});
}catch(e) {
expect(null).assertFail();
}
done();
})
/**
* @tc.number SUB_Communication_WiFi_Hotspot_Off_0004
* @tc.name testhotspotStaJoinOff
* @tc.desc Test hotspotStaJoin api.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
*/
it('SUB_Communication_WiFi_Sta_Off_0004', 0, async function (done) {
try {
await wifi.off('hotspotStaJoin', (data) => {
console.info("[wifi_test] hotspotStaJoin Off ->" + data);
expect(true).assertEqual(data != null);
console.info("[wifi_test] wifiRssiChange unregister end");
});
}catch(e) {
expect(null).assertFail();
}
done();
})
/**
* @tc.number SUB_Communication_WiFi_Hotspot_ON_0005
* @tc.name testhotspotStaLeaveOn
* @tc.desc Test hotspotStaLeaveOn api.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
*/
it('SUB_Communication_WiFi_Hotspot_ON_0005', 0, async function (done) {
console.info("[wifi_test]hotspotStaLeave On test");
try {
await wifi.on('hotspotStaLeave', (data) => {
console.info("[wifi_test] hotspotStaLeave On ->" + data);
expect(true).assertEqual(data != null);
});
}catch(e) {
expect(null).assertFail();
}
done();
})
/**
* @tc.number SUB_Communication_WiFi_Hotspot_Off_0006
* @tc.name testhotspotStaLeaveOff
* @tc.desc Test hotspotStaLeave api.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
*/
it('SUB_Communication_WiFi_Hotspot_Off_0006', 0, async function (done) {
try {
await wifi.off('hotspotStaLeave', (data) => {
console.info("[wifi_test] hotspotStaLeave Off ->" + data);
expect(true).assertEqual(data != null);
console.info("[wifi_test] hotspotStaLeave unregister end");
});
}catch(e) {
expect(null).assertFail();
}
done();
})
console.log("*************[wifi_test] start wifi js unit test end*************");
})
...@@ -21,12 +21,9 @@ function sleep(delay) { ...@@ -21,12 +21,9 @@ function sleep(delay) {
return new Promise(resovle => setTimeout(resovle, delay)) return new Promise(resovle => setTimeout(resovle, delay))
} }
async function tryToEnableWifi(){ function checkWifiPowerOn(){
if(!wifi.isWifiActive()){
console.info("wifi_test/enable wifi:" + wifi.enableWifi());
await sleep(3000);
}
console.info("wifi_test/wifi status:" + wifi.isWifiActive()); console.info("wifi_test/wifi status:" + wifi.isWifiActive());
expect(wifi.isWifiActive()).assertTrue();
} }
let GroupOwnerBand = { let GroupOwnerBand = {
...@@ -42,27 +39,13 @@ describe('ACTS_WifiTest', function () { ...@@ -42,27 +39,13 @@ describe('ACTS_WifiTest', function () {
afterEach(function () { afterEach(function () {
}) })
/**
* @tc.number Setting_0001
* @tc.name SUB_Communication_WiFi_P2P_Setting_0001
* @tc.desc Test setDeviceName infos
*/
it('SUB_Communication_WiFi_P2P_Setting_0001', 0, async function(done) {
await tryToEnableWifi();
console.info("[wifi_test] test setDeviceName start.");
let devName = wifi.setDeviceName("P2PTest");
console.info("[wifi_test] test start setDeviceName->" + devName);
expect(devName).assertTrue();
done();
})
/** /**
* @tc.number config_0001 * @tc.number config_0001
* @tc.name SUB_Communication_WiFi_P2P_Config_0001 * @tc.name SUB_Communication_WiFi_P2P_Config_0001
* @tc.desc Test createGroup and getCurrentGroup promise infos * @tc.desc Test createGroup and getCurrentGroup promise infos
*/ */
it('SUB_Communication_WiFi_P2P_Config_0001', 0, async function(done) { it('SUB_Communication_WiFi_P2P_Config_0001', 0, async function(done) {
await tryToEnableWifi(); checkWifiPowerOn();
let WifiP2PConfig = { let WifiP2PConfig = {
deviceAddress : "00:00:00:00:00:00", deviceAddress : "00:00:00:00:00:00",
netId : -1, netId : -1,
...@@ -95,7 +78,7 @@ describe('ACTS_WifiTest', function () { ...@@ -95,7 +78,7 @@ describe('ACTS_WifiTest', function () {
* @tc.desc Test getCurrentGroup callback infos * @tc.desc Test getCurrentGroup callback infos
*/ */
it('SUB_Communication_WiFi_P2P_Config_0002', 0, async function(done) { it('SUB_Communication_WiFi_P2P_Config_0002', 0, async function(done) {
await tryToEnableWifi(); checkWifiPowerOn();
let WifiP2PConfig = { let WifiP2PConfig = {
deviceAddress : "00:00:00:00:00:00", deviceAddress : "00:00:00:00:00:00",
netId : -1, netId : -1,
...@@ -139,7 +122,7 @@ describe('ACTS_WifiTest', function () { ...@@ -139,7 +122,7 @@ describe('ACTS_WifiTest', function () {
* @tc.desc Test createGroup 2.4G band and getCurrentGroup infos * @tc.desc Test createGroup 2.4G band and getCurrentGroup infos
*/ */
it('SUB_Communication_WiFi_P2P_Config_0003', 0, async function(done) { it('SUB_Communication_WiFi_P2P_Config_0003', 0, async function(done) {
await tryToEnableWifi(); checkWifiPowerOn();
let WifiP2PConfig2 = { let WifiP2PConfig2 = {
deviceAddress : "00:00:00:00:00:00", deviceAddress : "00:00:00:00:00:00",
netId : -1, netId : -1,
...@@ -170,10 +153,10 @@ describe('ACTS_WifiTest', function () { ...@@ -170,10 +153,10 @@ describe('ACTS_WifiTest', function () {
/** /**
* @tc.number config_0004 * @tc.number config_0004
* @tc.name SUB_Communication_WiFi_P2P_Config_0004 * @tc.name SUB_Communication_WiFi_P2P_Config_0004
* @tc.desc Test createGroup and deletePersistentGroup infos * @tc.desc Test create PersistentGroup infos
*/ */
it('SUB_Communication_WiFi_P2P_Config_0004', 0, async function(done) { it('SUB_Communication_WiFi_P2P_Config_0004', 0, async function(done) {
await tryToEnableWifi(); checkWifiPowerOn();
let WifiP2PConfig = { let WifiP2PConfig = {
deviceAddress : "00:00:00:00:00:00", deviceAddress : "00:00:00:00:00:00",
netId : -2, netId : -2,
...@@ -193,9 +176,6 @@ describe('ACTS_WifiTest', function () { ...@@ -193,9 +176,6 @@ describe('ACTS_WifiTest', function () {
console.info("[wifi_test] getCurrentGroup [promise] result -> " + JSON.stringify(data)); console.info("[wifi_test] getCurrentGroup [promise] result -> " + JSON.stringify(data));
expect(true).assertEqual(resultLength!=0); expect(true).assertEqual(resultLength!=0);
let removePConfig = wifi.deletePersistentGroup(data.networkId);
expect(removePConfig).assertTrue();
let removeConfig = wifi.removeGroup(); let removeConfig = wifi.removeGroup();
expect(removeConfig).assertTrue(); expect(removeConfig).assertTrue();
}); });
...@@ -208,7 +188,7 @@ describe('ACTS_WifiTest', function () { ...@@ -208,7 +188,7 @@ describe('ACTS_WifiTest', function () {
* @tc.desc Test p2pConnect infos * @tc.desc Test p2pConnect infos
*/ */
it('SUB_Communication_WiFi_P2P_Config_0005', 0, async function(done) { it('SUB_Communication_WiFi_P2P_Config_0005', 0, async function(done) {
await tryToEnableWifi(); checkWifiPowerOn();
let WifiP2PConfig3 = { let WifiP2PConfig3 = {
deviceAddress : "00:00:00:00:00:00", deviceAddress : "00:00:00:00:00:00",
netId : -2, netId : -2,
...@@ -237,7 +217,7 @@ describe('ACTS_WifiTest', function () { ...@@ -237,7 +217,7 @@ describe('ACTS_WifiTest', function () {
* @tc.desc Test getP2pLinkedInfo promise infos * @tc.desc Test getP2pLinkedInfo promise infos
*/ */
it('SUB_Communication_WiFi_P2P_Config_0006', 0, async function(done) { it('SUB_Communication_WiFi_P2P_Config_0006', 0, async function(done) {
await tryToEnableWifi(); checkWifiPowerOn();
let P2pConnectState = { let P2pConnectState = {
DISCONNECTED :0, DISCONNECTED :0,
CONNECTED : 1, CONNECTED : 1,
...@@ -261,7 +241,7 @@ describe('ACTS_WifiTest', function () { ...@@ -261,7 +241,7 @@ describe('ACTS_WifiTest', function () {
* @tc.desc Test getP2pLinkedInfo callback infos * @tc.desc Test getP2pLinkedInfo callback infos
*/ */
it('SUB_Communication_WiFi_P2P_Config_0007', 0, async function(done) { it('SUB_Communication_WiFi_P2P_Config_0007', 0, async function(done) {
await tryToEnableWifi(); checkWifiPowerOn();
let P2pConnectState = { let P2pConnectState = {
DISCONNECTED :0, DISCONNECTED :0,
CONNECTED : 1, CONNECTED : 1,
...@@ -287,7 +267,7 @@ describe('ACTS_WifiTest', function () { ...@@ -287,7 +267,7 @@ describe('ACTS_WifiTest', function () {
* @tc.desc Test p2pCancelConnect infos * @tc.desc Test p2pCancelConnect infos
*/ */
it('SUB_Communication_WiFi_P2P_Config_0008', 0, async function(done) { it('SUB_Communication_WiFi_P2P_Config_0008', 0, async function(done) {
await tryToEnableWifi(); checkWifiPowerOn();
let disConn = wifi.p2pCancelConnect(); let disConn = wifi.p2pCancelConnect();
await sleep(2000); await sleep(2000);
console.info("[wifi_test] test p2pCancelConnect result." + disConn); console.info("[wifi_test] test p2pCancelConnect result." + disConn);
...@@ -304,7 +284,7 @@ describe('ACTS_WifiTest', function () { ...@@ -304,7 +284,7 @@ describe('ACTS_WifiTest', function () {
* @tc.desc Test getP2pPeerDevices infos * @tc.desc Test getP2pPeerDevices infos
*/ */
it('SUB_Communication_WiFi_P2P_Config_0009', 0, async function(done){ it('SUB_Communication_WiFi_P2P_Config_0009', 0, async function(done){
await tryToEnableWifi(); checkWifiPowerOn();
let P2pDeviceStatus = { let P2pDeviceStatus = {
CONNECTED : 0, CONNECTED : 0,
INVITED : 1, INVITED : 1,
...@@ -337,7 +317,7 @@ describe('ACTS_WifiTest', function () { ...@@ -337,7 +317,7 @@ describe('ACTS_WifiTest', function () {
* @tc.desc Test getP2pPeerDevices infos * @tc.desc Test getP2pPeerDevices infos
*/ */
it('SUB_Communication_WiFi_P2P_Config_0010', 0, async function(done){ it('SUB_Communication_WiFi_P2P_Config_0010', 0, async function(done){
await tryToEnableWifi(); checkWifiPowerOn();
let P2pDeviceStatus = { let P2pDeviceStatus = {
CONNECTED : 0, CONNECTED : 0,
INVITED : 1, INVITED : 1,
...@@ -393,7 +373,7 @@ describe('ACTS_WifiTest', function () { ...@@ -393,7 +373,7 @@ describe('ACTS_WifiTest', function () {
* @tc.desc Test p2pStateChange callback * @tc.desc Test p2pStateChange callback
*/ */
it('SUB_Communication_WiFi_P2P_P2pStateChange_0001', 0, async function (done) { it('SUB_Communication_WiFi_P2P_P2pStateChange_0001', 0, async function (done) {
await tryToEnableWifi(); checkWifiPowerOn();
await wifi.on('p2pStateChange', result => { await wifi.on('p2pStateChange', result => {
console.info("onP2pStateChange callback, result:" + JSON.stringify(result)); console.info("onP2pStateChange callback, result:" + JSON.stringify(result));
expect(true).assertEqual(result !=null); expect(true).assertEqual(result !=null);
...@@ -415,7 +395,7 @@ describe('ACTS_WifiTest', function () { ...@@ -415,7 +395,7 @@ describe('ACTS_WifiTest', function () {
* @tc.desc Test p2pConnectionChange callback * @tc.desc Test p2pConnectionChange callback
*/ */
it('SUB_Communication_WiFi_P2P_p2pConnectionChange_0002', 0, async function (done) { it('SUB_Communication_WiFi_P2P_p2pConnectionChange_0002', 0, async function (done) {
await tryToEnableWifi(); checkWifiPowerOn();
await wifi.on('p2pConnectionChange', recvP2pConnectionChangeFunc => { await wifi.on('p2pConnectionChange', recvP2pConnectionChangeFunc => {
console.info("[wifi_test] p2pConnectionChange result -> " + recvP2pConnectionChangeFunc); console.info("[wifi_test] p2pConnectionChange result -> " + recvP2pConnectionChangeFunc);
expect(true).assertEqual(recvP2pConnectionChangeFunc !=null); expect(true).assertEqual(recvP2pConnectionChangeFunc !=null);
...@@ -459,7 +439,7 @@ describe('ACTS_WifiTest', function () { ...@@ -459,7 +439,7 @@ describe('ACTS_WifiTest', function () {
* @tc.desc Test p2pPeerDeviceChange callback * @tc.desc Test p2pPeerDeviceChange callback
*/ */
it('SUB_Communication_WiFi_P2P_p2pPeerDeviceChange_0004', 0, async function (done) { it('SUB_Communication_WiFi_P2P_p2pPeerDeviceChange_0004', 0, async function (done) {
await tryToEnableWifi(); checkWifiPowerOn();
let recvP2pPeerDeviceChangeFunc = result => { let recvP2pPeerDeviceChangeFunc = result => {
console.info("wifi_test / p2p peer device change receive event: " + JSON.stringify(result)); console.info("wifi_test / p2p peer device change receive event: " + JSON.stringify(result));
wifi.getP2pDevices((err, data) => { wifi.getP2pDevices((err, data) => {
...@@ -505,7 +485,7 @@ describe('ACTS_WifiTest', function () { ...@@ -505,7 +485,7 @@ describe('ACTS_WifiTest', function () {
* @tc.desc Test p2pPersistentGroupChange callback * @tc.desc Test p2pPersistentGroupChange callback
*/ */
it('SUB_Communication_WiFi_P2P_p2pPersistentGroupChange_0005', 0, async function (done) { it('SUB_Communication_WiFi_P2P_p2pPersistentGroupChange_0005', 0, async function (done) {
await tryToEnableWifi(); checkWifiPowerOn();
let recvP2pPersistentGroupChangeFunc = result => { let recvP2pPersistentGroupChangeFunc = result => {
console.info("wifi_test / p2p persistent group change receive event" + JSON.stringify(result)); console.info("wifi_test / p2p persistent group change receive event" + JSON.stringify(result));
let config = { let config = {
...@@ -545,7 +525,7 @@ describe('ACTS_WifiTest', function () { ...@@ -545,7 +525,7 @@ describe('ACTS_WifiTest', function () {
* @tc.desc Test p2pDiscoveryChange callback * @tc.desc Test p2pDiscoveryChange callback
*/ */
it('SUB_Communication_WiFi_P2P_p2pDiscoveryChange_0006', 0, async function (done) { it('SUB_Communication_WiFi_P2P_p2pDiscoveryChange_0006', 0, async function (done) {
await tryToEnableWifi(); checkWifiPowerOn();
await wifi.on('p2pDiscoveryChange', result => { await wifi.on('p2pDiscoveryChange', result => {
console.info("onp2pDiscoveryChange callback, result:" + JSON.stringify(result)); console.info("onp2pDiscoveryChange callback, result:" + JSON.stringify(result));
expect(true).assertEqual(result !=null); expect(true).assertEqual(result !=null);
...@@ -564,3 +544,4 @@ describe('ACTS_WifiTest', function () { ...@@ -564,3 +544,4 @@ describe('ACTS_WifiTest', function () {
}) })
...@@ -21,13 +21,6 @@ function sleep(delay) { ...@@ -21,13 +21,6 @@ function sleep(delay) {
return new Promise(resovle => setTimeout(resovle, delay)) return new Promise(resovle => setTimeout(resovle, delay))
} }
async function tryToEnableWifi(){
if(!wifi.isWifiActive()){
console.info("wifi_test/enable wifi:" + wifi.enableWifi());
await sleep(3000);
}
console.info("wifi_test/wifi status:" + wifi.isWifiActive());
}
let WifiSecurityType = { let WifiSecurityType = {
WIFI_SEC_TYPE_INVALID: 0, WIFI_SEC_TYPE_INVALID: 0,
...@@ -37,19 +30,9 @@ let WifiSecurityType = { ...@@ -37,19 +30,9 @@ let WifiSecurityType = {
WIFI_SEC_TYPE_SAE: 4, WIFI_SEC_TYPE_SAE: 4,
} }
let SuppState = { function checkWifiPowerOn(){
DISCONNECTED: 0, console.info("wifi_test/wifi status:" + wifi.isWifiActive());
INTERFACE_DISABLED: 1, expect(wifi.isWifiActive()).assertTrue();
INACTIVE : 2,
SCANNING: 3,
AUTHENTICATING: 4,
ASSOCIATING: 5,
ASSOCIATED: 6,
FOUR_WAY_HANDSHAKE: 7,
GROUP_HANDSHAKE: 8,
COMPLETED: 9,
UNINITIALIZED: 10,
INVALID: 11,
} }
let ConnState = { let ConnState = {
...@@ -70,14 +53,10 @@ let ipConfig = { ...@@ -70,14 +53,10 @@ let ipConfig = {
"domains": ["aaa"], "domains": ["aaa"],
} }
let IpType = {
STATIC : 0,
DHCP : 1,
UNKNOWN: 2
}
describe('ACTS_WifiTest', function() { describe('ACTS_WifiTest', function() {
beforeEach(function() {}) beforeEach(function() {
checkWifiPowerOn();
})
afterEach(function() {}) afterEach(function() {})
...@@ -86,23 +65,11 @@ describe('ACTS_WifiTest', function() { ...@@ -86,23 +65,11 @@ describe('ACTS_WifiTest', function() {
* @tc.name SUB_Communication_WiFi_Sta_Open_0001 * @tc.name SUB_Communication_WiFi_Sta_Open_0001
* @tc.desc Test wifi.isWifiEnable API functionality. * @tc.desc Test wifi.isWifiEnable API functionality.
*/ */
it('SUB_Communication_WiFi_Sta_Open_0001', 0, async function(done) { it('SUB_Communication_WiFi_Sta_Open_0001', 0, function() {
console.info("[wifi_test] check the state of wifi, if it's close, open it."); console.info("[wifi_test] check the state of wifi, if it's close, open it.");
let active = wifi.isWifiActive(); let active = wifi.isWifiActive();
if (!active) {
let enable = wifi.enableWifi();
await sleep(5000);
console.log("[wifi_test] wifi open result: " + enable);
expect(enable).assertTrue();
}
let disable = wifi.disableWifi();
await sleep(5000);
console.log("[wifi_test] wifi close result: " + disable);
expect(disable).assertTrue();
console.log("[wifi_test] check the state of wifi: " + wifi.isWifiActive()); console.log("[wifi_test] check the state of wifi: " + wifi.isWifiActive());
expect(wifi.isWifiActive()).assertFalse(); expect(wifi.isWifiActive()).assertTrue();
done();
}) })
/** /**
...@@ -111,7 +78,6 @@ describe('ACTS_WifiTest', function() { ...@@ -111,7 +78,6 @@ describe('ACTS_WifiTest', function() {
* @tc.desc Test get ScanInfos callback API functionality. * @tc.desc Test get ScanInfos callback API functionality.
*/ */
it('SUB_Communication_WiFi_Sta_Scan_0001', 0, async function(done) { it('SUB_Communication_WiFi_Sta_Scan_0001', 0, async function(done) {
await tryToEnableWifi();
let scan = wifi.scan(); let scan = wifi.scan();
await sleep(3000); await sleep(3000);
console.log("[wifi_test] open wifi scan result: " + scan); console.log("[wifi_test] open wifi scan result: " + scan);
...@@ -151,8 +117,7 @@ describe('ACTS_WifiTest', function() { ...@@ -151,8 +117,7 @@ describe('ACTS_WifiTest', function() {
* @tc.name SUB_Communication_WiFi_Sta_Scan_0004 * @tc.name SUB_Communication_WiFi_Sta_Scan_0004
* @tc.desc Test wifi.getSignalLevel API functionality. * @tc.desc Test wifi.getSignalLevel API functionality.
*/ */
it('SUB_Communication_WiFi_Sta_Scan_0004', 0, async function(done) { it('SUB_Communication_WiFi_Sta_Scan_0004', 0, function() {
await tryToEnableWifi();
console.info("[wifi_test] check the 2.4G rssi assgined to level test."); console.info("[wifi_test] check the 2.4G rssi assgined to level test.");
expect(wifi.getSignalLevel(-65, 1)).assertEqual(4); expect(wifi.getSignalLevel(-65, 1)).assertEqual(4);
...@@ -182,496 +147,9 @@ describe('ACTS_WifiTest', function() { ...@@ -182,496 +147,9 @@ describe('ACTS_WifiTest', function() {
expect(wifi.getSignalLevel(-86, 2)).assertEqual(0); expect(wifi.getSignalLevel(-86, 2)).assertEqual(0);
expect(wifi.getSignalLevel(-127, 2)).assertEqual(0); expect(wifi.getSignalLevel(-127, 2)).assertEqual(0);
done();
})
/**
* @tc.number Config_0001
* @tc.name SUB_Communication_WiFi_Sta_Config_0001
* @tc.desc Test create a OPEN SecurityType wifi device config
*/
it('SUB_Communication_WiFi_Sta_Config_0001', 0, async function(done) {
await tryToEnableWifi();
wifi.removeAllNetwork();
let wifiDeviceConfig1 = {
"ssid": "TEST_OPEN",
"bssid": "",
"preSharedKey": "",
"isHiddenSsid": false,
"securityType": WifiSecurityType.WIFI_SEC_TYPE_OPEN,
"netId": -1,
"ipType": IpType.DHCP,
"creatorUid": 7,
"disableReason": 0,
"randomMacType": 0,
"randomMacAddr": "11:22:33:44:55:66",
"staticIp": ipConfig,
};
await wifi.addDeviceConfig(wifiDeviceConfig1)
.then(netWorkId => {
console.info("[wifi_test]add OPEN Deviceconfig promise : " + JSON.stringify(netWorkId));
expect(true).assertEqual(netWorkId != -1);
let configs = wifi.getDeviceConfigs();
console.info("[wifi_test] wifi getDeviceConfigs result1 : " + JSON.stringify(configs));
expect(true).assertEqual(configs[0].securityType == wifiDeviceConfig1.securityType);
expect(true).assertEqual(configs[0].isHiddenSsid == wifiDeviceConfig1.isHiddenSsid);
expect(true).assertEqual(configs[0].ssid == wifiDeviceConfig1.ssid);
});
wifi.addDeviceConfig(wifiDeviceConfig1,
(err, netWorkId) => {
if(err) {
console.info("[wifi_test]add OPEN callback failed : " + JSON.stringify(err));
return;
}
console.info("[wifi_test]add OPEN Deviceconfig callback : " + JSON.stringify(netWorkId));
expect(true).assertEqual(netWorkId != -1);
let configs1 = wifi.getDeviceConfigs();
console.info("[wifi_test] wifi getDeviceConfigs result2 : " + JSON.stringify(configs1));
expect(true).assertEqual(configs1[0].securityType == wifiDeviceConfig1.securityType);
expect(true).assertEqual(configs1[0].isHiddenSsid == wifiDeviceConfig1.isHiddenSsid);
expect(true).assertEqual(configs1[0].ssid == wifiDeviceConfig1.ssid);
let isRemoved = wifi.removeAllNetwork();
expect(isRemoved).assertTrue();
let configs2 = wifi.getDeviceConfigs();
expect(true).assertEqual(configs2.length == 0);
done()
});
})
/**
* @tc.number Config_0002
* @tc.name SUB_Communication_WiFi_Sta_Config_0002
* @tc.desc Test create a PSK SecurityType wifi device config
*/
it('SUB_Communication_WiFi_Sta_Config_0002', 0, async function(done) {
await tryToEnableWifi();
let wifiDeviceConfig1 = {
"ssid": "TEST_PSK",
"bssid": "",
"preSharedKey": "12345678",
"isHiddenSsid": false,
"securityType": WifiSecurityType.WIFI_SEC_TYPE_PSK,
"netId": -1,
"ipType": 1,
"creatorUid": 7,
"disableReason": 0,
"randomMacType": 0,
"randomMacAddr": "11:22:33:44:55:66",
"staticIp": {"ipAddress": 1284752956,"gateway": 1284752936},
};
await wifi.addDeviceConfig(wifiDeviceConfig1)
.then(netWorkId => {
console.info("[wifi_test]add PSK Deviceconfig promise : " + JSON.stringify(netWorkId));
expect(true).assertEqual(netWorkId != -1);
let configs = wifi.getDeviceConfigs();
console.info("[wifi_test] wifi getDeviceConfigs result1 : " + JSON.stringify(configs));
expect(true).assertEqual(configs[0].securityType == wifiDeviceConfig1.securityType);
expect(true).assertEqual(configs[0].isHiddenSsid == wifiDeviceConfig1.isHiddenSsid);
expect(true).assertEqual(configs[0].preSharedKey == wifiDeviceConfig1.preSharedKey);
expect(true).assertEqual(configs[0].ssid == wifiDeviceConfig1.ssid);
let isRemoved = wifi.removeDevice(netWorkId);
expect(isRemoved).assertTrue();
let configs1 = wifi.getDeviceConfigs();
console.info("[wifi_test]remove config,current getConfig: " + JSON.stringify(configs1));
expect(true).assertEqual(configs1.length == 0);
});
done()
}) })
/**
* @tc.number Config_0003
* @tc.name SUB_Communication_WiFi_Sta_Config_0003
* @tc.desc Test create a WEP SecurityType wifi device config
*/
it('SUB_Communication_WiFi_Sta_Config_0003', 0, async function(done) {
await tryToEnableWifi();
let wifiDeviceConfig1 = {
"ssid": "TEST_WEP",
"bssid": "",
"preSharedKey": "ABCDEF1234",
"isHiddenSsid": false,
"securityType": WifiSecurityType.WIFI_SEC_TYPE_WEP,
"netId": -1,
"ipType": 1,
"creatorUid": 7,
"disableReason": 0,
"randomMacType": 0,
"randomMacAddr": "11:22:33:44:55:66",
"staticIp": {"ipAddress": 1284752956,"gateway": 1284752936},
};
await wifi.addDeviceConfig(wifiDeviceConfig1)
.then(netWorkId => {
console.info("[wifi_test]add WEP Deviceconfig promise : " + JSON.stringify(netWorkId));
expect(true).assertEqual(netWorkId != -1);
let configs = wifi.getDeviceConfigs();
console.info("[wifi_test]connectdevice result: " + wifi.connectToNetwork(netWorkId));
expect(wifi.connectToNetwork(netWorkId)).assertTrue();
console.info("[wifi_test] wifi getDeviceConfigs result1 : " + JSON.stringify(configs));
expect(true).assertEqual(configs[0].securityType == wifiDeviceConfig1.securityType);
expect(true).assertEqual(configs[0].isHiddenSsid == wifiDeviceConfig1.isHiddenSsid);
expect(true).assertEqual(configs[0].preSharedKey == wifiDeviceConfig1.preSharedKey);
expect(true).assertEqual(configs[0].ssid == wifiDeviceConfig1.ssid);
let isRemoved = wifi.removeDevice(netWorkId);
expect(isRemoved).assertTrue();
let configs1 = wifi.getDeviceConfigs();
expect(true).assertEqual(configs1.length == 0);
});
done()
})
/**
* @tc.number Config_0004
* @tc.name SUB_Communication_WiFi_Sta_Config_0004
* @tc.desc Test remove all wifi device config
*/
it('SUB_Communication_WiFi_Sta_Config_0004', 0, async function(done) {
await tryToEnableWifi();
let wifiDeviceConfig1 = {
"ssid": "TESTWgr1",
"bssid": "",
"preSharedKey": "123456789",
"isHiddenSsid": false,
"securityType": WifiSecurityType.WIFI_SEC_TYPE_PSK,
};
let wifiDeviceConfig2 = {
"ssid": "TESTWgr2",
"bssid": "",
"preSharedKey": "",
"isHiddenSsid": false,
"securityType": WifiSecurityType.WIFI_SEC_TYPE_OPEN,
};
let promiseOne = new Promise((resolve, reject) => {
wifi.addDeviceConfig(wifiDeviceConfig1,
(err,netWorkId1) => {
if(err) {
console.info("[wifi_test]add callback failed : " + JSON.stringify(err));
return;
}
console.info("[wifi_test] wifi addDeviceconfig1 callback:" + JSON.stringify(netWorkId1));
expect(true).assertEqual(netWorkId1 != -1);
let configs = wifi.getDeviceConfigs();
console.info("[wifi_test] wifi getDeviceConfigs result : " + JSON.stringify(configs));
resolve()
});
})
let promiseTwo = new Promise((resolve, reject) => {
wifi.addDeviceConfig(wifiDeviceConfig2,
(err,netWorkId2) => {
if(err) {
console.info("[wifi_test]add callback failed : " + JSON.stringify(err));
return;
}
console.info("[wifi_test] wifi addDeviceconfig2 callback : " + JSON.stringify(netWorkId2));
expect(true).assertEqual(netWorkId2 != -1);
let configs1 = wifi.getDeviceConfigs();
console.info("[wifi_test] wifi getDeviceConfigs result : " + JSON.stringify(configs1));
expect(true).assertEqual(configs1.length >= 1);
let isRemoved = wifi.removeAllNetwork();
expect(isRemoved).assertTrue();
let configs2 = wifi.getDeviceConfigs();
expect(true).assertEqual(configs2.length == 0);
resolve()
});
})
await promiseOne.then(()=>{
return promiseTwo
}).then(done)
})
/**
* @tc.number Config_0005
* @tc.name SUB_Communication_WiFi_Sta_Config_0005
* @tc.desc Test disableNetwork device config
*/
it('SUB_Communication_WiFi_Sta_Config_0005', 0, async function(done) {
await tryToEnableWifi();
let wifiDeviceConfigD = {
"ssid": "TESTD",
"bssid": "",
"preSharedKey": "12345678",
"isHiddenSsid": false,
"securityType": WifiSecurityType.WIFI_SEC_TYPE_PSK,
"netId": -1,
"ipType": 1,
"creatorUid": 7,
"disableReason": 0,
"randomMacType": 0,
"randomMacAddr": "11:22:33:44:55:66",
"staticIp": {"ipAddress": 1284752956,"gateway": 1284752936},
};
await wifi.addDeviceConfig(wifiDeviceConfigD)
.then(netWorkId => {
console.info("[wifi_test]add PSK Deviceconfig promise : " + JSON.stringify(netWorkId));
expect(true).assertEqual(netWorkId != -1);
expect(wifi.connectToNetwork(netWorkId)).assertTrue();
let disconNet = wifi.disableNetwork(netWorkId);
expect(disconNet).assertTrue();
let configs = wifi.getDeviceConfigs();
console.info("[wifi_test] wifi device config result : " + JSON.stringify(configs));
expect(true).assertEqual(configs[0].ssid == wifiDeviceConfigD.ssid);
let isRemoved = wifi.removeAllNetwork();
expect(isRemoved).assertTrue();
let configs1 = wifi.getDeviceConfigs();
expect(true).assertEqual(configs1.length == 0);
});
done()
})
/**
* @tc.number Config_0006
* @tc.name SUB_Communication_WiFi_Sta_Config_0006
* @tc.desc Test update wifi device config
*/
it('SUB_Communication_WiFi_Sta_Config_0006', 0, async function(done) {
await tryToEnableWifi();
let wifiDeviceConfigU = {
"ssid": "TEST",
"bssid": "",
"preSharedKey": "12345678",
"isHiddenSsid": false,
"securityType": WifiSecurityType.WIFI_SEC_TYPE_PSK,
"netId": -1,
"ipType": 1,
"creatorUid": 7,
"disableReason": 0,
"randomMacType": 0,
"randomMacAddr": "11:22:33:44:55:66",
"staticIp": {"ipAddress": 1284752956,"gateway": 1284752936},
};
await wifi.addDeviceConfig(wifiDeviceConfigU)
.then(netWorkId => {
console.info("[wifi_test]add PSK Deviceconfig promise : " + JSON.stringify(netWorkId));
expect(true).assertEqual(netWorkId != -1);
let configs = wifi.getDeviceConfigs();
console.info("[wifi_test] wifi getDeviceConfigs result1 : " + JSON.stringify(configs));
wifiDeviceConfigU.ssid = "UPDATE";
wifiDeviceConfigU.preSharedKey = "1234567890";
expect(true).assertEqual(wifi.updateNetwork(wifiDeviceConfigU) >= 0);
let configs1 = wifi.getDeviceConfigs();
console.info("[wifi_test] updated wifi device config result : " + JSON.stringify(configs1));
expect(true).assertEqual(configs1[1].ssid == wifiDeviceConfigU.ssid);
expect(true).assertEqual(configs1[1].preSharedKey == wifiDeviceConfigU.preSharedKey);
let isRemoved = wifi.removeAllNetwork();
expect(isRemoved).assertTrue();
let configs2 = wifi.getDeviceConfigs();
expect(true).assertEqual(configs2.length == 0);
});
done()
})
/**
* @tc.number Config_SSID_0001
* @tc.name SSUB_Communication_WiFi_Sta_Conn_SSID_0001
* @tc.desc Test SSID wifi device config
*/
it('SSUB_Communication_WiFi_Sta_Conn_SSID_0001', 0, async function(done) {
await tryToEnableWifi();
let wifiDeviceConfigZ = {
"ssid": "中文测试SSID",
"bssid": "",
"preSharedKey": "12345678",
"isHiddenSsid": false,
"securityType": WifiSecurityType.WIFI_SEC_TYPE_PSK,
"netId": -1,
"ipType": 1,
"creatorUid": 7,
"disableReason": 0,
"randomMacType": 0,
"randomMacAddr": "11:22:33:44:55:66",
"staticIp": {"ipAddress": 1284752956,"gateway": 1284752936},
};
await wifi.addDeviceConfig(wifiDeviceConfigZ)
.then(netWorkId => {
console.info("[wifi_test]add contains chinese Deviceconfig promise : " + JSON.stringify(netWorkId));
expect(true).assertEqual(netWorkId != -1);
expect(wifi.connectToNetwork(netWorkId)).assertTrue();
let disconNet = wifi.disableNetwork(netWorkId);
expect(disconNet).assertTrue();
let configs = wifi.getDeviceConfigs();
console.info("[wifi_test] wifi getDeviceConfigs result1 : " + JSON.stringify(configs));
expect(true).assertEqual(configs[0].ssid == wifiDeviceConfigZ.ssid);
expect(true).assertEqual(configs[0].preSharedKey == wifiDeviceConfigZ.preSharedKey);
let isRemoved = wifi.removeAllNetwork();
expect(isRemoved).assertTrue();
let configs1 = wifi.getDeviceConfigs();
console.info("[wifi_test]remove config,current get Config : " + JSON.stringify(configs1));
expect(true).assertEqual(configs1.length == 0);
});
done()
})
/**
* @tc.number Config_SSID_0002
* @tc.name SSUB_Communication_WiFi_Sta_Conn_SSID_0002
* @tc.desc Test SSID wifi device config
*/
it('SSUB_Communication_WiFi_Sta_Conn_SSID_0002', 0, async function(done) {
await tryToEnableWifi();
let wifiDeviceConfigK = {
"ssid": "test text",
"bssid": "",
"preSharedKey": "12345678",
"isHiddenSsid": false,
"securityType": WifiSecurityType.WIFI_SEC_TYPE_PSK,
"netId": -1,
"ipType": 1,
"creatorUid": 7,
"disableReason": 0,
"randomMacType": 0,
"randomMacAddr": "11:22:33:44:55:66",
"staticIp": {"ipAddress": 1284752956,"gateway": 1284752936},
};
await wifi.addDeviceConfig(wifiDeviceConfigK)
.then(netWorkId => {
console.info("[wifi_test]add kongge SSID Deviceconfig promise : " + JSON.stringify(netWorkId));
expect(true).assertEqual(netWorkId != -1);
expect(wifi.connectToNetwork(netWorkId)).assertTrue();
let disconNet = wifi.disableNetwork(netWorkId);
expect(disconNet).assertTrue();
let configs = wifi.getDeviceConfigs();
console.info("[wifi_test] wifi getDeviceConfigs result1 : " + JSON.stringify(configs));
expect(true).assertEqual(configs[0].ssid == wifiDeviceConfigK.ssid);
expect(true).assertEqual(configs[0].preSharedKey == wifiDeviceConfigK.preSharedKey);
let isRemoved = wifi.removeAllNetwork();
expect(isRemoved).assertTrue();
let configs1 = wifi.getDeviceConfigs();
expect(true).assertEqual(configs1.length == 0);
});
done()
})
/**
* @tc.number Config_SSID_0003
* @tc.name SSUB_Communication_WiFi_Sta_Conn_SSID_0003
* @tc.desc Test contains chinese SSID device config
*/
it('SSUB_Communication_WiFi_Sta_Conn_SSID_0003', 0, async function(done) {
await tryToEnableWifi();
let wifiDeviceConfigT = {
"ssid": "!@#¥%&*/",
"bssid": "",
"preSharedKey": "12345678",
"isHiddenSsid": false,
"securityType": WifiSecurityType.WIFI_SEC_TYPE_PSK,
"netId": -1,
"ipType": 1,
"creatorUid": 7,
"disableReason": 0,
"randomMacType": 0,
"randomMacAddr": "11:22:33:44:55:66",
"staticIp": {"ipAddress": 1284752956,"gateway": 1284752936},
};
await wifi.addDeviceConfig(wifiDeviceConfigT)
.then(netWorkId => {
expect(true).assertEqual(netWorkId != -1);
console.info("[wifi_test]connectdevice result: " + wifi.connectToNetwork(netWorkId));
let configs = wifi.getDeviceConfigs();
console.info("[wifi_test] wifi getDeviceConfigs result1 : " + JSON.stringify(configs));
expect(true).assertEqual(configs[0].ssid == wifiDeviceConfigT.ssid);
expect(true).assertEqual(configs[0].preSharedKey == wifiDeviceConfigT.preSharedKey);
let isRemoved = wifi.removeAllNetwork();
expect(isRemoved).assertTrue();
let configs1 = wifi.getDeviceConfigs();
console.info("[wifi_test]remove config,current get Config : " + JSON.stringify(configs1));
expect(true).assertEqual(configs1.length == 0);
});
done()
})
/**
* @tc.number Config_SSID_0007
* @tc.name SSUB_Communication_WiFi_Sta_Conn_SSID_0007
* @tc.desc Test hidden SSID wifi device config
*/
it('SUB_Communication_WiFi_Sta_Conn_SSID_0007', 0, async function(done) {
await tryToEnableWifi();
let wifiDeviceConfigT = {
"ssid": "test",
"bssid": "",
"preSharedKey": "12345678",
"isHiddenSsid": true,
"securityType": WifiSecurityType.WIFI_SEC_TYPE_PSK,
"netId": -1,
"ipType": 1,
"creatorUid": 7,
"disableReason": 0,
"randomMacType": 0,
"randomMacAddr": "11:22:33:44:55:66",
"staticIp": {"ipAddress": 1284752956,"gateway": 1284752936},
};
await wifi.addDeviceConfig(wifiDeviceConfigT)
.then(netWorkId => {
expect(true).assertEqual(netWorkId != -1);
console.info("[wifi_test]connectdevice result: " + wifi.connectToNetwork(netWorkId));
let configs = wifi.getDeviceConfigs();
console.info("[wifi_test] wifi getDeviceConfigs result1 : " + JSON.stringify(configs));
expect(true).assertEqual(configs[0].ssid == wifiDeviceConfigT.ssid);
expect(true).assertEqual(configs[0].isHiddenSsid == wifiDeviceConfigT.isHiddenSsid);
let isRemoved = wifi.removeAllNetwork();
expect(isRemoved).assertTrue();
let configs1 = wifi.getDeviceConfigs();
console.info("[wifi_test]remove config,current get Config : " + JSON.stringify(configs1));
expect(true).assertEqual(configs1.length == 0);
});
done()
})
/**
* @tc.number SUB_Communication_WiFi_Sta_info_0001
* @tc.name testgetMacAddress
* @tc.desc Test getMacAddress api.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
*/
it('SUB_Communication_WiFi_Sta_info_0001', 0, async function (done) {
await tryToEnableWifi();
expect(wifi.isWifiActive()).assertTrue();
console.info('[wifi_test] getDeviceMacAddress test start ...');
let result = wifi.getDeviceMacAddress();
console.info("[wifi_test] getDeviceMacAddress -> " + JSON.stringify(result));
expect(true).assertEqual(result.length >= 1)
done();
})
/** /**
* @tc.number SUB_Communication_WiFi_Sta_info_0002 * @tc.number SUB_Communication_WiFi_Sta_info_0002
...@@ -681,14 +159,12 @@ describe('ACTS_WifiTest', function() { ...@@ -681,14 +159,12 @@ describe('ACTS_WifiTest', function() {
* @tc.type Function * @tc.type Function
* @tc.level Level 3 * @tc.level Level 3
*/ */
it('SUB_Communication_WiFi_Sta_Info_0002', 0, async function(done) { it('SUB_Communication_WiFi_Sta_Info_0002', 0, function() {
await tryToEnableWifi();
expect(wifi.isWifiActive()).assertTrue(); expect(wifi.isWifiActive()).assertTrue();
console.info(" [wifi_test] getCountryCode start ... "); console.info(" [wifi_test] getCountryCode start ... ");
let countryCode = wifi.getCountryCode(); let countryCode = wifi.getCountryCode();
console.info("[wifi_test] getCountryCode -> " + JSON.stringify(countryCode)); console.info("[wifi_test] getCountryCode -> " + JSON.stringify(countryCode));
expect(JSON.stringify(countryCode)).assertEqual('"CN"'); expect(JSON.stringify(countryCode)).assertEqual('"CN"');
done()
}) })
/** /**
...@@ -699,14 +175,41 @@ describe('ACTS_WifiTest', function() { ...@@ -699,14 +175,41 @@ describe('ACTS_WifiTest', function() {
* @tc.type Function * @tc.type Function
* @tc.level Level 3 * @tc.level Level 3
*/ */
it('SUB_Communication_WiFi_Sta_info_0004', 0, async function (done) {
await tryToEnableWifi(); it('SUB_Communication_WiFi_Sta_info_0004', 0, function () {
expect(wifi.isWifiActive()).assertTrue(); expect(wifi.isWifiActive()).assertTrue();
let result = wifi.getSupportedFeatures(); let WifiUtils = {
console.info("[wifi_test] getFeatureSupported -> " + JSON.stringify(result)); WIFI_FEATURE_INFRA: 0x0001,
console.info("[wifi_test] isFeatureSupported: " + result +"->" + wifi.isFeatureSupported(result)); WIFI_FEATURE_INFRA_5G: 0x0002,
expect(wifi.isFeatureSupported(result)).assertTrue(); WIFI_GAS_ANQP: 0x0004,
done(); WIFI_WIFI_DIRECT: 0x0008,
WIFI_FEATURE_MOBILE_HOTSPOT: 0x0010,
WIFI_FEATURE_AWARE: 0x0040,
WIFI_FEATURE_AP_STA: 0x8000,
WIFI_FEATURE_WPA3_SAE: 0x8000000,
WIFI_FEATURE_WPA3_SUITE_B:0x10000000,
WIFI_FEATURE_OWE:0x20000000
}
let isSupport1 = wifi.isFeatureSupported(WifiUtils.WIFI_FEATURE_INFRA);
expect(isSupport1).assertFalse();
let isSupport2 = wifi.isFeatureSupported(WifiUtils.WIFI_FEATURE_INFRA_5G);
expect(isSupport2).assertFalse();
let isSupport3 = wifi.isFeatureSupported(WifiUtils.WIFI_GAS_ANQP);
expect(isSupport3).assertFalse();
let isSupport4 = wifi.isFeatureSupported(WifiUtils.WIFI_WIFI_DIRECT);
expect(isSupport4).assertFalse();
let isSupport5 = wifi.isFeatureSupported(WifiUtils.WIFI_FEATURE_MOBILE_HOTSPOT);
expect(isSupport5).assertFalse();
let isSupport6 = wifi.isFeatureSupported(WifiUtils.WIFI_FEATURE_AWARE);
expect(isSupport6).assertFalse();
let isSupport7 = wifi.isFeatureSupported(WifiUtils.WIFI_FEATURE_AP_STA);
expect(isSupport7).assertFalse();
let isSupport8 = wifi.isFeatureSupported(WifiUtils.WIFI_FEATURE_WPA3_SAE);
expect(isSupport8).assertFalse();
let isSupport9 = wifi.isFeatureSupported(WifiUtils.WIFI_FEATURE_WPA3_SUITE_B);
expect(isSupport9).assertFalse();
let isSupport = wifi.isFeatureSupported(WifiUtils.WIFI_FEATURE_OWE);
expect(isSupport).assertFalse();
}) })
/** /**
...@@ -717,52 +220,15 @@ describe('ACTS_WifiTest', function() { ...@@ -717,52 +220,15 @@ describe('ACTS_WifiTest', function() {
* @tc.type Function * @tc.type Function
* @tc.level Level 3 * @tc.level Level 3
*/ */
it('SUB_Communication_WiFi_Sta_Info_0005', 0, async function(done) { it('SUB_Communication_WiFi_Sta_Info_0005', 0, function() {
console.info(" [wifi_test] isHotspotDualBandSupported start ... "); console.info(" [wifi_test] isHotspotDualBandSupported start ... ");
await tryToEnableWifi();
expect(wifi.isWifiActive()).assertTrue(); expect(wifi.isWifiActive()).assertTrue();
let DualBand = wifi.isHotspotDualBandSupported(); let DualBand = wifi.isHotspotDualBandSupported();
console.info("[wifi_test] isHotspotDualBandSupported -> " + JSON.stringify(DualBand)); console.info("[wifi_test] isHotspotDualBandSupported -> " + JSON.stringify(DualBand));
expect(DualBand).assertFalse(); expect(DualBand).assertFalse();
done();
}) })
/**
* @tc.number Conn_Info_0001
* @tc.name SUB_Communication_WiFi_Sta_Conn_Info_0001
* @tc.desc Test reconnect wifi
*/
it('SUB_Communication_WiFi_Sta_Conn_Info_0001', 0, async function (done) {
await tryToEnableWifi();
let wifiDeviceConfigConn = {
"ssid": "TESTCONN",
"bssid": "",
"preSharedKey": "12345678",
"isHiddenSsid": false,
"securityType": WifiSecurityType.WIFI_SEC_TYPE_PSK,
"netId": -1,
"ipType": 1,
"creatorUid": 7,
"disableReason": 0,
"randomMacType": 0,
"randomMacAddr": "11:22:33:44:55:66",
"staticIp": {"ipAddress": 1284752956,"gateway": 1284752936},
};
expect(wifi.isWifiActive()).assertTrue();
let result1 = wifi.connectToDevice(wifiDeviceConfigConn);
expect(result1).assertTrue();
console.info("[wifi_test]isConnected : " + wifi.isConnected());
expect(wifi.isConnected()).assertFalse();
expect(wifi.reconnect()).assertTrue();
let isRemoved = wifi.removeAllNetwork();
expect(isRemoved).assertTrue();
let configs = wifi.getDeviceConfigs();
console.info("[wifi_test]remove config,current get Config : " + JSON.stringify(configs));
expect(true).assertEqual(configs.length == 0);
done()
})
/** /**
* @tc.number conn_Config_0002 * @tc.number conn_Config_0002
...@@ -770,7 +236,8 @@ describe('ACTS_WifiTest', function() { ...@@ -770,7 +236,8 @@ describe('ACTS_WifiTest', function() {
* @tc.desc Test getLinkedInfo information * @tc.desc Test getLinkedInfo information
*/ */
it('SUB_Communication_WiFi_Sta_Conn_Info_0002', 0, async function(done) { it('SUB_Communication_WiFi_Sta_Conn_Info_0002', 0, async function(done) {
await tryToEnableWifi(); console.info("[wifi_test]isConnected : " + wifi.isConnected());
expect(wifi.isConnected()).assertFalse();
await wifi.getLinkedInfo() await wifi.getLinkedInfo()
.then((result) => { .then((result) => {
console.info("[wifi_test] get wifi link [promise] -> " + JSON.stringify(result)); console.info("[wifi_test] get wifi link [promise] -> " + JSON.stringify(result));
...@@ -788,7 +255,8 @@ describe('ACTS_WifiTest', function() { ...@@ -788,7 +255,8 @@ describe('ACTS_WifiTest', function() {
* @tc.desc Test getLinkedInfo callback information * @tc.desc Test getLinkedInfo callback information
*/ */
it('SUB_Communication_WiFi_Sta_Conn_Info_0003', 0, async function(done) { it('SUB_Communication_WiFi_Sta_Conn_Info_0003', 0, async function(done) {
await tryToEnableWifi(); console.info("[wifi_test]isConnected : " + wifi.isConnected());
expect(wifi.isConnected()).assertFalse();
await wifi.getLinkedInfo( await wifi.getLinkedInfo(
(err,result) => { (err,result) => {
if(err) { if(err) {
...@@ -809,301 +277,13 @@ describe('ACTS_WifiTest', function() { ...@@ -809,301 +277,13 @@ describe('ACTS_WifiTest', function() {
}) })
/** /**
* @tc.number Conn_Security_0001 * @tc.number Conn_Info_0001
* @tc.name SUB_Communication_WiFi_Sta_Conn_Security_0001 * @tc.name SUB_Communication_WiFi_Sta_Conn_Info_0001
* @tc.desc Test connectToDevice 10 bits WEP Deviceconfig
*/
it('SUB_Communication_WiFi_Sta_Conn_Security_0001', 0, async function(done) {
await tryToEnableWifi();
let wifiDeviceConfig1 = {
"ssid": "TEST10",
"bssid": "",
"preSharedKey": "ABCDEF1234",
"isHiddenSsid": false,
"securityType": WifiSecurityType.WIFI_SEC_TYPE_WEP,
"netId": -1,
"ipType": 1,
"creatorUid": 7,
"disableReason": 0,
"randomMacType": 0,
"randomMacAddr": "11:22:33:44:55:66",
"staticIp": {"ipAddress": 1284752956,"gateway": 1284752936},
};
let result1 = wifi.connectToDevice(wifiDeviceConfig1);
console.log("[wifi_test] wifi connectToDevice result: " + result1);
expect(result1).assertTrue();
let isConnected= wifi.isConnected();
expect(isConnected).assertFalse();
let isRemoved = wifi.removeAllNetwork();
console.info("[wifi_test] check remove configs successfully,result:" + isRemoved);
expect(isRemoved).assertTrue();
done()
})
/**
* @tc.number Conn_Security_0002
* @tc.name SUB_Communication_WiFi_Sta_Conn_Security_0002
* @tc.desc Test disconnect Deviceconfig
*/
it('SUB_Communication_WiFi_Sta_Conn_Security_0002', 0, async function(done) {
await tryToEnableWifi();
let wifiDeviceConfig1 = {
"ssid": "TESTDIS",
"bssid": "",
"preSharedKey": "12345678",
"isHiddenSsid": false,
"securityType": WifiSecurityType.WIFI_SEC_TYPE_PSK,
"netId": -1,
"ipType": 1,
"creatorUid": 7,
"disableReason": 0,
"randomMacType": 0,
"randomMacAddr": "11:22:33:44:55:66",
"staticIp": {"ipAddress": 1284752956,"gateway": 1284752936},
};
let result1 = wifi.connectToDevice(wifiDeviceConfig1);
console.log("[wifi_test] wifi connectToDevice result: " + result1);
expect(result1).assertTrue();
let isConnected= wifi.isConnected();
expect(isConnected).assertFalse();
expect(wifi.disconnect()).assertTrue();
let isRemoved = wifi.removeAllNetwork();
console.info("[wifi_test] check remove configs successfully,result:" + isRemoved);
expect(isRemoved).assertTrue();
done()
})
/**
* @tc.number Conn_Security_0003
* @tc.name SUB_Communication_WiFi_Sta_Conn_Security_0003
* @tc.desc Test connectToDevice 26 bits WEP Deviceconfig
*/
it('SUB_Communication_WiFi_Sta_Conn_Security_0003', 0, async function(done) {
await tryToEnableWifi();
let wifiDeviceConfig1 = {
"ssid": "TEST26",
"bssid": "",
"preSharedKey": "12345678901234567890123456",
"isHiddenSsid": false,
"securityType": WifiSecurityType.WIFI_SEC_TYPE_WEP,
"netId": -1,
"ipType": 1,
"creatorUid": 7,
"disableReason": 0,
"randomMacType": 0,
"randomMacAddr": "11:22:33:44:55:66",
"staticIp": {"ipAddress": 1284752956,"gateway": 1284752936},
};
let result1 = wifi.connectToDevice(wifiDeviceConfig1);
console.log("[wifi_test] wifi connectToDevice result: " + result1);
expect(result1).assertTrue();
let isConnected= wifi.isConnected();
expect(isConnected).assertFalse();
let isRemoved = wifi.removeAllNetwork();
console.info("[wifi_test] check remove configs successfully,result:" + isRemoved);
expect(isRemoved).assertTrue();
done()
})
/**
* @tc.number Conn_Security_0005
* @tc.name SUB_Communication_WiFi_Sta_Conn_Security_0005
* @tc.desc Test connectToDevice 5bits ASCLL WEP Deviceconfig
*/
it('SUB_Communication_WiFi_Sta_Conn_Security_0005', 0, async function(done) {
await tryToEnableWifi();
let wifiDeviceConfig1 = {
"ssid": "TEST5",
"bssid": "",
"preSharedKey": "aB1@g",
"isHiddenSsid": false,
"securityType": WifiSecurityType.WIFI_SEC_TYPE_WEP,
"netId": -1,
"ipType": 1,
"creatorUid": 7,
"disableReason": 0,
"randomMacType": 0,
"randomMacAddr": "11:22:33:44:55:66",
"staticIp": {"ipAddress": 1284752956,"gateway": 1284752936},
};
let result1 = wifi.connectToDevice(wifiDeviceConfig1);
console.log("[wifi_test] wifi connectToDevice result: " + result1);
expect(result1).assertTrue();
let isConnected= wifi.isConnected();
expect(isConnected).assertFalse();
let isRemoved = wifi.removeAllNetwork();
console.info("[wifi_test] check remove configs successfully,result:" + isRemoved);
expect(isRemoved).assertTrue();
done()
})
/**
* @tc.number Conn_Security_0007
* @tc.name SUB_Communication_WiFi_Sta_Conn_Security_0007
* @tc.desc Test connectToDevice 13bits ASCLL WEP Deviceconfig
*/
it('SUB_Communication_WiFi_Sta_Conn_Security_0007', 0, async function(done) {
await tryToEnableWifi();
let wifiDeviceConfig1 = {
"ssid": "TEST7",
"bssid": "",
"preSharedKey": "1234aA@fFgGzZ",
"isHiddenSsid": false,
"securityType": WifiSecurityType.WIFI_SEC_TYPE_WEP,
"netId": -1,
"ipType": 1,
"creatorUid": 7,
"disableReason": 0,
"randomMacType": 0,
"randomMacAddr": "11:22:33:44:55:66",
"staticIp": {"ipAddress": 1284752956,"gateway": 1284752936},
};
let result1 = wifi.connectToDevice(wifiDeviceConfig1);
console.log("[wifi_test] wifi connectToDevice result: " + result1);
expect(result1).assertTrue();
console.info("[wifi_test] check isconnected wifi");
let isConnected= wifi.isConnected();
expect(isConnected).assertFalse();
let isRemoved = wifi.removeAllNetwork();
console.info("[wifi_test] check remove configs successfully,result:" + isRemoved);
expect(isRemoved).assertTrue();
done()
})
/**
* @tc.number Conn_Security_0013
* @tc.name SUB_Communication_WiFi_Sta_Conn_Security_0013
* @tc.desc Test connectToDevice 63bits ASCLL PSK Deviceconfig
*/
it('SUB_Communication_WiFi_Sta_Conn_Security_0013', 0, async function(done) {
await tryToEnableWifi();
let wifiDeviceConfig1 = {
"ssid": "TEST13",
"bssid": "",
"preSharedKey": "ABCDEFGHABCDEFGHABCDEFGHABCDEFGHABCDEFGHABCDEFGHABCDEFGH1234567",
"isHiddenSsid": false,
"securityType": WifiSecurityType.WIFI_SEC_TYPE_PSK,
"netId": -1,
"ipType": 1,
"creatorUid": 7,
"disableReason": 0,
"randomMacType": 0,
"randomMacAddr": "11:22:33:44:55:66",
"staticIp": {"ipAddress": 1284752956,"gateway": 1284752936},
};
let result1 = wifi.connectToDevice(wifiDeviceConfig1);
console.log("[wifi_test] wifi connectToDevice result: " + result1);
expect(result1).assertTrue();
let isConnected= wifi.isConnected();
expect(isConnected).assertFalse();
let isRemoved = wifi.removeAllNetwork();
console.info("[wifi_test] check remove configs successfully,result:" + isRemoved);
expect(isRemoved).assertTrue();
done()
})
/**
* @tc.number Conn_Security_0014
* @tc.name SUB_Communication_WiFi_Sta_Conn_Security_0014
* @tc.desc Test connectToDevice 8bits ASCLL PSK Deviceconfig
*/
it('SUB_Communication_WiFi_Sta_Conn_Security_0014', 0, async function(done) {
await tryToEnableWifi();
let wifiDeviceConfig1 = {
"ssid": "TEST13",
"bssid": "",
"preSharedKey": "ABCDEFGH",
"isHiddenSsid": false,
"securityType": WifiSecurityType.WIFI_SEC_TYPE_PSK,
"netId": -1,
"ipType": 1,
"creatorUid": 7,
"disableReason": 0,
"randomMacType": 0,
"randomMacAddr": "11:22:33:44:55:66",
"staticIp": {"ipAddress": 1284752956,"gateway": 1284752936},
};
let result1 = wifi.connectToDevice(wifiDeviceConfig1);
console.log("[wifi_test] wifi connectToDevice result: " + result1);
expect(result1).assertTrue();
let isConnected= wifi.isConnected();
expect(isConnected).assertFalse();
let isRemoved = wifi.removeAllNetwork();
console.info("[wifi_test] check remove configs successfully,result:" + isRemoved);
expect(isRemoved).assertTrue();
done()
})
/**
* @tc.number Conn_Security_0015
* @tc.name SUB_Communication_WiFi_Sta_Conn_Security_0015
* @tc.desc Test connectToDevice 63bits ASCLL PSK Deviceconfig
*/
it('SUB_Communication_WiFi_Sta_Conn_Security_0015', 0, async function(done) {
await tryToEnableWifi();
let wifiDeviceConfig1 = {
"ssid": "TEST13",
"bssid": "",
"preSharedKey": "ABCDEFGHABCDEFGHABCDEFGHABCDEFGHABCDEFGHABCDEFGHABCDEFGH1234567",
"isHiddenSsid": false,
"securityType": WifiSecurityType.WIFI_SEC_TYPE_PSK,
"netId": -1,
"ipType": 1,
"creatorUid": 7,
"disableReason": 0,
"randomMacType": 0,
"randomMacAddr": "11:22:33:44:55:66",
"staticIp": {"ipAddress": 1284752956,"gateway": 1284752936},
};
let result1 = wifi.connectToDevice(wifiDeviceConfig1);
console.log("[wifi_test] wifi connectToDevice result: " + result1);
expect(result1).assertTrue();
console.info("[wifi_test] check isconnected wifi");
let isConnected= wifi.isConnected();
expect(isConnected).assertFalse();
let isRemoved = wifi.removeAllNetwork();
console.info("[wifi_test] check remove configs successfully,result:" + isRemoved);
expect(isRemoved).assertTrue();
done()
})
/**
* @tc.number Conn_Info_0003
* @tc.name SUB_Communication_WiFi_Sta_Conn_Info_0003
* @tc.desc Test get IpInfo information * @tc.desc Test get IpInfo information
*/ */
it('SUB_Communication_WiFi_Sta_Conn_Info_0003', 0, async function (done) { it('SUB_Communication_WiFi_Sta_Conn_Info_0001', 0, function () {
await tryToEnableWifi();
let wifiDeviceConfigIp = {
"ssid": "TEST1",
"bssid": "",
"preSharedKey": "123456789",
"isHiddenSsid": false,
"securityType": WifiSecurityType.WIFI_SEC_TYPE_PSK,
"netId": -1,
"ipType": 1,
"creatorUid": 7,
"disableReason": 0,
"randomMacType": 0,
"randomMacAddr": "11:22:33:44:55:66",
"staticIp": {"ipAddress": 1284752956,"gateway": 1284752936},
};
let result1 = wifi.connectToDevice(wifiDeviceConfigIp);
console.log("[wifi_test] wifi connectToDevice result: " + result1);
expect(result1).assertTrue();
let isConnected= wifi.isConnected(); let isConnected= wifi.isConnected();
expect(isConnected).assertFalse(); expect(isConnected).assertFalse();
let reass= wifi.reassociate();
expect(reass).assertTrue();
let ipInfo = wifi.getIpInfo(); let ipInfo = wifi.getIpInfo();
expect(JSON.stringify(ipInfo)).assertContain("gateway"); expect(JSON.stringify(ipInfo)).assertContain("gateway");
console.info("gateway: " + ipInfo.gateway + "ipAddress: " + ipInfo.ipAddress console.info("gateway: " + ipInfo.gateway + "ipAddress: " + ipInfo.ipAddress
...@@ -1111,13 +291,6 @@ describe('ACTS_WifiTest', function() { ...@@ -1111,13 +291,6 @@ describe('ACTS_WifiTest', function() {
"leaseDuration: " + ipInfo.leaseDuration + "leaseDuration: " + ipInfo.leaseDuration +
"netmask: " + ipInfo.netmask + "primaryDns:" + ipInfo.primaryDns + "netmask: " + ipInfo.netmask + "primaryDns:" + ipInfo.primaryDns +
"secondDns: " + ipInfo.secondDns + "serverIp: " + ipInfo.serverIp ); "secondDns: " + ipInfo.secondDns + "serverIp: " + ipInfo.serverIp );
let isRemoved = wifi.removeAllNetwork();
expect(isRemoved).assertTrue();
let configs = wifi.getDeviceConfigs();
console.info("[wifi_test]remove config,current get Config : " + JSON.stringify(configs));
expect(true).assertEqual(configs.length == 0);
done()
}) })
/** /**
...@@ -1126,7 +299,6 @@ describe('ACTS_WifiTest', function() { ...@@ -1126,7 +299,6 @@ describe('ACTS_WifiTest', function() {
* @tc.desc Test wifiStateChange callback * @tc.desc Test wifiStateChange callback
*/ */
it('SUB_Communication_WiFi_Sta_wifiStateChange_0001', 0, async function (done) { it('SUB_Communication_WiFi_Sta_wifiStateChange_0001', 0, async function (done) {
await tryToEnableWifi();
wifi.on('wifiStateChange', async result => { wifi.on('wifiStateChange', async result => {
console.info("wifiStateChange callback, result:" + JSON.stringify(result)); console.info("wifiStateChange callback, result:" + JSON.stringify(result));
expect(true).assertEqual(result !=null); expect(true).assertEqual(result !=null);
...@@ -1139,13 +311,7 @@ describe('ACTS_WifiTest', function() { ...@@ -1139,13 +311,7 @@ describe('ACTS_WifiTest', function() {
}) })
await promise.then(done) await promise.then(done)
}); });
let disable = wifi.disableWifi()
await sleep(5000);
let enable = wifi.enableWifi();
await sleep(5000);
console.log("[wifi_test] check the state of wifi: " + wifi.isWifiActive());
done(); done();
}) })
/** /**
...@@ -1154,7 +320,6 @@ describe('ACTS_WifiTest', function() { ...@@ -1154,7 +320,6 @@ describe('ACTS_WifiTest', function() {
* @tc.desc Test wifiStateChange callback * @tc.desc Test wifiStateChange callback
*/ */
it('SUB_Communication_WiFi_Sta_wifiConnectionChange_0002', 0, async function (done) { it('SUB_Communication_WiFi_Sta_wifiConnectionChange_0002', 0, async function (done) {
await tryToEnableWifi();
wifi.on('wifiConnectionChange', async result => { wifi.on('wifiConnectionChange', async result => {
console.info("wifiConnectionChange callback, result:" + JSON.stringify(result)); console.info("wifiConnectionChange callback, result:" + JSON.stringify(result));
expect(true).assertEqual(result !=null); expect(true).assertEqual(result !=null);
...@@ -1169,7 +334,6 @@ describe('ACTS_WifiTest', function() { ...@@ -1169,7 +334,6 @@ describe('ACTS_WifiTest', function() {
await promise.then(done) await promise.then(done)
}); });
done(); done();
}) })
/** /**
...@@ -1178,7 +342,6 @@ describe('ACTS_WifiTest', function() { ...@@ -1178,7 +342,6 @@ describe('ACTS_WifiTest', function() {
* @tc.desc Test wifiScanStateChange callback * @tc.desc Test wifiScanStateChange callback
*/ */
it('SUB_Communication_WiFi_Sta_wifiScanStateChange_0003', 0, async function (done) { it('SUB_Communication_WiFi_Sta_wifiScanStateChange_0003', 0, async function (done) {
await tryToEnableWifi();
wifi.on('wifiScanStateChange', async result => { wifi.on('wifiScanStateChange', async result => {
console.info("wifiScanStateChange callback, result:" + JSON.stringify(result)); console.info("wifiScanStateChange callback, result:" + JSON.stringify(result));
expect(true).assertEqual(result !=null); expect(true).assertEqual(result !=null);
...@@ -1204,7 +367,6 @@ describe('ACTS_WifiTest', function() { ...@@ -1204,7 +367,6 @@ describe('ACTS_WifiTest', function() {
* @tc.desc Test wifiRssiChange callback * @tc.desc Test wifiRssiChange callback
*/ */
it('SUB_Communication_WiFi_Sta_wifiRssiChange_0004', 0, async function (done) { it('SUB_Communication_WiFi_Sta_wifiRssiChange_0004', 0, async function (done) {
await tryToEnableWifi();
wifi.on('wifiRssiChange', async result => { wifi.on('wifiRssiChange', async result => {
console.info("wifiRssiChange callback, result:" + JSON.stringify(result)); console.info("wifiRssiChange callback, result:" + JSON.stringify(result));
expect(true).assertEqual(result !=null); expect(true).assertEqual(result !=null);
...@@ -1223,30 +385,50 @@ describe('ACTS_WifiTest', function() { ...@@ -1223,30 +385,50 @@ describe('ACTS_WifiTest', function() {
}) })
/** /**
* @tc.number streamChange_0005 * @tc.number SUB_Communication_WiFi_Hotspot_ON_0001
* @tc.name SUB_Communication_WiFi_Sta_wifiRssiChange_0005 * @tc.name testhotspotStateChangeOn
* @tc.desc Test streamChange callback * @tc.desc Test hotspotStateChangeOn api.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
*/ */
it('SUB_Communication_WiFi_Sta_streamChange_0005', 0, async function (done) { it('SUB_Communication_WiFi_Hotspot_ON_0001', 0, async function (done) {
await tryToEnableWifi(); console.info("[wifi_test]hotspotStateChange On test");
try {
wifi.on('streamChange', async result => { await wifi.on('hotspotStateChange', (data) => {
console.info("streamChange callback, result:" + JSON.stringify(result)); console.info("[wifi_test] hotspotStateChange On ->" + data);
expect(true).assertEqual(result !=null); expect(true).assertEqual(data != null);
let promise = new Promise((resolve) => {
console.info('[wifi_test] offstreamChange test start ...');
wifi.off('streamChange', result => {
console.info("offstreamChange callback, result: " + JSON.stringify(result));
expect(true).assertEqual(result !=null);
resolve()
}); });
}catch(e) {
expect(null).assertFail();
}
done();
}) })
await promise.then(done)
/**
* @tc.number SUB_Communication_WiFi_Hotspot_Off_0002
* @tc.name testhotspotStateChangeOff
* @tc.desc Test hotspotStateChange api.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
*/
it('SUB_Communication_WiFi_Sta_Off_0002', 0, async function (done) {
try {
await wifi.off('hotspotStateChange', (data) => {
console.info("[wifi_test] hotspotStateChange Off ->" + data);
expect(true).assertEqual(data != null);
console.info("[wifi_test] wifiRssiChange unregister end");
}); });
done();
}catch(e) {
expect(null).assertFail();
}
done();
}) })
console.log("*************[wifi_test] start wifi js unit test end*************"); console.log("*************[wifi_test] start wifi js unit test end*************");
}) })
...@@ -35,24 +35,9 @@ async function changedLocationMode(){ ...@@ -35,24 +35,9 @@ async function changedLocationMode(){
await geolocation.isLocationEnabled().then(async(result) => { await geolocation.isLocationEnabled().then(async(result) => {
console.info('[lbs_js] getLocationSwitchState result: ' + result); console.info('[lbs_js] getLocationSwitchState result: ' + result);
if(!result){ if(!result){
await geolocation.enableLocation().then(async(result) => { await geolocation.requestEnableLocation().then(async(result) => {
await sleep(3000); await sleep(3000);
console.info('[lbs_js] test enableLocation promise result: ' + result); console.info('[lbs_js] test requestEnableLocation promise result: ' + result);
expect(result).assertTrue();
}).catch((error) => {
console.info("[lbs_js] promise then error." + error.message);
expect().assertFail();
});
}
})
}
async function offLocationMode(){
await geolocation.isLocationEnabled().then(async(result) => {
console.info('[lbs_js] getLocationSwitchState result: ' + result);
if(result){
await geolocation.disableLocation().then(async(result) => {
await sleep(3000);
console.info('[lbs_js] test disableLocation promise result: ' + result);
expect(result).assertTrue(); expect(result).assertTrue();
}).catch((error) => { }).catch((error) => {
console.info("[lbs_js] promise then error." + error.message); console.info("[lbs_js] promise then error." + error.message);
...@@ -106,8 +91,8 @@ describe('geolocationTest', function () { ...@@ -106,8 +91,8 @@ describe('geolocationTest', function () {
console.info('beforeAll case'); console.info('beforeAll case');
}) })
beforeEach(function () { beforeEach(async function () {
sleep(3000); await changedLocationMode();
console.info('beforeEach case'); console.info('beforeEach case');
}) })
afterEach(function () { afterEach(function () {
...@@ -122,13 +107,6 @@ describe('geolocationTest', function () { ...@@ -122,13 +107,6 @@ describe('geolocationTest', function () {
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('SUB_HSS_LocationSystem_Geo_0001', 0, async function (done) { it('SUB_HSS_LocationSystem_Geo_0001', 0, async function (done) {
geolocation.enableLocation(async(err, data) => {
if (err) {
console.info('[lbs_js] enableLocation callback err is : ' + err );
}
console.info("[lbs_js] enableLocation callback data: " + data);
expect(data).assertTrue();
geolocation.isGeoServiceAvailable(async(err, data) => { geolocation.isGeoServiceAvailable(async(err, data) => {
if (err) { if (err) {
console.info('[lbs_js] getGeoServiceState err is : ' + err ); console.info('[lbs_js] getGeoServiceState err is : ' + err );
...@@ -137,27 +115,8 @@ describe('geolocationTest', function () { ...@@ -137,27 +115,8 @@ describe('geolocationTest', function () {
console.info('[lbs_js] isGeoServiceAvailable callback result: ' + data); console.info('[lbs_js] isGeoServiceAvailable callback result: ' + data);
expect(data).assertTrue(); expect(data).assertTrue();
} }
geolocation.disableLocation(async(err, data) => {
if (err) {
console.info('[lbs_js] disableLocation callback err is : ' + err );
}else {
console.info("[lbs_js] disableLocation callback data: " + data);
expect(data).assertTrue();
}
geolocation.isGeoServiceAvailable(async(err, data) => {
if (err) {
console.info('[lbs_js] getGeoServiceState err is : ' + err );
}else {
console.info('[lbs_js] isGeoServiceAvailable2 callback result: ' + data);
expect(data).assertFalse();
done() done()
}
});
}) })
})
});
}); });
/** /**
...@@ -169,13 +128,6 @@ describe('geolocationTest', function () { ...@@ -169,13 +128,6 @@ describe('geolocationTest', function () {
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('SUB_HSS_LocationSystem_Geo_0002', 0, async function (done) { it('SUB_HSS_LocationSystem_Geo_0002', 0, async function (done) {
await geolocation.enableLocation().then((result) => {
console.info('[lbs_js] test enableLocation promise result: ' + result);
expect(result).assertTrue();
}).catch((error) => {
console.info("[lbs_js] promise then error." + error.message);
expect().assertFail();
});
await geolocation.isGeoServiceAvailable().then( (result) => { await geolocation.isGeoServiceAvailable().then( (result) => {
console.info('[lbs_js] isGeoServiceAvailable1 promise result: ' + result); console.info('[lbs_js] isGeoServiceAvailable1 promise result: ' + result);
expect(result).assertTrue(); expect(result).assertTrue();
...@@ -183,17 +135,6 @@ describe('geolocationTest', function () { ...@@ -183,17 +135,6 @@ describe('geolocationTest', function () {
console.info("[lbs_js] promise then error." + error.message); console.info("[lbs_js] promise then error." + error.message);
expect().assertFail(); expect().assertFail();
}); });
await geolocation.disableLocation().then((data) => {
console.info('[lbs_js] disableLocation promise data: ' + data);
expect(data).assertTrue();
});
await geolocation.isGeoServiceAvailable().then( (result) => {
console.info('[lbs_js] isGeoServiceAvailable2 promise result: ' + result);
expect(result).assertFalse();
}).catch((error) => {
console.info("[lbs_js] promise then error." + error.message);
expect().assertFail();
});
done(); done();
}) })
...@@ -206,21 +147,8 @@ describe('geolocationTest', function () { ...@@ -206,21 +147,8 @@ describe('geolocationTest', function () {
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('SUB_HSS_LocationSystem_Geo_0003', 0, async function (done) { it('SUB_HSS_LocationSystem_Geo_0003', 0, async function (done) {
let promiseOne = new Promise((resolve,reject) => {
geolocation.enableLocation((err, data) => {
if (err) {
console.info('[lbs_js] enableLocation callback err is : ' + err );
}else {
console.info("[lbs_js] enableLocation callback data: " + data);
expect(data).assertTrue();
}
resolve()
});
})
await sleep(3000);
let reverseGeocodeRequest = {"latitude": 31.265496, "longitude": 121.62771, "maxItems": 1,"locale": "zh"}; let reverseGeocodeRequest = {"latitude": 31.265496, "longitude": 121.62771, "maxItems": 1,"locale": "zh"};
let promiseTwo = new Promise((resolve,reject) => { let promise = new Promise((resolve,reject) => {
geolocation.getAddressesFromLocation(reverseGeocodeRequest, (err, data) => { geolocation.getAddressesFromLocation(reverseGeocodeRequest, (err, data) => {
if (err) { if (err) {
console.info('[lbs_js] getAddressesFromLocation callback err is : ' + err); console.info('[lbs_js] getAddressesFromLocation callback err is : ' + err);
...@@ -231,9 +159,7 @@ describe('geolocationTest', function () { ...@@ -231,9 +159,7 @@ describe('geolocationTest', function () {
resolve() resolve()
}); });
}) })
await promiseOne.then(()=>{ await promise.then(done)
return promiseTwo
}).then(done)
}) })
/** /**
...@@ -245,13 +171,6 @@ describe('geolocationTest', function () { ...@@ -245,13 +171,6 @@ describe('geolocationTest', function () {
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('SUB_HSS_LocationSystem_Geo_0004', 0, async function (done) { it('SUB_HSS_LocationSystem_Geo_0004', 0, async function (done) {
await geolocation.enableLocation().then((result) => {
console.info('[lbs_js] testenableLocation promise result: ' + result);
expect(result).assertTrue();
}).catch((error) => {
console.info("[lbs_js] promise then error." + error.message);
expect().assertFail();
});
let reverseGeocodeRequest = {"latitude": 31.265496, "longitude": 121.62771, "maxItems": 1}; let reverseGeocodeRequest = {"latitude": 31.265496, "longitude": 121.62771, "maxItems": 1};
await geolocation.getAddressesFromLocation(reverseGeocodeRequest).then((data) => { await geolocation.getAddressesFromLocation(reverseGeocodeRequest).then((data) => {
console.info('[lbs_js] getAddressesFromLocation04 promise: ' + JSON.stringify(data)); console.info('[lbs_js] getAddressesFromLocation04 promise: ' + JSON.stringify(data));
...@@ -277,13 +196,6 @@ describe('geolocationTest', function () { ...@@ -277,13 +196,6 @@ describe('geolocationTest', function () {
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('SUB_HSS_LocationSystem_Geo_0005', 0, async function (done) { it('SUB_HSS_LocationSystem_Geo_0005', 0, async function (done) {
await geolocation.enableLocation().then((result) => {
console.info('[lbs_js] testenableLocation promise result: ' + result);
expect(result).assertTrue();
}).catch((error) => {
console.info("[lbs_js] promise then error." + error.message);
expect().assertFail();
});
let reverseGeocodeRequest = {"latitude": 31.265496, "longitude": 121.62771, "maxItems": 5}; let reverseGeocodeRequest = {"latitude": 31.265496, "longitude": 121.62771, "maxItems": 5};
await geolocation.getAddressesFromLocation(reverseGeocodeRequest).then((data) => { await geolocation.getAddressesFromLocation(reverseGeocodeRequest).then((data) => {
console.info('[lbs_js] getAddressesFromLocation05 promise: ' + JSON.stringify(data)); console.info('[lbs_js] getAddressesFromLocation05 promise: ' + JSON.stringify(data));
...@@ -305,13 +217,6 @@ describe('geolocationTest', function () { ...@@ -305,13 +217,6 @@ describe('geolocationTest', function () {
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('SUB_HSS_LocationSystem_Geo_0006', 0, async function (done) { it('SUB_HSS_LocationSystem_Geo_0006', 0, async function (done) {
await geolocation.enableLocation().then((result) => {
console.info('[lbs_js] testenableLocation promise result: ' + result);
expect(result).assertTrue();
}).catch((error) => {
console.info("[lbs_js] promise then error." + error.message);
expect().assertFail();
});
let reverseGeocodeRequest1 = {"latitude": 90, "longitude": 121.62771, "maxItems": 1}; let reverseGeocodeRequest1 = {"latitude": 90, "longitude": 121.62771, "maxItems": 1};
await geolocation.getAddressesFromLocation(reverseGeocodeRequest1).then((data) => { await geolocation.getAddressesFromLocation(reverseGeocodeRequest1).then((data) => {
console.info('[lbs_js] getAddressesFromLocation0601 promise: ' + JSON.stringify(data)); console.info('[lbs_js] getAddressesFromLocation0601 promise: ' + JSON.stringify(data));
...@@ -350,19 +255,12 @@ describe('geolocationTest', function () { ...@@ -350,19 +255,12 @@ describe('geolocationTest', function () {
/** /**
* @tc.number Geo_0007 * @tc.number Geo_0007
* @tc.name SUB_HSS_LocationSystem_Geo_0007 * @tc.name SUB_HSS_LocationSystem_Geo_0007
* @tc.desc Test enableLocation api . * @tc.desc Test requestEnableLocation api .
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('SUB_HSS_LocationSystem_Geo_0007', 0, async function (done) { it('SUB_HSS_LocationSystem_Geo_0007', 0, async function (done) {
await geolocation.enableLocation().then((result) => {
console.info('[lbs_js] testenableLocation promise result: ' + result);
expect(result).assertTrue();
}).catch((error) => {
console.info("[lbs_js] promise then error." + error.message);
expect().assertFail();
});
let reverseGeocodeRequest = {"latitude": 31.265496, "longitude": 180, "maxItems": 1}; let reverseGeocodeRequest = {"latitude": 31.265496, "longitude": 180, "maxItems": 1};
await geolocation.getAddressesFromLocation(reverseGeocodeRequest).then((data) => { await geolocation.getAddressesFromLocation(reverseGeocodeRequest).then((data) => {
console.info('[lbs_js] getAddressesFromLocation0701 promise: ' + JSON.stringify(data)); console.info('[lbs_js] getAddressesFromLocation0701 promise: ' + JSON.stringify(data));
...@@ -407,13 +305,6 @@ describe('geolocationTest', function () { ...@@ -407,13 +305,6 @@ describe('geolocationTest', function () {
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('SUB_HSS_LocationSystem_Geo_0008', 0, async function (done) { it('SUB_HSS_LocationSystem_Geo_0008', 0, async function (done) {
await geolocation.enableLocation().then((result) => {
console.info('[lbs_js] testenableLocation result: ' + result);
expect(result).assertTrue();
}).catch((error) => {
console.info("[lbs_js] promise then error." + error.message);
expect().assertFail();
});
let geocodeRequest = {"description": "上海市浦东新区金穗路1800号", "maxItems": 1,"locale": "zh","minLatitude":"" , let geocodeRequest = {"description": "上海市浦东新区金穗路1800号", "maxItems": 1,"locale": "zh","minLatitude":"" ,
"minLongitude":"" ,"maxLatitude":"" ,"maxLongitude": ""}; "minLongitude":"" ,"maxLatitude":"" ,"maxLongitude": ""};
geolocation.getAddressesFromLocationName(geocodeRequest, (err, data) => { geolocation.getAddressesFromLocationName(geocodeRequest, (err, data) => {
...@@ -460,13 +351,6 @@ describe('geolocationTest', function () { ...@@ -460,13 +351,6 @@ describe('geolocationTest', function () {
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('SUB_HSS_LocationSystem_Geo_0009', 0, async function (done) { it('SUB_HSS_LocationSystem_Geo_0009', 0, async function (done) {
await geolocation.enableLocation().then((result) => {
console.info('[lbs_js] testenableLocation result: ' + result);
expect(result).assertTrue();
}).catch((error) => {
console.info("[lbs_js] promise then error." + error.message);
expect().assertFail();
});
let geocodeRequest = {"description": "上海市浦东新区金穗路1800号", "maxItems": 1}; let geocodeRequest = {"description": "上海市浦东新区金穗路1800号", "maxItems": 1};
await geolocation.getAddressesFromLocationName(geocodeRequest).then((result) => { await geolocation.getAddressesFromLocationName(geocodeRequest).then((result) => {
console.info("[lbs_js] getAddressesFromLocation callback data is: " + JSON.stringify(result)); console.info("[lbs_js] getAddressesFromLocation callback data is: " + JSON.stringify(result));
...@@ -487,13 +371,6 @@ describe('geolocationTest', function () { ...@@ -487,13 +371,6 @@ describe('geolocationTest', function () {
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('SUB_HSS_LocationSystem_Geo_0010', 0, async function (done) { it('SUB_HSS_LocationSystem_Geo_0010', 0, async function (done) {
await geolocation.enableLocation().then((result) => {
console.info('[lbs_js] test enableLocation result: ' + result);
expect(result).assertTrue();
}).catch((error) => {
console.info("[lbs_js] promise then error." + error.message);
expect().assertFail();
});
let geocodeRequest = {"description": "上海市浦东新区金穗路1800号", "maxItems": 5}; let geocodeRequest = {"description": "上海市浦东新区金穗路1800号", "maxItems": 5};
await geolocation.getAddressesFromLocationName(geocodeRequest).then((result) => { await geolocation.getAddressesFromLocationName(geocodeRequest).then((result) => {
console.info("[lbs_js] getAddressesFromLocation m callback data is: " + JSON.stringify(result)); console.info("[lbs_js] getAddressesFromLocation m callback data is: " + JSON.stringify(result));
...@@ -514,13 +391,6 @@ describe('geolocationTest', function () { ...@@ -514,13 +391,6 @@ describe('geolocationTest', function () {
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('SUB_HSS_LocationSystem_Geo_0011', 0, async function (done) { it('SUB_HSS_LocationSystem_Geo_0011', 0, async function (done) {
await geolocation.enableLocation().then((result) => {
console.info('[lbs_js] test enableLocation result: ' + result);
expect(result).assertTrue();
}).catch((error) => {
console.info("[lbs_js] promise then error." + error.message);
expect().assertFail();
});
let geocodeRequest = {"description": "", "maxItems": 1}; let geocodeRequest = {"description": "", "maxItems": 1};
await geolocation.getAddressesFromLocationName(geocodeRequest).then((result) => { await geolocation.getAddressesFromLocationName(geocodeRequest).then((result) => {
console.info("[lbs_js] getAddressesFromLocation promise data is: " + JSON.stringify(result)); console.info("[lbs_js] getAddressesFromLocation promise data is: " + JSON.stringify(result));
...@@ -549,13 +419,6 @@ describe('geolocationTest', function () { ...@@ -549,13 +419,6 @@ describe('geolocationTest', function () {
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('SUB_HSS_LocationSystem_Geo_0012', 0, async function (done) { it('SUB_HSS_LocationSystem_Geo_0012', 0, async function (done) {
await geolocation.enableLocation().then((result) => {
console.info('[lbs_js] test enableLocation result: ' + result);
expect(result).assertTrue();
}).catch((error) => {
console.info("[lbs_js] promise then error." + error.message);
expect().assertFail();
});
let geocodeRequest = {"description": "上海金穗路1800号", "maxItems": 1, "minLatitude":31.3082812847 , let geocodeRequest = {"description": "上海金穗路1800号", "maxItems": 1, "minLatitude":31.3082812847 ,
"minLongitude":121.5782001832,"maxLatitude":31.1537977881,"maxLongitude":121.8026736943}; "minLongitude":121.5782001832,"maxLatitude":31.1537977881,"maxLongitude":121.8026736943};
await geolocation.getAddressesFromLocationName(geocodeRequest).then((result) => { await geolocation.getAddressesFromLocationName(geocodeRequest).then((result) => {
...@@ -577,13 +440,6 @@ describe('geolocationTest', function () { ...@@ -577,13 +440,6 @@ describe('geolocationTest', function () {
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('SUB_HSS_LocationSystem_Geo_0013', 0, async function (done) { it('SUB_HSS_LocationSystem_Geo_0013', 0, async function (done) {
await geolocation.enableLocation().then((result) => {
console.info('[lbs_js] test enableLocation result: ' + result);
expect(result).assertTrue();
}).catch((error) => {
console.info("[lbs_js] promise then error" + error.message);
expect().assertFail();
});
let geocodeRequest = {"description": "", "maxItems": 1, "minLatitude":331.3082812847 , let geocodeRequest = {"description": "", "maxItems": 1, "minLatitude":331.3082812847 ,
"minLongitude":121.5782001832,"maxLatitude":31.1537977881,"maxLongitude":121.8026736943}; "minLongitude":121.5782001832,"maxLatitude":31.1537977881,"maxLongitude":121.8026736943};
await geolocation.getAddressesFromLocationName(geocodeRequest).then((result) => { await geolocation.getAddressesFromLocationName(geocodeRequest).then((result) => {
...@@ -614,13 +470,6 @@ describe('geolocationTest', function () { ...@@ -614,13 +470,6 @@ describe('geolocationTest', function () {
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('SUB_HSS_LocationSystem_Geo_0014', 0, async function (done) { it('SUB_HSS_LocationSystem_Geo_0014', 0, async function (done) {
await geolocation.enableLocation().then((result) => {
console.info('[lbs_js] testenableLocation result: ' + result);
expect(result).assertTrue();
}).catch((error) => {
console.info("[lbs_js] promise then error." + error.message);
expect().assertFail();
});
let geocodeRequest = {"description": "北京天安门", "maxItems": 1, "minLatitude":40.85 , let geocodeRequest = {"description": "北京天安门", "maxItems": 1, "minLatitude":40.85 ,
"minLongitude":116.35,"maxLatitude":40.95,"maxLongitude":116.45}; "minLongitude":116.35,"maxLatitude":40.95,"maxLongitude":116.45};
await geolocation.getAddressesFromLocationName(geocodeRequest).then((result) => { await geolocation.getAddressesFromLocationName(geocodeRequest).then((result) => {
...@@ -642,13 +491,6 @@ describe('geolocationTest', function () { ...@@ -642,13 +491,6 @@ describe('geolocationTest', function () {
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('SUB_HSS_LocationSystem_Geo_0015', 0, async function (done) { it('SUB_HSS_LocationSystem_Geo_0015', 0, async function (done) {
await geolocation.enableLocation().then((result) => {
console.info('[lbs_js] test enableLocation result: ' + result);
expect(result).assertTrue();
}).catch((error) => {
console.info("[lbs_js] promise then error." + error.message);
expect().assertFail();
});
let geocodeRequest = {"description": "北京天安门", "maxItems": 1, "minLatitude":39.95 , let geocodeRequest = {"description": "北京天安门", "maxItems": 1, "minLatitude":39.95 ,
"minLongitude":116.45,"maxLatitude":39.85,"maxLongitude":116.35}; "minLongitude":116.45,"maxLatitude":39.85,"maxLongitude":116.35};
await geolocation.getAddressesFromLocationName(geocodeRequest).then((result) => { await geolocation.getAddressesFromLocationName(geocodeRequest).then((result) => {
...@@ -670,13 +512,6 @@ describe('geolocationTest', function () { ...@@ -670,13 +512,6 @@ describe('geolocationTest', function () {
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('SUB_HSS_LocationSystem_Geo_0016', 0, async function (done) { it('SUB_HSS_LocationSystem_Geo_0016', 0, async function (done) {
await geolocation.enableLocation().then((result) => {
console.info('[lbs_js] testenableLocation result: ' + result);
expect(result).assertTrue();
}).catch((error) => {
console.info("[lbs_js] promise then error." + error.message);
expect().assertFail();
});
let geocodeRequest1 = {"description": "上海金穗路1800号", "maxItems": 1, "minLatitude":-90 , let geocodeRequest1 = {"description": "上海金穗路1800号", "maxItems": 1, "minLatitude":-90 ,
"minLongitude":121.5782001832,"maxLatitude":31.1537977881,"maxLongitude":121.8026736943}; "minLongitude":121.5782001832,"maxLatitude":31.1537977881,"maxLongitude":121.8026736943};
await geolocation.getAddressesFromLocationName(geocodeRequest1).then((result) => { await geolocation.getAddressesFromLocationName(geocodeRequest1).then((result) => {
...@@ -761,13 +596,6 @@ describe('geolocationTest', function () { ...@@ -761,13 +596,6 @@ describe('geolocationTest', function () {
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('SUB_HSS_LocationSystem_Geo_0017', 0, async function (done) { it('SUB_HSS_LocationSystem_Geo_0017', 0, async function (done) {
await geolocation.enableLocation().then((result) => {
console.info('[lbs_js] test enableLocation result: ' + result);
expect(result).assertTrue();
}).catch((error) => {
console.info("[lbs_js] promise then error." + error.message);
expect().assertFail();
});
let geocodeRequest1 = {"description": "北京天安门", "maxItems": 1, "minLatitude":39.85 , let geocodeRequest1 = {"description": "北京天安门", "maxItems": 1, "minLatitude":39.85 ,
"minLongitude":-180,"maxLatitude":39.95,"maxLongitude":116.45}; "minLongitude":-180,"maxLatitude":39.95,"maxLongitude":116.45};
await geolocation.getAddressesFromLocationName(geocodeRequest1).then((result) => { await geolocation.getAddressesFromLocationName(geocodeRequest1).then((result) => {
...@@ -852,13 +680,6 @@ describe('geolocationTest', function () { ...@@ -852,13 +680,6 @@ describe('geolocationTest', function () {
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('SUB_HSS_LocationSystem_LocSwitch_0001', 0, async function (done) { it('SUB_HSS_LocationSystem_LocSwitch_0001', 0, async function (done) {
await offLocationMode();
geolocation.enableLocation(async(err, data) => {
if (err) {
console.info('[lbs_js] enableLocation callback err is : ' + err );
}
console.info("[lbs_js] enableLocation callback data: " + data);
expect(data).assertTrue();
geolocation.isLocationEnabled(async(err, data) => { geolocation.isLocationEnabled(async(err, data) => {
if (err) { if (err) {
console.info('[lbs_js] getLocationSwitchState err is : ' + err ); console.info('[lbs_js] getLocationSwitchState err is : ' + err );
...@@ -867,28 +688,9 @@ describe('geolocationTest', function () { ...@@ -867,28 +688,9 @@ describe('geolocationTest', function () {
console.info('[lbs_js] getLocationSwitchState callback data1: ' + data); console.info('[lbs_js] getLocationSwitchState callback data1: ' + data);
expect(data).assertTrue(); expect(data).assertTrue();
} }
geolocation.disableLocation(async(err, data) => {
if (err) {
console.info('[lbs_js] disableLocation callback err is : ' + err );
}else {
console.info("[lbs_js] disableLocation callback data: " + data);
expect(data).assertTrue();
}
geolocation.isLocationEnabled(async(err, data) => {
if (err) {
console.info('[lbs_js] getLocationSwitchState err is : ' + err );
}else {
console.info('[lbs_js] getLocationSwitchState callback data2: ' + data);
expect(data).assertFalse();
done() done()
}
});
})
}) })
}); });
});
/** /**
* @tc.number LocSwitch_0002 * @tc.number LocSwitch_0002
...@@ -899,51 +701,24 @@ describe('geolocationTest', function () { ...@@ -899,51 +701,24 @@ describe('geolocationTest', function () {
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('SUB_HSS_LocationSystem_LocSwitch_0002', 0, async function (done) { it('SUB_HSS_LocationSystem_LocSwitch_0002', 0, async function (done) {
await offLocationMode();
await geolocation.enableLocation().then((result) => {
console.info('[lbs_js] testenableLocation result: ' + result);
expect(result).assertTrue();
}).catch((error) => {
console.info("[lbs_js] promise then error." + error.message);
expect().assertFail();
});
await geolocation.isLocationEnabled().then((result) => { await geolocation.isLocationEnabled().then((result) => {
console.info('[lbs_js] getLocationSwitchStateLocSwitch_00021 result: ' + result); console.info('[lbs_js] getLocationSwitchStateLocSwitch_00021 result: ' + result);
expect(result).assertTrue(); expect(result).assertTrue();
}).catch((error) => { }).catch((error) => {
expect().assertFail(); expect().assertFail();
}); });
await geolocation.disableLocation().then((data) => {
console.info('[lbs_js] disableLocation data: ' + data);
expect(data).assertTrue();
});
await geolocation.isLocationEnabled().then((result) => {
console.info('[lbs_js] getLocationSwitchStateLocSwitch_00022 result: ' + result);
expect(result).assertFalse();
}).catch((error) => {
expect().assertFail();
});
done(); done();
}) })
/** /**
* @tc.number LocSwitch_0003 * @tc.number LocSwitch_0003
* @tc.name SUB_HSS_LocationSystem_LocSwitch_0003 * @tc.name SUB_HSS_LocationSystem_LocSwitch_0003
* @tc.desc Test requestEnableLocation api . * @tc.desc Test requestrequestEnableLocation api .
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('SUB_HSS_LocationSystem_LocSwitch_0003', 0, async function (done) { it('SUB_HSS_LocationSystem_LocSwitch_0003', 0, async function (done) {
await offLocationMode();
geolocation.requestEnableLocation(async(err, data) => {
if (err) {
console.info('[lbs_js] requestEnableLocation err is : ' + err );
}else {
console.info('[lbs_js] requestEnableLocation callback data1: ' + data);
expect(data).assertTrue();
}
geolocation.isLocationEnabled(async(err, data) => { geolocation.isLocationEnabled(async(err, data) => {
if (err) { if (err) {
console.info('[lbs_js] getLocationSwitchState callback err is : ' + err ); console.info('[lbs_js] getLocationSwitchState callback err is : ' + err );
...@@ -951,29 +726,20 @@ describe('geolocationTest', function () { ...@@ -951,29 +726,20 @@ describe('geolocationTest', function () {
}else { }else {
console.info("[lbs_js] getLocationSwitchState callback data: " + data); console.info("[lbs_js] getLocationSwitchState callback data: " + data);
expect(data).assertTrue(); expect(data).assertTrue();
done()
} }
done()
}) })
}); });
});
/** /**
* @tc.number LocSwitch_0004 * @tc.number LocSwitch_0004
* @tc.name SUB_HSS_LocationSystem_LocSwitch_0004 * @tc.name SUB_HSS_LocationSystem_LocSwitch_0004
* @tc.desc Test requestEnableLocation api . * @tc.desc Test requestrequestEnableLocation api .
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('SUB_HSS_LocationSystem_LocSwitch_0004', 0, async function (done) { it('SUB_HSS_LocationSystem_LocSwitch_0004', 0, async function (done) {
await offLocationMode();
await geolocation.requestEnableLocation().then((result) => {
console.info('[lbs_js] requestEnableLocation result: ' + result);
expect(result).assertTrue();
}).catch((error) => {
console.info("[lbs_js] promise then error." + error.message);
expect().assertFail();
});
await geolocation.isLocationEnabled().then((result1) => { await geolocation.isLocationEnabled().then((result1) => {
console.info('[lbs_js] getLocationSwitchStateLocSwitch_0004 result: ' + result1); console.info('[lbs_js] getLocationSwitchStateLocSwitch_0004 result: ' + result1);
expect(result1).assertTrue(); expect(result1).assertTrue();
...@@ -992,7 +758,6 @@ describe('geolocationTest', function () { ...@@ -992,7 +758,6 @@ describe('geolocationTest', function () {
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('SUB_HSS_LocationSystem_LocSwitch_0005', 0, async function (done) { it('SUB_HSS_LocationSystem_LocSwitch_0005', 0, async function (done) {
await offLocationMode();
geolocation.on('locationServiceState', geolocation.on('locationServiceState',
(result) => { (result) => {
if(err){ if(err){
...@@ -1002,11 +767,11 @@ describe('geolocationTest', function () { ...@@ -1002,11 +767,11 @@ describe('geolocationTest', function () {
expect(true).assertEqual(result !=null); expect(true).assertEqual(result !=null);
done(); done();
}); });
geolocation.enableLocation((err, data) => { geolocation.requestEnableLocation((err, data) => {
if (err) { if (err) {
console.info('[lbs_js] enableLocation callback err is : ' + err ); console.info('[lbs_js] requestEnableLocation callback err is : ' + err );
}else { }else {
console.info("[lbs_js] enableLocation callback data: " + data); console.info("[lbs_js] requestEnableLocation callback data: " + data);
expect(data).assertTrue(); expect(data).assertTrue();
} }
done() done()
...@@ -1032,11 +797,11 @@ describe('geolocationTest', function () { ...@@ -1032,11 +797,11 @@ describe('geolocationTest', function () {
*/ */
it('SUB_HSS_LocationSystem_SingleLoc_0001', 0, async function(done) { it('SUB_HSS_LocationSystem_SingleLoc_0001', 0, async function(done) {
let currentLocationRequest = { "priority": 0x200, "scenario": 0x301, "timeoutMs": 10, "maxAccuracy": 0 }; let currentLocationRequest = { "priority": 0x200, "scenario": 0x301, "timeoutMs": 10, "maxAccuracy": 0 };
geolocation.enableLocation(async(err, data) => { geolocation.requestEnableLocation(async(err, data) => {
if (err) { if (err) {
console.info('[lbs_js] enableLocation callback err is : ' + err ); console.info('[lbs_js] requestEnableLocation callback err is : ' + err );
} }
console.info("[lbs_js] enableLocation callback data: " + data); console.info("[lbs_js] requestEnableLocation callback data: " + data);
expect(data).assertTrue(); expect(data).assertTrue();
geolocation.getCurrentLocation(currentLocationRequest, geolocation.getCurrentLocation(currentLocationRequest,
async(err, result) => { async(err, result) => {
...@@ -1060,7 +825,6 @@ describe('geolocationTest', function () { ...@@ -1060,7 +825,6 @@ describe('geolocationTest', function () {
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('SUB_HSS_LocationSystem_SingleLoc_0002', 0, async function (done) { it('SUB_HSS_LocationSystem_SingleLoc_0002', 0, async function (done) {
await changedLocationMode();
let currentLocationRequest = { "priority": 0x203, "scenario": 0x301, "timeoutMs": 10, "maxAccuracy": 0 }; let currentLocationRequest = { "priority": 0x203, "scenario": 0x301, "timeoutMs": 10, "maxAccuracy": 0 };
try { try {
geolocation.getCurrentLocation(currentLocationRequest).then( (result) => { geolocation.getCurrentLocation(currentLocationRequest).then( (result) => {
...@@ -1082,7 +846,6 @@ describe('geolocationTest', function () { ...@@ -1082,7 +846,6 @@ describe('geolocationTest', function () {
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('SUB_HSS_LocationSystem_SingleLoc_0003', 0, async function(done) { it('SUB_HSS_LocationSystem_SingleLoc_0003', 0, async function(done) {
await changedLocationMode();
let currentLocationRequest = { "priority": 0x200, "scenario": 0x302, "timeoutMs": 10, "maxAccuracy": 0 }; let currentLocationRequest = { "priority": 0x200, "scenario": 0x302, "timeoutMs": 10, "maxAccuracy": 0 };
geolocation.getCurrentLocation(currentLocationRequest, geolocation.getCurrentLocation(currentLocationRequest,
(err, result) => { (err, result) => {
...@@ -1104,7 +867,6 @@ describe('geolocationTest', function () { ...@@ -1104,7 +867,6 @@ describe('geolocationTest', function () {
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('SUB_HSS_LocationSystem_SingleLoc_0004', 0, async function(done) { it('SUB_HSS_LocationSystem_SingleLoc_0004', 0, async function(done) {
await changedLocationMode();
let currentLocationRequest = { "priority": 0x200, "scenario": 0x303, "timeoutMs": 10, "maxAccuracy": 0 }; let currentLocationRequest = { "priority": 0x200, "scenario": 0x303, "timeoutMs": 10, "maxAccuracy": 0 };
geolocation.getCurrentLocation(currentLocationRequest, geolocation.getCurrentLocation(currentLocationRequest,
(err, result) => { (err, result) => {
...@@ -1127,7 +889,6 @@ describe('geolocationTest', function () { ...@@ -1127,7 +889,6 @@ describe('geolocationTest', function () {
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('SUB_HSS_LocationSystem_SingleLoc_0005', 0, async function(done) { it('SUB_HSS_LocationSystem_SingleLoc_0005', 0, async function(done) {
await changedLocationMode();
let currentLocationRequest = { "priority": 0x200, "scenario": 0x304, "timeoutMs": 10, "maxAccuracy": 0 }; let currentLocationRequest = { "priority": 0x200, "scenario": 0x304, "timeoutMs": 10, "maxAccuracy": 0 };
geolocation.getCurrentLocation(currentLocationRequest, geolocation.getCurrentLocation(currentLocationRequest,
(err, result) => { (err, result) => {
...@@ -1150,7 +911,6 @@ describe('geolocationTest', function () { ...@@ -1150,7 +911,6 @@ describe('geolocationTest', function () {
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('SUB_HSS_LocationSystem_SingleLoc_0006', 0, async function(done) { it('SUB_HSS_LocationSystem_SingleLoc_0006', 0, async function(done) {
await changedLocationMode();
let currentLocationRequest1 = { "priority": 0x200, "scenario": 0x305, "timeoutMs": 10, "maxAccuracy": 0 }; let currentLocationRequest1 = { "priority": 0x200, "scenario": 0x305, "timeoutMs": 10, "maxAccuracy": 0 };
let currentLocationRequest2= { "priority": 0x200, "scenario": 0x301, "timeoutMs": 10, "maxAccuracy": 0 }; let currentLocationRequest2= { "priority": 0x200, "scenario": 0x301, "timeoutMs": 10, "maxAccuracy": 0 };
geolocation.getCurrentLocation(currentLocationRequest1, geolocation.getCurrentLocation(currentLocationRequest1,
...@@ -1185,7 +945,6 @@ describe('geolocationTest', function () { ...@@ -1185,7 +945,6 @@ describe('geolocationTest', function () {
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('SUB_HSS_LocationSystem_SingleLoc_0007', 0, async function(done) { it('SUB_HSS_LocationSystem_SingleLoc_0007', 0, async function(done) {
await changedLocationMode();
let currentLocationRequest = { "priority": 0x0201, "scenario": 0x0300, "timeoutMs": 10, "maxAccuracy": 0 }; let currentLocationRequest = { "priority": 0x0201, "scenario": 0x0300, "timeoutMs": 10, "maxAccuracy": 0 };
geolocation.getCurrentLocation(currentLocationRequest, geolocation.getCurrentLocation(currentLocationRequest,
(err, result) => { (err, result) => {
...@@ -1209,7 +968,6 @@ describe('geolocationTest', function () { ...@@ -1209,7 +968,6 @@ describe('geolocationTest', function () {
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('SUB_HSS_LocationSystem_SingleLoc_0008', 0, async function(done) { it('SUB_HSS_LocationSystem_SingleLoc_0008', 0, async function(done) {
await changedLocationMode();
let currentLocationRequest = { "priority": 0x0203, "scenario": 0x0300, "timeoutMs": 10, "maxAccuracy": 0 }; let currentLocationRequest = { "priority": 0x0203, "scenario": 0x0300, "timeoutMs": 10, "maxAccuracy": 0 };
geolocation.getCurrentLocation(currentLocationRequest, geolocation.getCurrentLocation(currentLocationRequest,
(err, result) => { (err, result) => {
...@@ -1233,7 +991,6 @@ describe('geolocationTest', function () { ...@@ -1233,7 +991,6 @@ describe('geolocationTest', function () {
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('SUB_HSS_LocationSystem_SingleLoc_0009', 0, async function(done) { it('SUB_HSS_LocationSystem_SingleLoc_0009', 0, async function(done) {
await changedLocationMode();
let currentLocationRequest = { "priority": 0x0202, "scenario": 0x0300, "timeoutMs": 10, "maxAccuracy": 0 }; let currentLocationRequest = { "priority": 0x0202, "scenario": 0x0300, "timeoutMs": 10, "maxAccuracy": 0 };
geolocation.getCurrentLocation(currentLocationRequest, geolocation.getCurrentLocation(currentLocationRequest,
(err, result) => { (err, result) => {
...@@ -1251,3 +1008,4 @@ describe('geolocationTest', function () { ...@@ -1251,3 +1008,4 @@ describe('geolocationTest', function () {
}) })
...@@ -36,9 +36,9 @@ async function changedLocationMode(){ ...@@ -36,9 +36,9 @@ async function changedLocationMode(){
await geolocation.isLocationEnabled().then(async(result) => { await geolocation.isLocationEnabled().then(async(result) => {
console.info('[lbs_js] getLocationSwitchState result: ' + result); console.info('[lbs_js] getLocationSwitchState result: ' + result);
if(!result){ if(!result){
await geolocation.enableLocation().then(async(result) => { await geolocation.requestEnableLocation().then(async(result) => {
await sleep(3000); await sleep(3000);
console.info('[lbs_js] test enableLocation promise result:' + result); console.info('[lbs_js] test requestEnableLocation promise result:' + result);
expect(result).assertTrue(); expect(result).assertTrue();
}).catch((error) => { }).catch((error) => {
console.info("[lbs_js] promise then error." + error.message); console.info("[lbs_js] promise then error." + error.message);
...@@ -93,7 +93,6 @@ describe('geolocationTest', function () { ...@@ -93,7 +93,6 @@ describe('geolocationTest', function () {
}) })
beforeEach(function () { beforeEach(function () {
sleep(3000);
console.info('beforeEach case'); console.info('beforeEach case');
}) })
afterEach(function () { afterEach(function () {
...@@ -108,11 +107,11 @@ describe('geolocationTest', function () { ...@@ -108,11 +107,11 @@ describe('geolocationTest', function () {
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('SUB_HSS_LocationSystem_LocRequest_0001', 0, async function (done) { it('SUB_HSS_LocationSystem_LocRequest_0001', 0, async function (done) {
geolocation.enableLocation((err, data) => { geolocation.requestEnableLocation((err, data) => {
if (err) { if (err) {
console.info('[lbs_js] enableLocation callback err is : ' + err ); console.info('[lbs_js] requestEnableLocation callback err is : ' + err );
}else { }else {
console.info("[lbs_js] enableLocation callback data: " + data); console.info("[lbs_js] requestEnableLocation callback data: " + data);
expect(data).assertTrue(); expect(data).assertTrue();
} }
done() done()
...@@ -151,11 +150,11 @@ describe('geolocationTest', function () { ...@@ -151,11 +150,11 @@ describe('geolocationTest', function () {
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('SUB_HSS_LocationSystem_LocRequest_0002', 0, async function (done) { it('SUB_HSS_LocationSystem_LocRequest_0002', 0, async function (done) {
geolocation.enableLocation((err, data) => { geolocation.requestEnableLocation((err, data) => {
if (err) { if (err) {
console.info('[lbs_js] enableLocation callback err is : ' + err ); console.info('[lbs_js] requestEnableLocation callback err is : ' + err );
}else { }else {
console.info("[lbs_js] enableLocation callback data: " + data); console.info("[lbs_js] requestEnableLocation callback data: " + data);
expect(data).assertTrue(); expect(data).assertTrue();
} }
done() done()
...@@ -194,11 +193,11 @@ describe('geolocationTest', function () { ...@@ -194,11 +193,11 @@ describe('geolocationTest', function () {
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('SUB_HSS_LocationSystem_LocRequest_0003', 0, async function (done) { it('SUB_HSS_LocationSystem_LocRequest_0003', 0, async function (done) {
geolocation.enableLocation((err, data) => { geolocation.requestEnableLocation((err, data) => {
if (err) { if (err) {
console.info('[lbs_js] enableLocation callback err is : ' + err ); console.info('[lbs_js] requestEnableLocation callback err is : ' + err );
}else { }else {
console.info("[lbs_js] enableLocation callback data: " + data); console.info("[lbs_js] requestEnableLocation callback data: " + data);
expect(data).assertTrue(); expect(data).assertTrue();
} }
done() done()
...@@ -237,11 +236,11 @@ describe('geolocationTest', function () { ...@@ -237,11 +236,11 @@ describe('geolocationTest', function () {
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('SUB_HSS_LocationSystem_LocRequest_0004', 0, async function (done) { it('SUB_HSS_LocationSystem_LocRequest_0004', 0, async function (done) {
geolocation.enableLocation((err, data) => { geolocation.requestEnableLocation((err, data) => {
if (err) { if (err) {
console.info('[lbs_js] enableLocation callback err is : ' + err ); console.info('[lbs_js] requestEnableLocation callback err is : ' + err );
}else { }else {
console.info("[lbs_js] enableLocation callback data: " + data); console.info("[lbs_js] requestEnableLocation callback data: " + data);
expect(data).assertTrue(); expect(data).assertTrue();
} }
done() done()
...@@ -280,11 +279,11 @@ describe('geolocationTest', function () { ...@@ -280,11 +279,11 @@ describe('geolocationTest', function () {
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('SUB_HSS_LocationSystem_LocRequest_0005', 0, async function (done) { it('SUB_HSS_LocationSystem_LocRequest_0005', 0, async function (done) {
geolocation.enableLocation((err, data) => { geolocation.requestEnableLocation((err, data) => {
if (err) { if (err) {
console.info('[lbs_js] enableLocation callback err is : ' + err ); console.info('[lbs_js] requestEnableLocation callback err is : ' + err );
}else { }else {
console.info("[lbs_js] enableLocation callback data: " + data); console.info("[lbs_js] requestEnableLocation callback data: " + data);
expect(data).assertTrue(); expect(data).assertTrue();
} }
done() done()
...@@ -323,11 +322,11 @@ describe('geolocationTest', function () { ...@@ -323,11 +322,11 @@ describe('geolocationTest', function () {
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('SUB_HSS_LocationSystem_LocRequest_0006', 0, async function (done) { it('SUB_HSS_LocationSystem_LocRequest_0006', 0, async function (done) {
geolocation.enableLocation((err, data) => { geolocation.requestEnableLocation((err, data) => {
if (err) { if (err) {
console.info('[lbs_js] enableLocation callback err is : ' + err ); console.info('[lbs_js] requestEnableLocation callback err is : ' + err );
}else { }else {
console.info("[lbs_js] enableLocation callback data: " + data); console.info("[lbs_js] requestEnableLocation callback data: " + data);
expect(data).assertTrue(); expect(data).assertTrue();
} }
done() done()
...@@ -348,15 +347,6 @@ describe('geolocationTest', function () { ...@@ -348,15 +347,6 @@ describe('geolocationTest', function () {
expect(true).assertEqual(locationChange !=null); expect(true).assertEqual(locationChange !=null);
done(); done();
}); });
geolocation.disableLocation((err, data) => {
if (err) {
console.info('[lbs_js] disableLocation callback err is : ' + err );
}else {
console.info("[lbs_js] disableLocation callback data: " + data);
expect(data).assertTrue();
}
done()
});
geolocation.on('locationChange',requestInfo2, geolocation.on('locationChange',requestInfo2,
(locationChange) => { (locationChange) => {
if(err){ if(err){
...@@ -366,11 +356,11 @@ describe('geolocationTest', function () { ...@@ -366,11 +356,11 @@ describe('geolocationTest', function () {
expect(true).assertEqual(locationChange !=null); expect(true).assertEqual(locationChange !=null);
done(); done();
}); });
geolocation.enableLocation((err, data) => { geolocation.requestEnableLocation((err, data) => {
if (err) { if (err) {
console.info('[lbs_js] enableLocation callback err is : ' + err ); console.info('[lbs_js] requestEnableLocation callback err is : ' + err );
}else { }else {
console.info("[lbs_js] enableLocation callback data: " + data); console.info("[lbs_js] requestEnableLocation callback data: " + data);
expect(data).assertTrue(); expect(data).assertTrue();
} }
done() done()
...@@ -395,11 +385,11 @@ describe('geolocationTest', function () { ...@@ -395,11 +385,11 @@ describe('geolocationTest', function () {
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('SUB_HSS_LocationSystem_LocRequest_0007', 0, async function (done) { it('SUB_HSS_LocationSystem_LocRequest_0007', 0, async function (done) {
geolocation.enableLocation((err, data) => { geolocation.requestEnableLocation((err, data) => {
if (err) { if (err) {
console.info('[lbs_js] enableLocation callback err is : ' + err ); console.info('[lbs_js] requestEnableLocation callback err is : ' + err );
}else { }else {
console.info("[lbs_js] enableLocation callback data: " + data); console.info("[lbs_js] requestEnableLocation callback data: " + data);
expect(data).assertTrue(); expect(data).assertTrue();
} }
done() done()
...@@ -437,11 +427,11 @@ describe('geolocationTest', function () { ...@@ -437,11 +427,11 @@ describe('geolocationTest', function () {
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('SUB_HSS_LocationSystem_LocRequest_0008', 0, async function (done) { it('SUB_HSS_LocationSystem_LocRequest_0008', 0, async function (done) {
geolocation.enableLocation((err, data) => { geolocation.requestEnableLocation((err, data) => {
if (err) { if (err) {
console.info('[lbs_js] enableLocation callback err is : ' + err ); console.info('[lbs_js] requestEnableLocation callback err is : ' + err );
}else { }else {
console.info("[lbs_js] enableLocation callback data: " + data); console.info("[lbs_js] requestEnableLocation callback data: " + data);
expect(data).assertTrue(); expect(data).assertTrue();
} }
done() done()
...@@ -479,11 +469,11 @@ describe('geolocationTest', function () { ...@@ -479,11 +469,11 @@ describe('geolocationTest', function () {
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('SUB_HSS_LocationSystem_LocRequest_0009', 0, async function (done) { it('SUB_HSS_LocationSystem_LocRequest_0009', 0, async function (done) {
geolocation.enableLocation((err, data) => { geolocation.requestEnableLocation((err, data) => {
if (err) { if (err) {
console.info('[lbs_js] enableLocation callback err is : ' + err ); console.info('[lbs_js] requestEnableLocation callback err is : ' + err );
}else { }else {
console.info("[lbs_js] enableLocation callback data: " + data); console.info("[lbs_js] requestEnableLocation callback data: " + data);
expect(data).assertTrue(); expect(data).assertTrue();
} }
done() done()
...@@ -521,11 +511,11 @@ describe('geolocationTest', function () { ...@@ -521,11 +511,11 @@ describe('geolocationTest', function () {
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('SUB_HSS_LocationSystem_LocRequest_0010', 0, async function (done) { it('SUB_HSS_LocationSystem_LocRequest_0010', 0, async function (done) {
geolocation.enableLocation((err, data) => { geolocation.requestEnableLocation((err, data) => {
if (err) { if (err) {
console.info('[lbs_js] enableLocation callback err is : ' + err ); console.info('[lbs_js] requestEnableLocation callback err is : ' + err );
}else { }else {
console.info("[lbs_js] enableLocation callback data: " + data); console.info("[lbs_js] requestEnableLocation callback data: " + data);
expect(data).assertTrue(); expect(data).assertTrue();
} }
done() done()
...@@ -563,11 +553,11 @@ describe('geolocationTest', function () { ...@@ -563,11 +553,11 @@ describe('geolocationTest', function () {
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('SUB_HSS_LocationSystem_LocRequest_0011', 0, async function (done) { it('SUB_HSS_LocationSystem_LocRequest_0011', 0, async function (done) {
geolocation.enableLocation((err, data) => { geolocation.requestEnableLocation((err, data) => {
if (err) { if (err) {
console.info('[lbs_js] enableLocation callback err is : ' + err ); console.info('[lbs_js] requestEnableLocation callback err is : ' + err );
}else { }else {
console.info("[lbs_js] enableLocation callback data: " + data); console.info("[lbs_js] requestEnableLocation callback data: " + data);
expect(data).assertTrue(); expect(data).assertTrue();
} }
done() done()
...@@ -605,8 +595,8 @@ describe('geolocationTest', function () { ...@@ -605,8 +595,8 @@ describe('geolocationTest', function () {
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('SUB_HSS_LocationSystem_LastLoc_0001', 0, async function(done) { it('SUB_HSS_LocationSystem_LastLoc_0001', 0, async function(done) {
await geolocation.enableLocation().then(async(result) => { await geolocation.requestEnableLocation().then(async(result) => {
console.info('[lbs_js] test enableLocation result: ' + result); console.info('[lbs_js] test requestEnableLocation result: ' + result);
expect(result).assertTrue(); expect(result).assertTrue();
let currentLocationRequest = { "priority": 0x200, "scenario": 0x301, "timeoutMs": 10, "maxAccuracy": 0 }; let currentLocationRequest = { "priority": 0x200, "scenario": 0x301, "timeoutMs": 10, "maxAccuracy": 0 };
geolocation.getCurrentLocation(currentLocationRequest, geolocation.getCurrentLocation(currentLocationRequest,
...@@ -671,11 +661,11 @@ describe('geolocationTest', function () { ...@@ -671,11 +661,11 @@ describe('geolocationTest', function () {
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('SUB_HSS_LocationSystem_LastLoc_0002', 0, async function (done) { it('SUB_HSS_LocationSystem_LastLoc_0002', 0, async function (done) {
geolocation.enableLocation((err, data) => { geolocation.requestEnableLocation((err, data) => {
if (err) { if (err) {
console.info('[lbs_js] enableLocation callback err is : ' + err ); console.info('[lbs_js] requestEnableLocation callback err is : ' + err );
}else { }else {
console.info("[lbs_js] enableLocation callback data: " + data); console.info("[lbs_js] requestEnableLocation callback data: " + data);
expect(data).assertTrue(); expect(data).assertTrue();
} }
done() done()
...@@ -715,193 +705,6 @@ describe('geolocationTest', function () { ...@@ -715,193 +705,6 @@ describe('geolocationTest', function () {
}); });
}) })
/**
* @tc.number Privacy_0001
* @tc.name SUB_HSS_LocationSystem_Privacy_0001
* @tc.desc Test setLocationPrivacyConfirmStatus api .
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('SUB_HSS_LocationSystem_Privacy_0001', 0, async function (done) {
let reqType = 1;
let value = true;
await geolocation.setLocationPrivacyConfirmStatus(reqType, value, async(err, resp)=>{
console.log("[lbs_js] setLocationPrivacyConfirmStatus current type1 is "+ JSON.stringify(resp))
await geolocation.isLocationPrivacyConfirmed(reqType ,async(err,resp) => {
console.log("[lbs_js] isLocationPrivacyConfirmed current type1 is "+ JSON.stringify(resp))
expect(resp).assertTrue();
await geolocation.setLocationPrivacyConfirmStatus(reqType, false, async(err, resp)=>{
console.log("[lbs_js] setLocationPrivacyConfirmStatus current type2 is "+ JSON.stringify(resp))
await geolocation.isLocationPrivacyConfirmed(reqType ,(err,resp) => {
console.log("[lbs_js] isLocationPrivacyConfirmed current type2 is "+ JSON.stringify(resp))
expect(resp).assertFalse();
done();
});
});
});
});
})
/**
* @tc.number Privacy_0002
* @tc.name SUB_HSS_LocationSystem_Privacy_0002
* @tc.desc Test setLocationPrivacyConfirmStatus api .
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('SUB_HSS_LocationSystem_Privacy_0002', 0, async function (done) {
await geolocation.setLocationPrivacyConfirmStatus(1,true).then(async(result) => {
console.info('[lbs_js] setLocationPrivacyConfirmStatus promise1 result: ' + result);
expect(result).assertTrue();
await geolocation.isLocationPrivacyConfirmed(1).then( async(result) => {
console.info('[lbs_js] isLocationPrivacyConfirmed promise1 result: ' + result);
expect(result).assertTrue();
await geolocation.setLocationPrivacyConfirmStatus(1,false).then(async(result) => {
console.info('[lbs_js] setLocationPrivacyConfirmStatus promise2 result: ' + result);
expect(result).assertTrue();
await geolocation.isLocationPrivacyConfirmed(1).then( (result) => {
console.info('[lbs_js] isLocationPrivacyConfirmed promise2 result: ' + result);
expect(result).assertFalse();
done()
});
}).catch((error) => {
console.info("[lbs_js] setLocationPrivacyConfirmStatus then error." + error.message);
expect().assertFail();
});
});
}).catch((error) => {
console.info("[lbs_js] setLocationPrivacyConfirmStatus then error." + error.message);
expect().assertFail();
});
})
/**
* @tc.number Privacy_0003
* @tc.name SUB_HSS_LocationSystem_Privacy_0003
* @tc.desc Test setLocationPrivacyConfirmStatus api .
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('SUB_HSS_LocationSystem_Privacy_0003', 0, async function (done) {
let reqType = 2;
let value = true;
await geolocation.setLocationPrivacyConfirmStatus(reqType, value, async(err, resp)=>{
console.log("[lbs_js] setLocationPrivacyConfirmStatus current type1 is "+ JSON.stringify(resp))
await geolocation.isLocationPrivacyConfirmed(reqType ,async(err,resp) => {
console.log("[lbs_js] isLocationPrivacyConfirmed current type1 is "+ JSON.stringify(resp))
expect(resp).assertTrue();
await geolocation.setLocationPrivacyConfirmStatus(reqType, false, async(err, resp)=>{
console.log("[lbs_js] setLocationPrivacyConfirmStatus current type2 is "+ JSON.stringify(resp))
await geolocation.isLocationPrivacyConfirmed(reqType ,(err,resp) => {
console.log("[lbs_js] isLocationPrivacyConfirmed current type2 is "+ JSON.stringify(resp))
expect(resp).assertFalse();
done();
});
});
});
});
})
/**
* @tc.number Privacy_0004
* @tc.name SUB_HSS_LocationSystem_Privacy_0004
* @tc.desc Test setLocationPrivacyConfirmStatus api .
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('SUB_HSS_LocationSystem_Privacy_0004', 0, async function (done) {
await geolocation.setLocationPrivacyConfirmStatus(2,true).then(async(result) => {
console.info('[lbs_js] setLocationPrivacyConfirmStatus promise1 result: ' + result);
expect(result).assertTrue();
await geolocation.isLocationPrivacyConfirmed(2).then( async(result) => {
console.info('[lbs_js] isLocationPrivacyConfirmed promise1 result: ' + result);
expect(result).assertTrue();
await geolocation.setLocationPrivacyConfirmStatus(2,false).then(async(result) => {
console.info('[lbs_js] setLocationPrivacyConfirmStatus promise2 result: ' + result);
expect(result).assertTrue();
await geolocation.isLocationPrivacyConfirmed(2).then( (result) => {
console.info('[lbs_js] isLocationPrivacyConfirmed promise2 result: ' + result);
expect(result).assertFalse();
done()
});
}).catch((error) => {
console.info("[lbs_js] setLocationPrivacyConfirmStatus then error." + error.message);
expect().assertFail();
});
});
}).catch((error) => {
console.info("[lbs_js] setLocationPrivacyConfirmStatus then error." + error.message);
expect().assertFail();
});
})
/**
* @tc.number Privacy_0005
* @tc.name SUB_HSS_LocationSystem_Privacy_0005
* @tc.desc Test setLocationPrivacyConfirmStatus api .
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('SUB_HSS_LocationSystem_Privacy_0005', 0, async function (done) {
await geolocation.setLocationPrivacyConfirmStatus(1,true).then(async(resp) => {
console.log("[lbs_js] setLocationPrivacyConfirmStatus current type1 is "+ JSON.stringify(resp))
expect(resp).assertTrue();
await geolocation.setLocationPrivacyConfirmStatus(2,false).then(async(resp) => {
console.log("[lbs_js] setLocationPrivacyConfirmStatus current type1 is "+ JSON.stringify(resp))
expect(resp).assertTrue();
await geolocation.isLocationPrivacyConfirmed(1).then(async(resp) => {
console.log("[lbs_js] isLocationPrivacyConfirmed current type2 is "+ JSON.stringify(resp))
expect(resp).assertTrue();
await geolocation.isLocationPrivacyConfirmed(2).then(resp => {
console.log("[lbs_js] isLocationPrivacyConfirmed current type2 is "+ JSON.stringify(resp))
expect(resp).assertFalse();
done();
});
}).catch((error) => {
console.info("[lbs_js] setLocationPrivacyConfirmStatus then error." + error.message);
expect().assertFail();
});
});
}).catch((error) => {
console.info("[lbs_js] setLocationPrivacyConfirmStatus then error." + error.message);
expect().assertFail();
});
})
/**
* @tc.number Privacy_0006
* @tc.name SUB_HSS_LocationSystem_Privacy_0006
* @tc.desc Test setLocationPrivacyConfirmStatus api .
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('SUB_HSS_LocationSystem_Privacy_0006', 0, async function (done) {
await geolocation.setLocationPrivacyConfirmStatus(1,false).then(async(resp) => {
console.log("[lbs_js] setLocationPrivacyConfirmStatus current type1 is "+ JSON.stringify(resp))
expect(resp).assertTrue();
await geolocation.setLocationPrivacyConfirmStatus(2,true).then(async(resp) => {
console.log("[lbs_js] setLocationPrivacyConfirmStatus current type1 is "+ JSON.stringify(resp))
expect(resp).assertTrue();
await geolocation.isLocationPrivacyConfirmed(1).then(async(resp) => {
console.log("[lbs_js] isLocationPrivacyConfirmed current type2 is "+ JSON.stringify(resp))
expect(resp).assertFalse();
await geolocation.isLocationPrivacyConfirmed(2).then(resp => {
console.log("[lbs_js] isLocationPrivacyConfirmed current type2 is "+ JSON.stringify(resp))
expect(resp).assertTrue();
done();
})
})
})
})
})
/** /**
* @tc.number Gnss_0001 * @tc.number Gnss_0001
* @tc.name SUB_HSS_LocationSystem_Gnss_0001 * @tc.name SUB_HSS_LocationSystem_Gnss_0001
...@@ -1153,11 +956,11 @@ describe('geolocationTest', function () { ...@@ -1153,11 +956,11 @@ describe('geolocationTest', function () {
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('SUB_HSS_LocationSystem_Batching_0002', 0, async function (done) { it('SUB_HSS_LocationSystem_Batching_0002', 0, async function (done) {
geolocation.enableLocation((err, data) => { geolocation.requestEnableLocation((err, data) => {
if (err) { if (err) {
console.info('[lbs_js] enableLocation callback err is : ' + err ); console.info('[lbs_js] requestEnableLocation callback err is : ' + err );
}else { }else {
console.info("[lbs_js] enableLocation callback data: " + data); console.info("[lbs_js] requestEnableLocation callback data: " + data);
expect(data).assertTrue(); expect(data).assertTrue();
} }
done() done()
...@@ -1381,3 +1184,4 @@ describe('geolocationTest', function () { ...@@ -1381,3 +1184,4 @@ describe('geolocationTest', function () {
}) })
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册