OLD | NEW |
1 # Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 # pylint: disable=W0212 | 4 # pylint: disable=W0212 |
5 | 5 |
6 import os | 6 import os |
7 import sys | 7 import sys |
8 import unittest | 8 import unittest |
9 | 9 |
10 sys.path.append(os.path.join(os.path.dirname(__file__), os.pardir, os.pardir)) | 10 sys.path.append(os.path.join(os.path.dirname(__file__), os.pardir, os.pardir)) |
11 | 11 |
12 from pylib import android_commands | |
13 from pylib.device import device_utils | 12 from pylib.device import device_utils |
14 from pylib.perf import perf_control | 13 from pylib.perf import perf_control |
15 | 14 |
16 class TestPerfControl(unittest.TestCase): | 15 class TestPerfControl(unittest.TestCase): |
17 def setUp(self): | 16 def setUp(self): |
18 if not os.getenv('BUILDTYPE'): | 17 if not os.getenv('BUILDTYPE'): |
19 os.environ['BUILDTYPE'] = 'Debug' | 18 os.environ['BUILDTYPE'] = 'Debug' |
20 | 19 |
21 devices = android_commands.GetAttachedDevices() | 20 devices = device_utils.DeviceUtils.HealthyDevices() |
22 self.assertGreater(len(devices), 0, 'No device attached!') | 21 self.assertGreater(len(devices), 0, 'No device attached!') |
23 self._device = device_utils.DeviceUtils( | 22 self._device = devices[0] |
24 android_commands.AndroidCommands(device=devices[0])) | |
25 | 23 |
26 def testHighPerfMode(self): | 24 def testHighPerfMode(self): |
27 perf = perf_control.PerfControl(self._device) | 25 perf = perf_control.PerfControl(self._device) |
28 try: | 26 try: |
29 perf.SetPerfProfilingMode() | 27 perf.SetPerfProfilingMode() |
30 cpu_info = perf.GetCpuInfo() | 28 cpu_info = perf.GetCpuInfo() |
31 self.assertEquals(len(perf._cpu_files), len(cpu_info)) | 29 self.assertEquals(len(perf._cpu_files), len(cpu_info)) |
32 for _, online, governor in cpu_info: | 30 for _, online, governor in cpu_info: |
33 self.assertTrue(online) | 31 self.assertTrue(online) |
34 self.assertEquals('performance', governor) | 32 self.assertEquals('performance', governor) |
35 finally: | 33 finally: |
36 perf.SetDefaultPerfMode() | 34 perf.SetDefaultPerfMode() |
37 | 35 |
38 if __name__ == '__main__': | 36 if __name__ == '__main__': |
39 unittest.main() | 37 unittest.main() |
OLD | NEW |