Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
45338c7d
X
Xts Acts
项目概览
OpenHarmony
/
Xts Acts
1 年多 前同步成功
通知
9
Star
22
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
X
Xts Acts
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
45338c7d
编写于
3月 22, 2023
作者:
O
openharmony_ci
提交者:
Gitee
3月 22, 2023
浏览文件
操作
浏览文件
下载
差异文件
!8114 【communication】【XTS脚本优化】bt优化脚本
Merge pull request !8114 from 权力/myfeature
上级
de46f207
2bec4351
变更
20
显示空白变更内容
内联
并排
Showing
20 changed file
with
755 addition
and
48 deletion
+755
-48
communication/bluetooth_ble/src/main/js/test/BleAdvertiser.test.js
...tion/bluetooth_ble/src/main/js/test/BleAdvertiser.test.js
+33
-2
communication/bluetooth_ble/src/main/js/test/BleGattManager.test.js
...ion/bluetooth_ble/src/main/js/test/BleGattManager.test.js
+33
-2
communication/bluetooth_ble/src/main/js/test/BleService.test.js
...ication/bluetooth_ble/src/main/js/test/BleService.test.js
+33
-2
communication/bluetooth_manager/src/main/js/test/BleAdvertiser.test.js
.../bluetooth_manager/src/main/js/test/BleAdvertiser.test.js
+33
-2
communication/bluetooth_manager/src/main/js/test/BleAdvertiser401.test.js
...uetooth_manager/src/main/js/test/BleAdvertiser401.test.js
+33
-2
communication/bluetooth_manager/src/main/js/test/BleGattManager.test.js
...bluetooth_manager/src/main/js/test/BleGattManager.test.js
+33
-2
communication/bluetooth_manager/src/main/js/test/BleGattManager401.test.js
...etooth_manager/src/main/js/test/BleGattManager401.test.js
+33
-2
communication/bluetooth_manager/src/main/js/test/BleScanResult.test.js
.../bluetooth_manager/src/main/js/test/BleScanResult.test.js
+33
-2
communication/bluetooth_manager/src/main/js/test/BleService.test.js
...ion/bluetooth_manager/src/main/js/test/BleService.test.js
+108
-2
communication/bluetooth_manager/src/main/js/test/SwitchOff003.test.js
...n/bluetooth_manager/src/main/js/test/SwitchOff003.test.js
+38
-7
communication/bluetooth_on/src/main/js/test/BleScanResult.test.js
...ation/bluetooth_on/src/main/js/test/BleScanResult.test.js
+33
-2
communication/bluetooth_on/src/main/js/test/BluetoothPair.test.js
...ation/bluetooth_on/src/main/js/test/BluetoothPair.test.js
+33
-2
communication/bluetooth_on/src/main/js/test/bluetoothSys.test.js
...cation/bluetooth_on/src/main/js/test/bluetoothSys.test.js
+33
-2
communication/bluetooth_profile/src/main/js/test/BluetoothA2dp.test.js
.../bluetooth_profile/src/main/js/test/BluetoothA2dp.test.js
+39
-2
communication/bluetooth_profile/src/main/js/test/BluetoothHfp.test.js
...n/bluetooth_profile/src/main/js/test/BluetoothHfp.test.js
+33
-2
communication/bluetooth_standard/src/main/js/test/BRDiscovery.test.js
...n/bluetooth_standard/src/main/js/test/BRDiscovery.test.js
+31
-2
communication/bluetooth_standard/src/main/js/test/BRScanMode.test.js
...on/bluetooth_standard/src/main/js/test/BRScanMode.test.js
+33
-2
communication/bluetooth_standard/src/main/js/test/BRSetLocalName.test.js
...luetooth_standard/src/main/js/test/BRSetLocalName.test.js
+33
-2
communication/bluetooth_standard/src/main/js/test/BRSpp.test.js
...ication/bluetooth_standard/src/main/js/test/BRSpp.test.js
+33
-2
communication/bluetooth_standard/src/main/js/test/BRSwitch.test.js
...tion/bluetooth_standard/src/main/js/test/BRSwitch.test.js
+44
-5
未找到文件。
communication/bluetooth_ble/src/main/js/test/BleAdvertiser.test.js
浏览文件 @
45338c7d
...
...
@@ -15,6 +15,11 @@
*/
import
bluetooth
from
'
@ohos.bluetooth
'
;
import
geolocation
from
'
@ohos.geolocation
'
;
import
geolocationm
from
'
@ohos.geoLocationManager
'
;
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
'
...
...
@@ -31,7 +36,7 @@ describe('bluetoothBLETest2', function() {
case
0
:
console
.
info
(
'
[bluetooth_js] bt turn off:
'
+
JSON
.
stringify
(
sta
));
bluetooth
.
enableBluetooth
();
await
sleep
(
3
000
);
await
sleep
(
1
000
);
break
;
case
1
:
console
.
info
(
'
[bluetooth_js] bt turning on:
'
+
JSON
.
stringify
(
sta
));
...
...
@@ -43,12 +48,38 @@ describe('bluetoothBLETest2', function() {
case
3
:
console
.
info
(
'
[bluetooth_js] bt turning off:
'
+
JSON
.
stringify
(
sta
));
bluetooth
.
enableBluetooth
();
await
sleep
(
3
000
);
await
sleep
(
1
000
);
break
;
default
:
console
.
info
(
'
[bluetooth_js] enable success
'
);
}
}
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.location.geolocation.function
'
,
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.LOCATION_IN_BACKGROUND
'
;
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
'
);
}
}
beforeAll
(
function
()
{
console
.
info
(
'
beforeAll called
'
)
gattServer
=
bluetooth
.
BLE
.
createGattServer
();
...
...
communication/bluetooth_ble/src/main/js/test/BleGattManager.test.js
浏览文件 @
45338c7d
...
...
@@ -14,6 +14,11 @@
*/
import
bluetooth
from
'
@ohos.bluetooth
'
;
import
geolocation
from
'
@ohos.geolocation
'
;
import
geolocationm
from
'
@ohos.geoLocationManager
'
;
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
'
export
default
function
bluetoothBLETest
()
{
...
...
@@ -30,7 +35,7 @@ describe('bluetoothBLETest', function() {
case
0
:
console
.
info
(
'
[bluetooth_js] bt turn off:
'
+
JSON
.
stringify
(
sta
));
bluetooth
.
enableBluetooth
();
await
sleep
(
3
000
);
await
sleep
(
10
000
);
break
;
case
1
:
console
.
info
(
'
[bluetooth_js] bt turning on:
'
+
JSON
.
stringify
(
sta
));
...
...
@@ -42,12 +47,38 @@ describe('bluetoothBLETest', function() {
case
3
:
console
.
info
(
'
[bluetooth_js] bt turning off:
'
+
JSON
.
stringify
(
sta
));
bluetooth
.
enableBluetooth
();
await
sleep
(
3
000
);
await
sleep
(
1
000
);
break
;
default
:
console
.
info
(
'
[bluetooth_js] enable success
'
);
}
}
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.location.geolocation.function
'
,
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.LOCATION_IN_BACKGROUND
'
;
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
'
);
}
}
beforeAll
(
function
()
{
console
.
info
(
'
beforeAll called
'
)
gattServer
=
bluetooth
.
BLE
.
createGattServer
();
...
...
communication/bluetooth_ble/src/main/js/test/BleService.test.js
浏览文件 @
45338c7d
...
...
@@ -14,6 +14,11 @@
*/
import
bluetooth
from
'
@ohos.bluetooth
'
;
import
geolocation
from
'
@ohos.geolocation
'
;
import
geolocationm
from
'
@ohos.geoLocationManager
'
;
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
'
export
default
function
bluetoothBLETest1
()
{
...
...
@@ -31,7 +36,7 @@ describe('bluetoothBLETest1', function() {
case
0
:
console
.
info
(
'
[bluetooth_js] bt turn off:
'
+
JSON
.
stringify
(
sta
));
bluetooth
.
enableBluetooth
();
await
sleep
(
3
000
);
await
sleep
(
10
000
);
break
;
case
1
:
console
.
info
(
'
[bluetooth_js] bt turning on:
'
+
JSON
.
stringify
(
sta
));
...
...
@@ -43,12 +48,38 @@ describe('bluetoothBLETest1', function() {
case
3
:
console
.
info
(
'
[bluetooth_js] bt turning off:
'
+
JSON
.
stringify
(
sta
));
bluetooth
.
enableBluetooth
();
await
sleep
(
3
000
);
await
sleep
(
10
000
);
break
;
default
:
console
.
info
(
'
[bluetooth_js] enable success
'
);
}
}
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.location.geolocation.function
'
,
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.LOCATION_IN_BACKGROUND
'
;
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
'
);
}
}
beforeAll
(
function
()
{
console
.
info
(
'
beforeAll called
'
)
gattServer
=
bluetooth
.
BLE
.
createGattServer
();
...
...
communication/bluetooth_manager/src/main/js/test/BleAdvertiser.test.js
浏览文件 @
45338c7d
...
...
@@ -15,6 +15,11 @@
*/
import
bluetooth
from
'
@ohos.bluetoothManager
'
;
import
geolocation
from
'
@ohos.geolocation
'
;
import
geolocationm
from
'
@ohos.geoLocationManager
'
;
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
'
...
...
@@ -31,7 +36,7 @@ describe('bluetoothBLETest2', function() {
case
0
:
console
.
info
(
'
[bluetooth_js] bt turn off:
'
+
JSON
.
stringify
(
sta
));
bluetooth
.
enableBluetooth
();
await
sleep
(
3
000
);
await
sleep
(
10
000
);
break
;
case
1
:
console
.
info
(
'
[bluetooth_js] bt turning on:
'
+
JSON
.
stringify
(
sta
));
...
...
@@ -43,12 +48,38 @@ describe('bluetoothBLETest2', function() {
case
3
:
console
.
info
(
'
[bluetooth_js] bt turning off:
'
+
JSON
.
stringify
(
sta
));
bluetooth
.
enableBluetooth
();
await
sleep
(
3
000
);
await
sleep
(
10
000
);
break
;
default
:
console
.
info
(
'
[bluetooth_js] enable success
'
);
}
}
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.location.geolocation.function
'
,
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.LOCATION_IN_BACKGROUND
'
;
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
'
);
}
}
beforeAll
(
async
function
(
done
)
{
console
.
info
(
'
beforeAll called
'
)
await
tryToEnableBt
()
...
...
communication/bluetooth_manager/src/main/js/test/BleAdvertiser401.test.js
浏览文件 @
45338c7d
...
...
@@ -16,6 +16,11 @@
//import bluetooth from '@ohos.bluetooth';
import
bluetooth
from
'
@ohos.bluetoothManager
'
;
import
geolocation
from
'
@ohos.geolocation
'
;
import
geolocationm
from
'
@ohos.geoLocationManager
'
;
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
'
...
...
@@ -32,7 +37,7 @@ describe('bluetoothBLETest5', function() {
case
0
:
console
.
info
(
'
[bluetooth_js] bt turn off:
'
+
JSON
.
stringify
(
sta
));
bluetooth
.
enableBluetooth
();
await
sleep
(
3
000
);
await
sleep
(
10
000
);
break
;
case
1
:
console
.
info
(
'
[bluetooth_js] bt turning on:
'
+
JSON
.
stringify
(
sta
));
...
...
@@ -44,12 +49,38 @@ describe('bluetoothBLETest5', function() {
case
3
:
console
.
info
(
'
[bluetooth_js] bt turning off:
'
+
JSON
.
stringify
(
sta
));
bluetooth
.
enableBluetooth
();
await
sleep
(
3
000
);
await
sleep
(
10
000
);
break
;
default
:
console
.
info
(
'
[bluetooth_js] enable success
'
);
}
}
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.location.geolocation.function
'
,
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.LOCATION_IN_BACKGROUND
'
;
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
'
);
}
}
beforeAll
(
async
function
(
done
)
{
console
.
info
(
'
beforeAll called
'
)
await
tryToEnableBt
()
...
...
communication/bluetooth_manager/src/main/js/test/BleGattManager.test.js
浏览文件 @
45338c7d
...
...
@@ -14,6 +14,11 @@
*/
import
bluetooth
from
'
@ohos.bluetoothManager
'
;
import
geolocation
from
'
@ohos.geolocation
'
;
import
geolocationm
from
'
@ohos.geoLocationManager
'
;
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
'
export
default
function
bluetoothBLETest
()
{
...
...
@@ -30,7 +35,7 @@ describe('bluetoothBLETest', function() {
case
0
:
console
.
info
(
'
[bluetooth_js] bt turn off:
'
+
JSON
.
stringify
(
sta
));
bluetooth
.
enableBluetooth
();
await
sleep
(
3
000
);
await
sleep
(
10
000
);
break
;
case
1
:
console
.
info
(
'
[bluetooth_js] bt turning on:
'
+
JSON
.
stringify
(
sta
));
...
...
@@ -42,12 +47,38 @@ describe('bluetoothBLETest', function() {
case
3
:
console
.
info
(
'
[bluetooth_js] bt turning off:
'
+
JSON
.
stringify
(
sta
));
bluetooth
.
enableBluetooth
();
await
sleep
(
3
000
);
await
sleep
(
10
000
);
break
;
default
:
console
.
info
(
'
[bluetooth_js] enable success
'
);
}
}
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.location.geolocation.function
'
,
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.LOCATION_IN_BACKGROUND
'
;
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
'
);
}
}
beforeAll
(
function
()
{
console
.
info
(
'
beforeAll called
'
)
gattServer
=
bluetooth
.
BLE
.
createGattServer
();
...
...
communication/bluetooth_manager/src/main/js/test/BleGattManager401.test.js
浏览文件 @
45338c7d
...
...
@@ -15,6 +15,11 @@
//import bluetooth from '@ohos.bluetooth';
import
bluetooth
from
'
@ohos.bluetoothManager
'
;
import
geolocation
from
'
@ohos.geolocation
'
;
import
geolocationm
from
'
@ohos.geoLocationManager
'
;
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
'
export
default
function
bluetoothBLETest4
()
{
...
...
@@ -30,7 +35,7 @@ describe('bluetoothBLETest4', function() {
case
0
:
console
.
info
(
'
[bluetooth_js] bt turn off:
'
+
JSON
.
stringify
(
sta
));
bluetooth
.
enableBluetooth
();
await
sleep
(
3
000
);
await
sleep
(
10
000
);
break
;
case
1
:
console
.
info
(
'
[bluetooth_js] bt turning on:
'
+
JSON
.
stringify
(
sta
));
...
...
@@ -42,12 +47,38 @@ describe('bluetoothBLETest4', function() {
case
3
:
console
.
info
(
'
[bluetooth_js] bt turning off:
'
+
JSON
.
stringify
(
sta
));
bluetooth
.
enableBluetooth
();
await
sleep
(
3
000
);
await
sleep
(
10
000
);
break
;
default
:
console
.
info
(
'
[bluetooth_js] enable success
'
);
}
}
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.location.geolocation.function
'
,
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.LOCATION_IN_BACKGROUND
'
;
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
'
);
}
}
beforeAll
(
function
()
{
console
.
info
(
'
beforeAll called
'
)
gattClient
=
bluetooth
.
BLE
.
createGattClientDevice
(
"
11:22:33:44:55:66
"
);
...
...
communication/bluetooth_manager/src/main/js/test/BleScanResult.test.js
浏览文件 @
45338c7d
...
...
@@ -14,6 +14,11 @@
*/
import
bluetooth
from
'
@ohos.bluetoothManager
'
;
import
geolocation
from
'
@ohos.geolocation
'
;
import
geolocationm
from
'
@ohos.geoLocationManager
'
;
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
'
export
default
function
bluetoothBLETest6
()
{
...
...
@@ -27,7 +32,7 @@ describe('bluetoothBLETest6', function() {
switch
(
sta
){
case
0
:
bluetooth
.
enableBluetooth
();
await
sleep
(
5
000
);
await
sleep
(
10
000
);
let
sta1
=
bluetooth
.
getState
();
console
.
info
(
'
[bluetooth_js] bt turn off:
'
+
JSON
.
stringify
(
sta1
));
break
;
...
...
@@ -40,7 +45,7 @@ describe('bluetoothBLETest6', function() {
break
;
case
3
:
bluetooth
.
enableBluetooth
();
await
sleep
(
3
000
);
await
sleep
(
10
000
);
let
sta2
=
bluetooth
.
getState
();
console
.
info
(
'
[bluetooth_js] bt turning off:
'
+
JSON
.
stringify
(
sta2
));
break
;
...
...
@@ -48,6 +53,32 @@ describe('bluetoothBLETest6', function() {
console
.
info
(
'
[bluetooth_js] enable success
'
);
}
}
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.location.geolocation.function
'
,
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.LOCATION_IN_BACKGROUND
'
;
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
'
);
}
}
beforeAll
(
function
()
{
console
.
info
(
'
beforeAll called
'
)
})
...
...
communication/bluetooth_manager/src/main/js/test/BleService.test.js
浏览文件 @
45338c7d
...
...
@@ -14,8 +14,88 @@
*/
import
bluetooth
from
'
@ohos.bluetoothManager
'
;
import
geolocation
from
'
@ohos.geolocation
'
;
import
geolocationm
from
'
@ohos.geoLocationManager
'
;
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
'
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_ON
:
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
,
COMPUTER_HANDHELD_PC_PDA
:
0x0110
,
COMPUTER_PALM_SIZE_PC_PDA
:
0x0114
,
COMPUTER_WEARABLE
:
0x0118
,
COMPUTER_TABLET
:
0x011C
,
PHONE_UNCATEGORIZED
:
0x0200
,
PHONE_CELLULAR
:
0x0204
,
PHONE_CORDLESS
:
0x0208
,
PHONE_SMART
:
0x020C
,
PHONE_MODEM_OR_GATEWAY
:
0x0210
,
PHONE_ISDN
:
0x0214
,
NETWORK_FULLY_AVAILABLE
:
0x0300
,
NETWORK_1_TO_17_UTILIZED
:
0x0320
,
NETWORK_17_TO_33_UTILIZED
:
0x0340
,
NETWORK_33_TO_50_UTILIZED
:
0x0360
,
NETWORK_60_TO_67_UTILIZED
:
0x0380
,
NETWORK_67_TO_83_UTILIZED
:
0x03A0
,
NETWORK_83_TO_99_UTILIZED
:
0x03C0
,
NETWORK_NO_SERVICE
:
0x03E0
,
AUDIO_VIDEO_UNCATEGORIZED
:
0x0400
,
AUDIO_VIDEO_WEARABLE_HEADSET
:
0x0404
,
AUDIO_VIDEO_HANDSFREE
:
0x0408
,
AUDIO_VIDEO_MICROPHONE
:
0x0410
,
AUDIO_VIDEO_LOUDSPEAKER
:
0x0414
,
AUDIO_VIDEO_HEADPHONES
:
0x0418
,
AUDIO_VIDEO_PORTABLE_AUDIO
:
0x041C
,
AUDIO_VIDEO_CAR_AUDIO
:
0x0420
,
AUDIO_VIDEO_SET_TOP_BOX
:
0x0424
,
AUDIO_VIDEO_HIFI_AUDIO
:
0x0428
,
AUDIO_VIDEO_VCR
:
0x042C
,
AUDIO_VIDEO_VIDEO_CAMERA
:
0x0430
,
AUDIO_VIDEO_CAMCORDER
:
0x0434
,
AUDIO_VIDEO_VIDEO_MONITOR
:
0x0438
,
AUDIO_VIDEO_VIDEO_DISPLAY_AND_LOUDSPEAKER
:
0x043C
,
AUDIO_VIDEO_VIDEO_CONFERENCING
:
0x0440
,
AUDIO_VIDEO_VIDEO_GAMING_TOY
:
0x0448
,
PERIPHERAL_NON_KEYBOARD_NON_POINTING
:
0x0500
,
PERIPHERAL_KEYBOARD
:
0x0540
,
PERIPHERAL_POINTING_DEVICE
:
0x0580
,
PERIPHERAL_KEYBOARD_POINTING
:
0x05C0
,
PERIPHERAL_UNCATEGORIZED
:
0x0500
,
PERIPHERAL_JOYSTICK
:
0x0504
,
PERIPHERAL_GAMEPAD
:
0x0508
,
PERIPHERAL_REMOTE_CONTROL
:
0x05C0
,
PERIPHERAL_SENSING_DEVICE
:
0x0510
,
PERIPHERAL_DIGITIZER_TABLET
:
0x0514
,
PERIPHERAL_CARD_READER
:
0x0518
,
PERIPHERAL_DIGITAL_PEN
:
0x051C
,
PERIPHERAL_SCANNER_RFID
:
0x0520
,
PERIPHERAL_GESTURAL_INPUT
:
0x0522
,
IMAGING_UNCATEGORIZED
:
0x0600
,
IMAGING_DISPLAY
:
0x0610
,
IMAGING_CAMERA
:
0x0620
,
IMAGING_SCANNER
:
0x0640
,
IMAGING_PRINTER
:
0x0680
,
WEARABLE_UNCATEGORIZED
:
0x0700
,
WEARABLE_WRIST_WATCH
:
0x0704
,
WEARABLE_PAGER
:
0x0708
,
WEARABLE_JACKET
:
0x070C
,
WEARABLE_HELMET
:
0x0710
,
WEARABLE_GLASSES
:
0x0714
,
TOY_UNCATEGORIZED
:
0x0800
,
TOY_ROBOT
:
0x0804
,
TOY_VEHICLE
:
0x0808
,
TOY_DOLL_ACTION_FIGURE
:
0x080C
,
TOY_CONTROLLER
:
0x0810
,
TOY_GAME
:
0x0814
,
HEALTH_UNCATEGORIZED
:
0x0900
,
HEALTH_BLOOD_PRESSURE
:
0x0904
,
HEALTH_THERMOMETER
:
0x0908
,
HEALTH_WEIGHING
:
0x090C
,
HEALTH_GLUCOSE
:
0x0910
,
HEALTH_PULSE_OXIMETER
:
0x0914
,
HEALTH_PULSE_RATE
:
0x0918
,
HEALTH_DATA_DISPLAY
:
0x091C
,
HEALTH_STEP_COUNTER
:
0x0920
,
HEALTH_BODY_COMPOSITION_ANALYZER
:
0x0924
,
HEALTH_PEAK_FLOW_MOITOR
:
0x0928
,
HEALTH_MEDICATION_MONITOR
:
0x092C
,
HEALTH_KNEE_PROSTHESIS
:
0x0930
,
HEALTH_ANKLE_PROSTHESIS
:
0x0934
,
HEALTH_GENERIC_HEALTH_MANAGER
:
0x0938
,
HEALTH_PERSONAL_MOBILITY_DEVICE
:
0x093C
,
HEALTH_PERSONAL_MOBILITY_DEVICE
:
0x093C
};
let
MajorClass
=
{
MAJOR_MISC
:
0x0000
,
MAJOR_COMPUTER
:
0x0100
,
MAJOR_PHONE
:
0x0200
,
MAJOR_NETWORKING
:
0x0300
,
MAJOR_AUDIO_VIDEO
:
0x0400
,
MAJOR_PERIPHERAL
:
0x0500
,
MAJOR_IMAGING
:
0x0600
,
MAJOR_WEARABLE
:
0x0700
,
MAJOR_TOY
:
0x0800
,
MAJOR_HEALTH
:
0x0900
,
MAJOR_UNCATEGORIZED
:
0x1F00
};
let
ProfileId
=
{
PROFILE_A2DP_SOURCE
:
1
,
PROFILE_HANDS_FREE_AUDIO_GATEWAY
:
4
,
PROFILE_HID_HOST
:
6
,
PROFILE_PAN_NETWORK
:
7
};
export
default
function
bluetoothBLETest1
()
{
describe
(
'
bluetoothBLETest1
'
,
function
()
{
...
...
@@ -31,7 +111,7 @@ describe('bluetoothBLETest1', function() {
case
0
:
console
.
info
(
'
[bluetooth_js] bt turn off:
'
+
JSON
.
stringify
(
sta
));
bluetooth
.
enableBluetooth
();
await
sleep
(
3
000
);
await
sleep
(
10
000
);
break
;
case
1
:
console
.
info
(
'
[bluetooth_js] bt turning on:
'
+
JSON
.
stringify
(
sta
));
...
...
@@ -43,12 +123,38 @@ describe('bluetoothBLETest1', function() {
case
3
:
console
.
info
(
'
[bluetooth_js] bt turning off:
'
+
JSON
.
stringify
(
sta
));
bluetooth
.
enableBluetooth
();
await
sleep
(
3
000
);
await
sleep
(
10
000
);
break
;
default
:
console
.
info
(
'
[bluetooth_js] enable success
'
);
}
}
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.location.geolocation.function
'
,
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.LOCATION_IN_BACKGROUND
'
;
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
'
);
}
}
beforeAll
(
async
function
(
done
)
{
console
.
info
(
'
beforeAll called
'
)
await
tryToEnableBt
()
...
...
communication/bluetooth_manager/src/main/js/test/SwitchOff003.test.js
浏览文件 @
45338c7d
...
...
@@ -14,6 +14,11 @@
*/
import
bluetooth
from
'
@ohos.bluetoothManager
'
;
import
geolocation
from
'
@ohos.geolocation
'
;
import
geolocationm
from
'
@ohos.geoLocationManager
'
;
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
'
export
default
function
bluetoothBLETest3
()
{
...
...
@@ -46,6 +51,32 @@ describe('bluetoothBLETest3', function() {
console
.
info
(
'
[bluetooth_js] enable success
'
);
}
}
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.location.geolocation.function
'
,
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.LOCATION_IN_BACKGROUND
'
;
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
'
);
}
}
beforeAll
(
function
()
{
console
.
info
(
'
beforeAll called
'
)
gattServer
=
bluetooth
.
BLE
.
createGattServer
();
...
...
@@ -198,12 +229,12 @@ describe('bluetoothBLETest3', function() {
*/
it
(
'
COMMUNICATION_BLUETOOTH_SwitchOff_0600
'
,
0
,
async
function
(
done
)
{
try
{
let
a2dpSrcConn
=
bluetooth
.
getProfileConnState
(
bluetooth
.
ProfileId
.
PROFILE_A2DP_SOURCE
);
let
a2dpSrcConn
=
bluetooth
.
getProfileConn
ection
State
(
bluetooth
.
ProfileId
.
PROFILE_A2DP_SOURCE
);
console
.
info
(
'
[bluetooth_js]get a2dp result:
'
+
JSON
.
stringify
(
a2dpSrcConn
));
expect
(
true
).
assertFalse
();
done
()
}
catch
(
error
)
{
console
.
error
(
'
[bluetooth_js]getProfileConnState error.code:
'
+
JSON
.
stringify
(
error
.
code
)
+
console
.
error
(
'
[bluetooth_js]getProfileConn
ection
State error.code:
'
+
JSON
.
stringify
(
error
.
code
)
+
'
error.message:
'
+
JSON
.
stringify
(
error
.
message
));
expect
(
error
.
code
).
assertEqual
(
'
2900003
'
);
done
()
...
...
@@ -355,7 +386,7 @@ describe('bluetoothBLETest3', function() {
*/
it
(
'
COMMUNICATION_BLUETOOTH_SwitchOff_1600
'
,
0
,
async
function
(
done
)
{
try
{
let
hfpSrc
=
bluetooth
.
getProfileInst
(
bluetooth
.
ProfileId
.
PROFILE_HANDS_FREE_AUDIO_GATEWAY
);
let
hfpSrc
=
bluetooth
.
getProfileInst
ance
(
bluetooth
.
ProfileId
.
PROFILE_HANDS_FREE_AUDIO_GATEWAY
);
let
retArray
=
hfpSrc
.
getConnectionDevices
();
console
.
info
(
'
[bluetooth_js]hfp getConnectionDevices:
'
+
JSON
.
stringify
(
retArray
));
expect
(
true
).
assertFalse
();
...
...
communication/bluetooth_on/src/main/js/test/BleScanResult.test.js
浏览文件 @
45338c7d
...
...
@@ -14,6 +14,11 @@
*/
import
bluetooth
from
'
@ohos.bluetooth
'
;
import
geolocation
from
'
@ohos.geolocation
'
;
import
geolocationm
from
'
@ohos.geoLocationManager
'
;
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
'
export
default
function
bluetoothhostTest
()
{
...
...
@@ -27,7 +32,7 @@ describe('bluetoothhostTest', function() {
switch
(
sta
){
case
0
:
bluetooth
.
enableBluetooth
();
await
sleep
(
5
000
);
await
sleep
(
10
000
);
let
sta1
=
bluetooth
.
getState
();
console
.
info
(
'
[bluetooth_js] bt turn off:
'
+
JSON
.
stringify
(
sta1
));
break
;
...
...
@@ -40,7 +45,7 @@ describe('bluetoothhostTest', function() {
break
;
case
3
:
bluetooth
.
enableBluetooth
();
await
sleep
(
3
000
);
await
sleep
(
10
000
);
let
sta2
=
bluetooth
.
getState
();
console
.
info
(
'
[bluetooth_js] bt turning off:
'
+
JSON
.
stringify
(
sta2
));
break
;
...
...
@@ -48,6 +53,32 @@ describe('bluetoothhostTest', function() {
console
.
info
(
'
[bluetooth_js] enable success
'
);
}
}
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.location.geolocation.function
'
,
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.LOCATION_IN_BACKGROUND
'
;
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
'
);
}
}
beforeAll
(
function
()
{
console
.
info
(
'
beforeAll called
'
)
})
...
...
communication/bluetooth_on/src/main/js/test/BluetoothPair.test.js
浏览文件 @
45338c7d
...
...
@@ -14,6 +14,11 @@
*/
import
bluetooth
from
'
@ohos.bluetooth
'
;
import
geolocation
from
'
@ohos.geolocation
'
;
import
geolocationm
from
'
@ohos.geoLocationManager
'
;
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
'
...
...
@@ -28,7 +33,7 @@ describe('bluetoothhostTest2', function() {
switch
(
sta
){
case
0
:
bluetooth
.
enableBluetooth
();
await
sleep
(
5
000
);
await
sleep
(
10
000
);
let
sta1
=
bluetooth
.
getState
();
console
.
info
(
'
[bluetooth_js] bt turn off:
'
+
JSON
.
stringify
(
sta1
));
break
;
...
...
@@ -41,7 +46,7 @@ describe('bluetoothhostTest2', function() {
break
;
case
3
:
bluetooth
.
enableBluetooth
();
await
sleep
(
3
000
);
await
sleep
(
10
000
);
let
sta2
=
bluetooth
.
getState
();
console
.
info
(
'
[bluetooth_js] bt turning off:
'
+
JSON
.
stringify
(
sta2
));
break
;
...
...
@@ -49,6 +54,32 @@ describe('bluetoothhostTest2', function() {
console
.
info
(
'
[bluetooth_js] enable success
'
);
}
}
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.location.geolocation.function
'
,
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.LOCATION_IN_BACKGROUND
'
;
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
'
);
}
}
beforeAll
(
function
()
{
console
.
info
(
'
beforeAll called
'
)
})
...
...
communication/bluetooth_on/src/main/js/test/bluetoothSys.test.js
浏览文件 @
45338c7d
...
...
@@ -15,6 +15,11 @@
import
bluetooth
from
'
@ohos.bluetooth
'
;
import
bluetoothsys
from
'
@system.bluetooth
'
;
import
geolocation
from
'
@ohos.geolocation
'
;
import
geolocationm
from
'
@ohos.geoLocationManager
'
;
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
'
export
default
function
bluetoothhostTest4
()
{
...
...
@@ -28,7 +33,7 @@ describe('bluetoothhostTest4', function() {
switch
(
sta
){
case
0
:
bluetooth
.
enableBluetooth
();
await
sleep
(
5
000
);
await
sleep
(
10
000
);
let
sta1
=
bluetooth
.
getState
();
console
.
info
(
'
[bluetooth_js] bt turn off:
'
+
JSON
.
stringify
(
sta1
));
break
;
...
...
@@ -41,7 +46,7 @@ describe('bluetoothhostTest4', function() {
break
;
case
3
:
bluetooth
.
enableBluetooth
();
await
sleep
(
3
000
);
await
sleep
(
10
000
);
let
sta2
=
bluetooth
.
getState
();
console
.
info
(
'
[bluetooth_js] bt turning off:
'
+
JSON
.
stringify
(
sta2
));
break
;
...
...
@@ -49,6 +54,32 @@ describe('bluetoothhostTest4', function() {
console
.
info
(
'
[bluetooth_js] enable success
'
);
}
}
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.location.geolocation.function
'
,
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.LOCATION_IN_BACKGROUND
'
;
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
'
);
}
}
beforeAll
(
function
()
{
console
.
info
(
'
beforeAll called
'
)
})
...
...
communication/bluetooth_profile/src/main/js/test/BluetoothA2dp.test.js
浏览文件 @
45338c7d
...
...
@@ -14,8 +14,19 @@
*/
import
bluetooth
from
'
@ohos.bluetooth
'
;
import
geolocation
from
'
@ohos.geolocation
'
;
import
geolocationm
from
'
@ohos.geoLocationManager
'
;
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
'
let
ProfileId
=
{
PROFILE_A2DP_SOURCE
:
1
,
PROFILE_HANDS_FREE_AUDIO_GATEWAY
:
4
,
PROFILE_HID_HOST
:
6
,
PROFILE_PAN_NETWORK
:
7
};
export
default
function
bluetoothhostTest_host_1
()
{
describe
(
'
bluetoothhostTest_host_1
'
,
function
()
{
...
...
@@ -28,7 +39,7 @@ describe('bluetoothhostTest_host_1', function () {
switch
(
sta
){
case
0
:
bluetooth
.
enableBluetooth
();
await
sleep
(
5
000
);
await
sleep
(
10
000
);
let
sta1
=
bluetooth
.
getState
();
console
.
info
(
'
[bluetooth_js] bt turn off:
'
+
JSON
.
stringify
(
sta1
));
break
;
...
...
@@ -41,7 +52,7 @@ describe('bluetoothhostTest_host_1', function () {
break
;
case
3
:
bluetooth
.
enableBluetooth
();
await
sleep
(
3
000
);
await
sleep
(
10
000
);
let
sta2
=
bluetooth
.
getState
();
console
.
info
(
'
[bluetooth_js] bt turning off:
'
+
JSON
.
stringify
(
sta2
));
break
;
...
...
@@ -49,6 +60,32 @@ describe('bluetoothhostTest_host_1', function () {
console
.
info
(
'
[bluetooth_js] enable success
'
);
}
}
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.location.geolocation.function
'
,
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.LOCATION_IN_BACKGROUND
'
;
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
'
);
}
}
beforeAll
(
function
()
{
console
.
info
(
'
beforeAll called
'
)
})
...
...
communication/bluetooth_profile/src/main/js/test/BluetoothHfp.test.js
浏览文件 @
45338c7d
...
...
@@ -14,6 +14,11 @@
*/
import
bluetooth
from
'
@ohos.bluetooth
'
;
import
geolocation
from
'
@ohos.geolocation
'
;
import
geolocationm
from
'
@ohos.geoLocationManager
'
;
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
'
...
...
@@ -28,7 +33,7 @@ describe('bluetoothhostTest_host_3', function () {
switch
(
sta
){
case
0
:
bluetooth
.
enableBluetooth
();
await
sleep
(
5
000
);
await
sleep
(
10
000
);
let
sta1
=
bluetooth
.
getState
();
console
.
info
(
'
[bluetooth_js] bt turn off:
'
+
JSON
.
stringify
(
sta1
));
break
;
...
...
@@ -41,7 +46,7 @@ describe('bluetoothhostTest_host_3', function () {
break
;
case
3
:
bluetooth
.
enableBluetooth
();
await
sleep
(
3
000
);
await
sleep
(
10
000
);
let
sta2
=
bluetooth
.
getState
();
console
.
info
(
'
[bluetooth_js] bt turning off:
'
+
JSON
.
stringify
(
sta2
));
break
;
...
...
@@ -49,6 +54,32 @@ describe('bluetoothhostTest_host_3', function () {
console
.
info
(
'
[bluetooth_js] enable success
'
);
}
}
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.location.geolocation.function
'
,
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.LOCATION_IN_BACKGROUND
'
;
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
'
);
}
}
beforeAll
(
function
()
{
console
.
info
(
'
beforeAll called
'
)
})
...
...
communication/bluetooth_standard/src/main/js/test/BRDiscovery.test.js
浏览文件 @
45338c7d
...
...
@@ -14,6 +14,9 @@
*/
import
bluetooth
from
'
@ohos.bluetooth
'
;
import
geolocation
from
'
@ohos.geolocation
'
;
import
geolocationm
from
'
@ohos.geoLocationManager
'
;
import
osaccount
from
'
@ohos.account.osAccount
'
;
import
abilityAccessCtrl
from
'
@ohos.abilityAccessCtrl
'
import
bundle
from
'
@ohos.bundle
'
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
@ohos/hypium
'
...
...
@@ -45,7 +48,7 @@ describe('bluetoothhostTest3', function() {
switch
(
sta
){
case
0
:
bluetooth
.
enableBluetooth
();
await
sleep
(
5
000
);
await
sleep
(
10
000
);
let
sta1
=
bluetooth
.
getState
();
console
.
info
(
'
[bluetooth_js] bt turn off:
'
+
JSON
.
stringify
(
sta1
));
break
;
...
...
@@ -58,7 +61,7 @@ describe('bluetoothhostTest3', function() {
break
;
case
3
:
bluetooth
.
enableBluetooth
();
await
sleep
(
3
000
);
await
sleep
(
10
000
);
let
sta2
=
bluetooth
.
getState
();
console
.
info
(
'
[bluetooth_js] bt turning off:
'
+
JSON
.
stringify
(
sta2
));
break
;
...
...
@@ -66,6 +69,32 @@ describe('bluetoothhostTest3', function() {
console
.
info
(
'
[bluetooth_js] enable success
'
);
}
}
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.location.geolocation.function
'
,
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.LOCATION_IN_BACKGROUND
'
;
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
'
);
}
}
beforeAll
(
async
function
(
done
)
{
console
.
info
(
'
beforeAll called
'
)
...
...
communication/bluetooth_standard/src/main/js/test/BRScanMode.test.js
浏览文件 @
45338c7d
...
...
@@ -14,6 +14,11 @@
*/
import
bluetooth
from
'
@ohos.bluetooth
'
;
import
geolocation
from
'
@ohos.geolocation
'
;
import
geolocationm
from
'
@ohos.geoLocationManager
'
;
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
'
export
default
function
bluetoothhostTest2
()
{
...
...
@@ -26,7 +31,7 @@ describe('bluetoothhostTest2', function() {
switch
(
sta
){
case
0
:
bluetooth
.
enableBluetooth
();
await
sleep
(
5
000
);
await
sleep
(
10
000
);
let
sta1
=
bluetooth
.
getState
();
console
.
info
(
'
[bluetooth_js] bt turn off:
'
+
JSON
.
stringify
(
sta1
));
break
;
...
...
@@ -39,7 +44,7 @@ describe('bluetoothhostTest2', function() {
break
;
case
3
:
bluetooth
.
enableBluetooth
();
await
sleep
(
3
000
);
await
sleep
(
10
000
);
let
sta2
=
bluetooth
.
getState
();
console
.
info
(
'
[bluetooth_js] bt turning off:
'
+
JSON
.
stringify
(
sta2
));
break
;
...
...
@@ -47,6 +52,32 @@ describe('bluetoothhostTest2', function() {
console
.
info
(
'
[bluetooth_js] enable success
'
);
}
}
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.location.geolocation.function
'
,
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.LOCATION_IN_BACKGROUND
'
;
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
'
);
}
}
beforeAll
(
function
()
{
console
.
info
(
'
beforeAll called
'
)
})
...
...
communication/bluetooth_standard/src/main/js/test/BRSetLocalName.test.js
浏览文件 @
45338c7d
...
...
@@ -14,6 +14,11 @@
*/
import
bluetooth
from
'
@ohos.bluetooth
'
;
import
geolocation
from
'
@ohos.geolocation
'
;
import
geolocationm
from
'
@ohos.geoLocationManager
'
;
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
'
let
Btname
=
{
NUM_TEST
:
'
012345678901234567890123456789012345678901234567890123
'
+
...
...
@@ -49,7 +54,7 @@ describe('bluetoothhostTest1', function() {
switch
(
sta
){
case
0
:
bluetooth
.
enableBluetooth
();
await
sleep
(
5
000
);
await
sleep
(
10
000
);
let
sta1
=
bluetooth
.
getState
();
console
.
info
(
'
[bluetooth_js] bt turn off:
'
+
JSON
.
stringify
(
sta1
));
break
;
...
...
@@ -62,7 +67,7 @@ describe('bluetoothhostTest1', function() {
break
;
case
3
:
bluetooth
.
enableBluetooth
();
await
sleep
(
3
000
);
await
sleep
(
10
000
);
let
sta2
=
bluetooth
.
getState
();
console
.
info
(
'
[bluetooth_js] bt turning off:
'
+
JSON
.
stringify
(
sta2
));
break
;
...
...
@@ -70,6 +75,32 @@ describe('bluetoothhostTest1', function() {
console
.
info
(
'
[bluetooth_js] enable success
'
);
}
}
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.location.geolocation.function
'
,
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.LOCATION_IN_BACKGROUND
'
;
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
'
);
}
}
beforeAll
(
function
()
{
console
.
info
(
'
beforeAll called
'
)
})
...
...
communication/bluetooth_standard/src/main/js/test/BRSpp.test.js
浏览文件 @
45338c7d
...
...
@@ -14,6 +14,11 @@
*/
import
bluetooth
from
'
@ohos.bluetooth
'
;
import
geolocation
from
'
@ohos.geolocation
'
;
import
geolocationm
from
'
@ohos.geoLocationManager
'
;
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
'
...
...
@@ -29,7 +34,7 @@ describe('bluetoothhostTest4', function() {
case
0
:
console
.
info
(
'
[bluetooth_js] bt turn off:
'
+
JSON
.
stringify
(
sta
));
bluetooth
.
enableBluetooth
();
await
sleep
(
3
000
);
await
sleep
(
10
000
);
break
;
case
1
:
console
.
info
(
'
[bluetooth_js] bt turning on:
'
+
JSON
.
stringify
(
sta
));
...
...
@@ -41,12 +46,38 @@ describe('bluetoothhostTest4', function() {
case
3
:
console
.
info
(
'
[bluetooth_js] bt turning off:
'
+
JSON
.
stringify
(
sta
));
bluetooth
.
enableBluetooth
();
await
sleep
(
3
000
);
await
sleep
(
10
000
);
break
;
default
:
console
.
info
(
'
[bluetooth_js] enable success
'
);
}
}
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.location.geolocation.function
'
,
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.LOCATION_IN_BACKGROUND
'
;
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
'
);
}
}
beforeAll
(
function
()
{
console
.
info
(
'
beforeAll called
'
)
})
...
...
communication/bluetooth_standard/src/main/js/test/BRSwitch.test.js
浏览文件 @
45338c7d
...
...
@@ -14,8 +14,20 @@
*/
import
bluetooth
from
'
@ohos.bluetooth
'
;
import
geolocation
from
'
@ohos.geolocation
'
;
import
geolocationm
from
'
@ohos.geoLocationManager
'
;
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
'
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_ON
:
6
};
export
default
function
bluetoothhostTest
()
{
describe
(
'
bluetoothhostTest
'
,
function
()
{
function
sleep
(
delay
)
{
...
...
@@ -26,7 +38,7 @@ describe('bluetoothhostTest', function() {
switch
(
sta
){
case
0
:
bluetooth
.
enableBluetooth
();
await
sleep
(
5
000
);
await
sleep
(
10
000
);
let
sta1
=
bluetooth
.
getState
();
console
.
info
(
'
[bluetooth_js] Reacquire bt state:
'
+
JSON
.
stringify
(
sta1
));
break
;
...
...
@@ -39,7 +51,7 @@ describe('bluetoothhostTest', function() {
break
;
case
3
:
bluetooth
.
enableBluetooth
();
await
sleep
(
3
000
);
await
sleep
(
10
000
);
let
sta2
=
bluetooth
.
getState
();
console
.
info
(
'
[bluetooth_js] bt turning off:
'
+
JSON
.
stringify
(
sta2
));
break
;
...
...
@@ -47,6 +59,32 @@ describe('bluetoothhostTest', function() {
console
.
info
(
'
[bluetooth_js] enable success
'
);
}
}
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.location.geolocation.function
'
,
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.LOCATION_IN_BACKGROUND
'
;
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
'
);
}
}
beforeAll
(
function
()
{
console
.
info
(
'
beforeAll called
'
)
})
...
...
@@ -81,7 +119,7 @@ describe('bluetoothhostTest', function() {
if
(
state
!=
bluetooth
.
BluetoothState
.
STATE_ON
)
{
let
enable
=
bluetooth
.
enableBluetooth
();
await
sleep
(
5
000
);
await
sleep
(
10
000
);
console
.
info
(
'
[bluetooth_js] bluetooth enable001
'
+
JSON
.
stringify
(
enable
));
expect
(
enable
).
assertTrue
();
let
state1
=
bluetooth
.
getState
();
...
...
@@ -109,12 +147,13 @@ describe('bluetoothhostTest', function() {
* @tc.level Level 3
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BR_Switch_0300
'
,
0
,
async
function
(
done
)
{
let
enable
=
bluetooth
.
enableBluetooth
();
let
state
=
bluetooth
.
getState
();
console
.
info
(
'
[bluetooth_js] bt open state1 =
'
+
JSON
.
stringify
(
state
));
expect
(
state
).
assertEqual
(
bluetooth
.
BluetoothState
.
STATE_ON
);
if
(
state
==
bluetooth
.
BluetoothState
.
STATE_ON
)
{
let
enable1
=
bluetooth
.
enableBluetooth
();
await
sleep
(
3
000
);
await
sleep
(
10
000
);
console
.
info
(
'
[bluetooth_js]enable1 :
'
+
JSON
.
stringify
(
enable1
));
expect
(
enable1
).
assertFalse
();
let
state1
=
bluetooth
.
getState
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录