Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 """Provides a variety of device interactions based on adb. | 5 """Provides a variety of device interactions based on adb. |
| 6 | 6 |
| 7 Eventually, this will be based on adb_wrapper. | 7 Eventually, this will be based on adb_wrapper. |
| 8 """ | 8 """ |
| 9 # pylint: disable=W0613 | 9 # pylint: disable=W0613 |
| 10 | 10 |
| (...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 343 timeout_retry.WaitFor(boot_completed) | 343 timeout_retry.WaitFor(boot_completed) |
| 344 if wifi: | 344 if wifi: |
| 345 timeout_retry.WaitFor(wifi_enabled) | 345 timeout_retry.WaitFor(wifi_enabled) |
| 346 | 346 |
| 347 REBOOT_DEFAULT_TIMEOUT = 10 * _DEFAULT_TIMEOUT | 347 REBOOT_DEFAULT_TIMEOUT = 10 * _DEFAULT_TIMEOUT |
| 348 REBOOT_DEFAULT_RETRIES = _DEFAULT_RETRIES | 348 REBOOT_DEFAULT_RETRIES = _DEFAULT_RETRIES |
| 349 | 349 |
| 350 @decorators.WithTimeoutAndRetriesDefaults( | 350 @decorators.WithTimeoutAndRetriesDefaults( |
| 351 REBOOT_DEFAULT_TIMEOUT, | 351 REBOOT_DEFAULT_TIMEOUT, |
| 352 REBOOT_DEFAULT_RETRIES) | 352 REBOOT_DEFAULT_RETRIES) |
| 353 def Reboot(self, block=True, timeout=None, retries=None): | 353 def Reboot(self, block=True, wifi=False, timeout=None, retries=None): |
| 354 """Reboot the device. | 354 """Reboot the device. |
| 355 | 355 |
| 356 Args: | 356 Args: |
| 357 block: A boolean indicating if we should wait for the reboot to complete. | 357 block: A boolean indicating if we should wait for the reboot to complete. |
| 358 wifi: A boolean indicaring if we should wait for wifi to be enabled after | |
|
jbudorick
2015/02/03 14:53:29
nit: indicaring -> indicating
| |
| 359 the reboot. The option has no effect unless also block=True. | |
|
jbudorick
2015/02/03 14:53:28
nit: rephrase: "unless |block| is also True."
| |
| 358 timeout: timeout in seconds | 360 timeout: timeout in seconds |
| 359 retries: number of retries | 361 retries: number of retries |
| 360 | 362 |
| 361 Raises: | 363 Raises: |
| 362 CommandTimeoutError on timeout. | 364 CommandTimeoutError on timeout. |
| 363 DeviceUnreachableError on missing device. | 365 DeviceUnreachableError on missing device. |
| 364 """ | 366 """ |
| 365 def device_offline(): | 367 def device_offline(): |
| 366 return not self.IsOnline() | 368 return not self.IsOnline() |
| 367 | 369 |
| 368 self.adb.Reboot() | 370 self.adb.Reboot() |
| 369 self._cache = {} | 371 self._cache = {} |
| 370 timeout_retry.WaitFor(device_offline, wait_period=1) | 372 timeout_retry.WaitFor(device_offline, wait_period=1) |
| 371 if block: | 373 if block: |
| 372 self.WaitUntilFullyBooted() | 374 self.WaitUntilFullyBooted(wifi=wifi) |
| 373 | 375 |
| 374 INSTALL_DEFAULT_TIMEOUT = 4 * _DEFAULT_TIMEOUT | 376 INSTALL_DEFAULT_TIMEOUT = 4 * _DEFAULT_TIMEOUT |
| 375 INSTALL_DEFAULT_RETRIES = _DEFAULT_RETRIES | 377 INSTALL_DEFAULT_RETRIES = _DEFAULT_RETRIES |
| 376 | 378 |
| 377 @decorators.WithTimeoutAndRetriesDefaults( | 379 @decorators.WithTimeoutAndRetriesDefaults( |
| 378 INSTALL_DEFAULT_TIMEOUT, | 380 INSTALL_DEFAULT_TIMEOUT, |
| 379 INSTALL_DEFAULT_RETRIES) | 381 INSTALL_DEFAULT_RETRIES) |
| 380 def Install(self, apk_path, reinstall=False, timeout=None, retries=None): | 382 def Install(self, apk_path, reinstall=False, timeout=None, retries=None): |
| 381 """Install an APK. | 383 """Install an APK. |
| 382 | 384 |
| (...skipping 926 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1309 Returns: | 1311 Returns: |
| 1310 A Parallelizer operating over |devices|. | 1312 A Parallelizer operating over |devices|. |
| 1311 """ | 1313 """ |
| 1312 if not devices: | 1314 if not devices: |
| 1313 devices = adb_wrapper.AdbWrapper.GetDevices() | 1315 devices = adb_wrapper.AdbWrapper.GetDevices() |
| 1314 devices = [d if isinstance(d, cls) else cls(d) for d in devices] | 1316 devices = [d if isinstance(d, cls) else cls(d) for d in devices] |
| 1315 if async: | 1317 if async: |
| 1316 return parallelizer.Parallelizer(devices) | 1318 return parallelizer.Parallelizer(devices) |
| 1317 else: | 1319 else: |
| 1318 return parallelizer.SyncParallelizer(devices) | 1320 return parallelizer.SyncParallelizer(devices) |
| OLD | NEW |