Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(479)

Side by Side Diff: chrome/test/functional/https.py

Issue 10830193: Remove SWIGged use of BrowserProxy and TabProxy from PyAuto tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 7
8 import pyauto_functional # Must be imported before pyauto 8 import pyauto_functional # Must be imported before pyauto
9 import pyauto 9 import pyauto
10 import pyauto_paths 10 import pyauto_paths
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 self.StopHttpsServer(self._https_server_mismatched) 56 self.StopHttpsServer(self._https_server_mismatched)
57 self.StopHttpsServer(self._https_server_expired) 57 self.StopHttpsServer(self._https_server_expired)
58 self.StopHttpsServer(self._https_server_ok) 58 self.StopHttpsServer(self._https_server_ok)
59 59
60 def testSSLProceed(self): 60 def testSSLProceed(self):
61 """Verify able to proceed from an interstitial page.""" 61 """Verify able to proceed from an interstitial page."""
62 for server in (self._https_server_expired, 62 for server in (self._https_server_expired,
63 self._https_server_mismatched): 63 self._https_server_mismatched):
64 url = server.GetURL('google.html').spec() 64 url = server.GetURL('google.html').spec()
65 self.NavigateToURL(url) 65 self.NavigateToURL(url)
66 tab_proxy = self.GetBrowserWindow(0).GetTab(0)
67 # Equivalent to clicking 'proceed anyway' button. 66 # Equivalent to clicking 'proceed anyway' button.
68 self.assertTrue(tab_proxy.TakeActionOnSSLBlockingPage(True), 67 self.ActionOnSSLBlockingPage(proceed=True)
69 msg="Did not proceed from the interstitial page.")
70 self.assertTrue( 68 self.assertTrue(
71 'google' in self.GetActiveTabTitle().lower(), 69 'google' in self.GetActiveTabTitle().lower(),
72 msg="Did not correctly proceed from the interstitial page.") 70 msg="Did not correctly proceed from the interstitial page.")
73 71
74 def testSSLGoBack(self): 72 def testSSLGoBack(self):
75 """Verify able to go back from the interstitial page to the previous site. 73 """Verify able to go back from the interstitial page to the previous site.
76 74
77 Visits a page with https error and then goes back using Browser::GoBack. 75 Visits a page with https error and then goes back using Browser::GoBack.
78 """ 76 """
79 for server in (self._https_server_expired, 77 for server in (self._https_server_expired,
80 self._https_server_mismatched): 78 self._https_server_mismatched):
81 self.NavigateToURL( 79 self.NavigateToURL(
82 self.GetHttpURLForDataPath('ssl', 'google.html')) 80 self.GetHttpURLForDataPath('ssl', 'google.html'))
83 first_page_title = self.GetActiveTabTitle() 81 first_page_title = self.GetActiveTabTitle()
84 self.NavigateToURL( 82 self.NavigateToURL(
85 server.GetURL('google.html').spec()) 83 server.GetURL('google.html').spec())
86 tab_proxy = self.GetBrowserWindow(0).GetTab(0)
87 # Equivalent to clicking 'back to safety' button. 84 # Equivalent to clicking 'back to safety' button.
88 self.assertTrue(tab_proxy.TakeActionOnSSLBlockingPage(False), 85 self.ActionOnSSLBlockingPage(proceed=False)
89 msg="Was not able to go back from the interstitial page.")
90 self.assertEqual(self.GetActiveTabTitle(), first_page_title, 86 self.assertEqual(self.GetActiveTabTitle(), first_page_title,
91 msg="Did not go back to previous page correctly.") 87 msg="Did not go back to previous page correctly.")
92 88
93 def testSSLCertOK(self): 89 def testSSLCertOK(self):
94 """Verify Certificate OK does not display interstitial page. 90 """Verify Certificate OK does not display interstitial page.
95 91
96 This test also asserts that the page type is normal. 92 This test also asserts that the page type is normal.
97 """ 93 """
98 url = self._https_server_ok.GetURL('google.html').spec() 94 url = self._https_server_ok.GetURL('google.html').spec()
99 self.NavigateToURL(url) 95 self.NavigateToURL(url)
100 tab_proxy = self.GetBrowserWindow(0).GetTab(0) 96 result_dict = self.GetNavigationInfo()
101 result_dict = tab_proxy.GetPageType()
102 self.assertTrue(result_dict, msg='Could not determine the type of the page') 97 self.assertTrue(result_dict, msg='Could not determine the type of the page')
103 page_type_dict = {
104 pyauto.PAGE_TYPE_INTERSTITIAL: 'interstitial',
105 pyauto.PAGE_TYPE_ERROR: 'error'}
106 self.assertEqual( 98 self.assertEqual(
107 result_dict['page_type'], pyauto.PAGE_TYPE_NORMAL, 99 result_dict['page_type'], 'NORMAL_PAGE',
108 msg='Cert OK did not display page type normal.') 100 msg='Cert OK did not display page type normal (page_type=%s).' %
101 result_dict['page_type'])
109 102
110 def testSSLCertIsExpiredAndCertNameMismatches(self): 103 def testSSLCertIsExpiredAndCertNameMismatches(self):
111 """Verify Certificate Expiration and Certificate Mismatched name.""" 104 """Verify Certificate Expiration and Certificate Mismatched name."""
112 for server, cert_status_flag, msg in zip( 105 for server, cert_status_flag, msg in zip(
113 (self._https_server_expired, self._https_server_mismatched), 106 (self._https_server_expired, self._https_server_mismatched),
114 (pyauto.CERT_STATUS_DATE_INVALID, 107 (pyauto.CERT_STATUS_DATE_INVALID,
115 pyauto.CERT_STATUS_COMMON_NAME_INVALID), 108 pyauto.CERT_STATUS_COMMON_NAME_INVALID),
116 ('Cert has not expired', 'Cert name does not mismatch')): 109 ('Cert has not expired', 'Cert name does not mismatch')):
117 self.NavigateToURL(server.GetURL('google.html').spec()) 110 self.NavigateToURL(server.GetURL('google.html').spec())
118 result_dict = self.GetBrowserWindow(0).GetTab(0).GetSecurityState() 111 result_dict = self.GetSecurityState()
119 self.assertTrue(result_dict, msg='Could not get security state info') 112 self.assertTrue(result_dict, msg='Could not get security state info')
120 self.assertTrue( 113 self.assertTrue(
121 result_dict['ssl_cert_status'] & pyauto.uint32_ptr.frompointer( 114 result_dict['ssl_cert_status'] & pyauto.uint32_ptr.frompointer(
122 cert_status_flag).value(), 115 cert_status_flag).value(),
123 msg=msg) 116 msg=msg)
124 117
125 def testSSLCertAuthorityOK(self): 118 def testSSLCertAuthorityOK(self):
126 """Verify Certificate OK is valid.""" 119 """Verify Certificate OK is valid."""
127 self.NavigateToURL( 120 self.NavigateToURL(
128 self._https_server_mismatched.GetURL('google.html').spec()) 121 self._https_server_mismatched.GetURL('google.html').spec())
129 result_dict = self.GetBrowserWindow(0).GetTab(0).GetSecurityState() 122 result_dict = self.GetSecurityState()
130 self.assertTrue(result_dict, msg='Could not get security state info') 123 self.assertTrue(result_dict, msg='Could not get security state info')
131 self.assertFalse( 124 self.assertFalse(
132 result_dict['ssl_cert_status'] & pyauto.uint32_ptr.frompointer( 125 result_dict['ssl_cert_status'] & pyauto.uint32_ptr.frompointer(
133 pyauto.CERT_STATUS_AUTHORITY_INVALID).value(), 126 pyauto.CERT_STATUS_AUTHORITY_INVALID).value(),
134 msg='Cert OK is invalid') 127 msg='Cert OK is invalid')
135 128
136 129
137 if __name__ == '__main__': 130 if __name__ == '__main__':
138 pyauto_functional.Main() 131 pyauto_functional.Main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698