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

Side by Side Diff: build/android/pylib/device/device_utils_test.py

Issue 392983003: Add a workaround for broken adb get-state call. (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 unified diff | Download patch
« no previous file with comments | « build/android/pylib/android_commands.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright 2014 The Chromium Authors. All rights reserved. 2 # Copyright 2014 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """ 6 """
7 Unit tests for the contents of device_utils.py (mostly DeviceUtils). 7 Unit tests for the contents of device_utils.py (mostly DeviceUtils).
8 """ 8 """
9 9
10 # pylint: disable=C0321 10 # pylint: disable=C0321
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 return type(self).AndroidCommandsCalls(self, cmd_ret, comp) 135 return type(self).AndroidCommandsCalls(self, cmd_ret, comp)
136 136
137 def setUp(self): 137 def setUp(self):
138 self.device = device_utils.DeviceUtils( 138 self.device = device_utils.DeviceUtils(
139 '0123456789abcdef', default_timeout=1, default_retries=0) 139 '0123456789abcdef', default_timeout=1, default_retries=0)
140 140
141 141
142 class DeviceUtilsIsOnlineTest(DeviceUtilsOldImplTest): 142 class DeviceUtilsIsOnlineTest(DeviceUtilsOldImplTest):
143 143
144 def testIsOnline_true(self): 144 def testIsOnline_true(self):
145 with self.assertCalls('adb -s 0123456789abcdef get-state', 145 with self.assertCalls('adb -s 0123456789abcdef devices',
146 'device\r\n'): 146 '00123456789abcdef device\r\n'):
147 self.assertTrue(self.device.IsOnline()) 147 self.assertTrue(self.device.IsOnline())
148 148
149 def testIsOnline_false(self): 149 def testIsOnline_false(self):
150 with self.assertCalls('adb -s 0123456789abcdef get-state', '\r\n'): 150 with self.assertCalls('adb -s 0123456789abcdef devices', '\r\n'):
151 self.assertFalse(self.device.IsOnline()) 151 self.assertFalse(self.device.IsOnline())
152 152
153 153
154 class DeviceUtilsHasRootTest(DeviceUtilsOldImplTest): 154 class DeviceUtilsHasRootTest(DeviceUtilsOldImplTest):
155 155
156 def testHasRoot_true(self): 156 def testHasRoot_true(self):
157 with self.assertCalls("adb -s 0123456789abcdef shell 'ls /root'", 157 with self.assertCalls("adb -s 0123456789abcdef shell 'ls /root'",
158 'foo\r\n'): 158 'foo\r\n'):
159 self.assertTrue(self.device.HasRoot()) 159 self.assertTrue(self.device.HasRoot())
160 160
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 with self.assertRaises(device_errors.CommandTimeoutError): 302 with self.assertRaises(device_errors.CommandTimeoutError):
303 self.device.WaitUntilFullyBooted(wifi=False) 303 self.device.WaitUntilFullyBooted(wifi=False)
304 304
305 305
306 class DeviceUtilsRebootTest(DeviceUtilsOldImplTest): 306 class DeviceUtilsRebootTest(DeviceUtilsOldImplTest):
307 307
308 def testReboot_nonBlocking(self): 308 def testReboot_nonBlocking(self):
309 with mock.patch('time.sleep'): 309 with mock.patch('time.sleep'):
310 with self.assertCallsSequence([ 310 with self.assertCallsSequence([
311 ('adb -s 0123456789abcdef reboot', ''), 311 ('adb -s 0123456789abcdef reboot', ''),
312 ('adb -s 0123456789abcdef get-state', 'unknown\r\n'), 312 ('adb -s 0123456789abcdef devices', 'unknown\r\n'),
313 ('adb -s 0123456789abcdef wait-for-device', ''), 313 ('adb -s 0123456789abcdef wait-for-device', ''),
314 ('adb -s 0123456789abcdef shell pm path android', 314 ('adb -s 0123456789abcdef shell pm path android',
315 'package:this.is.a.test.package'), 315 'package:this.is.a.test.package'),
316 ("adb -s 0123456789abcdef shell 'echo $EXTERNAL_STORAGE'", 316 ("adb -s 0123456789abcdef shell 'echo $EXTERNAL_STORAGE'",
317 '/fake/storage/path\r\n'), 317 '/fake/storage/path\r\n'),
318 ("adb -s 0123456789abcdef shell 'ls /fake/storage/path'", 318 ("adb -s 0123456789abcdef shell 'ls /fake/storage/path'",
319 'nothing\r\n')]): 319 'nothing\r\n')]):
320 self.device.Reboot(block=False) 320 self.device.Reboot(block=False)
321 321
322 def testReboot_blocking(self): 322 def testReboot_blocking(self):
323 with mock.patch('time.sleep'): 323 with mock.patch('time.sleep'):
324 with self.assertCallsSequence([ 324 with self.assertCallsSequence([
325 ('adb -s 0123456789abcdef reboot', ''), 325 ('adb -s 0123456789abcdef reboot', ''),
326 ('adb -s 0123456789abcdef get-state', 'unknown\r\n'), 326 ('adb -s 0123456789abcdef devices', 'unknown\r\n'),
327 ('adb -s 0123456789abcdef wait-for-device', ''), 327 ('adb -s 0123456789abcdef wait-for-device', ''),
328 ('adb -s 0123456789abcdef shell pm path android', 328 ('adb -s 0123456789abcdef shell pm path android',
329 'package:this.is.a.test.package'), 329 'package:this.is.a.test.package'),
330 ("adb -s 0123456789abcdef shell 'echo $EXTERNAL_STORAGE'", 330 ("adb -s 0123456789abcdef shell 'echo $EXTERNAL_STORAGE'",
331 '/fake/storage/path\r\n'), 331 '/fake/storage/path\r\n'),
332 ("adb -s 0123456789abcdef shell 'ls /fake/storage/path'", 332 ("adb -s 0123456789abcdef shell 'ls /fake/storage/path'",
333 'nothing\r\n'), 333 'nothing\r\n'),
334 ('adb -s 0123456789abcdef wait-for-device', ''), 334 ('adb -s 0123456789abcdef wait-for-device', ''),
335 ('adb -s 0123456789abcdef shell getprop sys.boot_completed', 335 ('adb -s 0123456789abcdef shell getprop sys.boot_completed',
336 '1\r\n'), 336 '1\r\n'),
(...skipping 1016 matching lines...) Expand 10 before | Expand all | Expand 10 after
1353 'adb -s 0123456789abcdef shell ' 1353 'adb -s 0123456789abcdef shell '
1354 'setprop this.is.a.test.property "test_property_value"', 1354 'setprop this.is.a.test.property "test_property_value"',
1355 ''): 1355 ''):
1356 self.device.SetProp('this.is.a.test.property', 'test_property_value') 1356 self.device.SetProp('this.is.a.test.property', 'test_property_value')
1357 1357
1358 1358
1359 if __name__ == '__main__': 1359 if __name__ == '__main__':
1360 logging.getLogger().setLevel(logging.DEBUG) 1360 logging.getLogger().setLevel(logging.DEBUG)
1361 unittest.main(verbosity=2) 1361 unittest.main(verbosity=2)
1362 1362
OLDNEW
« no previous file with comments | « build/android/pylib/android_commands.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698