| 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 errno, logging, os, re, signal, subprocess, time | 5 import errno, logging, os, re, signal, subprocess, time |
| 6 import common | 6 import common |
| 7 import constants, cros_logging, cros_ui, cryptohome | 7 import constants, cros_logging, cros_ui, cryptohome |
| 8 from autotest_lib.client.bin import utils | 8 from autotest_lib.client.bin import utils |
| 9 from autotest_lib.client.common_lib import error | 9 from autotest_lib.client.common_lib import error |
| 10 | 10 |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 | 147 |
| 148 # Mark /var/log/messages now; we'll run through all subsequent log messages | 148 # Mark /var/log/messages now; we'll run through all subsequent log messages |
| 149 # if we couldn't log in to see if the browser crashed. | 149 # if we couldn't log in to see if the browser crashed. |
| 150 log_reader = cros_logging.LogReader() | 150 log_reader = cros_logging.LogReader() |
| 151 log_reader.set_start_by_current() | 151 log_reader.set_start_by_current() |
| 152 | 152 |
| 153 # Up our priority so we don't get descheduled in the middle of sending key | 153 # Up our priority so we don't get descheduled in the middle of sending key |
| 154 # press and key release events. | 154 # press and key release events. |
| 155 utils.system('renice +%d -p %d' % (_LOGIN_NICE, os.getpid())) | 155 utils.system('renice +%d -p %d' % (_LOGIN_NICE, os.getpid())) |
| 156 try: | 156 try: |
| 157 ax = cros_ui.get_autox() | 157 ax = cros_ui.get_autox() |
| 158 # navigate to login screen | 158 # navigate to login screen |
| 159 ax.send_hotkey("Ctrl+Alt+L") | 159 ax.send_hotkey("Ctrl+Alt+L") |
| 160 # escape out of any login screen menus (e.g., the network selection menu) | 160 # escape out of any login screen menus (e.g., the network select menu) |
| 161 ax.send_hotkey("Escape") | 161 ax.send_hotkey("Escape") |
| 162 time.sleep(0.5) | 162 time.sleep(0.5) |
| 163 if (username): | 163 if (username): |
| 164 # focus username | 164 # focus username |
| 165 ax.send_hotkey("Alt+U") | 165 ax.send_hotkey("Alt+U") |
| 166 ax.send_text(username) | 166 ax.send_text(username) |
| 167 # focus password | 167 # focus password |
| 168 ax.send_hotkey("Alt+P") | 168 ax.send_hotkey("Alt+P") |
| 169 ax.send_text(password) | 169 ax.send_text(password) |
| 170 ax.send_hotkey("Return") | 170 ax.send_hotkey("Return") |
| 171 else: | 171 else: |
| 172 ax.send_hotkey("Alt+B") # Browse without signing-in | 172 ax.send_hotkey("Alt+B") # Browse without signing-in |
| 173 finally: | 173 finally: |
| 174 utils.system('renice -%d -p %d' % (_LOGIN_NICE, os.getpid())) | 174 utils.system('renice -%d -p %d' % (_LOGIN_NICE, os.getpid())) |
| 175 | 175 |
| 176 wait_for_condition(condition=logged_in, | 176 wait_for_condition(condition=logged_in, |
| 177 timeout_msg='Timed out waiting for login', | 177 timeout_msg='Timed out waiting for login', |
| 178 timeout=timeout, | 178 timeout=timeout, |
| 179 process='chrome', | 179 process='chrome', |
| 180 log_reader=log_reader, | 180 log_reader=log_reader, |
| 181 crash_msg='Chrome crashed during login') | 181 crash_msg='Chrome crashed during login') |
| 182 wait_for_ownership() # Otherwise we SIGABRT keygen |
| 182 | 183 |
| 183 | 184 |
| 184 def attempt_logout(timeout=_DEFAULT_TIMEOUT): | 185 def attempt_logout(timeout=_DEFAULT_TIMEOUT): |
| 185 """Attempt to log out by killing Chrome. | 186 """Attempt to log out by killing Chrome. |
| 186 | 187 |
| 187 Args: | 188 Args: |
| 188 timeout: float number of seconds to wait | 189 timeout: float number of seconds to wait |
| 189 | 190 |
| 190 Raises: | 191 Raises: |
| 191 TimeoutError: logout didn't complete before timeout | 192 TimeoutError: logout didn't complete before timeout |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 400 except (IOError, OSError) as error: | 401 except (IOError, OSError) as error: |
| 401 logging.error(error) | 402 logging.error(error) |
| 402 | 403 |
| 403 # Restart the UI. | 404 # Restart the UI. |
| 404 nuke_login_manager() | 405 nuke_login_manager() |
| 405 utils.poll_for_condition( | 406 utils.poll_for_condition( |
| 406 lambda: __session_manager_restarted(oldpid), | 407 lambda: __session_manager_restarted(oldpid), |
| 407 TimeoutError('Timed out waiting for logout'), | 408 TimeoutError('Timed out waiting for logout'), |
| 408 timeout) | 409 timeout) |
| 409 wait_for_login_prompt() | 410 wait_for_login_prompt() |
| OLD | NEW |