Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(579)

Unified Diff: telemetry/telemetry/core/android_action_runner.py

Issue 2709523005: [Telemetry] Switch RunShellCommand clients to check_return=True (Closed)
Patch Set: revert change in chown command Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | telemetry/telemetry/internal/backends/chrome/android_browser_backend.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: telemetry/telemetry/core/android_action_runner.py
diff --git a/telemetry/telemetry/core/android_action_runner.py b/telemetry/telemetry/core/android_action_runner.py
index 38f3cf201fdd1aff6e8fd59699cf4070793e073f..07fdccb71d5f7fbd24fe7cd08058013f44569ac5 100644
--- a/telemetry/telemetry/core/android_action_runner.py
+++ b/telemetry/telemetry/core/android_action_runner.py
@@ -5,6 +5,8 @@
import logging
import time
+from devil.android.sdk import keyevent
+
import py_utils
@@ -68,15 +70,18 @@ class AndroidActionRunner(object):
Args:
string: The string to send to the device.
"""
- self._platform_backend.device.RunShellCommand('input text %s' % string)
+ self._platform_backend.device.RunShellCommand(
+ ['input', 'text', string], check_return=True)
- def InputKeyEvent(self, key):
+ def InputKeyEvent(self, keycode):
"""Send a single key input to the device.
+ See the devil.android.sdk.keyevent module for suitable keycode values.
+
Args:
- key: A key code number or name that will be sent to the device
+ keycode: A key code number that will be sent to the device.
"""
- self._platform_backend.device.RunShellCommand('input keyevent %s' % key)
+ self._platform_backend.device.SendKeyEvent(keycode)
def InputTap(self, x_coord, y_coord):
"""Perform a tap input at the given coordinates.
@@ -85,8 +90,8 @@ class AndroidActionRunner(object):
x_coord: The x coordinate of the tap event.
y_coord: The y coordinate of the tap event.
"""
- self._platform_backend.device.RunShellCommand('input tap %s %s' % (x_coord,
- y_coord))
+ self._platform_backend.device.RunShellCommand(
+ ['input', 'tap', str(x_coord), str(y_coord)], check_return=True)
def InputSwipe(self, left_start_coord, top_start_coord, left_end_coord,
top_end_coord, duration):
@@ -99,14 +104,15 @@ class AndroidActionRunner(object):
top_end_coord: The vertical ending coordinate of the gesture
duration: The length of time of the swipe in milliseconds
"""
- self._platform_backend.device.RunShellCommand(
- 'input swipe %s %s %s %s %s' % (left_start_coord, top_start_coord,
- left_end_coord, top_end_coord,
- duration))
+ cmd = ['input', 'swipe']
+ cmd.expand(str(x) for x in (left_start_coord, top_start_coord,
+ left_end_coord, top_end_coord, duration))
+ self._platform_backend.device.RunShellCommand(cmd, check_return=True)
def InputPress(self):
"""Perform a press input."""
- self._platform_backend.device.RunShellCommand('input press')
+ self._platform_backend.device.RunShellCommand(
+ ['input', 'press'], check_return=True)
def InputRoll(self, dx, dy):
"""Perform a roll input. This sends a simple zero-pressure move event.
@@ -115,7 +121,8 @@ class AndroidActionRunner(object):
dx: Change in the x coordinate due to move.
dy: Change in the y coordinate due to move.
"""
- self._platform_backend.device.RunShellCommand('input roll %s %s' % (dx, dy))
+ self._platform_backend.device.RunShellCommand(
+ ['input', 'roll', str(dx), str(dy)], check_return=True)
def TurnScreenOn(self):
"""If device screen is off, turn screen on.
@@ -153,7 +160,7 @@ class AndroidActionRunner(object):
return not self._platform_backend.IsScreenLocked()
if self._platform_backend.IsScreenLocked():
- self._platform_backend.device.RunShellCommand('input keyevent 82')
+ self.InputKeyEvent(keyevent.KEYCODE_MENU)
else:
logging.warning('Screen not locked when expected.')
return
« no previous file with comments | « no previous file | telemetry/telemetry/internal/backends/chrome/android_browser_backend.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698