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, site_power_status | 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 | 9 from autotest_lib.client.cros import httpd, login, power_status |
10 | |
11 from autotest_lib.client.cros import flimflam_test_path | 10 from autotest_lib.client.cros import flimflam_test_path |
12 import flimflam | 11 import flimflam |
13 | 12 |
14 params_dict = { | 13 params_dict = { |
15 'test_time_ms': '_mseconds', | 14 'test_time_ms': '_mseconds', |
16 'should_scroll': '_should_scroll', | 15 'should_scroll': '_should_scroll', |
17 'should_scroll_up': '_should_scroll_up', | 16 'should_scroll_up': '_should_scroll_up', |
18 'scroll_loop': '_scroll_loop', | 17 'scroll_loop': '_scroll_loop', |
19 'scroll_interval_ms': '_scroll_interval_ms', | 18 'scroll_interval_ms': '_scroll_interval_ms', |
20 'scroll_by_pixels': '_scroll_by_pixels', | 19 'scroll_by_pixels': '_scroll_by_pixels', |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 self._loop_count = loop_count | 56 self._loop_count = loop_count |
58 self._mseconds = self._loop_time * 1000 | 57 self._mseconds = self._loop_time * 1000 |
59 self._verbose = verbose | 58 self._verbose = verbose |
60 self._low_battery_threshold = low_battery_threshold | 59 self._low_battery_threshold = low_battery_threshold |
61 self._should_scroll = should_scroll | 60 self._should_scroll = should_scroll |
62 self._should_scroll_up = should_scroll_up | 61 self._should_scroll_up = should_scroll_up |
63 self._scroll_loop = scroll_loop | 62 self._scroll_loop = scroll_loop |
64 self._scroll_interval_ms = scroll_interval_ms | 63 self._scroll_interval_ms = scroll_interval_ms |
65 self._scroll_by_pixels = scroll_by_pixels | 64 self._scroll_by_pixels = scroll_by_pixels |
66 self._tmp_keyvals = {} | 65 self._tmp_keyvals = {} |
67 self._power_status = site_power_status.get_status() | 66 self._power_status = power_status.get_status() |
68 self._json_path = None | 67 self._json_path = None |
69 self._force_wifi = force_wifi | 68 self._force_wifi = force_wifi |
70 | 69 |
71 # verify that initial conditions are met: | 70 # verify that initial conditions are met: |
72 if self._power_status.linepower[0].online: | 71 if self._power_status.linepower[0].online: |
73 raise error.TestError( | 72 raise error.TestError( |
74 'Running on AC power. Please remove AC power cable') | 73 'Running on AC power. Please remove AC power cable') |
75 | 74 |
76 percent_initial_charge = self._percent_current_charge() | 75 percent_initial_charge = self._percent_current_charge() |
77 if percent_initial_charge_min and percent_initial_charge < \ | 76 if percent_initial_charge_min and percent_initial_charge < \ |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 self._json_path = os.path.join(self.bindir, '..') | 119 self._json_path = os.path.join(self.bindir, '..') |
121 shutil.copy(os.path.join(self.bindir, 'external_extensions.json'), | 120 shutil.copy(os.path.join(self.bindir, 'external_extensions.json'), |
122 self._json_path) | 121 self._json_path) |
123 | 122 |
124 # setup a HTTP Server to listen for status updates from the power | 123 # setup a HTTP Server to listen for status updates from the power |
125 # test extension | 124 # test extension |
126 self._testServer = httpd.HTTPListener(8001, docroot=self.bindir) | 125 self._testServer = httpd.HTTPListener(8001, docroot=self.bindir) |
127 self._testServer.run() | 126 self._testServer.run() |
128 | 127 |
129 # initialize various interesting power related stats | 128 # initialize various interesting power related stats |
130 self._usb_stats = site_power_status.USBSuspendStats() | 129 self._usb_stats = power_status.USBSuspendStats() |
131 self._cpufreq_stats = site_power_status.CPUFreqStats() | 130 self._cpufreq_stats = power_status.CPUFreqStats() |
132 self._cpuidle_stats = site_power_status.CPUIdleStats() | 131 self._cpuidle_stats = power_status.CPUIdleStats() |
133 | 132 |
134 | 133 |
135 self._usb_stats.refresh() | 134 self._usb_stats.refresh() |
136 self._cpufreq_stats.refresh() | 135 self._cpufreq_stats.refresh() |
137 self._cpuidle_stats.refresh() | 136 self._cpuidle_stats.refresh() |
138 self._power_status.refresh() | 137 self._power_status.refresh() |
139 | 138 |
140 self._ah_charge_start = self._power_status.battery[0].charge_now | 139 self._ah_charge_start = self._power_status.battery[0].charge_now |
141 self._wh_energy_start = self._power_status.battery[0].energy | 140 self._wh_energy_start = self._power_status.battery[0].energy |
142 | 141 |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
317 # set backlight level to 40% of max | 316 # set backlight level to 40% of max |
318 cmd = 'backlight-tool --set_brightness %d ' % ( | 317 cmd = 'backlight-tool --set_brightness %d ' % ( |
319 int(self._max_backlight * 0.4)) | 318 int(self._max_backlight * 0.4)) |
320 os.system(cmd) | 319 os.system(cmd) |
321 | 320 |
322 # record brightness level | 321 # record brightness level |
323 cmd = 'backlight-tool --get_brightness' | 322 cmd = 'backlight-tool --get_brightness' |
324 level = int(utils.system_output(cmd).rstrip()) | 323 level = int(utils.system_output(cmd).rstrip()) |
325 logging.info('backlight level is %d' % level) | 324 logging.info('backlight level is %d' % level) |
326 self._tmp_keyvals['level_backlight_current'] = level | 325 self._tmp_keyvals['level_backlight_current'] = level |
OLD | NEW |