| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
from autopilot import platform |
| 18 |
|
| 19 |
|
| 20 |
NEXUS4_DEVICE = 'Nexus4' |
| 21 |
NEXUS10_DEVICE = 'Nexus10' |
| 22 |
DEFAULT_DEVICES = (NEXUS4_DEVICE, NEXUS10_DEVICE) |
| 23 |
|
| 24 |
|
| 25 |
def get_device_simulation_scenarios(devices=DEFAULT_DEVICES): |
| 26 |
"""Return a list of devices to be simulated on tests. |
| 27 |
|
| 28 |
:param devices: The device or devices to simulate. Default value is all the |
| 29 |
officially supported devices. |
| 30 |
:type devices: string or sequence of strings. |
| 31 |
:return: A list of scenarios to be used with the testscenarios python |
| 32 |
module, with the values of app_width, app_height and grid_unit |
| 33 |
corresponding to the selected device. |
| 34 |
|
| 35 |
""" |
| 36 |
if platform.model() == 'Desktop': |
| 37 |
return _get_device_simulation_scenarios_for_desktop(devices) |
| 38 |
else: |
| 39 |
return [(platform.model(), {})] |
| 40 |
|
| 41 |
|
| 42 |
def _get_device_simulation_scenarios_for_desktop(devices): |
| 43 |
scenarios = [] |
| 44 |
if NEXUS4_DEVICE in devices: |
| 45 |
scenarios.append( |
| 46 |
('Simulating Nexus 4 in desktop', |
| 47 |
dict(app_width=768, app_height=1280, grid_unit_px=18)) |
| 48 |
) |
| 49 |
if NEXUS10_DEVICE in devices: |
| 50 |
scenarios.append( |
| 51 |
('Simulating Nexus 10 in desktop', |
| 52 |
dict(app_width=2560, app_height=1600, grid_unit_px=20)) |
| 53 |
) |
| 54 |
return scenarios |