未验证 提交 f1650529 编写于 作者: O openharmony_ci 提交者: Gitee

!9869 【xts】【master】蓝牙、wifi流水线问题修改

Merge pull request !9869 from 权力/myfeature1
......@@ -147,7 +147,7 @@ describe('btHfpConnTest', function () {
}
let hfpSrc = bluetooth.getProfile(bluetooth.ProfileId.PROFILE_HANDS_FREE_AUDIO_GATEWAY);
hfpSrc.on('connectionStateChange', StateChangeParam);
await sleep(10000);
await sleep(6000);
let conn = hfpSrc.disconnect('11:22:33:44:55:66');
console.info('[bluetooth_js]hfp disconnect result:' + JSON.stringify(conn));
expect(conn).assertFalse();
......
......@@ -14,6 +14,7 @@
*/
import bluetooth from '@ohos.bluetooth.a2dp';
import btAccess from '@ohos.bluetooth.access';
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '@ohos/hypium'
export default function btA2dpTest() {
......@@ -24,12 +25,12 @@ describe('btA2dpTest', function() {
}
async function tryToEnableBt() {
let sta = bluetooth.getState();
let sta = btAccess.getState();
switch (sta) {
case 0:
bluetooth.enableBluetooth();
btAccess.enableBluetooth();
await sleep(10000);
let sta1 = bluetooth.getState();
let sta1 = btAccess.getState();
console.info('[bluetooth_js] bt turn off:' + JSON.stringify(sta1));
break;
case 1:
......@@ -40,9 +41,9 @@ describe('btA2dpTest', function() {
console.info('[bluetooth_js] bt turn on:' + JSON.stringify(sta));
break;
case 3:
bluetooth.enableBluetooth();
btAccess.enableBluetooth();
await sleep(10000);
let sta2 = bluetooth.getState();
let sta2 = btAccess.getState();
console.info('[bluetooth_js] bt turning off:' + JSON.stringify(sta2));
break;
default:
......
......@@ -84,7 +84,7 @@ describe('btConnectionTest', function() {
bluetooth.on('pinRequired', onReceiveEvent);
bluetooth.off('pinRequired', onReceiveEvent);
} catch (error) {
console.error(`[bluetooth_js]PairDevice error, code is ${error.code},
console.error(`[bluetooth_js]pinRequired error, code is ${error.code},
message is ${error.message}`);
expect(error.code).assertEqual('2900099');
}
......@@ -130,8 +130,8 @@ describe('btConnectionTest', function() {
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTHCONNECTION_PAIR_0400
* @tc.name Test On pair StateChange
* @tc.desc Test bondStateChange ON api10
* @tc.name Test pairDevice callback
* @tc.desc Test pairDevice callback api10
* @tc.type Function
* @tc.level Level 3
*/
......@@ -142,15 +142,21 @@ describe('btConnectionTest', function() {
}
try {
bluetooth.on('bondStateChange', BondStateParam);
bluetooth.pairDevice("11:22:55:66:33:44");
bluetooth.pairDevice("11:22:55:66:33:44", err => {
if (err) {
console.info('pairDevice errCode: ' + err.code + ', errMessage: ' + err.message);
}
console.info('pairDevice, err: ' + JSON.stringify(err));
});
bluetooth.off('bondStateChange', BondStateParam);
expect(bluetooth.BondState.BOND_STATE_INVALID == 0).assertTrue();
expect(bluetooth.BondState.BOND_STATE_BONDING == 1).assertTrue();
expect(bluetooth.BondState.BOND_STATE_BONDED == 2).assertTrue();
bluetooth.off('bondStateChange', BondStateParam);
} catch (err) {
console.error("errCode:" + err.code + ",errMessage:" + err.message);
expect(error.code).assertEqual('2900099');
}
bluetooth.off('bondStateChange', BondStateParam);
done();
})
......@@ -238,6 +244,37 @@ describe('btConnectionTest', function() {
done();
})
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTHCONNECTION_PAIR_0900
* @tc.name Test pairDevice promise
* @tc.desc Test pairDevice promise api10
* @tc.type Function
* @tc.level Level 3
*/
it('SUB_COMMUNICATION_BLUETOOTHCONNECTION_PAIR_0900', 0, async function (done) {
function BondStateParam(data) {
console.info("[bluetooth_js] bondStateChange on:" + JSON.stringify(data)
+'bondStateChange deviceId:' + data.deviceId + 'bondStateChange state:' + data.state);
}
try {
bluetooth.on('bondStateChange', BondStateParam);
bluetooth.pairDevice("11:22:55:66:33:44").then((data) => {
console.info('pairDevice info success');
}, err => {
console.info('pairDevice:errCode' + err.code + ', errMessage: ' + err.message);
});
bluetooth.off('bondStateChange', BondStateParam);
expect(bluetooth.BondState.BOND_STATE_INVALID == 0).assertTrue();
expect(bluetooth.BondState.BOND_STATE_BONDING == 1).assertTrue();
expect(bluetooth.BondState.BOND_STATE_BONDED == 2).assertTrue();
} catch (err) {
console.error("errCode:" + err.code + ",errMessage:" + err.message);
expect(error.code).assertEqual('2900099');
}
bluetooth.off('bondStateChange', BondStateParam);
done();
})
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTHCONNECTION_SCANMODE_0100
* @tc.name TEST scanmode
......@@ -335,6 +372,7 @@ describe('btConnectionTest', function() {
console.error(`[bluetooth_js]bluetoothDeviceFin error, code is ${error.code},message is ${error.message}`);
expect(error.code).assertEqual('2900099');
}
bluetooth.off('bluetoothDeviceFind', onReceiveEvent);
done();
})
......
......@@ -28,10 +28,22 @@ async function grantPerm() {
tokenID = appInfo.accessTokenId;
console.info("accessTokenId" + appInfo.accessTokenId + " bundleName:" + appInfo.bundleName);
let atManager = abilityAccessCtrl.createAtManager();
let result = await atManager.grantUserGrantedPermission(tokenID, PERMISSION_USER_NAME1, PERMISSION_USER_SET);
console.info("tokenId" + tokenID + " result:" + result);
let result1 = await atManager.grantUserGrantedPermission(tokenID, PERMISSION_USER_NAME2, PERMISSION_USER_SET);
console.info("tokenId" + tokenID + " result1:" + result1);
if (atManager != null) {
await atManager.grantUserGrantedPermission(tokenID, PERMISSION_USER_NAME1, PERMISSION_USER_SET).then((result) => {
console.info('[permission] case grantUserGrantedPermission success :' + JSON.stringify(result));
console.info("tokenId" + tokenID + " result:" + result);
}).catch((err) => {
console.info('[permission] case grantUserGrantedPermission failed :' + JSON.stringify(err));
});
await atManager.grantUserGrantedPermission(tokenID, PERMISSION_USER_NAME2, PERMISSION_USER_SET).then((results) => {
console.info('[permission] case grantUserGrantedPermission success :' + JSON.stringify(results));
console.info("tokenId" + tokenID + " result:" + results);
}).catch((error) => {
console.info('[permission] case grantUserGrantedPermission failed :' + JSON.stringify(error));
});
} else {
console.info('[permission] case apply permission failed, createAtManager failed');
}
console.info("====grant Permission end====");
}
export default function btDiscoveryTest() {
......
......@@ -122,6 +122,64 @@
{
"name": "ohos.permission.GET_NFC_INFO",
"reason": "use ohos.permission.GET_NFC_INFO"
},
{
"name": "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED",
"reason": "use ohos.permission.GET_BUNDLE_INFO_PRIVILEGED"
},
{
"name": "ohos.permission.LOCATION",
"reason": "need use ohos.permission.LOCATION",
"usedScene": {
"ability": [
"ohos.acts.location.geolocation.function.MainAbility"
],
"when": "inuse"
}
},
{
"name": "ohos.permission.ACCESS_LOCATION",
"reason": "need use ohos.permission.ACCESS_LOCATION",
"usedScene": {
"ability": [
"ohos.acts.location.geolocation.function.MainAbility"
],
"when": "inuse"
}
},
{
"name": "ohos.permission.LOCATION_IN_BACKGROUND",
"reason": "need use ohos.permission.LOCATION_IN_BACKGROUND",
"usedScene": {
"ability": [
"ohos.acts.location.geolocation.function.MainAbility"
],
"when": "inuse"
}
},
{
"name": "ohos.permission.MANAGE_SECURE_SETTINGS",
"reason": "need use ohos.permission.MANAGE_SECURE_SETTINGS",
"usedScene": {
"ability": [
"ohos.acts.location.geolocation.function.MainAbility"
],
"when": "inuse"
}
},
{
"name": "ohos.permission.GRANT_SENSITIVE_PERMISSIONS",
"reason": "use ohos.permission.GRANT_SENSITIVE_PERMISSIONS"
},
{
"name": "ohos.permission.REVOKE_SENSITIVE_PERMISSIONS",
"reason": "use ohos.permission.REVOKE_SENSITIVE_PERMISSIONS"
},
{
"name": "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED"
},
{
"name": "ohos.permission.GET_BUNDLE_INFO"
}
],
"testRunner": {
......
......@@ -26,7 +26,7 @@ async function applyPermission() {
console.info("=== getAccountManager finish");
let localId = await osAccountManager.getOsAccountLocalIdFromProcess();
console.info("LocalId is :" + localId);
let appInfo = await bundle.getApplicationInfo('ohos.acts.communication.wifiMg.wifidevice', 0, localId);
let appInfo = await bundle.getApplicationInfo('ohos.acts.communication.wifi.wifidevice', 0, localId);
let atManager = abilityAccessCtrl.createAtManager();
if (atManager != null) {
let tokenID = appInfo.accessTokenId;
......@@ -40,6 +40,9 @@ async function applyPermission() {
} else {
console.info('[permission] case apply permission failed, createAtManager failed');
}
}
function sleep(delay) {
......
......@@ -26,7 +26,7 @@ async function applyPermission() {
console.info("=== getAccountManager finish");
let localId = await osAccountManager.getOsAccountLocalIdFromProcess();
console.info("LocalId is :" + localId);
let appInfo = await bundle.getApplicationInfo('ohos.acts.communication.wifiMg.wifidevice', 0, localId);
let appInfo = await bundle.getApplicationInfo('ohos.acts.communication.wifi.wifidevice', 0, localId);
let atManager = abilityAccessCtrl.createAtManager();
if (atManager != null) {
let tokenID = appInfo.accessTokenId;
......
......@@ -26,7 +26,7 @@ async function applyPermission() {
console.info("=== getAccountManager finish");
let localId = await osAccountManager.getOsAccountLocalIdFromProcess();
console.info("LocalId is :" + localId);
let appInfo = await bundle.getApplicationInfo('ohos.acts.communication.wifiMg.wifidevice', 0, localId);
let appInfo = await bundle.getApplicationInfo('ohos.acts.communication.wifi.wifidevice', 0, localId);
let atManager = abilityAccessCtrl.createAtManager();
if (atManager != null) {
let tokenID = appInfo.accessTokenId;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册