Chromium Code Reviews| 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 again after clicking cancel |
| 257 for a specific account. | |
| 256 | 258 |
| 257 The one-click infobar should not display again after logging into an | 259 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 | 260 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 | 261 restarting the browser with the same profile and verifying the one-click |
| 260 infobar does not show after login. | 262 infobar does not show after login. |
| 261 | 263 |
| 262 This test also verifies that the password infobar displays. | 264 This test also verifies that the password infobar displays. |
| 263 """ | 265 """ |
| 264 self._DisplayOneClickInfobar() | 266 self._DisplayOneClickInfobar() |
| 265 self._PerformActionOnInfobar(action='cancel') # Click 'No thanks' button. | 267 self._PerformActionOnInfobar(action='cancel') # Click 'No thanks' button. |
| 266 self.NavigateToURL(self.URL_LOGOUT) | 268 self.NavigateToURL(self.URL_LOGOUT) |
| 267 self._LogIntoGoogleAccount() | 269 self._LogIntoGoogleAccount() |
| 268 test_utils.WaitForInfobarTypeAndGetIndex(self, self.PW_INFOBAR_TYPE) | 270 test_utils.WaitForInfobarTypeAndGetIndex(self, self.PW_INFOBAR_TYPE) |
| 269 test_utils.AssertInfobarTypeDoesNotAppear(self, self.OC_INFOBAR_TYPE) | 271 test_utils.AssertInfobarTypeDoesNotAppear(self, self.OC_INFOBAR_TYPE) |
| 270 # Restart browser with the same profile. | 272 # Restart browser with the same profile. |
| 271 self.RestartBrowser(clear_profile=False) | 273 self.RestartBrowser(clear_profile=False) |
| 272 self.NavigateToURL(self.URL_LOGOUT) | 274 self.NavigateToURL(self.URL_LOGOUT) |
| 273 self._LogIntoGoogleAccount() | 275 self._LogIntoGoogleAccount() |
| 274 test_utils.AssertInfobarTypeDoesNotAppear(self, self.OC_INFOBAR_TYPE) | 276 test_utils.AssertInfobarTypeDoesNotAppear(self, self.OC_INFOBAR_TYPE) |
| 277 test_utils.WaitForInfobarTypeAndGetIndex(self, self.PW_INFOBAR_TYPE) | |
| 278 | |
| 279 def testOneClickInfobarAppearsAfterCancelDifferentAccount(self): | |
| 280 """Verify one-click infobar appears again after clicking cancel for a | |
| 281 specific account but logging in with another account. | |
| 282 | |
| 283 The one-click infobar should display again after logging into an | |
| 284 account and selecting to reject sync, but logging again with another | |
| 285 account. The test covers restarting the browser with the same profile | |
| 286 but logging in with another account, and verifying the one-click infobar | |
| 287 does show after login. | |
| 288 | |
| 289 This test also verifies that the password infobar displays. | |
| 290 """ | |
| 291 self._DisplayOneClickInfobar() | |
| 292 self._PerformActionOnInfobar(action='cancel') # Click 'No thanks' button. | |
| 293 self.NavigateToURL(self.URL_LOGOUT) | |
| 294 self._LogIntoGoogleAccount() | |
| 295 test_utils.WaitForInfobarTypeAndGetIndex(self, self.PW_INFOBAR_TYPE) | |
| 296 test_utils.AssertInfobarTypeDoesNotAppear(self, self.OC_INFOBAR_TYPE) | |
|
Roger Tawa OOO till Jul 10th
2012/06/15 17:56:00
lines 294-296 are redundant with the previous test
Mathieu
2012/06/21 13:13:00
Done.
| |
| 297 # Restart browser with a different profile. | |
| 298 self.RestartBrowser(clear_profile=False) | |
| 299 self.NavigateToURL(self.URL_LOGOUT) | |
| 300 self._LogIntoGoogleAccount('test_google_account_2') | |
| 301 test_utils.WaitForInfobarTypeAndGetIndex(self, self.OC_INFOBAR_TYPE) | |
| 302 test_utils.AssertInfobarTypeDoesNotAppear(self, self.PW_INFOBAR_TYPE) | |
| 275 | 303 |
| 276 def testDisplayOneClickInfobarAfterDismiss(self): | 304 def testDisplayOneClickInfobarAfterDismiss(self): |
| 277 """Verify one-click infobar appears again after clicking dismiss button. | 305 """Verify one-click infobar appears again after clicking dismiss button. |
| 278 | 306 |
| 279 The one-click infobar should display again after logging into an | 307 The one-click infobar should display again after logging into an |
| 280 account and clicking to dismiss the infobar the first time. | 308 account and clicking to dismiss the infobar the first time. |
| 281 | 309 |
| 282 This test also verifies that the password infobar does not display. | 310 This test also verifies that the password infobar does not display. |
| 283 The one-click infobar should supersede the password infobar. | 311 The one-click infobar should supersede the password infobar. |
| 284 """ | 312 """ |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 356 def testNoOneClickInfobarInIncognito(self): | 384 def testNoOneClickInfobarInIncognito(self): |
| 357 """Verify that one-click infobar does not show up in incognito mode.""" | 385 """Verify that one-click infobar does not show up in incognito mode.""" |
| 358 self.RunCommand(pyauto.IDC_NEW_INCOGNITO_WINDOW) | 386 self.RunCommand(pyauto.IDC_NEW_INCOGNITO_WINDOW) |
| 359 self._LogIntoGoogleAccount(windex=1) | 387 self._LogIntoGoogleAccount(windex=1) |
| 360 test_utils.AssertInfobarTypeDoesNotAppear( | 388 test_utils.AssertInfobarTypeDoesNotAppear( |
| 361 self, self.OC_INFOBAR_TYPE, windex=1) | 389 self, self.OC_INFOBAR_TYPE, windex=1) |
| 362 | 390 |
| 363 | 391 |
| 364 if __name__ == '__main__': | 392 if __name__ == '__main__': |
| 365 pyauto_functional.Main() | 393 pyauto_functional.Main() |
| OLD | NEW |