| OLD | NEW |
| 1 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 1 # Copyright (c) 2010 The Chromium OS 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 | 4 |
| 5 import logging, os, time, utils | 5 import logging, os, time, utils |
| 6 from autotest_lib.client.bin import test | 6 from autotest_lib.client.bin import test |
| 7 from autotest_lib.client.common_lib import error, site_power_status, site_ui, \ | 7 from autotest_lib.client.common_lib import error, site_power_status, site_ui, \ |
| 8 utils | 8 utils |
| 9 | 9 |
| 10 class power_Backlight(test.test): | 10 class power_Backlight(test.test): |
| 11 version = 1 | 11 version = 1 |
| 12 | 12 |
| 13 | 13 |
| 14 def run_once(self, delay=60, seconds=10, tries=20): | 14 def run_once(self, delay=60, seconds=10, tries=20): |
| 15 # disable screen locker and screen blanking | 15 # disable screen locker |
| 16 os.system('stop screen-locker') |
| 17 |
| 18 # disable screen blanking. Stopping screen-locker isn't |
| 19 # synchronous :(. Add a sleep for now, till powerd comes around |
| 20 # and fixes all this for us. |
| 16 # TODO(davidjames): Power manager should support this feature directly | 21 # TODO(davidjames): Power manager should support this feature directly |
| 17 os.system('stop screen-locker') | 22 time.sleep(5) |
| 23 site_ui.xsystem('xset s off') |
| 24 site_ui.xsystem('xset dpms 0 0 0') |
| 18 site_ui.xsystem('xset -dpms') | 25 site_ui.xsystem('xset -dpms') |
| 19 | 26 |
| 20 status = site_power_status.get_status() | 27 status = site_power_status.get_status() |
| 21 if status.linepower[0].online: | 28 if status.linepower[0].online: |
| 22 raise error.TestFail('Machine must be unplugged') | 29 raise error.TestFail('Machine must be unplugged') |
| 23 | 30 |
| 24 cmd = 'backlight-tool --get_max_brightness' | 31 cmd = 'backlight-tool --get_max_brightness' |
| 25 max_brightness = int(utils.system_output(cmd).rstrip()) | 32 max_brightness = int(utils.system_output(cmd).rstrip()) |
| 26 if max_brightness < 4: | 33 if max_brightness < 4: |
| 27 raise error.TestFail('Must have at least 5 backlight levels') | 34 raise error.TestFail('Must have at least 5 backlight levels') |
| (...skipping 14 matching lines...) Expand all Loading... |
| 42 keyvals['w_bl_%d_rate' % i] = rate | 49 keyvals['w_bl_%d_rate' % i] = rate |
| 43 rates.append(rate) | 50 rates.append(rate) |
| 44 self.write_perf_keyval(keyvals) | 51 self.write_perf_keyval(keyvals) |
| 45 for i in range(1, len(levels)): | 52 for i in range(1, len(levels)): |
| 46 if rates[i] <= rates[i-1]: | 53 if rates[i] <= rates[i-1]: |
| 47 raise error.TestFail('Turning up the backlight ' \ | 54 raise error.TestFail('Turning up the backlight ' \ |
| 48 'should increase energy consumption') | 55 'should increase energy consumption') |
| 49 | 56 |
| 50 | 57 |
| 51 def cleanup(self): | 58 def cleanup(self): |
| 52 # re-enable screen locker and screen blanking | 59 # Re-enable screen locker. This also re-enables dpms. |
| 53 utils.system('start screen-locker') | 60 utils.system('start screen-locker') |
| 54 site_ui.xsystem('xset +dpms') | |
| 55 | 61 |
| OLD | NEW |