| OLD | NEW |
| 1 # Copyright (c) 2011 The Chromium OS Authors. All rights reserved. | 1 # Copyright (c) 2011 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, shutil, time | 5 import logging, os, shutil, time |
| 6 from autotest_lib.client.bin import utils | 6 from autotest_lib.client.bin import utils |
| 7 from autotest_lib.client.common_lib import error | 7 from autotest_lib.client.common_lib import error |
| 8 from autotest_lib.client.cros import backchannel, cros_ui, cros_ui_test | 8 from autotest_lib.client.cros import backchannel, cros_ui, cros_ui_test |
| 9 from autotest_lib.client.cros import httpd, login, power_status | 9 from autotest_lib.client.cros import httpd, login, power_status |
| 10 from autotest_lib.client.cros import flimflam_test_path | 10 from autotest_lib.client.cros import flimflam_test_path |
| 11 import flimflam | 11 import flimflam |
| 12 | 12 |
| 13 params_dict = { | 13 params_dict = { |
| 14 'test_time_ms': '_mseconds', | 14 'test_time_ms': '_mseconds', |
| 15 'should_scroll': '_should_scroll', | 15 'should_scroll': '_should_scroll', |
| 16 'should_scroll_up': '_should_scroll_up', | 16 'should_scroll_up': '_should_scroll_up', |
| 17 'scroll_loop': '_scroll_loop', | 17 'scroll_loop': '_scroll_loop', |
| 18 'scroll_interval_ms': '_scroll_interval_ms', | 18 'scroll_interval_ms': '_scroll_interval_ms', |
| 19 'scroll_by_pixels': '_scroll_by_pixels', | 19 'scroll_by_pixels': '_scroll_by_pixels', |
| 20 'tasks': '_tasks', |
| 20 } | 21 } |
| 21 | 22 |
| 22 | 23 |
| 23 class power_LoadTest(cros_ui_test.UITest): | 24 class power_LoadTest(cros_ui_test.UITest): |
| 24 auto_login = False | 25 auto_login = False |
| 25 version = 2 | 26 version = 2 |
| 26 | 27 |
| 27 | 28 |
| 28 def start_authserver(self): | 29 def start_authserver(self): |
| 29 """ | 30 """ |
| (...skipping 12 matching lines...) Expand all Loading... |
| 42 """ | 43 """ |
| 43 pass | 44 pass |
| 44 | 45 |
| 45 | 46 |
| 46 def initialize(self, creds='$default', percent_initial_charge_min=None, | 47 def initialize(self, creds='$default', percent_initial_charge_min=None, |
| 47 check_network=True, loop_time=3600, loop_count=1, | 48 check_network=True, loop_time=3600, loop_count=1, |
| 48 should_scroll='true', should_scroll_up='true', | 49 should_scroll='true', should_scroll_up='true', |
| 49 scroll_loop='false', scroll_interval_ms='10000', | 50 scroll_loop='false', scroll_interval_ms='10000', |
| 50 scroll_by_pixels='600', low_battery_threshold=3, | 51 scroll_by_pixels='600', low_battery_threshold=3, |
| 51 verbose=True, force_wifi=False, wifi_ap='', wifi_sec='none', | 52 verbose=True, force_wifi=False, wifi_ap='', wifi_sec='none', |
| 52 wifi_pw=''): | 53 wifi_pw='', tasks=""): |
| 53 | 54 |
| 54 """ | 55 """ |
| 55 percent_initial_charge_min: min battery charge at start of test | 56 percent_initial_charge_min: min battery charge at start of test |
| 56 check_network: check that Ethernet interface is not running | 57 check_network: check that Ethernet interface is not running |
| 57 loop_count: number of times to loop the test for | 58 loop_count: number of times to loop the test for |
| 58 loop_time: length of time to run the test for in each loop | 59 loop_time: length of time to run the test for in each loop |
| 59 should_scroll: should the extension scroll pages | 60 should_scroll: should the extension scroll pages |
| 60 should_scroll_up: should scroll in up direction | 61 should_scroll_up: should scroll in up direction |
| 61 scroll_loop: continue scrolling indefinitely | 62 scroll_loop: continue scrolling indefinitely |
| 62 scroll_interval_ms: how often to scoll | 63 scroll_interval_ms: how often to scoll |
| 63 scroll_by_pixels: number of pixels to scroll each time | 64 scroll_by_pixels: number of pixels to scroll each time |
| 64 """ | 65 """ |
| 65 self._loop_time = loop_time | 66 self._loop_time = loop_time |
| 66 self._loop_count = loop_count | 67 self._loop_count = loop_count |
| 67 self._mseconds = self._loop_time * 1000 | 68 self._mseconds = self._loop_time * 1000 |
| 68 self._verbose = verbose | 69 self._verbose = verbose |
| 69 self._low_battery_threshold = low_battery_threshold | 70 self._low_battery_threshold = low_battery_threshold |
| 70 self._should_scroll = should_scroll | 71 self._should_scroll = should_scroll |
| 71 self._should_scroll_up = should_scroll_up | 72 self._should_scroll_up = should_scroll_up |
| 72 self._scroll_loop = scroll_loop | 73 self._scroll_loop = scroll_loop |
| 73 self._scroll_interval_ms = scroll_interval_ms | 74 self._scroll_interval_ms = scroll_interval_ms |
| 74 self._scroll_by_pixels = scroll_by_pixels | 75 self._scroll_by_pixels = scroll_by_pixels |
| 75 self._tmp_keyvals = {} | 76 self._tmp_keyvals = {} |
| 76 self._power_status = power_status.get_status() | 77 self._power_status = power_status.get_status() |
| 77 self._json_path = None | 78 self._json_path = None |
| 78 self._force_wifi = force_wifi | 79 self._force_wifi = force_wifi |
| 79 self._testServer = None | 80 self._testServer = None |
| 81 self._tasks = '\'' + tasks + '\'' |
| 80 | 82 |
| 81 # verify that initial conditions are met: | 83 # verify that initial conditions are met: |
| 82 if self._power_status.linepower[0].online: | 84 if self._power_status.linepower[0].online: |
| 83 raise error.TestError( | 85 raise error.TestError( |
| 84 'Running on AC power. Please remove AC power cable') | 86 'Running on AC power. Please remove AC power cable') |
| 85 | 87 |
| 86 percent_initial_charge = self._percent_current_charge() | 88 percent_initial_charge = self._percent_current_charge() |
| 87 if percent_initial_charge_min and percent_initial_charge < \ | 89 if percent_initial_charge_min and percent_initial_charge < \ |
| 88 percent_initial_charge_min: | 90 percent_initial_charge_min: |
| 89 raise error.TestError('Initial charge (%f) less than min (%f)' | 91 raise error.TestError('Initial charge (%f) less than min (%f)' |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 328 # set backlight level to 40% of max | 330 # set backlight level to 40% of max |
| 329 cmd = 'backlight-tool --set_brightness %d ' % ( | 331 cmd = 'backlight-tool --set_brightness %d ' % ( |
| 330 int(self._max_backlight * 0.4)) | 332 int(self._max_backlight * 0.4)) |
| 331 os.system(cmd) | 333 os.system(cmd) |
| 332 | 334 |
| 333 # record brightness level | 335 # record brightness level |
| 334 cmd = 'backlight-tool --get_brightness' | 336 cmd = 'backlight-tool --get_brightness' |
| 335 level = int(utils.system_output(cmd).rstrip()) | 337 level = int(utils.system_output(cmd).rstrip()) |
| 336 logging.info('backlight level is %d' % level) | 338 logging.info('backlight level is %d' % level) |
| 337 self._tmp_keyvals['level_backlight_current'] = level | 339 self._tmp_keyvals['level_backlight_current'] = level |
| OLD | NEW |