OLD | NEW |
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 battery_utils.py | 7 Unit tests for the contents of battery_utils.py |
8 """ | 8 """ |
9 | 9 |
10 # pylint: disable=protected-access,unused-argument | 10 # pylint: disable=protected-access,unused-argument |
11 | 11 |
12 import logging | 12 import logging |
13 import os | |
14 import sys | 13 import sys |
15 import unittest | 14 import unittest |
16 | 15 |
| 16 from devil import devil_env |
17 from devil.android import battery_utils | 17 from devil.android import battery_utils |
18 from devil.android import device_errors | 18 from devil.android import device_errors |
19 from devil.android import device_utils | 19 from devil.android import device_utils |
20 from devil.android import device_utils_test | 20 from devil.android import device_utils_test |
21 from devil.utils import mock_calls | 21 from devil.utils import mock_calls |
22 from pylib import constants | |
23 | 22 |
24 sys.path.append(os.path.join( | 23 sys.path.append(devil_env.config.pymock_path) |
25 constants.DIR_SOURCE_ROOT, 'third_party', 'pymock')) | |
26 import mock # pylint: disable=F0401 | 24 import mock # pylint: disable=F0401 |
27 | 25 |
28 _DUMPSYS_OUTPUT = [ | 26 _DUMPSYS_OUTPUT = [ |
29 '9,0,i,uid,1000,test_package1', | 27 '9,0,i,uid,1000,test_package1', |
30 '9,0,i,uid,1001,test_package2', | 28 '9,0,i,uid,1001,test_package2', |
31 '9,1000,l,pwi,uid,1', | 29 '9,1000,l,pwi,uid,1', |
32 '9,1001,l,pwi,uid,2', | 30 '9,1001,l,pwi,uid,2', |
33 '9,0,l,pws,1728,2000,190,207', | 31 '9,0,l,pws,1728,2000,190,207', |
34 ] | 32 ] |
35 | 33 |
(...skipping 603 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
639 ['9,1000,l,pwi,uid,0.0327']), | 637 ['9,1000,l,pwi,uid,0.0327']), |
640 (self.call.device.RunShellCommand( | 638 (self.call.device.RunShellCommand( |
641 ['dumpsys', 'battery', 'reset'], check_return=True), [])): | 639 ['dumpsys', 'battery', 'reset'], check_return=True), [])): |
642 with self.assertRaises(device_errors.CommandFailedError): | 640 with self.assertRaises(device_errors.CommandFailedError): |
643 self.battery._ClearPowerData() | 641 self.battery._ClearPowerData() |
644 | 642 |
645 | 643 |
646 if __name__ == '__main__': | 644 if __name__ == '__main__': |
647 logging.getLogger().setLevel(logging.DEBUG) | 645 logging.getLogger().setLevel(logging.DEBUG) |
648 unittest.main(verbosity=2) | 646 unittest.main(verbosity=2) |
OLD | NEW |