Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4654)

Unified Diff: chrome/test/chromedriver/test/test_environment.py

Issue 420273006: [Android] Fix DeviceUtils.__str__ when no serial is provided. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/test/chromedriver/test/test_environment.py
diff --git a/chrome/test/chromedriver/test/test_environment.py b/chrome/test/chromedriver/test/test_environment.py
index b3e0cc2447b669f9aae5f068e66963c4a959454c..daf498160af8dbc7da571611ada85475d4eec62a 100644
--- a/chrome/test/chromedriver/test/test_environment.py
+++ b/chrome/test/chromedriver/test/test_environment.py
@@ -18,8 +18,10 @@ _THIS_DIR = os.path.abspath(os.path.dirname(__file__))
if util.IsLinux():
sys.path.insert(0, os.path.join(chrome_paths.GetSrc(), 'build', 'android'))
+ from pylib import android_commands
from pylib import forwarder
from pylib import valgrind_tools
+ from pylib.device import device_errors
from pylib.device import device_utils
ANDROID_TEST_HTTP_PORT = 2311
@@ -94,7 +96,12 @@ class AndroidTestEnvironment(DesktopTestEnvironment):
def GlobalSetUp(self):
os.putenv('TEST_HTTP_PORT', str(ANDROID_TEST_HTTP_PORT))
os.putenv('TEST_HTTPS_PORT', str(ANDROID_TEST_HTTPS_PORT))
- self._device = device_utils.DeviceUtils(None)
+ devices = android_commands.GetAttachedDevices()
+ if not len(devices):
frankf 2014/07/28 22:52:31 if not devices:
jbudorick 2014/07/28 23:05:40 Done.
+ raise device_errors.DeviceUnreachableError('No devices attached.')
frankf 2014/07/28 22:52:31 doesn't this warrant a new type of exception, Devi
jbudorick 2014/07/28 23:05:40 It is. Added NoDevicesError.
+ elif len(devices) > 1:
+ logging.warning('Multiple devices attached. Using %s.' % devices[0])
+ self._device = device_utils.DeviceUtils(devices[0])
forwarder.Forwarder.Map(
[(ANDROID_TEST_HTTP_PORT, ANDROID_TEST_HTTP_PORT),
(ANDROID_TEST_HTTPS_PORT, ANDROID_TEST_HTTPS_PORT)],
@@ -102,7 +109,8 @@ class AndroidTestEnvironment(DesktopTestEnvironment):
# override
def GlobalTearDown(self):
- forwarder.Forwarder.UnmapAllDevicePorts(self._device)
+ if self._device:
+ forwarder.Forwarder.UnmapAllDevicePorts(self._device)
# override
def GetOS(self):

Powered by Google App Engine
This is Rietveld 408576698