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 os | 6 import os |
7 import subprocess | 7 import subprocess |
8 import sys | 8 import sys |
9 | 9 |
10 import pyauto_functional # Must be imported before pyauto | 10 import pyauto_functional # Must be imported before pyauto |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 def testGoodLogin(self): | 48 def testGoodLogin(self): |
49 """Test that login is successful with valid credentials.""" | 49 """Test that login is successful with valid credentials.""" |
50 credentials = self._ValidCredentials() | 50 credentials = self._ValidCredentials() |
51 self.Login(credentials['username'], credentials['password']) | 51 self.Login(credentials['username'], credentials['password']) |
52 login_info = self.GetLoginInfo() | 52 login_info = self.GetLoginInfo() |
53 self.assertTrue(login_info['is_logged_in'], msg='Login failed.') | 53 self.assertTrue(login_info['is_logged_in'], msg='Login failed.') |
54 | 54 |
55 def testBadUsername(self): | 55 def testBadUsername(self): |
56 """Test that login fails when passed an invalid username.""" | 56 """Test that login fails when passed an invalid username.""" |
57 self.assertRaises( | 57 self.assertRaises( |
58 pyauto_errors.LoginError, | 58 pyauto_errors.JSONInterfaceError, |
59 lambda: self.Login('doesnotexist@fakedomain.org', 'badpassword')) | 59 lambda: self.Login('doesnotexist@fakedomain.org', 'badpassword')) |
60 login_info = self.GetLoginInfo() | 60 login_info = self.GetLoginInfo() |
61 self.assertFalse(login_info['is_logged_in'], | 61 self.assertFalse(login_info['is_logged_in'], |
62 msg='Login succeeded, with bad credentials.') | 62 msg='Login succeeded, with bad credentials.') |
63 | 63 |
64 def testBadPassword(self): | 64 def testBadPassword(self): |
65 """Test that login fails when passed an invalid password.""" | 65 """Test that login fails when passed an invalid password.""" |
66 credentials = self._ValidCredentials() | 66 credentials = self._ValidCredentials() |
67 self.assertRaises( | 67 self.assertRaises( |
68 pyauto_errors.LoginError, | 68 pyauto_errors.JSONInterfaceError, |
69 lambda: self.Login(credentials['username'], 'badpassword')) | 69 lambda: self.Login(credentials['username'], 'badpassword')) |
70 login_info = self.GetLoginInfo() | 70 login_info = self.GetLoginInfo() |
71 self.assertFalse(login_info['is_logged_in'], | 71 self.assertFalse(login_info['is_logged_in'], |
72 msg='Login succeeded, with bad credentials.') | 72 msg='Login succeeded, with bad credentials.') |
73 | 73 |
74 def testLoginAsGuest(self): | 74 def testLoginAsGuest(self): |
75 """Test we can login with guest mode.""" | 75 """Test we can login with guest mode.""" |
76 self.LoginAsGuest() | 76 self.LoginAsGuest() |
77 login_info = self.GetLoginInfo() | 77 login_info = self.GetLoginInfo() |
78 self.assertTrue(login_info['is_logged_in'], msg='Not logged in at all.') | 78 self.assertTrue(login_info['is_logged_in'], msg='Not logged in at all.') |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 # Should have 2 regular browser windows. | 189 # Should have 2 regular browser windows. |
190 info = self.GetBrowserInfo() | 190 info = self.GetBrowserInfo() |
191 self.assertEqual(2, len(info['windows'])) | 191 self.assertEqual(2, len(info['windows'])) |
192 self.assertFalse(info['windows'][0]['incognito']) | 192 self.assertFalse(info['windows'][0]['incognito']) |
193 self.assertFalse(info['windows'][1]['incognito'], | 193 self.assertFalse(info['windows'][1]['incognito'], |
194 msg='Expected a regular new window.') | 194 msg='Expected a regular new window.') |
195 | 195 |
196 | 196 |
197 if __name__ == '__main__': | 197 if __name__ == '__main__': |
198 pyauto_functional.Main() | 198 pyauto_functional.Main() |
OLD | NEW |