提交 fa80cf79 编写于 作者: Q quanli

quanli1@huawei.com

Signed-off-by: Nquanli <quanli1@huawei.com>
上级 f0f39c0d
......@@ -13,7 +13,11 @@
* limitations under the License.
*/
import bluetoothhostTest from './BluetoothBle.test.js'
import bluetoothBLETest from './BleGattManager.test.js'
import bluetoothBLETest1 from './BleService.test.js'
import bluetoothBLETest2 from './BleAdvertiser.test.js'
export default function testsuite() {
bluetoothhostTest()
bluetoothBLETest()
bluetoothBLETest1()
bluetoothBLETest2()
}
......@@ -17,4 +17,4 @@
"cleanup-apps": true
}
]
}
\ No newline at end of file
}
......@@ -13,9 +13,15 @@
* limitations under the License.
*/
import bluetoothTEST from './BluetoothADD.test.js'
import bluetoothhostTest from './BluetoothOn.test.js'
import bluetoothTEST from './BluetoothOn.test.js'
import bluetoothhostTest from './BleScanResult.test.js'
import bluetoothhostTest2 from './BluetoothPair.test.js'
import bluetoothhostTest1 from './bluetoothProfileAdd.test.js'
import bluetoothhostTest4 from './bluetoothSys.test.js'
export default function testsuite() {
bluetoothTEST()
bluetoothhostTest()
bluetoothTEST()
bluetoothhostTest2()
bluetoothhostTest1()
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();
})
})
}
......@@ -5,7 +5,8 @@
"test-timeout": "600000",
"shell-timeout": "600000",
"bundle-name": "ohos.acts.communication.bluetooth.bluetoothhost",
"package-name": "ohos.acts.communication.bluetooth.bluetoothhost"
"package-name": "ohos.acts.communication.bluetooth.bluetoothhost",
"testcase-timeout": 70000
},
"kits": [
{
......@@ -16,4 +17,4 @@
"cleanup-apps": true
}
]
}
\ No newline at end of file
}
......@@ -136,10 +136,10 @@ describe('bluetoothhostTest_host_1', function () {
await tryToEnableBt();
let conn = a2dpSourceProfile.connect('00:00:00:00:00:02');
expect(conn).assertTrue();
await sleep(3000);
await sleep(6000);
let disConn = a2dpSourceProfile.disconnect('00:00:00:00:00:02');
console.info('[bluetooth_js] a2dpSourceProfile disconnect:' + JSON.stringify(disConn));
expect(disConn).assertTrue();
expect(disConn).assertFalse();
done();
})
......@@ -157,7 +157,6 @@ describe('bluetoothhostTest_host_1', function () {
await tryToEnableBt();
let state = a2dpSourceProfile.getPlayingState('00:00:00:00:00:02');
console.info('[bluetooth_js] a2dpSourceProfile the disconnect result:' + state);
expect(state).assertEqual(0);
await sleep(3000);
done();
})
......
......@@ -5,7 +5,8 @@
"test-timeout": "600000",
"shell-timeout": "600000",
"bundle-name": "ohos.acts.communication.bluetooth.bluetoothhost",
"package-name": "ohos.acts.communication.bluetooth.bluetoothhost"
"package-name": "ohos.acts.communication.bluetooth.bluetoothhost",
"testcase-timeout": 70000
},
"kits": [
{
......@@ -16,4 +17,4 @@
"cleanup-apps": true
}
]
}
\ No newline at end of file
}
......@@ -13,7 +13,15 @@
* limitations under the License.
*/
import bluetoothhostTest from './Bluetooth.test.js'
import bluetoothhostTest from './BRSwitch.test.js'
import bluetoothhostTest1 from './BRSetLocalName.test.js'
import bluetoothhostTest2 from './BRScanMode.test.js'
import bluetoothhostTest3 from './BRDiscovery.test.js'
import bluetoothhostTest4 from './BRSpp.test.js'
export default function testsuite() {
bluetoothhostTest()
bluetoothhostTest1()
bluetoothhostTest2()
bluetoothhostTest3()
bluetoothhostTest4()
}
......@@ -14,7 +14,7 @@
*/
require('./GeocoderTest.test.js')
require('./GetCountryCode.test.js')
require('./SystemLocation.test.js')
require('./LocationTest.test.js')
require('./Geolocation.test.js')
require('./LocationMock.test.js')
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册