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

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

Issue 1165623003: [Android] Allow gtests to pull app data off the device before clearing it. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 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
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 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 329
330 def testGetApplicationPath_fails(self): 330 def testGetApplicationPath_fails(self):
331 with self.assertCalls( 331 with self.assertCalls(
332 (self.call.adb.Shell('getprop ro.build.version.sdk'), '19\n'), 332 (self.call.adb.Shell('getprop ro.build.version.sdk'), '19\n'),
333 (self.call.adb.Shell('pm path android'), 333 (self.call.adb.Shell('pm path android'),
334 self.CommandError('ERROR. Is package manager running?\n'))): 334 self.CommandError('ERROR. Is package manager running?\n'))):
335 with self.assertRaises(device_errors.CommandFailedError): 335 with self.assertRaises(device_errors.CommandFailedError):
336 self.device.GetApplicationPath('android') 336 self.device.GetApplicationPath('android')
337 337
338 338
339 class DeviceUtilsGetApplicationDataDirectoryTest(DeviceUtilsTest):
340
341 def testGetApplicationDataDirectory_exists(self):
342 with self.assertCall(
343 self.call.device._RunPipedShellCommand(
344 'pm dump foo.bar.baz | grep dataDir='),
345 ['dataDir=/data/data/foo.bar.baz']):
346 self.assertEquals(
347 '/data/data/foo.bar.baz',
348 self.device.GetApplicationDataDirectory('foo.bar.baz'))
349
350 def testGetApplicationDataDirectory_notExists(self):
351 with self.assertCall(
352 self.call.device._RunPipedShellCommand(
353 'pm dump foo.bar.baz | grep dataDir='),
354 self.ShellError()):
355 self.assertIsNone(self.device.GetApplicationDataDirectory('foo.bar.baz'))
356
357
339 @mock.patch('time.sleep', mock.Mock()) 358 @mock.patch('time.sleep', mock.Mock())
340 class DeviceUtilsWaitUntilFullyBootedTest(DeviceUtilsTest): 359 class DeviceUtilsWaitUntilFullyBootedTest(DeviceUtilsTest):
341 360
342 def testWaitUntilFullyBooted_succeedsNoWifi(self): 361 def testWaitUntilFullyBooted_succeedsNoWifi(self):
343 with self.assertCalls( 362 with self.assertCalls(
344 self.call.adb.WaitForDevice(), 363 self.call.adb.WaitForDevice(),
345 # sd_card_ready 364 # sd_card_ready
346 (self.call.device.GetExternalStoragePath(), '/fake/storage/path'), 365 (self.call.device.GetExternalStoragePath(), '/fake/storage/path'),
347 (self.call.adb.Shell('test -d /fake/storage/path'), ''), 366 (self.call.adb.Shell('test -d /fake/storage/path'), ''),
348 # pm_ready 367 # pm_ready
(...skipping 1351 matching lines...) Expand 10 before | Expand all | Expand 10 after
1700 devices = device_utils.DeviceUtils.HealthyDevices() 1719 devices = device_utils.DeviceUtils.HealthyDevices()
1701 self.assertEquals(1, len(devices)) 1720 self.assertEquals(1, len(devices))
1702 self.assertTrue(isinstance(devices[0], device_utils.DeviceUtils)) 1721 self.assertTrue(isinstance(devices[0], device_utils.DeviceUtils))
1703 self.assertEquals('0123456789abcdef', devices[0].adb.GetDeviceSerial()) 1722 self.assertEquals('0123456789abcdef', devices[0].adb.GetDeviceSerial())
1704 1723
1705 1724
1706 if __name__ == '__main__': 1725 if __name__ == '__main__':
1707 logging.getLogger().setLevel(logging.DEBUG) 1726 logging.getLogger().setLevel(logging.DEBUG)
1708 unittest.main(verbosity=2) 1727 unittest.main(verbosity=2)
1709 1728
OLDNEW
« no previous file with comments | « build/android/pylib/device/device_utils.py ('k') | build/android/pylib/gtest/gtest_test_instance.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698