From 6a34aec6267fe46a4010da9da814597d0f700529 Mon Sep 17 00:00:00 2001 From: quanli Date: Thu, 3 Aug 2023 17:50:48 +0800 Subject: [PATCH] quanli1@huawei.com Signed-off-by: quanli --- .../src/main/js/test/BluetoothHfp.test.js | 2 +- .../src/main/js/test/BtA2dp.test.js | 11 ++-- .../src/main/js/test/BtConnection.test.js | 48 +++++++++++++-- .../src/main/js/test/BtDiscovery.test.js | 20 ++++-- .../signature/openharmony_sx.p7b | Bin 4195 -> 3899 bytes .../wifi_ErrorCode201/src/main/config.json | 58 ++++++++++++++++++ .../main/js/test/ActWifiErrorCode201.test.js | 5 +- .../main/js/test/ActWifiErrorCode202.test.js | 2 +- .../main/js/test/ActWifiErrorCode401.test.js | 2 +- 9 files changed, 130 insertions(+), 18 deletions(-) diff --git a/communication/bluetooth_profile/src/main/js/test/BluetoothHfp.test.js b/communication/bluetooth_profile/src/main/js/test/BluetoothHfp.test.js index bd9f5f45b..c95bd8550 100644 --- a/communication/bluetooth_profile/src/main/js/test/BluetoothHfp.test.js +++ b/communication/bluetooth_profile/src/main/js/test/BluetoothHfp.test.js @@ -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(); diff --git a/communication/bluetooth_profile/src/main/js/test/BtA2dp.test.js b/communication/bluetooth_profile/src/main/js/test/BtA2dp.test.js index 443cee28f..94c504599 100644 --- a/communication/bluetooth_profile/src/main/js/test/BtA2dp.test.js +++ b/communication/bluetooth_profile/src/main/js/test/BtA2dp.test.js @@ -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: diff --git a/communication/bluetooth_scanpairing/src/main/js/test/BtConnection.test.js b/communication/bluetooth_scanpairing/src/main/js/test/BtConnection.test.js index 5d1ce1ec7..5ce6a936c 100644 --- a/communication/bluetooth_scanpairing/src/main/js/test/BtConnection.test.js +++ b/communication/bluetooth_scanpairing/src/main/js/test/BtConnection.test.js @@ -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(); }) diff --git a/communication/bluetooth_scanpairing/src/main/js/test/BtDiscovery.test.js b/communication/bluetooth_scanpairing/src/main/js/test/BtDiscovery.test.js index ef7569c1b..db3f32301 100644 --- a/communication/bluetooth_scanpairing/src/main/js/test/BtDiscovery.test.js +++ b/communication/bluetooth_scanpairing/src/main/js/test/BtDiscovery.test.js @@ -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() { diff --git a/communication/wifi_ErrorCode201/signature/openharmony_sx.p7b b/communication/wifi_ErrorCode201/signature/openharmony_sx.p7b index 0c7c439059f1776e982ee2f1fefb737b6a97ec3d..179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@3EQ=6WX32>LL(urCw172%J!u?&CTh6QX;ek3=ZMjs4A07fn%^ zOCV@UF==`a?|B`L6Ye%UYTO;&hm^+}qjFg@XzZ+v`e+y8i;{?|W1IGD2E#ahm-hDV zKk1ZSBYUMM{L>%!T*c+~~%q7Yj4vx8KE|-k%AX+RAF3I-6%Vt}oA@egpqHV$-J3 S?6(^O;F9j4?dBK5oz*}4BLBhw diff --git a/communication/wifi_ErrorCode201/src/main/config.json b/communication/wifi_ErrorCode201/src/main/config.json index ecfcad1e1..02fbe003c 100644 --- a/communication/wifi_ErrorCode201/src/main/config.json +++ b/communication/wifi_ErrorCode201/src/main/config.json @@ -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": { diff --git a/communication/wifi_ErrorCode201/src/main/js/test/ActWifiErrorCode201.test.js b/communication/wifi_ErrorCode201/src/main/js/test/ActWifiErrorCode201.test.js index ff9ec976e..43e6403cd 100644 --- a/communication/wifi_ErrorCode201/src/main/js/test/ActWifiErrorCode201.test.js +++ b/communication/wifi_ErrorCode201/src/main/js/test/ActWifiErrorCode201.test.js @@ -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) { diff --git a/communication/wifi_ErrorCode202/src/main/js/test/ActWifiErrorCode202.test.js b/communication/wifi_ErrorCode202/src/main/js/test/ActWifiErrorCode202.test.js index 8e22d2cb2..912af07c4 100644 --- a/communication/wifi_ErrorCode202/src/main/js/test/ActWifiErrorCode202.test.js +++ b/communication/wifi_ErrorCode202/src/main/js/test/ActWifiErrorCode202.test.js @@ -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; diff --git a/communication/wifi_ErrorCode401/src/main/js/test/ActWifiErrorCode401.test.js b/communication/wifi_ErrorCode401/src/main/js/test/ActWifiErrorCode401.test.js index ef7fcba40..edd35ab56 100644 --- a/communication/wifi_ErrorCode401/src/main/js/test/ActWifiErrorCode401.test.js +++ b/communication/wifi_ErrorCode401/src/main/js/test/ActWifiErrorCode401.test.js @@ -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; -- GitLab