提交 09859d49 编写于 作者: Q quanli 提交者: 权力
上级 46bb5b4b
......@@ -119,11 +119,11 @@ describe('bluetoothBLETest', function() {
console.info('[bluetooth_js] gattClient getrssi2 connect' + JSON.stringify(ret))
expect(ret).assertTrue();
await gattClient.getRssiValue().then((data) => {
console.info('[bluetooth_js] BLE read rssi ' + JSON.stringify(data));
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);
}).catch(error => {
console.info('bluetooth getRssiValue has error: '+ JSON.stringify(error));
expect(true).assertEqual(true);
});
let disconnect = gattClient.disconnect();
......@@ -146,15 +146,17 @@ describe('bluetoothBLETest', function() {
let ret = gattClient.connect();
console.info('[bluetooth_js] gattClient getRssi connect' + JSON.stringify(ret))
expect(ret).assertTrue();
gattClient.getRssiValue((err, data)=> {
console.info('[bluetooth_js]getRssi value:'+JSON.stringify(data));
expect(data).assertNull();
let disconnect = gattClient.disconnect();
console.info('[bluetooth_js] gatt getrssi1 disconnect:' + disconnect);
expect(disconnect).assertEqual(false);
});
await sleep(2000);
done();
let promise = new Promise((resolve) => {
gattClient.getRssiValue((err, data)=> {
console.info('[bluetooth_js]getRssi value:'+JSON.stringify(data));
expect(data).assertNull();
let disconnect = gattClient.disconnect();
console.info('[bluetooth_js] gatt getrssi1 disconnect:' + disconnect);
expect(disconnect).assertEqual(false);
});
resolve()
})
await promise.then(done)
})
/**
......@@ -353,37 +355,40 @@ describe('bluetoothBLETest', function() {
* @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);
it('SUB_COMMUNICATION_BLUETOOTH_BLE_ReadCharacteristic_0100', 0, async function (done) {
let promise = new Promise((resolve) => {
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};
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);
let arrayBufferCCC = new ArrayBuffer(8);
let cccValue = new Uint8Array(arrayBufferCCC);
cccValue[0] = 32;
let characteristic = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
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));
let gattClient = bluetooth.BLE.createGattClientDevice("00:00:00:00:00:00");
gattClient.readCharacteristicValue(characteristic).then((object) => {
if (object != null) {
expect(true).assertEqual(true);
} else {
console.info('[bluetooth_js] readCharacValue promise data:'
+ JSON.stringify(data));
expect(null).assertFail();
}
done();
}).catch(err => {
console.error(`bluetooth readCharacteValue promise has error: ${err}`);
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();
done();
});
resolve()
})
await promise.then(done)
})
/**
......@@ -400,6 +405,7 @@ describe('bluetoothBLETest', function() {
return;
}
console.log('bluetooth characteristic uuid:'+ BLECharacteristic.characteristicUuid);
expect(true).assertEqual(data==null);
let value = new Uint8Array(BLECharacteristic.characteristicValue);
console.log('bluetooth characteristic value: '
+ value[0] +','+ value[1]+','+ value[2]+','+ value[3]);
......@@ -408,7 +414,8 @@ describe('bluetoothBLETest', function() {
let desValue = new Uint8Array(arrayBuffer);
desValue[0] = 11;
let descriptor = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
descriptorUuid: '00001830-0000-1000-8000-00805F9B34FB', descriptorValue:arrayBuffer};
descriptorUuid: '00001830-0000-1000-8000-00805F9B34FB',
descriptorValue:arrayBuffer};
let arrayBufferCCC = new ArrayBuffer(8);
let cccValue = new Uint8Array(arrayBufferCCC);
cccValue[0] = 32;
......@@ -416,9 +423,7 @@ describe('bluetoothBLETest', function() {
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);
gattClient.readCharacteristicValue(characteristic,readCcc);
done()
})
......@@ -435,7 +440,8 @@ describe('bluetoothBLETest', function() {
let desValue = new Uint8Array(arrayBuffer);
desValue[0] = 11;
let descriptor = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
descriptorUuid: '00001830-0000-1000-8000-00805F9B34FB', descriptorValue: arrayBuffer};
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) {
......@@ -443,12 +449,12 @@ describe('bluetoothBLETest', function() {
expect(true).assertEqual(true);
} else {
console.info('[bluetooth_js]readDescriptorValue null:' + JSON.stringify(object));
console.info('[bluetooth_js]readDescripValue null:' + JSON.stringify(object));
expect(null).assertFail();
}
done();
}).catch(error => {
console.error('[bluetooth_js]readDescriptorValue promise error:'+JSON.stringify(error));
}).catch(err => {
console.error('[bluetooth_js]readDescrValue promise err:'+JSON.stringify(err));
expect(true).assertEqual(true);
done();
})
......@@ -466,7 +472,7 @@ describe('bluetoothBLETest', function() {
function readDesc(code, BLEDescriptor) {
if (code.code != 0) {
console.info('[bluetooth_js] descriptor code: ' + BLEDescriptor.descriptorUuid);
return;
expect(true).assertEqual(BLEDescriptor.descriptorUuid==null);
}
console.info('[bluetooth_js] descriptor uuid: ' + BLEDescriptor.descriptorUuid);
let value = new Uint8Array(BLEDescriptor.descriptorValue);
......@@ -479,9 +485,7 @@ describe('bluetoothBLETest', function() {
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);
gattClient.readDescriptorValue(descriptor,readDesc);
done()
})
......@@ -653,6 +657,22 @@ describe('bluetoothBLETest', function() {
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_GattClose_0100', 0, async function (done) {
let gattClient = bluetooth.BLE.createGattClientDevice("11:22:33:44:55:66");
let ret = gattClient.close();
console.info('[bluetooth_js] gattClient close ret:' + ret);
expect(ret).assertEqual(true);
done();
})
})
}
......@@ -226,7 +226,7 @@ describe('bluetoothhostTest2', function() {
bluetooth.BLE.on('pinRequired', PinRequiredParam);
let result = bluetooth.pairDevice("00:00:00:00:00:00");
console.info("[bluetooth_js] onStartpair007 -> " + JSON.stringify(result));
expect(result).assertTrue();
expect(result).assertFalse();
bluetooth.BLE.off('pinRequired', PinRequiredParam);
done()
})
......@@ -248,7 +248,7 @@ describe('bluetoothhostTest2', function() {
bluetooth.BLE.on('pinRequired', PinRequiredParam);
let result = bluetooth.pairDevice("00:00:00:00:00:00");
console.info("[bluetooth_js] onStartpair008 -> " + JSON.stringify(result));
expect(result).assertTrue();
expect(result).assertFalse();
bluetooth.BLE.off('pinRequired', PinRequiredParam);
done()
})
......
......@@ -79,9 +79,10 @@ describe('bluetoothhostTest4', function() {
secure: true, type: SppType.SPP_RFCOMM};
let serverNumber = -1;
function serverSocket(code, number) {
console.log('bluetooth error code: ' + code.code);
if (code.code == 0) {
console.log('bluetooth serverSocket Number: ' + number);
if (code) {
console.log('bluetooth error code: ' + code);
}else{
console.log('bluetooth serverSocket Number:' + JSON.stringify(number));
serverNumber = number;
expect(true).assertEqual(number!=null);
}
......@@ -103,11 +104,12 @@ describe('bluetoothhostTest4', function() {
secure: false, type: 0};
let serverNumber = -1;
function serverSocket(code, number) {
console.log('[bluetooth_js] error code: ' + code.code);
if (code.code == 0) {
console.log('[bluetooth_js] serverSocket Number: ' + number);
serverNumber = number;
expect(true).assertEqual(number!=null);
if (code) {
console.log('[bluetooth_js] error code: ' + code);
}else{
console.log('[bluetooth_js] serverSocket Number: ' + JSON.stringify(number));
serverNumber = number;
expect(true).assertEqual(number!=null);
}
}
bluetooth.sppListen('server1', sppOption, serverSocket);
......@@ -127,12 +129,15 @@ describe('bluetoothhostTest4', function() {
secure: true, type: 0};
let serverNumber = -1;
function serverSocket(code, number) {
console.log('[bluetooth_js] error code: ' + code.code);
if (code.code == 0) {
console.log('[bluetooth_js] serverSocket Number: ' + number);
serverNumber = number;
expect(true).assertEqual(number!=null);
}
if (code) {
console.log('[bluetooth_js] error code: ' + code);
}else{
console.log('[bluetooth_js] serverSocket Number: '+JSON.stringify(number));
serverNumber = number;
expect(true).assertEqual(serverNumber!=null);
}
}
bluetooth.sppListen('server1', sppOption, serverSocket);
done();
......@@ -151,11 +156,14 @@ describe('bluetoothhostTest4', function() {
secure: false, type: 0};
let serverNumber = -1;
function serverSocket(code, number) {
console.log('[bluetooth_js] error code: ' + code.code);
if (code.code == 0) {
console.log('[bluetooth_js] serverSocket Number: ' + number);
serverNumber = number;
expect(true).assertEqual(number!=null);
if (code) {
console.log('[bluetooth_js] error code: ' + code);
}else{
console.log('[bluetooth_js] serverSocket Number:'+ JSON.stringify(number));
serverNumber = number;
expect(true).assertEqual(serverNumber!=null);
}
}
bluetooth.sppListen('server1', sppOption, serverSocket);
......@@ -172,11 +180,13 @@ describe('bluetoothhostTest4', function() {
*/
it('SUB_COMMUNICATION_BLUETOOTH_BR_SPP_0500', 0, async function (done) {
function acceptClientSocket(code, number) {
console.log('[bluetooth_js] error code: ' + code.code);
if (code.code == 0) {
console.log('[bluetooth_js] clientSocket Number: ' + number);
expect(true).assertEqual(number!=null);
}
if (code) {
console.log('[bluetooth_js] error code: ' + code);
}else{
console.log('[bluetooth_js] clientSocket Number:' + JSON.stringify(number));
expect(true).assertEqual(number!=null);
}
}
bluetooth.sppAccept(0, acceptClientSocket);
done();
......@@ -191,13 +201,13 @@ describe('bluetoothhostTest4', function() {
* @tc.level Level 3
*/
it('SUB_COMMUNICATION_BLUETOOTH_BR_SPP_0600', 0, async function (done) {
bluetooth.sppAccept(-1, function(code, clientSocketNumber) {
console.info('[bluetooth_js] code is: ' + code.code);
if (code.code == 0) {
console.log('[bluetooth_js]sppAccept Number:' + clientSocketNumber);
expect(true).assertEqual(clientSocketNumber!=null);
bluetooth.sppAccept(-1, function(code, clientSocketNumber) {
if (code) {
console.info('[bluetooth_js] code is: ' + code);
} else {
expect(true).assertEqual(false);
console.log('[bluetooth_js]sppAccept Number:'
+ JSON.stringify(clientSocketNumber));
expect(true).assertEqual(clientSocketNumber!=null);
}
});
done();
......@@ -215,12 +225,12 @@ describe('bluetoothhostTest4', function() {
let sppOption = {uuid: '00001810-0000-1000-8000-00805F9B34FB',
secure: true, type: 0};
bluetooth.sppConnect('00:11:22:33:44:55', sppOption, function(code, clientSocketNumber) {
console.info('[bluetooth_js] code is: ' + code.code);
if (code.code == 0) {
console.log('[bluetooth_js]sppConnect Number:' + clientSocketNumber);
expect(true).assertEqual(clientSocketNumber!=null);
if (code) {
console.info('[bluetooth_js] code is: ' + code);
} else {
expect(true).assertEqual(false);
console.log('[bluetooth_js]sppConnect Number:'
+ JSON.stringify(clientSocketNumber));
expect(true).assertEqual(clientSocketNumber!=null);
}
});
done();
......@@ -238,12 +248,12 @@ describe('bluetoothhostTest4', function() {
let sppOption = {uuid: '0000',
secure: false, type: 0};
bluetooth.sppConnect('ABC', sppOption, function(code, clientSocketNumber) {
console.info('[bluetooth_js] code is: ' + code.code);
if (code.code == 0) {
console.log('[bluetooth_js]sppConnect Number' + clientSocketNumber);
expect(true).assertEqual(clientSocketNumber!=null);
if (code) {
console.info('[bluetooth_js] code is: ' + code);
} else {
expect(true).assertEqual(false);
console.log('[bluetooth_js]sppConnect Number'
+ JSON.stringify(clientSocketNumber));
expect(true).assertEqual(clientSocketNumber!=null);
}
});
done();
......@@ -261,12 +271,12 @@ describe('bluetoothhostTest4', function() {
let sppOption = {uuid: '00001810-0000-1000-8000-00805F9B34FB',
secure: true, type: 0};
bluetooth.sppConnect('BT', sppOption, function(code, clientSocketNumber) {
console.info('[bluetooth_js] code is: ' + code.code);
if (code.code == 0) {
console.log('[bluetooth_js]sppConnect Number' + clientSocketNumber);
expect(true).assertEqual(clientSocketNumber!=null);
if (code) {
console.info('[bluetooth_js] code is: ' + code);
} else {
expect(true).assertEqual(false);
console.log('[bluetooth_js]sppConnect Number'
+ JSON.stringify(clientSocketNumber));
expect(true).assertEqual(clientSocketNumber!=null);
}
});
done();
......@@ -283,11 +293,14 @@ describe('bluetoothhostTest4', function() {
it('SUB_COMMUNICATION_BLUETOOTH_BR_SPP_1000', 0, async function (done) {
let serverNumber = -1;
function serverSocket(code, number) {
console.log('bluetooth error code: ' + code.code);
if (code.code == 0) {
console.log('bluetooth serverSocket Number: ' + number);
if (code) {
console.log('bluetooth error code: ' + code);
}else{
console.log('bluetooth serverSocket Number:'+ JSON.stringify(number));
serverNumber = number;
expect(true).assertEqual(serverNumber!=null);
}
}
let SppOption = {uuid: '00001810-0000-1000-8000-00805F9B34FB',
secure: true, type: 0};
......@@ -307,13 +320,13 @@ describe('bluetoothhostTest4', function() {
it('SUB_COMMUNICATION_BLUETOOTH_BR_SPP_1100', 0, async function (done) {
let clientNumber = -1;
bluetooth.sppAccept(-1, function(code, clientSocketNumber) {
console.info('[bluetooth_js] code is: ' + code.code);
if (code.code == 0) {
console.log('[bluetooth_js]sppAccept Number:' + clientSocketNumber);
if (code) {
console.info('[bluetooth_js] code is: ' + code);
} else {
console.log('[bluetooth_js]sppAccept Number:'
+ JSON.stringify(clientSocketNumber));
clientNumber =clientSocketNumber;
expect(true).assertEqual(clientSocketNumber!=null);
} else {
expect(true).assertEqual(false);
}
});
bluetooth.sppCloseClientSocket(clientNumber);
......@@ -331,13 +344,13 @@ describe('bluetoothhostTest4', function() {
it('SUB_COMMUNICATION_BLUETOOTH_BR_SPP_1200', 0, async function (done) {
let clientNumber = -1;
bluetooth.sppAccept(-1, function(code, clientSocketNumber) {
console.info('[bluetooth_js] code is: ' + code.code);
if (code.code == 0) {
console.log('[bluetooth_js]sppAccept Number:' + clientSocketNumber);
if (code) {
console.info('[bluetooth_js] code is: ' + code);
} else {
console.log('[bluetooth_js]sppAccept Number:'
+ JSON.stringify(clientSocketNumber));
clientNumber =clientSocketNumber;
expect(true).assertEqual(clientSocketNumber!=null);
} else {
expect(true).assertEqual(false);
}
});
let arrayBuffer = new ArrayBuffer(8);
......
......@@ -888,7 +888,8 @@ describe('geolocationTest_geo3', function () {
' longitude: ' + result.longitude +' altitude: ' + result.altitude
+' accuracy: ' + result.accuracy+' speed: ' + result.speed +
'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);
}).catch((error) => {
console.info("[lbs_js] getLastLocation promise then error:" + JSON.stringify(error));
console.info('[lbs_js] not support now');
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册