Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright 2015 The Chromium Authors. All rights reserved. | 1 # Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 import logging | 5 import logging |
| 6 import time | 6 import time |
| 7 | 7 |
| 8 from devil.android.sdk import keyevent | 8 from devil.android.sdk import keyevent |
| 9 | 9 |
| 10 import py_utils | 10 import py_utils |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 87 """Perform a tap input at the given coordinates. | 87 """Perform a tap input at the given coordinates. |
| 88 | 88 |
| 89 Args: | 89 Args: |
| 90 x_coord: The x coordinate of the tap event. | 90 x_coord: The x coordinate of the tap event. |
| 91 y_coord: The y coordinate of the tap event. | 91 y_coord: The y coordinate of the tap event. |
| 92 """ | 92 """ |
| 93 self._platform_backend.device.RunShellCommand( | 93 self._platform_backend.device.RunShellCommand( |
| 94 ['input', 'tap', str(x_coord), str(y_coord)], check_return=True) | 94 ['input', 'tap', str(x_coord), str(y_coord)], check_return=True) |
| 95 | 95 |
| 96 def InputSwipe(self, left_start_coord, top_start_coord, left_end_coord, | 96 def InputSwipe(self, left_start_coord, top_start_coord, left_end_coord, |
| 97 top_end_coord, duration): | 97 top_end_coord, duration): |
|
nednguyen
2017/04/13 20:55:26
Can you add smoke test coverage for this? Probably
| |
| 98 """Perform a swipe input. | 98 """Perform a swipe input. |
| 99 | 99 |
| 100 Args: | 100 Args: |
| 101 left_start_coord: The horizontal starting coordinate of the gesture | 101 left_start_coord: The horizontal starting coordinate of the gesture |
| 102 top_start_coord: The vertical starting coordinate of the gesture | 102 top_start_coord: The vertical starting coordinate of the gesture |
| 103 left_end_coord: The horizontal ending coordinate of the gesture | 103 left_end_coord: The horizontal ending coordinate of the gesture |
| 104 top_end_coord: The vertical ending coordinate of the gesture | 104 top_end_coord: The vertical ending coordinate of the gesture |
| 105 duration: The length of time of the swipe in milliseconds | 105 duration: The length of time of the swipe in milliseconds |
| 106 """ | 106 """ |
| 107 cmd = ['input', 'swipe'] | 107 cmd = ['input', 'swipe'] |
| 108 cmd.expand(str(x) for x in (left_start_coord, top_start_coord, | 108 cmd.extend(str(x) for x in (left_start_coord, top_start_coord, |
| 109 left_end_coord, top_end_coord, duration)) | 109 left_end_coord, top_end_coord, duration)) |
| 110 self._platform_backend.device.RunShellCommand(cmd, check_return=True) | 110 self._platform_backend.device.RunShellCommand(cmd, check_return=True) |
| 111 | 111 |
| 112 def InputPress(self): | 112 def InputPress(self): |
| 113 """Perform a press input.""" | 113 """Perform a press input.""" |
| 114 self._platform_backend.device.RunShellCommand( | 114 self._platform_backend.device.RunShellCommand( |
| 115 ['input', 'press'], check_return=True) | 115 ['input', 'press'], check_return=True) |
| 116 | 116 |
| 117 def InputRoll(self, dx, dy): | 117 def InputRoll(self, dx, dy): |
| 118 """Perform a roll input. This sends a simple zero-pressure move event. | 118 """Perform a roll input. This sends a simple zero-pressure move event. |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 159 def is_screen_unlocked(): | 159 def is_screen_unlocked(): |
| 160 return not self._platform_backend.IsScreenLocked() | 160 return not self._platform_backend.IsScreenLocked() |
| 161 | 161 |
| 162 if self._platform_backend.IsScreenLocked(): | 162 if self._platform_backend.IsScreenLocked(): |
| 163 self.InputKeyEvent(keyevent.KEYCODE_MENU) | 163 self.InputKeyEvent(keyevent.KEYCODE_MENU) |
| 164 else: | 164 else: |
| 165 logging.warning('Screen not locked when expected.') | 165 logging.warning('Screen not locked when expected.') |
| 166 return | 166 return |
| 167 | 167 |
| 168 py_utils.WaitFor(is_screen_unlocked, 5) | 168 py_utils.WaitFor(is_screen_unlocked, 5) |
| OLD | NEW |