Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
ca43b2f8
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看板
未验证
提交
ca43b2f8
编写于
4月 27, 2023
作者:
O
openharmony_ci
提交者:
Gitee
4月 27, 2023
浏览文件
操作
浏览文件
下载
差异文件
!8555 【XTS】【communication】【3.2release】优化bt,lbs脚本
Merge pull request !8555 from 权力/myfeature2
上级
9b013955
1cf90995
变更
22
展开全部
隐藏空白更改
内联
并排
Showing
22 changed file
with
738 addition
and
121 deletion
+738
-121
communication/bluetooth_ble/signature/openharmony_sx.p7b
communication/bluetooth_ble/signature/openharmony_sx.p7b
+0
-0
communication/bluetooth_ble/src/main/config.json
communication/bluetooth_ble/src/main/config.json
+10
-0
communication/bluetooth_manager/signature/openharmony_sx.p7b
communication/bluetooth_manager/signature/openharmony_sx.p7b
+0
-0
communication/bluetooth_manager/src/main/config.json
communication/bluetooth_manager/src/main/config.json
+10
-0
communication/bluetooth_manager/src/main/js/test/BleGattManager.test.js
...bluetooth_manager/src/main/js/test/BleGattManager.test.js
+4
-4
communication/bluetooth_manager/src/main/js/test/BleScanResult.test.js
.../bluetooth_manager/src/main/js/test/BleScanResult.test.js
+29
-1
communication/bluetooth_manager/src/main/js/test/BleService.test.js
...ion/bluetooth_manager/src/main/js/test/BleService.test.js
+517
-70
communication/bluetooth_on/signature/openharmony_sx.p7b
communication/bluetooth_on/signature/openharmony_sx.p7b
+0
-0
communication/bluetooth_on/src/main/config.json
communication/bluetooth_on/src/main/config.json
+10
-0
communication/bluetooth_profile/signature/openharmony_sx.p7b
communication/bluetooth_profile/signature/openharmony_sx.p7b
+0
-0
communication/bluetooth_profile/src/main/config.json
communication/bluetooth_profile/src/main/config.json
+10
-0
communication/bluetooth_standard/signature/openharmony_sx.p7b
...unication/bluetooth_standard/signature/openharmony_sx.p7b
+0
-0
communication/bluetooth_standard/src/main/config.json
communication/bluetooth_standard/src/main/config.json
+10
-0
communication/bluetooth_standard/src/main/js/test/BRDiscovery.test.js
...n/bluetooth_standard/src/main/js/test/BRDiscovery.test.js
+34
-17
communication/bluetooth_standard/src/main/js/test/BRScanMode.test.js
...on/bluetooth_standard/src/main/js/test/BRScanMode.test.js
+4
-2
communication/bluetooth_standard/src/main/js/test/BRSwitch.test.js
...tion/bluetooth_standard/src/main/js/test/BRSwitch.test.js
+33
-7
communication/bluetooth_standard/src/main/js/test/List.test.js
...nication/bluetooth_standard/src/main/js/test/List.test.js
+2
-2
communication/bluetooth_switchoff/signature/openharmony_sx.p7b
...nication/bluetooth_switchoff/signature/openharmony_sx.p7b
+0
-0
communication/bluetooth_switchoff/src/main/config.json
communication/bluetooth_switchoff/src/main/config.json
+10
-0
communication/bluetooth_switchoff/src/main/js/test/SwitchOff003.test.js
...bluetooth_switchoff/src/main/js/test/SwitchOff003.test.js
+36
-1
location/geolocation_standard/src/main/js/test/GeocoderMTest.test.js
...olocation_standard/src/main/js/test/GeocoderMTest.test.js
+14
-11
location/geolocation_standard/src/main/js/test/LocationMTest.test.js
...olocation_standard/src/main/js/test/LocationMTest.test.js
+5
-6
未找到文件。
communication/bluetooth_ble/signature/openharmony_sx.p7b
浏览文件 @
ca43b2f8
无法预览此类型文件
communication/bluetooth_ble/src/main/config.json
浏览文件 @
ca43b2f8
...
...
@@ -106,6 +106,16 @@
"when"
:
"inuse"
}
},
{
"name"
:
"ohos.permission.APPROXIMATELY_LOCATION"
,
"reason"
:
""
,
"usedScene"
:
{
"ability"
:
[
"ohos.acts.communication.bluetooth.bluetoothhost.MainAbility"
],
"when"
:
"inuse"
}
},
{
"name"
:
"ohos.permission.DISCOVER_BLUETOOTH"
,
"reason"
:
""
,
...
...
communication/bluetooth_manager/signature/openharmony_sx.p7b
浏览文件 @
ca43b2f8
无法预览此类型文件
communication/bluetooth_manager/src/main/config.json
浏览文件 @
ca43b2f8
...
...
@@ -120,6 +120,16 @@
"when"
:
"inuse"
}
},
{
"name"
:
"ohos.permission.APPROXIMATELY_LOCATION"
,
"reason"
:
""
,
"usedScene"
:
{
"ability"
:
[
"ohos.acts.communication.bluetooth.bluetoothhost.MainAbility"
],
"when"
:
"inuse"
}
},
{
"name"
:
"ohos.permission.LOCATION"
,
"reason"
:
""
,
...
...
communication/bluetooth_manager/src/main/js/test/BleGattManager.test.js
浏览文件 @
ca43b2f8
...
...
@@ -217,18 +217,18 @@ describe('bluetoothBLETest', function() {
await
sleep
(
5000
)
try
{
await
gattClient
.
getDeviceName
().
then
((
data
)
=>
{
console
.
info
(
'
[bluetooth_js] device name
'
+
JSON
.
stringify
(
data
))
console
.
info
(
'
[bluetooth_js] device name
:
'
+
JSON
.
stringify
(
data
))
expect
(
data
).
assertNull
();
done
();
}).
catch
(
err
=>
{
console
.
error
(
'
bluetooth getDeviceName has error:
'
+
err
);
expect
(
true
).
assertFalse
();
console
.
error
(
'
[bluetooth_js] bluetooth getDeviceName has error:
'
+
JSON
.
stringify
(
err
)
);
expect
(
err
).
assertFalse
();
done
();
});
}
catch
(
error
)
{
console
.
error
(
`[bluetooth_js]GetDeviceName_0100 failed, code is
${
error
.
code
}
,
message is
${
error
.
message
}
`
);
expect
(
true
).
assertFalse
();
expect
(
true
).
assertFalse
();
done
()
}
})
...
...
communication/bluetooth_manager/src/main/js/test/BleScanResult.test.js
浏览文件 @
ca43b2f8
...
...
@@ -16,6 +16,32 @@
import
bluetooth
from
'
@ohos.bluetoothManager
'
;
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
);
0
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
permissionName
=
'
ohos.permission.LOCATION
'
;
await
atManager
.
grantUserGrantedPermission
(
tokenID
,
permissionName
,
1
).
then
((
result
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission success :
'
+
JSON
.
stringify
(
result
));
}).
catch
((
err
)
=>
{
console
.
info
(
'
[permis
'
+
'
sion] case grantUserGrantedPermission failed :
'
+
JSON
.
stringify
(
err
));
});
}
else
{
console
.
info
(
'
[permission] case apply permission failed, createAtManager failed
'
);
}
}
export
default
function
bluetoothBLETest6
()
{
describe
(
'
bluetoothBLETest6
'
,
function
()
{
function
sleep
(
delay
)
{
...
...
@@ -48,8 +74,10 @@ describe('bluetoothBLETest6', function() {
console
.
info
(
'
[bluetooth_js] enable success
'
);
}
}
beforeAll
(
function
(
)
{
beforeAll
(
async
function
(
done
)
{
console
.
info
(
'
beforeAll called
'
)
await
applyPermission
();
done
();
})
beforeEach
(
async
function
(
done
)
{
console
.
info
(
'
beforeEach called
'
)
...
...
communication/bluetooth_manager/src/main/js/test/BleService.test.js
浏览文件 @
ca43b2f8
此差异已折叠。
点击以展开。
communication/bluetooth_on/signature/openharmony_sx.p7b
浏览文件 @
ca43b2f8
无法预览此类型文件
communication/bluetooth_on/src/main/config.json
浏览文件 @
ca43b2f8
...
...
@@ -110,6 +110,16 @@
"when"
:
"inuse"
}
},
{
"name"
:
"ohos.permission.APPROXIMATELY_LOCATION"
,
"reason"
:
""
,
"usedScene"
:
{
"ability"
:
[
"ohos.acts.communication.bluetooth.bluetoothhost.MainAbility"
],
"when"
:
"inuse"
}
},
{
"name"
:
"ohos.permission.DISCOVER_BLUETOOTH"
,
"reason"
:
""
,
...
...
communication/bluetooth_profile/signature/openharmony_sx.p7b
浏览文件 @
ca43b2f8
无法预览此类型文件
communication/bluetooth_profile/src/main/config.json
浏览文件 @
ca43b2f8
...
...
@@ -106,6 +106,16 @@
"when"
:
"inuse"
}
},
{
"name"
:
"ohos.permission.APPROXIMATELY_LOCATION"
,
"reason"
:
""
,
"usedScene"
:
{
"ability"
:
[
"ohos.acts.communication.bluetooth.bluetoothhost.MainAbility"
],
"when"
:
"inuse"
}
},
{
"name"
:
"ohos.permission.GRANT_SENSITIVE_PERMISSIONS"
,
"reason"
:
"use ohos.permission.GRANT_SENSITIVE_PERMISSIONS"
...
...
communication/bluetooth_standard/signature/openharmony_sx.p7b
浏览文件 @
ca43b2f8
无法预览此类型文件
communication/bluetooth_standard/src/main/config.json
浏览文件 @
ca43b2f8
...
...
@@ -96,6 +96,16 @@
"when"
:
"inuse"
}
},
{
"name"
:
"ohos.permission.APPROXIMATELY_LOCATION"
,
"reason"
:
""
,
"usedScene"
:
{
"ability"
:
[
"ohos.acts.communication.bluetooth.bluetoothhost.MainAbility"
],
"when"
:
"inuse"
}
},
{
"name"
:
"ohos.permission.GRANT_SENSITIVE_PERMISSIONS"
,
"reason"
:
"use ohos.permission.GRANT_SENSITIVE_PERMISSIONS"
...
...
communication/bluetooth_standard/src/main/js/test/BRDiscovery.test.js
浏览文件 @
ca43b2f8
...
...
@@ -14,26 +14,41 @@
*/
import
bluetooth
from
'
@ohos.bluetooth
'
;
import
abilityAccessCtrl
from
'
@ohos.abilityAccessCtrl
'
import
bundle
from
'
@ohos.bundle
'
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
grantPerm
()
{
console
.
info
(
"
====grant Permission start====
"
);
let
appInfo
=
await
bundle
.
getApplicationInfo
(
'
ohos.acts.communication.bluetooth.bluetoothhost
'
,
0
,
100
);
tokenID
=
appInfo
.
accessTokenId
;
console
.
info
(
"
accessTokenId
"
+
appInfo
.
accessTokenId
+
"
bundleName:
"
+
appInfo
.
bundleName
);
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
);
0
let
appInfo
=
await
bundle
.
getApplicationInfo
(
'
ohos.acts.communication.bluetooth.bluetoothhost
'
,
0
,
localId
);
let
atManager
=
abilityAccessCtrl
.
createAtManager
();
let
result
=
await
atManager
.
grantUserGrantedPermission
(
tokenID
,
PERMISSION_USER_NAME1
,
PERMISSION_USER_SET
);
console
.
info
(
"
tokenId
"
+
tokenID
+
"
result:
"
+
result
);
let
result1
=
await
atManager
.
grantUserGrantedPermission
(
tokenID
,
PERMISSION_USER_NAME2
,
PERMISSION_USER_SET
);
console
.
info
(
"
tokenId
"
+
tokenID
+
"
result1:
"
+
result1
);
console
.
info
(
"
====grant Permission end====
"
);
if
(
atManager
!=
null
)
{
let
tokenID
=
appInfo
.
accessTokenId
;
console
.
info
(
'
[permission] case accessTokenID is
'
+
tokenID
);
let
permissionName
=
'
ohos.permission.LOCATION
'
;
let
permissionName1
=
'
ohos.permission.APPROXIMATELY_LOCATION
'
;
await
atManager
.
grantUserGrantedPermission
(
tokenID
,
permissionName
,
1
).
then
((
result
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission success :
'
+
JSON
.
stringify
(
result
));
}).
catch
((
err
)
=>
{
console
.
info
(
'
[permis
'
+
'
sion] case grantUserGrantedPermission failed :
'
+
JSON
.
stringify
(
err
));
});
await
atManager
.
grantUserGrantedPermission
(
tokenID
,
permissionName1
,
1
).
then
((
result
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission success1 :
'
+
JSON
.
stringify
(
result
));
}).
catch
((
err
)
=>
{
console
.
info
(
'
[permis
'
+
'
sion] case grantUserGrantedPermission failed :
'
+
JSON
.
stringify
(
err
));
});
}
else
{
console
.
info
(
'
[permission] case apply permission failed, createAtManager failed
'
);
}
}
export
default
function
bluetoothhostTest3
()
{
describe
(
'
bluetoothhostTest3
'
,
function
()
{
function
sleep
(
delay
)
{
...
...
@@ -69,7 +84,7 @@ describe('bluetoothhostTest3', function() {
beforeAll
(
async
function
(
done
)
{
console
.
info
(
'
beforeAll called
'
)
await
grantPerm
();
await
applyPermission
();
done
()
})
beforeEach
(
async
function
(
done
)
{
...
...
@@ -122,6 +137,8 @@ describe('bluetoothhostTest3', function() {
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BR_Discovery_0300
'
,
0
,
async
function
(
done
)
{
let
result1
=
bluetooth
.
setBluetoothScanMode
(
bluetooth
.
ScanMode
.
SCAN_MODE_CONNECTABLE
,
10
);
console
.
info
(
'
[bluetooth_js] setBluetoothScanMode =
'
+
JSON
.
stringify
(
result1
));
await
sleep
(
3000
);
expect
(
result1
).
assertTrue
();
let
getScanMode
=
bluetooth
.
getBluetoothScanMode
();
console
.
info
(
'
[bluetooth_js] getScanMode =
'
+
JSON
.
stringify
(
getScanMode
));
...
...
communication/bluetooth_standard/src/main/js/test/BRScanMode.test.js
浏览文件 @
ca43b2f8
...
...
@@ -332,12 +332,14 @@ describe('bluetoothhostTest2', function() {
let
oldScanMode
=
bluetooth
.
getBluetoothScanMode
();
console
.
info
(
'
[bluetooth_js] ScanMode_0800 oldScanMode =
'
+
JSON
.
stringify
(
oldScanMode
));
let
result
=
bluetooth
.
setBluetoothScanMode
(
bluetooth
.
ScanMode
.
SCAN_MODE_CONNECTABLE_GENERAL_DISCOVERABLE
,
0
);
expect
(
result
).
assertTrue
();
console
.
info
(
'
[bluetooth_js] result =
'
+
JSON
.
stringify
(
result
));
// expect(result).assertTrue();
let
getScanMode
=
bluetooth
.
getBluetoothScanMode
();
console
.
info
(
'
[bluetooth_js] ScanMode_0800 getScanMode =
'
+
JSON
.
stringify
(
getScanMode
));
expect
(
true
).
assertEqual
(
getScanMode
==
bluetooth
.
ScanMode
.
SCAN_MODE_CONNECTABLE_GENERAL_DISCOVERABLE
);
result
=
bluetooth
.
setBluetoothScanMode
(
oldScanMode
,
0
);
expect
(
result
).
assertTrue
();
console
.
info
(
'
[bluetooth_js] result1 =
'
+
JSON
.
stringify
(
result
));
// expect(result).assertTrue();
let
getOldScanMode
=
bluetooth
.
getBluetoothScanMode
();
console
.
info
(
'
[bluetooth_js] ScanMode_0800 getOldScanMode =
'
+
JSON
.
stringify
(
getOldScanMode
));
expect
(
true
).
assertEqual
(
oldScanMode
==
getOldScanMode
);
...
...
communication/bluetooth_standard/src/main/js/test/BRSwitch.test.js
浏览文件 @
ca43b2f8
...
...
@@ -15,13 +15,6 @@
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
,
STATE_BLE_TURNING_ON
:
4
,
STATE_BLE_ON
:
5
,
STATE_BLE_TURNING_OFF
:
6
};
export
default
function
bluetoothhostTest
()
{
describe
(
'
bluetoothhostTest
'
,
function
()
{
...
...
@@ -126,6 +119,39 @@ describe('bluetoothhostTest', function() {
}
done
()
})
/**
* @tc.number COMMUNICATION_BLUETOOTH_SwitchOff_0444
* @tc.name testEnableBluetooth and getState
* @tc.desc Test EnableBluetooth api by promise.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
*/
it
(
'
COMMUNICATION_BLUETOOTH_SwitchOff_0444
'
,
0
,
async
function
(
done
)
{
let
STATE_ON
=
bluetooth
.
BluetoothState
.
STATE_ON
;
console
.
info
(
"
[bluetooth_js]STATE_ON :
"
+
JSON
.
stringify
(
STATE_ON
));
expect
(
true
).
assertTrue
(
STATE_ON
==
2
);
let
STATE_OFF
=
bluetooth
.
BluetoothState
.
STATE_OFF
;
console
.
info
(
"
[bluetooth_js]STATE_OFF :
"
+
JSON
.
stringify
(
STATE_OFF
));
expect
(
true
).
assertTrue
(
STATE_OFF
==
0
);
let
STATE_TURNING_ON
=
bluetooth
.
BluetoothState
.
STATE_TURNING_ON
;
console
.
info
(
"
[bluetooth_js]STATE_TURNING_ON :
"
+
JSON
.
stringify
(
STATE_TURNING_ON
));
expect
(
true
).
assertTrue
(
STATE_TURNING_ON
==
1
);
let
STATE_TURNING_OFF
=
bluetooth
.
BluetoothState
.
STATE_TURNING_OFF
;
console
.
info
(
"
[bluetooth_js]STATE_TURNING_OFF :
"
+
JSON
.
stringify
(
STATE_TURNING_OFF
));
expect
(
true
).
assertTrue
(
STATE_TURNING_OFF
==
3
);
let
STATE_BLE_TURNING_ON
=
bluetooth
.
BluetoothState
.
STATE_BLE_TURNING_ON
;
console
.
info
(
"
[bluetooth_js]STATE_BLE_TURNING_ON :
"
+
JSON
.
stringify
(
STATE_BLE_TURNING_ON
));
expect
(
true
).
assertTrue
(
STATE_BLE_TURNING_ON
==
4
);
let
STATE_BLE_ON
=
bluetooth
.
BluetoothState
.
STATE_BLE_ON
;
console
.
info
(
"
[bluetooth_js]STATE_BLE_ON :
"
+
JSON
.
stringify
(
STATE_BLE_ON
));
expect
(
true
).
assertTrue
(
STATE_BLE_ON
==
5
);
let
STATE_BLE_TURNING_OFF
=
bluetooth
.
BluetoothState
.
STATE_BLE_TURNING_OFF
;
console
.
info
(
"
[bluetooth_js]STATE_BLE_TURNING_OFF :
"
+
JSON
.
stringify
(
STATE_BLE_TURNING_OFF
));
expect
(
true
).
assertTrue
(
STATE_BLE_TURNING_OFF
==
6
);
done
()
})
})
}
...
...
communication/bluetooth_standard/src/main/js/test/List.test.js
浏览文件 @
ca43b2f8
...
...
@@ -15,14 +15,14 @@
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
'
import
bluetoothhostTest3
from
'
./BRDiscovery.test.js
'
export
default
function
testsuite
()
{
bluetoothhostTest
()
bluetoothhostTest1
()
bluetoothhostTest2
()
bluetoothhostTest3
()
bluetoothhostTest4
()
bluetoothhostTest
()
bluetoothhostTest3
()
}
communication/bluetooth_switchoff/signature/openharmony_sx.p7b
浏览文件 @
ca43b2f8
无法预览此类型文件
communication/bluetooth_switchoff/src/main/config.json
浏览文件 @
ca43b2f8
...
...
@@ -96,6 +96,16 @@
"when"
:
"inuse"
}
},
{
"name"
:
"ohos.permission.APPROXIMATELY_LOCATION"
,
"reason"
:
""
,
"usedScene"
:
{
"ability"
:
[
"ohos.acts.communication.bluetooth.bluetoothhost.MainAbility"
],
"when"
:
"inuse"
}
},
{
"name"
:
"ohos.permission.MANAGE_BLUETOOTH"
,
"reason"
:
""
,
...
...
communication/bluetooth_switchoff/src/main/js/test/SwitchOff003.test.js
浏览文件 @
ca43b2f8
...
...
@@ -17,6 +17,39 @@ import bluetoothManager from '@ohos.bluetoothManager';
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
);
0
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
permissionName
=
'
ohos.permission.LOCATION
'
;
let
permissionName1
=
'
ohos.permission.APPROXIMATELY_LOCATION
'
;
await
atManager
.
grantUserGrantedPermission
(
tokenID
,
permissionName
,
1
).
then
((
result
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission success :
'
+
JSON
.
stringify
(
result
));
}).
catch
((
err
)
=>
{
console
.
info
(
'
[permis
'
+
'
sion] case grantUserGrantedPermission failed :
'
+
JSON
.
stringify
(
err
));
});
await
atManager
.
grantUserGrantedPermission
(
tokenID
,
permissionName1
,
1
).
then
((
result
)
=>
{
console
.
info
(
'
[permission] case grantUserGrantedPermission success1 :
'
+
JSON
.
stringify
(
result
));
}).
catch
((
err
)
=>
{
console
.
info
(
'
[permis
'
+
'
sion] case grantUserGrantedPermission failed :
'
+
JSON
.
stringify
(
err
));
});
}
else
{
console
.
info
(
'
[permission] case apply permission failed, createAtManager failed
'
);
}
}
export
default
function
bluetoothBLETest3
()
{
describe
(
'
bluetoothBLETest3
'
,
function
()
{
let
gattServer
=
null
;
...
...
@@ -47,10 +80,12 @@ describe('bluetoothBLETest3', function() {
console
.
info
(
'
[bluetooth_js] enable success
'
);
}
}
beforeAll
(
function
(
)
{
beforeAll
(
async
function
(
done
)
{
console
.
info
(
'
beforeAll called
'
)
gattServer
=
bluetoothManager
.
BLE
.
createGattServer
();
gattClient
=
bluetoothManager
.
BLE
.
createGattClientDevice
(
"
11:22:33:44:55:66
"
);
await
applyPermission
();
done
();
})
beforeEach
(
async
function
(
done
)
{
console
.
info
(
'
beforeEach called
'
)
...
...
location/geolocation_standard/src/main/js/test/GeocoderMTest.test.js
浏览文件 @
ca43b2f8
...
...
@@ -164,17 +164,20 @@ export default function geolocationTest_geo5() {
let
reverseGeocodeRequest
=
{
"
latitude
"
:
31.265496
,
"
longitude
"
:
121.62771
,
"
maxItems
"
:
5
};
await
geolocationm
.
getAddressesFromLocation
(
reverseGeocodeRequest
).
then
((
data
)
=>
{
console
.
info
(
'
[lbs_js] getAddressesFromLocation21 promise:
'
+
JSON
.
stringify
(
data
));
console
.
info
(
'
addressUrl:
'
+
JSON
.
stringify
(
data
)[
0
].
addressUrl
+
JSON
.
stringify
(
data
)[
0
].
administrativeArea
+
JSON
.
stringify
(
data
)[
0
].
countryCode
+
JSON
.
stringify
(
data
)[
0
].
countryName
+
JSON
.
stringify
(
data
)[
0
].
descriptions
+
JSON
.
stringify
(
data
)[
0
].
descriptionsSize
+
data
[
0
].
latitude
+
JSON
.
stringify
(
data
)[
0
].
locale
+
JSON
.
stringify
(
data
)[
0
].
locality
+
JSON
.
stringify
(
data
)[
0
].
longitude
+
JSON
.
stringify
(
data
)[
0
].
phoneNumber
+
JSON
.
stringify
(
data
)[
0
].
placeName
+
JSON
.
stringify
(
data
)[
0
].
postalCode
+
JSON
.
stringify
(
data
)[
0
].
premises
+
JSON
.
stringify
(
data
)[
0
].
roadName
+
JSON
.
stringify
(
data
)[
0
].
subAdministrativeArea
+
JSON
.
stringify
(
data
)[
0
].
subLocality
+
JSON
.
stringify
(
data
)[
0
].
subRoadName
+
JSON
.
stringify
(
data
)[
0
].
isFromMock
);
if
(
data
!=
""
)
{
console
.
info
(
'
addressUrl:
'
+
JSON
.
stringify
(
data
)[
0
].
addressUrl
+
JSON
.
stringify
(
data
)[
0
].
administrativeArea
+
JSON
.
stringify
(
data
)[
0
].
countryCode
+
JSON
.
stringify
(
data
)[
0
].
countryName
+
JSON
.
stringify
(
data
)[
0
].
descriptions
+
JSON
.
stringify
(
data
)[
0
].
descriptionsSize
+
data
[
0
].
latitude
+
JSON
.
stringify
(
data
)[
0
].
locale
+
JSON
.
stringify
(
data
)[
0
].
locality
+
JSON
.
stringify
(
data
)[
0
].
longitude
+
JSON
.
stringify
(
data
)[
0
].
phoneNumber
+
JSON
.
stringify
(
data
)[
0
].
placeName
+
JSON
.
stringify
(
data
)[
0
].
postalCode
+
JSON
.
stringify
(
data
)[
0
].
premises
+
JSON
.
stringify
(
data
)[
0
].
roadName
+
JSON
.
stringify
(
data
)[
0
].
subAdministrativeArea
+
JSON
.
stringify
(
data
)[
0
].
subLocality
+
JSON
.
stringify
(
data
)[
0
].
subRoadName
+
JSON
.
stringify
(
data
)[
0
].
isFromMock
);
}
}).
catch
(
error
=>
{
console
.
info
(
"
[lbs_js] getAddressesFromLocation21 promise then error.
"
+
JSON
.
stringify
(
error
));
console
.
info
(
'
[lbs_js] not support now
'
);
...
...
location/geolocation_standard/src/main/js/test/LocationMTest.test.js
浏览文件 @
ca43b2f8
...
...
@@ -612,7 +612,6 @@ export default function geolocationTest_geo7() {
console
.
info
(
'
[lbs_js] sendcommand promise err:
'
+
JSON
.
stringify
(
error
));
console
.
info
(
'
[lbs_js] not support now
'
);
expect
(
error
.
code
).
assertEqual
(
801
);
//expect(true).assertEqual(JSON.stringify(error) != null);
done
();
})
}
catch
(
error
)
{
...
...
@@ -1180,11 +1179,11 @@ export default function geolocationTest_geo7() {
try
{
let
last
=
geolocationm
.
getLastLocation
();
console
.
info
(
'
[lbs_js] getLastLocation latitude:
'
+
last
.
latitude
+
'
longitude:
'
+
result
.
longitude
+
'
altitude:
'
+
resul
t
.
altitude
+
'
accuracy:
'
+
result
.
accuracy
+
'
speed:
'
+
resul
t
.
speed
+
'
timeStamp:
'
+
result
.
timeStamp
+
'
direction:
'
+
resul
t
.
direction
+
'
timeSinceBoot:
'
+
result
.
timeSinceBoot
+
'
additions:
'
+
result
.
additions
+
'
additionSize
'
+
resul
t
.
additionSize
+
'
isFromMock
'
+
resul
t
.
isFromMock
);
'
longitude:
'
+
last
.
longitude
+
'
altitude:
'
+
las
t
.
altitude
+
'
accuracy:
'
+
last
.
accuracy
+
'
speed:
'
+
las
t
.
speed
+
'
timeStamp:
'
+
last
.
timeStamp
+
'
direction:
'
+
las
t
.
direction
+
'
timeSinceBoot:
'
+
last
.
timeSinceBoot
+
'
additions:
'
+
last
.
additions
+
'
additionSize
'
+
las
t
.
additionSize
+
'
isFromMock
'
+
las
t
.
isFromMock
);
expect
(
true
).
assertEqual
(
JSON
.
stringify
(
last
)
!=
null
);
}
catch
(
error
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录