| 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, shutil, time | 5 import logging, os, shutil, time |
| 6 from autotest_lib.client.bin import site_backchannel, utils | 6 from autotest_lib.client.bin import utils |
| 7 from autotest_lib.client.common_lib import error, site_power_status | 7 from autotest_lib.client.common_lib import error, site_power_status |
| 8 from autotest_lib.client.cros import cros_ui, cros_ui_test, httpd, login | 8 from autotest_lib.client.cros import backchannel, cros_ui, cros_ui_test |
| 9 from autotest_lib.client.cros import httpd, login |
| 9 | 10 |
| 10 from autotest_lib.client.cros import flimflam_test_path | 11 from autotest_lib.client.cros import flimflam_test_path |
| 11 import flimflam | 12 import flimflam |
| 12 | 13 |
| 13 params_dict = { | 14 params_dict = { |
| 14 'test_time_ms': '_mseconds', | 15 'test_time_ms': '_mseconds', |
| 15 'should_scroll': '_should_scroll', | 16 'should_scroll': '_should_scroll', |
| 16 'should_scroll_up': '_should_scroll_up', | 17 'should_scroll_up': '_should_scroll_up', |
| 17 'scroll_loop': '_scroll_loop', | 18 'scroll_loop': '_scroll_loop', |
| 18 'scroll_interval_ms': '_scroll_interval_ms', | 19 'scroll_interval_ms': '_scroll_interval_ms', |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 percent_initial_charge = self._percent_current_charge() | 76 percent_initial_charge = self._percent_current_charge() |
| 76 if percent_initial_charge_min and percent_initial_charge < \ | 77 if percent_initial_charge_min and percent_initial_charge < \ |
| 77 percent_initial_charge_min: | 78 percent_initial_charge_min: |
| 78 raise error.TestError('Initial charge (%f) less than min (%f)' | 79 raise error.TestError('Initial charge (%f) less than min (%f)' |
| 79 % (percent_initial_charge, percent_initial_charge_min)) | 80 % (percent_initial_charge, percent_initial_charge_min)) |
| 80 | 81 |
| 81 # If force wifi enabled, convert eth0 to backchannel and connect to the | 82 # If force wifi enabled, convert eth0 to backchannel and connect to the |
| 82 # specified WiFi AP. | 83 # specified WiFi AP. |
| 83 if self._force_wifi: | 84 if self._force_wifi: |
| 84 # If backchannel is already running, don't run it again. | 85 # If backchannel is already running, don't run it again. |
| 85 if not site_backchannel.setup(): | 86 if not backchannel.setup(): |
| 86 raise error.TestError('Could not setup Backchannel network.') | 87 raise error.TestError('Could not setup Backchannel network.') |
| 87 | 88 |
| 88 # Note: FlimFlam is flaky after Backchannel setup sometimes. It may | 89 # Note: FlimFlam is flaky after Backchannel setup sometimes. It may |
| 89 # take several tries for WiFi to connect. More experimentation with | 90 # take several tries for WiFi to connect. More experimentation with |
| 90 # the retry settings here may be necessary if this becomes a source | 91 # the retry settings here may be necessary if this becomes a source |
| 91 # of test flakiness in the future. | 92 # of test flakiness in the future. |
| 92 if not flimflam.FlimFlam().ConnectService(retry=True, | 93 if not flimflam.FlimFlam().ConnectService(retry=True, |
| 93 service_type='wifi', | 94 service_type='wifi', |
| 94 ssid=wifi_ap, | 95 ssid=wifi_ap, |
| 95 security=wifi_sec, | 96 security=wifi_sec, |
| 96 passphrase=wifi_pw, | 97 passphrase=wifi_pw, |
| 97 mode='managed')[0]: | 98 mode='managed')[0]: |
| 98 raise error.TestError('Could not connect to WiFi network.') | 99 raise error.TestError('Could not connect to WiFi network.') |
| 99 | 100 |
| 100 if check_network and site_backchannel.is_network_iface_running('eth0'): | 101 if check_network and backchannel.is_network_iface_running('eth0'): |
| 101 raise error.TestError( | 102 raise error.TestError( |
| 102 'Ethernet interface is active. Please remove Ethernet cable') | 103 'Ethernet interface is active. Please remove Ethernet cable') |
| 103 | 104 |
| 104 # record the max backlight level | 105 # record the max backlight level |
| 105 cmd = 'backlight-tool --get_max_brightness' | 106 cmd = 'backlight-tool --get_max_brightness' |
| 106 self._max_backlight = int(utils.system_output(cmd).rstrip()) | 107 self._max_backlight = int(utils.system_output(cmd).rstrip()) |
| 107 self._tmp_keyvals['level_backlight_max'] = self._max_backlight | 108 self._tmp_keyvals['level_backlight_max'] = self._max_backlight |
| 108 | 109 |
| 109 # fix up file perms for the power test extension so that chrome | 110 # fix up file perms for the power test extension so that chrome |
| 110 # can access it | 111 # can access it |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 if self._json_path: | 237 if self._json_path: |
| 237 jsonfile = os.path.join(self._json_path, 'external_extensions.json') | 238 jsonfile = os.path.join(self._json_path, 'external_extensions.json') |
| 238 if os.path.exists(jsonfile): | 239 if os.path.exists(jsonfile): |
| 239 os.system('rm -f %s' % jsonfile) | 240 os.system('rm -f %s' % jsonfile) |
| 240 # re-enable powerd | 241 # re-enable powerd |
| 241 os.system('start powerd') | 242 os.system('start powerd') |
| 242 if login.logged_in(): | 243 if login.logged_in(): |
| 243 login.attempt_logout() | 244 login.attempt_logout() |
| 244 # cleanup backchannel interface | 245 # cleanup backchannel interface |
| 245 if self._force_wifi: | 246 if self._force_wifi: |
| 246 site_backchannel.teardown() | 247 backchannel.teardown() |
| 247 | 248 |
| 248 | 249 |
| 249 def _percent_current_charge(self): | 250 def _percent_current_charge(self): |
| 250 return self._power_status.battery[0].charge_now * 100 / \ | 251 return self._power_status.battery[0].charge_now * 100 / \ |
| 251 self._power_status.battery[0].charge_full_design | 252 self._power_status.battery[0].charge_full_design |
| 252 | 253 |
| 253 | 254 |
| 254 def _write_ext_params(self): | 255 def _write_ext_params(self): |
| 255 data = '' | 256 data = '' |
| 256 template= 'var %s = %s;\n' | 257 template= 'var %s = %s;\n' |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 322 # set backlight level to 40% of max | 323 # set backlight level to 40% of max |
| 323 cmd = 'backlight-tool --set_brightness %d ' % ( | 324 cmd = 'backlight-tool --set_brightness %d ' % ( |
| 324 int(self._max_backlight * 0.4)) | 325 int(self._max_backlight * 0.4)) |
| 325 os.system(cmd) | 326 os.system(cmd) |
| 326 | 327 |
| 327 # record brightness level | 328 # record brightness level |
| 328 cmd = 'backlight-tool --get_brightness' | 329 cmd = 'backlight-tool --get_brightness' |
| 329 level = int(utils.system_output(cmd).rstrip()) | 330 level = int(utils.system_output(cmd).rstrip()) |
| 330 logging.info('backlight level is %d' % level) | 331 logging.info('backlight level is %d' % level) |
| 331 self._tmp_keyvals['level_backlight_current'] = level | 332 self._tmp_keyvals['level_backlight_current'] = level |
| OLD | NEW |