proximity_sensor¶
Source code: proximity_sensor.py
A test to check if the proximity sensor triggers events properly.
Description¶
It captures the proximity events from the given sensor device
(usually /dev/proximity-*) and verifies if the close/far events are
triggered properly.
A typical use case of proximity sensor is controlling SAR.
Note that:
- This test doesn’t support station-based remote test yet. 
- This test stops - powerdservice when it is capturing the events.
Test Procedure¶
This test requires the operator to provide some actions.
- The test shows instruction to ask the operator to remove the cover. 
- Wait until the sensor value is small enough. 
- The test shows instruction to ask the operator to cover the sensor. 
- The test starts to wait for proximity events. 
- If the first captured event is not a - closeevent, the test ends with failure.
- The test shows instruction to ask the operator to remove the cover. 
- The test starts to wait for proximity events. 
- If the first captured event is not a - farevent, the test ends with failure.
- If timeout reaches before all the tasks done, the test also ends with failure. 
Dependency¶
Examples¶
Let’s assume we want to test the sensor device /dev/iio:device7, which
echo /sys/bus/iio/devices/iio:device7/name outputs sx9310, just add a test
item in the test list:
{
  "pytest_name": "proximity_sensor",
  "disable_services": [
    "powerd"
  ],
  "args": {
    "device_name": "sx9310"
  }
}
To provide the operator detail instructions, we can specify the messages to show in the test list:
{
  "pytest_name": "proximity_sensor",
  "disable_services": [
    "powerd"
  ],
  "args": {
    "device_name": "sx9310",
    "close_instruction": "i18n! Please cover the left edge by hand",
    "far_instruction": "i18n! Please remove the cover"
  }
}
To test the multiple sensor devices with the same device_name, add a test items in the test list:
{
  "pytest_name": "proximity_sensor",
  "disable_services": [
    "powerd"
  ],
  "args": {
    "device_name": "sx9324",
    "device_count": 2
  }
}
Test Arguments¶
| Name | Type | Description | 
|---|---|---|
| device_name | str, None | (optional; default:  | 
| device_count | int | (optional; default:  | 
| calibrate_path | str | (optional; default:  | 
| enable_sensor_sleep_secs | int, float | (optional; default:  | 
| sensor_value_path | str | (optional; default:  | 
| sensor_initial_max | int | (optional; default:  | 
| close_instruction | str, dict | (optional; default:  | 
| far_instruction | str, dict | (optional; default:  | 
| timeout | int | (optional; default:  |