tablet_mode¶
Source code: tablet_mode.py
Tests that certain conditions are met when in tablet mode.
Description¶
Currently, it check that the lid switch is not triggered and tablet mode event is triggered and in correct state.
Turning devices into tablet mode exercises the GMR sensor and the accelerometer.
Test Procedure¶
If prompt_flip_tablet is set:
The operator flips the device to make it enter tablet mode.
The operator clicks the button by using touch screen or external mouse.
If prompt_flip_notebook is set:
The operator flips the device to make it enter notebook mode.
The operator presses the space key.
Dependency¶
cros.factory.external.py_lib.evdev
cros.factory.test.utils.evdev_utils
Examples¶
To run the test, add this in test list:
{
"pytest_name": "tablet_mode",
"label": "Go To Tablet Mode And Go Back",
"run_if": "not constants.has_device_data or device.component.has_tabletmode",
"related_components": [
"test_tags.TestCategory.ACCELEROMETER"
],
"args": {
"timeout_secs": 3600,
"prompt_flip_tablet": true,
"prompt_flip_notebook": true,
"lid_filter": "cros_ec_buttons"
}
}
Set lid_filter to choose the lid sensor explicitly:
{
"pytest_name": "tablet_mode",
"label": "Go To Tablet Mode And Go Back With Specific Lid",
"run_if": "not constants.has_device_data or device.component.has_tabletmode",
"related_components": [
"test_tags.TestCategory.ACCELEROMETER"
],
"args": {
"timeout_secs": 3600,
"prompt_flip_tablet": true,
"prompt_flip_notebook": true,
"lid_filter": "Lid Switch"
}
}
To test screen rotation for Chrome and prompt operator to flip before and after the test, we can combine the test with tablet_rotation.py:
{
"label": "Screen Rotation",
"run_if": "not constants.has_device_data or device.component.has_tabletmode",
"subtests": [
{
"pytest_name": "tablet_mode",
"label": "Tablet Mode",
"run_if": "not constants.has_device_data or device.component.has_tabletmode",
"related_components": [
"test_tags.TestCategory.ACCELEROMETER"
],
"action_on_failure": "STOP",
"args": {
"timeout_secs": 3600,
"prompt_flip_tablet": true,
"prompt_flip_notebook": false,
"lid_filter": "cros_ec_buttons"
}
},
{
"pytest_name": "tablet_rotation",
"label": "Tablet Rotation Accelerometers",
"run_if": "not constants.has_device_data or (device.component.has_base_accelerometer and device.component.has_lid_accelerometer)",
"related_components": [
"test_tags.TestCategory.ACCELEROMETER"
],
"action_on_failure": "STOP",
"args": {
"spec_offset": [
1.5,
1.5
],
"timeout_secs": 3600,
"degrees_to_orientations": {
"base": {
"0": {
"in_accel_x": 0,
"in_accel_y": -1,
"in_accel_z": 0
},
"90": {
"in_accel_x": 1,
"in_accel_y": 0,
"in_accel_z": 0
},
"180": {
"in_accel_x": 0,
"in_accel_y": 1,
"in_accel_z": 0
},
"270": {
"in_accel_x": -1,
"in_accel_y": 0,
"in_accel_z": 0
}
},
"lid": {
"0": {
"in_accel_x": 0,
"in_accel_y": 1,
"in_accel_z": 0
},
"90": {
"in_accel_x": 1,
"in_accel_y": 0,
"in_accel_z": 0
},
"180": {
"in_accel_x": 0,
"in_accel_y": -1,
"in_accel_z": 0
},
"270": {
"in_accel_x": -1,
"in_accel_y": 0,
"in_accel_z": 0
}
}
}
}
},
{
"pytest_name": "tablet_rotation",
"label": "Tablet Rotation Base-Accel",
"run_if": "constants.has_device_data and device.component.has_base_accelerometer and not device.component.has_lid_accelerometer",
"related_components": [
"test_tags.TestCategory.ACCELEROMETER"
],
"action_on_failure": "STOP",
"args": {
"spec_offset": [
1.5,
1.5
],
"timeout_secs": 3600,
"degrees_to_orientations": {
"base": {
"0": {
"in_accel_x": 0,
"in_accel_y": -1,
"in_accel_z": 0
},
"90": {
"in_accel_x": 1,
"in_accel_y": 0,
"in_accel_z": 0
},
"180": {
"in_accel_x": 0,
"in_accel_y": 1,
"in_accel_z": 0
},
"270": {
"in_accel_x": -1,
"in_accel_y": 0,
"in_accel_z": 0
}
}
}
}
},
{
"pytest_name": "tablet_rotation",
"label": "Tablet Rotation Lid-Accel",
"run_if": "constants.has_device_data and not device.component.has_base_accelerometer and device.component.has_lid_accelerometer",
"related_components": [
"test_tags.TestCategory.ACCELEROMETER"
],
"action_on_failure": "STOP",
"args": {
"spec_offset": [
1.5,
1.5
],
"timeout_secs": 3600,
"degrees_to_orientations": {
"lid": {
"0": {
"in_accel_x": 0,
"in_accel_y": 1,
"in_accel_z": 0
},
"90": {
"in_accel_x": 1,
"in_accel_y": 0,
"in_accel_z": 0
},
"180": {
"in_accel_x": 0,
"in_accel_y": -1,
"in_accel_z": 0
},
"270": {
"in_accel_x": -1,
"in_accel_y": 0,
"in_accel_z": 0
}
}
}
}
},
{
"pytest_name": "tablet_mode",
"label": "Notebook Mode",
"run_if": "not constants.has_device_data or device.component.has_tabletmode",
"related_components": [
"test_tags.TestCategory.ACCELEROMETER"
],
"action_on_failure": "STOP",
"args": {
"timeout_secs": 3600,
"prompt_flip_tablet": false,
"prompt_flip_notebook": true,
"lid_filter": "cros_ec_buttons"
}
}
]
}
Test Arguments¶
Name |
Type |
Description |
---|---|---|
timeout_secs |
int |
(optional; default: |
lid_filter |
int, str, None |
(optional; default: |
tablet_filter |
int, str, None |
(optional; default: |
prompt_flip_tablet |
bool |
(optional; default: |
prompt_flip_notebook |
bool |
(optional; default: |