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

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

Issue 772003002: Migrate DeviceUtils.EnableRoot to adb_wrapper (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years 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/device/device_utils.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 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 288
289 def testHasRoot_true(self): 289 def testHasRoot_true(self):
290 with self.assertCall(self.call.adb.Shell('ls /root'), 'foo\n'): 290 with self.assertCall(self.call.adb.Shell('ls /root'), 'foo\n'):
291 self.assertTrue(self.device.HasRoot()) 291 self.assertTrue(self.device.HasRoot())
292 292
293 def testHasRoot_false(self): 293 def testHasRoot_false(self):
294 with self.assertCall(self.call.adb.Shell('ls /root'), self.ShellError()): 294 with self.assertCall(self.call.adb.Shell('ls /root'), self.ShellError()):
295 self.assertFalse(self.device.HasRoot()) 295 self.assertFalse(self.device.HasRoot())
296 296
297 297
298 class DeviceUtilsEnableRootTest(DeviceUtilsOldImplTest): 298 class DeviceUtilsEnableRootTest(DeviceUtilsNewImplTest):
299 299
300 def testEnableRoot_succeeds(self): 300 def testEnableRoot_succeeds(self):
301 with self.assertCallsSequence([ 301 with self.assertCalls(
302 ('adb -s 0123456789abcdef shell getprop ro.build.type', 302 (self.call.device.IsUserBuild(), False),
303 'userdebug\r\n'), 303 self.call.adb.Root(),
304 ('adb -s 0123456789abcdef root', 'restarting adbd as root\r\n'), 304 self.call.adb.WaitForDevice()):
305 ('adb -s 0123456789abcdef wait-for-device', ''),
306 ('adb -s 0123456789abcdef wait-for-device', '')]):
307 self.device.EnableRoot() 305 self.device.EnableRoot()
308 306
309 def testEnableRoot_userBuild(self): 307 def testEnableRoot_userBuild(self):
310 with self.assertCallsSequence([ 308 with self.assertCalls(
311 ('adb -s 0123456789abcdef shell getprop ro.build.type', 'user\r\n')]): 309 (self.call.device.IsUserBuild(), True)):
312 with self.assertRaises(device_errors.CommandFailedError): 310 with self.assertRaises(device_errors.CommandFailedError):
313 self.device.EnableRoot() 311 self.device.EnableRoot()
314 312
315 def testEnableRoot_rootFails(self): 313 def testEnableRoot_rootFails(self):
316 with self.assertCallsSequence([ 314 with self.assertCalls(
317 ('adb -s 0123456789abcdef shell getprop ro.build.type', 315 (self.call.device.IsUserBuild(), False),
318 'userdebug\r\n'), 316 (self.call.adb.Root(), self.CommandError())):
319 ('adb -s 0123456789abcdef root', 'no\r\n'),
320 ('adb -s 0123456789abcdef wait-for-device', '')]):
321 with self.assertRaises(device_errors.CommandFailedError): 317 with self.assertRaises(device_errors.CommandFailedError):
322 self.device.EnableRoot() 318 self.device.EnableRoot()
323 319
324 320
325 class DeviceUtilsIsUserBuildTest(DeviceUtilsNewImplTest): 321 class DeviceUtilsIsUserBuildTest(DeviceUtilsNewImplTest):
326 322
327 def testIsUserBuild_yes(self): 323 def testIsUserBuild_yes(self):
328 with self.assertCall( 324 with self.assertCall(
329 self.call.device.GetProp('ro.build.type', cache=True), 'user'): 325 self.call.device.GetProp('ro.build.type', cache=True), 'user'):
330 self.assertTrue(self.device.IsUserBuild()) 326 self.assertTrue(self.device.IsUserBuild())
(...skipping 1212 matching lines...) Expand 10 before | Expand all | Expand 10 after
1543 self.device = device_utils.DeviceUtils(None) 1539 self.device = device_utils.DeviceUtils(None)
1544 with self.assertCalls('adb get-serialno', 'unknown'), ( 1540 with self.assertCalls('adb get-serialno', 'unknown'), (
1545 self.assertRaises(device_errors.NoDevicesError)): 1541 self.assertRaises(device_errors.NoDevicesError)):
1546 str(self.device) 1542 str(self.device)
1547 1543
1548 1544
1549 if __name__ == '__main__': 1545 if __name__ == '__main__':
1550 logging.getLogger().setLevel(logging.DEBUG) 1546 logging.getLogger().setLevel(logging.DEBUG)
1551 unittest.main(verbosity=2) 1547 unittest.main(verbosity=2)
1552 1548
OLDNEW
« no previous file with comments | « build/android/pylib/device/device_utils.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698