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 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 OC_INFOBAR_TYPE = 'oneclicklogin_infobar' | 199 OC_INFOBAR_TYPE = 'oneclicklogin_infobar' |
200 PW_INFOBAR_TYPE = 'password_infobar' | 200 PW_INFOBAR_TYPE = 'password_infobar' |
201 URL = 'https://www.google.com/accounts/ServiceLogin' | 201 URL = 'https://www.google.com/accounts/ServiceLogin' |
202 URL_LOGIN = 'https://www.google.com/accounts/Login' | 202 URL_LOGIN = 'https://www.google.com/accounts/Login' |
203 URL_LOGOUT = 'https://www.google.com/accounts/Logout' | 203 URL_LOGOUT = 'https://www.google.com/accounts/Logout' |
204 | 204 |
205 def setUp(self): | 205 def setUp(self): |
206 pyauto.PyUITest.setUp(self) | 206 pyauto.PyUITest.setUp(self) |
207 self._driver = self.NewWebDriver() | 207 self._driver = self.NewWebDriver() |
208 | 208 |
209 def _LogIntoGoogleAccount(self, tab_index=0, windex=0): | 209 def _LogIntoGoogleAccount(self, test_account='test_google_account', |
| 210 tab_index=0, windex=0): |
210 """Log into Google account. | 211 """Log into Google account. |
211 | 212 |
212 Args: | 213 Args: |
213 tab_index: The tab index, default is 0. | 214 tab_index: The tab index, default is 0. |
214 windex: The window index, default is 0. | 215 windex: The window index, default is 0. |
215 """ | 216 """ |
216 creds = self.GetPrivateInfo()['test_google_account'] | 217 creds = self.GetPrivateInfo()[test_account] |
217 username = creds['username'] | 218 username = creds['username'] |
218 password = creds['password'] | 219 password = creds['password'] |
219 test_utils.GoogleAccountsLogin(self, username, password, tab_index, windex) | 220 test_utils.GoogleAccountsLogin(self, username, password, tab_index, windex) |
220 # TODO(dyu): Use WaitUntilNavigationCompletes after investigating | 221 # TODO(dyu): Use WaitUntilNavigationCompletes after investigating |
221 # crbug.com/124877 | 222 # crbug.com/124877 |
222 self.WaitUntil( | 223 self.WaitUntil( |
223 lambda: self.GetDOMValue('document.readyState'), | 224 lambda: self.GetDOMValue('document.readyState'), |
224 expect_retval='complete') | 225 expect_retval='complete') |
225 | 226 |
226 def _PerformActionOnInfobar(self, action): | 227 def _PerformActionOnInfobar(self, action): |
(...skipping 27 matching lines...) Expand all Loading... |
254 msg='The one-click login infobar did not appear.') | 255 msg='The one-click login infobar did not appear.') |
255 | 256 |
256 def testDisplayOneClickInfobar(self): | 257 def testDisplayOneClickInfobar(self): |
257 """Verify one-click infobar appears after login into google account. | 258 """Verify one-click infobar appears after login into google account. |
258 | 259 |
259 One-click infobar should appear after signing into a google account | 260 One-click infobar should appear after signing into a google account |
260 for the first time using a clean profile. | 261 for the first time using a clean profile. |
261 """ | 262 """ |
262 self._DisplayOneClickInfobar() | 263 self._DisplayOneClickInfobar() |
263 | 264 |
264 def testNoOneClickInfobarAfterCancel(self): | 265 def testNoOneClickInfobarAfterCancelSameAccount(self): |
265 """Verify one-click infobar does not appear again after clicking cancel. | 266 """Verify one-click infobar does not appear after clicking cancel. |
266 | 267 |
267 The one-click infobar should not display again after logging into an | 268 The one-click infobar should not display again after logging into an |
268 account and selecting to reject sync the first time. The test covers | 269 account and selecting to reject sync the first time. The test covers |
269 restarting the browser with the same profile and verifying the one-click | 270 restarting the browser with the same profile and verifying the one-click |
270 infobar does not show after login. | 271 infobar does not show after login. |
271 | 272 |
272 This test also verifies that the password infobar displays. | 273 This test also verifies that the password infobar displays. |
273 """ | 274 """ |
274 self._DisplayOneClickInfobar() | 275 self._DisplayOneClickInfobar() |
275 self._PerformActionOnInfobar(action='cancel') # Click 'No thanks' button. | 276 self._PerformActionOnInfobar(action='cancel') # Click 'No thanks' button. |
276 self.NavigateToURL(self.URL_LOGOUT) | 277 self.NavigateToURL(self.URL_LOGOUT) |
277 self._LogIntoGoogleAccount() | 278 self._LogIntoGoogleAccount() |
278 test_utils.WaitForInfobarTypeAndGetIndex(self, self.PW_INFOBAR_TYPE) | 279 test_utils.WaitForInfobarTypeAndGetIndex(self, self.PW_INFOBAR_TYPE) |
279 test_utils.AssertInfobarTypeDoesNotAppear(self, self.OC_INFOBAR_TYPE) | 280 test_utils.AssertInfobarTypeDoesNotAppear(self, self.OC_INFOBAR_TYPE) |
280 # Restart browser with the same profile. | 281 # Restart browser with the same profile. |
281 self.RestartBrowser(clear_profile=False) | 282 self.RestartBrowser(clear_profile=False) |
282 self.NavigateToURL(self.URL_LOGOUT) | 283 self.NavigateToURL(self.URL_LOGOUT) |
283 self._LogIntoGoogleAccount() | 284 self._LogIntoGoogleAccount() |
284 test_utils.AssertInfobarTypeDoesNotAppear(self, self.OC_INFOBAR_TYPE) | 285 test_utils.AssertInfobarTypeDoesNotAppear(self, self.OC_INFOBAR_TYPE) |
| 286 test_utils.WaitForInfobarTypeAndGetIndex(self, self.PW_INFOBAR_TYPE) |
| 287 |
| 288 def testOneClickInfobarAppearsAfterCancelDifferentAccount(self): |
| 289 """Verify one-click infobar appears again with different account. |
| 290 |
| 291 The one-click infobar should display again after logging into an |
| 292 account and selecting to reject sync, but logging again with another |
| 293 account. The test covers restarting the browser with the same profile |
| 294 but logging in with another account, and verifying the one-click infobar |
| 295 does show after login. |
| 296 |
| 297 This test also verifies that the password infobar does not display |
| 298 in this case. |
| 299 """ |
| 300 self._DisplayOneClickInfobar() |
| 301 self._PerformActionOnInfobar(action='cancel') # Click 'No thanks' button. |
| 302 self.NavigateToURL(self.URL_LOGOUT) |
| 303 # Restart browser with the same profile. |
| 304 self.RestartBrowser(clear_profile=False) |
| 305 self._LogIntoGoogleAccount('test_google_account_2') # Different account. |
| 306 test_utils.WaitForInfobarTypeAndGetIndex(self, self.OC_INFOBAR_TYPE) |
| 307 test_utils.AssertInfobarTypeDoesNotAppear(self, self.PW_INFOBAR_TYPE) |
285 | 308 |
286 def testDisplayOneClickInfobarAfterDismiss(self): | 309 def testDisplayOneClickInfobarAfterDismiss(self): |
287 """Verify one-click infobar appears again after clicking dismiss button. | 310 """Verify one-click infobar appears again after clicking dismiss button. |
288 | 311 |
289 The one-click infobar should display again after logging into an | 312 The one-click infobar should display again after logging into an |
290 account and clicking to dismiss the infobar the first time. | 313 account and clicking to dismiss the infobar the first time. |
291 | 314 |
292 This test also verifies that the password infobar does not display. | 315 This test also verifies that the password infobar does not display. |
293 The one-click infobar should supersede the password infobar. | 316 The one-click infobar should supersede the password infobar. |
294 """ | 317 """ |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
366 def testNoOneClickInfobarInIncognito(self): | 389 def testNoOneClickInfobarInIncognito(self): |
367 """Verify that one-click infobar does not show up in incognito mode.""" | 390 """Verify that one-click infobar does not show up in incognito mode.""" |
368 self.RunCommand(pyauto.IDC_NEW_INCOGNITO_WINDOW) | 391 self.RunCommand(pyauto.IDC_NEW_INCOGNITO_WINDOW) |
369 self._LogIntoGoogleAccount(windex=1) | 392 self._LogIntoGoogleAccount(windex=1) |
370 test_utils.AssertInfobarTypeDoesNotAppear( | 393 test_utils.AssertInfobarTypeDoesNotAppear( |
371 self, self.OC_INFOBAR_TYPE, windex=1) | 394 self, self.OC_INFOBAR_TYPE, windex=1) |
372 | 395 |
373 | 396 |
374 if __name__ == '__main__': | 397 if __name__ == '__main__': |
375 pyauto_functional.Main() | 398 pyauto_functional.Main() |
OLD | NEW |