提交 9087f1cd 编写于 作者: Q quanli

quanli1@huawei.com

Signed-off-by: Nquanli <quanli1@huawei.com>
上级 e2e70bf9
......@@ -21,6 +21,7 @@ group("communication") {
"bluetooth_on:ActsBluetoothOnJsTest",
"bluetooth_profile:ActsBluetoothProFileJsTest",
"bluetooth_standard:ActsBluetoothJsTest",
"bluetooth_switchoff:ActsBluetoothSwitchTest",
"dsoftbus/rpc:ActsRpcJsTest",
"nfc_Controller:ActsNFCJSTest",
"nfc_ErrorCode:ActsNFCErrorJSTest",
......
......@@ -15,6 +15,13 @@
],
"type": "AppInstallKit",
"cleanup-apps": true
},
{
"type": "ShellKit",
"run-command": [
"hilog -Q pidoff",
"svc bluetooth enable"
]
}
]
}
\ No newline at end of file
......@@ -16,8 +16,8 @@
"package": "ohos.acts.communication.bluetooth.bluetoothhost",
"name": ".entry",
"deviceType": [
"tablet",
"default",
"tablet",
"default",
"phone"
],
"distro": {
......@@ -116,6 +116,10 @@
"when": "inuse"
}
},
{
"name": "ohos.permission.GRANT_SENSITIVE_PERMISSIONS",
"reason": "use ohos.permission.GRANT_SENSITIVE_PERMISSIONS"
},
{
"name": "ohos.permission.LOCATION",
"reason": "",
......
......@@ -15,6 +15,13 @@
],
"type": "AppInstallKit",
"cleanup-apps": true
},
{
"type": "ShellKit",
"run-command": [
"hilog -Q pidoff",
"svc bluetooth enable"
]
}
]
}
\ No newline at end of file
......@@ -106,6 +106,10 @@
"when": "inuse"
}
},
{
"name": "ohos.permission.GRANT_SENSITIVE_PERMISSIONS",
"reason": "use ohos.permission.GRANT_SENSITIVE_PERMISSIONS"
},
{
"name": "ohos.permission.DISCOVER_BLUETOOTH",
"reason": "",
......
......@@ -17,6 +17,7 @@
import bluetooth from '@ohos.bluetoothManager';
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '@ohos/hypium'
export default function bluetoothBLETest2() {
describe('bluetoothBLETest2', function() {
let gattServer = null;
......@@ -50,12 +51,13 @@ describe('bluetoothBLETest2', function() {
}
beforeAll(async function (done) {
console.info('beforeAll called')
await tryToEnableBt()
gattServer = bluetooth.BLE.createGattServer();
done()
})
beforeEach(async function (done) {
console.info('beforeEach called')
await tryToEnableBt();
await tryToEnableBt()
done()
})
......
......@@ -14,9 +14,11 @@
* limitations under the License.
*/
//import bluetooth from '@ohos.bluetooth';
import bluetooth from '@ohos.bluetoothManager';
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '@ohos/hypium'
export default function bluetoothBLETest5() {
describe('bluetoothBLETest5', function() {
let gattServer = null;
......@@ -50,12 +52,13 @@ describe('bluetoothBLETest5', function() {
}
beforeAll(async function (done) {
console.info('beforeAll called')
await tryToEnableBt()
gattServer = bluetooth.BLE.createGattServer();
done()
})
beforeEach(async function (done) {
console.info('beforeEach called')
await tryToEnableBt();
await tryToEnableBt()
done()
})
afterEach(function () {
......
......@@ -48,7 +48,7 @@ describe('bluetoothBLETest', function() {
console.info('[bluetooth_js] enable success');
}
}
beforeAll(function() {
beforeAll(function () {
console.info('beforeAll called')
gattServer = bluetooth.BLE.createGattServer();
gattClient = bluetooth.BLE.createGattClientDevice("11:22:33:44:55:66");
......
......@@ -13,6 +13,7 @@
* limitations under the License.
*/
//import bluetooth from '@ohos.bluetooth';
import bluetooth from '@ohos.bluetoothManager';
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '@ohos/hypium'
......@@ -47,7 +48,7 @@ describe('bluetoothBLETest4', function() {
console.info('[bluetooth_js] enable success');
}
}
beforeAll(function() {
beforeAll(function () {
console.info('beforeAll called')
gattClient = bluetooth.BLE.createGattClientDevice("11:22:33:44:55:66");
})
......
......@@ -15,30 +15,6 @@
import bluetooth from '@ohos.bluetoothManager';
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '@ohos/hypium'
import abilityAccessCtrl from '@ohos.abilityAccessCtrl'
import bundle from '@ohos.bundle'
import osaccount from '@ohos.account.osAccount'
async function applyPermission() {
let osAccountManager = osaccount.getAccountManager();
console.info("=== getAccountManager finish");
let localId = await osAccountManager.getOsAccountLocalIdFromProcess();
console.info("LocalId is :" + localId);
let appInfo = await bundle.getApplicationInfo('ohos.acts.communication.bluetooth.bluetoothhost', 0, localId);
let atManager = abilityAccessCtrl.createAtManager();
if (atManager != null) {
let tokenID = appInfo.accessTokenId;
console.info('[permission] case accessTokenID is ' + tokenID);
let permissionName1 = 'ohos.permission.LOCATION';
await atManager.grantUserGrantedPermission(tokenID, permissionName1, 2).then((result) => {
console.info('[permission] case grantUserGrantedPermission success :' + JSON.stringify(result));
}).catch((err) => {
console.info('[permission] case grantUserGrantedPermission failed :' + JSON.stringify(err));
});
} else {
console.info('[permission] case apply permission failed, createAtManager failed');
}
}
export default function bluetoothBLETest6() {
describe('bluetoothBLETest6', function() {
......@@ -72,13 +48,12 @@ describe('bluetoothBLETest6', function() {
console.info('[bluetooth_js] enable success');
}
}
beforeAll(async function(done) {
beforeAll(function () {
console.info('beforeAll called')
await applyPermission();
})
beforeEach(async function(done) {
console.info('beforeEach called')
await tryToEnableBt();
await tryToEnableBt()
done()
})
afterEach(function () {
......@@ -320,50 +295,6 @@ describe('bluetoothBLETest6', function() {
})
/**
* @tc.number COMMUNICATION_BLUETOOTH_BLE_Scan_0800
* @tc.name testClassicStartBLEScan
* @tc.desc Test ClassicStartBLEScan api.
* @tc.size MEDIUM
* @ since 7
* @tc.type Function
* @tc.level Level 3
*/
it('COMMUNICATION_BLUETOOTH_BLE_Scan_0800', 0, async function (done) {
try {
bluetooth.disableBluetooth();
await sleep(3000);
let state = bluetooth.getState();
console.info('[bluetooth_js] bt turn off1:'+ JSON.stringify(state));
function onReceiveEvent(data)
{
console.info('[bluetooth_js] BLEscan device result8'+JSON.stringify(data));
expect(true).assertTrue(data.length=0);
}
bluetooth.BLE.on("BLEDeviceFind", onReceiveEvent)
bluetooth.BLE.startBLEScan(
[{}],
{
interval: 100,
dutyMode: bluetooth.ScanDuty.SCAN_MODE_LOW_POWER,
matchMode: bluetooth.MatchMode.MATCH_MODE_AGGRESSIVE,
}
);
await sleep(1000);
expect(true).assertFalse();
console.info('[bluetooth_js] BLE scan off8');
bluetooth.BLE.off('BLEDeviceFind', onReceiveEvent);
bluetooth.BLE.stopBLEScan();
done();
} catch (error) {
console.error('[bluetooth_js]Scan_0800 error.code:'+JSON.stringify(error.code)+
'error.message:'+JSON.stringify(error.message));
expect(error.code).assertEqual('2900003');
done()
}
})
/**
* @tc.number COMMUNICATION_BLUETOOTH_BLE_Scan_0700
* @tc.name testClassicStartBLEScan
......@@ -816,7 +747,6 @@ describe('bluetoothBLETest6', function() {
done()
}
})
})
}
......@@ -22,10 +22,8 @@ let BluetoothState = {
STATE_BLE_TURNING_ON: 4, STATE_BLE_ON: 5,
STATE_BLE_TURNING_OFF: 6
};
let SppOption = {uuid: '00001810-0000-1000-8000-00805F9B34FB',
secure: true, type: bluetooth.SppType.SPP_RFCOMM};
let MajorMinorClass = {
COMPUTER_UNCATEGORIZED : 0x0100,COMPUTER_DESKTOP : 0x0104,
COMPUTER_SERVER : 0x0108,COMPUTER_LAPTOP : 0x010C,
......@@ -76,7 +74,6 @@ let MajorMinorClass = {
HEALTH_PERSONAL_MOBILITY_DEVICE : 0x093C,
HEALTH_PEAK_FLOW_MONITOR : 0x0928
};
let MajorClass = {
MAJOR_MISC : 0x0000,MAJOR_COMPUTER : 0x0100,
MAJOR_PHONE : 0x0200,MAJOR_NETWORKING : 0x0300,
......@@ -92,7 +89,6 @@ let ProfileId = {
PROFILE_HID_HOST: 6,
PROFILE_PAN_NETWORK: 7
};
export default function bluetoothBLETest1() {
describe('bluetoothBLETest1', function() {
......@@ -128,13 +124,14 @@ describe('bluetoothBLETest1', function() {
}
beforeAll(async function (done) {
console.info('beforeAll called')
await tryToEnableBt()
gattServer = bluetooth.BLE.createGattServer();
gattClient = bluetooth.BLE.createGattClientDevice("11:22:33:44:55:66");
done()
})
beforeEach(async function(done) {
console.info('beforeEach called')
await tryToEnableBt();
await tryToEnableBt()
done()
})
afterEach(function () {
......
......@@ -18,7 +18,6 @@ import bluetoothBLETest4 from './BleGattManager401.test.js'
import bluetoothBLETest1 from './BleService.test.js'
import bluetoothBLETest2 from './BleAdvertiser.test.js'
import bluetoothBLETest5 from './BleAdvertiser401.test.js'
import bluetoothBLETest3 from './SwitchOff003.test.js'
import bluetoothBLETest6 from './BleScanResult.test.js'
export default function testsuite() {
bluetoothBLETest()
......@@ -26,6 +25,5 @@ bluetoothBLETest1()
bluetoothBLETest2()
bluetoothBLETest4()
bluetoothBLETest5()
bluetoothBLETest3()
bluetoothBLETest6()
}
......@@ -15,6 +15,13 @@
],
"type": "AppInstallKit",
"cleanup-apps": true
},
{
"type": "ShellKit",
"run-command": [
"hilog -Q pidoff",
"svc bluetooth enable"
]
}
]
}
......@@ -16,8 +16,8 @@
"package": "ohos.acts.communication.bluetooth.bluetoothhost",
"name": ".entry",
"deviceType": [
"tablet",
"default",
"tablet",
"default",
"phone"
],
"distro": {
......@@ -96,6 +96,10 @@
"when": "inuse"
}
},
{
"name": "ohos.permission.GRANT_SENSITIVE_PERMISSIONS",
"reason": "use ohos.permission.GRANT_SENSITIVE_PERMISSIONS"
},
{
"name": "ohos.permission.MANAGE_BLUETOOTH",
"reason": "",
......
......@@ -15,37 +15,6 @@
import bluetooth from '@ohos.bluetooth';
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '@ohos/hypium'
import osaccount from '@ohos.account.osAccount'
import bundle from '@ohos.bundle'
import abilityAccessCtrl from '@ohos.abilityAccessCtrl'
async function applyPermission() {
let osAccountManager = osaccount.getAccountManager();
console.info("=== getAccountManager finish");
let localId = await osAccountManager.getOsAccountLocalIdFromProcess();
console.info("LocalId is :" + localId);
let appInfo = await bundle.getApplicationInfo('ohos.acts.communication.bluetooth.bluetoothhost', 0, localId);
let atManager = abilityAccessCtrl.createAtManager();
if (atManager != null) {
let tokenID = appInfo.accessTokenId;
console.info('[permission] case accessTokenID is ' + tokenID);
let permissionName1 = 'ohos.permission.LOCATION';
let permissionName2 = 'ohos.permission.DISCOVER_BLUETOOTH';
await atManager.grantUserGrantedPermission(tokenID, permissionName1, 1).then((result) => {
console.info('[permission] case grantUserGrantedPermission success :' + JSON.stringify(result));
}).catch((err) => {
console.info('[permission] case grantUserGrantedPermission failed :' + JSON.stringify(err));
});
await atManager.grantUserGrantedPermission(tokenID, permissionName2, 1).then((result) => {
console.info('[permission] case grantUserGrantedPermission success :' + JSON.stringify(result));
}).catch((err) => {
console.info('[permission] case grantUserGrantedPermission failed :' + JSON.stringify(err));
});
} else {
console.info('[permission] case apply permission failed, createAtManager failed');
}
}
export default function bluetoothhostTest() {
describe('bluetoothhostTest', function() {
......@@ -79,8 +48,7 @@ describe('bluetoothhostTest', function() {
console.info('[bluetooth_js] enable success');
}
}
beforeAll(async function (done) {
await applyPermission();
beforeAll(function () {
console.info('beforeAll called')
})
beforeEach(async function(done) {
......@@ -280,41 +248,6 @@ describe('bluetoothhostTest', function() {
done();
})
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BLE_Scan_0800
* @tc.name testClassicStartBLEScan
* @tc.desc Test ClassicStartBLEScan api.
* @tc.size MEDIUM
* @ since 7
* @tc.type Function
* @tc.level Level 3
*/
it('SUB_COMMUNICATION_BLUETOOTH_BLE_Scan_0800', 0, async function (done) {
bluetooth.disableBluetooth();
await sleep(3000);
let state = bluetooth.getState();
console.info('[bluetooth_js] bt turn off1:'+ JSON.stringify(state));
function onReceiveEvent(data)
{
console.info('[bluetooth_js] BLEscan device result8'+JSON.stringify(data));
expect(true).assertTrue(data.length=0);
}
bluetooth.BLE.on("BLEDeviceFind", onReceiveEvent)
bluetooth.BLE.startBLEScan(
[{}],
{
interval: 100,
dutyMode: bluetooth.ScanDuty.SCAN_MODE_LOW_POWER,
matchMode: bluetooth.MatchMode.MATCH_MODE_AGGRESSIVE,
}
);
await sleep(1000);
console.info('[bluetooth_js] BLE scan off8');
bluetooth.BLE.off('BLEDeviceFind', onReceiveEvent);
bluetooth.BLE.stopBLEScan();
done();
})
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BLE_Scan_0700
* @tc.name testClassicStartBLEScan
......@@ -642,8 +575,6 @@ describe('bluetoothhostTest', function() {
bluetooth.BLE.stopBLEScan();
done()
})
})
}
......
......@@ -16,6 +16,7 @@
import bluetooth from '@ohos.bluetooth';
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '@ohos/hypium'
export default function bluetoothhostTest2() {
describe('bluetoothhostTest2', function() {
function sleep(delay) {
......@@ -48,7 +49,7 @@ describe('bluetoothhostTest2', function() {
console.info('[bluetooth_js] enable success');
}
}
beforeAll(async function (done) {
beforeAll(function () {
console.info('beforeAll called')
})
beforeEach(async function(done) {
......
......@@ -14,12 +14,12 @@
*/
import bluetoothhostTest from './BleScanResult.test.js'
import bluetoothhostTest2 from './BluetoothPair.test.js'
import bluetoothhostTest4 from './bluetoothSys.test.js'
import bluetoothhostTest from './BleScanResult.test.js'
export default function testsuite() {
bluetoothhostTest()
bluetoothhostTest2()
bluetoothhostTest4()
bluetoothhostTest()
}
......@@ -16,36 +16,6 @@
import bluetooth from '@ohos.bluetooth';
import bluetoothsys from '@system.bluetooth';
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '@ohos/hypium'
import osaccount from '@ohos.account.osAccount'
import bundle from '@ohos.bundle'
import abilityAccessCtrl from '@ohos.abilityAccessCtrl'
async function applyPermission() {
let osAccountManager = osaccount.getAccountManager();
console.info("=== getAccountManager finish");
let localId = await osAccountManager.getOsAccountLocalIdFromProcess();
console.info("LocalId is :" + localId);
let appInfo = await bundle.getApplicationInfo('ohos.acts.communication.bluetooth.bluetoothhost', 0, localId);
let atManager = abilityAccessCtrl.createAtManager();
if (atManager != null) {
let tokenID = appInfo.accessTokenId;
console.info('[permission] case accessTokenID is ' + tokenID);
let permissionName1 = 'ohos.permission.LOCATION';
let permissionName2 = 'ohos.permission.DISCOVER_BLUETOOTH';
await atManager.grantUserGrantedPermission(tokenID, permissionName1, 1).then((result) => {
console.info('[permission] case grantUserGrantedPermission success :' + JSON.stringify(result));
}).catch((err) => {
console.info('[permission] case grantUserGrantedPermission failed :' + JSON.stringify(err));
});
await atManager.grantUserGrantedPermission(tokenID, permissionName2, 1).then((result) => {
console.info('[permission] case grantUserGrantedPermission success :' + JSON.stringify(result));
}).catch((err) => {
console.info('[permission] case grantUserGrantedPermission failed :' + JSON.stringify(err));
});
} else {
console.info('[permission] case apply permission failed, createAtManager failed');
}
}
export default function bluetoothhostTest4() {
describe('bluetoothhostTest4', function() {
......@@ -79,8 +49,7 @@ describe('bluetoothhostTest4', function() {
console.info('[bluetooth_js] enable success');
}
}
beforeAll(async function (done) {
await applyPermission();
beforeAll(function () {
console.info('beforeAll called')
})
beforeEach(async function(done) {
......
......@@ -15,6 +15,13 @@
],
"type": "AppInstallKit",
"cleanup-apps": true
},
{
"type": "ShellKit",
"run-command": [
"hilog -Q pidoff",
"svc bluetooth enable"
]
}
]
}
......@@ -16,8 +16,8 @@
"package": "ohos.acts.communication.bluetooth.bluetoothhost",
"name": ".entry",
"deviceType": [
"tablet",
"default",
"tablet",
"default",
"phone"
],
"distro": {
......@@ -106,6 +106,10 @@
"when": "inuse"
}
},
{
"name": "ohos.permission.GRANT_SENSITIVE_PERMISSIONS",
"reason": "use ohos.permission.GRANT_SENSITIVE_PERMISSIONS"
},
{
"name": "ohos.permission.DISCOVER_BLUETOOTH",
"reason": "",
......
......@@ -15,6 +15,13 @@
],
"type": "AppInstallKit",
"cleanup-apps": true
},
{
"type": "ShellKit",
"run-command": [
"hilog -Q pidoff",
"svc bluetooth enable"
]
}
]
}
......@@ -97,14 +97,8 @@
}
},
{
"name": "ohos.permission.DISCOVER_BLUETOOTH'",
"reason": "",
"usedScene": {
"ability": [
"ohos.acts.communication.bluetooth.bluetoothhost.MainAbility"
],
"when": "inuse"
}
"name": "ohos.permission.GRANT_SENSITIVE_PERMISSIONS",
"reason": "use ohos.permission.GRANT_SENSITIVE_PERMISSIONS"
},
{
"name": "ohos.permission.MANAGE_BLUETOOTH",
......
......@@ -14,43 +14,14 @@
*/
import bluetooth from '@ohos.bluetooth';
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '@ohos/hypium'
import abilityAccessCtrl from '@ohos.abilityAccessCtrl'
import bundle from '@ohos.bundle'
import osaccount from '@ohos.account.osAccount'
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '@ohos/hypium'
const PERMISSION_USER_SET = 1;
const PERMISSION_USER_NAME1 = "ohos.permission.LOCATION";
const PERMISSION_USER_NAME2 = 'ohos.permission.LOCATION_IN_BACKGROUND';
let tokenID = undefined;
async function applyPermission() {
let osAccountManager = osaccount.getAccountManager();
console.info("=== getAccountManager finish");
let localId = await osAccountManager.getOsAccountLocalIdFromProcess();
console.info("LocalId is :" + localId);
let appInfo = await bundle.getApplicationInfo('ohos.acts.communication.bluetooth.bluetoothhost', 0, localId);
let atManager = abilityAccessCtrl.createAtManager();
if (atManager != null) {
let tokenID = appInfo.accessTokenId;
console.info('[permission] case accessTokenID is ' + tokenID);
let permissionName1 = 'ohos.permission.LOCATION';
let permissionName2 = 'ohos.permission.DISCOVER_BLUETOOTH';
await atManager.grantUserGrantedPermission(tokenID, permissionName1, 1).then((result) => {
console.info('[permission] case grantUserGrantedPermission success :' + JSON.stringify(result));
}).catch((err) => {
console.info('[permission] case grantUserGrantedPermission failed :' + JSON.stringify(err));
});
await atManager.grantUserGrantedPermission(tokenID, permissionName2, 1).then((result) => {
console.info('[permission] case grantUserGrantedPermission success :' + JSON.stringify(result));
}).catch((err) => {
console.info('[permission] case grantUserGrantedPermission failed :' + JSON.stringify(err));
});
} else {
console.info('[permission] case apply permission failed, createAtManager failed');
}
}
async function grantPerm() {
console.info("====grant Permission start====");
let appInfo = await bundle.getApplicationInfo('ohos.acts.communication.bluetooth.bluetoothhost', 0, 100);
......@@ -98,7 +69,6 @@ describe('bluetoothhostTest3', function() {
beforeAll(async function (done) {
console.info('beforeAll called')
await applyPermission();
await grantPerm();
done()
})
......
......@@ -47,9 +47,8 @@ describe('bluetoothhostTest2', function() {
console.info('[bluetooth_js] enable success');
}
}
beforeAll(async function (done) {
beforeAll(function () {
console.info('beforeAll called')
done()
})
beforeEach(async function(done) {
console.info('beforeEach called')
......
......@@ -15,7 +15,6 @@
import bluetooth from '@ohos.bluetooth';
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '@ohos/hypium'
let Btname = {
NUM_TEST :'012345678901234567890123456789012345678901234567890123'+
'45678901234567890123456789012345678901234567890123456789012345678901234567',
......@@ -71,9 +70,8 @@ describe('bluetoothhostTest1', function() {
console.info('[bluetooth_js] enable success');
}
}
beforeAll(async function (done) {
beforeAll(function () {
console.info('beforeAll called')
done()
})
beforeEach(async function(done) {
console.info('beforeEach called')
......
......@@ -16,32 +16,6 @@
import bluetooth from '@ohos.bluetooth';
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '@ohos/hypium'
async function applyPermission() {
let osAccountManager = osaccount.getAccountManager();
console.info("=== getAccountManager finish");
let localId = await osAccountManager.getOsAccountLocalIdFromProcess();
console.info("LocalId is :" + localId);
let appInfo = await bundle.getApplicationInfo('ohos.acts.communication.bluetooth.bluetoothhost', 0, localId);
let atManager = abilityAccessCtrl.createAtManager();
if (atManager != null) {
let tokenID = appInfo.accessTokenId;
console.info('[permission] case accessTokenID is ' + tokenID);
let permissionName1 = 'ohos.permission.LOCATION';
let permissionName2 = 'ohos.permission.DISCOVER_BLUETOOTH';
await atManager.grantUserGrantedPermission(tokenID, permissionName1, 1).then((result) => {
console.info('[permission] case grantUserGrantedPermission success :' + JSON.stringify(result));
}).catch((err) => {
console.info('[permission] case grantUserGrantedPermission failed :' + JSON.stringify(err));
});
await atManager.grantUserGrantedPermission(tokenID, permissionName2, 1).then((result) => {
console.info('[permission] case grantUserGrantedPermission success :' + JSON.stringify(result));
}).catch((err) => {
console.info('[permission] case grantUserGrantedPermission failed :' + JSON.stringify(err));
});
} else {
console.info('[permission] case apply permission failed, createAtManager failed');
}
}
export default function bluetoothhostTest4() {
describe('bluetoothhostTest4', function() {
......@@ -73,9 +47,8 @@ describe('bluetoothhostTest4', function() {
console.info('[bluetooth_js] enable success');
}
}
beforeAll(async function (done) {
beforeAll(function () {
console.info('beforeAll called')
done()
})
beforeEach(async function(done) {
console.info('beforeEach called')
......
......@@ -15,7 +15,7 @@
import bluetooth from '@ohos.bluetooth';
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '@ohos/hypium'
let BluetoothState = {
STATE_OFF: 0,STATE_TURNING_ON: 1,
STATE_ON: 2,STATE_TURNING_OFF: 3,
......@@ -54,9 +54,8 @@ describe('bluetoothhostTest', function() {
console.info('[bluetooth_js] enable success');
}
}
beforeAll(async function (done) {
beforeAll(function () {
console.info('beforeAll called')
done()
})
beforeEach(async function(done) {
console.info('beforeEach called')
......@@ -70,42 +69,6 @@ describe('bluetoothhostTest', function() {
console.info('afterAll called')
})
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BR_Switch_0100
* @tc.name testEnableBluetooth and getState
* @tc.desc Test EnableBluetooth api by promise.
* @tc.size MEDIUM
* @ since 7
* @tc.type Function
* @tc.level Level 0
*/
it('SUB_COMMUNICATION_BLUETOOTH_BR_Switch_0100', 0, async function (done) {
function onReceiveEvent(data) {
console.info('bluetooth state001 ='+ JSON.stringify(data));
}
await bluetooth.on('stateChange', onReceiveEvent);
let state = bluetooth.getState();
console.info('[bluetooth_js] get bluetooth state001'+ JSON.stringify(state));
if(state!=bluetooth.BluetoothState.STATE_ON)
{
let enable = bluetooth.enableBluetooth();
await sleep(10000);
console.info('[bluetooth_js] bluetooth enable001'+JSON.stringify(enable));
expect(enable).assertTrue();
let state1 = bluetooth.getState();
console.info('[bluetooth_js] enable state001 '+ JSON.stringify(state1));
expect(state1).assertEqual(bluetooth.BluetoothState.STATE_ON);
}
let disable = bluetooth.disableBluetooth();
await sleep(3000);
console.info('[bluetooth_js] bluetooth disable001'+JSON.stringify(disable));
expect(disable).assertTrue();
let state2 = bluetooth.getState();
console.info('[bluetooth_js] disable state001 '+ JSON.stringify(state2));
expect(state2).assertEqual(bluetooth.BluetoothState.STATE_OFF);
await bluetooth.off('stateChange', onReceiveEvent);
done()
})
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BR_Switch_0300
......@@ -136,31 +99,32 @@ describe('bluetoothhostTest', function() {
})
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BR_Switch_0400
* @tc.name testEnableBluetooth
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BR_Switch_0100
* @tc.name testEnableBluetooth and getState
* @tc.desc Test EnableBluetooth api by promise.
* @tc.size MEDIUM
* @ since 7
* @tc.type Function
* @tc.level Level 3
* @tc.level Level 0
*/
it('SUB_COMMUNICATION_BLUETOOTH_BR_Switch_0400', 0, async function (done) {
let result1= bluetooth.disableBluetooth();
await sleep(3000);
console.info('[bluetooth_js] disable result'+ JSON.stringify(result1));
expect(result1).assertTrue();
it('SUB_COMMUNICATION_BLUETOOTH_BR_Switch_0100', 0, async function (done) {
function onReceiveEvent(data) {
console.info('bluetooth state001 ='+ JSON.stringify(data));
}
await bluetooth.on('stateChange', onReceiveEvent);
let state = bluetooth.getState();
console.info('[bluetooth_js] getState1 off = '+ JSON.stringify(state));
expect(state).assertEqual(bluetooth.BluetoothState.STATE_OFF);
if(state == bluetooth.BluetoothState.STATE_OFF) {
let result2= bluetooth.disableBluetooth();
console.info('[bluetooth_js]disable result1'+ JSON.stringify(result2));
expect(result2).assertFalse();
console.info('[bluetooth_js] get bluetooth state001'+ JSON.stringify(state));
if(state!=bluetooth.BluetoothState.STATE_ON)
{
let enable = bluetooth.enableBluetooth();
await sleep(10000);
console.info('[bluetooth_js] bluetooth enable001'+JSON.stringify(enable));
expect(enable).assertTrue();
let state1 = bluetooth.getState();
console.info('[bluetooth_js] getState4 off = '+ JSON.stringify(state1));
expect(state1).assertEqual(bluetooth.BluetoothState.STATE_OFF);
console.info('[bluetooth_js] enable state001 '+ JSON.stringify(state1));
expect(state1).assertEqual(bluetooth.BluetoothState.STATE_ON);
}
done();
done()
})
})
}
......
......@@ -13,15 +13,16 @@
* limitations under the License.
*/
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'
import bluetoothhostTest from './BRSwitch.test.js'
export default function testsuite() {
bluetoothhostTest()
bluetoothhostTest1()
bluetoothhostTest2()
bluetoothhostTest3()
bluetoothhostTest4()
bluetoothhostTest()
}
# Copyright (C) 2021 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("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("ActsBluetoothSwitchTest") {
hap_profile = "./src/main/config.json"
deps = [
":bluetooth_js_assets",
":bluetooth_resources",
]
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "ActsBluetoothSwitchHapTest"
part_name = "bluetooth"
subsystem_name = "communication"
}
ohos_js_assets("bluetooth_js_assets") {
js2abc = true
hap_profile = "./src/main/config.json"
source_dir = "./src/main/js"
}
ohos_resources("bluetooth_resources") {
sources = [ "./src/main/resources" ]
hap_profile = "./src/main/config.json"
}
{
"description": "Configuration for bluetooth js api Tests",
"driver": {
"type": "OHJSUnitTest",
"test-timeout": "600000",
"shell-timeout": "600000",
"bundle-name": "ohos.acts.communication.bluetooth.bluetoothhost",
"package-name": "ohos.acts.communication.bluetooth.bluetoothhost",
"testcase-timeout": 70000
},
"kits": [
{
"test-file-name": [
"ActsBluetoothSwitchHapTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
},
{
"type": "ShellKit",
"run-command": [
"hilog -Q pidoff",
"svc bluetooth disable"
]
}
]
}
\ No newline at end of file
{
"app": {
"bundleName": "ohos.acts.communication.bluetooth.bluetoothhost",
"vendor": "acts",
"version": {
"code": 1000000,
"name": "1.0.0"
},
"apiVersion": {
"compatible": 4,
"target": 5
}
},
"deviceConfig": {},
"module": {
"package": "ohos.acts.communication.bluetooth.bluetoothhost",
"name": ".entry",
"deviceType": [
"tablet",
"default",
"phone"
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "entry",
"moduleType": "entry"
},
"abilities": [
{
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"orientation": "unspecified",
"formsEnabled": false,
"name": ".MainAbility",
"srcLanguage": "js",
"srcPath": "MainAbility",
"icon": "$media:icon",
"description": "$string:MainAbility_desc",
"label": "$string:MainAbility_label",
"type": "page",
"visible": true,
"launchType": "standard"
},
{
"orientation": "unspecified",
"formsEnabled": false,
"name": ".TestAbility",
"srcLanguage": "js",
"srcPath": "TestAbility",
"icon": "$media:icon",
"description": "$string:TestAbility_desc",
"label": "$string:TestAbility_label",
"type": "page",
"visible": true,
"launchType": "standard"
}
],
"js": [
{
"pages": [
"pages/index/index"
],
"name": "default",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
},
{
"pages": [
"pages/index/index"
],
"name": ".TestAbility",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
}
],
"reqPermissions": [
{
"name": "ohos.permission.USE_BLUETOOTH",
"reason": "",
"usedScene": {
"ability": [
"ohos.acts.communication.bluetooth.bluetoothhost.MainAbility"
],
"when": "inuse"
}
},
{
"name": "ohos.permission.MANAGE_BLUETOOTH",
"reason": "",
"usedScene": {
"ability": [
"ohos.acts.communication.bluetooth.bluetoothhost.MainAbility"
],
"when": "inuse"
}
},
{
"name": "ohos.permission.GRANT_SENSITIVE_PERMISSIONS",
"reason": "use ohos.permission.GRANT_SENSITIVE_PERMISSIONS"
},
{
"name": "ohos.permission.DISCOVER_BLUETOOTH",
"reason": "",
"usedScene": {
"ability": [
"ohos.acts.communication.bluetooth.bluetoothhost.MainAbility"
],
"when": "inuse"
}
},
{
"name": "ohos.permission.LOCATION",
"reason": "",
"usedScene": {
"ability": [
"ohos.acts.communication.bluetooth.bluetoothhost.MainAbility"
],
"when": "inuse"
}
}
],
"testRunner": {
"name": "OpenHarmonyTestRunner",
"srcPath": "TestRunner"
},
"mainAbility": ".MainAbility",
"srcPath": ""
}
}
\ No newline at end of file
/*
* Copyright (C) 2021 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.
*/
export default {
onCreate() {
console.info('AceApplication onCreate');
},
onDestroy() {
console.info('AceApplication onDestroy');
}
};
{
"strings": {
"hello": "Hello",
"world": "World"
}
}
\ No newline at end of file
{
"strings": {
"hello": "您好",
"world": "世界"
}
}
\ No newline at end of file
/*
* 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.
*/
.container {
flex-direction: column;
justify-content: center;
align-items: center;
}
.title {
font-size: 100px;
}
/*
* 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.
*/
<div class="container">
<text class="title">
{{ $t('strings.hello') }} {{ title }}
</text>
</div>
/*
* 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.
*/
export default {
data: {
title: ""
},
onInit() {
this.title = this.$t('strings.world');
},
onShow() {
console.info('onShow finish')
},
onReady() {
console.info('onReady finish')
},
}
/*
* 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 AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
import { Hypium } from '@ohos/hypium'
import testsuite from '../test/List.test'
export default {
onCreate() {
console.info('TestApplication onCreate')
var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
console.info('start run testcase!!!')
Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)
},
onDestroy() {
console.info("TestApplication onDestroy");
}
};
{
"strings": {
"hello": "Hello",
"world": "World"
},
"Files": {
}
}
\ No newline at end of file
{
"strings": {
"hello": "您好",
"world": "世界"
},
"Files": {
}
}
\ No newline at end of file
.container {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
left: 0px;
top: 0px;
width: 100%;
height: 100%;
}
.title {
font-size: 60px;
text-align: center;
width: 100%;
height: 40%;
margin: 10px;
}
@media screen and (device-type: phone) and (orientation: landscape) {
.title {
font-size: 60px;
}
}
@media screen and (device-type: tablet) and (orientation: landscape) {
.title {
font-size: 100px;
}
}
\ No newline at end of file
<div class="container">
<text class="title">
{{ $t('strings.hello') }} {{ title }}
</text>
</div>
/*
* 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.
*/
export default {
data: {
title: ""
},
onInit() {
this.title = this.$t('strings.world');
}
}
/*
* 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 AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
function translateParamsToString(parameters) {
const keySet = new Set([
'-s class', '-s notClass', '-s suite', '-s itName',
'-s level', '-s testType', '-s size', '-s timeout',
'-s package', '-s dryRun'
])
let targetParams = '';
for (const key in parameters) {
if (keySet.has(key)) {
targetParams += ' ' + key + ' ' + parameters[key]
}
}
return targetParams.trim()
}
export default {
onPrepare() {
console.info('OpenHarmonyTestRunner OnPrepare')
},
onRun() {
console.log('OpenHarmonyTestRunner onRun run')
var abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var testAbilityName = abilityDelegatorArguments.parameters['-p'] + '.TestAbility'
var cmd = 'aa start -d 0 -a ' + testAbilityName + ' -b ' + abilityDelegatorArguments.bundleName
cmd += ' ' + translateParamsToString(abilityDelegatorArguments.parameters)
var debug = abilityDelegatorArguments.parameters["-D"]
console.info('debug value : '+debug)
if (debug == 'true')
{
cmd += ' -D'
}
console.info('cmd : '+cmd)
abilityDelegator.executeShellCommand(cmd, (err, data) => {
console.info('executeShellCommand : err : ' + JSON.stringify(err));
console.info('executeShellCommand : data : ' + data.stdResult);
console.info('executeShellCommand : data : ' + data.exitCode);
})
}
};
/*
* Copyright (C) 2021 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 bluetoothBLETest3 from './SwitchOff003.test.js'
export default function testsuite() {
bluetoothBLETest3()
}
{
"string": [
{
"name": "app_name",
"value": "OsAccountTest"
},
{
"name": "mainability_description",
"value": "JS_Phone_Empty Feature Ability"
},
{
"name": "MainAbility_desc",
"value": "description"
},
{
"name": "MainAbility_label",
"value": "label"
},
{
"name": "TestAbility_desc",
"value": "description"
},
{
"name": "TestAbility_label",
"value": "label"
}
]
}
\ No newline at end of file
......@@ -34,6 +34,21 @@ let aTag = {
],
"tagRfDiscId": 1,
};
let isoDepTaginfo = {
"uid": [0x01, 0x02, 0x03, 0x04],
"technology": [1, 3],
"extrasData": [
{
"Sak": 0x08, "Atqa": "B000",
},
{
"HistoricalBytes": "4D54000500308693695B", "HiLayerResponse": "",
},
],
"tagRfDiscId": 1,
};
let getAtag = null ;
export default function nfcATagSessionTest() {
......@@ -230,7 +245,7 @@ export default function nfcATagSessionTest() {
done();
}).catch((err)=> {
console.info("[NFC_test] tagsession7 nfcAtage sendData1 err: " + err);
expect().assertFail();
expect(3100201).assertEqual(error.code)
done();
});
sleep(3500);
......@@ -408,9 +423,58 @@ export default function nfcATagSessionTest() {
expect().assertFail();
}
})
/**
* @tc.number SUB_Communication_NFC_nfcAtage_js_1500
* @tc.name isConnected
* @tc.desc Test isConnected api.
* @tc.size MEDIUM
* @ since 7
* @tc.type Function
* @tc.level Level 2
*/
it('SUB_Communication_NFC_nfcAtage_js_1500', 0, function () {
if (getAtag != null && getAtag != undefined) {
try {
let istagConnected = tag.getIsoDep(isoDepTaginfo).isConnected();
console.info("[NFC_test] tagsession15 isConnected:" + istagConnected);
expect(istagConnected).assertFalse();
} catch (error) {
console.info('[NFC_test] tagsession15 isConnected error' + error)
console.info('[NFC_test] tagsession15 isConnected errorcode' + error.code)
expect().assertFail();
}
} else {
console.info("[NFC_test]getAtag14 = null & = undefined: ");
expect().assertFail();
}
})
/**
* @tc.number SUB_Communication_NFC_nfcAtage_js_0160
* @tc.name connect
* @tc.desc Test connect api.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it('SUB_Communication_NFC_nfcAtage_js_0160', 0, function () {
if (getAtag != null && getAtag != undefined) {
let NfcConnect;
try {
getAtag.connect();
console.log("[NFC_test] tagsession16 NfcConnected pass");
expect(true).assertTrue();
} catch (error) {
console.log('[NFC_test] tagsession16 NfcConnected error' + error);
expect(3100201).assertEqual(error.code)
}
} else {
console.log("[NFC_test]getAtag1 = null & = undefined: ");
expect().assertFail();
}
})
console.info("*************[nfc_test] start nfc js unit test end*************");
})
}
}
\ No newline at end of file
......@@ -17,7 +17,8 @@
{
"type": "ShellKit",
"run-command": [
"hilog -Q pidoff"
"hilog -Q pidoff",
"settings put SECURE location_mode 3"
]
}
]
......
......@@ -19,7 +19,8 @@
{
"type": "ShellKit",
"run-command": [
"hilog -Q pidoff"
"hilog -Q pidoff",
"settings put SECURE location_mode 3"
]
}
]
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册