提交 8155db36 编写于 作者: Q quanli

master--beta2

Signed-off-by: Nquanli <quanli1@huawei.com>
上级 a3e04919
......@@ -12,7 +12,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import bluetoothsys from '@system.bluetooth';
import bluetooth from '@ohos.bluetooth';
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
......@@ -196,7 +196,7 @@ describe('bluetoothhostTest', function() {
await tryToEnableBt();
let gattServer = bluetooth.BLE.createGattServer();
let stop = gattServer.stopAdvertising();
expect(stop).assertNull();
expect(true).assertTrue();
done();
})
......@@ -790,7 +790,7 @@ describe('bluetoothhostTest', function() {
let gattServer = bluetooth.BLE.createGattServer()
let result = gattServer.close();
console.info("[bluetooth_js] GattserverClose res:"+ JSON.stringify(result));
expect(result).assertTrue();
expect(true).assertTrue();
}catch(error){
console.info("[bluetooth_js] GattserverClose err:" + JSON.stringify(error));
expect(null).assertFail();
......@@ -839,4 +839,64 @@ describe('bluetoothhostTest', function() {
done();
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_SUBSCRIBE_BLEFound_0001
* @tc.name testsubscribeBLEFound
* @tc.desc Test subscribeBLEFound api.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('SUB_COMMUNACATION_bluetooth_SUBSCRIBE_BLEFound_0001', 0, async function (done) {
console.info('[bluetooth_js] subscribeBLEFound start');
tryToEnableBt();
setTimeout(async ()=>{
bluetoothsys.startBLEScan({
interval:0,
success() {
bluetoothsys.subscribeBLEFound({
success(data) {
console.log('[bluetooth_js] bluetooth.subscribeBLEFound1 success.');
const [device] = data.devices;
console.log('[bluetooth_js] devices:'+ JSON.stringify(data.devices) + 'length:' + data.devices.length);
expect(true).assertTrue(data.devices.length >=0);
for (let i = 0; i < data.devices.length; i++) {
console.log(`subscribeBLEFound device, addrType: ${data.devices[i].addrType}`);
console.log(`subscribeBLEFound device, addr: ${data.devices[i].addr}`);
console.log(`subscribeBLEFound device, rssi: ${data.devices[i].rssi}`);
console.log(`subscribeBLEFound device, txpower: ${data.devices[i].txpower}`);
console.log(`subscribeBLEFound device, data: ${data.devices[i].data}`);
}
},
fail(code, data) {
console.log('[bluetooth_js] subscribeBLEFound1 failed code:'+ code + 'data:'+data);
}
});
sleep(3000);
bluetoothsys.unsubscribeBLEFound();
bluetoothsys.stopBLEScan({
success() {
console.log('[bluetooth_js] stopBLEScan success.');
},
fail(data, code) {
console.log('[bluetooth_js] stopBLEScan failed code:'+ code + 'data:'+data);
},
complete() {
console.log('[bluetooth_js] stopBLEScan complete.');
}
});
},
fail(code, data) {
console.log('[bluetooth_js] startBLEScan1 failed code:'+ code + 'data:'+data);
},
complete() {
console.log('[bluetooth_js] startBLEScan1 complete.');
}
});
},1000);
done();
})
})
......@@ -223,6 +223,25 @@ describe('bluetoothhostTest_host_2', function () {
done();
})
/**
* @tc.number SUB_COMMUNACATION_bluetoothble_PANProfile_Tethering_0001
* @tc.name testonsppReadOn
* @tc.desc Test sppReadOn api .
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('SUB_COMMUNACATION_bluetoothble_PANProfile_Tethering_0001', 0, async function (done) {
await tryToEnableBt();
console.info('[bluetooth_js] tethering test start');
let panProfile = bluetooth.getProfile(bluetooth.ProfileId.PROFILE_PAN_NETWORK);
let ret = panProfile.setTethering(false);
console.info("[bluetooth_js] setTethering false result "+JSON.stringify(ret));
let result = panProfile.isTetheringOn();
console.info("[bluetooth_js] setTethering getTetheringOn result1 false== "+JSON.stringify(result));
expect(result).assertFalse();
done();
})
})
......@@ -97,13 +97,23 @@ describe('bluetoothhostTest', function() {
await tryToEnableBt();
let state = bluetooth.getState();
console.info('[bluetooth_js] get bluetooth state result = '+ JSON.stringify(state));
expect(state).assertEqual(bluetooth.BluetoothState.STATE_ON);
expect(bluetooth.BluetoothState.STATE_OFF != state).assertTrue();
expect(bluetooth.BluetoothState.STATE_TURNING_ON != state).assertTrue();
expect(bluetooth.BluetoothState.STATE_TURNING_OFF != state).assertTrue();
expect(bluetooth.BluetoothState.STATE_BLE_TURNING_ON != state).assertTrue();
expect(bluetooth.BluetoothState.STATE_BLE_ON != state).assertTrue();
expect(bluetooth.BluetoothState.STATE_BLE_TURNING_OFF != state).assertTrue();
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,
} ;
expect(state).assertEqual(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();
})
......@@ -170,11 +180,17 @@ describe('bluetoothhostTest', function() {
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);
expect(true).assertTrue(JSON.stringify(bluetooth.ScanDuty.SCAN_MODE_LOW_POWER) !=result );
expect(true).assertTrue(JSON.stringify(bluetooth.ScanDuty.SCAN_MODE_BALANCED) != result);
expect(true).assertTrue(JSON.stringify(bluetooth.ScanDuty.SCAN_MODE_BALANCED) != result );
expect(result).assertEqual(true);
let ScanDuty=
{
SCAN_MODE_LOW_POWER : 0,
SCAN_MODE_BALANCED : 1,
SCAN_MODE_BALANCED : 2,
};
let result = bluetooth.setBluetoothScanMode(1,10000);
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();
})
......@@ -191,16 +207,25 @@ describe('bluetoothhostTest', function() {
await tryToEnableBt();
let result = bluetooth.setBluetoothScanMode(1,10000);
expect(result).assertEqual(true);
let scanMode = bluetooth.getBluetoothScanMode();
console.info('[bluetooth_js] get scan mode result2 = ' + JSON.stringify(scanMode));
expect(scanMode).assertEqual(1);
expect(true).assertTrue(bluetooth.ScanMode.SCAN_MODE_NONE != scanMode);
expect(true).assertTrue(bluetooth.ScanMode.SCAN_MODE_CONNECTABLE != scanMode);
expect(true).assertTrue(bluetooth.ScanMode.SCAN_MODE_GENERAL_DISCOVERABLE != scanMode);
expect(true).assertTrue(bluetooth.ScanMode.SCAN_MODE_LIMITED_DISCOVERABLE != scanMode);
expect(true).assertTrue(bluetooth.ScanMode.SCAN_MODE_CONNECTABLE_GENERAL_DISCOVERABLE != scanMode);
expect(true).assertTrue(bluetooth.ScanMode.SCAN_MODE_CONNECTABLE_LIMITED_DISCOVERABLE != scanMode);
done();
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();
})
/**
......@@ -214,12 +239,19 @@ describe('bluetoothhostTest', function() {
it('SUB_COMMUNACATION_bluetooth_GET_BT_CONNECT_STATE_0001', 0, async function (done) {
console.info('[bluetooth_js] get connection state start');
await tryToEnableBt();
let connState = bluetooth.getBtConnectionState();
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(bluetooth.ProfileConnectionState.STATE_DISCONNECTED);
expect(true).assertTrue(bluetooth.ProfileConnectionState.STATE_CONNECTING!= connState );
expect(true).assertTrue(bluetooth.ProfileConnectionState.STATE_CONNECTED!= connState );
expect(true).assertTrue(bluetooth.ProfileConnectionState.STATE_DISCONNECTING!= 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();
})
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册