OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 import logging | 6 import logging |
7 import os | 7 import os |
8 import re | 8 import re |
9 | 9 |
10 import pyauto_functional # Must be imported before pyauto | 10 import pyauto_functional # Must be imported before pyauto |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 OC_INFOBAR_TYPE = 'oneclicklogin_infobar' | 189 OC_INFOBAR_TYPE = 'oneclicklogin_infobar' |
190 PW_INFOBAR_TYPE = 'password_infobar' | 190 PW_INFOBAR_TYPE = 'password_infobar' |
191 URL = 'https://www.google.com/accounts/ServiceLogin' | 191 URL = 'https://www.google.com/accounts/ServiceLogin' |
192 URL_LOGIN = 'https://www.google.com/accounts/Login' | 192 URL_LOGIN = 'https://www.google.com/accounts/Login' |
193 URL_LOGOUT = 'https://www.google.com/accounts/Logout' | 193 URL_LOGOUT = 'https://www.google.com/accounts/Logout' |
194 | 194 |
195 def setUp(self): | 195 def setUp(self): |
196 pyauto.PyUITest.setUp(self) | 196 pyauto.PyUITest.setUp(self) |
197 self._driver = self.NewWebDriver() | 197 self._driver = self.NewWebDriver() |
198 | 198 |
199 def _LogIntoGoogleAccount(self, tab_index=0, windex=0): | 199 def _LogIntoGoogleAccount(self, test_account='test_google_account', |
| 200 tab_index=0, windex=0): |
200 """Log into Google account. | 201 """Log into Google account. |
201 | 202 |
202 Args: | 203 Args: |
203 tab_index: The tab index, default is 0. | 204 tab_index: The tab index, default is 0. |
204 windex: The window index, default is 0. | 205 windex: The window index, default is 0. |
205 """ | 206 """ |
206 creds = self.GetPrivateInfo()['test_google_account'] | 207 creds = self.GetPrivateInfo()[test_account] |
207 username = creds['username'] | 208 username = creds['username'] |
208 password = creds['password'] | 209 password = creds['password'] |
209 test_utils.GoogleAccountsLogin(self, username, password, tab_index, windex) | 210 test_utils.GoogleAccountsLogin(self, username, password, tab_index, windex) |
210 # TODO(dyu): Use WaitUntilNavigationCompletes after investigating | 211 # TODO(dyu): Use WaitUntilNavigationCompletes after investigating |
211 # crbug.com/124877 | 212 # crbug.com/124877 |
212 self.WaitUntil( | 213 self.WaitUntil( |
213 lambda: self.GetDOMValue('document.readyState'), | 214 lambda: self.GetDOMValue('document.readyState'), |
214 expect_retval='complete') | 215 expect_retval='complete') |
215 | 216 |
216 def _PerformActionOnInfobar(self, action): | 217 def _PerformActionOnInfobar(self, action): |
(...skipping 27 matching lines...) Expand all Loading... |
244 msg='The one-click login infobar did not appear.') | 245 msg='The one-click login infobar did not appear.') |
245 | 246 |
246 def testDisplayOneClickInfobar(self): | 247 def testDisplayOneClickInfobar(self): |
247 """Verify one-click infobar appears after login into google account. | 248 """Verify one-click infobar appears after login into google account. |
248 | 249 |
249 One-click infobar should appear after signing into a google account | 250 One-click infobar should appear after signing into a google account |
250 for the first time using a clean profile. | 251 for the first time using a clean profile. |
251 """ | 252 """ |
252 self._DisplayOneClickInfobar() | 253 self._DisplayOneClickInfobar() |
253 | 254 |
254 def testNoOneClickInfobarAfterCancel(self): | 255 def testNoOneClickInfobarAfterCancelSameAccount(self): |
255 """Verify one-click infobar does not appear again after clicking cancel. | 256 """Verify one-click infobar does not appear after clicking cancel. |
256 | 257 |
257 The one-click infobar should not display again after logging into an | 258 The one-click infobar should not display again after logging into an |
258 account and selecting to reject sync the first time. The test covers | 259 account and selecting to reject sync the first time. The test covers |
259 restarting the browser with the same profile and verifying the one-click | 260 restarting the browser with the same profile and verifying the one-click |
260 infobar does not show after login. | 261 infobar does not show after login. |
261 | 262 |
262 This test also verifies that the password infobar displays. | 263 This test also verifies that the password infobar displays. |
263 """ | 264 """ |
264 self._DisplayOneClickInfobar() | 265 self._DisplayOneClickInfobar() |
265 self._PerformActionOnInfobar(action='cancel') # Click 'No thanks' button. | 266 self._PerformActionOnInfobar(action='cancel') # Click 'No thanks' button. |
266 self.NavigateToURL(self.URL_LOGOUT) | 267 self.NavigateToURL(self.URL_LOGOUT) |
267 self._LogIntoGoogleAccount() | 268 self._LogIntoGoogleAccount() |
268 test_utils.WaitForInfobarTypeAndGetIndex(self, self.PW_INFOBAR_TYPE) | 269 test_utils.WaitForInfobarTypeAndGetIndex(self, self.PW_INFOBAR_TYPE) |
269 test_utils.AssertInfobarTypeDoesNotAppear(self, self.OC_INFOBAR_TYPE) | 270 test_utils.AssertInfobarTypeDoesNotAppear(self, self.OC_INFOBAR_TYPE) |
270 # Restart browser with the same profile. | 271 # Restart browser with the same profile. |
271 self.RestartBrowser(clear_profile=False) | 272 self.RestartBrowser(clear_profile=False) |
272 self.NavigateToURL(self.URL_LOGOUT) | 273 self.NavigateToURL(self.URL_LOGOUT) |
273 self._LogIntoGoogleAccount() | 274 self._LogIntoGoogleAccount() |
274 test_utils.AssertInfobarTypeDoesNotAppear(self, self.OC_INFOBAR_TYPE) | 275 test_utils.AssertInfobarTypeDoesNotAppear(self, self.OC_INFOBAR_TYPE) |
| 276 test_utils.WaitForInfobarTypeAndGetIndex(self, self.PW_INFOBAR_TYPE) |
| 277 |
| 278 def testOneClickInfobarAppearsAfterCancelDifferentAccount(self): |
| 279 """Verify one-click infobar appears again with different account. |
| 280 |
| 281 The one-click infobar should display again after logging into an |
| 282 account and selecting to reject sync, but logging again with another |
| 283 account. The test covers restarting the browser with the same profile |
| 284 but logging in with another account, and verifying the one-click infobar |
| 285 does show after login. |
| 286 |
| 287 This test also verifies that the password infobar does not display |
| 288 in this case. |
| 289 """ |
| 290 self._DisplayOneClickInfobar() |
| 291 self._PerformActionOnInfobar(action='cancel') # Click 'No thanks' button. |
| 292 self.NavigateToURL(self.URL_LOGOUT) |
| 293 # Restart browser with the same profile. |
| 294 self.RestartBrowser(clear_profile=False) |
| 295 self._LogIntoGoogleAccount('test_google_account_2') # Different account. |
| 296 test_utils.WaitForInfobarTypeAndGetIndex(self, self.OC_INFOBAR_TYPE) |
| 297 test_utils.AssertInfobarTypeDoesNotAppear(self, self.PW_INFOBAR_TYPE) |
275 | 298 |
276 def testDisplayOneClickInfobarAfterDismiss(self): | 299 def testDisplayOneClickInfobarAfterDismiss(self): |
277 """Verify one-click infobar appears again after clicking dismiss button. | 300 """Verify one-click infobar appears again after clicking dismiss button. |
278 | 301 |
279 The one-click infobar should display again after logging into an | 302 The one-click infobar should display again after logging into an |
280 account and clicking to dismiss the infobar the first time. | 303 account and clicking to dismiss the infobar the first time. |
281 | 304 |
282 This test also verifies that the password infobar does not display. | 305 This test also verifies that the password infobar does not display. |
283 The one-click infobar should supersede the password infobar. | 306 The one-click infobar should supersede the password infobar. |
284 """ | 307 """ |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
356 def testNoOneClickInfobarInIncognito(self): | 379 def testNoOneClickInfobarInIncognito(self): |
357 """Verify that one-click infobar does not show up in incognito mode.""" | 380 """Verify that one-click infobar does not show up in incognito mode.""" |
358 self.RunCommand(pyauto.IDC_NEW_INCOGNITO_WINDOW) | 381 self.RunCommand(pyauto.IDC_NEW_INCOGNITO_WINDOW) |
359 self._LogIntoGoogleAccount(windex=1) | 382 self._LogIntoGoogleAccount(windex=1) |
360 test_utils.AssertInfobarTypeDoesNotAppear( | 383 test_utils.AssertInfobarTypeDoesNotAppear( |
361 self, self.OC_INFOBAR_TYPE, windex=1) | 384 self, self.OC_INFOBAR_TYPE, windex=1) |
362 | 385 |
363 | 386 |
364 if __name__ == '__main__': | 387 if __name__ == '__main__': |
365 pyauto_functional.Main() | 388 pyauto_functional.Main() |
OLD | NEW |