summaryrefslogtreecommitdiffstats
path: root/build
diff options
context:
space:
mode:
authorjbudorick <jbudorick@chromium.org>2015-04-21 07:02:52 -0700
committerCommit bot <commit-bot@chromium.org>2015-04-21 14:04:02 +0000
commitcdb5bb0b94d7d2716a0c826fca576a0efdd33511 (patch)
tree599d7a86fab17e70cd17c1221b3b509e90690521 /build
parentf0a9e71e6ad0b13397d45afeeeba7c0ced15b570 (diff)
downloadchromium_src-cdb5bb0b94d7d2716a0c826fca576a0efdd33511.zip
chromium_src-cdb5bb0b94d7d2716a0c826fca576a0efdd33511.tar.gz
chromium_src-cdb5bb0b94d7d2716a0c826fca576a0efdd33511.tar.bz2
[Android] More old_interface conversions in build/android/.
This also creates build/android/pylib/constants/ and moves the existing constants.py file into it as __init__.py. BUG=267773 Review URL: https://codereview.chromium.org/1092703002 Cr-Commit-Position: refs/heads/master@{#326025}
Diffstat (limited to 'build')
-rw-r--r--build/android/gyp/util/build_device.py2
-rw-r--r--build/android/pylib/constants/__init__.py (renamed from build/android/pylib/constants.py)5
-rw-r--r--build/android/pylib/constants/keyevent.py14
-rw-r--r--build/android/pylib/forwarder.py11
-rw-r--r--build/android/pylib/local/device/local_device_instrumentation_test_run.py37
-rw-r--r--build/android/pylib/monkey/test_runner.py17
-rw-r--r--build/android/pylib/utils/emulator.py22
7 files changed, 77 insertions, 31 deletions
diff --git a/build/android/gyp/util/build_device.py b/build/android/gyp/util/build_device.py
index b153a15..7e0d57b 100644
--- a/build/android/gyp/util/build_device.py
+++ b/build/android/gyp/util/build_device.py
@@ -40,7 +40,7 @@ class BuildDevice(object):
return self.id
def Install(self, *args, **kwargs):
- return self.device.old_interface.Install(*args, **kwargs)
+ return self.device.Install(*args, **kwargs)
def GetInstallMetadata(self, apk_package):
"""Gets the metadata on the device for the apk_package apk."""
diff --git a/build/android/pylib/constants.py b/build/android/pylib/constants/__init__.py
index 8f8e782..fb5ce6d 100644
--- a/build/android/pylib/constants.py
+++ b/build/android/pylib/constants/__init__.py
@@ -3,6 +3,9 @@
# found in the LICENSE file.
"""Defines a set of constants shared by test runners and other scripts."""
+
+# TODO(jbudorick): Split these constants into coherent modules.
+
# pylint: disable=W0212
import collections
@@ -13,7 +16,7 @@ import subprocess
DIR_SOURCE_ROOT = os.environ.get('CHECKOUT_SOURCE_ROOT',
os.path.abspath(os.path.join(os.path.dirname(__file__),
- os.pardir, os.pardir, os.pardir)))
+ os.pardir, os.pardir, os.pardir, os.pardir)))
ISOLATE_DEPS_DIR = os.path.join(DIR_SOURCE_ROOT, 'isolate_deps_dir')
CHROME_SHELL_HOST_DRIVEN_DIR = os.path.join(
diff --git a/build/android/pylib/constants/keyevent.py b/build/android/pylib/constants/keyevent.py
new file mode 100644
index 0000000..06736b3
--- /dev/null
+++ b/build/android/pylib/constants/keyevent.py
@@ -0,0 +1,14 @@
+# Copyright 2015 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+"""Android KeyEvent constants.
+
+http://developer.android.com/reference/android/view/KeyEvent.html
+"""
+
+KEYCODE_BACK = 4
+KEYCODE_DPAD_RIGHT = 22
+KEYCODE_ENTER = 66
+KEYCODE_MENU = 82
+
diff --git a/build/android/pylib/forwarder.py b/build/android/pylib/forwarder.py
index eb83d68..d16b9b1 100644
--- a/build/android/pylib/forwarder.py
+++ b/build/android/pylib/forwarder.py
@@ -288,11 +288,8 @@ class Forwarder(object):
self._device_forwarder_path_on_host,
Forwarder._DEVICE_FORWARDER_FOLDER)])
cmd = '%s %s' % (tool.GetUtilWrapper(), Forwarder._DEVICE_FORWARDER_PATH)
- (exit_code, output) = device.old_interface.GetAndroidToolStatusAndOutput(
- cmd, lib_path=Forwarder._DEVICE_FORWARDER_FOLDER)
- if exit_code != 0:
- raise Exception(
- 'Failed to start device forwarder:\n%s' % '\n'.join(output))
+ device.RunShellCommand(
+ cmd, env={'LD_LIBRARY_PATH': Forwarder._DEVICE_FORWARDER_FOLDER})
self._initialized_devices.add(device_serial)
def _KillHostLocked(self):
@@ -328,5 +325,5 @@ class Forwarder(object):
cmd = '%s %s --kill-server' % (tool.GetUtilWrapper(),
Forwarder._DEVICE_FORWARDER_PATH)
- device.old_interface.GetAndroidToolStatusAndOutput(
- cmd, lib_path=Forwarder._DEVICE_FORWARDER_FOLDER)
+ device.RunShellCommand(
+ cmd, env={'LD_LIBRARY_PATH': Forwarder._DEVICE_FORWARDER_FOLDER})
diff --git a/build/android/pylib/local/device/local_device_instrumentation_test_run.py b/build/android/pylib/local/device/local_device_instrumentation_test_run.py
index ac3f5b1..1dc3ed4 100644
--- a/build/android/pylib/local/device/local_device_instrumentation_test_run.py
+++ b/build/android/pylib/local/device/local_device_instrumentation_test_run.py
@@ -3,11 +3,14 @@
# found in the LICENSE file.
import logging
+import re
import time
from pylib import flag_changer
from pylib.base import base_test_result
from pylib.base import test_run
+from pylib.constants import keyevent
+from pylib.device import device_errors
from pylib.local.device import local_device_test_run
@@ -27,16 +30,36 @@ TIMEOUT_ANNOTATIONS = [
def DidPackageCrashOnDevice(package_name, device):
# Dismiss any error dialogs. Limit the number in case we have an error
# loop or we are failing to dismiss.
- for _ in xrange(10):
- package = device.old_interface.DismissCrashDialogIfNeeded()
- if not package:
- return False
- # Assume test package convention of ".test" suffix
- if package in package_name:
- return True
+ try:
+ for _ in xrange(10):
+ package = _DismissCrashDialog(device)
+ if not package:
+ return False
+ # Assume test package convention of ".test" suffix
+ if package in package_name:
+ return True
+ except device_errors.CommandFailedError:
+ logging.exception('Error while attempting to dismiss crash dialog.')
return False
+_CURRENT_FOCUS_CRASH_RE = re.compile(
+ r'\s*mCurrentFocus.*Application (Error|Not Responding): (\S+)}')
+
+
+def _DismissCrashDialog(device):
+ for l in device.RunShellCommand(
+ ['dumpsys', 'window', 'windows'], check_return=True):
+ m = re.match(_CURRENT_FOCUS_CRASH_RE, l)
+ if m:
+ device.SendKeyEvent(keyevent.KEYCODE_DPAD_RIGHT)
+ device.SendKeyEvent(keyevent.KEYCODE_DPAD_RIGHT)
+ device.SendKeyEvent(keyevent.KEYCODE_ENTER)
+ return m.group(2)
+
+ return None
+
+
class LocalDeviceInstrumentationTestRun(
local_device_test_run.LocalDeviceTestRun):
def __init__(self, env, test_instance):
diff --git a/build/android/pylib/monkey/test_runner.py b/build/android/pylib/monkey/test_runner.py
index 19dd339..3fd1797 100644
--- a/build/android/pylib/monkey/test_runner.py
+++ b/build/android/pylib/monkey/test_runner.py
@@ -10,8 +10,11 @@ import random
from pylib import constants
from pylib.base import base_test_result
from pylib.base import base_test_runner
+from pylib.device import device_errors
from pylib.device import intent
+_CHROME_PACKAGE = constants.PACKAGE_INFO['chrome'].package
+
class TestRunner(base_test_runner.BaseTestRunner):
"""A TestRunner instance runs a monkey test on a single device."""
@@ -87,9 +90,17 @@ class TestRunner(base_test_runner.BaseTestRunner):
test_name, base_test_result.ResultType.FAIL, log=output)
if 'chrome' in self._options.package:
logging.warning('Starting MinidumpUploadService...')
+ # TODO(jbudorick): Update this after upstreaming.
+ minidump_intent = intent.Intent(
+ action='%s.crash.ACTION_FIND_ALL' % _CHROME_PACKAGE,
+ package=self._package,
+ activity='%s.crash.MinidumpUploadService' % _CHROME_PACKAGE)
try:
- self.device.old_interface.StartCrashUploadService(self._package)
- except AssertionError as e:
- logging.error('Failed to start MinidumpUploadService: %s', e)
+ self.device.RunShellCommand(
+ ['am', 'startservice'] + minidump_intent.am_args,
+ as_root=True, check_return=True)
+ except device_errors.CommandFailedError:
+ logging.exception('Failed to start MinidumpUploadService')
+
results.AddResult(result)
return results, False
diff --git a/build/android/pylib/utils/emulator.py b/build/android/pylib/utils/emulator.py
index 81b9c98..26b9109 100644
--- a/build/android/pylib/utils/emulator.py
+++ b/build/android/pylib/utils/emulator.py
@@ -19,6 +19,7 @@ from pylib import android_commands
from pylib import cmd_helper
from pylib import constants
from pylib import pexpect
+from pylib.device import device_errors
from pylib.device import device_utils
from pylib.utils import time_profile
@@ -394,33 +395,30 @@ class Emulator(object):
"""
seconds_waited = 0
number_of_waits = 2 # Make sure we can wfd twice
- # TODO(jbudorick) Un-handroll this in the implementation switch.
- adb_cmd = "adb -s %s %s" % (self.device_serial, 'wait-for-device')
+
+ device = device_utils.DeviceUtils(self.device_serial)
while seconds_waited < self._LAUNCH_TIMEOUT:
try:
- run_command.RunCommand(adb_cmd,
- timeout_time=self._WAITFORDEVICE_TIMEOUT,
- retry_count=1)
+ device.adb.WaitForDevice(
+ timeout=self._WAITFORDEVICE_TIMEOUT, retries=1)
number_of_waits -= 1
if not number_of_waits:
break
- except errors.WaitForResponseTimedOutError:
+ except device_errors.CommandTimeoutError:
seconds_waited += self._WAITFORDEVICE_TIMEOUT
- adb_cmd = "adb -s %s %s" % (self.device_serial, 'kill-server')
- run_command.RunCommand(adb_cmd)
+ device.adb.KillServer()
self.popen.poll()
if self.popen.returncode != None:
raise EmulatorLaunchException('EMULATOR DIED')
+
if seconds_waited >= self._LAUNCH_TIMEOUT:
raise EmulatorLaunchException('TIMEOUT with wait-for-device')
+
logging.info('Seconds waited on wait-for-device: %d', seconds_waited)
if wait_for_boot:
# Now that we checked for obvious problems, wait for a boot complete.
# Waiting for the package manager is sometimes problematic.
- # TODO(jbudorick) Convert this once waiting for the package manager and
- # the external storage is no longer problematic.
- d = device_utils.DeviceUtils(self.device_serial)
- d.old_interface.WaitForSystemBootCompleted(self._WAITFORBOOT_TIMEOUT)
+ device.WaitUntilFullyBooted(timeout=self._WAITFORBOOT_TIMEOUT)
def Shutdown(self):
"""Shuts down the process started by launch."""