OLD | NEW |
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 The Chromium 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 | 5 import logging |
6 | 6 |
7 import telemetry | 7 import telemetry |
8 from telemetry import util | 8 from telemetry import util |
9 | 9 |
10 | 10 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 raise NotImplementedError() | 55 raise NotImplementedError() |
56 | 56 |
57 @property | 57 @property |
58 def already_logged_in_element_id(self): | 58 def already_logged_in_element_id(self): |
59 raise NotImplementedError() | 59 raise NotImplementedError() |
60 | 60 |
61 @property | 61 @property |
62 def password_input_id(self): | 62 def password_input_id(self): |
63 raise NotImplementedError() | 63 raise NotImplementedError() |
64 | 64 |
| 65 def IsLoggedIn(self): |
| 66 return self._logged_in |
| 67 |
| 68 def _ResetLoggedInState(self): |
| 69 """Makes the backend think we're not logged in even though we are. |
| 70 Should only be used in unit tests to simulate --dont-override-profile. |
| 71 """ |
| 72 self._logged_in = False |
| 73 |
65 def LoginNeeded(self, tab, config): | 74 def LoginNeeded(self, tab, config): |
66 """Logs in to a test account. | 75 """Logs in to a test account. |
67 | 76 |
68 Raises: | 77 Raises: |
69 RuntimeError: if could not get credential information. | 78 RuntimeError: if could not get credential information. |
70 """ | 79 """ |
71 if self._logged_in: | 80 if self._logged_in: |
72 return True | 81 return True |
73 | 82 |
74 if 'username' not in config or 'password' not in config: | 83 if 'username' not in config or 'password' not in config: |
(...skipping 27 matching lines...) Expand all Loading... |
102 _SubmitFormAndWait(self.login_form_id, tab) | 111 _SubmitFormAndWait(self.login_form_id, tab) |
103 | 112 |
104 self._logged_in = True | 113 self._logged_in = True |
105 return True | 114 return True |
106 except telemetry.TimeoutException: | 115 except telemetry.TimeoutException: |
107 logging.warning('Timed out while loading: %s', self.url) | 116 logging.warning('Timed out while loading: %s', self.url) |
108 return False | 117 return False |
109 | 118 |
110 def LoginNoLongerNeeded(self, tab): # pylint: disable=W0613 | 119 def LoginNoLongerNeeded(self, tab): # pylint: disable=W0613 |
111 assert self._logged_in | 120 assert self._logged_in |
OLD | NEW |