提交 f8bb3cf2 编写于 作者: Q quanli

location update0830

Signed-off-by: Nquanli <quanli1@huawei.com>
上级 49a9a0b3
...@@ -89,7 +89,7 @@ describe('bluetoothBLETest', function() { ...@@ -89,7 +89,7 @@ describe('bluetoothBLETest', function() {
}) })
/** /**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BLE_Connect_0300 * @tc.number SUB_COMMUNICATION_BLUETOOTH_BLE_Connect_0200
* @tc.name testGetConnectedBLEDevices * @tc.name testGetConnectedBLEDevices
* @tc.desc Test getConnectedBLEDevices api . * @tc.desc Test getConnectedBLEDevices api .
* @tc.size MEDIUM * @tc.size MEDIUM
...@@ -97,13 +97,40 @@ describe('bluetoothBLETest', function() { ...@@ -97,13 +97,40 @@ describe('bluetoothBLETest', function() {
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('SUB_COMMUNICATION_BLUETOOTH_BLE_GattConnect_0300', 0, function () { it('SUB_COMMUNICATION_BLUETOOTH_BLE_GattConnect_0200', 0, function () {
let result = bluetooth.BLE.getConnectedBLEDevices(); let result = bluetooth.BLE.getConnectedBLEDevices();
console.info("[bluetooth_js] getConnDev:" + JSON.stringify(result) console.info("[bluetooth_js] getConnDev:" + JSON.stringify(result)
+ "length:" +result.length); + "length:" +result.length);
expect(result.length).assertEqual(0); expect(result.length).assertEqual(0);
}) })
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BLE_Connect_0300
* test Client BLEconnectStateChange
* @tc.desc Test on and off api
* @tc.size MEDIUM
* @ since 7
* @tc.type Function
* @tc.level Level 2
*/
it('SUB_COMMUNICATION_BLUETOOTH_BLE_GattConnect_0300', 0, async function (done) {
function ConnectStateChanged(state) {
console.log('bluetooth connect state changed');
let connectState = state.state;
console.info('[bluetooth_js] state changed' + connectState)
expect(true).assertEqual(connectState!=null);
}
let gattClient = bluetooth.BLE.createGattClientDevice("11:22:33:44:55:66");
await gattClient.on('BLEConnectionStateChange', ConnectStateChanged);
let ret = gattClient.connect();
console.info('[bluetooth_js] gattClient connect' + ret)
expect(ret).assertTrue();
gattClient.disconnect();
await gattClient.off("BLEConnectionStateChange");
done()
})
/** /**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BLE_GetRssiValue_0100 * @tc.number SUB_COMMUNICATION_BLUETOOTH_BLE_GetRssiValue_0100
* @tc.name testgetRssiValue * @tc.name testgetRssiValue
...@@ -427,6 +454,37 @@ describe('bluetoothBLETest', function() { ...@@ -427,6 +454,37 @@ describe('bluetoothBLETest', function() {
done() done()
}) })
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BLE_ReadCharacteristic_0300
* @tc.name test characteristicReadOn
* @tc.desc Test On and off api.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
*/
it('SUB_COMMUNICATION_BLUETOOTH_BLE_ReadCharacteristic_0300', 0, async function (done) {
let arrayBufferCCC = new ArrayBuffer(8);
let cccValue = new Uint8Array(arrayBufferCCC);
cccValue[0] = 1123;
function ReadCharacteristicReq(CharacteristicReadReq) {
let deviceId = CharacteristicReadReq.deviceId;
let transId = CharacteristicReadReq.transId;
let offset = CharacteristicReadReq.offset;
let characteristicUuid = CharacteristicReadReq.characteristicUuid;
let serverResponse = {deviceId: deviceId, transId: transId,
status: 0, offset: offset, value:arrayBufferCCC};
let ret = gattServer.sendResponse(serverResponse);
console.info('[bluetooth_js] sendResponse ret : ' + ret);
expect(ret).assertEqual(false);
}
let gattServer = bluetooth.BLE.createGattServer();
await gattServer.on("characteristicRead", ReadCharacteristicReq);
await gattServer.off("characteristicRead");
done()
})
/** /**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BLE_ReadDescriptor_0100 * @tc.number SUB_COMMUNICATION_BLUETOOTH_BLE_ReadDescriptor_0100
* @tc.name testReadDescriptorValue * @tc.name testReadDescriptorValue
...@@ -489,6 +547,41 @@ describe('bluetoothBLETest', function() { ...@@ -489,6 +547,41 @@ describe('bluetoothBLETest', function() {
done() done()
}) })
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BLE_ReadDescriptor_0300
* @tc.name test ReadDescriptorOn
* @tc.desc Test On and Off api.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
*/
it('SUB_COMMUNICATION_BLUETOOTH_BLE_ReadDescriptor_0300', 0, async function (done) {
let arrayBufferCCC = new ArrayBuffer(8);
let cccValue = new Uint8Array(arrayBufferCCC);
cccValue[0] = 1011;
function ReadDescriptorReq(DescriptorReadReq) {
let deviceId = DescriptorReadReq.deviceId;
let transId = DescriptorReadReq.transId;
let offset = DescriptorReadReq.offset;
let characteristicUuid = DescriptorReadReq.characteristicUuid;
let serverResponse = {deviceId: deviceId, transId: transId,
status: 0, offset: offset, value:arrayBufferCCC};
let ret = gattServer.sendResponse(serverResponse);
console.info('[bluetooth_js]sendResponse ret : ' + ret);
expect(ret).assertEqual(false);
console.info("[bluetooth_js] DesRedon jsondata:" +
'deviceId:' + deviceId + 'transId:' +transId + 'offset:' +
offset +'descriptorUuid:' + DescriptorReadReq.descriptorUuid +
'characteristicUuid:' +characteristicUuid +
'serviceUuid:' + DescriptorReadReq.serviceUuid);
expect(true).assertEqual(DescriptorReadReq !=null);
}
let gattServer = bluetooth.BLE.createGattServer();
await gattServer.on("descriptorRead", ReadDescriptorReq);
await gattServer.off("descriptorRead");
done()
})
/** /**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BLE_WriteCharacteristic_0100 * @tc.number SUB_COMMUNICATION_BLUETOOTH_BLE_WriteCharacteristic_0100
* @tc.name testWriteCharacteristicValue * @tc.name testWriteCharacteristicValue
...@@ -532,6 +625,40 @@ describe('bluetoothBLETest', function() { ...@@ -532,6 +625,40 @@ describe('bluetoothBLETest', function() {
expect(ret).assertEqual(false); expect(ret).assertEqual(false);
}) })
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BLE_WriteCharacteristic_0300
* @tc.name test characteristicWriteOn
* @tc.desc Test on and off api.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
*/
it('SUB_COMMUNICATION_BLUETOOTH_BLE_WriteCharacteristic_0300', 0, async function (done) {
let arrayBufferCCC = new ArrayBuffer(8);
let cccValue = new Uint8Array(arrayBufferCCC);
function WriteCharacteristicReq(CharacteristicWriteReq) {
let deviceId = CharacteristicWriteReq.deviceId;
let transId = CharacteristicWriteReq.transId;
let offset = CharacteristicWriteReq.offset;
let isPrep = CharacteristicWriteReq.isPrep;
let needRsp = CharacteristicWriteReq.needRsp;
let value = new Uint8Array(CharacteristicWriteReq.value);
let characteristicUuid = CharacteristicWriteReq.characteristicUuid;
cccValue[0] = value[0];
let serverResponse = {deviceId: deviceId, transId: transId,
status: 0, offset: offset, value:arrayBufferCCC};
let ret = gattServer.sendResponse(serverResponse);
console.info('[bluetooth_js] sendResponse ret : ' + ret);
expect(ret).assertEqual(false);
}
let gattServer = bluetooth.BLE.createGattServer();
gattServer.on("characteristicWrite", WriteCharacteristicReq);
gattServer.off("characteristicWrite");
done()
})
/** /**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BLE_WriteDescriptor_0100 * @tc.number SUB_COMMUNICATION_BLUETOOTH_BLE_WriteDescriptor_0100
* @tc.name testWriteDescriptorValue * @tc.name testWriteDescriptorValue
...@@ -567,6 +694,47 @@ describe('bluetoothBLETest', function() { ...@@ -567,6 +694,47 @@ describe('bluetoothBLETest', function() {
expect(ret).assertEqual(false); expect(ret).assertEqual(false);
}) })
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BLE_WriteDescriptor_0300
* @tc.name test WriteDescriptorOn
* @tc.desc Test on and off api.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
*/
it('SUB_COMMUNICATION_BLUETOOTH_BLE_WriteDescriptor_0300', 0, async function (done) {
let arrayBufferDesc = new ArrayBuffer(8);
let descValue = new Uint8Array(arrayBufferDesc);
function WriteDescriptorReq(DescriptorWriteReq) {
let deviceId = DescriptorWriteReq.deviceId;
let transId = DescriptorWriteReq.transId;
let offset = DescriptorWriteReq.offset;
let isPrep = DescriptorWriteReq.isPrep;
let needRsp = DescriptorWriteReq.needRsp;
let value = new Uint8Array(DescriptorWriteReq.value);
let descriptorUuid = DescriptorWriteReq.descriptorUuid;
descValue[0] = value[0];
let serverResponse = {deviceId: deviceId, transId: transId,
status: 0, offset: offset, value:arrayBufferDesc};
let ret = gattServer.sendResponse(serverResponse);
console.info('[bluetooth_js] sendResponse ret : ' + ret);
expect(ret).assertEqual(false);
console.info("[bluetooth_js] desWriOn jsondata: " +'deviceId: '
+ deviceId + 'transId:' + transId + 'offset:' + offset +'descriptorUuid:'
+ descriptorUuid + 'charUuid:' + DescriptorWriteReq.characteristicUuid +
'serviceUuid:' + DescriptorWriteReq.serviceUuid +
'value:' + DescriptorWriteReq.value + 'needRsp' +
needRsp + 'isPrep:' +isPrep );
expect(true).assertEqual(DescriptorWriteReq !=null);
}
let gattServer = bluetooth.BLE.createGattServer();
gattServer.on("descriptorWrite", WriteDescriptorReq);
gattServer.off("descriptorWrite");
done()
})
/** /**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BLE_NotifyCharacteristic_0100 * @tc.number SUB_COMMUNICATION_BLUETOOTH_BLE_NotifyCharacteristic_0100
* @tc.name testSetNotifyCharacteristicChanged * @tc.name testSetNotifyCharacteristicChanged
...@@ -647,7 +815,7 @@ describe('bluetoothBLETest', function() { ...@@ -647,7 +815,7 @@ describe('bluetoothBLETest', function() {
* @tc.desc Test SetNotifyCharacteristicChanged api. * @tc.desc Test SetNotifyCharacteristicChanged api.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 3
*/ */
it('SUB_COMMUNICATION_BLUETOOTH_BLE_SetNotifyCharacteristic_0300', 0, async function (done) { it('SUB_COMMUNICATION_BLUETOOTH_BLE_SetNotifyCharacteristic_0300', 0, async function (done) {
let gattClient = bluetooth.BLE.createGattClientDevice("11:22:33:44:55:66"); let gattClient = bluetooth.BLE.createGattClientDevice("11:22:33:44:55:66");
...@@ -657,6 +825,50 @@ describe('bluetoothBLETest', function() { ...@@ -657,6 +825,50 @@ describe('bluetoothBLETest', function() {
done(); done();
}) })
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BLE_NotifyCharacteristic_0400
* @tc.name test BLECharacteristicChangeON
* @tc.desc Test On and off api.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
*/
it('SUB_COMMUNICATION_BLUETOOTH_BLE_SetNotifyCharacteristic_0400', 0, async function (done) {
let gattClient = bluetooth.BLE.createGattClientDevice("11:22:33:44:55:66");
function CharacteristicChange(CharacteristicChangeReq) {
let serviceUuid = CharacteristicChangeReq.serviceUuid;
let characteristicUuid = CharacteristicChangeReq.characteristicUuid;
let value = new Uint8Array(CharacteristicChangeReq.characteristicValue);
expect(true).assertEqual(CharacteristicChangeReq !=null);
}
gattClient.on('BLECharacteristicChange', CharacteristicChange);
let descriptors = [];
let arrayBuffer = new ArrayBuffer(8);
let desValue = new Uint8Array(arrayBuffer);
desValue[0] = 11;
let arrayBufferNotify = new ArrayBuffer(8);
let descNotifyValue = new Uint8Array(arrayBufferNotify);
descNotifyValue[0] = 1
let descriptor = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
descriptorUuid: '00001830-0000-1000-8000-00805F9B34FB',
descriptorValue: arrayBuffer};
let descriptorNotify = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
descriptorUuid: '00002902-0000-1000-8000-00805F9B34FB',
descriptorValue: arrayBufferNotify};
descriptors[0] = descriptor;
descriptors[1] = descriptorNotify;
let arrayBufferCCC = new ArrayBuffer(8);
let cccValue = new Uint8Array(arrayBufferCCC);
cccValue[0] = 1;
let characteristic = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
characteristicValue: arrayBufferCCC, descriptors:descriptors};
let ret = gattClient.setNotifyCharacteristicChanged(characteristic, false);
expect(ret).assertEqual(false);
gattClient.off('BLECharacteristicChange');
done();
})
/** /**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BLE_NotifyCharacteristic_0300 * @tc.number SUB_COMMUNICATION_BLUETOOTH_BLE_NotifyCharacteristic_0300
* @tc.name testSetNotifyCharacteristicChanged * @tc.name testSetNotifyCharacteristicChanged
...@@ -676,3 +888,4 @@ describe('bluetoothBLETest', function() { ...@@ -676,3 +888,4 @@ describe('bluetoothBLETest', function() {
}) })
} }
...@@ -68,6 +68,35 @@ describe('bluetoothBLETest1', function() { ...@@ -68,6 +68,35 @@ describe('bluetoothBLETest1', function() {
}) })
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BLE_Connect_0100
* @tc.name test Server connectStateChange
* @tc.desc Test on and off api .
* @tc.size MEDIUM
* @ since 7
* @tc.type Function
* @tc.level Level 2
*/
it('SUB_COMMUNICATION_BLUETOOTH_BLE_Connect_0100', 0, async function (done) {
function Connected(BLEConnectChangedState) {
let deviceId = BLEConnectChangedState.deviceId;
let status = BLEConnectChangedState.state;
console.info("[bluetooth_js] connectStateChange jsondata:"
+'deviceId:' + deviceId + 'status:' + status);
expect(true).assertEqual(BLEConnectChangedState !=null);
}
let gattServer = bluetooth.BLE.createGattServer();
await gattServer.on("connectStateChange", Connected);
let gattClient = bluetooth.BLE.createGattClientDevice("11:22:33:44:55:66");
let ret = gattClient.connect();
await sleep(2000);
console.info('[bluetooth_js] gattClient connect' + ret)
expect(ret).assertTrue();
await gattServer.off("connectStateChange");
done()
})
/** /**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BLE_AddService_0100 * @tc.number SUB_COMMUNICATION_BLUETOOTH_BLE_AddService_0100
* @tc.name testAddService * @tc.name testAddService
...@@ -83,9 +112,9 @@ describe('bluetoothBLETest1', function() { ...@@ -83,9 +112,9 @@ describe('bluetoothBLETest1', function() {
let ret = gattServer.addService(service); let ret = gattServer.addService(service);
console.info('[bluetooth_js] bluetooth addService characteristics is null result:' + ret); console.info('[bluetooth_js] bluetooth addService characteristics is null result:' + ret);
expect(ret).assertTrue(); expect(ret).assertTrue();
await sleep(3000); await sleep(1000);
let ret1=gattServer.removeService('00001810-0000-1000-8000-00805F9B34FB'); let ret1=gattServer.removeService('00001810-0000-1000-8000-00805F9B34FB');
await sleep(3000); await sleep(1000);
console.info('[bluetooth_js]removeService ret:'+ret1); console.info('[bluetooth_js]removeService ret:'+ret1);
expect(ret1).assertTrue(); expect(ret1).assertTrue();
done(); done();
...@@ -474,7 +503,7 @@ describe('bluetoothBLETest1', function() { ...@@ -474,7 +503,7 @@ describe('bluetoothBLETest1', function() {
let ret = gattServer.addService(gattService); let ret = gattServer.addService(gattService);
console.info('[bluetooth_js] bluetooth addService null characteristicValue result : ' + ret); console.info('[bluetooth_js] bluetooth addService null characteristicValue result : ' + ret);
expect(ret).assertFalse(); expect(ret).assertFalse();
await sleep(2000); await sleep(1000);
let ret1=gattServer.removeService('00001810-0000-1000-8000-00805F9B34FB'); let ret1=gattServer.removeService('00001810-0000-1000-8000-00805F9B34FB');
console.info('[bluetooth_js]removeService ret:'+ret1); console.info('[bluetooth_js]removeService ret:'+ret1);
expect(ret1).assertFalse(); expect(ret1).assertFalse();
...@@ -512,7 +541,7 @@ describe('bluetoothBLETest1', function() { ...@@ -512,7 +541,7 @@ describe('bluetoothBLETest1', function() {
let ret = gattServer.addService(gattService); let ret = gattServer.addService(gattService);
console.info('[bluetooth_js] bluetooth addService null descriptorValue result : ' + ret); console.info('[bluetooth_js] bluetooth addService null descriptorValue result : ' + ret);
expect(ret).assertFalse(); expect(ret).assertFalse();
await sleep(2000); await sleep(1000);
let ret1=gattServer.removeService('00001810-0000-1000-8000-00805F9B34FB'); let ret1=gattServer.removeService('00001810-0000-1000-8000-00805F9B34FB');
console.info('[bluetooth_js]removeService ret:'+ret1); console.info('[bluetooth_js]removeService ret:'+ret1);
expect(ret1).assertFalse(); expect(ret1).assertFalse();
...@@ -539,7 +568,7 @@ describe('bluetoothBLETest1', function() { ...@@ -539,7 +568,7 @@ describe('bluetoothBLETest1', function() {
let retN = gattServer.addService(gattService1); let retN = gattServer.addService(gattService1);
console.info('[bluetooth_js] bluetooth addService2 result : ' + retN); console.info('[bluetooth_js] bluetooth addService2 result : ' + retN);
expect(retN).assertTrue(); expect(retN).assertTrue();
await sleep(2000); await sleep(1000);
let ret1=gattServer.removeService('00001888-0000-1000-8000-00805f9b34fb'); let ret1=gattServer.removeService('00001888-0000-1000-8000-00805f9b34fb');
console.info('[bluetooth_js]removeService ret:'+ret1); console.info('[bluetooth_js]removeService ret:'+ret1);
expect(ret1).assertTrue(); expect(ret1).assertTrue();
...@@ -599,7 +628,7 @@ describe('bluetoothBLETest1', function() { ...@@ -599,7 +628,7 @@ describe('bluetoothBLETest1', function() {
console.info('[bluetooth_js]removeService ret:'+ret1); console.info('[bluetooth_js]removeService ret:'+ret1);
expect(ret1).assertTrue(); expect(ret1).assertTrue();
let ret2=gattServer.removeService('00001810-0000-1000-8000-00805F9B34FB'); let ret2=gattServer.removeService('00001810-0000-1000-8000-00805F9B34FB');
await sleep(2000); await sleep(1000);
console.info('[bluetooth_js]removeService ret:'+ret2); console.info('[bluetooth_js]removeService ret:'+ret2);
expect(ret2).assertFalse(); expect(ret2).assertFalse();
done(); done();
......
/*
* 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 '@ohos/hypium'
let SppType = {
SPP_RFCOMM : 0
}
let MatchMode = {
MATCH_MODE_AGGRESSIVE : 1,
MATCH_MODE_STICKY : 2
}
let MajorClass = {
MAJOR_MISC : 0x0000,
MAJOR_COMPUTER : 0x0100,
MAJOR_PHONE : 0x0200,
MAJOR_NETWORKING : 0x0300,
MAJOR_AUDIO_VIDEO : 0x0400,
MAJOR_PERIPHERAL : 0x0500,
MAJOR_IMAGING : 0x0600,
MAJOR_WEARABLE : 0x0700,
MAJOR_TOY : 0x0800,
MAJOR_HEALTH : 0x0900,
MAJOR_UNCATEGORIZED : 0x1F00
}
export default function bluetoothhostTest() {
describe('bluetoothhostTest', function() {
let gattServer = null;
let gattClient = null;
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');
}
}
beforeAll(function () {
console.info('beforeAll called')
gattServer = bluetooth.BLE.createGattServer();
gattClient = bluetooth.BLE.createGattClientDevice("00:00:00:00:00:00");
})
beforeEach(async function(done) {
console.info('beforeEach called')
await tryToEnableBt()
done()
})
afterEach(function () {
console.info('afterEach called')
})
afterAll(function () {
console.info('afterAll called')
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_ENABLE_0001
* @tc.name testEnableBluetooth
* @tc.desc Test EnableBluetooth api by promise.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('SUB_COMMUNACATION_bluetooth_ENABLE_0001', 0, async function (done) {
let state = bluetooth.getState();
console.info('[bluetooth_js] getState On = '+ JSON.stringify(state));
expect(state).assertEqual(2);
done();
})
/**
* @tc.number SUB_COMMUNACATION_bluetoothble_GET_CONNECTED_BLEDEVICES_0001
* @tc.name testGetConnectedBLEDevices
* @tc.desc Test getConnectedBLEDevices api .
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('SUB_COMMUNACATION_bluetoothble_GET_CONNECTED_BLEDEVICES_0001', 0, async function (done) {
let result = bluetooth.BLE.getConnectedBLEDevices();
console.info("[bluetooth_js] getConnDev:" + JSON.stringify(result)+ "length:" +result.length);
expect(result.length).assertEqual(0);
done();
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_START_ADVERTISING_0001
* @tc.name testStartAdvertising
* @tc.desc Test StartAdvertising api.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('SUB_COMMUNACATION_bluetooth_START_ADVERTISING_0001', 0, async function (done) {
let manufactureValueBuffer = new Uint8Array(4);
manufactureValueBuffer[0] = 1;
manufactureValueBuffer[1] = 2;
manufactureValueBuffer[2] = 3;
manufactureValueBuffer[3] = 4;
let serviceValueBuffer = new Uint8Array(4);
serviceValueBuffer[0] = 4;
serviceValueBuffer[1] = 6;
serviceValueBuffer[2] = 7;
serviceValueBuffer[3] = 8;
let promise = new Promise((resolve) => {
let gattServer = bluetooth.BLE.createGattServer()
gattServer.startAdvertising({
interval:150,
txPower:60,
connectable:true,
},{
serviceUuids:["12"],
manufactureData:[{
manufactureId:4567,
manufactureValue:manufactureValueBuffer.buffer
}],
serviceData:[{
serviceUuid:"1234",
serviceValue:serviceValueBuffer.buffer
}],
},{
serviceUuids:["12"],
manufactureData:[{
manufactureId:1789,
manufactureValue:manufactureValueBuffer.buffer
}],
serviceData:[{
serviceUuid:"1794",
serviceValue:serviceValueBuffer.buffer
}],
});
resolve()
})
await promise.then(done)
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_STOP_ADVERTISING_0001
* @tc.name testStopAdvertising
* @tc.desc Test StopAdvertising api.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('SUB_COMMUNACATION_bluetooth_STOP_ADVERTISING_0001', 0, async function (done) {
let gattServer = bluetooth.BLE.createGattServer();
gattServer.stopAdvertising();
done();
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_GATT_CONNRCT_0001
* @tc.name testConnect
* @tc.desc Test Connect api.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('SUB_COMMUNACATION_bluetooth_GATT_CONNRCT_0001', 0, async function (done) {
gattClient = bluetooth.BLE.createGattClientDevice("00:00:00:00:00:00");
let ret = gattClient.connect();
expect(ret).assertTrue();
done();
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_GET_RSSI_VALUE_CALLBACK
* @tc.name testGetRssiValue
* @tc.desc Test GetRssiValue api by callback.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('SUB_COMMUNACATION_bluetooth_GET_RSSI_VALUE_CALLBACK', 0, async function (done) {
let promise = new Promise((resolve) => {
let gattClient = bluetooth.BLE.createGattClientDevice("00:00:00:00:00:00");
gattClient.getRssiValue((err, data)=> {
console.info('[bluetooth_js] rssi err:' + JSON.stringify(err)+'value:'+JSON.stringify(data));
expect(data).assertNull();
});
resolve()
})
await promise.then(done)
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_GET_RSSI_VALUE_PROMISE_0001
* @tc.name testGetRssiValue
* @tc.desc Test GetRssiValue api by promise.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('SUB_COMMUNACATION_bluetooth_GET_RSSI_VALUE_PROMISE_0001', 0, async function (done) {
let promise = new Promise((resolve) => {
let gattClient = bluetooth.BLE.createGattClientDevice("00:00:00:00:00:00");
gattClient.getRssiValue().then((data) => {
if (data != null) {
expect(true).assertEqual(true);
} else {
console.info('[bluetooth_js] BLE read rssi ' + JSON.stringify(data));
let rssiLength = Object.keys(data).length;
expect(rssiLength).assertEqual(0);
}
}).catch(err => {
console.error(`bluetooth getRssiValue has error: ${err}`);
expect(true).assertEqual(true);
});
resolve()
})
await promise.then(done)
done();
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_GET_DEVICE_NAME_PROMISE_0001
* @tc.name testGetDeviceName
* @tc.desc Test GetDeviceName api by promise.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('SUB_COMMUNACATION_bluetooth_GET_DEVICE_NAME_PROMISE_0001', 0, async function (done) {
let promise = new Promise((resolve) => {
let gattClient = bluetooth.BLE.createGattClientDevice("00:00:00:00:00:00");
gattClient.getDeviceName().then((data) => {
console.info('[bluetooth_js] device name' + JSON.stringify(data))
expect(data).assertNull();
done();
})
resolve()
})
await promise.then(done)
done();
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_GET_DEVICE_NAME_CALLBACK_0001
* @tc.name testGetDeviceName
* @tc.desc Test GetDeviceName api by callback.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('SUB_COMMUNACATION_bluetooth_GET_DEVICE_NAME_CALLBACK_0001', 0, async function (done) {
let promise = new Promise((resolve) => {
let gattClient = bluetooth.BLE.createGattClientDevice("00:00:00:00:00:00");
gattClient.getDeviceName((err, data)=> {
console.info('[bluetooth_js] device name' + JSON.stringify(data))
expect(data).assertNull();
done();
})
resolve()
})
await promise.then(done)
done();
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_GATT_GETSERVICES_CALLBACK_0001
* @tc.name testGetServices
* @tc.desc Test GetServices api by callback.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('SUB_COMMUNACATION_bluetooth_GATT_GETSERVICES_CALLBACK_0001', 0, async function (done) {
let promise = new Promise((resolve) => {
let gattClient = bluetooth.BLE.createGattClientDevice("00:00:00:00:00:00");
gattClient.getServices((err, data)=> {
console.info('[bluetooth_js] device name err1 ' + JSON.stringify(err) +'name1' + JSON.stringify(data));
expect(true).assertEqual(err.code == -1);
done();
})
resolve()
})
await promise.then(done)
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_GATT_GETSERVICES_PROMISE_0001
* @tc.name testGetServices
* @tc.desc Test GetServices api by promise.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('SUB_COMMUNACATION_bluetooth_GATT_GETSERVICES_PROMISE_0001', 0, async function (done) {
let promise = new Promise((resolve) => {
let gattClient = bluetooth.BLE.createGattClientDevice("00:00:00:00:00:00");
gattClient.getServices().then((object) => {
if (object != null) {
expect(true).assertEqual(true);
} else {
console.info('[bluetooth_js] getServices successfully:'+JSON.stringify(object));
expect(null).assertFail();
}
done();
}).catch(err => {
console.error(`bluetooth getServices has error: ${err}`);
expect(true).assertEqual(true);
done();
});
resolve()
})
await promise.then(done)
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_GATT_SET_BLE_MTUSIZE_0001
* @tc.name testSetBLEMtuSize
* @tc.desc Test SetBLEMtuSize api.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('SUB_COMMUNACATION_bluetooth_GATT_SET_BLE_MTUSIZE_0001', 0, async function (done) {
let gattClient = bluetooth.BLE.createGattClientDevice("00:00:00:00:00:00");
let ret = gattClient.setBLEMtuSize(128);
console.info('[bluetooth_js] bluetooth setBLEMtuSize ret:' + ret);
expect(ret).assertEqual(false);
done();
})
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BLE_ReadCharacteristic_0100
* @tc.name testReadDescriptorValue
* @tc.desc Test ReadDescriptorValue api by promise.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('SUB_COMMUNICATION_BLUETOOTH_BLE_ReadCharacteristic_0100', 0, async function (done) {
let descriptors = [];
let arrayBuffer = new ArrayBuffer(8);
let desValue = new Uint8Array(arrayBuffer);
desValue[0] = 11;
let descriptor = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
descriptorUuid: '00001830-0000-1000-8000-00805F9B34FB', descriptorValue: arrayBuffer};
descriptors[0] = descriptor;
let arrayBufferCCC = new ArrayBuffer(8);
let cccValue = new Uint8Array(arrayBufferCCC);
cccValue[0] = 32;
let characteristic = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
characteristicValue: arrayBufferCCC, descriptors:descriptors};
let gattClient = bluetooth.BLE.createGattClientDevice("11:22:33:44:55:66");
await gattClient.readCharacteristicValue(characteristic).then((object) => {
if (object != null) {
console.error('bluetooth readCharacteristicValue promise object :'
+JSON.stringify(object));
expect(true).assertEqual(true);
} else {
console.info('[bluetooth_js] readCharacValue promise null:' + JSON.stringify(object));
expect(null).assertFail();
}
done();
}).catch(error => {
console.error('[bluetooth_js] readCharacteristicValue promise has error:'
+JSON.stringify(error));
expect(true).assertEqual(true);
done();
})
})
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BLE_ReadCharacteristic_0200
* @tc.name testReadDescriptorValue
* @tc.desc Test ReadDescriptorValue api by callback.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('SUB_COMMUNICATION_BLUETOOTH_BLE_ReadCharacteristic_0200', 0, async function(done) {
function readCcc(code, BLECharacteristic) {
if (code.code != 0) {
return;
}
console.log('bluetooth characteristic uuid:'+ BLECharacteristic.characteristicUuid);
let value = new Uint8Array(BLECharacteristic.characteristicValue);
console.log('bluetooth characteristic value: '
+ value[0] +','+ value[1]+','+ value[2]+','+ value[3]);
}
let arrayBuffer = new ArrayBuffer(8);
let desValue = new Uint8Array(arrayBuffer);
desValue[0] = 11;
let descriptor = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
descriptorUuid: '00001830-0000-1000-8000-00805F9B34FB', descriptorValue:arrayBuffer};
let arrayBufferCCC = new ArrayBuffer(8);
let cccValue = new Uint8Array(arrayBufferCCC);
cccValue[0] = 32;
let characteristic = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
characteristicValue: arrayBufferCCC, descriptors:descriptor};
let gattClient = bluetooth.BLE.createGattClientDevice("11:22:33:44:55:66");
let data = await gattClient.readCharacteristicValue(characteristic,readCcc);
console.log('[bluetooth_js] readCharacteristicValue callback: ' + JSON.stringify(data))
expect(true).assertEqual(data==null);
done()
})
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BLE_readDescriptor_0100
* @tc.name testReadDescriptorValue
* @tc.desc Test ReadDescriptorValue api by promise.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('SUB_COMMUNICATION_BLUETOOTH_BLE_readDescriptor_0100', 0, async function (done) {
let arrayBuffer = new ArrayBuffer(8);
let desValue = new Uint8Array(arrayBuffer);
desValue[0] = 11;
let descriptor = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
descriptorUuid: '00001830-0000-1000-8000-00805F9B34FB', descriptorValue: arrayBuffer};
let gattClient = bluetooth.BLE.createGattClientDevice("11:22:33:44:55:66");
await gattClient.readDescriptorValue(descriptor).then((object) => {
if (object != null) {
console.error('readDescriptorValue promise object:'+JSON.stringify(object));
expect(true).assertEqual(true);
} else {
console.info('[bluetooth_js]readDescriptorValue null:' + JSON.stringify(object));
expect(null).assertFail();
}
done();
}).catch(error => {
console.error('[bluetooth_js]readDescriptorValue promise error:'+JSON.stringify(error));
expect(true).assertEqual(true);
done();
})
})
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BLE_readDescriptor_0200
* @tc.name testReadDescriptorValue
* @tc.desc Test ReadDescriptorValue api by callback.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('SUB_COMMUNICATION_BLUETOOTH_BLE_readDescriptor_0200', 0, async function (done) {
function readDesc(code, BLEDescriptor) {
if (code.code != 0) {
console.info('[bluetooth_js] descriptor code: ' + BLEDescriptor.descriptorUuid);
return;
}
console.info('[bluetooth_js] descriptor uuid: ' + BLEDescriptor.descriptorUuid);
let value = new Uint8Array(BLEDescriptor.descriptorValue);
console.info('[bluetooth_js] descriptor value: '
+ value[0] +','+ value[1]+','+ value[2]+','+ value[3]);
}
let arrayBuffer = new ArrayBuffer(8);
let desValue = new Uint8Array(arrayBuffer);
desValue[0] = 11;
let descriptor = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
descriptorUuid: '00001830-0000-1000-8000-00805F9B34FB', descriptorValue: arrayBuffer};
let gattClient = bluetooth.BLE.createGattClientDevice("11:22:33:44:55:66");
let data1 = await gattClient.readDescriptorValue(descriptor,readDesc);
console.log('[bluetooth_js] readDescriptorValue callback: ' + JSON.stringify(data1))
expect(true).assertEqual(data1==null);
done()
})
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BLE_WriteCharacteristic_0100
* @tc.name testWriteCharacteristicValue
* @tc.desc Test Client WriteCharacteristicValue api.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('SUB_COMMUNICATION_BLUETOOTH_BLE_WriteCharacteristic_0100', 0, function () {
let descriptors = [];
let arrayBuffer = new ArrayBuffer(8);
let desValue = new Uint8Array(arrayBuffer);
desValue[0] = 11;
let descriptor = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
descriptorUuid: '00001830-0000-1000-8000-00805F9B34FB', descriptorValue: arrayBuffer};
descriptors[0] = descriptor;
let arrayBufferCCC = new ArrayBuffer(8);
let cccValue = new Uint8Array(arrayBufferCCC);
cccValue[0] = 32;
let characteristic = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
characteristicValue: arrayBufferCCC, descriptors:descriptors};
let gattClient = bluetooth.BLE.createGattClientDevice("11:22:33:44:55:66");
let ret = gattClient.writeCharacteristicValue(characteristic);
console.info('[bluetooth_js] writeCharacteristicValue ret : ' + ret);
expect(ret).assertEqual(false);
})
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BLE_WriteCharacteristic_0200
* @tc.name testWriteCharacteristicValue
* @tc.desc Test Client WriteCharacteristicValue api.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
*/
it('SUB_COMMUNICATION_BLUETOOTH_BLE_WriteCharacteristic_0200', 0, function () {
let gattClient = bluetooth.BLE.createGattClientDevice("11:22:33:44:55:66");
let ret = gattClient.writeCharacteristicValue("123");
console.info('[bluetooth_js] invaild writeCharacteristicValue ret : ' + ret);
expect(ret).assertEqual(false);
})
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BLE_WriteDescriptor_0100
* @tc.name testWriteDescriptorValue
* @tc.desc Test Client WriteDescriptorValue api.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('SUB_COMMUNICATION_BLUETOOTH_BLE_WriteDescriptor_0100', 0, function () {
let arrayBuffer = new ArrayBuffer(8);
let desValue = new Uint8Array(arrayBuffer);
desValue[0] = 11;
let descriptor = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
descriptorUuid: '00001830-0000-1000-8000-00805F9B34FB', descriptorValue: arrayBuffer};
let gattClient = bluetooth.BLE.createGattClientDevice("11:22:33:44:55:66");
let ret = gattClient.writeDescriptorValue(descriptor);
console.info('[bluetooth_js] bluetooth writeDescriptorValue ret : ' + ret);
expect(ret).assertEqual(false);
})
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BLE_WriteDescriptor_0200
* @tc.name testWriteDescriptorValue
* @tc.desc Test WriteDescriptorValue api.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
*/
it('SUB_COMMUNICATION_BLUETOOTH_BLE_WriteDescriptor_0200', 0, function () {
let gattClient = bluetooth.BLE.createGattClientDevice("11:22:33:44:55:66");
let ret = gattClient.writeDescriptorValue("");
console.info('[bluetooth_js] bluetooth writeDescriptorValue ret : ' + ret);
expect(ret).assertEqual(false);
})
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BLE_NotifyCharacteristic_0100
* @tc.name testSetNotifyCharacteristicChanged
* @tc.desc Test SetNotifyCharacteristicChanged api.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('SUB_COMMUNICATION_BLUETOOTH_BLE_SetNotifyCharacteristic_0100', 0, async function (done) {
let gattClient = bluetooth.BLE.createGattClientDevice("11:22:33:44:55:66");
let descriptors = [];
let arrayBuffer = new ArrayBuffer(8);
let desValue = new Uint8Array(arrayBuffer);
desValue[0] = 11;
let arrayBufferNotify = new ArrayBuffer(8);
let descNotifyValue = new Uint8Array(arrayBufferNotify);
descNotifyValue[0] = 1
let descriptor = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
descriptorUuid: '00001830-0000-1000-8000-00805F9B34FB',
descriptorValue: arrayBuffer};
let descriptorNotify = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
descriptorUuid: '00002902-0000-1000-8000-00805F9B34FB',
descriptorValue: arrayBufferNotify};
descriptors[0] = descriptor;
descriptors[1] = descriptorNotify;
let arrayBufferCCC = new ArrayBuffer(8);
let cccValue = new Uint8Array(arrayBufferCCC);
cccValue[0] = 1;
let characteristic = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
characteristicValue: arrayBufferCCC, descriptors:descriptors};
let ret = gattClient.setNotifyCharacteristicChanged(characteristic, true);
console.info('[bluetooth_js] setNotifyCharacteristicChanged ret:' + ret);
expect(ret).assertEqual(false);
done();
})
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BLE_NotifyCharacteristic_0200
* @tc.name testSetNotifyCharacteristicChanged
* @tc.desc Test SetNotifyCharacteristicChanged api.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('SUB_COMMUNICATION_BLUETOOTH_BLE_SetNotifyCharacteristic_0200', 0, async function(done) {
let gattClient = bluetooth.BLE.createGattClientDevice("11:22:33:44:55:66");
let descriptors = [];
let arrayBuffer = new ArrayBuffer(8);
let desValue = new Uint8Array(arrayBuffer);
desValue[0] = 11;
let arrayBufferNotify = new ArrayBuffer(8);
let descNotifyValue = new Uint8Array(arrayBufferNotify);
descNotifyValue[0] = 1
let descriptor = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
descriptorUuid: '00001830-0000-1000-8000-00805F9B34FB',
descriptorValue: arrayBuffer};
let descriptorNotify = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
descriptorUuid: '00002902-0000-1000-8000-00805F9B34FB',
descriptorValue: arrayBufferNotify};
descriptors[0] = descriptor;
descriptors[1] = descriptorNotify;
let arrayBufferCCC = new ArrayBuffer(8);
let cccValue = new Uint8Array(arrayBufferCCC);
cccValue[0] = 1;
let characteristic = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
characteristicValue: arrayBufferCCC, descriptors:descriptors};
let ret = gattClient.setNotifyCharacteristicChanged(characteristic, false);
console.info('[bluetooth_js] setNotifyCharacteristicChanged ret:' + ret);
expect(ret).assertEqual(false);
done();
})
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BLE_NotifyCharacteristic_0300
* @tc.name testSetNotifyCharacteristicChanged
* @tc.desc Test SetNotifyCharacteristicChanged api.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('SUB_COMMUNICATION_BLUETOOTH_BLE_SetNotifyCharacteristic_0300', 0, async function (done) {
let gattClient = bluetooth.BLE.createGattClientDevice("11:22:33:44:55:66");
let ret = gattClient.setNotifyCharacteristicChanged(null, false);
console.info('[bluetooth_js] setNotifyCharacteristicChanged is null ret:' + ret);
expect(ret).assertEqual(false);
done();
})
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BLE_AddService_0100
* @tc.name testAddService
* @tc.desc Test AddService api.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('SUB_COMMUNICATION_BLUETOOTH_BLE_AddService_0100', 0, async function (done) {
let gattServer = bluetooth.BLE.createGattServer();
let service = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
isPrimary: true, includeServices: []};
let ret = gattServer.addService(service);
console.info('[bluetooth_js] bluetooth addService characteristics is null result:' + ret);
expect(ret).assertTrue();
await sleep(3000);
let ret1=gattServer.removeService('00001810-0000-1000-8000-00805F9B34FB');
await sleep(3000);
console.info('[bluetooth_js]removeService ret:'+ret1);
expect(ret1).assertTrue();
done();
})
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BLE_AddService_0200
* @tc.name testAddService
* @tc.desc Test AddService api.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 1
*/
it('SUB_COMMUNICATION_BLUETOOTH_BLE_AddService_0200', 0, async function (done) {
let gattServer = bluetooth.BLE.createGattServer();
let descriptors = [];
let arrayBuffer = new ArrayBuffer(8);
let descV = new Uint8Array(arrayBuffer);
descV[0] = 11;
let descriptor = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
descriptorUuid: '00002902-0000-1000-8000-00805F9B34FB', descriptorValue: arrayBuffer};
descriptors[0] = descriptor;
let characteristics = [];
let arrayBufferC = new ArrayBuffer(8);
let cccV = new Uint8Array(arrayBufferC);
cccV[0] = 1;
let characteristic = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
characteristicValue: arrayBufferC, descriptors:descriptors};
characteristics[0] = characteristic;
let gattService = {serviceUuid:'00001810-0000-1000-8000-00805F9B34FB', isPrimary: true,
characteristics:characteristics, includeServices:[]};
let ret = gattServer.addService(gattService);
console.info('[bluetooth_js] bluetooth addService a characteristics result : ' + ret);
expect(ret).assertTrue();
await sleep(3000);
let ret1=gattServer.removeService('00001810-0000-1000-8000-00805F9B34FB');
await sleep(3000);
console.info('[bluetooth_js]removeService ret:'+ret1);
expect(ret1).assertTrue();
done();
})
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BLE_AddService_0300
* @tc.name testAddService
* @tc.desc Test AddService api.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
*/
it('SUB_COMMUNICATION_BLUETOOTH_BLE_AddService_0300', 0, async function (done) {
let gattServer = bluetooth.BLE.createGattServer();
let descriptors = [];
let arrayBuffer = new ArrayBuffer(8);
let descV = new Uint8Array(arrayBuffer);
descV[0] = 11;
let descriptor = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
descriptorUuid: '00002902-0000-1000-8000-00805F9B34FB', descriptorValue: arrayBuffer};
descriptors[0] = descriptor;
let characteristics = [];
let arrayBufferC = new ArrayBuffer(8);
let cccV = new Uint8Array(arrayBufferC);
cccV[0] = 1;
let characteristic = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
characteristicValue: arrayBufferC, descriptors:descriptors};
let characteristicN = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
characteristicUuid: '00001821-0000-1000-8000-00805F9B34FB',
characteristicValue: arrayBufferC, descriptors:descriptors};
characteristics[0] = characteristic;
characteristics[1] = characteristicN;
let gattService = {serviceUuid:'00001810-0000-1000-8000-00805F9B34FB', isPrimary: true,
characteristics:characteristics, includeServices:[]};
let ret = gattServer.addService(gattService);
console.info('[bluetooth_js] bluetooth addService more characteristics result : ' + ret);
expect(ret).assertTrue();
await sleep(3000);
let ret1=gattServer.removeService('00001810-0000-1000-8000-00805F9B34FB');
await sleep(3000);
console.info('[bluetooth_js]removeService ret:'+ret1);
expect(ret1).assertTrue();
done();
})
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BLE_AddService_0400
* @tc.name testAddService
* @tc.desc Test AddService api.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
*/
it('SUB_COMMUNICATION_BLUETOOTH_BLE_AddService_0400', 0, async function (done) {
let gattServer = bluetooth.BLE.createGattServer();
let characteristics = [];
let arrayBufferC = new ArrayBuffer(8);
let cccV = new Uint8Array(arrayBufferC);
cccV[0] = 1;
let characteristic = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
characteristicValue: arrayBufferC, descriptors:[]};
characteristics[0] = characteristic;
let gattService = {serviceUuid:'00001810-0000-1000-8000-00805F9B34FB', isPrimary: true,
characteristics:characteristics, includeServices:[]};
let ret = gattServer.addService(gattService);
console.info('[bluetooth_js] bluetooth addService not descriptors result : ' + ret);
expect(ret).assertFalse();
await sleep(3000);
let ret1=gattServer.removeService('00001810-0000-1000-8000-00805F9B34FB');
await sleep(3000);
console.info('[bluetooth_js]removeService ret:'+ret1);
expect(ret1).assertFalse();
done();
})
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BLE_AddService_0500
* @tc.name testAddService
* @tc.desc Test AddService api.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('SUB_COMMUNICATION_BLUETOOTH_BLE_AddService_0500', 0, async function (done) {
let gattServer = bluetooth.BLE.createGattServer();
let descriptors = [];
let arrayBuffer = new ArrayBuffer(8);
let descV = new Uint8Array(arrayBuffer);
descV[0] = 11;
let descriptor = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
descriptorUuid: '00002902-0000-1000-8000-00805F9B34FB', descriptorValue: arrayBuffer};
descriptors[0] = descriptor;
let characteristics = [];
let arrayBufferC = new ArrayBuffer(8);
let cccV = new Uint8Array(arrayBufferC);
cccV[0] = 1;
let characteristic = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
characteristicValue: arrayBufferC, descriptors:descriptors};
characteristics[0] = characteristic;
let gattService = {serviceUuid:'00001810-0000-1000-8000-00805F9B34FB', isPrimary: true,
characteristics:characteristics, includeServices:[]};
let ret = gattServer.addService(gattService);
console.info('[bluetooth_js] bluetooth addService a descriptors result : ' + ret);
expect(ret).assertTrue();
await sleep(3000);
let ret1=gattServer.removeService('00001810-0000-1000-8000-00805F9B34FB');
await sleep(3000);
console.info('[bluetooth_js]removeService ret:'+ret1);
expect(ret1).assertTrue();
done();
})
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BLE_AddService_0600
* @tc.name testAddService
* @tc.desc Test AddService api.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
*/
it('SUB_COMMUNICATION_BLUETOOTH_BLE_AddService_0600', 0, async function (done) {
let gattServer = bluetooth.BLE.createGattServer();
let descriptors = [];
let arrayBuffer = new ArrayBuffer(8);
let descV = new Uint8Array(arrayBuffer);
descV[0] = 11;
let descriptor = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
descriptorUuid: '00002902-0000-1000-8000-00805F9B34FB', descriptorValue: arrayBuffer};
let descriptor1 = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
characteristicUuid: '00001821-0000-1000-8000-00805F9B34FB',
descriptorUuid: '00001830-0000-1000-8000-00805F9B34FB', descriptorValue: arrayBuffer};
descriptors[0] = descriptor;
descriptors[1] = descriptor1;
let characteristics = [];
let arrayBufferC = new ArrayBuffer(8);
let cccV = new Uint8Array(arrayBufferC);
cccV[0] = 1;
let characteristic = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
characteristicValue: arrayBufferC, descriptors:descriptors};
characteristics[0] = characteristic;
let gattService = {serviceUuid:'00001810-0000-1000-8000-00805F9B34FB', isPrimary: true,
characteristics:characteristics, includeServices:[]};
let ret = gattServer.addService(gattService);
console.info('[bluetooth_js] bluetooth addService more descriptors result : ' + ret);
expect(ret).assertTrue();
await sleep(3000);
let ret1=gattServer.removeService('00001810-0000-1000-8000-00805F9B34FB');
await sleep(3000);
console.info('[bluetooth_js]removeService ret:'+ret1);
expect(ret1).assertTrue();
done();
})
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BLE_AddService_0700
* @tc.name testAddService
* @tc.desc Test AddService api.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
*/
it('SUB_COMMUNICATION_BLUETOOTH_BLE_AddService_0700', 0, async function (done) {
let gattServer = bluetooth.BLE.createGattServer();
let descriptors = [];
let arrayBuffer = new ArrayBuffer(8);
let descV = new Uint8Array(arrayBuffer);
descV[0] = 11;
let descriptor = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
descriptorUuid: '00002902-0000-1000-8000-00805F9B34FB', descriptorValue: arrayBuffer};
descriptors[0] = descriptor;
let characteristics = [];
let arrayBufferC = new ArrayBuffer(8);
let cccV = new Uint8Array(arrayBufferC);
cccV[0] = 1;
let characteristic = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
characteristicValue: arrayBufferC, descriptors:descriptors};
characteristics[0] = characteristic;
let gattService = {serviceUuid:'00001810-0000-1000-8000-00805F9B34FB', isPrimary: true,
characteristics:characteristics, includeServices:[]};
let ret = gattServer.addService(gattService);
console.info('[bluetooth_js] bluetooth addService isPrimary result : ' + ret);
expect(ret).assertTrue();
await sleep(3000);
let ret1=gattServer.removeService('00001810-0000-1000-8000-00805F9B34FB');
await sleep(3000);
console.info('[bluetooth_js]removeService ret:'+ret1);
expect(ret1).assertTrue();
done();
})
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BLE_AddService_0800
* @tc.name testAddService
* @tc.desc Test AddService api.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
*/
it('SUB_COMMUNICATION_BLUETOOTH_BLE_AddService_0800', 0, async function (done) {
let gattServer = bluetooth.BLE.createGattServer();
let descriptors = [];
let arrayBuffer = new ArrayBuffer(8);
let descV = new Uint8Array(arrayBuffer);
descV[0] = 11;
let descriptor = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
descriptorUuid: '00002902-0000-1000-8000-00805F9B34FB', descriptorValue: arrayBuffer};
descriptors[0] = descriptor;
let characteristics = [];
let arrayBufferC = new ArrayBuffer(8);
let cccV = new Uint8Array(arrayBufferC);
cccV[0] = 1;
let characteristic = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
characteristicValue: arrayBufferC, descriptors:descriptors};
characteristics[0] = characteristic;
let gattService = {serviceUuid:'00001810-0000-1000-8000-00805F9B34FB', isPrimary: false,
characteristics:characteristics, includeServices:[]};
let ret = gattServer.addService(gattService);
console.info('[bluetooth_js] bluetooth addService isNotPrimary result : ' + ret);
expect(ret).assertTrue();
await sleep(3000);
let ret1=gattServer.removeService('00001810-0000-1000-8000-00805F9B34FB');
await sleep(3000);
console.info('[bluetooth_js]removeService ret:'+ret1);
expect(ret1).assertTrue();
done();
})
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BLE_AddService_0900
* @tc.name testAddService
* @tc.desc Test AddService api.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
*/
it('SUB_COMMUNICATION_BLUETOOTH_BLE_AddService_0900', 0, async function (done) {
let gattServer = bluetooth.BLE.createGattServer();
let descriptors = [];
let arrayBuffer = new ArrayBuffer(8);
let descV = new Uint8Array(arrayBuffer);
descV[0] = 11;
let descriptor = {serviceUuid: '',
characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
descriptorUuid: '00002902-0000-1000-8000-00805F9B34FB', descriptorValue: arrayBuffer};
descriptors[0] = descriptor;
let characteristics = [];
let arrayBufferC = new ArrayBuffer(8);
let cccV = new Uint8Array(arrayBufferC);
cccV[0] = 1;
let characteristic = {serviceUuid: '',
characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
characteristicValue: arrayBufferC, descriptors:descriptors};
characteristics[0] = characteristic;
let gattService = {serviceUuid:'', isPrimary: true,
characteristics:characteristics, includeServices:[]};
let ret = gattServer.addService(gattService);
console.info('[bluetooth_js] bluetooth addService null serviceUuid result : ' + ret);
expect(ret).assertTrue();
await sleep(3000);
let ret1=gattServer.removeService('');
await sleep(3000);
console.info('[bluetooth_js]removeService ret:'+ret1);
expect(ret1).assertTrue();
done();
})
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BLE_AddService_1000
* @tc.name testAddService
* @tc.desc Test AddService api.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
*/
it('SUB_COMMUNICATION_BLUETOOTH_BLE_AddService_1000', 0, async function (done) {
let gattServer = bluetooth.BLE.createGattServer();
let descriptors = [];
let arrayBuffer = new ArrayBuffer(8);
let descV = new Uint8Array(arrayBuffer);
descV[0] = 11;
let descriptor = {serviceUuid: '123@ad',
characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
descriptorUuid: '00002902-0000-1000-8000-00805F9B34FB', descriptorValue: arrayBuffer};
descriptors[0] = descriptor;
let characteristics = [];
let arrayBufferC = new ArrayBuffer(8);
let cccV = new Uint8Array(arrayBufferC);
cccV[0] = 1;
let characteristic = {serviceUuid: '123@ad',
characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
characteristicValue: arrayBufferC, descriptors:descriptors};
characteristics[0] = characteristic;
let gattService = {serviceUuid:'123@ad', isPrimary: true,
characteristics:characteristics, includeServices:[]};
let ret = gattServer.addService(gattService);
console.info('[bluetooth_js] bluetooth addService invalid serviceUuid result : ' + ret);
expect(ret).assertTrue();
await sleep(3000);
let ret1=gattServer.removeService('123@ad');
await sleep(3000);
console.info('[bluetooth_js]removeService ret:'+ret1);
expect(ret1).assertTrue();
done();
})
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BLE_AddService_1100
* @tc.name testAddService
* @tc.desc Test AddService api.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
*/
it('SUB_COMMUNICATION_BLUETOOTH_BLE_AddService_1100', 0, async function (done) {
let gattServer = bluetooth.BLE.createGattServer();
let descriptors = [];
let arrayBuffer = new ArrayBuffer(8);
let descV = new Uint8Array(arrayBuffer);
descV[0] = 11;
let descriptor = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
descriptorUuid: '00002902-0000-1000-8000-00805F9B34FB', descriptorValue: arrayBuffer};
descriptors[0] = descriptor;
let characteristics = [];
let arrayBufferC = new ArrayBuffer(8);
let cccV = new Uint8Array(arrayBufferC);
cccV[0] = 1;
let characteristic = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB', descriptors:descriptors};
characteristics[0] = characteristic;
let gattService = {serviceUuid:'00001810-0000-1000-8000-00805F9B34FB', isPrimary: true,
characteristics:characteristics, includeServices:[]};
let ret = gattServer.addService(gattService);
console.info('[bluetooth_js] bluetooth addService null characteristicValue result : ' + ret);
expect(ret).assertFalse();
await sleep(3000);
let ret1=gattServer.removeService('00001810-0000-1000-8000-00805F9B34FB');
console.info('[bluetooth_js]removeService ret:'+ret1);
expect(ret1).assertFalse();
done();
})
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BLE_AddService_1200
* @tc.name testAddService
* @tc.desc Test AddService api.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
*/
it('SUB_COMMUNICATION_BLUETOOTH_BLE_AddService_1200', 0, async function (done) {
let gattServer = bluetooth.BLE.createGattServer();
let descriptors = [];
let arrayBuffer = new ArrayBuffer(8);
let descV = new Uint8Array(arrayBuffer);
descV[0] = 11;
let descriptor = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
descriptorUuid: '00002902-0000-1000-8000-00805F9B34FB'};
descriptors[0] = descriptor;
let characteristics = [];
let arrayBufferC = new ArrayBuffer(8);
let cccV = new Uint8Array(arrayBufferC);
cccV[0] = 1;
let characteristic = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
characteristicValue: arrayBufferC, descriptors:descriptors};
characteristics[0] = characteristic;
let gattService = {serviceUuid:'00001810-0000-1000-8000-00805F9B34FB', isPrimary: true,
characteristics:characteristics, includeServices:[]};
let ret = gattServer.addService(gattService);
console.info('[bluetooth_js] bluetooth addService null descriptorValue result : ' + ret);
expect(ret).assertFalse();
await sleep(3000);
let ret1=gattServer.removeService('00001810-0000-1000-8000-00805F9B34FB');
console.info('[bluetooth_js]removeService ret:'+ret1);
expect(ret1).assertFalse();
done();
})
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BLE_RemoveService_0100
* @tc.name testRemoveService
* @tc.desc Test RemoveService api.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
*/
it('SUB_COMMUNICATION_BLUETOOTH_BLE_RemoveService_0100', 0, async function (done) {
let gattServer = bluetooth.BLE.createGattServer();
let gattService = {serviceUuid:'00001810-0000-1000-8000-00805F9B34FB',
isPrimary: true,includeServices:[]};
let gattService1 = {serviceUuid:'00001888-0000-1000-8000-00805f9b34fb',
isPrimary: false,includeServices:[]};
let ret = gattServer.addService(gattService);
console.info('[bluetooth_js] bluetooth addService1 result : ' + ret);
expect(ret).assertTrue();
let retN = gattServer.addService(gattService1);
console.info('[bluetooth_js] bluetooth addService2 result : ' + retN);
expect(retN).assertTrue();
await sleep(3000);
let ret1=gattServer.removeService('00001888-0000-1000-8000-00805f9b34fb');
console.info('[bluetooth_js]removeService ret:'+ret1);
expect(ret1).assertTrue();
done();
})
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BLE_RemoveService_0200
* @tc.name testRemoveService
* @tc.desc Test RemoveService api.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
*/
it('SUB_COMMUNICATION_BLUETOOTH_BLE_RemoveService_0200', 0, async function (done) {
let gattServer = bluetooth.BLE.createGattServer();
let ret1=gattServer.removeService('00001800-0000-1000-8000-00805f9b3442');
console.info('[bluetooth_js]removeService ret:'+ret1);
expect(ret1).assertFalse();
done();
})
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BLE_RemoveService_0300
* @tc.name testRemoveService
* @tc.desc Test RemoveService api.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
*/
it('SUB_COMMUNICATION_BLUETOOTH_BLE_RemoveService_0300', 0, async function (done) {
let gattServer = bluetooth.BLE.createGattServer();
let descriptors = [];
let arrayBuffer = new ArrayBuffer(8);
let descV = new Uint8Array(arrayBuffer);
descV[0] = 11;
let descriptor = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
descriptorUuid: '00002902-0000-1000-8000-00805F9B34FB', descriptorValue: arrayBuffer};
descriptors[0] = descriptor;
let characteristics = [];
let arrayBufferC = new ArrayBuffer(8);
let cccV = new Uint8Array(arrayBufferC);
cccV[0] = 1;
let characteristic = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
characteristicValue: arrayBufferC, descriptors:descriptors};
characteristics[0] = characteristic;
let gattService = {serviceUuid:'00001810-0000-1000-8000-00805F9B34FB', isPrimary: true,
characteristics:characteristics, includeServices:[]};
let ret = gattServer.addService(gattService);
console.info('[bluetooth_js] bluetooth addService result : ' + ret);
expect(ret).assertTrue();
await sleep(3000);
let ret1=gattServer.removeService('00001810-0000-1000-8000-00805F9B34FB');
await sleep(2000);
console.info('[bluetooth_js]removeService ret:'+ret1);
expect(ret1).assertTrue();
let ret2=gattServer.removeService('00001810-0000-1000-8000-00805F9B34FB');
await sleep(2000);
console.info('[bluetooth_js]removeService ret:'+ret2);
expect(ret2).assertFalse();
done();
})
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BLE_notifyCharacteristic_0100
* @tc.name testNotifyCharacteristicChanged
* @tc.desc Test NotifyCharacteristicChanged api.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('SUB_COMMUNICATION_BLUETOOTH_BLE_notifyCharacteristic_0100', 0, async function (done) {
let descriptors = [];
let arrayBuffer = new ArrayBuffer(8);
let descV = new Uint8Array(arrayBuffer);
descV[0] = 11;
let descriptor = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
descriptorUuid: '00002902-0000-1000-8000-00805F9B34FB', descriptorValue: descV};
descriptors[0] = descriptor;
let arrayBufferC = new ArrayBuffer(8);
let characteristic = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB', characteristicValue:
arrayBufferC, descriptors:descriptors};
let notifyCharacteristic = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
characteristicUuid: '00001821-0000-1000-8000-00805F9B34FB', characteristicValue:
characteristic.characteristicValue, confirm: false};
let ret = gattServer.notifyCharacteristicChanged('00:11:22:33:44:55', notifyCharacteristic);
console.info('[bluetooth_js] notifyCharacteristicChanged ret : ' + ret);
expect(ret).assertEqual(false);
done();
})
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BLE_notifyCharacteristic_0200
* @tc.name testNotifyCharacteristicChanged
* @tc.desc Test NotifyCharacteristicChanged api.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('SUB_COMMUNICATION_BLUETOOTH_BLE_notifyCharacteristic_0200', 0, async function (done) {
let descriptors = [];
let arrayBuffer = new ArrayBuffer(8);
let descV = new Uint8Array(arrayBuffer);
descV[0] = 11;
let descriptor = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
descriptorUuid: '00002902-0000-1000-8000-00805F9B34FB', descriptorValue: descV};
descriptors[0] = descriptor;
let arrayBufferC = new ArrayBuffer(8);
let characteristic = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB', characteristicValue:
arrayBufferC, descriptors:descriptors};
let notifyCharacteristic = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
characteristicUuid: '00001821-0000-1000-8000-00805F9B34FB', characteristicValue:
characteristic.characteristicValue, confirm: false};
let ret = gattServer.notifyCharacteristicChanged('00:11:22:33:44:55', notifyCharacteristic);
console.info('[bluetooth_js] notifyCharacteristicChanged ret : ' + ret);
expect(ret).assertEqual(false);
done();
})
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BLE_notifyCharacteristic_0300
* @tc.name testNotifyCharacteristicChanged
* @tc.desc Test NotifyCharacteristicChanged api.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
*/
it('SUB_COMMUNICATION_BLUETOOTH_BLE_notifyCharacteristic_0300', 0, async function (done) {
console.info('[bluetooth_js] SUB_COMMUNICATION_BLUETOOTH_BLE_notifyCharacteristic_0200');
let ret = gattServer.notifyCharacteristicChanged('00:11:22:33:44:55', null);
console.info('[bluetooth_js] notifyCharacteristicChanged ret : ' + ret);
expect(ret).assertEqual(false);
done();
})
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BLE_sendResponse_0200
* @tc.name testSendResponse success
* @tc.desc Test SendResponse api.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 1
*/
it('SUB_COMMUNICATION_BLUETOOTH_BLE_sendResponse_0100', 0, async function (done) {
let arrayBuffer = new ArrayBuffer(8);
let value = new Uint8Array(arrayBuffer);
value[0] = 1;
let serverResponse = {deviceId: '00:11:22:33:44:55', transId: 1,
status: 0, offset: 0, value: arrayBuffer};
let ret = gattServer.sendResponse(serverResponse);
console.info('[bluetooth_js] sendResponse ret : ' + ret);
expect(ret).assertEqual(false);
done();
})
/**
* @tc.number SUB_COMMUNACATION_bluetoothble_GATTSERVER_CLOSE_0001
* @tc.name testBlePeripheralManagerClose
* @tc.desc Test BlePeripheralManagerClose api .
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('SUB_COMMUNACATION_bluetoothble_GATTSERVER_CLOSE_0001', 0, async function (done) {
try{
let gattServer = bluetooth.BLE.createGattServer()
let result = gattServer.close();
console.info("[bluetooth_js] GattserverClose res:"+ JSON.stringify(result));
expect(result).assertTrue();
}catch(error){
console.info("[bluetooth_js] GattserverClose err:" + JSON.stringify(error));
expect(null).assertFail();
}
done();
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_GATT_DISCONNRCT_0001
* @tc.name testDisConnect
* @tc.desc Test DisConnect api.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('SUB_COMMUNACATION_bluetooth_GATT_DISCONNRCT_0001', 0, async function (done) {
let gattClient = bluetooth.BLE.createGattClientDevice("00:00:00:00:00:00");
let ret = gattClient.disconnect();
console.info('[bluetooth_js] gatt disconnect ret:' + ret);
expect(ret).assertEqual(false);
done();
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_GATT_CLIENT_CLOSE_0001
* @tc.name testGattClientClose
* @tc.desc Test GattClientClose api .
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('SUB_COMMUNACATION_bluetooth_GATT_CLIENT_CLOSE_0001', 0, async function (done) {
try{
let gattClient = bluetooth.BLE.createGattClientDevice("00:00:00:00:00:00");
let result = gattClient.close();
console.info("[bluetooth_js] GattclientClose result:" + JSON.stringify(result));
expect(result).assertTrue();
}catch(error){
console.info("[bluetooth_js] GattclientClose err:" + JSON.stringify(error));
expect(null).assertFail();
}
done();
})
})
}
/*
* 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 '@ohos/hypium'
let MajorMinorClass = {
COMPUTER_UNCATEGORIZED : 0x0100,
COMPUTER_DESKTOP : 0x0104,
COMPUTER_SERVER : 0x0108,
COMPUTER_LAPTOP : 0x010C,
COMPUTER_HANDHELD_PC_PDA : 0x0110,
COMPUTER_PALM_SIZE_PC_PDA : 0x0114,
COMPUTER_WEARABLE : 0x0118,
COMPUTER_TABLET : 0x011C,
PHONE_UNCATEGORIZED : 0x0200,
PHONE_CELLULAR : 0x0204,
PHONE_CORDLESS : 0x0208,
PHONE_SMART : 0x020C,
PHONE_MODEM_OR_GATEWAY : 0x0210,
PHONE_ISDN : 0x0214,
NETWORK_FULLY_AVAILABLE : 0x0300,
NETWORK_1_TO_17_UTILIZED : 0x0320,
NETWORK_17_TO_33_UTILIZED : 0x0340,
NETWORK_33_TO_50_UTILIZED : 0x0360,
NETWORK_60_TO_67_UTILIZED : 0x0380,
NETWORK_67_TO_83_UTILIZED : 0x03A0,
NETWORK_83_TO_99_UTILIZED : 0x03C0,
NETWORK_NO_SERVICE : 0x03E0,
AUDIO_VIDEO_UNCATEGORIZED : 0x0400,
AUDIO_VIDEO_WEARABLE_HEADSET : 0x0404,
AUDIO_VIDEO_HANDSFREE : 0x0408,
AUDIO_VIDEO_MICROPHONE : 0x0410,
AUDIO_VIDEO_LOUDSPEAKER : 0x0414,
AUDIO_VIDEO_HEADPHONES : 0x0418,
AUDIO_VIDEO_PORTABLE_AUDIO : 0x041C,
AUDIO_VIDEO_CAR_AUDIO : 0x0420,
AUDIO_VIDEO_SET_TOP_BOX : 0x0424,
AUDIO_VIDEO_HIFI_AUDIO : 0x0428,
AUDIO_VIDEO_VCR : 0x042C,
AUDIO_VIDEO_VIDEO_CAMERA : 0x0430,
AUDIO_VIDEO_CAMCORDER : 0x0434,
AUDIO_VIDEO_VIDEO_MONITOR : 0x0438,
AUDIO_VIDEO_VIDEO_DISPLAY_AND_LOUDSPEAKER : 0x043C,
AUDIO_VIDEO_VIDEO_CONFERENCING : 0x0440,
AUDIO_VIDEO_VIDEO_GAMING_TOY : 0x0448,
PERIPHERAL_NON_KEYBOARD_NON_POINTING : 0x0500,
PERIPHERAL_KEYBOARD : 0x0540,
PERIPHERAL_POINTING_DEVICE : 0x0580,
PERIPHERAL_KEYBOARD_POINTING : 0x05C0,
PERIPHERAL_UNCATEGORIZED : 0x0500,
PERIPHERAL_JOYSTICK : 0x0504,
PERIPHERAL_GAMEPAD : 0x0508,
PERIPHERAL_REMOTE_CONTROL : 0x05C0,
PERIPHERAL_SENSING_DEVICE : 0x0510,
PERIPHERAL_DIGITIZER_TABLET : 0x0514,
PERIPHERAL_CARD_READER : 0x0518,
PERIPHERAL_DIGITAL_PEN : 0x051C,
PERIPHERAL_SCANNER_RFID : 0x0520,
PERIPHERAL_GESTURAL_INPUT : 0x0522,
IMAGING_UNCATEGORIZED : 0x0600,
IMAGING_DISPLAY : 0x0610,
IMAGING_CAMERA : 0x0620,
IMAGING_SCANNER : 0x0640,
IMAGING_PRINTER : 0x0680,
WEARABLE_UNCATEGORIZED : 0x0700,
WEARABLE_WRIST_WATCH : 0x0704,
WEARABLE_PAGER : 0x0708,
WEARABLE_JACKET : 0x070C,
WEARABLE_HELMET : 0x0710,
WEARABLE_GLASSES : 0x0714,
TOY_UNCATEGORIZED : 0x0800,
TOY_ROBOT : 0x0804,
TOY_VEHICLE : 0x0808,
TOY_DOLL_ACTION_FIGURE : 0x080C,
TOY_CONTROLLER : 0x0810,
TOY_GAME : 0x0814,
HEALTH_UNCATEGORIZED : 0x0900,
HEALTH_BLOOD_PRESSURE : 0x0904,
HEALTH_THERMOMETER : 0x0908,
HEALTH_WEIGHING : 0x090C,
HEALTH_GLUCOSE : 0x0910,
HEALTH_PULSE_OXIMETER : 0x0914,
HEALTH_PULSE_RATE : 0x0918,
HEALTH_DATA_DISPLAY : 0x091C,
HEALTH_STEP_COUNTER : 0x0920,
HEALTH_BODY_COMPOSITION_ANALYZER : 0x0924,
HEALTH_PEAK_FLOW_MOITOR : 0x0928,
HEALTH_MEDICATION_MONITOR : 0x092C,
HEALTH_KNEE_PROSTHESIS : 0x0930,
HEALTH_ANKLE_PROSTHESIS : 0x0934,
HEALTH_GENERIC_HEALTH_MANAGER : 0x0938,
HEALTH_PERSONAL_MOBILITY_DEVICE : 0x093C,
HEALTH_PERSONAL_MOBILITY_DEVICE : 0x093C
};
let ScanDuty=
{
SCAN_MODE_LOW_POWER : 0,
SCAN_MODE_BALANCED : 1,
SCAN_MODE_LOW_LATENCY : 2,
};
let MatchMode=
{
MATCH_MODE_AGGRESSIVE : 1,
MATCH_MODE_STICKY : 2,
};
export default function bluetoothTEST() {
describe('bluetoothTEST', function() {
let gattServer = null;
let gattClient = null;
beforeAll(function () {
console.info('beforeAll called')
gattServer = bluetooth.BLE.createGattServer();
gattClient = bluetooth.BLE.createGattClientDevice("00:00:00:00:00:00");
})
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_PAIR_DEVICE_0002
* @tc.name testClassicPairDevice
* @tc.desc Test ClassicPairDevice api.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('SUB_COMMUNACATION_bluetooth_PAIR_DEVICE_0002', 0, async function (done) {
console.info('[bluetooth_js] pair device start');
await tryToEnableBt();
await bluetooth.BLE.on('bondStateChange', result => {
console.info("[bluetooth_js] bondStateChange on:" + JSON.stringify(result)
+'bondStateChange deviceId:' + data.deviceId + 'bondStateChange state:' + data.state);
expect(true).assertEqual(result !=null);
done();
});
let BondState=
{
BOND_STATE_INVALID : 0,
BOND_STATE_BONDING : 1,
BOND_STATE_BONDED : 2
};
expect(BondState.BOND_STATE_INVALID == 0).assertTrue();
expect(BondState.BOND_STATE_BONDING == 1).assertTrue();
expect(BondState.BOND_STATE_BONDED == 2).assertTrue();
bluetooth.BLE.off('bondStateChange', result => {
expect(true).assertEqual(true);
done();
});
})
/**
* @tc.number SUB_COMMUNACATION_bluetoothble_CHARAC_READ_ON_0001
* @tc.name testonCharacteristicReadOn
* @tc.desc Test CharacteristicReadOn api .
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('SUB_COMMUNACATION_bluetoothble_CHARAC_READ_ON_0001', 0, async function (done) {
try {
await tryToEnableBt();
console.info('[bluetooth_js] CharacteristicReadOn test start');
gattServer.on('characteristicRead', function (data) {
console.info('[bluetooth_js] CharRedReq deviceId: ' + data.deviceId +
'transId:' + data.transId + 'offset:' + data.offset + 'charUuid:' +
data.characteristicUuid + 'serviceUuid:' + data.serviceUuid);
let serverResponse = {
"deviceId": data.deviceId,
"transId": data.transId,
"status": 0,
"offset": data.offset,
"value": str2ab("characteristic read response", data.offset),
};
let result = gattServer.sendResponse(serverResponse);
expect(JSON.stringify(result)).assertContain("true");
});
}catch(e) {
expect(null).assertFail();
}
try {
console.info('[bluetooth_js] characteristicRead test1 start');
gattServer.off('characteristicRead', function (data) {
console.info("[bluetooth_js] charaRead off data:" + JSON.stringify(data));
expect(true).assertEqual(true);
});
}catch(e) {
expect(null).assertFail();
}
done();
})
/**
* @tc.number SUB_COMMUNACATION_bluetoothble_CHARAC_WRITE_ON_0001
* @tc.name testonCharacteristicwriteOn
* @tc.desc Test CharacteristicwriteOn api .
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('SUB_COMMUNACATION_bluetoothble_CHARAC_WRITE_ON_0001', 0, async function (done) {
try {
await tryToEnableBt();
console.info('[bluetooth_js] CharacteristicwriteOn test start');
gattServer.on('characteristicWrite', function (data) {
console.info('[bluetooth_js] CharWriReq deviceId: ' + data.deviceId +
'transId:' + data.transId + 'offset:' + data.offset + 'isPrep:' + data.isPrep +
'charUuid:' + data.characteristicUuid + 'serviceUuid:' + data.serviceUuid +
'value:' + data.value + 'needRsp' + data.needRsp);
if (data.value instanceof ArrayBuffer) {
console.log(`[bluetooth_js] value: ${ab2hex(data.value)}`)
}
if (data.needRsp == false) {
return;
}
console.log(`data.value is ArraryBuffer: ${ab2hex(data.value)}`)
let serverResponse = {
"deviceId": data.deviceId,
"transId": data.transId,
"status": 0,
"offset": data.offset,
"value": data.value,
};
let result = gattServer.sendResponse(serverResponse);
expect(JSON.stringify(result)).assertContain("true");
});
}catch(e) {
expect(null).assertFail();
}
try {
console.info('[bluetooth_js] characteristicWrite test1 start');
gattServer.off('characteristicWrite', function (data) {
console.info("[bluetooth_js] charaWrite off data2:" + JSON.stringify(data));
expect(true).assertEqual(true);
});
}catch(e) {
expect(null).assertFail();
}
done();
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_DESC_READ_ON_0001
* @tc.name testDescriptorReadOn
* @tc.desc Test DescriptorReadOn api .
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('SUB_COMMUNACATION_bluetooth_DESC_READ_ON_0001', 0, async function (done) {
try {
await tryToEnableBt();
console.info('[bluetooth_js] descriptorReadOn test start ...');
gattServer.on('descriptorRead', function (data) {
console.info("[bluetooth_js] DesRedon jsondata:" + JSON.stringify(data) +
'deviceId:' + data.deviceId + 'transId:' + data.transId + 'offset:' +
data.offset +'descriptorUuid:' + data.descriptorUuid + 'characteristicUuid:' +
data.characteristicUuid + 'serviceUuid:' + data.serviceUuid);
expect(true).assertEqual(data !=null);
});
}catch(e) {
expect(null).assertFail();
}
try {
console.info('[bluetooth_js] descriptorReadOff test start ...');
gattServer.off('descriptorRead', function (data) {
expect(true).assertEqual(true);
});
}catch(e) {
expect(null).assertFail();
}
done();
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_DESC_WRITE_ON_0001
* @tc.name testDescriptorWriteOn
* @tc.desc Test DescriptorWriteOn api .
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('SUB_COMMUNACATION_bluetooth_DESC_WRITE_ON_0001', 0, async function (done) {
try {
await tryToEnableBt();
console.info('[bluetooth_js] descriptorWriteOn test start ...');
gattServer.on('descriptorWrite', function (data) {
console.info("[bluetooth_js] desWriOn jsondata: " + JSON.stringify(data) +
'deviceId: ' + data.deviceId + 'transId:' + data.transId + 'offset:' +
data.offset +'descriptorUuid:' + data.descriptorUuid +
'charUuid:' + data.characteristicUuid +'serviceUuid:' + data.serviceUuid +
'value:' + data.value + 'needRsp' + data.needRsp + 'isPrep:' + data.isPrep );
expect(true).assertEqual(data !=null);
});
}catch(e) {
expect(null).assertFail();
}
try {
console.info('[bluetooth_js] descriptorWriteOff test start ...');
gattServer.off('descriptorWrite', function (data) {
expect(true).assertTrue();
});
}catch(e) {
expect(null).assertFail();
}
done();
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_CONNE_STATE_CHANGE_ON_0001
* @tc.name testConnectStateChangeOn
* @tc.desc Test ConnectStateChangeOn api .
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('SUB_COMMUNACATION_bluetooth_CONNE_STATE_CHANGE_ON_0001', 0, async function (done) {
try {
await tryToEnableBt();
console.info('[bluetooth_js] ConnectStateChangeOn test start ...');
gattServer.on('connectStateChange', function (data) {
console.info("[bluetooth_js] connectStaOn jsonData -> " + JSON.stringify(data) +
'deviceId: ' + data.deviceId + 'state:'+ data.state);
expect(true).assertEqual(data !=null);
});
}catch(e) {
expect(null).assertFail();
}
try {
console.info('[bluetooth_js] ConnectStateChangeOff test start ...');
gattServer.off('connectStateChange', function (data) {
console.info("[bluetooth_js] connectStateChange_off Data:" + JSON.stringify(data));
expect(true).assertTrue();
});
}catch(e) {
expect(null).assertFail();
}
done();
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_BLE_CHAR_CHANGE_ON_0001
* @tc.name testBLECharacteristicChangeOn
* @tc.desc Test BLECharacteristicChangeOn api .
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('SUB_COMMUNACATION_bluetooth_BLE_CHAR_CHANGE_ON_0001', 0, async function (done) {
try {
await tryToEnableBt();
console.info('[bluetooth_js] BLECharacteristicChangeOn test start ...');
gattClient.on('BLECharacteristicChange', function (data) {
console.info("[bluetooth_js] BLECharacteristicChange data " + JSON.stringify(data));
expect(true).assertEqual(data !=null);
});
}catch(e) {
expect(null).assertFail();
}
try {
console.info('[bluetooth_js] BLECharacteristicChangeOff test start');
gattClient.off('BLECharacteristicChange', function (data) {
console.info("[bluetooth_js] BLECharcChange_off data-> " + JSON.stringify(data));
expect(true).assertTrue();
});
}catch(e) {
expect(null).assertFail();
}
done();
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_BLE_CONNE_STATE_CHANGE_ON_0001
* @tc.name testBLEConnectionStateChangeOn
* @tc.desc Test BLEConnectionStateChangeOn api .
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('SUB_COMMUNACATION_bluetooth_BLE_CONNE_STATE_CHANGE_ON_0001', 0, async function (done) {
try {
await tryToEnableBt();
console.info('[bluetooth_js] BLEConnectionStateChangeOn test start');
gattClient.on('BLEConnectionStateChange', function (data) {
console.info("[bluetooth_js] BLEConnecStateChange_on data " + JSON.stringify(data)
+'deviceId: ' + data.deviceId + 'state:'+ data.state);
expect(true).assertEqual(data !=null);
});
}catch(e) {
expect(null).assertFail();
}
try {
console.info('[bluetooth_js] BLEConnectionStateChangeOff test start');
gattClient.off('BLEConnectionStateChange', function (data) {
console.info("[bluetooth_js] BLEConneStateChange_off data-> " + JSON.stringify(data));
expect(true).assertEqual(true);
});
}catch(e) {
expect(null).assertFail();
}
done();
})
/**
* @tc.number SUB_COMMUNACATION_bluetoothble_SPP_READ_ON_0001
* @tc.name testonsppReadOn
* @tc.desc Test sppReadOn api .
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('SUB_COMMUNACATION_bluetoothble_SPP_READ_ON_0001', 0, async function (done) {
try {
await tryToEnableBt();
console.info('[bluetooth_js] sppReadOn test start');
bluetooth.on("sppRead",-1, (result) => {
console.info("[bluetooth_js] sppReadOn json_result -> " + JSON.stringify(result));
expect(true).assertEqual(result !=null);
});
}catch(e) {
expect(null).assertFail();
}
try {
console.info('[bluetooth_js] sppReadOff test start ...');
bluetooth.off("sppRead",-1, (result) => {
console.info("[bluetooth_js] sppReadOff json_result -> " + JSON.stringify(result));
expect(true).assertEqual(true);
});
}catch(e) {
expect(null).assertFail();
}
done();
})
})
}
...@@ -179,8 +179,8 @@ describe('bluetoothhostTest2', function() { ...@@ -179,8 +179,8 @@ describe('bluetoothhostTest2', function() {
/** /**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BR_Pair_0500 * @tc.number SUB_COMMUNICATION_BLUETOOTH_BR_Pair_0500
* @tc.name test getRemoteDeviceClass * @tc.name test get RemoteDeviceName
* @tc.desc Test get getRemoteDeviceClass * @tc.desc Test getRemoteDeviceName api
* @tc.size MEDIUM * @tc.size MEDIUM
* @ since 8 * @ since 8
* @tc.type Function * @tc.type Function
...@@ -195,8 +195,8 @@ describe('bluetoothhostTest2', function() { ...@@ -195,8 +195,8 @@ describe('bluetoothhostTest2', function() {
/** /**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BR_Pair_0600 * @tc.number SUB_COMMUNICATION_BLUETOOTH_BR_Pair_0600
* @tc.name test getPairedDevices * @tc.name test get PairedDevices
* @tc.desc Test get getPairedDevices * @tc.desc Test getPairedDevices api
* @tc.size MEDIUM * @tc.size MEDIUM
* @ since 8 * @ since 8
* @tc.type Function * @tc.type Function
...@@ -211,8 +211,8 @@ describe('bluetoothhostTest2', function() { ...@@ -211,8 +211,8 @@ describe('bluetoothhostTest2', function() {
/** /**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BR_Pair_0700 * @tc.number SUB_COMMUNICATION_BLUETOOTH_BR_Pair_0700
* @tc.name test pinRequired * @tc.name Test pinRequired and setDevicePairing false
* @tc.desc Test pinRequired and setDevicePairing false * @tc.desc Test pinRequired ON api
* @tc.size MEDIUM * @tc.size MEDIUM
* @ since 8 * @ since 8
* @tc.type Function * @tc.type Function
...@@ -224,7 +224,7 @@ describe('bluetoothhostTest2', function() { ...@@ -224,7 +224,7 @@ describe('bluetoothhostTest2', function() {
bluetooth.setDevicePairingConfirmation(data.deviceId,false); bluetooth.setDevicePairingConfirmation(data.deviceId,false);
} }
bluetooth.BLE.on('pinRequired', PinRequiredParam); bluetooth.BLE.on('pinRequired', PinRequiredParam);
let result = bluetooth.pairDevice("00:00:00:00:00:00"); let result = bluetooth.pairDevice("11:22:55:66:33:44");
console.info("[bluetooth_js] onStartpair007 -> " + JSON.stringify(result)); console.info("[bluetooth_js] onStartpair007 -> " + JSON.stringify(result));
expect(result).assertFalse(); expect(result).assertFalse();
bluetooth.BLE.off('pinRequired', PinRequiredParam); bluetooth.BLE.off('pinRequired', PinRequiredParam);
...@@ -233,8 +233,8 @@ describe('bluetoothhostTest2', function() { ...@@ -233,8 +233,8 @@ describe('bluetoothhostTest2', function() {
/** /**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BR_Pair_0800 * @tc.number SUB_COMMUNICATION_BLUETOOTH_BR_Pair_0800
* @tc.name test pinRequired * @tc.name Test pinRequired and setDevicePairing true
* @tc.desc Test pinRequired and setDevicePairing true * @tc.desc Test pinRequired off api
* @tc.size MEDIUM * @tc.size MEDIUM
* @ since 8 * @ since 8
* @tc.type Function * @tc.type Function
...@@ -246,13 +246,43 @@ describe('bluetoothhostTest2', function() { ...@@ -246,13 +246,43 @@ describe('bluetoothhostTest2', function() {
bluetooth.setDevicePairingConfirmation(data.deviceId,true); bluetooth.setDevicePairingConfirmation(data.deviceId,true);
} }
bluetooth.BLE.on('pinRequired', PinRequiredParam); bluetooth.BLE.on('pinRequired', PinRequiredParam);
let result = bluetooth.pairDevice("00:00:00:00:00:00"); let result = bluetooth.pairDevice("11:22:55:66:33:44");
console.info("[bluetooth_js] onStartpair008 -> " + JSON.stringify(result)); console.info("[bluetooth_js] onStartpair008 -> " + JSON.stringify(result));
expect(result).assertFalse(); expect(result).assertFalse();
bluetooth.BLE.off('pinRequired', PinRequiredParam); bluetooth.BLE.off('pinRequired', PinRequiredParam);
done() done()
}) })
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BR_Pair_0900
* @tc.name Test On pair StateChange
* @tc.desc Test bondStateChange ON api
* @tc.size MEDIUM
* @ since 8
* @tc.type Function
* @tc.level Level 3
*/
it('SUB_COMMUNICATION_BLUETOOTH_BR_Pair_0900', 0, async function (done) {
let BondState=
{
BOND_STATE_INVALID : 0,
BOND_STATE_BONDING : 1,
BOND_STATE_BONDED : 2
};
function BondStateParam(data) {
console.info("[bluetooth_js] bondStateChange on:" + JSON.stringify(data)
+'bondStateChange deviceId:' + data.deviceId + 'bondStateChange state:' + data.state);
}
bluetooth.BLE.on('bondStateChange', BondStateParam);
let result = bluetooth.pairDevice("11:22:55:66:33:44");
expect(BondState.BOND_STATE_INVALID == 0).assertTrue();
expect(BondState.BOND_STATE_BONDING == 1).assertTrue();
expect(BondState.BOND_STATE_BONDED == 2).assertTrue();
bluetooth.BLE.off('bondStateChange', BondStateParam);
done()
})
}) })
} }
...@@ -13,15 +13,13 @@ ...@@ -13,15 +13,13 @@
* limitations under the License. * limitations under the License.
*/ */
import bluetoothTEST from './BluetoothOn.test.js'
import bluetoothhostTest from './BleScanResult.test.js' import bluetoothhostTest from './BleScanResult.test.js'
import bluetoothhostTest2 from './BluetoothPair.test.js' import bluetoothhostTest2 from './BluetoothPair.test.js'
import bluetoothhostTest1 from './bluetoothProfileAdd.test.js'
import bluetoothhostTest4 from './bluetoothSys.test.js' import bluetoothhostTest4 from './bluetoothSys.test.js'
export default function testsuite() { export default function testsuite() {
bluetoothTEST()
bluetoothhostTest() bluetoothhostTest()
bluetoothhostTest2() bluetoothhostTest2()
bluetoothhostTest1()
bluetoothhostTest4() bluetoothhostTest4()
} }
/*
* 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 '@ohos/hypium'
export default function bluetoothhostTest1() {
describe('bluetoothhostTest1', 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_GET_BT_CONNECT_STATE_0001
* @tc.name testClassicGetBtConnectionState
* @tc.desc Test ClassicGetBtConnectionState api.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('SUB_COMMUNACATION_bluetooth_GET_BT_CONNECT_STATE_0001', 0, async function (done) {
console.info('[bluetooth_js] get connection state start');
await tryToEnableBt();
let ProfileConnectionState=
{
STATE_CONNECTING : 1,
STATE_CONNECTED : 2,
STATE_DISCONNECTED : 0,
STATE_DISCONNECTING : 3,
};
let connState = bluetooth.getBtConnectionState();
console.info('[bluetooth_js] get bt connection state result' + JSON.stringify(connState));
expect(connState).assertEqual(ProfileConnectionState.STATE_DISCONNECTED);
expect(true).assertTrue(ProfileConnectionState.STATE_CONNECTING!= connState );
expect(true).assertTrue(ProfileConnectionState.STATE_CONNECTED!= connState );
expect(true).assertTrue(ProfileConnectionState.STATE_DISCONNECTING!= connState );
done();
})
})
}
...@@ -17,14 +17,10 @@ import bluetooth from '@ohos.bluetooth'; ...@@ -17,14 +17,10 @@ import bluetooth from '@ohos.bluetooth';
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '@ohos/hypium' import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '@ohos/hypium'
let ProfileId = { let ProfileId = {
PROFILE_A2DP_SINK : 0,
PROFILE_A2DP_SOURCE : 1, PROFILE_A2DP_SOURCE : 1,
PROFILE_AVRCP_CT : 2,
PROFILE_AVRCP_TG : 3,
PROFILE_HANDS_FREE_AUDIO_GATEWAY : 4, PROFILE_HANDS_FREE_AUDIO_GATEWAY : 4,
PROFILE_HANDS_FREE_UNIT : 5,
PROFILE_HID_HOST : 6, PROFILE_HID_HOST : 6,
PROFILE_PAN_NETWORK : 7 PROFILE_PAN_NETWORK : 7
} }
...@@ -34,49 +30,16 @@ let PlayingState = { ...@@ -34,49 +30,16 @@ let PlayingState = {
STATE_PLAYING : 0x0001, STATE_PLAYING : 0x0001,
} }
let a2dpSourceProfile = bluetooth.getProfile(1); let ProfileConnectionState=
{
STATE_CONNECTING : 1,
function on(ON_VALUE_TEST_ELEMENT) { STATE_CONNECTED : 2,
return new Promise((resolve, reject) => { STATE_DISCONNECTED : 0,
a2dpSourceProfile.on(ON_VALUE_TEST_ELEMENT, function (err, data) { STATE_DISCONNECTING : 3
if (err != undefined) {
reject(err);
} else {
resolve(data);
}
})
});
}
function off(OFF_VALUE_TEST_ELEMENT) {
return new Promise((resolve, reject) => {
a2dpSourceProfile.off(OFF_VALUE_TEST_ELEMENT, function (err, data) {
if (err != undefined) {
reject(err);
} else {
resolve(data);
} }
})
});
}
export default function bluetoothhostTest_host_1() { export default function bluetoothhostTest_host_1() {
describe('bluetoothhostTest_host_1', function () { describe('bluetoothhostTest_host_1', 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) { function sleep(delay) {
return new Promise(resovle => setTimeout(resovle, delay)) return new Promise(resovle => setTimeout(resovle, delay))
} }
...@@ -85,9 +48,10 @@ describe('bluetoothhostTest_host_1', function () { ...@@ -85,9 +48,10 @@ describe('bluetoothhostTest_host_1', function () {
let sta = bluetooth.getState(); let sta = bluetooth.getState();
switch(sta){ switch(sta){
case 0: case 0:
console.info('[bluetooth_js] bt turn off:'+ JSON.stringify(sta));
bluetooth.enableBluetooth(); bluetooth.enableBluetooth();
await sleep(3000); await sleep(5000);
let sta1 = bluetooth.getState();
console.info('[bluetooth_js] bt turn off:'+ JSON.stringify(sta1));
break; break;
case 1: case 1:
console.info('[bluetooth_js] bt turning on:'+ JSON.stringify(sta)); console.info('[bluetooth_js] bt turning on:'+ JSON.stringify(sta));
...@@ -97,122 +61,225 @@ describe('bluetoothhostTest_host_1', function () { ...@@ -97,122 +61,225 @@ describe('bluetoothhostTest_host_1', function () {
console.info('[bluetooth_js] bt turn on:'+ JSON.stringify(sta)); console.info('[bluetooth_js] bt turn on:'+ JSON.stringify(sta));
break; break;
case 3: case 3:
console.info('[bluetooth_js] bt turning off:'+ JSON.stringify(sta));
bluetooth.enableBluetooth(); bluetooth.enableBluetooth();
await sleep(3000); await sleep(3000);
let sta2 = bluetooth.getState();
console.info('[bluetooth_js] bt turning off:'+ JSON.stringify(sta2));
break; break;
default: default:
console.info('[bluetooth_js] enable success'); console.info('[bluetooth_js] enable success');
} }
} }
beforeAll(function () {
console.info('beforeAll called')
})
beforeEach(async function(done) {
console.info('beforeEach called')
await tryToEnableBt()
done()
})
afterEach(function () {
console.info('afterEach called')
})
afterAll(function () {
console.info('afterAll called')
})
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BR_A2DP_Conn_0100
* @tc.name test bluetooth Profile ConnectionState
* @tc.desc Test getBtConnectionState api.
* @tc.size MEDIUM
* @ since 7
* @tc.type Function
* @tc.level Level 2
*/
it('SUB_COMMUNICATION_BLUETOOTH_BR_A2DP_Conn_0100', 0, async function (done) {
let connState = bluetooth.getBtConnectionState();
console.info('[bluetooth_js] get bt connection state result' + JSON.stringify(connState));
expect(connState).assertEqual(ProfileConnectionState.STATE_DISCONNECTED);
expect(true).assertTrue(ProfileConnectionState.STATE_CONNECTING!= connState );
expect(true).assertTrue(ProfileConnectionState.STATE_CONNECTED!= connState );
expect(true).assertTrue(ProfileConnectionState.STATE_DISCONNECTING!= connState );
done();
})
/** /**
* @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_A2DP_GET_PROFILE_0001 * @tc.number SUB_COMMUNICATION_BLUETOOTH_BR_A2DP_Conn_0200
* @tc.name testgetprofile * @tc.name test A2DP Connect
* @tc.desc Test getProfile api. * @tc.desc Test connect api.
* @tc.size MEDIUM
* @ since 8
* @tc.type Function * @tc.type Function
* @tc.level Level 0 * @tc.level Level 1
*/ */
it('SUB_COMMUNACATION_bluetooth_DEVICE_JS_A2DP_GET_PROFILE_0001', 0, async function (done) { it('SUB_COMMUNICATION_BLUETOOTH_BR_A2DP_Conn_0200', 0, async function (done) {
console.info('[bluetooth_js] a2dp get profile start'); function StateChangeParam(data) {
await tryToEnableBt(); console.info("[bluetooth_js] a2dp state " + JSON.stringify(data) +
let proFile = bluetooth.getProfile(1); 'deviceId: ' + data.deviceId + 'state:'+ data.state);
console.info('[bluetooth_js] a2dp get profile result:' + JSON.stringify(proFile)); expect(true).assertEqual(data !=null);
expect(proFile != null).assertEqual(true); }
let a2dpSrc = bluetooth.getProfile(ProfileId.PROFILE_A2DP_SOURCE);
console.info('[bluetooth_js]a2dp get profile result:' + JSON.stringify(a2dpSrc));
a2dpSrc.on('connectionStateChange', StateChangeParam);
let conn = a2dpSrc.connect('11:22:33:44:55:77');
await sleep(6000);
console.info('[bluetooth_js]a2dp connect result:' + JSON.stringify(conn));
expect(conn).assertTrue();
a2dpSrc.off('connectionStateChange', StateChangeParam);
done(); done();
}) })
/** /**
* @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_A2DP_SOURCCE_PROFILE_CONN_0001 * @tc.number SUB_COMMUNICATION_BLUETOOTH_BR_A2DP_Conn_0300
* @tc.name testa2dpSourceProfileconnect * @tc.name test A2DP disconnect
* @tc.desc Test a2dpSourceProfile connect api. * @tc.desc Test disconnect api.
* @tc.size MEDIUM
* @ since 8
* @tc.type Function * @tc.type Function
* @tc.level Level 0 * @tc.level Level 3
*/ */
it('SUB_COMMUNACATION_bluetooth_DEVICE_JS_A2DP_SOURCCE_PROFILE_CONN_0001', 0, async function (done) { it('SUB_COMMUNICATION_BLUETOOTH_BR_A2DP_Conn_0300', 0, async function (done) {
console.info('[bluetooth_js] a2dpSourceProfile the connect start'); function StateChangeParam(data) {
await tryToEnableBt(); console.info("[bluetooth_js] a2dp state " + JSON.stringify(data) +
let conn = a2dpSourceProfile.connect('00:00:00:00:00:02'); 'deviceId: ' + data.deviceId + 'state:'+ data.state);
expect(conn).assertTrue(); expect(true).assertEqual(data !=null);
}
let a2dpSrc = bluetooth.getProfile(ProfileId.PROFILE_A2DP_SOURCE);
console.info('[bluetooth_js]a2dp get profile result:' + JSON.stringify(a2dpSrc));
a2dpSrc.on('connectionStateChange', StateChangeParam);
await sleep(6000); await sleep(6000);
let disConn = a2dpSourceProfile.disconnect('00:00:00:00:00:02'); let conn = a2dpSrc.disconnect('11:22:33:44:55:66');
console.info('[bluetooth_js] a2dpSourceProfile disconnect:' + JSON.stringify(disConn)); console.info('[bluetooth_js]a2dp disconnect result:' + JSON.stringify(conn));
expect(disConn).assertFalse(); expect(conn).assertFalse();
a2dpSrc.off('connectionStateChange', StateChangeParam);
done(); done();
}) })
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BR_A2DP_Conn_0400
* @tc.name test a invaild A2DP disconnect
* @tc.desc Test disconnect api.
* @tc.size MEDIUM
* @ since 8
* @tc.type Function
* @tc.level Level 3
*/
it('SUB_COMMUNICATION_BLUETOOTH_BR_A2DP_Conn_0400', 0, async function (done) {
let a2dpSrc = bluetooth.getProfile(ProfileId.PROFILE_A2DP_SOURCE);
console.info('[bluetooth_js]a2dp get profile result:' + JSON.stringify(a2dpSrc));
let conn = a2dpSrc.disconnect('test');
console.info('[bluetooth_js]a2dp disconnect1 result:' + JSON.stringify(conn));
expect(conn).assertFalse();
done();
})
/** /**
* @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_A2DP_GET_PLAYING_STATE_0001 * @tc.number SUB_COMMUNICATION_BLUETOOTH_BR_A2DP_Conn_0500
* @tc.name testgetPlayingState * @tc.name test Get A2DP ConnectionState
* @tc.desc Test getPlayingState api. * @tc.desc Test getProfileConnState api.
* @tc.size MEDIUM
* @ since 8
* @tc.type Function * @tc.type Function
* @tc.level Level 0 * @tc.level Level 3
*/ */
it('SUB_COMMUNACATION_bluetooth_DEVICE_JS_A2DP_GET_PLAYING_STATE_0001', 0, async function (done) { it('SUB_COMMUNICATION_BLUETOOTH_BR_A2DP_Conn_0500', 0, async function (done) {
console.info('[bluetooth_js] a2dpSourceProfile getPlayingState start'); let a2dpSrcConn = bluetooth.getProfileConnState(ProfileId.PROFILE_A2DP_SOURCE);
await tryToEnableBt(); console.info('[bluetooth_js]get a2dp result:' + JSON.stringify(a2dpSrcConn));
let state = a2dpSourceProfile.getPlayingState('00:00:00:00:00:02'); expect(a2dpSrcConn).assertEqual(ProfileConnectionState.STATE_DISCONNECTED);
console.info('[bluetooth_js] a2dpSourceProfile the disconnect result:' + state);
await sleep(3000);
done(); done();
}) })
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BR_A2DP_Conn_0600
* @tc.name test a invaild A2DP Connect
* @tc.desc Test connect api.
* @tc.size MEDIUM
* @ since 8
* @tc.type Function
* @tc.level Level 3
*/
it('SUB_COMMUNICATION_BLUETOOTH_BR_A2DP_Conn_0600', 0, async function (done) {
let a2dpSrc = bluetooth.getProfile(ProfileId.PROFILE_A2DP_SOURCE);
let conn = a2dpSrc.connect('test');
console.info('[bluetooth_js]a2dp invaild connect:' + JSON.stringify(conn));
expect(conn).assertFalse();
done();
})
/** /**
* @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_A2DP_GET_PROFILE_STATE_0001 * @tc.number SUB_COMMUNICATION_BLUETOOTH_BR_A2DP_Conn_0700
* @tc.name testgetProfileState * @tc.name test getDevice A2DP State.
* @tc.desc Test getProfileState api. * @tc.desc Test getDeviceState api.
* @tc.size MEDIUM
* @ since 8
* @tc.type Function * @tc.type Function
* @tc.level Level 0 * @tc.level Level 3
*/ */
it('SUB_COMMUNACATION_bluetooth_DEVICE_JS_A2DP_GET_PROFILE_STATE_0001', 0, async function (done) { it('SUB_COMMUNICATION_BLUETOOTH_BR_A2DP_Conn_0700', 0, async function (done) {
console.info('[bluetooth_js] a2dpSourceProfile getProfileState start'); let a2dpSrc = bluetooth.getProfile(ProfileId.PROFILE_A2DP_SOURCE);
await tryToEnableBt(); console.info('[bluetooth_js]a2dp get profile result:' + JSON.stringify(a2dpSrc));
let state = bluetooth.getProfileConnState(bluetooth.ProfileId.PROFILE_A2DP_SOURCE); let ret = a2dpSrc.getDeviceState('11:22:33:44:55:66');
console.info('[bluetooth_js] a2dpSourceProfile state is:' + state); expect(ret).assertEqual(ProfileConnectionState.STATE_DISCONNECTED);
expect(state).assertEqual(0);
await sleep(1000);
done(); done();
}) })
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BR_A2DP_Conn_0800
* @tc.name test getDevice A2DP State.
* @tc.desc Test getDeviceState api.
* @tc.size MEDIUM
* @ since 8
* @tc.type Function
* @tc.level Level 3
*/
it('SUB_COMMUNICATION_BLUETOOTH_BR_A2DP_Conn_0800', 0, async function (done) {
let a2dpSrc = bluetooth.getProfile(ProfileId.PROFILE_A2DP_SOURCE);
console.info('[bluetooth_js]a2dp get profile result:' + JSON.stringify(a2dpSrc));
let ret = a2dpSrc.getDeviceState('test');
expect(ret).assertEqual(ProfileConnectionState.STATE_DISCONNECTED);
done();
})
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BR_A2DP_Conn_0900
* @tc.name test get A2DP Playing State
* @tc.desc Test getPlayingState api.
* @tc.size MEDIUM
* @ since 8
* @tc.type Function
* @tc.level Level 3
*/
it('SUB_COMMUNICATION_BLUETOOTH_BR_A2DP_Conn_0900', 0, async function (done) {
let a2dpSrc = bluetooth.getProfile(ProfileId.PROFILE_A2DP_SOURCE);
console.info('[bluetooth_js]a2dp get profile result:' + JSON.stringify(a2dpSrc));
let state = a2dpSrc.getPlayingState('11:22:33:44:55:66');
console.info('[bluetooth_js]a2dp getPlayingState result:' + JSON.stringify(state));
expect(state).assertEqual(PlayingState.STATE_NOT_PLAYING);
expect(true).assertEqual(state!=PlayingState.STATE_PLAYING);
done();
})
/** /**
* @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_A2DP_SOURCCE_PROFILE_ON_0001 * @tc.number SUB_COMMUNICATION_BLUETOOTH_BR_A2DP_Conn_1000
* @tc.name testa2dpSourceProfileon * @tc.name test getDevice A2DP State.
* @tc.desc Test a2dpSourceProfile on api. * @tc.desc Test getDeviceState api.
* @tc.size MEDIUM
* @ since 8
* @tc.type Function * @tc.type Function
* @tc.level Level 0 * @tc.level Level 1
*/ */
it('SUB_COMMUNACATION_bluetooth_DEVICE_JS_A2DP_SOURCCE_PROFILE_ON_0001', 0, async function (done) { it('SUB_COMMUNICATION_BLUETOOTH_BR_A2DP_Conn_1000', 0, async function (done) {
try { let a2dpSrc = bluetooth.getProfile(ProfileId.PROFILE_A2DP_SOURCE);
await tryToEnableBt(); console.info('[bluetooth_js]a2dp get profile result:' + JSON.stringify(a2dpSrc));
console.info('[bluetooth_js] a2dpSourceProfile the on start'); let retArray = a2dpSrc.getConnectionDevices();
on("connectionStateChange", function (data) { expect(true).assertEqual(retArray.length>=0);
console.info("[bluetooth_js] a2dpSource_on data " + JSON.stringify(data));
expect(true).assertEqual(data !=null);
console.info("[bluetooth_js] StateChangeParam deviceId" + data.deviceId +
"ProfileConnectionState" + data.state);
});
}catch(e) {
expect(null).assertFail();
}
try {
console.info('[bluetooth_js] a2dpSourceProfile the off test start');
off("connectionStateChange", function (data) {
console.info("[bluetooth_js] a2dpSource_off data-> " + JSON.stringify(data));
expect(true).assertEqual(data ==null);
});
}catch(e) {
expect(null).assertFail();
}
done(); done();
}) })
}) })
} }
...@@ -16,59 +16,23 @@ ...@@ -16,59 +16,23 @@
import bluetooth from '@ohos.bluetooth'; import bluetooth from '@ohos.bluetooth';
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '@ohos/hypium' import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '@ohos/hypium'
let hfpGatewayProfile = bluetooth.getProfile(4);
let ProfileId = { let ProfileId = {
PROFILE_A2DP_SINK : 0,
PROFILE_A2DP_SOURCE : 1, PROFILE_A2DP_SOURCE : 1,
PROFILE_AVRCP_CT : 2,
PROFILE_AVRCP_TG : 3,
PROFILE_HANDS_FREE_AUDIO_GATEWAY : 4, PROFILE_HANDS_FREE_AUDIO_GATEWAY : 4,
PROFILE_HANDS_FREE_UNIT : 5,
PROFILE_HID_HOST : 6, PROFILE_HID_HOST : 6,
PROFILE_PAN_NETWORK : 7 PROFILE_PAN_NETWORK : 7
} }
function on(ON_VALUE_TEST_ELEMENT) { let ProfileConnectionState=
return new Promise((resolve, reject) => { {
hfpGatewayProfile.on(ON_VALUE_TEST_ELEMENT, function (err, data) { STATE_CONNECTING : 1,
if (err != undefined) { STATE_CONNECTED : 2,
reject(err); STATE_DISCONNECTED : 0,
} else { STATE_DISCONNECTING : 3,
resolve(data); };
}
})
});
}
function off(OFF_VALUE_TEST_ELEMENT) {
return new Promise((resolve, reject) => {
hfpGatewayProfile.off(OFF_VALUE_TEST_ELEMENT, function (err, data) {
if (err != undefined) {
reject(err);
} else {
resolve(data);
}
})
});
}
export default function bluetoothhostTest_host_3() { export default function bluetoothhostTest_host_3() {
describe('bluetoothhostTest_host_3', function () { describe('bluetoothhostTest_host_3', 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) { function sleep(delay) {
return new Promise(resovle => setTimeout(resovle, delay)) return new Promise(resovle => setTimeout(resovle, delay))
} }
...@@ -77,9 +41,10 @@ describe('bluetoothhostTest_host_3', function () { ...@@ -77,9 +41,10 @@ describe('bluetoothhostTest_host_3', function () {
let sta = bluetooth.getState(); let sta = bluetooth.getState();
switch(sta){ switch(sta){
case 0: case 0:
console.info('[bluetooth_js] bt turn off:'+ JSON.stringify(sta));
bluetooth.enableBluetooth(); bluetooth.enableBluetooth();
await sleep(3000); await sleep(5000);
let sta1 = bluetooth.getState();
console.info('[bluetooth_js] bt turn off:'+ JSON.stringify(sta1));
break; break;
case 1: case 1:
console.info('[bluetooth_js] bt turning on:'+ JSON.stringify(sta)); console.info('[bluetooth_js] bt turning on:'+ JSON.stringify(sta));
...@@ -89,84 +54,185 @@ describe('bluetoothhostTest_host_3', function () { ...@@ -89,84 +54,185 @@ describe('bluetoothhostTest_host_3', function () {
console.info('[bluetooth_js] bt turn on:'+ JSON.stringify(sta)); console.info('[bluetooth_js] bt turn on:'+ JSON.stringify(sta));
break; break;
case 3: case 3:
console.info('[bluetooth_js] bt turning off:'+ JSON.stringify(sta));
bluetooth.enableBluetooth(); bluetooth.enableBluetooth();
await sleep(3000); await sleep(3000);
let sta2 = bluetooth.getState();
console.info('[bluetooth_js] bt turning off:'+ JSON.stringify(sta2));
break; break;
default: default:
console.info('[bluetooth_js] enable success'); console.info('[bluetooth_js] enable success');
} }
} }
beforeAll(function () {
console.info('beforeAll called')
})
beforeEach(async function(done) {
console.info('beforeEach called')
await tryToEnableBt()
done()
})
afterEach(function () {
console.info('afterEach called')
})
afterAll(function () {
console.info('afterAll called')
})
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BR_HFP_Conn_1100
* @tc.name test Get HFP ConnectionState
* @tc.desc Test getProfileConnState api.
* @tc.size MEDIUM
* @ since 8
* @tc.type Function
* @tc.level Level 3
*/
it('SUB_COMMUNICATION_BLUETOOTH_BR_HFP_Conn_1100', 0, async function (done) {
let hfpSrcConn =
bluetooth.getProfileConnState(ProfileId.PROFILE_HANDS_FREE_AUDIO_GATEWAY);
console.info('[bluetooth_js]get hfp result:' + JSON.stringify(hfpSrcConn));
expect(hfpSrcConn).assertEqual(ProfileConnectionState.STATE_DISCONNECTED);
done();
})
/** /**
* @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_GET_PROFILE_0001 * @tc.number SUB_COMMUNICATION_BLUETOOTH_BR_HFP_Conn_1200
* @tc.name testgetprofile * @tc.name test getDevice HFP State.
* @tc.desc Test getProfile api. * @tc.desc Test getDeviceState api.
* @tc.size MEDIUM
* @ since 8
* @tc.type Function * @tc.type Function
* @tc.level Level 0 * @tc.level Level 3
*/ */
it('SUB_COMMUNACATION_bluetooth_DEVICE_JS_HFP_GET_PROFILE_0001', 0, async function (done) { it('SUB_COMMUNICATION_BLUETOOTH_BR_HFP_Conn_1200', 0, async function (done) {
console.info('[bluetooth_js] hfp get profile start'); let hfpSrc = bluetooth.getProfile(ProfileId.PROFILE_HANDS_FREE_AUDIO_GATEWAY);
await tryToEnableBt(); let ret = hfpSrc.getDeviceState('11:22:33:44:55:66');
let proFile = bluetooth.getProfile(4); console.info('[bluetooth_js]hfp getDeviceState:' + JSON.stringify(ret));
console.info('[bluetooth_js] get profile:' + JSON.stringify(proFile)); expect(ret).assertEqual(ProfileConnectionState.STATE_DISCONNECTED);
expect(proFile != null).assertEqual(true);
done(); done();
}) })
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BR_HFP_Conn_1300
* @tc.name test getDevice HFP State.
* @tc.desc Test getDeviceState api.
* @tc.size MEDIUM
* @ since 8
* @tc.type Function
* @tc.level Level 3
*/
it('SUB_COMMUNICATION_BLUETOOTH_BR_HFP_Conn_1300', 0, async function (done) {
let hfpSrc = bluetooth.getProfile(ProfileId.PROFILE_HANDS_FREE_AUDIO_GATEWAY);
let ret = hfpSrc.getDeviceState('bluetooth1');
console.info('[bluetooth_js]hfp get valid mac DeviceState:' + JSON.stringify(ret));
expect(ret).assertEqual(ProfileConnectionState.STATE_DISCONNECTED);
done();
})
/** /**
* @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_HFP_GATWAY_PROFILE_CONN_0001 * @tc.number SUB_COMMUNICATION_BLUETOOTH_BR_HFP_Conn_1400
* @tc.name testhfpGatewayProfileconnect * @tc.name test HFP Connect
* @tc.desc Test hfpGatewayProfile connect api. * @tc.desc Test connect api.
* @tc.size MEDIUM
* @ since 8
* @tc.type Function * @tc.type Function
* @tc.level Level 0 * @tc.level Level 1
*/ */
it('SUB_COMMUNACATION_bluetooth_DEVICE_JS_HFP_GATWAY_PROFILE_CONN_0001', 0, async function (done) { it('SUB_COMMUNICATION_BLUETOOTH_BR_HFP_Conn_1400', 0, async function (done) {
console.info('[bluetooth_js] hfpGatewayProfile the connect start'); function StateChangeParam(data) {
await tryToEnableBt(); console.info("[bluetooth_js] hfp state " + JSON.stringify(data) +
let conn = hfpGatewayProfile.connect('00:00:00:00:00:01'); 'deviceId: ' + data.deviceId + 'state:'+ data.state);
expect(true).assertEqual(data !=null);
}
let hfpSrc = bluetooth.getProfile(ProfileId.PROFILE_HANDS_FREE_AUDIO_GATEWAY);
hfpSrc.on('connectionStateChange', StateChangeParam);
let conn = hfpSrc.connect('11:22:33:44:55:66');
await sleep(6000);
console.info('[bluetooth_js]hfp connect result:' + JSON.stringify(conn));
expect(conn).assertTrue(); expect(conn).assertTrue();
await sleep(2000); hfpSrc.off('connectionStateChange', StateChangeParam);
let disConn = hfpGatewayProfile.disconnect('00:00:00:00:00:01');
console.info('[bluetooth_js] hfpGatewayProfile disconnect:' + disConn);
expect(disConn).assertTrue();
await sleep(2000);
done(); done();
}) })
/** /**
* @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_HFP_GATWAY_PROFILE_ON_0001 * @tc.number SUB_COMMUNICATION_BLUETOOTH_BR_HFP_Conn_1500
* @tc.name testhfpGatewayProfileon * @tc.name test HFP disconnect
* @tc.desc Test hfpGatewayProfile on api. * @tc.desc Test disconnect api.
* @tc.size MEDIUM
* @ since 8
* @tc.type Function * @tc.type Function
* @tc.level Level 0 * @tc.level Level 3
*/ */
it('SUB_COMMUNACATION_bluetooth_DEVICE_JS_HFP_GATWAY_PROFILE_ON_0001', 0, async function (done) { it('SUB_COMMUNICATION_BLUETOOTH_BR_HFP_Conn_1500', 0, async function (done) {
try { function StateChangeParam(data) {
await tryToEnableBt(); console.info("[bluetooth_js] hfp state " + JSON.stringify(data) +
console.info('[bluetooth_js] hfpGatewayProfile the on start'); 'deviceId: ' + data.deviceId + 'state:'+ data.state);
on("connectionStateChange", function (data) {
console.info("[bluetooth_js] hfpGateway_on data " + JSON.stringify(data));
expect(true).assertEqual(data !=null); expect(true).assertEqual(data !=null);
});
}catch(e) {
expect(null).assertFail();
}
try {
console.info('[bluetooth_js] hfpGatewayProfile the off test start');
off("connectionStateChange", function (data) {
console.info("[bluetooth_js] hfpGateway_off data-> " + JSON.stringify(data));
expect(true).assertEqual(data ==null);
});
}catch(e) {
expect(null).assertFail();
} }
let hfpSrc = bluetooth.getProfile(ProfileId.PROFILE_HANDS_FREE_AUDIO_GATEWAY);
hfpSrc.on('connectionStateChange', StateChangeParam);
await sleep(10000);
let conn = hfpSrc.disconnect('11:22:33:44:55:66');
console.info('[bluetooth_js]hfp disconnect result:' + JSON.stringify(conn));
expect(conn).assertFalse();
hfpSrc.off('connectionStateChange', StateChangeParam);
done(); done();
}) })
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BR_HFP_Conn_1600
* @tc.name test a invaild HFP Connect
* @tc.desc Test connect api.
* @tc.size MEDIUM
* @ since 8
* @tc.type Function
* @tc.level Level 3
*/
it('SUB_COMMUNICATION_BLUETOOTH_BR_HFP_Conn_1600', 0, async function (done) {
let hfpSrc = bluetooth.getProfile(ProfileId.PROFILE_HANDS_FREE_AUDIO_GATEWAY);
let conn1 = hfpSrc.connect('test');
console.info('[bluetooth_js]hfp vaild MAC disconnect :' + JSON.stringify(conn1));
expect(conn1).assertFalse();
done();
})
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BR_HFP_Conn_1700
* @tc.name test a invaild HFP disconnect
* @tc.desc Test disconnect api.
* @tc.size MEDIUM
* @ since 8
* @tc.type Function
* @tc.level Level 3
*/
it('SUB_COMMUNICATION_BLUETOOTH_BR_HFP_Conn_1700', 0, async function (done) {
let hfpSrc = bluetooth.getProfile(ProfileId.PROFILE_HANDS_FREE_AUDIO_GATEWAY);
console.info('[bluetooth_js]hfp get profile result:' + JSON.stringify(hfpSrc));
let conn = hfpSrc.disconnect('test');
console.info('[bluetooth_js]hfp disconnect1 result:' + JSON.stringify(conn));
expect(conn).assertFalse();
done();
})
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BR_HFP_Conn_1800
* @tc.name test getDevice HFP State.
* @tc.desc Test getDeviceState api.
* @tc.size MEDIUM
* @ since 8
* @tc.type Function
* @tc.level Level 1
*/
it('SUB_COMMUNICATION_BLUETOOTH_BR_HFP_Conn_1800', 0, async function (done) {
let hfpSrc = bluetooth.getProfile(ProfileId.PROFILE_HANDS_FREE_AUDIO_GATEWAY);
let retArray = hfpSrc.getConnectionDevices();
console.info('[bluetooth_js]hfp getConnectionDevices:' + JSON.stringify(retArray));
expect(true).assertEqual(retArray.length>=0);
done();
})
}) })
} }
/* /*
* Copyright (C) 2022 Huawei Device Co., Ltd. * Copyright (C) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
...@@ -80,14 +79,14 @@ describe('bluetoothhostTest4', function() { ...@@ -80,14 +79,14 @@ describe('bluetoothhostTest4', function() {
let serverNumber = -1; let serverNumber = -1;
function serverSocket(code, number) { function serverSocket(code, number) {
if (code) { if (code) {
console.log('bluetooth error code: ' + code); console.log('bluetooth error code01: ' + code);
}else{ }else{
console.log('bluetooth serverSocket Number:' + JSON.stringify(number)); console.log('bluetooth serverSocket Number:' + JSON.stringify(number));
serverNumber = number; serverNumber = number;
expect(true).assertEqual(number!=null); expect(true).assertEqual(number!=null);
} }
} }
bluetooth.sppListen('server1', SppOption, serverSocket); await bluetooth.sppListen('server1', SppOption, serverSocket);
done() done()
}) })
...@@ -105,14 +104,14 @@ describe('bluetoothhostTest4', function() { ...@@ -105,14 +104,14 @@ describe('bluetoothhostTest4', function() {
let serverNumber = -1; let serverNumber = -1;
function serverSocket(code, number) { function serverSocket(code, number) {
if (code) { if (code) {
console.log('[bluetooth_js] error code: ' + code); console.log('[bluetooth_js] error code02: ' + code);
}else{ }else{
console.log('[bluetooth_js] serverSocket Number: ' + JSON.stringify(number)); console.log('[bluetooth_js] serverSocket Number: ' + JSON.stringify(number));
serverNumber = number; serverNumber = number;
expect(true).assertEqual(number!=null); expect(true).assertEqual(number!=null);
} }
} }
bluetooth.sppListen('server1', sppOption, serverSocket); await bluetooth.sppListen('server1', sppOption, serverSocket);
done(); done();
}) })
...@@ -129,17 +128,15 @@ describe('bluetoothhostTest4', function() { ...@@ -129,17 +128,15 @@ describe('bluetoothhostTest4', function() {
secure: true, type: 0}; secure: true, type: 0};
let serverNumber = -1; let serverNumber = -1;
function serverSocket(code, number) { function serverSocket(code, number) {
if (code) { if (code) {
console.log('[bluetooth_js] error code: ' + code); console.log('[bluetooth_js] error code03: ' + JSON.stringify(code));
}else{ }else{
console.log('[bluetooth_js] serverSocket Number: '+JSON.stringify(number)); console.log('[bluetooth_js] serverSocket Number: '+JSON.stringify(number));
serverNumber = number; serverNumber = number;
expect(true).assertEqual(serverNumber!=null); expect(true).assertEqual(serverNumber!=null);
} }
} }
bluetooth.sppListen('server1', sppOption, serverSocket); await bluetooth.sppListen('server1', sppOption, serverSocket);
done(); done();
}) })
...@@ -156,9 +153,8 @@ describe('bluetoothhostTest4', function() { ...@@ -156,9 +153,8 @@ describe('bluetoothhostTest4', function() {
secure: false, type: 0}; secure: false, type: 0};
let serverNumber = -1; let serverNumber = -1;
function serverSocket(code, number) { function serverSocket(code, number) {
if (code) { if (code) {
console.log('[bluetooth_js] error code: ' + code); console.log('[bluetooth_js] error code04: ' + JSON.stringify(code));
}else{ }else{
console.log('[bluetooth_js] serverSocket Number:'+ JSON.stringify(number)); console.log('[bluetooth_js] serverSocket Number:'+ JSON.stringify(number));
...@@ -166,7 +162,7 @@ describe('bluetoothhostTest4', function() { ...@@ -166,7 +162,7 @@ describe('bluetoothhostTest4', function() {
expect(true).assertEqual(serverNumber!=null); expect(true).assertEqual(serverNumber!=null);
} }
} }
bluetooth.sppListen('server1', sppOption, serverSocket); await bluetooth.sppListen('server1', sppOption, serverSocket);
done(); done();
}) })
...@@ -182,13 +178,13 @@ describe('bluetoothhostTest4', function() { ...@@ -182,13 +178,13 @@ describe('bluetoothhostTest4', function() {
function acceptClientSocket(code, number) { function acceptClientSocket(code, number) {
if (code) { if (code) {
console.log('[bluetooth_js] error code: ' + code); console.log('[bluetooth_js] error code05: ' + JSON.stringify(code));
}else{ }else{
console.log('[bluetooth_js] clientSocket Number:' + JSON.stringify(number)); console.log('[bluetooth_js] clientSocket Number:' + JSON.stringify(number));
expect(true).assertEqual(number!=null); expect(true).assertEqual(number!=null);
} }
} }
bluetooth.sppAccept(0, acceptClientSocket); await bluetooth.sppAccept(0, acceptClientSocket);
done(); done();
}) })
...@@ -201,9 +197,9 @@ describe('bluetoothhostTest4', function() { ...@@ -201,9 +197,9 @@ describe('bluetoothhostTest4', function() {
* @tc.level Level 3 * @tc.level Level 3
*/ */
it('SUB_COMMUNICATION_BLUETOOTH_BR_SPP_0600', 0, async function (done) { it('SUB_COMMUNICATION_BLUETOOTH_BR_SPP_0600', 0, async function (done) {
bluetooth.sppAccept(-1, function(code, clientSocketNumber) { await bluetooth.sppAccept(-1, function(code, clientSocketNumber) {
if (code) { if (code) {
console.info('[bluetooth_js] code is: ' + code); console.info('[bluetooth_js] code is: ' + JSON.stringify(code));
} else { } else {
console.log('[bluetooth_js]sppAccept Number:' console.log('[bluetooth_js]sppAccept Number:'
+ JSON.stringify(clientSocketNumber)); + JSON.stringify(clientSocketNumber));
...@@ -224,13 +220,13 @@ describe('bluetoothhostTest4', function() { ...@@ -224,13 +220,13 @@ describe('bluetoothhostTest4', function() {
it('SUB_COMMUNICATION_BLUETOOTH_BR_SPP_0700', 0, async function (done) { it('SUB_COMMUNICATION_BLUETOOTH_BR_SPP_0700', 0, async function (done) {
let sppOption = {uuid: '00001810-0000-1000-8000-00805F9B34FB', let sppOption = {uuid: '00001810-0000-1000-8000-00805F9B34FB',
secure: true, type: 0}; secure: true, type: 0};
bluetooth.sppConnect('00:11:22:33:44:55', sppOption, function(code, clientSocketNumber) { await bluetooth.sppConnect('00:11:22:33:44:55', sppOption, function(code, number) {
if (code) { if (code) {
console.info('[bluetooth_js] code is: ' + code); console.info('[bluetooth_js] code is: ' + JSON.stringify(code));
} else { } else {
console.log('[bluetooth_js]sppConnect Number:' console.log('[bluetooth_js]sppConnect Number:'
+ JSON.stringify(clientSocketNumber)); + JSON.stringify(number));
expect(true).assertEqual(clientSocketNumber!=null); expect(true).assertEqual(number!=null);
} }
}); });
done(); done();
...@@ -247,9 +243,9 @@ describe('bluetoothhostTest4', function() { ...@@ -247,9 +243,9 @@ describe('bluetoothhostTest4', function() {
it('SUB_COMMUNICATION_BLUETOOTH_BR_SPP_0800', 0, async function (done) { it('SUB_COMMUNICATION_BLUETOOTH_BR_SPP_0800', 0, async function (done) {
let sppOption = {uuid: '0000', let sppOption = {uuid: '0000',
secure: false, type: 0}; secure: false, type: 0};
bluetooth.sppConnect('ABC', sppOption, function(code, clientSocketNumber) { await bluetooth.sppConnect('ABC', sppOption, function(code, clientSocketNumber) {
if (code) { if (code) {
console.info('[bluetooth_js] code is: ' + code); console.info('[bluetooth_js] code is: ' + JSON.stringify(code));
} else { } else {
console.log('[bluetooth_js]sppConnect Number' console.log('[bluetooth_js]sppConnect Number'
+ JSON.stringify(clientSocketNumber)); + JSON.stringify(clientSocketNumber));
...@@ -270,9 +266,9 @@ describe('bluetoothhostTest4', function() { ...@@ -270,9 +266,9 @@ describe('bluetoothhostTest4', function() {
it('SUB_COMMUNICATION_BLUETOOTH_BR_SPP_0900', 0, async function (done) { it('SUB_COMMUNICATION_BLUETOOTH_BR_SPP_0900', 0, async function (done) {
let sppOption = {uuid: '00001810-0000-1000-8000-00805F9B34FB', let sppOption = {uuid: '00001810-0000-1000-8000-00805F9B34FB',
secure: true, type: 0}; secure: true, type: 0};
bluetooth.sppConnect('BT', sppOption, function(code, clientSocketNumber) { await bluetooth.sppConnect('BT', sppOption, function(code, clientSocketNumber) {
if (code) { if (code) {
console.info('[bluetooth_js] code is: ' + code); console.info('[bluetooth_js] code is: ' + JSON.stringify(code));
} else { } else {
console.log('[bluetooth_js]sppConnect Number' console.log('[bluetooth_js]sppConnect Number'
+ JSON.stringify(clientSocketNumber)); + JSON.stringify(clientSocketNumber));
...@@ -294,7 +290,7 @@ describe('bluetoothhostTest4', function() { ...@@ -294,7 +290,7 @@ describe('bluetoothhostTest4', function() {
let serverNumber = -1; let serverNumber = -1;
function serverSocket(code, number) { function serverSocket(code, number) {
if (code) { if (code) {
console.log('bluetooth error code: ' + code); console.log('bluetooth error code10: ' + JSON.stringify(code));
}else{ }else{
console.log('bluetooth serverSocket Number:'+ JSON.stringify(number)); console.log('bluetooth serverSocket Number:'+ JSON.stringify(number));
serverNumber = number; serverNumber = number;
...@@ -304,7 +300,7 @@ describe('bluetoothhostTest4', function() { ...@@ -304,7 +300,7 @@ describe('bluetoothhostTest4', function() {
} }
let SppOption = {uuid: '00001810-0000-1000-8000-00805F9B34FB', let SppOption = {uuid: '00001810-0000-1000-8000-00805F9B34FB',
secure: true, type: 0}; secure: true, type: 0};
bluetooth.sppListen('server1', SppOption, serverSocket); await bluetooth.sppListen('server1', SppOption, serverSocket);
bluetooth.sppCloseServerSocket(serverNumber); bluetooth.sppCloseServerSocket(serverNumber);
done(); done();
}) })
...@@ -319,9 +315,9 @@ describe('bluetoothhostTest4', function() { ...@@ -319,9 +315,9 @@ describe('bluetoothhostTest4', function() {
*/ */
it('SUB_COMMUNICATION_BLUETOOTH_BR_SPP_1100', 0, async function (done) { it('SUB_COMMUNICATION_BLUETOOTH_BR_SPP_1100', 0, async function (done) {
let clientNumber = -1; let clientNumber = -1;
bluetooth.sppAccept(-1, function(code, clientSocketNumber) { await bluetooth.sppAccept(-1, function(code, clientSocketNumber) {
if (code) { if (code) {
console.info('[bluetooth_js] code is: ' + code); console.info('[bluetooth_js] code is: ' + JSON.stringify(code));
} else { } else {
console.log('[bluetooth_js]sppAccept Number:' console.log('[bluetooth_js]sppAccept Number:'
+ JSON.stringify(clientSocketNumber)); + JSON.stringify(clientSocketNumber));
...@@ -343,9 +339,9 @@ describe('bluetoothhostTest4', function() { ...@@ -343,9 +339,9 @@ describe('bluetoothhostTest4', function() {
*/ */
it('SUB_COMMUNICATION_BLUETOOTH_BR_SPP_1200', 0, async function (done) { it('SUB_COMMUNICATION_BLUETOOTH_BR_SPP_1200', 0, async function (done) {
let clientNumber = -1; let clientNumber = -1;
bluetooth.sppAccept(-1, function(code, clientSocketNumber) { await bluetooth.sppAccept(-1, function(code, clientSocketNumber) {
if (code) { if (code) {
console.info('[bluetooth_js] code is: ' + code); console.info('[bluetooth_js] code is: ' + JSON.stringify(code));
} else { } else {
console.log('[bluetooth_js]sppAccept Number:' console.log('[bluetooth_js]sppAccept Number:'
+ JSON.stringify(clientSocketNumber)); + JSON.stringify(clientSocketNumber));
...@@ -362,7 +358,37 @@ describe('bluetoothhostTest4', function() { ...@@ -362,7 +358,37 @@ describe('bluetoothhostTest4', function() {
done(); done();
}) })
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BR_SPP_1300
* @tc.name test sppReadOn
* @tc.desc Test On and Off Api
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('SUB_COMMUNICATION_BLUETOOTH_BR_SPP_1300', 0, async function (done) {
let clientNumber = -1;
function acceptClientSocket(code, number) {
if (code) {
console.log('[bluetooth_js] error code13: ' + JSON.stringify(code));
}else{
console.log('[bluetooth_js]clientSocke Number:' + JSON.stringify(number));
clientNumber = number;
expect(true).assertEqual(number!=null);
}
}
await bluetooth.sppAccept(0, acceptClientSocket);
function dataRead(dataBuffer) {
let data = new Uint8Array(dataBuffer);
console.log('bluetooth data is: ' + data[0]);
}
await bluetooth.on('sppRead', clientNumber, dataRead);
await bluetooth.off('sppRead', clientNumber, dataRead);
done();
})
}) })
} }
...@@ -82,25 +82,30 @@ describe('bluetoothhostTest', function() { ...@@ -82,25 +82,30 @@ describe('bluetoothhostTest', function() {
* @tc.level Level 0 * @tc.level Level 0
*/ */
it('SUB_COMMUNICATION_BLUETOOTH_BR_Switch_0100', 0, async function (done) { it('SUB_COMMUNICATION_BLUETOOTH_BR_Switch_0100', 0, async function (done) {
function onReceiveEvent(data) {
console.info('bluetooth state001 ='+ JSON.stringify(data));
}
await bluetooth.on('stateChange', onReceiveEvent);
let state = bluetooth.getState(); let state = bluetooth.getState();
console.info('[bluetooth_js] get bluetooth state result'+ JSON.stringify(state)); console.info('[bluetooth_js] get bluetooth state001'+ JSON.stringify(state));
if(state!=BluetoothState.STATE_ON) if(state!=BluetoothState.STATE_ON)
{ {
let enable = bluetooth.enableBluetooth(); let enable = bluetooth.enableBluetooth();
await sleep(3000); await sleep(5000);
console.info('[bluetooth_js] bluetooth enable result'+JSON.stringify(enable)); console.info('[bluetooth_js] bluetooth enable001'+JSON.stringify(enable));
expect(enable).assertTrue(); expect(enable).assertTrue();
let state1 = bluetooth.getState(); let state1 = bluetooth.getState();
console.info('[bluetooth_js] enable state1 '+ JSON.stringify(state1)); console.info('[bluetooth_js] enable state001 '+ JSON.stringify(state1));
expect(state1).assertEqual(BluetoothState.STATE_ON); expect(state1).assertEqual(BluetoothState.STATE_ON);
} }
let disable = bluetooth.disableBluetooth(); let disable = bluetooth.disableBluetooth();
await sleep(3000); await sleep(3000);
console.info('[bluetooth_js] bluetooth disable result'+JSON.stringify(disable)); console.info('[bluetooth_js] bluetooth disable001'+JSON.stringify(disable));
expect(disable).assertTrue(); expect(disable).assertTrue();
let state2 = bluetooth.getState(); let state2 = bluetooth.getState();
console.info('[bluetooth_js] disable state2 '+ JSON.stringify(state2)); console.info('[bluetooth_js] disable state001 '+ JSON.stringify(state2));
expect(state2).assertEqual(BluetoothState.STATE_OFF); expect(state2).assertEqual(BluetoothState.STATE_OFF);
await bluetooth.off('stateChange', onReceiveEvent);
done() done()
}) })
......
/*
* 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 '@ohos/hypium'
let Btname = {
NUM_TEST :'012345678901234567890123456789012345678901234567890123'+
'45678901234567890123456789012345678901234567890123456789012345678901234567',
NUM_TEST1 :'01234567890123456789012345678901234567890123456'
+'7890123456789012345678901234567890123456789012345678901234567890123456789012345678',
LETTERS_TEST :'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
CHINESES_TEST :'测试蓝牙名称是否正常测试蓝牙名称是否试蓝牙',
SYMBOL_TEST:'*^_^* 、。·ˉˇ¨〃々—~‖·‘’“”「『』〖❂【±×'
+'÷∶∧∨∑∏∪∩∈∷√⊥‖∠⌒⊙∫∮≡≌≈∽∝≠♂♀°℃$¤¢£‰§№☆★○●◎◇□■△※→←↑↓〓',
MIXES:'测试蓝牙名称是否正试蓝牙\'名称是否[666]aaw',
MIXES2:'——◎◇◆□■△▲测试蓝牙',
MIXES3:'78453-、、。。◎◇◆□■△▲',
MIXES4:'hhhfdf-、、。。◎◇◆□■△▲',
MIXES5:'#01-5@<?;:!@$%^&*(1[]{【+-;:‘’“”测试=》《\'[6]',
MIXES6:'#01-567890@<>?/;:5675ASDF012345678!@'
+'$%^&*()9012378901[]{}【】566~·67890blue',
MIXES7:'0123456789012345678901234567890123456789012345678901'
+'23456789012345678901234567890123456789012345678901234567890123456789012345678012'
+'345678901234567890123456789012345678901234567890123456789012367890123456789012345568'
}
export default function bluetoothhostTest() {
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_GET_STATE_0001
* @tc.name testEnableBluetooth
* @tc.desc Test EnableBluetooth api by promise.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('SUB_COMMUNACATION_bluetooth_GET_STATE_0001', 0, async function (done) {
console.info('[bluetooth_js] getState start');
await tryToEnableBt();
let state = bluetooth.getState();
let BluetoothState=
{
STATE_OFF : 0,
STATE_TURNING_ON : 1,
STATE_ON : 2,
STATE_TURNING_OFF : 3,
STATE_BLE_TURNING_ON : 4,
STATE_BLE_ON : 5,
STATE_BLE_TURNING_OFF : 6,
} ;
console.info('[bluetooth_js] get bluetooth state result = '+ JSON.stringify(state));
expect(state).assertEqual(bluetooth.BluetoothState.STATE_ON);
expect(BluetoothState.STATE_OFF != state).assertTrue();
expect(BluetoothState.STATE_TURNING_ON != state).assertTrue();
expect(BluetoothState.STATE_TURNING_OFF != state).assertTrue();
expect(BluetoothState.STATE_BLE_TURNING_ON != state).assertTrue();
expect(BluetoothState.STATE_BLE_ON != state).assertTrue();
expect(BluetoothState.STATE_BLE_TURNING_OFF != state).assertTrue();
done();
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_SET_LOCALNAME_0001
* @tc.name testClassicSetLocalName
* @tc.desc Test ClassicSetLocalName api.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('SUB_COMMUNACATION_bluetooth_SET_LOCALNAME_0001', 0, async function (done) {
console.info('[bluetooth_js] set localname start');
await tryToEnableBt();
let name = bluetooth.setLocalName('bluetooth_test');
console.info('[bluetooth_js] appInfoTest enable bluetooth result = '+ JSON.stringify(name));
expect(name).assertEqual(true);
done();
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_START_PAIR_0001
* @tc.name testStartpair
* @tc.desc Test Startpair api by promise.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('SUB_COMMUNACATION_bluetooth_START_PAIR_0001', 0, async function (done) {
console.info('[bluetooth_js] Startpair test start ...');
await tryToEnableBt();
let result = bluetooth.pairDevice("00:00:00:00:00:00");
console.info("[bluetooth_js] onStartpair -> " + JSON.stringify(result));
expect(result).assertFalse();
done();
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_GET_LOCALNAME_0001
* @tc.name testClassicGetLocalName
* @tc.desc Test ClassicGetLocalName api.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('SUB_COMMUNACATION_bluetooth_GET_LOCALNAME_0001', 0, async function (done) {
console.info('[bluetooth_js] get localName start');
await tryToEnableBt();
let localName = bluetooth.getLocalName();
console.info('[bluetooth_js] get local Name result = ' + JSON.stringify(localName));
expect(localName).assertEqual('bluetooth_test');
done();
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_SET_BLUETOOTH_SCAN_MODE_0001
* @tc.name testClassicSetBluetoothScanMode
* @tc.desc Test ClassicSetBluetoothScanMode api.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('SUB_COMMUNACATION_bluetooth_SET_BLUETOOTH_SCAN_MODE_0001', 0, async function (done) {
console.info('[bluetooth_js] set scan mode start');
await tryToEnableBt();
let result = bluetooth.setBluetoothScanMode(1,10000);
let ScanDuty=
{
SCAN_MODE_LOW_POWER : 0,
SCAN_MODE_BALANCED : 1,
SCAN_MODE_BALANCED : 2,
};
expect(true).assertTrue(JSON.stringify(ScanDuty.SCAN_MODE_LOW_POWER) !=result );
expect(true).assertTrue(JSON.stringify(ScanDuty.SCAN_MODE_BALANCED) != result);
expect(true).assertTrue(JSON.stringify(ScanDuty.SCAN_MODE_BALANCED) != result );
expect(result).assertEqual(true);
done();
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_GET_BLUETOOTH_SCAN_MODE_0001
* @tc.name testClassicGetBluetoothScanMode
* @tc.desc Test ClassicGetBluetoothScanMode api.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('SUB_COMMUNACATION_bluetooth_GET_BLUETOOTH_SCAN_MODE_0001', 0, async function (done) {
console.info('[bluetooth_js] get scan mode start');
await tryToEnableBt();
let result = bluetooth.setBluetoothScanMode(1,10000);
expect(result).assertEqual(true);
let ScanMode=
{
SCAN_MODE_NONE : 0,
SCAN_MODE_CONNECTABLE : 1,
SCAN_MODE_GENERAL_DISCOVERABLE : 2,
SCAN_MODE_LIMITED_DISCOVERABLE : 3,
SCAN_MODE_CONNECTABLE_GENERAL_DISCOVERABLE : 4,
SCAN_MODE_CONNECTABLE_LIMITED_DISCOVERABLE : 5,
};
let scanModeResult = bluetooth.getBluetoothScanMode();
console.info('[bluetooth_js] get scan mode result2 = ' + JSON.stringify(scanModeResult));
expect(scanModeResult).assertEqual(1);
expect(true).assertTrue(ScanMode.SCAN_MODE_NONE != scanModeResult);
expect(true).assertTrue(ScanMode.SCAN_MODE_CONNECTABLE != scanModeResult);
expect(true).assertTrue(ScanMode.SCAN_MODE_GENERAL_DISCOVERABLE != scanModeResult);
expect(true).assertTrue(ScanMode.SCAN_MODE_LIMITED_DISCOVERABLE != scanModeResult);
expect(true).assertTrue(ScanMode.SCAN_MODE_CONNECTABLE_GENERAL_DISCOVERABLE != scanModeResult);
expect(true).assertTrue(ScanMode.SCAN_MODE_CONNECTABLE_LIMITED_DISCOVERABLE != scanModeResult);
done();
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_GET_BT_CONNECT_STATE_0001
* @tc.name testClassicGetBtConnectionState
* @tc.desc Test ClassicGetBtConnectionState api.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('SUB_COMMUNACATION_bluetooth_GET_BT_CONNECT_STATE_0001', 0, async function (done) {
console.info('[bluetooth_js] get connection state start');
await tryToEnableBt();
let ProfileConnectionState=
{
STATE_CONNECTING : 1,
STATE_CONNECTED : 2,
STATE_DISCONNECTED : 0,
STATE_DISCONNECTING : 3,
};
let connState = bluetooth.getBtConnectionState();
console.info('[bluetooth_js] get bt connection state result' + JSON.stringify(connState));
expect(connState).assertEqual(ProfileConnectionState.STATE_DISCONNECTED);
expect(true).assertTrue(ProfileConnectionState.STATE_CONNECTING!= connState );
expect(true).assertTrue(ProfileConnectionState.STATE_CONNECTED!= connState );
expect(true).assertTrue(ProfileConnectionState.STATE_DISCONNECTING!= connState );
done();
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_START_BLUETOOTH_DISCOVERY_0001
* @tc.name testClassicStartBluetoothDiscovery
* @tc.desc Test ClassicStartBluetoothDiscovery api.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('SUB_COMMUNACATION_bluetooth_START_BLUETOOTH_DISCOVERY_0001', 0, async function (done) {
console.info('[bluetooth_js] discovery start');
await tryToEnableBt();
let result = bluetooth.startBluetoothDiscovery();
console.info('[bluetooth_js] get bt connection state result' + JSON.stringify(result));
expect(result).assertEqual(true);
done();
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_STOP_BLUETOOTH_DISCOVERY_0001
* @tc.name testClassicStopBluetoothDiscovery
* @tc.desc Test ClassicStopBluetoothDiscovery api.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('SUB_COMMUNACATION_bluetooth_STOP_BLUETOOTH_DISCOVERY_0001', 0, async function (done) {
console.info('[bluetooth_js] stop discovery start');
await tryToEnableBt();
let result = bluetooth.stopBluetoothDiscovery();
console.info("stopBluetoothDiscovery :" + JSON.stringify(result));
expect(result).assertTrue();
done();
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_GET_PAIRED_DEVICES_0001
* @tc.name testClassicGetPairedDevices
* @tc.desc Test ClassicGetPairedDevices api.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('SUB_COMMUNACATION_bluetooth_GET_PAIRED_DEVICES_0001', 0, async function (done) {
console.info('[bluetooth_js] get paired devices start');
await tryToEnableBt();
let devices = bluetooth.getPairedDevices();
console.info('[bluetooth_js] get paired devices:' + JSON.stringify(devices) +'length:' + devices.length);
expect(devices.length).assertEqual(0);
done();
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_SPP_LISTEN_0001
* @tc.name testSppListen
* @tc.desc Test SppListen api by callback.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('SUB_COMMUNACATION_bluetooth_SPP_LISTEN_0001', 0, async function (done) {
console.log("[bluetooth_js]: spp listen start");
await tryToEnableBt();
let sppOption = {uuid: '00001810-0000-1000-8000-00805F9B34FB',
secure: false, type: 0};
bluetooth.sppListen('server1', sppOption, function(code, serverSocketNumber) {
console.info('[bluetooth_js] code is: ' + code.code);
if (code.code == 0) {
expect(true).assertEqual(true);
done();
} else {
expect(true).assertEqual(false);
done();
}
});
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_SPP_ACCEPT_0001
* @tc.name testSppAccept
* @tc.desc Test SppAccept api by callbck.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('SUB_COMMUNACATION_bluetooth_SPP_ACCEPT_0001', 0, async function (done) {
console.log("[bluetooth_js] spp accept start");
await tryToEnableBt();
bluetooth.sppAccept(-1, function(code, clientSocketNumber) {
console.info('[bluetooth_js] code is: ' + code.code);
if (code.code == 0) {
expect(true).assertEqual(true);
} else {
expect(true).assertEqual(false);
}
});
done();
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_SPP_CLOSE_SERVER_SOCKET_0001
* @tc.name testSppCloseServerSocket
* @tc.desc Test SppCloseServerSocket api.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('SUB_COMMUNACATION_bluetooth_SPP_CLOSE_SERVER_SOCKET_0001', 0, async function (done) {
console.log("[bluetooth_js] spp closeServerSocket start");
await tryToEnableBt();
setTimeout(async ()=>{
bluetooth.sppCloseServerSocket(-1);
},3000);
done();
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_SPP_CONNECT_0001
* @tc.name testSppConnect
* @tc.desc Test SppConnect api by callback.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('SUB_COMMUNACATION_bluetooth_SPP_CONNECT_0001', 0, async function (done) {
console.info('[bluetooth_js] spp_connect start');
await tryToEnableBt();
let sppOption = {uuid: '00001810-0000-1000-8000-00805F9B34FB',
secure: true, type: 0};
bluetooth.sppConnect(55, sppOption, function(code, clientSocketNumber) {
console.info('[bluetooth_js] code is: ' + code.code);
if (code.code == 0) {
expect(true).assertEqual(true);
} else {
expect(true).assertEqual(false);
}
});
done();
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_SPP_WRITE_0001
* @tc.name testSppWrite
* @tc.desc Test SppWrite api.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('SUB_COMMUNACATION_bluetooth_SPP_WRITE_0001', 0, async function (done) {
console.info('[bluetooth_js] spp write start');
await tryToEnableBt();
let arrayBuffer = new ArrayBuffer(8);
let data = new Uint8Array(arrayBuffer);
data[0] = 123;
let ret = bluetooth.sppWrite(-1, arrayBuffer);
console.info('[bluetooth_js] bluetooth sppWrite ret : ' + ret);
expect(ret).assertEqual(false);
done();
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_SPP_CLOSE_CLIENT_SOCKET_0001
* @tc.name testSppCloseClientSocket
* @tc.desc Test SppCloseClientSocket api.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('SUB_COMMUNACATION_bluetooth_SPP_CLOSE_CLIENT_SOCKET_0001', 0, async function (done) {
console.log("[bluetooth_js] spp closeClientSocket start");
await tryToEnableBt();
setTimeout(async ()=>{
bluetooth.sppCloseClientSocket(-1);
},3000);
done();
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_GET_REMO_DEV_NAME_0001
* @tc.name testGetRemoteDeviceName
* @tc.desc Test GetRemoteDeviceName api.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('SUB_COMMUNACATION_bluetooth_GET_REMO_DEV_NAME_0001', 0, async function (done) {
console.info('[bluetooth_js] getRemoteDeviceName start');
await tryToEnableBt();
let ret = bluetooth.getRemoteDeviceName("00:00:00:00:00:00");
console.info('[bluetooth_js] getRemoteDeviceName ret2 : ' + JSON.stringify(ret));
expect(ret.length).assertEqual(0);
done();
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_GET_REMO_DEV_CLASS_0001
* @tc.name testGetRemoteDeviceClass
* @tc.desc Test GetRemoteDeviceClass api.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('SUB_COMMUNACATION_bluetooth_GET_REMO_DEV_CLASS_0001', 0, async function (done) {
console.info('[bluetooth_js] getRemoteDeviceClass start');
await tryToEnableBt();
let ret = bluetooth.getRemoteDeviceClass("00:00:00:00:00:00");
console.info('[bluetooth_js] getRemoteDeviceClass ret2 :' + JSON.stringify(ret) + 'majorClass:' +
ret.majorClass + 'majorMinorClass:'+ ret.majorMinorClass + 'classOfDevice:' + ret.classOfDevice);
expect(ret.majorClass).assertEqual(0);
done();
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_SET_LOCAL_NAME_0001
* @tc.name testsetLocalName
* @tc.desc Test setLocalName api.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('SUB_COMMUNACATION_bluetooth_SET_LOCAL_NAME_0001', 0, async function (done) {
await tryToEnableBt();
let name = bluetooth.getLocalName();
let set = bluetooth.setLocalName('');
expect(set).assertFalse();
let localName = bluetooth.getLocalName();
expect(true).assertTrue(localName==name);
console.info('[bluetooth_js] getLocalName result1 = ' + JSON.stringify(localName));
done();
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_SET_LOCAL_NAME_0002
* @tc.name testsetLocalName
* @tc.desc Test setLocalName api.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('SUB_COMMUNACATION_bluetooth_SET_LOCAL_NAME_0002', 0, async function (done) {
await tryToEnableBt();
let localName = bluetooth.getLocalName();
let name = bluetooth.setLocalName();
console.info('[bluetooth_js] getName result2 = '+ JSON.stringify(localName) +
'setName result2 =' + JSON.stringify(name));
expect(name).assertFalse();
done();
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_SET_LOCAL_NAME_0003
* @tc.name testsetLocalName
* @tc.desc Test setLocalName api.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('SUB_COMMUNACATION_bluetooth_SET_LOCAL_NAME_0003', 0, async function (done) {
await tryToEnableBt();
let name = bluetooth.setLocalName(Btname.NUM_TEST);
expect(name).assertTrue();
let localName = bluetooth.getLocalName();
expect(true).assertTrue(Btname.NUM_TEST == JSON.stringify(localName));
done();
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_SET_LOCAL_NAME_0004
* @tc.name testsetLocalName
* @tc.desc Test setLocalName api.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('SUB_COMMUNACATION_bluetooth_SET_LOCAL_NAME_0004', 0, async function (done) {
await tryToEnableBt();
let name = bluetooth.setLocalName(Btname.NUM_TEST1);
expect(name).assertTrue();
let localName = bluetooth.getLocalName();
expect(true).assertTrue(Btname.NUM_TEST1 == JSON.stringify(localName));
done();
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_SET_LOCAL_NAME_0005
* @tc.name testsetLocalName
* @tc.desc Test setLocalName api.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('SUB_COMMUNACATION_bluetooth_SET_LOCAL_NAME_0005', 0, async function (done) {
await tryToEnableBt();
let name = bluetooth.setLocalName(Btname.LETTERS_TEST);
expect(name).assertTrue();
let localName = bluetooth.getLocalName();
expect(true).assertTrue(Btname.LETTERS_TEST == JSON.stringify(localName));
done();
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_SET_LOCAL_NAME_0006
* @tc.name testsetLocalName
* @tc.desc Test setLocalName api.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('SUB_COMMUNACATION_bluetooth_SET_LOCAL_NAME_0006', 0, async function (done) {
await tryToEnableBt();
let name = bluetooth.setLocalName(Btname.CHINESES_TEST);
expect(name).assertTrue();
let localName = bluetooth.getLocalName();
expect(true).assertTrue(Btname.CHINESES_TEST == JSON.stringify(localName));
done();
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_SET_LOCAL_NAME_0007
* @tc.name testsetLocalName
* @tc.desc Test setLocalName api.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('SUB_COMMUNACATION_bluetooth_SET_LOCAL_NAME_0007', 0, async function (done) {
await tryToEnableBt();
let name = bluetooth.setLocalName(Btname.SYMBOL_TEST);
console.info('[bluetooth_js] setLocalName result7 = '+ JSON.stringify(name));
expect(name).assertTrue();
let localName = bluetooth.getLocalName();
expect(true).assertTrue(Btname.SYMBOL_TEST == JSON.stringify(localName));
done();
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_SET_LOCAL_NAME_0008
* @tc.name testsetLocalName
* @tc.desc Test setLocalName api.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('SUB_COMMUNACATION_bluetooth_SET_LOCAL_NAME_0008', 0, async function (done) {
await tryToEnableBt();
let name = bluetooth.setLocalName(Btname.MIXES);
console.info('[bluetooth_js] setLocalName result8 = '+ JSON.stringify(name));
expect(name).assertTrue();
let localName = bluetooth.getLocalName();
expect(true).assertTrue(Btname.MIXES == JSON.stringify(localName));
done();
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_SET_LOCAL_NAME_0009
* @tc.name testsetLocalName
* @tc.desc Test setLocalName api.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('SUB_COMMUNACATION_bluetooth_SET_LOCAL_NAME_0009', 0, async function (done) {
await tryToEnableBt();
let name = bluetooth.setLocalName(Btname.MIXES2);
console.info('[bluetooth_js] setLocalName result9 = '+ JSON.stringify(name));
expect(name).assertTrue();
let localName = bluetooth.getLocalName();
expect(true).assertTrue(Btname.MIXES2 == JSON.stringify(localName));
done();
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_SET_LOCAL_NAME_00010
* @tc.name testsetLocalName
* @tc.desc Test setLocalName api.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('SUB_COMMUNACATION_bluetooth_SET_LOCAL_NAME_00010', 0, async function (done) {
await tryToEnableBt();
let name = bluetooth.setLocalName(Btname.MIXES3);
console.info('[bluetooth_js] setLocalName result10 = '+ JSON.stringify(name));
expect(name).assertTrue();
let localName = bluetooth.getLocalName();
expect(true).assertTrue(Btname.MIXES3 == JSON.stringify(localName));
done();
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_SET_LOCAL_NAME_00011
* @tc.name testsetLocalName
* @tc.desc Test setLocalName api.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('SUB_COMMUNACATION_bluetooth_SET_LOCAL_NAME_00011', 0, async function (done) {
await tryToEnableBt();
let name = bluetooth.setLocalName(Btname.MIXES4);
console.info('[bluetooth_js] setLocalName result11 = '+ JSON.stringify(name));
expect(name).assertTrue();
let localName = bluetooth.getLocalName();
expect(true).assertTrue(Btname.MIXES4 == JSON.stringify(localName));
done();
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_SET_LOCAL_NAME_00012
* @tc.name testsetLocalName
* @tc.desc Test setLocalName api.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('SUB_COMMUNACATION_bluetooth_SET_LOCAL_NAME_00012', 0, async function (done) {
await tryToEnableBt();
let name = bluetooth.setLocalName(Btname.MIXES5);
console.info('[bluetooth_js] setLocalName result12 = '+ JSON.stringify(name));
expect(name).assertTrue();
let localName = bluetooth.getLocalName();
expect(true).assertTrue(Btname.MIXES5 == JSON.stringify(localName));
done();
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_SET_LOCAL_NAME_00013
* @tc.name testsetLocalName
* @tc.desc Test setLocalName api.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('SUB_COMMUNACATION_bluetooth_SET_LOCAL_NAME_00013', 0, async function (done) {
await tryToEnableBt();
let name = bluetooth.setLocalName(Btname.MIXES6);
console.info('[bluetooth_js] setLocalName result13 = '+ JSON.stringify(name));
expect(name).assertTrue();
let localName = bluetooth.getLocalName();
expect(true).assertTrue(Btname.MIXES6 == JSON.stringify(localName));
done();
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_SET_LOCAL_NAME_00014
* @tc.name testsetLocalName
* @tc.desc Test setLocalName api.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('SUB_COMMUNACATION_bluetooth_SET_LOCAL_NAME_00014', 0, async function (done) {
await tryToEnableBt();
let name = bluetooth.setLocalName(Btname.MIXES7);
console.info('[bluetooth_js] setLocalName result14 = '+ JSON.stringify(name));
expect(name).assertTrue();
let localName = bluetooth.getLocalName();
expect(true).assertTrue(Btname.MIXES7 == JSON.stringify(localName));
done();
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_DISABLE_0001
* @tc.name testdisablebluetooth
* @tc.desc Test disablebluetooth api.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('SUB_COMMUNACATION_bluetooth_DISABLE_0001', 0, async function (done) {
await tryToEnableBt();
console.info('[bluetooth_js] disable test start');
let disable = bluetooth.disableBluetooth();
console.info('[bluetooth_js] disable:' + JSON.stringify(disable));
expect(disable).assertTrue();
let state = bluetooth.getState();
console.info('[bluetooth_js] bt state:' + JSON.stringify(state));
done();
})
})
}
...@@ -101,14 +101,14 @@ describe('geolocationTest_geo1', function () { ...@@ -101,14 +101,14 @@ describe('geolocationTest_geo1', function () {
}) })
/** /**
* @tc.number SUB_HSS_LocationSystem_Geo_0001 * @tc.number SUB_HSS_LocationSystem_Geo_0100
* @tc.name testIsGeoServiceAvailable * @tc.name testIsGeoServiceAvailable
* @tc.desc Check whether address resolution and reverse address resolution are supported. * @tc.desc Check whether address resolution and reverse address resolution are supported.
* @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_0001', 0, async function (done) { it('SUB_HSS_LocationSystem_Geo_0100', 0, async function (done) {
geolocation.isGeoServiceAvailable(async (err, data) => { geolocation.isGeoServiceAvailable(async (err, data) => {
if (err) { if (err) {
console.info('[lbs_js] getGeoServiceState err is : ' + JSON.stringify(err)); console.info('[lbs_js] getGeoServiceState err is : ' + JSON.stringify(err));
...@@ -124,14 +124,14 @@ describe('geolocationTest_geo1', function () { ...@@ -124,14 +124,14 @@ describe('geolocationTest_geo1', function () {
}); });
/** /**
* @tc.number SUB_HSS_LocationSystem_Geo_0002 * @tc.number SUB_HSS_LocationSystem_Geo_0200
* @tc.name TestisGeoServiceAvailable * @tc.name TestisGeoServiceAvailable
* @tc.desc Check whether address resolution and reverse address resolution are supported. * @tc.desc Check whether address resolution and reverse address resolution are supported.
* @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_0002', 0, async function (done) { it('SUB_HSS_LocationSystem_Geo_0200', 0, async function (done) {
await geolocation.isGeoServiceAvailable().then((result) => { await geolocation.isGeoServiceAvailable().then((result) => {
console.info('[lbs_js] isGeoServiceAvailable1 promise result: ' + JSON.stringify(result)); console.info('[lbs_js] isGeoServiceAvailable1 promise result: ' + JSON.stringify(result));
console.info('[lbs_js] not support now'); console.info('[lbs_js] not support now');
...@@ -144,14 +144,14 @@ describe('geolocationTest_geo1', function () { ...@@ -144,14 +144,14 @@ describe('geolocationTest_geo1', function () {
}) })
/** /**
* @tc.number SUB_HSS_LocationSystem_Geo_0003 * @tc.number SUB_HSS_LocationSystem_Geo_0300
* @tc.name TestgetAddressesFromLocation * @tc.name TestgetAddressesFromLocation
* @tc.desc Address Resolution Test. * @tc.desc Address Resolution Test.
* @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_0003', 0, async function (done) { it('SUB_HSS_LocationSystem_Geo_0300', 0, async function (done) {
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 promise = new Promise((resolve, reject) => { let promise = new Promise((resolve, reject) => {
geolocation.getAddressesFromLocation(reverseGeocodeRequest, (err, data) => { geolocation.getAddressesFromLocation(reverseGeocodeRequest, (err, data) => {
...@@ -168,14 +168,14 @@ describe('geolocationTest_geo1', function () { ...@@ -168,14 +168,14 @@ describe('geolocationTest_geo1', function () {
}) })
/** /**
* @tc.number SUB_HSS_LocationSystem_Geo_0004 * @tc.number SUB_HSS_LocationSystem_Geo_0400
* @tc.name TestgetAddressesFromLocation * @tc.name TestgetAddressesFromLocation
* @tc.desc Address Resolution Test. * @tc.desc Address Resolution Test.
* @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_0004', 0, async function (done) { it('SUB_HSS_LocationSystem_Geo_0400', 0, async function (done) {
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));
...@@ -199,14 +199,14 @@ describe('geolocationTest_geo1', function () { ...@@ -199,14 +199,14 @@ describe('geolocationTest_geo1', function () {
}) })
/** /**
* @tc.number SUB_HSS_LocationSystem_Geo_0005 * @tc.number SUB_HSS_LocationSystem_Geo_0500
* @tc.name TestgetAddressesFromLocation * @tc.name TestgetAddressesFromLocation
* @tc.desc Obtaining Multiple Addresses Using the Address Resolution Function. * @tc.desc Obtaining Multiple Addresses Using the Address Resolution Function.
* @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_0005', 0, async function (done) { it('SUB_HSS_LocationSystem_Geo_0500', 0, async function (done) {
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));
...@@ -221,14 +221,14 @@ describe('geolocationTest_geo1', function () { ...@@ -221,14 +221,14 @@ describe('geolocationTest_geo1', function () {
}) })
/** /**
* @tc.number SUB_HSS_LocationSystem_Geo_0006 * @tc.number SUB_HSS_LocationSystem_Geo_0600
* @tc.name TestgetAddressesFromLocation * @tc.name TestgetAddressesFromLocation
* @tc.desc Input parameter boundary test of the address resolution function * @tc.desc Input parameter boundary test of the address resolution function
* @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_0006', 0, async function (done) { it('SUB_HSS_LocationSystem_Geo_0600', 0, async function (done) {
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));
...@@ -267,14 +267,14 @@ describe('geolocationTest_geo1', function () { ...@@ -267,14 +267,14 @@ describe('geolocationTest_geo1', function () {
}) })
/** /**
* @tc.number SUB_HSS_LocationSystem_Geo_0007 * @tc.number SUB_HSS_LocationSystem_Geo_0700
* @tc.name TestgetAddressesFromLocation * @tc.name TestgetAddressesFromLocation
* @tc.desc Input parameter boundary test of the address resolution function * @tc.desc Input parameter boundary test of the address resolution function
* @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_0700', 0, async function (done) {
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));
...@@ -313,14 +313,14 @@ describe('geolocationTest_geo1', function () { ...@@ -313,14 +313,14 @@ describe('geolocationTest_geo1', function () {
}) })
/** /**
* @tc.number SUB_HSS_LocationSystem_Geo_0008 * @tc.number SUB_HSS_LocationSystem_Geo_0800
* @tc.name TestgetAddressesFromLocation * @tc.name TestgetAddressesFromLocation
* @tc.desc Reverse address resolution test. * @tc.desc Reverse address resolution test.
* @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_0008', 0, async function (done) { it('SUB_HSS_LocationSystem_Geo_0800', 0, async function (done) {
let geocodeRequest = { let geocodeRequest = {
"description": "上海市浦东新区金穗路1800号", "description": "上海市浦东新区金穗路1800号",
"maxItems": 1, "maxItems": 1,
...@@ -330,6 +330,7 @@ describe('geolocationTest_geo1', function () { ...@@ -330,6 +330,7 @@ describe('geolocationTest_geo1', function () {
"maxLatitude": "", "maxLatitude": "",
"maxLongitude": "" "maxLongitude": ""
}; };
try {
geolocation.getAddressesFromLocationName(geocodeRequest, (err, data) => { geolocation.getAddressesFromLocationName(geocodeRequest, (err, data) => {
if (err) { if (err) {
switch (err) { switch (err) {
...@@ -361,7 +362,7 @@ describe('geolocationTest_geo1', function () { ...@@ -361,7 +362,7 @@ describe('geolocationTest_geo1', function () {
console.info("QUERY_COUNTRY_CODE_ERROR: " + JSON.stringify(err)); console.info("QUERY_COUNTRY_CODE_ERROR: " + JSON.stringify(err));
break; break;
default: default:
console.info('[lbs_js] getAddressesFromLocationName callback err is : ' + JSON.stringify(err)); console.info('getAddressesFromLocationName callback err: ' + JSON.stringify(err));
} }
} else { } else {
console.info("[lbs_js] getAddressesFromLocationName08 callback data is: " + JSON.stringify(data)); console.info("[lbs_js] getAddressesFromLocationName08 callback data is: " + JSON.stringify(data));
...@@ -369,17 +370,22 @@ describe('geolocationTest_geo1', function () { ...@@ -369,17 +370,22 @@ describe('geolocationTest_geo1', function () {
} }
done(); done();
}); });
}catch(error){
console.info("[lbs_js] getAddressesFromLocationName message." + JSON.stringify(error.message));
expect(true).assertEqual((JSON.stringify(error.message)) != null);
}
done();
}) })
/** /**
* @tc.number SUB_HSS_LocationSystem_Geo_0009 * @tc.number SUB_HSS_LocationSystem_Geo_0900
* @tc.name TestgetAddressesFromLocation * @tc.name TestgetAddressesFromLocation
* @tc.desc Reverse address resolution test. * @tc.desc Reverse address resolution test.
* @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_0009', 0, async function (done) { it('SUB_HSS_LocationSystem_Geo_0900', 0, async function (done) {
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));
...@@ -392,14 +398,14 @@ describe('geolocationTest_geo1', function () { ...@@ -392,14 +398,14 @@ describe('geolocationTest_geo1', function () {
}) })
/** /**
* @tc.number SUB_HSS_LocationSystem_Geo_0010 * @tc.number SUB_HSS_LocationSystem_Geo_1000
* @tc.name TestgetAddressesFromLocation * @tc.name TestgetAddressesFromLocation
* @tc.desc Obtaining Multiple Locations Using the Reverse Address Resolution Function. * @tc.desc Obtaining Multiple Locations Using the Reverse Address Resolution Function.
* @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_0010', 0, async function (done) { it('SUB_HSS_LocationSystem_Geo_1000', 0, async function (done) {
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));
...@@ -413,14 +419,16 @@ describe('geolocationTest_geo1', function () { ...@@ -413,14 +419,16 @@ describe('geolocationTest_geo1', function () {
}) })
/** /**
* @tc.number SUB_HSS_LocationSystem_Geo_0011 * @tc.number SUB_HSS_LocationSystem_Geo_1100
* @tc.name TestgetAddressesFromLocation * @tc.name TestgetAddressesFromLocation
* @tc.desc Invalid parameter input test for the reverse address resolution function. * @tc.desc Invalid parameter input test for the reverse address resolution function.
* @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_0011', 0, async function (done) { it('SUB_HSS_LocationSystem_Geo_1100', 0, async function (done) {
try {
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));
...@@ -430,27 +438,35 @@ describe('geolocationTest_geo1', function () { ...@@ -430,27 +438,35 @@ describe('geolocationTest_geo1', function () {
console.info('[lbs_js] not support now'); console.info('[lbs_js] not support now');
expect(true).assertEqual(JSON.stringify(error) != null); expect(true).assertEqual(JSON.stringify(error) != null);
}); });
}catch(error){
console.info("[lbs_js] getAddressesFromLocationName message." + JSON.stringify(error.message));
expect(true).assertEqual((JSON.stringify(error.message)) != null);
}
let geocodeRequest1 = { "description": null, "maxItems": 1 }; let geocodeRequest1 = { "description": null, "maxItems": 1 };
try {
await geolocation.getAddressesFromLocationName(geocodeRequest1).then((result) => { await geolocation.getAddressesFromLocationName(geocodeRequest1).then((result) => {
console.info("[lbs_js] getAddressesFromLocation promise data is: " + JSON.stringify(result)); console.info("[lbs_js] getAddressesFromLocation callback data is: " + JSON.stringify(result));
expect(true).assertEqual((JSON.stringify(result)) != null); expect(result.length == 0).assertTrue();
}).catch((error) => { }).catch((error) => {
console.info("[lbs_js] getAddressesFromLocationName promise then error." + JSON.stringify(error)); console.info("[lbs_js] getAddressesFromLocationName promise then error." + JSON.stringify(error));
console.info('[lbs_js] not support now'); expect(true).assertEqual((JSON.stringify(error)) != null);
expect(true).assertEqual(JSON.stringify(error) != null);
}); });
}catch(error){
console.info("[lbs_js] getAddressesFromLocationName message." + JSON.stringify(error.message));
expect(true).assertEqual((JSON.stringify(error.message)) != null);
}
done(); done();
}) })
/** /**
* @tc.number SUB_HSS_LocationSystem_Geo_0012 * @tc.number SUB_HSS_LocationSystem_Geo_1200
* @tc.name TestgetAddressesFromLocation * @tc.name TestgetAddressesFromLocation
* @tc.desc Test the reverse address resolution function in the specified range.. * @tc.desc Test the reverse address resolution function in the specified range..
* @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_0012', 0, async function (done) { it('SUB_HSS_LocationSystem_Geo_1200', 0, async function (done) {
let geocodeRequest = { let geocodeRequest = {
"description": "上海金穗路1800号", "description": "上海金穗路1800号",
"maxItems": 1, "maxItems": 1,
...@@ -471,7 +487,7 @@ describe('geolocationTest_geo1', function () { ...@@ -471,7 +487,7 @@ describe('geolocationTest_geo1', function () {
}) })
/** /**
* @tc.number SUB_HSS_LocationSystem_Geo_0013 * @tc.number SUB_HSS_LocationSystem_Geo_1300
* @tc.name TestgetAddressesFromLocation * @tc.name TestgetAddressesFromLocation
* @tc.desc Invalid input parameter test for the reverse address resolution function in the specified range * @tc.desc Invalid input parameter test for the reverse address resolution function in the specified range
* -Invalid location name. * -Invalid location name.
...@@ -479,7 +495,7 @@ describe('geolocationTest_geo1', function () { ...@@ -479,7 +495,7 @@ describe('geolocationTest_geo1', function () {
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('SUB_HSS_LocationSystem_Geo_0013', 0, async function (done) { it('SUB_HSS_LocationSystem_Geo_1300', 0, async function (done) {
let geocodeRequest = { let geocodeRequest = {
"description": "", "description": "",
"maxItems": 1, "maxItems": 1,
...@@ -488,6 +504,7 @@ describe('geolocationTest_geo1', function () { ...@@ -488,6 +504,7 @@ describe('geolocationTest_geo1', function () {
"maxLatitude": 31.1537977881, "maxLatitude": 31.1537977881,
"maxLongitude": 121.8026736943 "maxLongitude": 121.8026736943
}; };
try {
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));
expect(result.length == 0).assertTrue(); expect(result.length == 0).assertTrue();
...@@ -495,6 +512,10 @@ describe('geolocationTest_geo1', function () { ...@@ -495,6 +512,10 @@ describe('geolocationTest_geo1', function () {
console.info("[lbs_js] getAddressesFromLocationName promise then error." + JSON.stringify(error)); console.info("[lbs_js] getAddressesFromLocationName promise then error." + JSON.stringify(error));
expect(true).assertEqual((JSON.stringify(error)) != null); expect(true).assertEqual((JSON.stringify(error)) != null);
}); });
}catch(error){
console.info("[lbs_js] getAddressesFromLocationName message." + JSON.stringify(error.message));
expect(true).assertEqual((JSON.stringify(error.message)) != null);
}
let geocodeRequest1 = { let geocodeRequest1 = {
"description": null, "description": null,
"maxItems": 1, "maxItems": 1,
...@@ -503,6 +524,7 @@ describe('geolocationTest_geo1', function () { ...@@ -503,6 +524,7 @@ describe('geolocationTest_geo1', function () {
"maxLatitude": 31.1537977881, "maxLatitude": 31.1537977881,
"maxLongitude": 121.8026736943 "maxLongitude": 121.8026736943
}; };
try {
await geolocation.getAddressesFromLocationName(geocodeRequest1).then((result) => { await geolocation.getAddressesFromLocationName(geocodeRequest1).then((result) => {
console.info("[lbs_js] getAddressesFromLocation callback data is: " + JSON.stringify(result)); console.info("[lbs_js] getAddressesFromLocation callback data is: " + JSON.stringify(result));
expect(result.length == 0).assertTrue(); expect(result.length == 0).assertTrue();
...@@ -510,11 +532,15 @@ describe('geolocationTest_geo1', function () { ...@@ -510,11 +532,15 @@ describe('geolocationTest_geo1', function () {
console.info("[lbs_js] getAddressesFromLocationName promise then error." + JSON.stringify(error)); console.info("[lbs_js] getAddressesFromLocationName promise then error." + JSON.stringify(error));
expect(true).assertEqual((JSON.stringify(error)) != null); expect(true).assertEqual((JSON.stringify(error)) != null);
}); });
}catch(error){
console.info("[lbs_js] getAddressesFromLocationName message." + JSON.stringify(error.message));
expect(true).assertEqual((JSON.stringify(error.message)) != null);
}
done(); done();
}) })
/** /**
* @tc.number SUB_HSS_LocationSystem_Geo_0014 * @tc.number SUB_HSS_LocationSystem_Geo_1400
* @tc.name TestgetAddressesFromLocation * @tc.name TestgetAddressesFromLocation
* @tc.desc Invalid input parameter test for the reverse address resolution function in the specified range * @tc.desc Invalid input parameter test for the reverse address resolution function in the specified range
* - the address is not in the range. * - the address is not in the range.
...@@ -522,7 +548,7 @@ describe('geolocationTest_geo1', function () { ...@@ -522,7 +548,7 @@ describe('geolocationTest_geo1', function () {
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('SUB_HSS_LocationSystem_Geo_0014', 0, async function (done) { it('SUB_HSS_LocationSystem_Geo_1400', 0, async function (done) {
let geocodeRequest = { let geocodeRequest = {
"description": "北京天安门", "description": "北京天安门",
"maxItems": 1, "maxItems": 1,
...@@ -543,7 +569,7 @@ describe('geolocationTest_geo1', function () { ...@@ -543,7 +569,7 @@ describe('geolocationTest_geo1', function () {
}) })
/** /**
* @tc.number SUB_HSS_LocationSystem_Geo_0015 * @tc.number SUB_HSS_LocationSystem_Geo_1500
* @tc.name TestgetAddressesFromLocation * @tc.name TestgetAddressesFromLocation
* @tc.desc Invalid longitude and latitude entered for the reverse address resolution * @tc.desc Invalid longitude and latitude entered for the reverse address resolution
* function in the specified range. The longitude and latitude range boundary is inverted.. * function in the specified range. The longitude and latitude range boundary is inverted..
...@@ -551,7 +577,7 @@ describe('geolocationTest_geo1', function () { ...@@ -551,7 +577,7 @@ describe('geolocationTest_geo1', function () {
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('SUB_HSS_LocationSystem_Geo_0015', 0, async function (done) { it('SUB_HSS_LocationSystem_Geo_1500', 0, async function (done) {
let geocodeRequest = { let geocodeRequest = {
"description": "北京天安门", "description": "北京天安门",
"maxItems": 1, "maxItems": 1,
...@@ -572,14 +598,14 @@ describe('geolocationTest_geo1', function () { ...@@ -572,14 +598,14 @@ describe('geolocationTest_geo1', function () {
}) })
/** /**
* @tc.number SUB_HSS_LocationSystem_Geo_0016 * @tc.number SUB_HSS_LocationSystem_Geo_1600
* @tc.name TestgetAddressesFromLocation * @tc.name TestgetAddressesFromLocation
* @tc.desc Input parameter boundary test for the reverse address resolution function in a specified range. * @tc.desc Input parameter boundary test for the reverse address resolution function in a specified range.
* @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_0016', 0, async function (done) { it('SUB_HSS_LocationSystem_Geo_1600', 0, async function (done) {
let geocodeRequest1 = { let geocodeRequest1 = {
"description": "上海金穗路1800号", "description": "上海金穗路1800号",
"maxItems": 1, "maxItems": 1,
...@@ -588,6 +614,7 @@ describe('geolocationTest_geo1', function () { ...@@ -588,6 +614,7 @@ describe('geolocationTest_geo1', function () {
"maxLatitude": 31.1537977881, "maxLatitude": 31.1537977881,
"maxLongitude": 121.8026736943 "maxLongitude": 121.8026736943
}; };
try{
await geolocation.getAddressesFromLocationName(geocodeRequest1).then((result) => { await geolocation.getAddressesFromLocationName(geocodeRequest1).then((result) => {
console.info("[lbs_js]getAddressesFromLocation promise1: " + JSON.stringify(result)); console.info("[lbs_js]getAddressesFromLocation promise1: " + JSON.stringify(result));
expect(true).assertEqual((JSON.stringify(result)) != null); expect(true).assertEqual((JSON.stringify(result)) != null);
...@@ -596,6 +623,10 @@ describe('geolocationTest_geo1', function () { ...@@ -596,6 +623,10 @@ describe('geolocationTest_geo1', function () {
console.info('[lbs_js] not support now'); console.info('[lbs_js] not support now');
expect(true).assertEqual(JSON.stringify(error) != null); expect(true).assertEqual(JSON.stringify(error) != null);
}); });
}catch(error){
console.info("[lbs_js] getAddressesFromLocationName message." + JSON.stringify(error.message));
expect(true).assertEqual((JSON.stringify(error.message)) != null);
}
let geocodeRequest2 = { let geocodeRequest2 = {
"description": "上海金穗路1800号", "description": "上海金穗路1800号",
"maxItems": 1, "maxItems": 1,
...@@ -604,6 +635,7 @@ describe('geolocationTest_geo1', function () { ...@@ -604,6 +635,7 @@ describe('geolocationTest_geo1', function () {
"maxLatitude": 31.1537977881, "maxLatitude": 31.1537977881,
"maxLongitude": 121.8026736943 "maxLongitude": 121.8026736943
}; };
try{
await geolocation.getAddressesFromLocationName(geocodeRequest2).then((result) => { await geolocation.getAddressesFromLocationName(geocodeRequest2).then((result) => {
console.info("[lbs_js]getAddressesFromLocation promise2: " + JSON.stringify(result)); console.info("[lbs_js]getAddressesFromLocation promise2: " + JSON.stringify(result));
expect(true).assertEqual((JSON.stringify(result)) != null); expect(true).assertEqual((JSON.stringify(result)) != null);
...@@ -612,6 +644,10 @@ describe('geolocationTest_geo1', function () { ...@@ -612,6 +644,10 @@ describe('geolocationTest_geo1', function () {
console.info('[lbs_js] not support now'); console.info('[lbs_js] not support now');
expect(true).assertEqual(JSON.stringify(error) != null); expect(true).assertEqual(JSON.stringify(error) != null);
}); });
}catch(error){
console.info("[lbs_js] getAddressesFromLocationName message." + JSON.stringify(error.message));
expect(true).assertEqual((JSON.stringify(error.message)) != null);
}
let geocodeRequest3 = { let geocodeRequest3 = {
"description": "上海金穗路1800号", "description": "上海金穗路1800号",
"maxItems": 1, "maxItems": 1,
...@@ -620,6 +656,7 @@ describe('geolocationTest_geo1', function () { ...@@ -620,6 +656,7 @@ describe('geolocationTest_geo1', function () {
"maxLatitude": 31.1537977881, "maxLatitude": 31.1537977881,
"maxLongitude": 121.8026736943 "maxLongitude": 121.8026736943
}; };
try{
await geolocation.getAddressesFromLocationName(geocodeRequest3).then((result) => { await geolocation.getAddressesFromLocationName(geocodeRequest3).then((result) => {
console.info("[lbs_js]getAddressesFromLocation promise3: " + JSON.stringify(result)); console.info("[lbs_js]getAddressesFromLocation promise3: " + JSON.stringify(result));
expect(true).assertEqual((JSON.stringify(result)) == null); expect(true).assertEqual((JSON.stringify(result)) == null);
...@@ -627,6 +664,10 @@ describe('geolocationTest_geo1', function () { ...@@ -627,6 +664,10 @@ describe('geolocationTest_geo1', function () {
console.info("[lbs_js] getAddressesFromLocationName promise then error." + JSON.stringify(error)); console.info("[lbs_js] getAddressesFromLocationName promise then error." + JSON.stringify(error));
expect(true).assertEqual((JSON.stringify(error)) != null); expect(true).assertEqual((JSON.stringify(error)) != null);
}); });
}catch(error){
console.info("[lbs_js] getAddressesFromLocationName message." + JSON.stringify(error.message));
expect(true).assertEqual((JSON.stringify(error.message)) != null);
}
let geocodeRequest4 = { let geocodeRequest4 = {
"description": "上海金穗路1800号", "description": "上海金穗路1800号",
"maxItems": 1, "maxItems": 1,
...@@ -635,6 +676,7 @@ describe('geolocationTest_geo1', function () { ...@@ -635,6 +676,7 @@ describe('geolocationTest_geo1', function () {
"maxLatitude": 31.1537977881, "maxLatitude": 31.1537977881,
"maxLongitude": 121.8026736943 "maxLongitude": 121.8026736943
}; };
try{
await geolocation.getAddressesFromLocationName(geocodeRequest4).then((result) => { await geolocation.getAddressesFromLocationName(geocodeRequest4).then((result) => {
console.info("[lbs_js]getAddressesFromLocation promise4: " + JSON.stringify(result)); console.info("[lbs_js]getAddressesFromLocation promise4: " + JSON.stringify(result));
console.info('[lbs_js] not support now'); console.info('[lbs_js] not support now');
...@@ -643,6 +685,10 @@ describe('geolocationTest_geo1', function () { ...@@ -643,6 +685,10 @@ describe('geolocationTest_geo1', function () {
console.info("[lbs_js] getAddressesFromLocationName promise then error." + JSON.stringify(error)); console.info("[lbs_js] getAddressesFromLocationName promise then error." + JSON.stringify(error));
expect(true).assertEqual((JSON.stringify(error)) != null); expect(true).assertEqual((JSON.stringify(error)) != null);
}); });
}catch(error){
console.info("[lbs_js] getAddressesFromLocationName message." + JSON.stringify(error.message));
expect(true).assertEqual((JSON.stringify(error.message)) != null);
}
let geocodeRequest5 = { let geocodeRequest5 = {
"description": "上海金穗路1800号", "description": "上海金穗路1800号",
"maxItems": 1, "maxItems": 1,
...@@ -651,6 +697,7 @@ describe('geolocationTest_geo1', function () { ...@@ -651,6 +697,7 @@ describe('geolocationTest_geo1', function () {
"maxLatitude": -90, "maxLatitude": -90,
"maxLongitude": 121.8026736943 "maxLongitude": 121.8026736943
}; };
try {
await geolocation.getAddressesFromLocationName(geocodeRequest5).then((result) => { await geolocation.getAddressesFromLocationName(geocodeRequest5).then((result) => {
console.info("[lbs_js]getAddressesFromLocation promise5: " + JSON.stringify(result)); console.info("[lbs_js]getAddressesFromLocation promise5: " + JSON.stringify(result));
expect(true).assertEqual((JSON.stringify(result)) != null); expect(true).assertEqual((JSON.stringify(result)) != null);
...@@ -659,6 +706,10 @@ describe('geolocationTest_geo1', function () { ...@@ -659,6 +706,10 @@ describe('geolocationTest_geo1', function () {
console.info('[lbs_js] not support now'); console.info('[lbs_js] not support now');
expect(true).assertEqual(JSON.stringify(error) != null); expect(true).assertEqual(JSON.stringify(error) != null);
}); });
}catch(error){
console.info("[lbs_js] getAddressesFromLocationName message." + JSON.stringify(error.message));
expect(true).assertEqual((JSON.stringify(error.message)) != null);
}
let geocodeRequest6 = { let geocodeRequest6 = {
"description": "上海金穗路1800号", "description": "上海金穗路1800号",
"maxItems": 1, "maxItems": 1,
...@@ -667,6 +718,7 @@ describe('geolocationTest_geo1', function () { ...@@ -667,6 +718,7 @@ describe('geolocationTest_geo1', function () {
"maxLatitude": 90, "maxLatitude": 90,
"maxLongitude": 121.8026736943 "maxLongitude": 121.8026736943
}; };
try{
await geolocation.getAddressesFromLocationName(geocodeRequest6).then((result) => { await geolocation.getAddressesFromLocationName(geocodeRequest6).then((result) => {
console.info("[lbs_js]getAddressesFromLocation promise6: " + JSON.stringify(result)); console.info("[lbs_js]getAddressesFromLocation promise6: " + JSON.stringify(result));
expect(true).assertEqual((JSON.stringify(result)) != null); expect(true).assertEqual((JSON.stringify(result)) != null);
...@@ -675,6 +727,10 @@ describe('geolocationTest_geo1', function () { ...@@ -675,6 +727,10 @@ describe('geolocationTest_geo1', function () {
console.info('[lbs_js] not support now'); console.info('[lbs_js] not support now');
expect(true).assertEqual(JSON.stringify(error) != null); expect(true).assertEqual(JSON.stringify(error) != null);
}); });
}catch(error){
console.info("[lbs_js] getAddressesFromLocationName message." + JSON.stringify(error.message));
expect(true).assertEqual((JSON.stringify(error.message)) != null);
}
let geocodeRequest7 = { let geocodeRequest7 = {
"description": "上海金穗路1800号", "description": "上海金穗路1800号",
"maxItems": 1, "maxItems": 1,
...@@ -683,6 +739,7 @@ describe('geolocationTest_geo1', function () { ...@@ -683,6 +739,7 @@ describe('geolocationTest_geo1', function () {
"maxLatitude": -90.1, "maxLatitude": -90.1,
"maxLongitude": 121.8026736943 "maxLongitude": 121.8026736943
}; };
try{
await geolocation.getAddressesFromLocationName(geocodeRequest7).then((result) => { await geolocation.getAddressesFromLocationName(geocodeRequest7).then((result) => {
console.info("[lbs_js]getAddressesFromLocation promise7: " + JSON.stringify(result)); console.info("[lbs_js]getAddressesFromLocation promise7: " + JSON.stringify(result));
expect(true).assertEqual((JSON.stringify(result)) == null); expect(true).assertEqual((JSON.stringify(result)) == null);
...@@ -690,6 +747,10 @@ describe('geolocationTest_geo1', function () { ...@@ -690,6 +747,10 @@ describe('geolocationTest_geo1', function () {
console.info("[lbs_js] getAddressesFromLocationName promise then error." + JSON.stringify(error)); console.info("[lbs_js] getAddressesFromLocationName promise then error." + JSON.stringify(error));
expect(true).assertEqual((JSON.stringify(error)) != null); expect(true).assertEqual((JSON.stringify(error)) != null);
}); });
}catch(error){
console.info("[lbs_js] getAddressesFromLocationName message." + JSON.stringify(error.message));
expect(true).assertEqual((JSON.stringify(error.message)) != null);
}
let geocodeRequest8 = { let geocodeRequest8 = {
"description": "上海金穗路1800号", "description": "上海金穗路1800号",
"maxItems": 1, "maxItems": 1,
...@@ -698,6 +759,7 @@ describe('geolocationTest_geo1', function () { ...@@ -698,6 +759,7 @@ describe('geolocationTest_geo1', function () {
"maxLatitude": 90.1, "maxLatitude": 90.1,
"maxLongitude": 121.8026736943 "maxLongitude": 121.8026736943
}; };
try{
await geolocation.getAddressesFromLocationName(geocodeRequest8).then((result) => { await geolocation.getAddressesFromLocationName(geocodeRequest8).then((result) => {
console.info("[lbs_js]getAddressesFromLocation promise8: " + JSON.stringify(result)); console.info("[lbs_js]getAddressesFromLocation promise8: " + JSON.stringify(result));
expect(true).assertEqual((JSON.stringify(result)) == null); expect(true).assertEqual((JSON.stringify(result)) == null);
...@@ -705,18 +767,22 @@ describe('geolocationTest_geo1', function () { ...@@ -705,18 +767,22 @@ describe('geolocationTest_geo1', function () {
console.info("[lbs_js] getAddressesFromLocationName promise then error." + JSON.stringify(error)); console.info("[lbs_js] getAddressesFromLocationName promise then error." + JSON.stringify(error));
expect(true).assertEqual((JSON.stringify(error)) != null); expect(true).assertEqual((JSON.stringify(error)) != null);
}); });
}catch(error){
console.info("[lbs_js] getAddressesFromLocationName message." + JSON.stringify(error.message));
expect(true).assertEqual((JSON.stringify(error.message)) != null);
}
done() done()
}) })
/** /**
* @tc.number SUB_HSS_LocationSystem_Geo_0017 * @tc.number SUB_HSS_LocationSystem_Geo_1700
* @tc.name TestgetAddressesFromLocation * @tc.name TestgetAddressesFromLocation
* @tc.desc Longitude input parameter boundary test for the reverse address resolution function in a specified range * @tc.desc Longitude input parameter boundary test for the reverse address resolution function in a specified range
* @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_0017', 0, async function (done) { it('SUB_HSS_LocationSystem_Geo_1700', 0, async function (done) {
let geocodeRequest1 = { let geocodeRequest1 = {
"description": "北京天安门", "description": "北京天安门",
"maxItems": 1, "maxItems": 1,
...@@ -725,6 +791,7 @@ describe('geolocationTest_geo1', function () { ...@@ -725,6 +791,7 @@ describe('geolocationTest_geo1', function () {
"maxLatitude": 39.95, "maxLatitude": 39.95,
"maxLongitude": 116.45 "maxLongitude": 116.45
}; };
try{
await geolocation.getAddressesFromLocationName(geocodeRequest1).then((result) => { await geolocation.getAddressesFromLocationName(geocodeRequest1).then((result) => {
console.info("[lbs_js]getAddressesFromLocation promise1: " + JSON.stringify(result)); console.info("[lbs_js]getAddressesFromLocation promise1: " + JSON.stringify(result));
expect(true).assertEqual((JSON.stringify(result)) != null); expect(true).assertEqual((JSON.stringify(result)) != null);
...@@ -733,6 +800,10 @@ describe('geolocationTest_geo1', function () { ...@@ -733,6 +800,10 @@ describe('geolocationTest_geo1', function () {
console.info('[lbs_js] not support now'); console.info('[lbs_js] not support now');
expect(true).assertEqual(JSON.stringify(error) != null); expect(true).assertEqual(JSON.stringify(error) != null);
}); });
}catch(error){
console.info("[lbs_js] getAddressesFromLocationName message." + JSON.stringify(error.message));
expect(true).assertEqual((JSON.stringify(error.message)) != null);
}
let geocodeRequest2 = { let geocodeRequest2 = {
"description": "北京天安门", "description": "北京天安门",
"maxItems": 1, "maxItems": 1,
...@@ -741,6 +812,7 @@ describe('geolocationTest_geo1', function () { ...@@ -741,6 +812,7 @@ describe('geolocationTest_geo1', function () {
"maxLatitude": 39.95, "maxLatitude": 39.95,
"maxLongitude": 116.45 "maxLongitude": 116.45
}; };
try{
await geolocation.getAddressesFromLocationName(geocodeRequest2).then((result) => { await geolocation.getAddressesFromLocationName(geocodeRequest2).then((result) => {
console.info("[lbs_js]getAddressesFromLocation promise2: " + JSON.stringify(result)); console.info("[lbs_js]getAddressesFromLocation promise2: " + JSON.stringify(result));
expect(true).assertEqual((JSON.stringify(result)) != null); expect(true).assertEqual((JSON.stringify(result)) != null);
...@@ -748,6 +820,10 @@ describe('geolocationTest_geo1', function () { ...@@ -748,6 +820,10 @@ describe('geolocationTest_geo1', function () {
console.info("[lbs_js] getAddressesFromLocationName promise then error." + JSON.stringify(error)); console.info("[lbs_js] getAddressesFromLocationName promise then error." + JSON.stringify(error));
expect(error.length != 0).assertTrue(); expect(error.length != 0).assertTrue();
}); });
}catch(error){
console.info("[lbs_js] getAddressesFromLocationName message." + JSON.stringify(error.message));
expect(true).assertEqual((JSON.stringify(error.message)) != null);
}
let geocodeRequest3 = { let geocodeRequest3 = {
"description": "北京天安门", "description": "北京天安门",
"maxItems": 1, "maxItems": 1,
...@@ -756,6 +832,7 @@ describe('geolocationTest_geo1', function () { ...@@ -756,6 +832,7 @@ describe('geolocationTest_geo1', function () {
"maxLatitude": 39.95, "maxLatitude": 39.95,
"maxLongitude": 116.45 "maxLongitude": 116.45
}; };
try{
await geolocation.getAddressesFromLocationName(geocodeRequest3).then((result) => { await geolocation.getAddressesFromLocationName(geocodeRequest3).then((result) => {
console.info("[lbs_js]getAddressesFromLocation promise3: " + JSON.stringify(result)); console.info("[lbs_js]getAddressesFromLocation promise3: " + JSON.stringify(result));
expect(true).assertEqual((JSON.stringify(result)) != null); expect(true).assertEqual((JSON.stringify(result)) != null);
...@@ -763,6 +840,10 @@ describe('geolocationTest_geo1', function () { ...@@ -763,6 +840,10 @@ describe('geolocationTest_geo1', function () {
console.info("[lbs_js] getAddressesFromLocationName promise then error." + JSON.stringify(error)); console.info("[lbs_js] getAddressesFromLocationName promise then error." + JSON.stringify(error));
expect(error.length != 0).assertTrue(); expect(error.length != 0).assertTrue();
}); });
}catch(error){
console.info("[lbs_js] getAddressesFromLocationName message." + JSON.stringify(error.message));
expect(true).assertEqual((JSON.stringify(error.message)) != null);
}
let geocodeRequest4 = { let geocodeRequest4 = {
"description": "北京天安门", "description": "北京天安门",
"maxItems": 1, "maxItems": 1,
...@@ -771,6 +852,7 @@ describe('geolocationTest_geo1', function () { ...@@ -771,6 +852,7 @@ describe('geolocationTest_geo1', function () {
"maxLatitude": 39.95, "maxLatitude": 39.95,
"maxLongitude": 116.45 "maxLongitude": 116.45
}; };
try{
await geolocation.getAddressesFromLocationName(geocodeRequest4).then((result) => { await geolocation.getAddressesFromLocationName(geocodeRequest4).then((result) => {
console.info("[lbs_js]getAddressesFromLocation promise4: " + JSON.stringify(result)); console.info("[lbs_js]getAddressesFromLocation promise4: " + JSON.stringify(result));
expect(true).assertEqual((JSON.stringify(result)) != null); expect(true).assertEqual((JSON.stringify(result)) != null);
...@@ -778,6 +860,10 @@ describe('geolocationTest_geo1', function () { ...@@ -778,6 +860,10 @@ describe('geolocationTest_geo1', function () {
console.info("[lbs_js] getAddressesFromLocationName promise then error." + JSON.stringify(error)); console.info("[lbs_js] getAddressesFromLocationName promise then error." + JSON.stringify(error));
expect(error.length != 0).assertTrue(); expect(error.length != 0).assertTrue();
}); });
}catch(error){
console.info("[lbs_js] getAddressesFromLocationName message." + JSON.stringify(error.message));
expect(true).assertEqual((JSON.stringify(error.message)) != null);
}
let geocodeRequest5 = { let geocodeRequest5 = {
"description": "北京天安门", "description": "北京天安门",
"maxItems": 1, "maxItems": 1,
...@@ -786,6 +872,7 @@ describe('geolocationTest_geo1', function () { ...@@ -786,6 +872,7 @@ describe('geolocationTest_geo1', function () {
"maxLatitude": 39.95, "maxLatitude": 39.95,
"maxLongitude": -180 "maxLongitude": -180
}; };
try{
await geolocation.getAddressesFromLocationName(geocodeRequest5).then((result) => { await geolocation.getAddressesFromLocationName(geocodeRequest5).then((result) => {
console.info("[lbs_js]getAddressesFromLocation promise5: " + JSON.stringify(result)); console.info("[lbs_js]getAddressesFromLocation promise5: " + JSON.stringify(result));
expect(true).assertEqual((JSON.stringify(result)) != null); expect(true).assertEqual((JSON.stringify(result)) != null);
...@@ -793,6 +880,10 @@ describe('geolocationTest_geo1', function () { ...@@ -793,6 +880,10 @@ describe('geolocationTest_geo1', function () {
console.info("[lbs_js] getAddressesFromLocationName promise then error." + JSON.stringify(error)); console.info("[lbs_js] getAddressesFromLocationName promise then error." + JSON.stringify(error));
expect(error.length != 0).assertTrue(); expect(error.length != 0).assertTrue();
}); });
}catch(error){
console.info("[lbs_js] getAddressesFromLocationName message." + JSON.stringify(error.message));
expect(true).assertEqual((JSON.stringify(error.message)) != null);
}
let geocodeRequest6 = { let geocodeRequest6 = {
"description": "北京天安门", "description": "北京天安门",
"maxItems": 1, "maxItems": 1,
...@@ -801,6 +892,7 @@ describe('geolocationTest_geo1', function () { ...@@ -801,6 +892,7 @@ describe('geolocationTest_geo1', function () {
"maxLatitude": 39.95, "maxLatitude": 39.95,
"maxLongitude": 180 "maxLongitude": 180
}; };
try{
await geolocation.getAddressesFromLocationName(geocodeRequest6).then((result) => { await geolocation.getAddressesFromLocationName(geocodeRequest6).then((result) => {
console.info("[lbs_js]getAddressesFromLocation promise6: " + JSON.stringify(result)); console.info("[lbs_js]getAddressesFromLocation promise6: " + JSON.stringify(result));
expect(true).assertEqual((JSON.stringify(result)) != null); expect(true).assertEqual((JSON.stringify(result)) != null);
...@@ -808,6 +900,10 @@ describe('geolocationTest_geo1', function () { ...@@ -808,6 +900,10 @@ describe('geolocationTest_geo1', function () {
console.info("[lbs_js] getAddressesFromLocationName promise then error." + JSON.stringify(error)); console.info("[lbs_js] getAddressesFromLocationName promise then error." + JSON.stringify(error));
expect(error.length != 0).assertTrue(); expect(error.length != 0).assertTrue();
}); });
}catch(error){
console.info("[lbs_js] getAddressesFromLocationName message." + JSON.stringify(error.message));
expect(true).assertEqual((JSON.stringify(error.message)) != null);
}
let geocodeRequest7 = { let geocodeRequest7 = {
"description": "北京天安门", "description": "北京天安门",
"maxItems": 1, "maxItems": 1,
...@@ -816,6 +912,7 @@ describe('geolocationTest_geo1', function () { ...@@ -816,6 +912,7 @@ describe('geolocationTest_geo1', function () {
"maxLatitude": 39.95, "maxLatitude": 39.95,
"maxLongitude": -180.1 "maxLongitude": -180.1
}; };
try{
await geolocation.getAddressesFromLocationName(geocodeRequest7).then((result) => { await geolocation.getAddressesFromLocationName(geocodeRequest7).then((result) => {
console.info("[lbs_js]getAddressesFromLocation promise7: " + JSON.stringify(result)); console.info("[lbs_js]getAddressesFromLocation promise7: " + JSON.stringify(result));
expect(true).assertEqual((JSON.stringify(result)) != null); expect(true).assertEqual((JSON.stringify(result)) != null);
...@@ -823,6 +920,10 @@ describe('geolocationTest_geo1', function () { ...@@ -823,6 +920,10 @@ describe('geolocationTest_geo1', function () {
console.info("[lbs_js] getAddressesFromLocationName promise then error." + JSON.stringify(error)); console.info("[lbs_js] getAddressesFromLocationName promise then error." + JSON.stringify(error));
expect(error.length != 0).assertTrue(); expect(error.length != 0).assertTrue();
}); });
}catch(error){
console.info("[lbs_js] getAddressesFromLocationName message." + JSON.stringify(error.message));
expect(true).assertEqual((JSON.stringify(error.message)) != null);
}
let geocodeRequest8 = { let geocodeRequest8 = {
"description": "北京天安门", "description": "北京天安门",
"maxItems": 1, "maxItems": 1,
...@@ -831,6 +932,7 @@ describe('geolocationTest_geo1', function () { ...@@ -831,6 +932,7 @@ describe('geolocationTest_geo1', function () {
"maxLatitude": 39.95, "maxLatitude": 39.95,
"maxLongitude": 180.1 "maxLongitude": 180.1
}; };
try{
await geolocation.getAddressesFromLocationName(geocodeRequest8).then((result) => { await geolocation.getAddressesFromLocationName(geocodeRequest8).then((result) => {
console.info("[lbs_js]getAddressesFromLocation promise8: " + JSON.stringify(result)); console.info("[lbs_js]getAddressesFromLocation promise8: " + JSON.stringify(result));
expect(true).assertEqual((JSON.stringify(result)) != null); expect(true).assertEqual((JSON.stringify(result)) != null);
...@@ -838,7 +940,12 @@ describe('geolocationTest_geo1', function () { ...@@ -838,7 +940,12 @@ describe('geolocationTest_geo1', function () {
console.info("[lbs_js] getAddressesFromLocationName promise then error." + JSON.stringify(error)); console.info("[lbs_js] getAddressesFromLocationName promise then error." + JSON.stringify(error));
expect(error.length != 0).assertTrue(); expect(error.length != 0).assertTrue();
}); });
}catch(error){
console.info("[lbs_js] getAddressesFromLocationName message." + JSON.stringify(error.message));
expect(true).assertEqual((JSON.stringify(error.message)) != null);
}
done(); done();
}) })
}) })
...@@ -90,13 +90,13 @@ describe('geolocationTest_4', function () { ...@@ -90,13 +90,13 @@ describe('geolocationTest_4', function () {
}) })
/** /**
* @tc.number SUB_HSS_LocationSystem_CountryCode_0001 * @tc.number SUB_HSS_LocationSystem_CountryCode_0100
* @tc.name Test getCountryCode * @tc.name Test getCountryCode
* @tc.desc Obtaining Country Code Information * @tc.desc Obtaining Country Code Information
* @tc.type Function * @tc.type Function
* @tc.level since 9 * @tc.level since 9
*/ */
it('SUB_HSS_LocationSystem_CountryCode_0001', 0, async function (done) { it('SUB_HSS_LocationSystem_CountryCode_0100', 0, async function (done) {
await geolocation.getCountryCode().then((result) => { await geolocation.getCountryCode().then((result) => {
console.info("[lbs_js] getCountryCode promise result: " + JSON.stringify(result)); console.info("[lbs_js] getCountryCode promise result: " + JSON.stringify(result));
console.info("[lbs_js] country :" + result.country); console.info("[lbs_js] country :" + result.country);
...@@ -113,13 +113,13 @@ describe('geolocationTest_4', function () { ...@@ -113,13 +113,13 @@ describe('geolocationTest_4', function () {
}) })
/** /**
* @tc.number SUB_HSS_LocationSystem_CountryCode_0002 * @tc.number SUB_HSS_LocationSystem_CountryCode_0200
* @tc.name Test getCountryCode * @tc.name Test getCountryCode
* @tc.desc Obtaining Country Code Information * @tc.desc Obtaining Country Code Information
* @tc.type Function * @tc.type Function
* @tc.level since 9 * @tc.level since 9
*/ */
it('SUB_HSS_LocationSystem_CountryCode_0002', 0, async function (done) { it('SUB_HSS_LocationSystem_CountryCode_0200', 0, async function (done) {
function getCountryCodeCallback() { function getCountryCodeCallback() {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
geolocation.getCountryCode((err) => { geolocation.getCountryCode((err) => {
...@@ -137,13 +137,13 @@ describe('geolocationTest_4', function () { ...@@ -137,13 +137,13 @@ describe('geolocationTest_4', function () {
}) })
/** /**
* @tc.number SUB_HSS_LocationSystem_CountryCode_0003 * @tc.number SUB_HSS_LocationSystem_CountryCode_0300
* @tc.name getCountryCode_on_off * @tc.name getCountryCode_on_off
* @tc.desc The interception country code is changed. * @tc.desc The interception country code is changed.
* @tc.type Function * @tc.type Function
* @tc.level since 9 * @tc.level since 9
*/ */
it('SUB_HSS_LocationSystem_CountryCode_0003', 0, async function (done) { it('SUB_HSS_LocationSystem_CountryCode_0300', 0, async function (done) {
console.info("[lbs_js]countryCodeChange"); console.info("[lbs_js]countryCodeChange");
geolocation.on('countryCodeChange', function (data) { geolocation.on('countryCodeChange', function (data) {
console.info('[lbs_js] countryCodeChange' +JSON.stringify(data) ); console.info('[lbs_js] countryCodeChange' +JSON.stringify(data) );
......
...@@ -111,14 +111,14 @@ describe('geolocationTest_geo3', function () { ...@@ -111,14 +111,14 @@ describe('geolocationTest_geo3', function () {
}) })
/** /**
* @tc.number LocSwitch_0003 * @tc.number SUB_HSS_LocationSystem_LocSwitch_0300
* @tc.name SUB_HSS_LocationSystem_LocSwitch_0003 * @tc.name Test requestrequestEnableLocation api
* @tc.desc Test requestrequestEnableLocation api . * @tc.desc Enabling the Location Service Function for a Third-Party App - Callback
* @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_0300', 0, async function (done) {
geolocation.isLocationEnabled(async (err, data) => { geolocation.isLocationEnabled(async (err, data) => {
if (err) { if (err) {
console.info('[lbs_js] getLocationSwitchState callback err is : ' + JSON.stringify(err)); console.info('[lbs_js] getLocationSwitchState callback err is : ' + JSON.stringify(err));
...@@ -132,14 +132,14 @@ describe('geolocationTest_geo3', function () { ...@@ -132,14 +132,14 @@ describe('geolocationTest_geo3', function () {
}); });
/** /**
* @tc.number LocSwitch_0004 * @tc.number LocSwitch_0400
* @tc.name SUB_HSS_LocationSystem_LocSwitch_0004 * @tc.name Test requestrequestEnableLocation api.
* @tc.desc Test requestrequestEnableLocation api . * @tc.desc Enabling the Location Service Function for a Third-Party Application -Promise Mode
* @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_0400', 0, async function (done) {
await geolocation.isLocationEnabled().then((result1) => { await geolocation.isLocationEnabled().then((result1) => {
console.info('[lbs_js] getLocationSwitchStateLocSwitch_0004 result: ' + JSON.stringify(result1)); console.info('[lbs_js] getLocationSwitchStateLocSwitch_0004 result: ' + JSON.stringify(result1));
expect(result1).assertTrue(); expect(result1).assertTrue();
...@@ -150,14 +150,14 @@ describe('geolocationTest_geo3', function () { ...@@ -150,14 +150,14 @@ describe('geolocationTest_geo3', function () {
}); });
/** /**
* @tc.number LocSwitch_0005 * @tc.number SUB_HSS_LocationSystem_LocSwitch_0500
* @tc.name SUB_HSS_LocationSystem_LocSwitch_0005 * @tc.name Test locationServiceState api .
* @tc.desc Test locationServiceState api . * @tc.desc Subscribe to the location service status change.
* @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_0005', 0, async function (done) { it('SUB_HSS_LocationSystem_LocSwitch_0500', 0, async function (done) {
console.log('just for overwriting,locationServiceState test need system api '); console.log('just for overwriting,locationServiceState test need system api ');
var locationServiceState = (state) => { var locationServiceState = (state) => {
console.log('locationServiceState: state: ' + JSON.stringify(state)); console.log('locationServiceState: state: ' + JSON.stringify(state));
...@@ -168,14 +168,14 @@ describe('geolocationTest_geo3', function () { ...@@ -168,14 +168,14 @@ describe('geolocationTest_geo3', function () {
}) })
/** /**
* @tc.number SUB_HSS_LocationSystem_SingleLoc_0001 * @tc.number SUB_HSS_LocationSystem_SingleLoc_0100
* @tc.name Test getCurrentLocation * @tc.name Test getCurrentLocation
* @tc.desc Initiate a single location request in a specified scenario and set the navigation scenario.. * @tc.desc Initiate a single location request in a specified scenario and set the navigation scenario..
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('SUB_HSS_LocationSystem_SingleLoc_0001', 0, async function (done) { it('SUB_HSS_LocationSystem_SingleLoc_0100', 0, async function (done) {
let currentLocationRequest = { "priority": 0x200, "scenario": 0x301, "timeoutMs": 1000, "maxAccuracy": 0 }; let currentLocationRequest = { "priority": 0x200, "scenario": 0x301, "timeoutMs": 1000, "maxAccuracy": 0 };
function getCurrentLocationCallback() { function getCurrentLocationCallback() {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
...@@ -193,24 +193,25 @@ describe('geolocationTest_geo3', function () { ...@@ -193,24 +193,25 @@ describe('geolocationTest_geo3', function () {
}) })
} }
console.info('getCurrentLocationCallback start'); console.info('getCurrentLocationCallback start');
await getCurrentLocationCallback().then(() => { await geolocation.getCurrentLocation(currentLocationRequest).then((result) => {
console.info('getCurrentLocationCallback resolve'); console.info("getCurrentLocation callback_0003, result: " + JSON.stringify(result));
}, () => { expect(true).assertEqual(result != null);
console.info('getCurrentLocationCallback reject'); }).catch(error => {
}); console.info('getCurrentLocation callback_0003:' + JSON.stringify(error));
console.info('getCurrentLocationCallback end'); expect(true).assertEqual(JSON.stringify(error) != null);
})
done(); done();
}) })
/** /**
* @tc.number SUB_HSS_LocationSystem_SingleLoc_0002 * @tc.number SUB_HSS_LocationSystem_SingleLoc_0200
* @tc.name Test getCurrentLocation * @tc.name Test getCurrentLocation
* @tc.desc Initiate a single location request in a specified scenario and set the navigation scenario.. * @tc.desc Initiate a single location request in a specified scenario and set the navigation scenario..
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('SUB_HSS_LocationSystem_SingleLoc_0002', 0, async function (done) { it('SUB_HSS_LocationSystem_SingleLoc_0200', 0, async function (done) {
let currentLocationRequest = { "priority": 0x203, "scenario": 0x301, "timeoutMs": 1000, "maxAccuracy": 0 }; let currentLocationRequest = { "priority": 0x203, "scenario": 0x301, "timeoutMs": 1000, "maxAccuracy": 0 };
await geolocation.getCurrentLocation(currentLocationRequest).then((result) => { await geolocation.getCurrentLocation(currentLocationRequest).then((result) => {
console.info('[lbs_js] getCurrentLocation promise result ' + JSON.stringify(result)); console.info('[lbs_js] getCurrentLocation promise result ' + JSON.stringify(result));
...@@ -223,14 +224,14 @@ describe('geolocationTest_geo3', function () { ...@@ -223,14 +224,14 @@ describe('geolocationTest_geo3', function () {
}) })
/** /**
* @tc.number SUB_HSS_LocationSystem_SingleLoc_0003 * @tc.number SUB_HSS_LocationSystem_SingleLoc_0300
* @tc.name Test getCurrentLocation * @tc.name Test getCurrentLocation
* @tc.desc Initiate a single location request in a specified scenario and set the track tracing scenario. * @tc.desc Initiate a single location request in a specified scenario and set the track tracing scenario.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('SUB_HSS_LocationSystem_SingleLoc_0003', 0, async function (done) { it('SUB_HSS_LocationSystem_SingleLoc_0300', 0, async function (done) {
let currentLocationRequest = { "priority": 0x200, "scenario": 0x302, "timeoutMs": 1000, "maxAccuracy": 10 }; let currentLocationRequest = { "priority": 0x200, "scenario": 0x302, "timeoutMs": 1000, "maxAccuracy": 10 };
function getCurrentLocationCallback() { function getCurrentLocationCallback() {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
...@@ -248,24 +249,25 @@ describe('geolocationTest_geo3', function () { ...@@ -248,24 +249,25 @@ describe('geolocationTest_geo3', function () {
}) })
} }
console.info('getCurrentLocationCallback start'); console.info('getCurrentLocationCallback start');
await getCurrentLocationCallback().then(() => { await geolocation.getCurrentLocation(currentLocationRequest).then((result) => {
console.info('getCurrentLocationCallback resolve'); console.info("getCurrentLocation callback_0003, result: " + JSON.stringify(result));
}, () => { expect(true).assertEqual(result != null);
console.info('getCurrentLocationCallback reject'); }).catch(error => {
}); console.info('getCurrentLocation callback_0003:' + JSON.stringify(error));
console.info('getCurrentLocationCallback end'); expect(true).assertEqual(JSON.stringify(error) != null);
})
done(); done();
}) })
/** /**
* @tc.number SUB_HSS_LocationSystem_SingleLoc_0004 * @tc.number SUB_HSS_LocationSystem_SingleLoc_0400
* @tc.name Test getCurrentLocation * @tc.name Test getCurrentLocation
* @tc.desc Initiate a single location request in a specified scenario and set a car-sharing scenario. * @tc.desc Initiate a single location request in a specified scenario and set a car-sharing scenario.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('SUB_HSS_LocationSystem_SingleLoc_0004', 0, async function (done) { it('SUB_HSS_LocationSystem_SingleLoc_0400', 0, async function (done) {
let currentLocationRequest = { "priority": 0x200, "scenario": 0x303, "timeoutMs": 1000, "maxAccuracy": 10 }; let currentLocationRequest = { "priority": 0x200, "scenario": 0x303, "timeoutMs": 1000, "maxAccuracy": 10 };
await geolocation.getCurrentLocation(currentLocationRequest).then((result) => { await geolocation.getCurrentLocation(currentLocationRequest).then((result) => {
console.info('[lbs_js] getCurrentLocation promise result004 ' + JSON.stringify(result)); console.info('[lbs_js] getCurrentLocation promise result004 ' + JSON.stringify(result));
...@@ -278,14 +280,14 @@ describe('geolocationTest_geo3', function () { ...@@ -278,14 +280,14 @@ describe('geolocationTest_geo3', function () {
}) })
/** /**
* @tc.number SUB_HSS_LocationSystem_SingleLoc_0005 * @tc.number SUB_HSS_LocationSystem_SingleLoc_0500
* @tc.name Test getCurrentLocation * @tc.name Test getCurrentLocation
* @tc.desc Initiate a single location request in a specified scenario and set the life service scenario.. * @tc.desc Initiate a single location request in a specified scenario and set the life service scenario..
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('SUB_HSS_LocationSystem_SingleLoc_0005', 0, async function (done) { it('SUB_HSS_LocationSystem_SingleLoc_0500', 0, async function (done) {
let currentLocationRequest = { "priority": 0x200, "scenario": 0x304, "timeoutMs": 1000, "maxAccuracy": 0 }; let currentLocationRequest = { "priority": 0x200, "scenario": 0x304, "timeoutMs": 1000, "maxAccuracy": 0 };
await geolocation.getCurrentLocation(currentLocationRequest).then((result) => { await geolocation.getCurrentLocation(currentLocationRequest).then((result) => {
console.info('[lbs_js] getCurrentLocation promise result005 ' + JSON.stringify(result)); console.info('[lbs_js] getCurrentLocation promise result005 ' + JSON.stringify(result));
...@@ -298,7 +300,7 @@ describe('geolocationTest_geo3', function () { ...@@ -298,7 +300,7 @@ describe('geolocationTest_geo3', function () {
}) })
/** /**
* @tc.number SUB_HSS_LocationSystem_SingleLoc_0006 * @tc.number SUB_HSS_LocationSystem_SingleLoc_0600
* @tc.name Test getCurrentLocation * @tc.name Test getCurrentLocation
* @tc.desc Initiate a single location request in a specified scenario * @tc.desc Initiate a single location request in a specified scenario
* and set the scenario with no power consumption. * and set the scenario with no power consumption.
...@@ -306,7 +308,7 @@ describe('geolocationTest_geo3', function () { ...@@ -306,7 +308,7 @@ describe('geolocationTest_geo3', function () {
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('SUB_HSS_LocationSystem_SingleLoc_0006', 0, async function (done) { it('SUB_HSS_LocationSystem_SingleLoc_0600', 0, async function (done) {
let currentLocationRequest1 = { "priority": 0x200, "scenario": 0x305, "timeoutMs": 1000, "maxAccuracy": 10 }; let currentLocationRequest1 = { "priority": 0x200, "scenario": 0x305, "timeoutMs": 1000, "maxAccuracy": 10 };
let currentLocationRequest2 = { "priority": 0x200, "scenario": 0x301, "timeoutMs": 1000, "maxAccuracy": 10 }; let currentLocationRequest2 = { "priority": 0x200, "scenario": 0x301, "timeoutMs": 1000, "maxAccuracy": 10 };
await geolocation.getCurrentLocation(currentLocationRequest1).then((result) => { await geolocation.getCurrentLocation(currentLocationRequest1).then((result) => {
...@@ -326,14 +328,14 @@ describe('geolocationTest_geo3', function () { ...@@ -326,14 +328,14 @@ describe('geolocationTest_geo3', function () {
}) })
/** /**
* @tc.number SUB_HSS_LocationSystem_SingleLoc_0007 * @tc.number SUB_HSS_LocationSystem_SingleLoc_0700
* @tc.name Test getCurrentLocation * @tc.name Test getCurrentLocation
* @tc.desc Initiate a single location request with the parameter set to high-precision priority location request. * @tc.desc Initiate a single location request with the parameter set to high-precision priority location request.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('SUB_HSS_LocationSystem_SingleLoc_0007', 0, async function (done) { it('SUB_HSS_LocationSystem_SingleLoc_0700', 0, async function (done) {
let currentLocationRequest = { "priority": 0x0201, "scenario": 0x0300, "timeoutMs": 1000, "maxAccuracy": 10 }; let currentLocationRequest = { "priority": 0x0201, "scenario": 0x0300, "timeoutMs": 1000, "maxAccuracy": 10 };
await geolocation.getCurrentLocation(currentLocationRequest).then((result) => { await geolocation.getCurrentLocation(currentLocationRequest).then((result) => {
console.info('[lbs_js] getCurrentLocation promise result007 ' + JSON.stringify(result)); console.info('[lbs_js] getCurrentLocation promise result007 ' + JSON.stringify(result));
...@@ -346,14 +348,14 @@ describe('geolocationTest_geo3', function () { ...@@ -346,14 +348,14 @@ describe('geolocationTest_geo3', function () {
}) })
/** /**
* @tc.number SUB_HSS_LocationSystem_SingleLoc_0008 * @tc.number SUB_HSS_LocationSystem_SingleLoc_0800
* @tc.name Test getCurrentLocation * @tc.name Test getCurrentLocation
* @tc.desc Initiate a single location request with parameters set to fast location and priority location request. * @tc.desc Initiate a single location request with parameters set to fast location and priority location request.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('SUB_HSS_LocationSystem_SingleLoc_0008', 0, async function (done) { it('SUB_HSS_LocationSystem_SingleLoc_0800', 0, async function (done) {
let currentLocationRequest = { "priority": 0x0203, "scenario": 0x0300, "timeoutMs": 1000, "maxAccuracy": 10 }; let currentLocationRequest = { "priority": 0x0203, "scenario": 0x0300, "timeoutMs": 1000, "maxAccuracy": 10 };
await geolocation.getCurrentLocation(currentLocationRequest).then((result) => { await geolocation.getCurrentLocation(currentLocationRequest).then((result) => {
console.info('[lbs_js] getCurrentLocation promise result010 ' + JSON.stringify(result)); console.info('[lbs_js] getCurrentLocation promise result010 ' + JSON.stringify(result));
...@@ -366,14 +368,14 @@ describe('geolocationTest_geo3', function () { ...@@ -366,14 +368,14 @@ describe('geolocationTest_geo3', function () {
}) })
/** /**
* @tc.number SUB_HSS_LocationSystem_SingleLoc_0009 * @tc.number SUB_HSS_LocationSystem_SingleLoc_0900
* @tc.name Test getCurrentLocation * @tc.name Test getCurrentLocation
* @tc.desc Initiate a single location request with parameters set to low power consumption. * @tc.desc Initiate a single location request with parameters set to low power consumption.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('SUB_HSS_LocationSystem_SingleLoc_0009', 0, async function (done) { it('SUB_HSS_LocationSystem_SingleLoc_0900', 0, async function (done) {
let currentLocationRequest = { "priority": 0x0202, "scenario": 0x0300, "timeoutMs": 1000, "maxAccuracy": 0 }; let currentLocationRequest = { "priority": 0x0202, "scenario": 0x0300, "timeoutMs": 1000, "maxAccuracy": 0 };
await geolocation.getCurrentLocation(currentLocationRequest).then((result) => { await geolocation.getCurrentLocation(currentLocationRequest).then((result) => {
console.info('[lbs_js] getCurrentLocation promise result009 ' + JSON.stringify(result)); console.info('[lbs_js] getCurrentLocation promise result009 ' + JSON.stringify(result));
...@@ -386,14 +388,14 @@ describe('geolocationTest_geo3', function () { ...@@ -386,14 +388,14 @@ describe('geolocationTest_geo3', function () {
}) })
/** /**
* @tc.number SUB_HSS_LocationSystem_SingleLoc_0010 * @tc.number SUB_HSS_LocationSystem_SingleLoc_0100
* @tc.name Test getCurrentLocation * @tc.name Test getCurrentLocation
* @tc.desc Initiate a single location request and set the location reporting precision. * @tc.desc Initiate a single location request and set the location reporting precision.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('SUB_HSS_LocationSystem_SingleLoc_0010', 0, async function (done) { it('SUB_HSS_LocationSystem_SingleLoc_0100', 0, async function (done) {
let currentLocationRequest = { "priority": 0x0200, "scenario": 0x0300, "timeoutMs": 1000, "maxAccuracy": 5 }; let currentLocationRequest = { "priority": 0x0200, "scenario": 0x0300, "timeoutMs": 1000, "maxAccuracy": 5 };
let currentLocationRequest1 = { "priority": 0x0200, "scenario": 0x0300, "timeoutMs": 1000, "maxAccuracy": 2 }; let currentLocationRequest1 = { "priority": 0x0200, "scenario": 0x0300, "timeoutMs": 1000, "maxAccuracy": 2 };
await geolocation.getCurrentLocation(currentLocationRequest).then((result) => { await geolocation.getCurrentLocation(currentLocationRequest).then((result) => {
...@@ -412,7 +414,7 @@ describe('geolocationTest_geo3', function () { ...@@ -412,7 +414,7 @@ describe('geolocationTest_geo3', function () {
}) })
/** /**
* @tc.number SUB_HSS_LocationSystem_SingleLoc_0011 * @tc.number SUB_HSS_LocationSystem_SingleLoc_1100
* @tc.name Test getCurrentLocation * @tc.name Test getCurrentLocation
* @tc.desc Initiate a single location request for specific configuration * @tc.desc Initiate a single location request for specific configuration
* and set the reporting precision of abnormal location. * and set the reporting precision of abnormal location.
...@@ -420,7 +422,7 @@ describe('geolocationTest_geo3', function () { ...@@ -420,7 +422,7 @@ describe('geolocationTest_geo3', function () {
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('SUB_HSS_LocationSystem_SingleLoc_0011', 0, async function (done) { it('SUB_HSS_LocationSystem_SingleLoc_1100', 0, async function (done) {
let currentLocationRequest = { "priority": 0x0201, "scenario": 0x0300, "timeoutMs": 1000, "maxAccuracy": 0 }; let currentLocationRequest = { "priority": 0x0201, "scenario": 0x0300, "timeoutMs": 1000, "maxAccuracy": 0 };
let currentLocationRequest1 = { "priority": 0x0201, "scenario": 0x0300, "timeoutMs": 1000, "maxAccuracy": -1 }; let currentLocationRequest1 = { "priority": 0x0201, "scenario": 0x0300, "timeoutMs": 1000, "maxAccuracy": -1 };
await geolocation.getCurrentLocation(currentLocationRequest).then((result) => { await geolocation.getCurrentLocation(currentLocationRequest).then((result) => {
...@@ -440,14 +442,14 @@ describe('geolocationTest_geo3', function () { ...@@ -440,14 +442,14 @@ describe('geolocationTest_geo3', function () {
}) })
/** /**
* @tc.number SUB_HSS_LocationSystem_SingleLoc_0012 * @tc.number SUB_HSS_LocationSystem_SingleLoc_1200
* @tc.name Test getCurrentLocation * @tc.name Test getCurrentLocation
* @tc.desc Initiate a single location request and set the location timeout interval. * @tc.desc Initiate a single location request and set the location timeout interval.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('SUB_HSS_LocationSystem_SingleLoc_0012', 0, async function (done) { it('SUB_HSS_LocationSystem_SingleLoc_1200', 0, async function (done) {
let currentLocationRequest = { "priority": 0x0201, "scenario": 0x0301, "timeoutMs": 1000, "maxAccuracy": 0 }; let currentLocationRequest = { "priority": 0x0201, "scenario": 0x0301, "timeoutMs": 1000, "maxAccuracy": 0 };
let currentLocationRequest1 = { "priority": 0x0201, "scenario": 0x0301, "timeoutMs": 1000, "maxAccuracy": 0 }; let currentLocationRequest1 = { "priority": 0x0201, "scenario": 0x0301, "timeoutMs": 1000, "maxAccuracy": 0 };
await geolocation.getCurrentLocation(currentLocationRequest).then((result) => { await geolocation.getCurrentLocation(currentLocationRequest).then((result) => {
...@@ -467,14 +469,14 @@ describe('geolocationTest_geo3', function () { ...@@ -467,14 +469,14 @@ describe('geolocationTest_geo3', function () {
}) })
/** /**
* @tc.number SUB_HSS_LocationSystem_SingleLoc_0013 * @tc.number SUB_HSS_LocationSystem_SingleLoc_1300
* @tc.name Test getCurrentLocation * @tc.name Test getCurrentLocation
* @tc.desc Initiate a specified single location request and set the exception location timeout interval. * @tc.desc Initiate a specified single location request and set the exception location timeout interval.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('SUB_HSS_LocationSystem_SingleLoc_0013', 0, async function (done) { it('SUB_HSS_LocationSystem_SingleLoc_1300', 0, async function (done) {
let currentLocationRequest = { "priority": 0x0201, "scenario": 0x0302, "timeoutMs": 0, "maxAccuracy": 0 }; let currentLocationRequest = { "priority": 0x0201, "scenario": 0x0302, "timeoutMs": 0, "maxAccuracy": 0 };
let currentLocationRequest1 = { "priority": 0x0201, "scenario": 0x0302, "timeoutMs": -1000, "maxAccuracy": 0 }; let currentLocationRequest1 = { "priority": 0x0201, "scenario": 0x0302, "timeoutMs": -1000, "maxAccuracy": 0 };
await geolocation.getCurrentLocation(currentLocationRequest).then((result) => { await geolocation.getCurrentLocation(currentLocationRequest).then((result) => {
...@@ -496,14 +498,14 @@ describe('geolocationTest_geo3', function () { ...@@ -496,14 +498,14 @@ describe('geolocationTest_geo3', function () {
/** /**
* @tc.number SUB_HSS_SendCommand_callback * @tc.number SUB_HSS_SendCommand_0100
* @tc.name Test sendCommand * @tc.name Test sendCommand
* @tc.desc Test sendCommand api . * @tc.desc Test sendCommand api .
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('SUB_HSS_SendCommand_callback', 0, async function (done) { it('SUB_HSS_SendCommand_0100', 0, async function (done) {
let requestInfo = { 'scenairo': 0x301, 'command': "command_1" }; let requestInfo = { 'scenairo': 0x301, 'command': "command_1" };
await geolocation.sendCommand(requestInfo, (err, result) => { await geolocation.sendCommand(requestInfo, (err, result) => {
if (err) { if (err) {
...@@ -516,14 +518,14 @@ describe('geolocationTest_geo3', function () { ...@@ -516,14 +518,14 @@ describe('geolocationTest_geo3', function () {
}) })
/** /**
* @tc.number SUB_HSS_SendCommand_promise * @tc.number SUB_HSS_SendCommand_0200
* @tc.name Test sendCommand * @tc.name Test sendCommand
* @tc.desc Test sendCommand1 api . * @tc.desc Test sendCommand1 api .
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('SUB_HSS_SendCommand_promise', 0, async function (done) { it('SUB_HSS_SendCommand_0200', 0, async function (done) {
let requestInfo = { 'scenairo': 0x301, 'command': "command_1" }; let requestInfo = { 'scenairo': 0x301, 'command': "command_1" };
geolocation.sendCommand(requestInfo).then((result) => { geolocation.sendCommand(requestInfo).then((result) => {
console.info('sendCommand promise result:' + result); console.info('sendCommand promise result:' + result);
...@@ -536,14 +538,14 @@ describe('geolocationTest_geo3', function () { ...@@ -536,14 +538,14 @@ describe('geolocationTest_geo3', function () {
}) })
/** /**
* @tc.number SUB_HSS_LocationSystem_LocRequest_0001 * @tc.number SUB_HSS_LocationSystem_LocRequest_0100
* @tc.name Test locationChange * @tc.name Test locationChange
* @tc.desc Initiate a request for continuous positioning in a specified scenario and set the navigation scenario. * @tc.desc Initiate a request for continuous positioning in a specified scenario and set the navigation scenario.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('SUB_HSS_LocationSystem_LocRequest_0001', 0, async function (done) { it('SUB_HSS_LocationSystem_LocRequest_0100', 0, async function (done) {
enableLocationSwitch(); enableLocationSwitch();
let requestInfo = {"priority":0x200, "scenario":0x301, "timeInterval":5, let requestInfo = {"priority":0x200, "scenario":0x301, "timeInterval":5,
"distanceInterval": 0, "maxAccuracy": 0}; "distanceInterval": 0, "maxAccuracy": 0};
...@@ -557,14 +559,14 @@ describe('geolocationTest_geo3', function () { ...@@ -557,14 +559,14 @@ describe('geolocationTest_geo3', function () {
}) })
/** /**
* @tc.number SUB_HSS_LocationSystem_LocRequest_0002 * @tc.number SUB_HSS_LocationSystem_LocRequest_0200
* @tc.name Test locationChange * @tc.name Test locationChange
* @tc.desc Initiate a request for continuous positioning in a specified scenario and set a track tracing scenario. * @tc.desc Initiate a request for continuous positioning in a specified scenario and set a track tracing scenario.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('SUB_HSS_LocationSystem_LocRequest_0002', 0, async function (done) { it('SUB_HSS_LocationSystem_LocRequest_0200', 0, async function (done) {
enableLocationSwitch(); enableLocationSwitch();
let requestInfo = {"priority":0x200, "scenario":0x302, "timeInterval":1, let requestInfo = {"priority":0x200, "scenario":0x302, "timeInterval":1,
"distanceInterval": 5, "maxAccuracy": 10}; "distanceInterval": 5, "maxAccuracy": 10};
...@@ -578,14 +580,14 @@ describe('geolocationTest_geo3', function () { ...@@ -578,14 +580,14 @@ describe('geolocationTest_geo3', function () {
}) })
/** /**
* @tc.number SUB_HSS_LocationSystem_LocRequest_0003 * @tc.number SUB_HSS_LocationSystem_LocRequest_0300
* @tc.name Test locationChange * @tc.name Test locationChange
* @tc.desc Initiate a continuous location request in a specified scenario and set a car-sharing scenario. * @tc.desc Initiate a continuous location request in a specified scenario and set a car-sharing scenario.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('SUB_HSS_LocationSystem_LocRequest_0003', 0, async function (done) { it('SUB_HSS_LocationSystem_LocRequest_0300', 0, async function (done) {
enableLocationSwitch(); enableLocationSwitch();
let requestInfo = {"priority":0x200, "scenario":0x303, "timeInterval":5, let requestInfo = {"priority":0x200, "scenario":0x303, "timeInterval":5,
"distanceInterval": 5, "maxAccuracy": 10}; "distanceInterval": 5, "maxAccuracy": 10};
...@@ -599,14 +601,14 @@ describe('geolocationTest_geo3', function () { ...@@ -599,14 +601,14 @@ describe('geolocationTest_geo3', function () {
}) })
/** /**
* @tc.number SUB_HSS_LocationSystem_LocRequest_0004 * @tc.number SUB_HSS_LocationSystem_LocRequest_0400
* @tc.name Test locationChange * @tc.name Test locationChange
* @tc.desc Initiate a continuous location request in a specified scenario and set a life service scenario. * @tc.desc Initiate a continuous location request in a specified scenario and set a life service scenario.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('SUB_HSS_LocationSystem_LocRequest_0004', 0, async function (done) { it('SUB_HSS_LocationSystem_LocRequest_0400', 0, async function (done) {
enableLocationSwitch(); enableLocationSwitch();
let requestInfo = {"priority":0x200, "scenario":0x303, "timeInterval":1, let requestInfo = {"priority":0x200, "scenario":0x303, "timeInterval":1,
"distanceInterval": 5, "maxAccuracy": 0}; "distanceInterval": 5, "maxAccuracy": 0};
...@@ -620,7 +622,7 @@ describe('geolocationTest_geo3', function () { ...@@ -620,7 +622,7 @@ describe('geolocationTest_geo3', function () {
}) })
/** /**
* @tc.number SUB_HSS_LocationSystem_LocRequest_0005 * @tc.number SUB_HSS_LocationSystem_LocRequest_0500
* @tc.name Test locationChange * @tc.name Test locationChange
* @tc.desc Initiate a continuous location request in a specified scenario * @tc.desc Initiate a continuous location request in a specified scenario
* and set the scenario with no power consumption. * and set the scenario with no power consumption.
...@@ -628,7 +630,7 @@ describe('geolocationTest_geo3', function () { ...@@ -628,7 +630,7 @@ describe('geolocationTest_geo3', function () {
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('SUB_HSS_LocationSystem_LocRequest_0005', 0, async function (done) { it('SUB_HSS_LocationSystem_LocRequest_0500', 0, async function (done) {
enableLocationSwitch(); enableLocationSwitch();
let requestInfo = {"priority":0x200, "scenario":0x305, "timeInterval":1, let requestInfo = {"priority":0x200, "scenario":0x305, "timeInterval":1,
"distanceInterval": 5, "maxAccuracy": 10}; "distanceInterval": 5, "maxAccuracy": 10};
...@@ -648,7 +650,7 @@ describe('geolocationTest_geo3', function () { ...@@ -648,7 +650,7 @@ describe('geolocationTest_geo3', function () {
}) })
/** /**
* @tc.number SUB_HSS_LocationSystem_LocRequest_0007 * @tc.number SUB_HSS_LocationSystem_LocRequest_0700
* @tc.name Test locationChange * @tc.name Test locationChange
* @tc.desc Initiate a specified continuous positioning request and * @tc.desc Initiate a specified continuous positioning request and
* set the parameter to high-precision priority positioning request. * set the parameter to high-precision priority positioning request.
...@@ -656,7 +658,7 @@ describe('geolocationTest_geo3', function () { ...@@ -656,7 +658,7 @@ describe('geolocationTest_geo3', function () {
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('SUB_HSS_LocationSystem_LocRequest_0007', 0, async function (done) { it('SUB_HSS_LocationSystem_LocRequest_0700', 0, async function (done) {
enableLocationSwitch(); enableLocationSwitch();
let requestInfo = {"priority":0x201, "scenario":0x300, "timeInterval":1, let requestInfo = {"priority":0x201, "scenario":0x300, "timeInterval":1,
"distanceInterval": 5, "maxAccuracy": 10}; "distanceInterval": 5, "maxAccuracy": 10};
...@@ -670,7 +672,7 @@ describe('geolocationTest_geo3', function () { ...@@ -670,7 +672,7 @@ describe('geolocationTest_geo3', function () {
}) })
/** /**
* @tc.number SUB_HSS_LocationSystem_LocRequest_0008 * @tc.number SUB_HSS_LocationSystem_LocRequest_0800
* @tc.name Test locationChange * @tc.name Test locationChange
* @tc.desc Initiate a specified continuous positioning request with the parameter * @tc.desc Initiate a specified continuous positioning request with the parameter
* set to fast positioning and priority positioning request. * set to fast positioning and priority positioning request.
...@@ -678,7 +680,7 @@ describe('geolocationTest_geo3', function () { ...@@ -678,7 +680,7 @@ describe('geolocationTest_geo3', function () {
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('SUB_HSS_LocationSystem_LocRequest_0008', 0, async function (done) { it('SUB_HSS_LocationSystem_LocRequest_0800', 0, async function (done) {
enableLocationSwitch(); enableLocationSwitch();
let requestInfo = {"priority":0x203, "scenario":0x300, "timeInterval":5, let requestInfo = {"priority":0x203, "scenario":0x300, "timeInterval":5,
"distanceInterval": 5, "maxAccuracy": 10}; "distanceInterval": 5, "maxAccuracy": 10};
...@@ -692,7 +694,7 @@ describe('geolocationTest_geo3', function () { ...@@ -692,7 +694,7 @@ describe('geolocationTest_geo3', function () {
}) })
/** /**
* @tc.number SUB_HSS_LocationSystem_LocRequest_0009 * @tc.number SUB_HSS_LocationSystem_LocRequest_0900
* @tc.name Test locationChange * @tc.name Test locationChange
* @tc.desc Initiate a specified continuous positioning request with the parameter * @tc.desc Initiate a specified continuous positioning request with the parameter
* set to low power consumption type. * set to low power consumption type.
...@@ -700,7 +702,7 @@ describe('geolocationTest_geo3', function () { ...@@ -700,7 +702,7 @@ describe('geolocationTest_geo3', function () {
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('SUB_HSS_LocationSystem_LocRequest_0009', 0, async function (done) { it('SUB_HSS_LocationSystem_LocRequest_0900', 0, async function (done) {
enableLocationSwitch(); enableLocationSwitch();
let requestInfo = {"priority":0x202, "scenario":0x300, "timeInterval":1, let requestInfo = {"priority":0x202, "scenario":0x300, "timeInterval":1,
"distanceInterval": 5, "maxAccuracy": 10} "distanceInterval": 5, "maxAccuracy": 10}
...@@ -714,14 +716,14 @@ describe('geolocationTest_geo3', function () { ...@@ -714,14 +716,14 @@ describe('geolocationTest_geo3', function () {
}) })
/** /**
* @tc.number SUB_HSS_LocationSystem_LocRequest_0010 * @tc.number SUB_HSS_LocationSystem_LocRequest_0100
* @tc.name Test locationChange * @tc.name Test locationChange
* @tc.desc Initiate a specified continuous location request and set the reporting interval. * @tc.desc Initiate a specified continuous location request and set the reporting interval.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('SUB_HSS_LocationSystem_LocRequest_0010', 0, async function (done) { it('SUB_HSS_LocationSystem_LocRequest_0100', 0, async function (done) {
enableLocationSwitch(); enableLocationSwitch();
let requestInfo = {"priority":0x200, "scenario":0x301, "timeInterval":3, let requestInfo = {"priority":0x200, "scenario":0x301, "timeInterval":3,
"distanceInterval": 0, "maxAccuracy": 0}; "distanceInterval": 0, "maxAccuracy": 0};
...@@ -735,14 +737,14 @@ describe('geolocationTest_geo3', function () { ...@@ -735,14 +737,14 @@ describe('geolocationTest_geo3', function () {
}) })
/** /**
* @tc.number SUB_HSS_LocationSystem_LocRequest_0011 * @tc.number SUB_HSS_LocationSystem_LocRequest_1100
* @tc.name Test locationChange * @tc.name Test locationChange
* @tc.desc Initiate a specified continuous location request and set the location reporting interval. * @tc.desc Initiate a specified continuous location request and set the location reporting interval.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('SUB_HSS_LocationSystem_LocRequest_0011', 0, async function (done) { it('SUB_HSS_LocationSystem_LocRequest_1100', 0, async function (done) {
enableLocationSwitch(); enableLocationSwitch();
let requestInfo = {"priority":0x200, "scenario":0x301, "timeInterval":5, let requestInfo = {"priority":0x200, "scenario":0x301, "timeInterval":5,
"distanceInterval": 0, "maxAccuracy": 0}; "distanceInterval": 0, "maxAccuracy": 0};
...@@ -756,14 +758,14 @@ describe('geolocationTest_geo3', function () { ...@@ -756,14 +758,14 @@ describe('geolocationTest_geo3', function () {
}) })
/** /**
* @tc.number SUB_HSS_LocationSystem_LocRequest_0012 * @tc.number SUB_HSS_LocationSystem_LocRequest_1200
* @tc.name Test locationChange * @tc.name Test locationChange
* @tc.desc Initiate a specified continuous location request and set the interval for reporting exceptions. * @tc.desc Initiate a specified continuous location request and set the interval for reporting exceptions.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('SUB_HSS_LocationSystem_LocRequest_0012', 0, async function (done) { it('SUB_HSS_LocationSystem_LocRequest_1200', 0, async function (done) {
enableLocationSwitch(); enableLocationSwitch();
let requestInfo = {"priority":0x200, "scenario":0x301, "timeInterval":0, let requestInfo = {"priority":0x200, "scenario":0x301, "timeInterval":0,
"distanceInterval": 0, "maxAccuracy": 0}; "distanceInterval": 0, "maxAccuracy": 0};
...@@ -777,14 +779,14 @@ describe('geolocationTest_geo3', function () { ...@@ -777,14 +779,14 @@ describe('geolocationTest_geo3', function () {
}) })
/** /**
* @tc.number SUB_HSS_LocationSystem_LocRequest_0013 * @tc.number SUB_HSS_LocationSystem_LocRequest_1300
* @tc.name Test locationChange * @tc.name Test locationChange
* @tc.desc Initiate a specified continuous location request and set the interval for reporting abnormal locations. * @tc.desc Initiate a specified continuous location request and set the interval for reporting abnormal locations.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('SUB_HSS_LocationSystem_LocRequest_0013', 0, async function (done) { it('SUB_HSS_LocationSystem_LocRequest_1300', 0, async function (done) {
enableLocationSwitch(); enableLocationSwitch();
let requestInfo1 = {"priority":0x200, "scenario":0x301, "timeInterval":0, let requestInfo1 = {"priority":0x200, "scenario":0x301, "timeInterval":0,
"distanceInterval": 0, "maxAccuracy": 0}; "distanceInterval": 0, "maxAccuracy": 0};
...@@ -806,14 +808,14 @@ describe('geolocationTest_geo3', function () { ...@@ -806,14 +808,14 @@ describe('geolocationTest_geo3', function () {
}) })
/** /**
* @tc.number SUB_HSS_LocationSystem_LocRequest_0014 * @tc.number SUB_HSS_LocationSystem_LocRequest_1400
* @tc.name Test locationChange * @tc.name Test locationChange
* @tc.desc Initiate a specified continuous positioning request and set the positioning reporting precision. * @tc.desc Initiate a specified continuous positioning request and set the positioning reporting precision.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('SUB_HSS_LocationSystem_LocRequest_0014', 0, async function (done) { it('SUB_HSS_LocationSystem_LocRequest_1400', 0, async function (done) {
enableLocationSwitch(); enableLocationSwitch();
let requestInfo1 = {"priority":0x200, "scenario":0x301, "timeInterval":0, let requestInfo1 = {"priority":0x200, "scenario":0x301, "timeInterval":0,
"distanceInterval": 0, "maxAccuracy": 5}; "distanceInterval": 0, "maxAccuracy": 5};
...@@ -835,14 +837,14 @@ describe('geolocationTest_geo3', function () { ...@@ -835,14 +837,14 @@ describe('geolocationTest_geo3', function () {
}) })
/** /**
* @tc.number SUB_HSS_LocationSystem_LocRequest_0015 * @tc.number SUB_HSS_LocationSystem_LocRequest_1500
* @tc.name Test locationChange * @tc.name Test locationChange
* @tc.desc Initiate a specified continuous location request and set the reporting precision of abnormal location. * @tc.desc Initiate a specified continuous location request and set the reporting precision of abnormal location.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('SUB_HSS_LocationSystem_LocRequest_0015', 0, async function (done) { it('SUB_HSS_LocationSystem_LocRequest_1500', 0, async function (done) {
enableLocationSwitch(); enableLocationSwitch();
let requestInfo1 = {"priority":0x200, "scenario":0x301, "timeInterval":0, let requestInfo1 = {"priority":0x200, "scenario":0x301, "timeInterval":0,
"distanceInterval": 0, "maxAccuracy": 0}; "distanceInterval": 0, "maxAccuracy": 0};
...@@ -864,14 +866,14 @@ describe('geolocationTest_geo3', function () { ...@@ -864,14 +866,14 @@ describe('geolocationTest_geo3', function () {
}) })
/** /**
* @tc.number SUB_HSS_LocationSystem_LastLoc_0001 * @tc.number SUB_HSS_LocationSystem_LastLoc_0100
* @tc.name Test getLastLocation * @tc.name Test getLastLocation
* @tc.desc Obtain the last location after a single location. * @tc.desc Obtain the last location after a single location.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('SUB_HSS_LocationSystem_LastLoc_0001', 0, async function(done) { it('SUB_HSS_LocationSystem_LastLoc_0100', 0, async function(done) {
enableLocationSwitch(); enableLocationSwitch();
let requestInfo = {"priority":0x200, "scenario":0x301, "timeInterval":0, let requestInfo = {"priority":0x200, "scenario":0x301, "timeInterval":0,
"distanceInterval": 0, "maxAccuracy": 0}; "distanceInterval": 0, "maxAccuracy": 0};
...@@ -889,7 +891,7 @@ describe('geolocationTest_geo3', function () { ...@@ -889,7 +891,7 @@ describe('geolocationTest_geo3', function () {
+' accuracy: ' + result.accuracy+' speed: ' + result.speed + +' accuracy: ' + result.accuracy+' speed: ' + result.speed +
'timeStamp: ' + result.timeStamp+'direction:' + result.direction+' timeSinceBoot: ' 'timeStamp: ' + result.timeStamp+'direction:' + result.direction+' timeSinceBoot: '
+ result.timeSinceBoot +'additions: ' + result.additions+' additionSize' + result.additionSize + result.timeSinceBoot +'additions: ' + result.additions+' additionSize' + result.additionSize
+'isFromMock'+ result.isFromMock); + 'isFromMock' +result.isFromMock);
}).catch((error) => { }).catch((error) => {
console.info("[lbs_js] getLastLocation promise then error:" + JSON.stringify(error)); console.info("[lbs_js] getLastLocation promise then error:" + JSON.stringify(error));
console.info('[lbs_js] not support now'); console.info('[lbs_js] not support now');
...@@ -899,14 +901,14 @@ describe('geolocationTest_geo3', function () { ...@@ -899,14 +901,14 @@ describe('geolocationTest_geo3', function () {
}) })
/** /**
* @tc.number SUB_HSS_LocationSystem_LastLoc_0002 * @tc.number SUB_HSS_LocationSystem_LastLoc_0200
* @tc.name Test getLastLocation * @tc.name Test getLastLocation
* @tc.desc Obtain the last location after continuous positioning. * @tc.desc Obtain the last location after continuous positioning.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('SUB_HSS_LocationSystem_LastLoc_0002', 0, async function (done) { it('SUB_HSS_LocationSystem_LastLoc_0200', 0, async function (done) {
enableLocationSwitch(); enableLocationSwitch();
let requestInfo = {"priority":0x200, "scenario":0x301, "timeInterval":0, let requestInfo = {"priority":0x200, "scenario":0x301, "timeInterval":0,
"distanceInterval": 0, "maxAccuracy": 0}; "distanceInterval": 0, "maxAccuracy": 0};
...@@ -916,27 +918,34 @@ describe('geolocationTest_geo3', function () { ...@@ -916,27 +918,34 @@ describe('geolocationTest_geo3', function () {
}; };
geolocation.on('locationChange', requestInfo, locationChange); geolocation.on('locationChange', requestInfo, locationChange);
geolocation.off('locationChange', locationChange); geolocation.off('locationChange', locationChange);
geolocation.getLastLocation(async (err, data) => {
function getLastLocationCallback(){
return new Promise((resolve, reject)=>{
geolocation.getLastLocation((err, data) => {
if (err) { if (err) {
console.info('[LastLoc_0002] getLastLocation callback err is : ' + JSON.stringify(err)); console.info('[LastLoc_0002] getLastLocation callback err is : ' + JSON.stringify(err));
expect(true).assertEqual(err !=null);
} else { } else {
console.info('[LastLoc_0002] getLastLocation callback result: ' + JSON.stringify(data)); console.info('[LastLoc_0002] getLastLocation callback result: ' + JSON.stringify(data));
expect(data).assertTrue(); expect(true).assertEqual(data !=null);
} }
done() resolve();
});
}) })
}
await getLastLocationCallback();
done(); done();
}) })
/** /**
* @tc.number SUB_HSS_LocationSystem_Gnss_0001 * @tc.number SUB_HSS_LocationSystem_Gnss_0100
* @tc.name Test gnssStatusChange * @tc.name Test gnssStatusChange
* @tc.desc Monitoring Satellite Information Reporting * @tc.desc Monitoring Satellite Information Reporting
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('SUB_HSS_LocationSystem_Gnss_0001', 0, async function (done) { it('SUB_HSS_LocationSystem_Gnss_0100', 0, async function (done) {
await changedLocationMode(); await changedLocationMode();
var gnssStatusCb = (satelliteStatusInfo) => { var gnssStatusCb = (satelliteStatusInfo) => {
console.info('gnssStatusChange: ' + satelliteStatusInfo); console.info('gnssStatusChange: ' + satelliteStatusInfo);
...@@ -961,14 +970,14 @@ describe('geolocationTest_geo3', function () { ...@@ -961,14 +970,14 @@ describe('geolocationTest_geo3', function () {
}) })
/** /**
* @tc.number SUB_HSS_LocationSystem_Gnss_0002 * @tc.number SUB_HSS_LocationSystem_Gnss_0200
* @tc.name Test nmeaMessageChange * @tc.name Test nmeaMessageChange
* @tc.desc Monitoring NMEA Information Reporting * @tc.desc Monitoring NMEA Information Reporting
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('SUB_HSS_LocationSystem_Gnss_0002', 0, async function (done) { it('SUB_HSS_LocationSystem_Gnss_0200', 0, async function (done) {
await changedLocationMode(); await changedLocationMode();
let requestInfo = {"priority":0x200, "scenario":0x301, "timeInterval":0, let requestInfo = {"priority":0x200, "scenario":0x301, "timeInterval":0,
"distanceInterval": 0, "maxAccuracy": 0}; "distanceInterval": 0, "maxAccuracy": 0};
...@@ -987,14 +996,14 @@ describe('geolocationTest_geo3', function () { ...@@ -987,14 +996,14 @@ describe('geolocationTest_geo3', function () {
}) })
/** /**
* @tc.number SUB_HSS_LocationSystem_Batching_0001 * @tc.number SUB_HSS_LocationSystem_Batching_0100
* @tc.name Test cachedGnssLocationsReporting * @tc.name Test cachedGnssLocationsReporting
* @tc.desc Setting the Gnss Batching Reporting Interval * @tc.desc Setting the Gnss Batching Reporting Interval
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('SUB_HSS_LocationSystem_Batching_0001', 0, async function (done) { it('SUB_HSS_LocationSystem_Batching_0100', 0, async function (done) {
var cachedLocationsCb1 = (locations) => { var cachedLocationsCb1 = (locations) => {
console.log('cachedGnssLocationsReporting: locations: ' + JSON.stringify(locations)); console.log('cachedGnssLocationsReporting: locations: ' + JSON.stringify(locations));
expect(true).assertEqual(locations !=null); expect(true).assertEqual(locations !=null);
...@@ -1013,14 +1022,14 @@ describe('geolocationTest_geo3', function () { ...@@ -1013,14 +1022,14 @@ describe('geolocationTest_geo3', function () {
}) })
/** /**
* @tc.number SUB_HSS_LocationSystem_Batching_0002 * @tc.number SUB_HSS_LocationSystem_Batching_0200
* @tc.name Test cachedGnssLocationsReporting * @tc.name Test cachedGnssLocationsReporting
* @tc.desc Setting the Gnss Batching Cache Queue to Be Reported When the Gnss Batching Cache Queue Is Full * @tc.desc Setting the Gnss Batching Cache Queue to Be Reported When the Gnss Batching Cache Queue Is Full
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('SUB_HSS_LocationSystem_Batching_0002', 0, async function (done) { it('SUB_HSS_LocationSystem_Batching_0200', 0, async function (done) {
var cachedLocationsCb = (locations) => { var cachedLocationsCb = (locations) => {
console.log('cachedGnssLocationsReporting: locations: ' + JSON.stringify(locations)); console.log('cachedGnssLocationsReporting: locations: ' + JSON.stringify(locations));
expect(true).assertEqual(locations !=null); expect(true).assertEqual(locations !=null);
...@@ -1034,14 +1043,14 @@ describe('geolocationTest_geo3', function () { ...@@ -1034,14 +1043,14 @@ describe('geolocationTest_geo3', function () {
}) })
/** /**
* @tc.number SUB_HSS_LocationSystem_Batching_0003 * @tc.number SUB_HSS_LocationSystem_Batching_0300
* @tc.name Test getCachedGnssLocationsSize * @tc.name Test getCachedGnssLocationsSize
* @tc.desc Obtains the number of GNSS data records in the batching process. * @tc.desc Obtains the number of GNSS data records in the batching process.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('SUB_HSS_LocationSystem_Batching_0003', 0, async function (done) { it('SUB_HSS_LocationSystem_Batching_0300', 0, async function (done) {
var cachedLocationsCb = (locations) => { var cachedLocationsCb = (locations) => {
console.log('cachedGnssLocationsReporting: locations: ' + JSON.stringify(locations)); console.log('cachedGnssLocationsReporting: locations: ' + JSON.stringify(locations));
expect(true).assertEqual(locations !=null); expect(true).assertEqual(locations !=null);
...@@ -1051,29 +1060,33 @@ describe('geolocationTest_geo3', function () { ...@@ -1051,29 +1060,33 @@ describe('geolocationTest_geo3', function () {
"distanceInterval": 0, "maxAccuracy": 0}; "distanceInterval": 0, "maxAccuracy": 0};
geolocation.on('cachedGnssLocationsReporting', CachedGnssLoactionsRequest, cachedLocationsCb); geolocation.on('cachedGnssLocationsReporting', CachedGnssLoactionsRequest, cachedLocationsCb);
geolocation.off('cachedGnssLocationsReporting',cachedLocationsCb); geolocation.off('cachedGnssLocationsReporting',cachedLocationsCb);
function getCachedGnssLocationsSizeCallback(){
return new Promise((resolve, reject)=>{
geolocation.getCachedGnssLocationsSize((err, data) => { geolocation.getCachedGnssLocationsSize((err, data) => {
if (err) { if (err) {
console.info('[lbs_js] getCachedGnssLocationsSize callback err is : ' + err); console.info('[lbs_js] getCachedGnssLocationsSize callback err is : ' + JSON.stringify(err));
expect(true).assertTrue(err != null); expect(true).assertTrue(err != null);
done();
}else { }else {
console.info("[lbs_js] getCachedGnssLocationsSize callback data is: " + JSON.stringify(data)); console.info("[lbs_js] getCachedGnssLocationsSize callback data is: " + JSON.stringify(data));
expect(true).assertTrue(data != null); expect(true).assertTrue(data != null);
done()
} }
resolve();
}); });
})
}
await getCachedGnssLocationsSizeCallback();
done(); done();
}) })
/** /**
* @tc.number SUB_HSS_LocationSystem_Batching_0004 * @tc.number SUB_HSS_LocationSystem_Batching_0400
* @tc.name Test getCachedGnssLocationsSize * @tc.name Test getCachedGnssLocationsSize
* @tc.desc Obtains the number of GNSS data records in the batching process. * @tc.desc Obtains the number of GNSS data records in the batching process.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('SUB_HSS_LocationSystem_Batching_0004', 0, async function (done) { it('SUB_HSS_LocationSystem_Batching_0400', 0, async function (done) {
var cachedLocationsCb = (locations) => { var cachedLocationsCb = (locations) => {
console.log('cachedGnssLocationsReporting: locations: ' + JSON.stringify(locations)); console.log('cachedGnssLocationsReporting: locations: ' + JSON.stringify(locations));
expect(true).assertEqual(locations !=null); expect(true).assertEqual(locations !=null);
...@@ -1095,14 +1108,14 @@ describe('geolocationTest_geo3', function () { ...@@ -1095,14 +1108,14 @@ describe('geolocationTest_geo3', function () {
}) })
/** /**
* @tc.number SUB_HSS_LocationSystem_Batching_0005 * @tc.number SUB_HSS_LocationSystem_Batching_0500
* @tc.name Test flushCachedGnssLocations * @tc.name Test flushCachedGnssLocations
* @tc.desc Obtains the GNSS data of the current batching. * @tc.desc Obtains the GNSS data of the current batching.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('SUB_HSS_LocationSystem_Batching_0005', 0, async function (done) { it('SUB_HSS_LocationSystem_Batching_0500', 0, async function (done) {
var cachedLocationsCb = (locations) => { var cachedLocationsCb = (locations) => {
console.log('cachedGnssLocationsReporting: locations: ' + JSON.stringify(locations)); console.log('cachedGnssLocationsReporting: locations: ' + JSON.stringify(locations));
expect(true).assertEqual(locations !=null); expect(true).assertEqual(locations !=null);
...@@ -1112,29 +1125,33 @@ describe('geolocationTest_geo3', function () { ...@@ -1112,29 +1125,33 @@ describe('geolocationTest_geo3', function () {
"distanceInterval": 0, "maxAccuracy": 0}; "distanceInterval": 0, "maxAccuracy": 0};
geolocation.on('cachedGnssLocationsReporting', CachedGnssLoactionsRequest, cachedLocationsCb); geolocation.on('cachedGnssLocationsReporting', CachedGnssLoactionsRequest, cachedLocationsCb);
geolocation.off('cachedGnssLocationsReporting',cachedLocationsCb); geolocation.off('cachedGnssLocationsReporting',cachedLocationsCb);
function flushCachedGnssLocationsCallback(){
return new Promise((resolve, reject)=>{
geolocation.flushCachedGnssLocations((err, data) => { geolocation.flushCachedGnssLocations((err, data) => {
if (err) { if (err) {
console.info('[lbs_js] flushCachedGnssLocations callback err is : ' + err); console.info('[lbs_js] flushCachedGnssLocations callback err is : ' + JSON.stringify(err));
expect(true).assertTrue(err != null); expect(true).assertTrue(err != null);
done();
}else { }else {
console.info("[lbs_js] flushCachedGnssLocations callback data is: " + JSON.stringify(data)); console.info("[lbs_js] flushCachedGnssLocations callback data is: " + JSON.stringify(data));
expect(true).assertTrue(data); expect(true).assertTrue(data);
done();
} }
resolve();
}); });
})
}
await flushCachedGnssLocationsCallback();
done(); done();
}) })
/** /**
* @tc.number SUB_HSS_LocationSystem_Batching_0006 * @tc.number SUB_HSS_LocationSystem_Batching_0600
* @tc.name Test flushCachedGnssLocations * @tc.name Test flushCachedGnssLocations
* @tc.desc Obtain the GNSS data of the current batching. * @tc.desc Obtain the GNSS data of the current batching.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('SUB_HSS_LocationSystem_Batching_0006', 0, async function (done) { it('SUB_HSS_LocationSystem_Batching_0600', 0, async function (done) {
var cachedLocationsCb = (locations) => { var cachedLocationsCb = (locations) => {
console.log('cachedGnssLocationsReporting: locations: ' + JSON.stringify(locations)); console.log('cachedGnssLocationsReporting: locations: ' + JSON.stringify(locations));
expect(true).assertEqual(locations !=null); expect(true).assertEqual(locations !=null);
...@@ -1157,14 +1174,14 @@ describe('geolocationTest_geo3', function () { ...@@ -1157,14 +1174,14 @@ describe('geolocationTest_geo3', function () {
}) })
/** /**
* @tc.number SUB_HSS_LocationSystem_GeoFence_0001 * @tc.number SUB_HSS_LocationSystem_GeoFence_0100
* @tc.name Test fenceStatusChange * @tc.name Test fenceStatusChange
* @tc.desc Gnss fence function test * @tc.desc Gnss fence function test
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 1 * @tc.level Level 1
*/ */
it('SUB_HSS_LocationSystem_GeoFence_0001', 0, async function (done) { it('SUB_HSS_LocationSystem_GeoFence_0100', 0, async function (done) {
await changedLocationMode(); await changedLocationMode();
let geofence = {"latitude": 31.12, "longitude": 121.11, "radius": 1,"expiration": ""}; let geofence = {"latitude": 31.12, "longitude": 121.11, "radius": 1,"expiration": ""};
let geofenceRequest = {"priority":0x200, "scenario":0x301, "geofence": geofence}; let geofenceRequest = {"priority":0x200, "scenario":0x301, "geofence": geofence};
...@@ -1194,14 +1211,14 @@ describe('geolocationTest_geo3', function () { ...@@ -1194,14 +1211,14 @@ describe('geolocationTest_geo3', function () {
}) })
/** /**
* @tc.number SUB_HSS_LocationSystem_GeoFence_0005 * @tc.number SUB_HSS_LocationSystem_GeoFence_0500
* @tc.name Test fenceStatusChange * @tc.name Test fenceStatusChange
* @tc.desc Test the function of locating the validity period of the fence. * @tc.desc Test the function of locating the validity period of the fence.
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 1 * @tc.level Level 1
*/ */
it('SUB_HSS_LocationSystem_GeoFence_0005', 0, async function (done) { it('SUB_HSS_LocationSystem_GeoFence_0500', 0, async function (done) {
await changedLocationMode(); await changedLocationMode();
let geofence = {"latitude": 31.12, "longitude": 121.11, "radius": 1,"expiration": ""}; let geofence = {"latitude": 31.12, "longitude": 121.11, "radius": 1,"expiration": ""};
let geofenceRequest = {"priority":0x203, "scenario":0x301, "geofence": geofence}; let geofenceRequest = {"priority":0x203, "scenario":0x301, "geofence": geofence};
......
...@@ -83,14 +83,14 @@ describe('geolocationTest_geo2', function () { ...@@ -83,14 +83,14 @@ describe('geolocationTest_geo2', function () {
}) })
/** /**
* @tc.number SUB_HSS_LocationSystem_systemapi_0001 * @tc.number SUB_HSS_LocationSystem_systemapi_0100
* @tc.name Test getLocation * @tc.name Test getLocation
* @tc.desc Obtains the geographical location of a device.. * @tc.desc Obtains the geographical location of a device..
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('SUB_HSS_LocationSystem_systemapi_0001', 0, async function (done) { it('SUB_HSS_LocationSystem_systemapi_0100', 0, async function (done) {
geolocations.getLocation({ geolocations.getLocation({
timeout:30000, timeout:30000,
coordType:'wgs84', coordType:'wgs84',
...@@ -127,14 +127,14 @@ describe('geolocationTest_geo2', function () { ...@@ -127,14 +127,14 @@ describe('geolocationTest_geo2', function () {
}) })
/** /**
* @tc.number SUB_HSS_LocationSystem_systemapi_0002 * @tc.number SUB_HSS_LocationSystem_systemapi_0200
* @tc.name Test subscribe and unsubscribe * @tc.name Test subscribe and unsubscribe
* @tc.desc Test subscribe api . * @tc.desc Test subscribe 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_systemapi_0002', 0, async function (done) { it('SUB_HSS_LocationSystem_systemapi_0200', 0, async function (done) {
geolocations.subscribe({ geolocations.subscribe({
coordType:'wgs84', coordType:'wgs84',
success: function(data) { success: function(data) {
...@@ -152,14 +152,14 @@ describe('geolocationTest_geo2', function () { ...@@ -152,14 +152,14 @@ describe('geolocationTest_geo2', function () {
}) })
/** /**
* @tc.number SUB_HSS_LocationSystem_systemapi_0003 * @tc.number SUB_HSS_LocationSystem_systemapi_0300
* @tc.name test getLocationType * @tc.name test getLocationType
* @tc.desc Subscribing to geographical location information . * @tc.desc Subscribing to geographical location information .
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('SUB_HSS_LocationSystem_systemapi_0003', 0, async function (done) { it('SUB_HSS_LocationSystem_systemapi_0300', 0, async function (done) {
geolocations.getLocationType({ geolocations.getLocationType({
success: function(data) { success: function(data) {
console.log('success get location type:' + JSON.stringify(data)); console.log('success get location type:' + JSON.stringify(data));
...@@ -178,14 +178,14 @@ describe('geolocationTest_geo2', function () { ...@@ -178,14 +178,14 @@ describe('geolocationTest_geo2', function () {
}) })
/** /**
* @tc.number SUB_HSS_LocationSystem_systemapi_0004 * @tc.number SUB_HSS_LocationSystem_systemapi_0400
* @tc.name Test getSupportedCoordTypes * @tc.name Test getSupportedCoordTypes
* @tc.desc Obtains the geographical location of a device.. * @tc.desc Obtains the geographical location of a device..
* @tc.size MEDIUM * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('SUB_HSS_LocationSystem_systemapi_0004', 0, function () { it('SUB_HSS_LocationSystem_systemapi_0400', 0, function () {
let types = geolocations.getSupportedCoordTypes(); let types = geolocations.getSupportedCoordTypes();
console.info('[lbs_js] getSupportedCoordTypes result: ' + JSON.stringify(types)); console.info('[lbs_js] getSupportedCoordTypes result: ' + JSON.stringify(types));
expect(true).assertEqual(types.length !=0); expect(true).assertEqual(types.length !=0);
...@@ -197,9 +197,3 @@ describe('geolocationTest_geo2', function () { ...@@ -197,9 +197,3 @@ describe('geolocationTest_geo2', function () {
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册