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 3# found in the LICENSE file. 4# pylint: disable=W0212 5 6import os 7import sys 8import unittest 9 10sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..')) 11 12from devil.android import device_test_case 13from devil.android import device_utils 14from devil.android.perf import perf_control 15 16 17class TestPerfControl(device_test_case.DeviceTestCase): 18 def setUp(self): 19 super(TestPerfControl, self).setUp() 20 if not os.getenv('BUILDTYPE'): 21 os.environ['BUILDTYPE'] = 'Debug' 22 self._device = device_utils.DeviceUtils(self.serial) 23 24 def testHighPerfMode(self): 25 perf = perf_control.PerfControl(self._device) 26 try: 27 perf.SetPerfProfilingMode() 28 cpu_info = perf.GetCpuInfo() 29 self.assertEquals(len(perf._cpu_files), len(cpu_info)) 30 for _, online, governor in cpu_info: 31 self.assertTrue(online) 32 self.assertEquals('performance', governor) 33 finally: 34 perf.SetDefaultPerfMode() 35 36 37if __name__ == '__main__': 38 unittest.main() 39