Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
fa80cf79
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看板
提交
fa80cf79
编写于
8月 19, 2022
作者:
Q
quanli
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
quanli1@huawei.com
Signed-off-by:
N
quanli
<
quanli1@huawei.com
>
上级
f0f39c0d
变更
29
展开全部
显示空白变更内容
内联
并排
Showing
29 changed file
with
8233 addition
and
4121 deletion
+8233
-4121
communication/bluetooth_ble/src/main/js/test/BleAdvertiser.test.js
...tion/bluetooth_ble/src/main/js/test/BleAdvertiser.test.js
+725
-0
communication/bluetooth_ble/src/main/js/test/BleGattManager.test.js
...ion/bluetooth_ble/src/main/js/test/BleGattManager.test.js
+658
-0
communication/bluetooth_ble/src/main/js/test/BleService.test.js
...ication/bluetooth_ble/src/main/js/test/BleService.test.js
+1254
-0
communication/bluetooth_ble/src/main/js/test/List.test.js
communication/bluetooth_ble/src/main/js/test/List.test.js
+6
-2
communication/bluetooth_on/Test.json
communication/bluetooth_on/Test.json
+1
-1
communication/bluetooth_on/src/main/js/test/BleScanResult.test.js
...ation/bluetooth_on/src/main/js/test/BleScanResult.test.js
+629
-0
communication/bluetooth_on/src/main/js/test/BluetoothOn.test.js
...ication/bluetooth_on/src/main/js/test/BluetoothOn.test.js
+500
-1025
communication/bluetooth_on/src/main/js/test/BluetoothPair.test.js
...ation/bluetooth_on/src/main/js/test/BluetoothPair.test.js
+258
-0
communication/bluetooth_on/src/main/js/test/List.test.js
communication/bluetooth_on/src/main/js/test/List.test.js
+9
-3
communication/bluetooth_on/src/main/js/test/bluetoothProfileAdd.test.js
...bluetooth_on/src/main/js/test/bluetoothProfileAdd.test.js
+97
-0
communication/bluetooth_on/src/main/js/test/bluetoothSys.test.js
...cation/bluetooth_on/src/main/js/test/bluetoothSys.test.js
+125
-0
communication/bluetooth_profile/Test.json
communication/bluetooth_profile/Test.json
+3
-2
communication/bluetooth_profile/src/main/js/test/BluetoothA2dp.test.js
.../bluetooth_profile/src/main/js/test/BluetoothA2dp.test.js
+2
-3
communication/bluetooth_standard/Test.json
communication/bluetooth_standard/Test.json
+3
-2
communication/bluetooth_standard/src/main/js/test/BRDiscovery.test.js
...n/bluetooth_standard/src/main/js/test/BRDiscovery.test.js
+128
-0
communication/bluetooth_standard/src/main/js/test/BRScanMode.test.js
...on/bluetooth_standard/src/main/js/test/BRScanMode.test.js
+319
-0
communication/bluetooth_standard/src/main/js/test/BRSetLocalName.test.js
...luetooth_standard/src/main/js/test/BRSetLocalName.test.js
+428
-0
communication/bluetooth_standard/src/main/js/test/BRSpp.test.js
...ication/bluetooth_standard/src/main/js/test/BRSpp.test.js
+355
-0
communication/bluetooth_standard/src/main/js/test/BRSwitch.test.js
...tion/bluetooth_standard/src/main/js/test/BRSwitch.test.js
+163
-0
communication/bluetooth_standard/src/main/js/test/List.test.js
...nication/bluetooth_standard/src/main/js/test/List.test.js
+9
-1
communication/wifi_p2p/src/main/js/test/WifiP2P.test2.js
communication/wifi_p2p/src/main/js/test/WifiP2P.test2.js
+82
-47
communication/wifi_p2p/src/main/js/test/WifiP2P.testsame.js
communication/wifi_p2p/src/main/js/test/WifiP2P.testsame.js
+483
-483
communication/wifi_standard/src/main/js/test/WifiJsunit.test1.js
...cation/wifi_standard/src/main/js/test/WifiJsunit.test1.js
+101
-14
communication/wifi_standard/src/main/js/test/WifiJsunit.testsame.js
...ion/wifi_standard/src/main/js/test/WifiJsunit.testsame.js
+367
-387
location/geolocation_standard/src/main/js/default/test/GeocoderTest.test.js
...on_standard/src/main/js/default/test/GeocoderTest.test.js
+383
-1213
location/geolocation_standard/src/main/js/default/test/GetCountryCode.test.js
..._standard/src/main/js/default/test/GetCountryCode.test.js
+169
-0
location/geolocation_standard/src/main/js/default/test/List.test.js
...eolocation_standard/src/main/js/default/test/List.test.js
+2
-2
location/geolocation_standard/src/main/js/default/test/LocationTest.test.js
...on_standard/src/main/js/default/test/LocationTest.test.js
+913
-870
location/geolocation_standard/src/main/js/default/test/SystemLocation.test.js
..._standard/src/main/js/default/test/SystemLocation.test.js
+61
-66
未找到文件。
communication/bluetooth_ble/src/main/js/test/BleAdvertiser.test.js
0 → 100644
浏览文件 @
fa80cf79
此差异已折叠。
点击以展开。
communication/bluetooth_ble/src/main/js/test/BleGattManager.test.js
0 → 100644
浏览文件 @
fa80cf79
此差异已折叠。
点击以展开。
communication/bluetooth_ble/src/main/js/test/BleService.test.js
0 → 100644
浏览文件 @
fa80cf79
此差异已折叠。
点击以展开。
communication/bluetooth_ble/src/main/js/test/List.test.js
浏览文件 @
fa80cf79
...
...
@@ -13,7 +13,11 @@
* limitations under the License.
*/
import
bluetoothhostTest
from
'
./BluetoothBle.test.js
'
import
bluetoothBLETest
from
'
./BleGattManager.test.js
'
import
bluetoothBLETest1
from
'
./BleService.test.js
'
import
bluetoothBLETest2
from
'
./BleAdvertiser.test.js
'
export
default
function
testsuite
()
{
bluetoothhostTest
()
bluetoothBLETest
()
bluetoothBLETest1
()
bluetoothBLETest2
()
}
communication/bluetooth_on/Test.json
浏览文件 @
fa80cf79
communication/bluetooth_on/src/main/js/test/BleScanResult.test.js
0 → 100644
浏览文件 @
fa80cf79
此差异已折叠。
点击以展开。
communication/bluetooth_on/src/main/js/test/BluetoothOn.test.js
浏览文件 @
fa80cf79
此差异已折叠。
点击以展开。
communication/bluetooth_on/src/main/js/test/BluetoothPair.test.js
0 → 100644
浏览文件 @
fa80cf79
/*
* 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
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
)
{
return
new
Promise
(
resovle
=>
setTimeout
(
resovle
,
delay
))
}
async
function
tryToEnableBt
()
{
let
sta
=
bluetooth
.
getState
();
switch
(
sta
){
case
0
:
bluetooth
.
enableBluetooth
();
await
sleep
(
5000
);
let
sta1
=
bluetooth
.
getState
();
console
.
info
(
'
[bluetooth_js] bt turn off:
'
+
JSON
.
stringify
(
sta1
));
break
;
case
1
:
console
.
info
(
'
[bluetooth_js] bt turning on:
'
+
JSON
.
stringify
(
sta
));
await
sleep
(
3000
);
break
;
case
2
:
console
.
info
(
'
[bluetooth_js] bt turn on:
'
+
JSON
.
stringify
(
sta
));
break
;
case
3
:
bluetooth
.
enableBluetooth
();
await
sleep
(
3000
);
let
sta2
=
bluetooth
.
getState
();
console
.
info
(
'
[bluetooth_js] bt turning off:
'
+
JSON
.
stringify
(
sta2
));
break
;
default
:
console
.
info
(
'
[bluetooth_js] enable success
'
);
}
}
beforeAll
(
function
()
{
console
.
info
(
'
beforeAll called
'
)
})
beforeEach
(
async
function
(
done
)
{
console
.
info
(
'
beforeEach called
'
)
await
tryToEnableBt
()
done
()
})
afterEach
(
function
()
{
console
.
info
(
'
afterEach called
'
)
})
afterAll
(
function
()
{
console
.
info
(
'
afterAll called
'
)
})
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BR_Pair_0200
* @tc.name testStartpair
* @tc.desc Test pairDevice of use vailded address.
* @tc.size MEDIUM
* @ since 8
* @tc.type Function
* @tc.level Level 0
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BR_Pair_0200
'
,
0
,
async
function
(
done
)
{
function
PinRequiredParam
(
data
)
{
console
.
info
(
"
[bluetooth_js] pinRequired on:
"
+
JSON
.
stringify
(
data
));
bluetooth
.
setDevicePairingConfirmation
(
data
.
deviceId
,
false
);
}
bluetooth
.
BLE
.
on
(
'
pinRequired
'
,
PinRequiredParam
);
let
result
=
bluetooth
.
pairDevice
(
"
SSS
"
);
console
.
info
(
"
[bluetooth_js] onStartpair ->
"
+
JSON
.
stringify
(
result
));
expect
(
result
).
assertFalse
();
bluetooth
.
BLE
.
off
(
'
pinRequired
'
,
PinRequiredParam
);
done
();
})
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BR_Pair_0300
* @tc.name test getRemoteDeviceName
* @tc.desc Test get RemoteDeviceName
* @tc.size MEDIUM
* @ since 8
* @tc.type Function
* @tc.level Level 3
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BR_Pair_0300
'
,
0
,
async
function
(
done
)
{
let
ret
=
bluetooth
.
getRemoteDeviceName
(
"
00:00:00:00:00:00
"
);
console
.
info
(
'
[bluetooth_js] getRemoteDeviceName ret2:
'
+
JSON
.
stringify
(
ret
));
expect
(
ret
.
length
).
assertEqual
(
0
);
done
();
})
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BR_Pair_0400
* @tc.name test getRemoteDeviceClass
* @tc.desc Test get RemoteDeviceClass
* @tc.size MEDIUM
* @ since 8
* @tc.type Function
* @tc.level Level 1
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BR_Pair_0400
'
,
0
,
async
function
(
done
)
{
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
DeviceClass
=
bluetooth
.
getRemoteDeviceClass
(
"
00:00:00:00:00:00
"
);
console
.
info
(
'
[bluetooth_js] getRemoteDeviceClass ret2 :
'
+
JSON
.
stringify
(
DeviceClass
)
+
'
majorClass:
'
+
DeviceClass
.
majorClass
+
'
majorMinorClass:
'
+
DeviceClass
.
majorMinorClass
+
'
classOfDevice:
'
+
DeviceClass
.
classOfDevice
);
expect
(
DeviceClass
.
majorClass
).
assertEqual
(
0
);
done
();
})
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BR_Pair_0500
* @tc.name test getRemoteDeviceClass
* @tc.desc Test get getRemoteDeviceClass
* @tc.size MEDIUM
* @ since 8
* @tc.type Function
* @tc.level Level 3
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BR_Pair_0500
'
,
0
,
async
function
(
done
)
{
let
ret
=
bluetooth
.
getRemoteDeviceName
(
"
1125445
"
);
console
.
info
(
'
[bluetooth_js] getRemoteDeviceName ret2:
'
+
JSON
.
stringify
(
ret
));
expect
(
ret
.
length
).
assertEqual
(
0
);
done
();
})
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BR_Pair_0600
* @tc.name test getPairedDevices
* @tc.desc Test get getPairedDevices
* @tc.size MEDIUM
* @ since 8
* @tc.type Function
* @tc.level Level 3
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BR_Pair_0600
'
,
0
,
async
function
(
done
)
{
let
ret
=
bluetooth
.
getPairedDevices
();
console
.
info
(
'
[bluetooth_js] getPairedDevices ret2:
'
+
JSON
.
stringify
(
ret
));
expect
(
ret
.
length
).
assertEqual
(
0
);
done
();
})
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BR_Pair_0700
* @tc.name test pinRequired
* @tc.desc Test pinRequired and setDevicePairing false
* @tc.size MEDIUM
* @ since 8
* @tc.type Function
* @tc.level Level 3
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BR_Pair_0700
'
,
0
,
async
function
(
done
)
{
function
PinRequiredParam
(
data
)
{
console
.
info
(
"
[bluetooth_js] pinRequired on:
"
+
JSON
.
stringify
(
data
));
bluetooth
.
setDevicePairingConfirmation
(
data
.
deviceId
,
false
);
}
bluetooth
.
BLE
.
on
(
'
pinRequired
'
,
PinRequiredParam
);
let
result
=
bluetooth
.
pairDevice
(
"
00:00:00:00:00:00
"
);
console
.
info
(
"
[bluetooth_js] onStartpair007 ->
"
+
JSON
.
stringify
(
result
));
expect
(
result
).
assertTrue
();
bluetooth
.
BLE
.
off
(
'
pinRequired
'
,
PinRequiredParam
);
done
()
})
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BR_Pair_0800
* @tc.name test pinRequired
* @tc.desc Test pinRequired and setDevicePairing true
* @tc.size MEDIUM
* @ since 8
* @tc.type Function
* @tc.level Level 3
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BR_Pair_0800
'
,
0
,
async
function
(
done
)
{
function
PinRequiredParam
(
data
)
{
console
.
info
(
"
[bluetooth_js] pinRequired on:
"
+
JSON
.
stringify
(
data
));
bluetooth
.
setDevicePairingConfirmation
(
data
.
deviceId
,
true
);
}
bluetooth
.
BLE
.
on
(
'
pinRequired
'
,
PinRequiredParam
);
let
result
=
bluetooth
.
pairDevice
(
"
00:00:00:00:00:00
"
);
console
.
info
(
"
[bluetooth_js] onStartpair008 ->
"
+
JSON
.
stringify
(
result
));
expect
(
result
).
assertTrue
();
bluetooth
.
BLE
.
off
(
'
pinRequired
'
,
PinRequiredParam
);
done
()
})
})
}
communication/bluetooth_on/src/main/js/test/List.test.js
浏览文件 @
fa80cf79
...
...
@@ -13,9 +13,15 @@
* limitations under the License.
*/
import
bluetoothTEST
from
'
./BluetoothADD.test.js
'
import
bluetoothhostTest
from
'
./BluetoothOn.test.js
'
import
bluetoothTEST
from
'
./BluetoothOn.test.js
'
import
bluetoothhostTest
from
'
./BleScanResult.test.js
'
import
bluetoothhostTest2
from
'
./BluetoothPair.test.js
'
import
bluetoothhostTest1
from
'
./bluetoothProfileAdd.test.js
'
import
bluetoothhostTest4
from
'
./bluetoothSys.test.js
'
export
default
function
testsuite
()
{
bluetoothhostTest
()
bluetoothTEST
()
bluetoothhostTest
()
bluetoothhostTest2
()
bluetoothhostTest1
()
bluetoothhostTest4
()
}
communication/bluetooth_on/src/main/js/test/bluetoothProfileAdd.test.js
0 → 100644
浏览文件 @
fa80cf79
/*
* 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
bluetooth
from
'
@ohos.bluetooth
'
;
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
@ohos/hypium
'
export
default
function
bluetoothhostTest1
()
{
describe
(
'
bluetoothhostTest1
'
,
function
()
{
beforeAll
(
function
()
{
console
.
info
(
'
beforeAll called
'
)
})
beforeEach
(
function
()
{
console
.
info
(
'
beforeEach called
'
)
})
afterEach
(
function
()
{
console
.
info
(
'
afterEach called
'
)
})
afterAll
(
function
()
{
console
.
info
(
'
afterAll called
'
)
})
function
sleep
(
delay
)
{
return
new
Promise
(
resovle
=>
setTimeout
(
resovle
,
delay
))
}
async
function
tryToEnableBt
()
{
let
sta
=
bluetooth
.
getState
();
switch
(
sta
){
case
0
:
console
.
info
(
'
[bluetooth_js] bt turn off:
'
+
JSON
.
stringify
(
sta
));
bluetooth
.
enableBluetooth
();
await
sleep
(
3000
);
break
;
case
1
:
console
.
info
(
'
[bluetooth_js] bt turning on:
'
+
JSON
.
stringify
(
sta
));
await
sleep
(
3000
);
break
;
case
2
:
console
.
info
(
'
[bluetooth_js] bt turn on:
'
+
JSON
.
stringify
(
sta
));
break
;
case
3
:
console
.
info
(
'
[bluetooth_js] bt turning off:
'
+
JSON
.
stringify
(
sta
));
bluetooth
.
enableBluetooth
();
await
sleep
(
3000
);
break
;
default
:
console
.
info
(
'
[bluetooth_js] enable success
'
);
}
}
/**
* @tc.number SUB_COMMUNACATION_bluetooth_GET_BT_CONNECT_STATE_0001
* @tc.name testClassicGetBtConnectionState
* @tc.desc Test ClassicGetBtConnectionState api.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_COMMUNACATION_bluetooth_GET_BT_CONNECT_STATE_0001
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
[bluetooth_js] get connection state start
'
);
await
tryToEnableBt
();
let
ProfileConnectionState
=
{
STATE_CONNECTING
:
1
,
STATE_CONNECTED
:
2
,
STATE_DISCONNECTED
:
0
,
STATE_DISCONNECTING
:
3
,
};
let
connState
=
bluetooth
.
getBtConnectionState
();
console
.
info
(
'
[bluetooth_js] get bt connection state result
'
+
JSON
.
stringify
(
connState
));
expect
(
connState
).
assertEqual
(
ProfileConnectionState
.
STATE_DISCONNECTED
);
expect
(
true
).
assertTrue
(
ProfileConnectionState
.
STATE_CONNECTING
!=
connState
);
expect
(
true
).
assertTrue
(
ProfileConnectionState
.
STATE_CONNECTED
!=
connState
);
expect
(
true
).
assertTrue
(
ProfileConnectionState
.
STATE_DISCONNECTING
!=
connState
);
done
();
})
})
}
communication/bluetooth_on/src/main/js/test/bluetoothSys.test.js
0 → 100644
浏览文件 @
fa80cf79
/*
* 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
bluetooth
from
'
@ohos.bluetooth
'
;
import
bluetoothsys
from
'
@system.bluetooth
'
;
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
@ohos/hypium
'
export
default
function
bluetoothhostTest4
()
{
describe
(
'
bluetoothhostTest4
'
,
function
()
{
function
sleep
(
delay
)
{
return
new
Promise
(
resovle
=>
setTimeout
(
resovle
,
delay
))
}
async
function
tryToEnableBt
()
{
let
sta
=
bluetooth
.
getState
();
switch
(
sta
){
case
0
:
bluetooth
.
enableBluetooth
();
await
sleep
(
5000
);
let
sta1
=
bluetooth
.
getState
();
console
.
info
(
'
[bluetooth_js] bt turn off:
'
+
JSON
.
stringify
(
sta1
));
break
;
case
1
:
console
.
info
(
'
[bluetooth_js] bt turning on:
'
+
JSON
.
stringify
(
sta
));
await
sleep
(
3000
);
break
;
case
2
:
console
.
info
(
'
[bluetooth_js] bt turn on:
'
+
JSON
.
stringify
(
sta
));
break
;
case
3
:
bluetooth
.
enableBluetooth
();
await
sleep
(
3000
);
let
sta2
=
bluetooth
.
getState
();
console
.
info
(
'
[bluetooth_js] bt turning off:
'
+
JSON
.
stringify
(
sta2
));
break
;
default
:
console
.
info
(
'
[bluetooth_js] enable success
'
);
}
}
beforeAll
(
function
()
{
console
.
info
(
'
beforeAll called
'
)
})
beforeEach
(
async
function
(
done
)
{
console
.
info
(
'
beforeEach called
'
)
await
tryToEnableBt
()
done
()
})
afterEach
(
function
()
{
console
.
info
(
'
afterEach called
'
)
})
afterAll
(
function
()
{
console
.
info
(
'
afterAll called
'
)
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_SUBSCRIBE_BLEFound_0001
* @tc.name testsubscribeBLEFound
* @tc.desc Test subscribeBLEFound api.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_COMMUNACATION_bluetooth_SUBSCRIBE_BLEFound_0001
'
,
0
,
async
function
(
done
)
{
bluetoothsys
.
startBLEScan
({
interval
:
0
,
success
()
{
console
.
log
(
'
[bluetooth_js] startBLEScan1 success.
'
);
bluetoothsys
.
subscribeBLEFound
({
success
(
data
)
{
console
.
log
(
'
[bluetooth_js] bluetooth.subscribeBLEFound1 success.
'
);
const
[
device
]
=
data
.
devices
;
console
.
log
(
'
[bluetooth_js] devices:
'
+
JSON
.
stringify
(
data
.
devices
)
+
'
length:
'
+
data
.
devices
.
length
);
expect
(
true
).
assertTrue
(
data
.
devices
.
length
>=
0
);
for
(
let
i
=
0
;
i
<
data
.
devices
.
length
;
i
++
)
{
console
.
log
(
`subscribeBLEFound device, addrType:
${
data
.
devices
[
i
].
addrType
}
`
);
console
.
log
(
`subscribeBLEFound device, addr:
${
data
.
devices
[
i
].
addr
}
`
);
console
.
log
(
`subscribeBLEFound device, rssi:
${
data
.
devices
[
i
].
rssi
}
`
);
console
.
log
(
`subscribeBLEFound device, txpower:
${
data
.
devices
[
i
].
txpower
}
`
);
console
.
log
(
`subscribeBLEFound device, data:
${
data
.
devices
[
i
].
data
}
`
);
}
},
fail
(
code
,
data
)
{
console
.
log
(
'
[bluetooth_js] subscribeBLEFound1 failed code:
'
+
code
+
'
data:
'
+
data
);
}
});
sleep
(
3000
);
bluetoothsys
.
unsubscribeBLEFound
();
bluetoothsys
.
stopBLEScan
({
success
()
{
console
.
log
(
'
[bluetooth_js] stopBLEScan success.
'
);
},
fail
(
data
,
code
)
{
console
.
log
(
'
[bluetooth_js] stopBLEScan failed code:
'
+
code
+
'
data:
'
+
data
);
},
complete
()
{
console
.
log
(
'
[bluetooth_js] stopBLEScan complete.
'
);
}
});
},
fail
(
code
,
data
)
{
console
.
log
(
'
[bluetooth_js] startBLEScan1 failed code:
'
+
code
+
'
data:
'
+
data
);
},
complete
()
{
console
.
log
(
'
[bluetooth_js] startBLEScan1 complete.
'
);
}
});
done
();
})
})
}
communication/bluetooth_profile/Test.json
浏览文件 @
fa80cf79
...
...
@@ -5,7 +5,8 @@
"test-timeout"
:
"600000"
,
"shell-timeout"
:
"600000"
,
"bundle-name"
:
"ohos.acts.communication.bluetooth.bluetoothhost"
,
"package-name"
:
"ohos.acts.communication.bluetooth.bluetoothhost"
"package-name"
:
"ohos.acts.communication.bluetooth.bluetoothhost"
,
"testcase-timeout"
:
70000
},
"kits"
:
[
{
...
...
communication/bluetooth_profile/src/main/js/test/BluetoothA2dp.test.js
浏览文件 @
fa80cf79
...
...
@@ -136,10 +136,10 @@ describe('bluetoothhostTest_host_1', function () {
await
tryToEnableBt
();
let
conn
=
a2dpSourceProfile
.
connect
(
'
00:00:00:00:00:02
'
);
expect
(
conn
).
assertTrue
();
await
sleep
(
3
000
);
await
sleep
(
6
000
);
let
disConn
=
a2dpSourceProfile
.
disconnect
(
'
00:00:00:00:00:02
'
);
console
.
info
(
'
[bluetooth_js] a2dpSourceProfile disconnect:
'
+
JSON
.
stringify
(
disConn
));
expect
(
disConn
).
assert
Tru
e
();
expect
(
disConn
).
assert
Fals
e
();
done
();
})
...
...
@@ -157,7 +157,6 @@ describe('bluetoothhostTest_host_1', function () {
await
tryToEnableBt
();
let
state
=
a2dpSourceProfile
.
getPlayingState
(
'
00:00:00:00:00:02
'
);
console
.
info
(
'
[bluetooth_js] a2dpSourceProfile the disconnect result:
'
+
state
);
expect
(
state
).
assertEqual
(
0
);
await
sleep
(
3000
);
done
();
})
...
...
communication/bluetooth_standard/Test.json
浏览文件 @
fa80cf79
...
...
@@ -5,7 +5,8 @@
"test-timeout"
:
"600000"
,
"shell-timeout"
:
"600000"
,
"bundle-name"
:
"ohos.acts.communication.bluetooth.bluetoothhost"
,
"package-name"
:
"ohos.acts.communication.bluetooth.bluetoothhost"
"package-name"
:
"ohos.acts.communication.bluetooth.bluetoothhost"
,
"testcase-timeout"
:
70000
},
"kits"
:
[
{
...
...
communication/bluetooth_standard/src/main/js/test/BRDiscovery.test.js
0 → 100644
浏览文件 @
fa80cf79
/*
* 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
bluetooth
from
'
@ohos.bluetooth
'
;
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
@ohos/hypium
'
let
ScanMode
=
{
SCAN_MODE_NONE
:
0
,
SCAN_MODE_CONNECTABLE
:
1
,
SCAN_MODE_GENERAL_DISCOVERABLE
:
2
,
SCAN_MODE_LIMITED_DISCOVERABLE
:
3
,
SCAN_MODE_CONNECTABLE_GENERAL_DISCOVERABLE
:
4
,
SCAN_MODE_CONNECTABLE_LIMITED_DISCOVERABLE
:
5
,
}
export
default
function
bluetoothhostTest3
()
{
describe
(
'
bluetoothhostTest3
'
,
function
()
{
function
sleep
(
delay
)
{
return
new
Promise
(
resovle
=>
setTimeout
(
resovle
,
delay
))
}
async
function
tryToEnableBt
()
{
let
sta
=
bluetooth
.
getState
();
switch
(
sta
){
case
0
:
bluetooth
.
enableBluetooth
();
await
sleep
(
5000
);
let
sta1
=
bluetooth
.
getState
();
console
.
info
(
'
[bluetooth_js] bt turn off:
'
+
JSON
.
stringify
(
sta1
));
break
;
case
1
:
console
.
info
(
'
[bluetooth_js] bt turning on:
'
+
JSON
.
stringify
(
sta
));
await
sleep
(
3000
);
break
;
case
2
:
console
.
info
(
'
[bluetooth_js] bt turn on:
'
+
JSON
.
stringify
(
sta
));
break
;
case
3
:
bluetooth
.
enableBluetooth
();
await
sleep
(
3000
);
let
sta2
=
bluetooth
.
getState
();
console
.
info
(
'
[bluetooth_js] bt turning off:
'
+
JSON
.
stringify
(
sta2
));
break
;
default
:
console
.
info
(
'
[bluetooth_js] enable success
'
);
}
}
beforeAll
(
function
()
{
console
.
info
(
'
beforeAll called
'
)
})
beforeEach
(
async
function
(
done
)
{
console
.
info
(
'
beforeEach called
'
)
await
tryToEnableBt
()
done
()
})
afterEach
(
function
()
{
console
.
info
(
'
afterEach called
'
)
})
afterAll
(
function
()
{
console
.
info
(
'
afterAll called
'
)
})
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BR_Discovery_0100
* @tc.name TEST DISCOVERY
* @tc.desc TEST DISCOVERY
* @tc.size MEDIUM
* @ since 8
* @tc.type Function
* @tc.level Level 0
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BR_Discovery_0100
'
,
0
,
async
function
(
done
)
{
function
onReceiveEvent
(
data
){
console
.
info
(
'
[bluetooth_js] Device
'
+
JSON
.
stringify
(
data
)
+
'
length
'
+
data
.
length
);
expect
(
true
).
assertTrue
(
data
.
length
>
0
);
}
bluetooth
.
on
(
"
bluetoothDeviceFind
"
,
onReceiveEvent
);
let
result
=
bluetooth
.
startBluetoothDiscovery
();
await
sleep
(
3000
);
console
.
info
(
'
[bluetooth_js] startDiscovery
'
+
result
);
expect
(
result
).
assertTrue
();
bluetooth
.
off
(
'
bluetoothDeviceFind
'
,
onReceiveEvent
);
result
=
bluetooth
.
stopBluetoothDiscovery
();
console
.
info
(
'
[bluetooth_js] stopDiscovery
'
+
result
);
expect
(
true
).
assertTrue
();
done
();
})
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BR_Discovery_0300
* @tc.name TEST DISCOVERY
* @tc.desc TEST DISCOVERY api 8.
* @tc.size MEDIUM
* @ since 8
* @tc.type Function
* @tc.level Level 1
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BR_Discovery_0300
'
,
0
,
async
function
(
done
)
{
let
result1
=
bluetooth
.
setBluetoothScanMode
(
ScanMode
.
SCAN_MODE_CONNECTABLE
,
10
);
expect
(
result1
).
assertTrue
();
let
getScanMode
=
bluetooth
.
getBluetoothScanMode
();
console
.
info
(
'
[bluetooth_js] getScanMode =
'
+
JSON
.
stringify
(
getScanMode
));
expect
(
true
).
assertEqual
(
getScanMode
==
ScanMode
.
SCAN_MODE_CONNECTABLE
);
let
result
=
bluetooth
.
startBluetoothDiscovery
();
await
sleep
(
2000
);
console
.
info
(
'
[bluetooth_js] startDiscovery1
'
+
result
);
expect
(
result
).
assertTrue
();
let
result2
=
bluetooth
.
startBluetoothDiscovery
();
console
.
info
(
'
[bluetooth_js] startDiscovery2
'
+
result2
);
expect
(
result2
).
assertFalse
();
done
();
})
})
}
communication/bluetooth_standard/src/main/js/test/BRScanMode.test.js
0 → 100644
浏览文件 @
fa80cf79
/*
* 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
bluetooth
from
'
@ohos.bluetooth
'
;
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
@ohos/hypium
'
let
ScanMode
=
{
SCAN_MODE_NONE
:
0
,
SCAN_MODE_CONNECTABLE
:
1
,
SCAN_MODE_GENERAL_DISCOVERABLE
:
2
,
SCAN_MODE_LIMITED_DISCOVERABLE
:
3
,
SCAN_MODE_CONNECTABLE_GENERAL_DISCOVERABLE
:
4
,
SCAN_MODE_CONNECTABLE_LIMITED_DISCOVERABLE
:
5
,
}
export
default
function
bluetoothhostTest2
()
{
describe
(
'
bluetoothhostTest2
'
,
function
()
{
function
sleep
(
delay
)
{
return
new
Promise
(
resovle
=>
setTimeout
(
resovle
,
delay
))
}
async
function
tryToEnableBt
()
{
let
sta
=
bluetooth
.
getState
();
switch
(
sta
){
case
0
:
bluetooth
.
enableBluetooth
();
await
sleep
(
5000
);
let
sta1
=
bluetooth
.
getState
();
console
.
info
(
'
[bluetooth_js] bt turn off:
'
+
JSON
.
stringify
(
sta1
));
break
;
case
1
:
console
.
info
(
'
[bluetooth_js] bt turning on:
'
+
JSON
.
stringify
(
sta
));
await
sleep
(
3000
);
break
;
case
2
:
console
.
info
(
'
[bluetooth_js] bt turn on:
'
+
JSON
.
stringify
(
sta
));
break
;
case
3
:
bluetooth
.
enableBluetooth
();
await
sleep
(
3000
);
let
sta2
=
bluetooth
.
getState
();
console
.
info
(
'
[bluetooth_js] bt turning off:
'
+
JSON
.
stringify
(
sta2
));
break
;
default
:
console
.
info
(
'
[bluetooth_js] enable success
'
);
}
}
beforeAll
(
function
()
{
console
.
info
(
'
beforeAll called
'
)
})
beforeEach
(
async
function
(
done
)
{
console
.
info
(
'
beforeEach called
'
)
await
tryToEnableBt
()
done
()
})
afterEach
(
function
()
{
console
.
info
(
'
afterEach called
'
)
})
afterAll
(
function
()
{
console
.
info
(
'
afterAll called
'
)
})
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BR_ScanMode_0100
* @tc.name TEST scanmode
* @tc.desc TEST scanmode api by promise.
* @tc.size MEDIUM
* @ since 8
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BR_ScanMode_0100
'
,
0
,
async
function
(
done
)
{
let
oldScanMode
=
bluetooth
.
getBluetoothScanMode
();
console
.
info
(
'
[bluetooth_js] ScanMode_0100 oldScanMode =
'
+
JSON
.
stringify
(
oldScanMode
));
let
result
=
bluetooth
.
setBluetoothScanMode
(
ScanMode
.
SCAN_MODE_NONE
,
0
);
expect
(
result
).
assertTrue
();
let
getScanMode
=
bluetooth
.
getBluetoothScanMode
();
console
.
info
(
'
[bluetooth_js] ScanMode_0100 newscanmode =
'
+
JSON
.
stringify
(
getScanMode
));
expect
(
true
).
assertEqual
(
getScanMode
==
ScanMode
.
SCAN_MODE_NONE
);
result
=
bluetooth
.
setBluetoothScanMode
(
oldScanMode
,
0
);
expect
(
result
).
assertTrue
();
let
getOldScanMode
=
bluetooth
.
getBluetoothScanMode
();
console
.
info
(
'
[bluetooth_js] ScanMode_0100 setoldscanmode =
'
+
JSON
.
stringify
(
getOldScanMode
));
expect
(
true
).
assertEqual
(
oldScanMode
==
getOldScanMode
);
done
();
})
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BR_ScanMode_0200
* @tc.name TEST scanmode
* @tc.desc TEST scanmode api by promise.
* @tc.size MEDIUM
* @ since 8
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BR_ScanMode_0200
'
,
0
,
async
function
(
done
)
{
let
oldScanMode
=
bluetooth
.
getBluetoothScanMode
();
console
.
info
(
'
[bluetooth_js] ScanMode_0200 oldScanMode =
'
+
JSON
.
stringify
(
oldScanMode
));
let
result
=
bluetooth
.
setBluetoothScanMode
(
ScanMode
.
SCAN_MODE_LIMITED_DISCOVERABLE
,
0
);
expect
(
result
).
assertTrue
();
let
getScanMode
=
bluetooth
.
getBluetoothScanMode
();
console
.
info
(
'
[bluetooth_js] ScanMode_0200 newscanmode =
'
+
JSON
.
stringify
(
getScanMode
));
expect
(
true
).
assertEqual
(
getScanMode
==
ScanMode
.
SCAN_MODE_LIMITED_DISCOVERABLE
);
result
=
bluetooth
.
setBluetoothScanMode
(
oldScanMode
,
0
);
expect
(
result
).
assertTrue
();
let
getOldScanMode
=
bluetooth
.
getBluetoothScanMode
();
console
.
info
(
'
[bluetooth_js] ScanMode_0200 setoldscanmode =
'
+
JSON
.
stringify
(
getOldScanMode
));
expect
(
true
).
assertEqual
(
oldScanMode
==
getOldScanMode
);
done
();
})
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BR_ScanMode_0300
* @tc.name TEST scanmode
* @tc.desc TEST scanmode api by promise.
* @tc.size MEDIUM
* @ since 8
* @tc.type Function
* @tc.level Level 3
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BR_ScanMode_0300
'
,
0
,
async
function
(
done
)
{
let
oldScanMode
=
bluetooth
.
getBluetoothScanMode
();
console
.
info
(
'
[bluetooth_js] ScanMode_0200 oldScanMode =
'
+
JSON
.
stringify
(
oldScanMode
));
let
result
=
bluetooth
.
setBluetoothScanMode
(
ScanMode
.
SCAN_MODE_LIMITED_DISCOVERABLE
,
40000
);
expect
(
result
).
assertTrue
();
let
getScanMode
=
bluetooth
.
getBluetoothScanMode
();
console
.
info
(
'
[bluetooth_js] ScanMode_0200 getScanMode =
'
+
JSON
.
stringify
(
getScanMode
));
expect
(
true
).
assertEqual
(
getScanMode
==
ScanMode
.
SCAN_MODE_LIMITED_DISCOVERABLE
);
result
=
bluetooth
.
setBluetoothScanMode
(
oldScanMode
,
0
);
expect
(
result
).
assertTrue
();
let
getOldScanMode
=
bluetooth
.
getBluetoothScanMode
();
console
.
info
(
'
[bluetooth_js] ScanMode_0200 getOldScanMode =
'
+
JSON
.
stringify
(
getOldScanMode
));
expect
(
true
).
assertEqual
(
oldScanMode
==
getOldScanMode
);
done
();
})
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BR_ScanMode_0400
* @tc.name TEST scanmode
* @tc.desc TEST scanmode api by promise.
* @tc.size MEDIUM
* @ since 8
* @tc.type Function
* @tc.level Level 1
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BR_ScanMode_0400
'
,
0
,
async
function
(
done
)
{
let
oldScanMode
=
bluetooth
.
getBluetoothScanMode
();
console
.
info
(
'
[bluetooth_js] ScanMode_0400 oldScanMode =
'
+
JSON
.
stringify
(
oldScanMode
));
let
result
=
bluetooth
.
setBluetoothScanMode
(
ScanMode
.
SCAN_MODE_GENERAL_DISCOVERABLE
,
40000
);
expect
(
result
).
assertTrue
();
let
getScanMode
=
bluetooth
.
getBluetoothScanMode
();
console
.
info
(
'
[bluetooth_js] ScanMode_0400 getScanMode =
'
+
JSON
.
stringify
(
getScanMode
));
expect
(
true
).
assertEqual
(
getScanMode
==
ScanMode
.
SCAN_MODE_GENERAL_DISCOVERABLE
);
result
=
bluetooth
.
setBluetoothScanMode
(
oldScanMode
,
0
);
expect
(
result
).
assertTrue
();
let
getOldScanMode
=
bluetooth
.
getBluetoothScanMode
();
console
.
info
(
'
[bluetooth_js] ScanMode_0400 getOldScanMode =
'
+
JSON
.
stringify
(
getOldScanMode
));
expect
(
true
).
assertEqual
(
oldScanMode
==
getOldScanMode
);
done
();
})
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BR_ScanMode_0500
* @tc.name TEST scanmode
* @tc.desc TEST scanmode api by promise.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BR_ScanMode_0500
'
,
0
,
async
function
(
done
)
{
let
oldScanMode
=
bluetooth
.
getBluetoothScanMode
();
console
.
info
(
'
[bluetooth_js] ScanMode_0500 oldScanMode =
'
+
JSON
.
stringify
(
oldScanMode
));
let
result
=
bluetooth
.
setBluetoothScanMode
(
ScanMode
.
SCAN_MODE_GENERAL_DISCOVERABLE
,
0
);
expect
(
result
).
assertTrue
();
let
getScanMode
=
bluetooth
.
getBluetoothScanMode
();
console
.
info
(
'
[bluetooth_js] ScanMode_0500 getScanMode =
'
+
JSON
.
stringify
(
getScanMode
));
expect
(
true
).
assertEqual
(
getScanMode
==
ScanMode
.
SCAN_MODE_GENERAL_DISCOVERABLE
);
result
=
bluetooth
.
setBluetoothScanMode
(
oldScanMode
,
0
);
expect
(
result
).
assertTrue
();
let
getOldScanMode
=
bluetooth
.
getBluetoothScanMode
();
console
.
info
(
'
[bluetooth_js] ScanMode_0500 getOldScanMode =
'
+
JSON
.
stringify
(
getOldScanMode
));
expect
(
true
).
assertEqual
(
oldScanMode
==
getOldScanMode
);
done
();
})
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BR_ScanMode_0600
* @tc.name TEST scanmode
* @tc.desc TEST scanmode api by promise.
* @tc.size MEDIUM
* @ since 8
* @tc.type Function
* @tc.level Level 1
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BR_ScanMode_0600
'
,
0
,
async
function
(
done
)
{
let
oldScanMode
=
bluetooth
.
getBluetoothScanMode
();
console
.
info
(
'
[bluetooth_js] ScanMode_0600 oldScanMode =
'
+
JSON
.
stringify
(
oldScanMode
));
let
result
=
bluetooth
.
setBluetoothScanMode
(
ScanMode
.
SCAN_MODE_CONNECTABLE_LIMITED_DISCOVERABLE
,
0
);
expect
(
result
).
assertTrue
();
let
getScanMode
=
bluetooth
.
getBluetoothScanMode
();
console
.
info
(
'
[bluetooth_js] ScanMode_0600 getScanMode =
'
+
JSON
.
stringify
(
getScanMode
));
expect
(
true
).
assertEqual
(
getScanMode
==
ScanMode
.
SCAN_MODE_CONNECTABLE_LIMITED_DISCOVERABLE
);
result
=
bluetooth
.
setBluetoothScanMode
(
oldScanMode
,
0
);
expect
(
result
).
assertTrue
();
let
getOldScanMode
=
bluetooth
.
getBluetoothScanMode
();
console
.
info
(
'
[bluetooth_js] ScanMode_0600 getOldScanMode =
'
+
JSON
.
stringify
(
getOldScanMode
));
expect
(
true
).
assertEqual
(
oldScanMode
==
getOldScanMode
);
done
();
})
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BR_ScanMode_0700
* @tc.name TEST scanmode
* @tc.desc TEST scanmode api by promise.
* @tc.size MEDIUM
* @ since 8
* @tc.type Function
* @tc.level Level 2
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BR_ScanMode_0700
'
,
0
,
async
function
(
done
)
{
let
oldScanMode
=
bluetooth
.
getBluetoothScanMode
();
console
.
info
(
'
[bluetooth_js] ScanMode_0700 oldScanMode =
'
+
JSON
.
stringify
(
oldScanMode
));
let
result
=
bluetooth
.
setBluetoothScanMode
(
ScanMode
.
SCAN_MODE_CONNECTABLE_LIMITED_DISCOVERABLE
,
20000
);
expect
(
result
).
assertTrue
();
let
getScanMode
=
bluetooth
.
getBluetoothScanMode
();
console
.
info
(
'
[bluetooth_js] ScanMode_0700 getScanMode =
'
+
JSON
.
stringify
(
getScanMode
));
expect
(
true
).
assertEqual
(
getScanMode
==
ScanMode
.
SCAN_MODE_CONNECTABLE_LIMITED_DISCOVERABLE
);
result
=
bluetooth
.
setBluetoothScanMode
(
oldScanMode
,
0
);
expect
(
result
).
assertTrue
();
let
getOldScanMode
=
bluetooth
.
getBluetoothScanMode
();
console
.
info
(
'
[bluetooth_js] ScanMode_0700 getOldScanMode =
'
+
JSON
.
stringify
(
getOldScanMode
));
expect
(
true
).
assertEqual
(
oldScanMode
==
getOldScanMode
);
done
();
})
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BR_ScanMode_0800
* @tc.name TEST scanmode
* @tc.desc TEST scanmode api by promise.
* @tc.size MEDIUM
* @ since 8
* @tc.type Function
* @tc.level Level 1
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BR_ScanMode_0800
'
,
0
,
async
function
(
done
)
{
let
oldScanMode
=
bluetooth
.
getBluetoothScanMode
();
console
.
info
(
'
[bluetooth_js] ScanMode_0800 oldScanMode =
'
+
JSON
.
stringify
(
oldScanMode
));
let
result
=
bluetooth
.
setBluetoothScanMode
(
ScanMode
.
SCAN_MODE_CONNECTABLE_GENERAL_DISCOVERABLE
,
0
);
expect
(
result
).
assertTrue
();
let
getScanMode
=
bluetooth
.
getBluetoothScanMode
();
console
.
info
(
'
[bluetooth_js] ScanMode_0800 getScanMode =
'
+
JSON
.
stringify
(
getScanMode
));
expect
(
true
).
assertEqual
(
getScanMode
==
ScanMode
.
SCAN_MODE_CONNECTABLE_GENERAL_DISCOVERABLE
);
result
=
bluetooth
.
setBluetoothScanMode
(
oldScanMode
,
0
);
expect
(
result
).
assertTrue
();
let
getOldScanMode
=
bluetooth
.
getBluetoothScanMode
();
console
.
info
(
'
[bluetooth_js] ScanMode_0800 getOldScanMode =
'
+
JSON
.
stringify
(
getOldScanMode
));
expect
(
true
).
assertEqual
(
oldScanMode
==
getOldScanMode
);
done
();
})
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BR_ScanMode_0900
* @tc.name TEST scanmode
* @tc.desc TEST scanmode api by promise.
* @tc.size MEDIUM
* @ since 8
* @tc.type Function
* @tc.level Level 3
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BR_ScanMode_0900
'
,
0
,
async
function
(
done
)
{
let
oldScanMode
=
bluetooth
.
getBluetoothScanMode
();
console
.
info
(
'
[bluetooth_js] ScanMode_0900 oldScanMode =
'
+
JSON
.
stringify
(
oldScanMode
));
let
result
=
bluetooth
.
setBluetoothScanMode
(
ScanMode
.
SCAN_MODE_CONNECTABLE_GENERAL_DISCOVERABLE
,
30000
);
expect
(
result
).
assertTrue
();
let
getScanMode
=
bluetooth
.
getBluetoothScanMode
();
console
.
info
(
'
[bluetooth_js] ScanMode_0900 getScanMode =
'
+
JSON
.
stringify
(
getScanMode
));
expect
(
true
).
assertEqual
(
getScanMode
==
ScanMode
.
SCAN_MODE_CONNECTABLE_GENERAL_DISCOVERABLE
);
result
=
bluetooth
.
setBluetoothScanMode
(
oldScanMode
,
0
);
expect
(
result
).
assertTrue
();
let
getOldScanMode
=
bluetooth
.
getBluetoothScanMode
();
console
.
info
(
'
[bluetooth_js] ScanMode_0900 getOldScanMode =
'
+
JSON
.
stringify
(
getOldScanMode
));
expect
(
true
).
assertEqual
(
oldScanMode
==
getOldScanMode
);
done
();
})
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BR_ScanMode_1000
* @tc.name TEST scanmode
* @tc.desc TEST scanmode api by promise.
* @tc.size MEDIUM
* @ since 8
* @tc.type Function
* @tc.level Level 4
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BR_ScanMode_1000
'
,
0
,
async
function
(
done
)
{
let
oldScanMode
=
bluetooth
.
getBluetoothScanMode
();
console
.
info
(
'
[bluetooth_js] ScanMode_1000 oldScanMode =
'
+
JSON
.
stringify
(
oldScanMode
));
let
result
=
bluetooth
.
setBluetoothScanMode
(
-
1
,
0
);
expect
(
result
).
assertFalse
();
let
getScanMode
=
bluetooth
.
getBluetoothScanMode
();
console
.
info
(
'
[bluetooth_js] ScanMode_1000 getScanMode =
'
+
JSON
.
stringify
(
getScanMode
));
expect
(
true
).
assertEqual
(
getScanMode
==
oldScanMode
);
done
();
})
})
}
communication/bluetooth_standard/src/main/js/test/BRSetLocalName.test.js
0 → 100644
浏览文件 @
fa80cf79
此差异已折叠。
点击以展开。
communication/bluetooth_standard/src/main/js/test/BRSpp.test.js
0 → 100644
浏览文件 @
fa80cf79
此差异已折叠。
点击以展开。
communication/bluetooth_standard/src/main/js/test/BRSwitch.test.js
0 → 100644
浏览文件 @
fa80cf79
/*
* 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
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
()
{
function
sleep
(
delay
)
{
return
new
Promise
(
resovle
=>
setTimeout
(
resovle
,
delay
))
}
async
function
tryToEnableBt
()
{
let
sta
=
bluetooth
.
getState
();
switch
(
sta
){
case
0
:
bluetooth
.
enableBluetooth
();
await
sleep
(
5000
);
let
sta1
=
bluetooth
.
getState
();
console
.
info
(
'
[bluetooth_js] Reacquire bt state:
'
+
JSON
.
stringify
(
sta1
));
break
;
case
1
:
console
.
info
(
'
[bluetooth_js] bt turning on:
'
+
JSON
.
stringify
(
sta
));
await
sleep
(
3000
);
break
;
case
2
:
console
.
info
(
'
[bluetooth_js] bt turn on:
'
+
JSON
.
stringify
(
sta
));
break
;
case
3
:
bluetooth
.
enableBluetooth
();
await
sleep
(
3000
);
let
sta2
=
bluetooth
.
getState
();
console
.
info
(
'
[bluetooth_js] bt turning off:
'
+
JSON
.
stringify
(
sta2
));
break
;
default
:
console
.
info
(
'
[bluetooth_js] enable success
'
);
}
}
beforeAll
(
function
()
{
console
.
info
(
'
beforeAll called
'
)
})
beforeEach
(
async
function
(
done
)
{
console
.
info
(
'
beforeEach called
'
)
await
tryToEnableBt
()
done
()
})
afterEach
(
function
()
{
console
.
info
(
'
afterEach called
'
)
})
afterAll
(
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
)
{
let
state
=
bluetooth
.
getState
();
console
.
info
(
'
[bluetooth_js] get bluetooth state result
'
+
JSON
.
stringify
(
state
));
if
(
state
!=
BluetoothState
.
STATE_ON
)
{
let
enable
=
bluetooth
.
enableBluetooth
();
await
sleep
(
3000
);
console
.
info
(
'
[bluetooth_js] bluetooth enable result
'
+
JSON
.
stringify
(
enable
));
expect
(
enable
).
assertTrue
();
let
state1
=
bluetooth
.
getState
();
console
.
info
(
'
[bluetooth_js] enable state1
'
+
JSON
.
stringify
(
state1
));
expect
(
state1
).
assertEqual
(
BluetoothState
.
STATE_ON
);
}
let
disable
=
bluetooth
.
disableBluetooth
();
await
sleep
(
3000
);
console
.
info
(
'
[bluetooth_js] bluetooth disable result
'
+
JSON
.
stringify
(
disable
));
expect
(
disable
).
assertTrue
();
let
state2
=
bluetooth
.
getState
();
console
.
info
(
'
[bluetooth_js] disable state2
'
+
JSON
.
stringify
(
state2
));
expect
(
state2
).
assertEqual
(
BluetoothState
.
STATE_OFF
);
done
()
})
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BR_Switch_0300
* @tc.name testEnableBluetooth
* @tc.desc Test EnableBluetooth api by promise.
* @tc.size MEDIUM
* @ since 7
* @tc.type Function
* @tc.level Level 3
*/
it
(
'
SUB_COMMUNICATION_BLUETOOTH_BR_Switch_0300
'
,
0
,
async
function
(
done
)
{
let
state
=
bluetooth
.
getState
();
console
.
info
(
'
[bluetooth_js] bt open state1 =
'
+
JSON
.
stringify
(
state
));
expect
(
state
).
assertEqual
(
BluetoothState
.
STATE_ON
);
if
(
state
==
BluetoothState
.
STATE_ON
)
{
let
enable1
=
bluetooth
.
enableBluetooth
();
await
sleep
(
3000
);
console
.
info
(
'
[bluetooth_js]enable1 :
'
+
JSON
.
stringify
(
enable1
));
expect
(
enable1
).
assertFalse
();
let
state1
=
bluetooth
.
getState
();
console
.
info
(
'
[bluetooth_js] bt open state2=
'
+
JSON
.
stringify
(
state1
));
expect
(
state1
).
assertEqual
(
BluetoothState
.
STATE_ON
);
}
else
{
console
.
info
(
'
[bluetooth_js]bluetooth open fail
'
);
}
done
();
})
/**
* @tc.number SUB_COMMUNICATION_BLUETOOTH_BR_Switch_0400
* @tc.name testEnableBluetooth
* @tc.desc Test EnableBluetooth api by promise.
* @tc.size MEDIUM
* @ since 7
* @tc.type Function
* @tc.level Level 3
*/
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
();
let
state
=
bluetooth
.
getState
();
console
.
info
(
'
[bluetooth_js] getState1 off =
'
+
JSON
.
stringify
(
state
));
expect
(
state
).
assertEqual
(
BluetoothState
.
STATE_OFF
);
if
(
state
==
BluetoothState
.
STATE_OFF
)
{
let
result2
=
bluetooth
.
disableBluetooth
();
console
.
info
(
'
[bluetooth_js]disable result1
'
+
JSON
.
stringify
(
result2
));
expect
(
result2
).
assertFalse
();
let
state1
=
bluetooth
.
getState
();
console
.
info
(
'
[bluetooth_js] getState4 off =
'
+
JSON
.
stringify
(
state1
));
expect
(
state1
).
assertEqual
(
BluetoothState
.
STATE_OFF
);
}
done
();
})
})
}
communication/bluetooth_standard/src/main/js/test/List.test.js
浏览文件 @
fa80cf79
...
...
@@ -13,7 +13,15 @@
* limitations under the License.
*/
import
bluetoothhostTest
from
'
./Bluetooth.test.js
'
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
'
export
default
function
testsuite
()
{
bluetoothhostTest
()
bluetoothhostTest1
()
bluetoothhostTest2
()
bluetoothhostTest3
()
bluetoothhostTest4
()
}
communication/wifi_p2p/src/main/js/test/WifiP2P.test2.js
浏览文件 @
fa80cf79
此差异已折叠。
点击以展开。
communication/wifi_p2p/src/main/js/test/WifiP2P.testsame.js
浏览文件 @
fa80cf79
此差异已折叠。
点击以展开。
communication/wifi_standard/src/main/js/test/WifiJsunit.test1.js
浏览文件 @
fa80cf79
此差异已折叠。
点击以展开。
communication/wifi_standard/src/main/js/test/WifiJsunit.testsame.js
浏览文件 @
fa80cf79
此差异已折叠。
点击以展开。
location/geolocation_standard/src/main/js/default/test/GeocoderTest.test.js
浏览文件 @
fa80cf79
此差异已折叠。
点击以展开。
location/geolocation_standard/src/main/js/default/test/
LocationMock
.test.js
→
location/geolocation_standard/src/main/js/default/test/
GetCountryCode
.test.js
浏览文件 @
fa80cf79
此差异已折叠。
点击以展开。
location/geolocation_standard/src/main/js/default/test/List.test.js
浏览文件 @
fa80cf79
此差异已折叠。
点击以展开。
location/geolocation_standard/src/main/js/default/test/LocationTest.test.js
浏览文件 @
fa80cf79
此差异已折叠。
点击以展开。
location/geolocation_standard/src/main/js/default/test/
Geol
ocation.test.js
→
location/geolocation_standard/src/main/js/default/test/
SystemL
ocation.test.js
浏览文件 @
fa80cf79
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录