| 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 utils | 5 import 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 | 7 from autotest_lib.client.common_lib import error |
| 8 | 8 |
| 9 def backlight_tool(args): | 9 def backlight_tool(args): |
| 10 cmd = 'backlight-tool %s' % args | 10 cmd = 'backlight-tool %s' % args |
| 11 return utils.system_output(cmd) | 11 return utils.system_output(cmd) |
| 12 | 12 |
| 13 class hardware_Backlight(test.test): | 13 class hardware_Backlight(test.test): |
| 14 version = 1 | 14 version = 1 |
| 15 | 15 |
| 16 def run_once(self): | 16 def run_once(self): |
| 17 try: | 17 try: |
| 18 brightness = int(backlight_tool("--get_brightness").rstrip()) | 18 brightness = int(backlight_tool("--get_brightness").rstrip()) |
| 19 except error.CmdError, e: | 19 except error.CmdError, e: |
| 20 raise error.TestFail('Cannot get brightness with backlight-tool') | 20 raise error.TestFail('Cannot get brightness with backlight-tool') |
| 21 max_brightness = int(backlight_tool("--get_max_brightness").rstrip()) | 21 max_brightness = int(backlight_tool("--get_max_brightness").rstrip()) |
| 22 logging.debug("max_brightness = %d" % max_brightness) |
| 22 try: | 23 try: |
| 23 for i in range(max_brightness + 1): | 24 for i in range(max_brightness + 1): |
| 24 backlight_tool("--set_brightness %d" % i) | 25 backlight_tool("--set_brightness %d" % i) |
| 25 result = int(backlight_tool("--get_brightness").rstrip()) | 26 result = int(backlight_tool("--get_brightness").rstrip()) |
| 27 logging.debug("result = %d" % result) |
| 26 if i != result: | 28 if i != result: |
| 27 raise error.TestFail('Adjusting backlight should change ' \ | 29 raise error.TestFail('Adjusting backlight should change ' \ |
| 28 'actual brightness') | 30 'actual brightness') |
| 29 finally: | 31 finally: |
| 30 backlight_tool("--set_brightness %d" % brightness) | 32 backlight_tool("--set_brightness %d" % brightness) |
| OLD | NEW |