OLD | NEW |
---|---|
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 # Copyright (c) 2010 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2010 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 pyauto_functional # Must be imported before pyauto | 6 import pyauto_functional |
7 import pyauto | 7 import pyauto |
8 import test_utils | 8 import test_utils |
9 | 9 |
10 | 10 |
11 class PasswordTest(pyauto.PyUITest): | 11 class PasswordTest(pyauto.PyUITest): |
12 """Tests that passwords work correctly""" | 12 """Tests that passwords work correctly""" |
13 | 13 |
14 def Debug(self): | 14 def Debug(self): |
15 """Test method for experimentation. | 15 """Test method for experimentation. |
16 | 16 |
(...skipping 21 matching lines...) Expand all Loading... | |
38 'username_element': 'username', | 38 'username_element': 'username', |
39 'password_element': 'password', | 39 'password_element': 'password', |
40 'submit_element': 'submit', | 40 'submit_element': 'submit', |
41 'action_target': 'https://www.example.com/login/', | 41 'action_target': 'https://www.example.com/login/', |
42 'blacklist': False } | 42 'blacklist': False } |
43 self.assertTrue(self.AddSavedPassword(password1)) | 43 self.assertTrue(self.AddSavedPassword(password1)) |
44 self.assertEquals(self.GetSavedPasswords(), [password1]) | 44 self.assertEquals(self.GetSavedPasswords(), [password1]) |
45 | 45 |
46 def testDisplayAndSavePasswordInfobar(self): | 46 def testDisplayAndSavePasswordInfobar(self): |
47 """Verify password infobar displays and able to save password.""" | 47 """Verify password infobar displays and able to save password.""" |
48 | |
48 url_https = 'https://www.google.com/accounts/' | 49 url_https = 'https://www.google.com/accounts/' |
49 url_logout = 'https://www.google.com/accounts/Logout' | 50 url_logout = 'https://www.google.com/accounts/Logout' |
50 creds = self.GetPrivateInfo()['test_google_account'] | 51 creds = self.GetPrivateInfo()['test_google_account'] |
51 username = creds['username'] | 52 test_utils.GoogleAccountsLogin(self, url_https, creds['username'], |
Nirnimesh
2010/12/21 20:02:11
why not move all args to the next line
| |
52 password = creds['password'] | 53 creds['password']) |
53 test_utils.GoogleAccountsLogin(self, ['url'], username, password) | |
54 # Wait until page completes loading. | 54 # Wait until page completes loading. |
55 self.WaitUntil( | 55 self.WaitUntil(» |
Nirnimesh
2010/12/21 20:02:11
remove stray tab char
| |
56 lambda: self.GetDOMValue('document.readyState'), 'complete') | 56 lambda: self.GetDOMValue('document.readyState'), 'complete') |
Nirnimesh
2010/12/21 20:02:11
indent by 4 spaces
| |
57 self.assertTrue(self.WaitForInfobarCount(1), | 57 self.assertTrue(self.WaitForInfobarCount(1), |
58 'Did not get save password infobar') | 58 'Did not get save password infobar') |
Nirnimesh
2010/12/21 20:02:11
Keep this aligned under self.
| |
59 infobar = self.GetBrowserInfo()['windows'][0]['tabs'][0]['infobars'] | 59 infobar = self.GetBrowserInfo()['windows'][0]['tabs'][0]['infobars'] |
60 self.assertEqual(infobar[0]['type'], 'confirm_infobar') | 60 self.assertEqual(infobar[0]['type'], 'confirm_infobar') |
61 self.PerformActionOnInfobar('accept', infobar_index=0) | 61 self.PerformActionOnInfobar('accept', infobar_index=0) |
62 self.NavigateToURL(url_logout) | 62 self.NavigateToURL(url_logout) |
63 self.NavigateToURL(url_https) | 63 self.NavigateToURL(url_https) |
64 test_utils.VerifyGoogleAccountCredsFilled(self, username, password) | 64 test_utils.VerifyGoogleAccountCredsFilled(self, creds['username'], |
Nirnimesh
2010/12/21 20:02:11
move all args to next line so that it looks better
| |
65 self.ExecuteJavascript('document.getElementById("gaia_loginform").submit();' | 65 creds['password']) |
66 'window.domAutomationController.send("done")') | 66 self.ExecuteJavascript('document.getElementById("gaia_loginform").submit();\ |
67 window.domAutomationController.send("done")') | |
67 test_utils.ClearPasswords(self) | 68 test_utils.ClearPasswords(self) |
68 | 69 |
70 def testInfoBarDisappearByNavigatingPage(self): | |
71 """Test that Password infobar is dismissed by navigating to | |
72 different page.""" | |
Nirnimesh
2010/12/21 20:02:11
align under Test
| |
69 | 73 |
74 url = 'https://www.google.com/accounts/Login?hl=en' | |
75 creds = self.GetPrivateInfo()['test_google_account'] | |
76 | |
77 # Login to Google a/c | |
78 test_utils.GoogleAccountsLogin(self, url, creds['username'], | |
Nirnimesh
2010/12/21 20:02:11
this fn doesn't take the url arg any more. Please
| |
79 creds['password']) | |
80 | |
81 # Wait for the infobar to appear | |
82 self.assertTrue(self.WaitForInfobarCount(1)) | |
83 self.assertTrue(self.GetBrowserInfo()['windows'][0]['tabs'][0]['infobars']) | |
84 self.NavigateToURL('chrome://history') | |
85 self.assertTrue(self.WaitForInfobarCount(0)) | |
86 # To make sure user is navigated to History page. | |
87 self.assertEqual('History', self.GetActiveTabTitle()) | |
88 self.assertFalse(self.GetBrowserInfo()['windows'][0]['tabs'][0]['infobars']) | |
89 | |
90 def testInfoBarDisappearByReload(self): | |
91 """Test that Password infobar disappears by the page reload.""" | |
92 | |
93 url = 'https://www.google.com/accounts/Login?hl=en' | |
94 creds = self.GetPrivateInfo()['test_google_account'] | |
95 | |
96 # Login to Google a/c | |
97 test_utils.GoogleAccountsLogin(self, url, creds['username'], | |
Nirnimesh
2010/12/21 20:02:11
ditto
| |
98 creds['password']) | |
99 | |
100 # Wait for the infobar to appear | |
101 self.assertTrue(self.WaitForInfobarCount(1)) | |
102 self.assertTrue(self.GetBrowserInfo()['windows'][0]['tabs'][0]['infobars']) | |
103 self.GetBrowserWindow(0).GetTab(0).Reload() | |
104 self.assertTrue(self.WaitForInfobarCount(0)) | |
105 self.assertFalse(self.GetBrowserInfo()['windows'][0]['tabs'][0]['infobars']) | |
106 | |
70 if __name__ == '__main__': | 107 if __name__ == '__main__': |
71 pyauto_functional.Main() | 108 pyauto_functional.Main() |
OLD | NEW |