def setUp(self):
     super(DeviceUtilsPushDeleteFilesTest, self).setUp()
     self.adb = adb_wrapper.AdbWrapper(self.serial)
     self.adb.WaitForDevice()
     self.device = device_utils.DeviceUtils(self.adb,
                                            default_timeout=10,
                                            default_retries=0)
Exemplo n.º 2
0
    def __init__(self, device=None):
        assert os.path.exists(ANDROID_DIR)
        sys.path.insert(0, ANDROID_DIR)

        # We import the dependencies only on demand, so that this file can be
        # imported unconditionally.
        import devil_chromium
        from devil.android import device_errors  # pylint: disable=import-error
        from devil.android import device_utils  # pylint: disable=import-error
        from devil.android.perf import cache_control  # pylint: disable=import-error
        from devil.android.perf import perf_control  # pylint: disable=import-error
        from devil.android.sdk import adb_wrapper  # pylint: disable=import-error
        global cache_control
        global device_errors
        global perf_control

        devil_chromium.Initialize()

        if not device:
            # Detect attached device if not specified.
            devices = adb_wrapper.AdbWrapper.Devices()
            assert devices, 'No devices detected'
            assert len(devices) == 1, 'Multiple devices detected.'
            device = str(devices[0])
        self.adb_wrapper = adb_wrapper.AdbWrapper(device)
        self.device = device_utils.DeviceUtils(self.adb_wrapper)

        # This remembers what we have already pushed to the device.
        self.pushed = set()
 def setUp(self):
     super(FlagChangerTest, self).setUp()
     self.adb = adb_wrapper.AdbWrapper(self.serial)
     self.adb.WaitForDevice()
     self.device = device_utils.DeviceUtils(self.adb,
                                            default_timeout=10,
                                            default_retries=0)
     # pylint: disable=protected-access
     self.cmdline_path = posixpath.join(flag_changer._CMDLINE_DIR,
                                        _CMDLINE_FILE)
     self.cmdline_path_legacy = posixpath.join(
         flag_changer._CMDLINE_DIR_LEGACY, _CMDLINE_FILE)
Exemplo n.º 4
0
  def __init__(self, options):
    super(AndroidPlatform, self).__init__(options)
    LoadAndroidBuildTools(ANDROID_BUILD_TOOLS)

    if not options.device:
      # Detect attached device if not specified.
      devices = adb_wrapper.AdbWrapper.Devices()
      assert devices and len(devices) == 1, (
          "None or multiple devices detected. Please specify the device on "
          "the command-line with --device")
      options.device = str(devices[0])
    self.adb_wrapper = adb_wrapper.AdbWrapper(options.device)
    self.device = device_utils.DeviceUtils(self.adb_wrapper)
  def testWaitFor_buffering(self):
    # Simulate an adb log stream which does not complete until the test tells it
    # to. This checks that the log matcher can receive individual lines from the
    # log reader thread even if adb is not producing enough output to fill an
    # entire file io buffer.
    finished_lock = threading.Lock()
    finished_lock.acquire()

    def LogGenerator():
      for line in type(self)._TEST_THREADTIME_LOGCAT_DATA:
        yield line
      finished_lock.acquire()

    test_adb = adb_wrapper.AdbWrapper('0123456789abcdef')
    test_adb.Logcat = mock.Mock(return_value=LogGenerator())
    test_log = logcat_monitor.LogcatMonitor(test_adb, clear=False)
    test_log.Start()

    actual_match = test_log.WaitFor(r'.*last line.*', None)
    finished_lock.release()
    self.assertTrue(actual_match)
    test_log.Stop()
    test_log.Close()
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
 def getTestInstance(self):
   """Creates a real AdbWrapper instance for testing."""
   return adb_wrapper.AdbWrapper(self.serial)
Exemplo n.º 8
0
 def setUp(self):
   super(PsOutputCompatibilityTests, self).setUp()
   self.adb = adb_wrapper.AdbWrapper(self.serial)
   self.adb.WaitForDevice()
   self.device = device_utils.DeviceUtils(self.adb, default_retries=0)
Exemplo n.º 9
0
 def setUp(self):
     self.device_serial = 'ABC12345678'
     self.adb = adb_wrapper.AdbWrapper(self.device_serial)
 def getTestInstance(self):
   """Creates a real AdbWrapper instance for testing."""
   devices = adb_wrapper.AdbWrapper.Devices()
   if not devices:
     self.skipTest('No test device available.')
   return adb_wrapper.AdbWrapper(devices[0])
Exemplo n.º 11
0
 def testDeviceUnreachable(self):
     with self.assertRaises(device_errors.DeviceUnreachableError):
         bad_adb = adb_wrapper.AdbWrapper('device_gone')
         bad_adb.Shell('echo test')
Exemplo n.º 12
0
 def setUp(self):
     super(TestAdbWrapper, self).setUp()
     self._adb = adb_wrapper.AdbWrapper(self.serial)
     self._adb.WaitForDevice()
 def setUp(self):
   self.adb = adb_wrapper.AdbWrapper('ABC12345678')