bluetooth¶
Source code: bluetooth.py
A factory test to verify the functionality of bluetooth device.
Description¶
A bluetooth test to detect adapter, scan bluetooth device, check average RSSI value, and connect with the bluetooth input device.
To run this bluetooth test, the DUT must have at least one bluetooth adapter.
If argument scan_devices
is set, there should be at least one remote
bluetooth device.
If argument pair_with_match
is set, there should be a bluetooth input
device like a mouse.
Test Procedure¶
Setup a bluetooth input device (like a mouse) if needed.
Enable the connection ability of bluetooth on DUT.
A prompt message will be displayed on the UI if
prompt_scan_message
andscan_devices
is set.The bluetooth test will run automatically.
Dependency¶
Device API (
cros.factory.device.chromeos.bluetooth
).Bluetooth utility (
cros.factory.test.utils.bluetooth_utils
).
Examples¶
To detect the specified number of bluetooth adapter on DUT, add this in test list:
{
"pytest_name": "bluetooth",
"label": "Detect bluetooth adapter",
"related_components": [
"test_tags.TestCategory.WIFI"
],
"args": {
"expected_adapter_count": 1,
"scan_devices": false
}
}
To scan remote bluetooth device and try to find at least one device whose name contains ‘Chromebook’:
{
"pytest_name": "bluetooth",
"label": "Scan for Bluetooth device named Chromebook",
"related_components": [
"test_tags.TestCategory.WIFI"
],
"args": {
"expected_adapter_count": 1,
"scan_devices": true,
"keyword": "Chromebook"
}
}
To check the the largest average RSSI among all scanned devices is bigger than threshold:
{
"pytest_name": "bluetooth",
"label": "Scan for Bluetooth devices with a specific strength threshold",
"related_components": [
"test_tags.TestCategory.WIFI"
],
"args": {
"expected_adapter_count": 1,
"scan_devices": true,
"average_rssi_threshold": -60.0
}
}
To pair, connect with, and disconnect with the bluetooth device:
{
"inherit": "TestGroup",
"label": "Pair With Bluetooth Device",
"subtests": [
{
"pytest_name": "scan",
"label": "Scan Bluetooth Device Name",
"related_components": [
"test_tags.TestCategory.VPD"
],
"args": {
"device_data_key": "factory.bluetooth_device_name",
"label": "Bluetooth Device Name"
}
},
{
"pytest_name": "bluetooth",
"label": "Pair With Bluetooth Device",
"related_components": [
"test_tags.TestCategory.WIFI"
],
"args": {
"expected_adapter_count": 1,
"pair_with_match": true,
"scan_devices": true,
"scan_counts": 1,
"keyword": "eval! device.factory.bluetooth_device_name"
}
}
]
}
Test Arguments¶
Name |
Type |
Description |
---|---|---|
expected_adapter_count |
int |
(optional; default: |
manufacturer_id |
int, None |
(optional; default: |
detect_adapters_retry_times |
int |
(optional; default: |
detect_adapters_interval_secs |
int |
(optional; default: |
read_bluetooth_uuid_timeout_secs |
int, None |
(optional; default: |
scan_devices |
bool |
(optional; default: |
prompt_scan_message |
bool |
(optional; default: |
keyword |
str, None |
(optional; default: |
average_rssi_threshold |
float |
(optional; default: |
scan_counts |
int |
(optional; default: |
scan_timeout_secs |
int |
(optional; default: |
input_device_mac |
str, None |
(optional; default: |
input_device_mac_key |
str, None |
(optional; default: |
input_device_rssi_key |
str, None |
(optional; default: |
firmware_revision_string_key |
str, None |
(optional; default: |
firmware_revision_string |
str, None |
(optional; default: |
average_rssi_lower_threshold |
float, dict, None |
(optional; default: |
average_rssi_upper_threshold |
float, dict, None |
(optional; default: |
pair_with_match |
bool |
(optional; default: |
finish_after_pair |
bool |
(optional; default: |
unpair |
bool |
(optional; default: |
check_shift_pair_keys |
bool |
(optional; default: |
check_battery_charging |
bool |
(optional; default: |
read_battery_level |
int, None |
(optional; default: |
check_battery_level |
bool |
(optional; default: |
prompt_into_fixture |
bool |
(optional; default: |
use_charge_fixture |
bool |
(optional; default: |
reset_fixture |
bool |
(optional; default: |
start_charging |
bool |
(optional; default: |
enable_magnet |
bool |
(optional; default: |
reset_magnet |
bool |
(optional; default: |
stop_charging |
bool |
(optional; default: |
base_enclosure_serial_number |
str, None |
(optional; default: |
battery_log |
str, None |
(optional; default: |
expected_battery_level |
int |
(optional; default: |
log_path |
str, None |
(optional; default: |
keep_raw_logs |
bool |
(optional; default: |
test_host_id_file |
str, None |
(optional; default: |