Revert of Remove OneClickSigninHelper since it is no longer used. (patchset #5 id...
[chromium-blink-merge.git] / build / android / pylib / local / device / local_device_environment.py
blob72acb6e2ec44e71ce1922b88225888035123a68d
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
3 # found in the LICENSE file.
5 from pylib.base import environment
6 from pylib.device import adb_wrapper
7 from pylib.device import device_errors
8 from pylib.device import device_utils
9 from pylib.utils import parallelizer
12 class LocalDeviceEnvironment(environment.Environment):
14 def __init__(self, args, _error_func):
15 super(LocalDeviceEnvironment, self).__init__()
16 self._device = args.test_device
17 self._devices = []
18 self._max_tries = 1 + args.num_retries
19 self._tool_name = args.tool
21 #override
22 def SetUp(self):
23 # TODO(jbudorick): This can be refined to support filters etc.
24 available_devices = adb_wrapper.AdbWrapper.GetDevices()
25 if not available_devices:
26 raise device_errors.NoDevicesError
27 if self._device:
28 if self._device not in available_devices:
29 raise device_errors.DeviceUnreachableError(
30 'Could not find device %r' % self._device)
31 self._devices = [device_utils.DeviceUtils(self._device)]
32 else:
33 self._devices = [
34 device_utils.DeviceUtils(s)
35 for s in available_devices]
37 @property
38 def devices(self):
39 return self._devices
41 @property
42 def parallel_devices(self):
43 return parallelizer.SyncParallelizer(self._devices)
45 @property
46 def max_tries(self):
47 return self._max_tries
49 @property
50 def tool(self):
51 return self._tool_name
53 #override
54 def TearDown(self):
55 pass