#!/usr/bin/env python # 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. # pylint: disable=protected-access import itertools import threading import unittest from devil import devil_env from devil.android import logcat_monitor from devil.android.sdk import adb_wrapper with devil_env.SysPath(devil_env.PYMOCK_PATH): import mock # pylint: disable=import-error def _CreateTestLog(raw_logcat=None): test_adb = adb_wrapper.AdbWrapper('0123456789abcdef') test_adb.Logcat = mock.Mock(return_value=(l for l in raw_logcat)) test_log = logcat_monitor.LogcatMonitor(test_adb, clear=False) return test_log class LogcatMonitorTest(unittest.TestCase): _TEST_THREADTIME_LOGCAT_DATA = [ '01-01 01:02:03.456 7890 0987 V LogcatMonitorTest: ' 'verbose logcat monitor test message 1',
import re import shlex import sys import devil_chromium from devil import devil_env from devil.android import apk_helper from devil.android import device_errors from devil.android import device_utils from devil.android import flag_changer from devil.android.sdk import adb_wrapper from devil.android.sdk import intent from devil.android.sdk import version_codes from devil.utils import run_tests_helper with devil_env.SysPath(os.path.join(os.path.dirname(__file__), '..', '..', 'third_party', 'colorama', 'src')): import colorama from incremental_install import installer from pylib import constants from pylib.symbols import deobfuscator # Matches messages only on pre-L (Dalvik) that are spammy and unimportant. _DALVIK_IGNORE_PATTERN = re.compile('|'.join([ r'^Added shared lib', r'^Could not find ', r'^DexOpt:', r'^GC_', r'^Late-enabling CheckJNI', r'^Link of class',
# Copyright 2019 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. """This module wraps bundletool.""" import json from devil import base_error from devil import devil_env from devil.utils import cmd_helper from devil.utils import lazy with devil_env.SysPath(devil_env.PY_UTILS_PATH): from py_utils import tempfile_ext _bundletool_path = lazy.WeakConstant( lambda: devil_env.config.FetchPath('bundletool')) def ExtractApks(output_dir, apks_path, abis, locales, features, pixel_density, sdk_version, modules=None): """Extracts splits from APKS archive. Args: output_dir: Directory to extract splits into.
#!/usr/bin/env python # 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. # pylint: disable=protected-access import itertools import unittest from devil import devil_env from devil.android import logcat_monitor from devil.android.sdk import adb_wrapper with devil_env.SysPath(devil_env.config.LocalPath('pymock')): import mock # pylint: disable=import-error def _CreateTestLog(raw_logcat=None): test_adb = adb_wrapper.AdbWrapper('0123456789abcdef') test_adb.Logcat = mock.Mock(return_value=(l for l in raw_logcat)) test_log = logcat_monitor.LogcatMonitor(test_adb, clear=False) return test_log class LogcatMonitorTest(unittest.TestCase): _TEST_THREADTIME_LOGCAT_DATA = [ '01-01 01:02:03.456 7890 0987 V LogcatMonitorTest: ' 'verbose logcat monitor test message 1', '01-01 01:02:03.457 8901 1098 D LogcatMonitorTest: '
#!/usr/bin/env python # 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. import argparse import sys import tempfile import unittest from devil import devil_env from devil.android import device_errors from devil.android import device_utils from devil.android.tools import script_common with devil_env.SysPath(devil_env.PYMOCK_PATH): import mock # pylint: disable=import-error with devil_env.SysPath(devil_env.DEPENDENCY_MANAGER_PATH): # pylint: disable=wrong-import-order from dependency_manager import exceptions class GetDevicesTest(unittest.TestCase): def testNoSpecs(self): devices = [ device_utils.DeviceUtils('123'), device_utils.DeviceUtils('456'), ] with mock.patch( 'devil.android.device_utils.DeviceUtils.HealthyDevices',
# 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. import os from devil import devil_env from devil.utils import lazy with devil_env.SysPath(devil_env.CATAPULT_BASE_PATH): from catapult_base import dependency_manager # pylint: disable=import-error def GetPath(build_tool): try: return devil_env.config.LocalPath(build_tool) except dependency_manager.NoPathFoundError: pass try: return _PathInLocalSdk(build_tool) except dependency_manager.NoPathFoundError: pass return devil_env.config.FetchPath(build_tool) def _PathInLocalSdk(build_tool): build_tools_path = _build_tools_path.read() return (os.path.join(build_tools_path, build_tool) if build_tools_path else None)
""" Function/method decorators that provide timeout and retry logic. """ import functools import itertools import sys from devil.android import device_errors from devil.utils import cmd_helper from devil.utils import reraiser_thread from devil.utils import timeout_retry from devil import devil_env with devil_env.SysPath(devil_env.SIX_PATH): import six # pylint: disable=wrong-import-order DEFAULT_TIMEOUT_ATTR = '_default_timeout' DEFAULT_RETRIES_ATTR = '_default_retries' def _TimeoutRetryWrapper(f, timeout_func, retries_func, retry_if_func=timeout_retry.AlwaysRetry, pass_values=False): """ Wraps a funcion with timeout and retry handling logic. Args: f: The function to wrap.
# Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. # pylint: disable=protected-access import logging import sys import unittest import mock from devil import devil_env _SYS_PATH_BEFORE = list(sys.path) _SAMPLE_PATH = '/path/to/fake/modules' with devil_env.SysPath(_SAMPLE_PATH): _SYS_PATH_WITH_SAMPLE = list(sys.path) _SYS_PATH_AFTER = list(sys.path) class DevilEnvTest(unittest.TestCase): def testSysPath(self): self.assertEquals(_SYS_PATH_BEFORE, _SYS_PATH_AFTER) self.assertEquals(_SYS_PATH_BEFORE + [_SAMPLE_PATH], _SYS_PATH_WITH_SAMPLE) def testGetEnvironmentVariableConfig_configType(self): with mock.patch('os.environ.get', mock.Mock(side_effect=lambda _env_var: None)): env_config = devil_env._GetEnvironmentVariableConfig() self.assertEquals('BaseConfig', env_config.get('config_type'))