from pylib import valgrind_tools
from pylib.base import base_test_result
from pylib.base import base_test_runner
+from pylib.device import adb_wrapper
from pylib.instrumentation import json_perf_parser
from pylib.instrumentation import test_result
if a.test_package == self.test_pkg.GetPackageName()]
assert len(cmdline_file) < 2, 'Multiple packages have the same test package'
if len(cmdline_file) and cmdline_file[0]:
- self.flags = flag_changer.FlagChanger(self.adb, cmdline_file[0])
+ self.flags = flag_changer.FlagChanger(self.device, cmdline_file[0])
if additional_flags:
self.flags.AddFlags(additional_flags)
else:
#override
def InstallTestPackage(self):
- self.test_pkg.Install(self.adb)
+ self.test_pkg.Install(self.device)
#override
def PushDataDeps(self):
# once across test runners.
if TestRunner._DEVICE_HAS_TEST_FILES.get(self.device, False):
logging.warning('Already copied test files to device %s, skipping.',
- self.device)
+ self.device.old_interface.GetDevice())
return
test_data = _GetDataFilesForTestSuite(self.test_pkg.GetApkName())
if test_data:
# Make sure SD card is ready.
- self.adb.WaitForSdCardReady(20)
+ self.device.old_interface.WaitForSdCardReady(20)
for p in test_data:
- self.adb.PushIfNeeded(
+ self.device.old_interface.PushIfNeeded(
os.path.join(constants.DIR_SOURCE_ROOT, p),
- os.path.join(self.adb.GetExternalStorage(), p))
+ os.path.join(self.device.old_interface.GetExternalStorage(), p))
# TODO(frankf): Specify test data in this file as opposed to passing
# as command-line.
host_src = dst_src[1]
host_test_files_path = '%s/%s' % (constants.DIR_SOURCE_ROOT, host_src)
if os.path.exists(host_test_files_path):
- self.adb.PushIfNeeded(host_test_files_path, '%s/%s/%s' % (
- self.adb.GetExternalStorage(), TestRunner._DEVICE_DATA_DIR,
- dst_layer))
+ self.device.old_interface.PushIfNeeded(
+ host_test_files_path,
+ '%s/%s/%s' % (
+ self.device.old_interface.GetExternalStorage(),
+ TestRunner._DEVICE_DATA_DIR,
+ dst_layer))
self.tool.CopyFiles()
- TestRunner._DEVICE_HAS_TEST_FILES[self.device] = True
+ TestRunner._DEVICE_HAS_TEST_FILES[
+ self.device.old_interface.GetDevice()] = True
def _GetInstrumentationArgs(self):
ret = {}
"""Takes a screenshot from the device."""
screenshot_name = os.path.join(constants.SCREENSHOTS_DIR, '%s.png' % test)
logging.info('Taking screenshot named %s', screenshot_name)
- self.adb.TakeScreenshot(screenshot_name)
+ self.device.old_interface.TakeScreenshot(screenshot_name)
def SetUp(self):
"""Sets up the test harness and device before all tests are run."""
super(TestRunner, self).SetUp()
- if not self.adb.IsRootEnabled():
+ if not self.device.old_interface.IsRootEnabled():
logging.warning('Unable to enable java asserts for %s, non rooted device',
- self.device)
+ str(self.device))
else:
- if self.adb.SetJavaAssertsEnabled(True):
- self.adb.Reboot(full_reboot=False)
+ if self.device.old_interface.SetJavaAssertsEnabled(True):
+ self.device.old_interface.Reboot(full_reboot=False)
# We give different default value to launch HTTP server based on shard index
# because it may have race condition when multiple processes are trying to
if self.coverage_dir:
coverage_basename = '%s.ec' % test
- self.coverage_device_file = '%s/%s/%s' % (self.adb.GetExternalStorage(),
- TestRunner._DEVICE_COVERAGE_DIR,
- coverage_basename)
+ self.coverage_device_file = '%s/%s/%s' % (
+ self.device.old_interface.GetExternalStorage(),
+ TestRunner._DEVICE_COVERAGE_DIR, coverage_basename)
self.coverage_host_file = os.path.join(
self.coverage_dir, coverage_basename)
"""
if not self._IsPerfTest(test):
return
- self.adb.Adb().SendCommand('shell rm ' +
- TestRunner._DEVICE_PERF_OUTPUT_SEARCH_PREFIX)
- self.adb.StartMonitoringLogcat()
+ self.device.old_interface.Adb().SendCommand(
+ 'shell rm ' + TestRunner._DEVICE_PERF_OUTPUT_SEARCH_PREFIX)
+ self.device.old_interface.StartMonitoringLogcat()
def TestTeardown(self, test, raw_result):
"""Cleans up the test harness after running a particular test.
self.TearDownPerfMonitoring(test)
if self.coverage_dir:
- self.adb.Adb().Pull(self.coverage_device_file, self.coverage_host_file)
- self.adb.RunShellCommand('rm -f %s' % self.coverage_device_file)
+ self.device.old_interface.Adb().Pull(
+ self.coverage_device_file, self.coverage_host_file)
+ self.device.old_interface.RunShellCommand(
+ 'rm -f %s' % self.coverage_device_file)
def TearDownPerfMonitoring(self, test):
"""Cleans up performance monitoring if the specified test required it.
raw_test_name = test.split('#')[1]
# Wait and grab annotation data so we can figure out which traces to parse
- regex = self.adb.WaitForLogMatch(re.compile('\*\*PERFANNOTATION\(' +
- raw_test_name +
- '\)\:(.*)'), None)
+ regex = self.device.old_interface.WaitForLogMatch(
+ re.compile('\*\*PERFANNOTATION\(' + raw_test_name + '\)\:(.*)'), None)
# If the test is set to run on a specific device type only (IE: only
# tablet or phone) and it is being run on the wrong device, the test
# Obtain the relevant perf data. The data is dumped to a
# JSON formatted file.
- json_string = self.adb.GetProtectedFileContents(
+ json_string = self.device.old_interface.GetProtectedFileContents(
'/data/data/com.google.android.apps.chrome/files/PerfTestData.txt')
if json_string:
def _SetupIndividualTestTimeoutScale(self, test):
timeout_scale = self._GetIndividualTestTimeoutScale(test)
- valgrind_tools.SetChromeTimeoutScale(self.adb, timeout_scale)
+ valgrind_tools.SetChromeTimeoutScale(self.device, timeout_scale)
def _GetIndividualTestTimeoutScale(self, test):
"""Returns the timeout scale for the given |test|."""
def _RunTest(self, test, timeout):
try:
- return self.adb.RunInstrumentationTest(
+ return self.device.old_interface.RunInstrumentationTest(
test, self.test_pkg.GetPackageName(),
self._GetInstrumentationArgs(), timeout)
- except android_commands.errors.WaitForResponseTimedOutError:
+ except (adb_wrapper.CommandTimeoutError,
+ # TODO(jbudorick) Remove this once the underlying implementations
+ # for the above are switched or wrapped.
+ android_commands.errors.WaitForResponseTimedOutError):
logging.info('Ran the test with timeout of %ds.' % timeout)
raise
if not log:
log = 'No information.'
result_type = base_test_result.ResultType.FAIL
- package = self.adb.DismissCrashDialogIfNeeded()
+ package = self.device.old_interface.DismissCrashDialogIfNeeded()
# Assume test package convention of ".test" suffix
if package and package in self.test_pkg.GetPackageName():
result_type = base_test_result.ResultType.CRASH
results.AddResult(result)
# Catch exceptions thrown by StartInstrumentation().
# See ../../third_party/android/testrunner/adb_interface.py
- except (android_commands.errors.WaitForResponseTimedOutError,
+ except (adb_wrapper.CommandTimeoutError,
+ adb_wrapper.DeviceUnreachableError,
+ # TODO(jbudorick) Remove these once the underlying implementations
+ # for the above are switched or wrapped.
+ android_commands.errors.WaitForResponseTimedOutError,
android_commands.errors.DeviceUnresponsiveError,
android_commands.errors.InstrumentationError), e:
if start_date_ms: