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

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

Issue 6685077: Two sets of Autofill tests.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 9 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/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 logging 6 import logging
7 import os 7 import os
8 import pickle 8 import pickle
9 9
10 import autofill_dataset_converter 10 import autofill_dataset_converter
11 import autofill_dataset_generator
11 import pyauto_functional # Must be imported before pyauto 12 import pyauto_functional # Must be imported before pyauto
12 import pyauto 13 import pyauto
13 14
14 15
15 class AutoFillTest(pyauto.PyUITest): 16 class AutoFillTest(pyauto.PyUITest):
16 """Tests that autofill works correctly""" 17 """Tests that autofill works correctly"""
17 18
18 def Debug(self): 19 def Debug(self):
19 """Test method for experimentation. 20 """Test method for experimentation.
20 21
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 self.GetAutofillProfile()['credit_cards']) 98 self.GetAutofillProfile()['credit_cards'])
98 99
99 def testFilterIncompleteAddresses(self): 100 def testFilterIncompleteAddresses(self):
100 """Test Autofill filters out profile with incomplete address info.""" 101 """Test Autofill filters out profile with incomplete address info."""
101 profile = {'NAME_FIRST': 'Bob', 102 profile = {'NAME_FIRST': 'Bob',
102 'NAME_LAST': 'Smith', 103 'NAME_LAST': 'Smith',
103 'EMAIL_ADDRESS': 'bsmith@example.com', 104 'EMAIL_ADDRESS': 'bsmith@example.com',
104 'COMPANY_NAME': 'Company X', 105 'COMPANY_NAME': 'Company X',
105 'PHONE_HOME_WHOLE_NUMBER': '650-123-4567',} 106 'PHONE_HOME_WHOLE_NUMBER': '650-123-4567',}
106 url = self.GetHttpURLForDataPath( 107 url = self.GetHttpURLForDataPath(
107 os.path.join('autofill', 'dup-profiles-test.html')) 108 os.path.join('autofill', 'duplicate_profiles_test.html'))
108 self.NavigateToURL(url) 109 self.NavigateToURL(url)
109 for key, value in profile.iteritems(): 110 for key, value in profile.iteritems():
110 script = ('document.getElementById("%s").value = "%s"; ' 111 script = ('document.getElementById("%s").value = "%s"; '
111 'window.domAutomationController.send("done");') % (key, value) 112 'window.domAutomationController.send("done");') % (key, value)
112 self.ExecuteJavascript(script, 0, 0) 113 self.ExecuteJavascript(script, 0, 0)
113 js_code = """ 114 js_code = """
114 document.getElementById("merge_dup").submit(); 115 document.getElementById("merge_dup").submit();
115 window.addEventListener("unload", function() { 116 window.addEventListener("unload", function() {
116 window.domAutomationController.send("done"); 117 window.domAutomationController.send("done");
117 }); 118 });
118 """ 119 """
119 self.ExecuteJavascript(js_code, 0, 0) 120 self.ExecuteJavascript(js_code, 0, 0)
120 self.assertEqual([], self.GetAutofillProfile()['profiles']) 121 self.assertEqual([], self.GetAutofillProfile()['profiles'])
121 122
122 def testFilterMalformedEmailAddresses(self): 123 def testFilterMalformedEmailAddresses(self):
123 """Test Autofill filters out malformed email address during form submit.""" 124 """Test Autofill filters out malformed email address during form submit."""
124 profile = {'NAME_FIRST': 'Bob', 125 profile = {'NAME_FIRST': 'Bob',
125 'NAME_LAST': 'Smith', 126 'NAME_LAST': 'Smith',
126 'EMAIL_ADDRESS': 'garbage', 127 'EMAIL_ADDRESS': 'garbage',
127 'ADDRESS_HOME_LINE1': '1234 H St.', 128 'ADDRESS_HOME_LINE1': '1234 H St.',
128 'ADDRESS_HOME_CITY': 'San Jose', 129 'ADDRESS_HOME_CITY': 'San Jose',
129 'ADDRESS_HOME_STATE': 'CA', 130 'ADDRESS_HOME_STATE': 'CA',
130 'ADDRESS_HOME_ZIP': '95110', 131 'ADDRESS_HOME_ZIP': '95110',
131 'COMPANY_NAME': 'Company X', 132 'COMPANY_NAME': 'Company X',
132 'PHONE_HOME_WHOLE_NUMBER': '408-123-4567',} 133 'PHONE_HOME_WHOLE_NUMBER': '408-123-4567',}
133 url = self.GetHttpURLForDataPath( 134 url = self.GetHttpURLForDataPath(
134 os.path.join('autofill', 'dup-profiles-test.html')) 135 os.path.join('autofill', 'duplicate_profiles_test.html'))
135 self.NavigateToURL(url) 136 self.NavigateToURL(url)
136 for key, value in profile.iteritems(): 137 for key, value in profile.iteritems():
137 script = ('document.getElementById("%s").value = "%s"; ' 138 script = ('document.getElementById("%s").value = "%s"; '
138 'window.domAutomationController.send("done");') % (key, value) 139 'window.domAutomationController.send("done");') % (key, value)
139 self.ExecuteJavascript(script, 0, 0) 140 self.ExecuteJavascript(script, 0, 0)
140 js_code = """ 141 js_code = """
141 document.getElementById("merge_dup").submit(); 142 document.getElementById("merge_dup").submit();
142 window.addEventListener("unload", function() { 143 window.addEventListener("unload", function() {
143 window.domAutomationController.send("done"); 144 window.domAutomationController.send("done");
144 }); 145 });
145 """ 146 """
146 self.ExecuteJavascript(js_code, 0, 0) 147 self.ExecuteJavascript(js_code, 0, 0)
147 if 'EMAIL_ADDRESS' in self.GetAutofillProfile()['profiles'][0]: 148 if 'EMAIL_ADDRESS' in self.GetAutofillProfile()['profiles'][0]:
148 raise KeyError('TEST FAIL: Malformed email address is saved in profiles.') 149 raise KeyError('TEST FAIL: Malformed email address is saved in profiles.')
149 150
151 def testComparePhoneNumbers(self):
152 """Test phone fields parses correctly from a given profile."""
153 profile_path = os.path.join(self.DataDir(), 'autofill',
154 'phone_pinput_autofill.txt')
155 profile_expected_path = os.path.join(self.DataDir(), 'autofill',
156 'phone_pexpected_autofill.txt')
157 profiles = self.EvalDataFrom(profile_path)
158 profiles_expected = self.EvalDataFrom(profile_expected_path)
159 tab_keypress=0x09
160 down_keypress=0x28
161 return_keypress=0x0D
Ilya Sherman 2011/03/18 23:17:11 Are these constants really not defined in the glob
dyu1 2011/03/21 18:42:35 PyAUto was never meant to interact with the browse
162 self.FillAutofillProfile(profiles=profiles)
163 url = self.GetHttpURLForDataPath(
164 os.path.join('autofill', 'form_phones.html'))
165 for profile_expected in profiles_expected:
166 self.NavigateToURL(url)
167 self.SendWebkitKeyEvent(tab_keypress, tab_index=0, windex=0)
168 self.SendWebkitKeyEvent(down_keypress, tab_index=0, windex=0)
169 self.SendWebkitKeyEvent(down_keypress, tab_index=0, windex=0)
170 self.SendWebkitKeyEvent(return_keypress, tab_index=0, windex=0)
171 form_values = {}
172 for key, value in profile_expected.iteritems():
173 js_returning_field_value = (
174 'var field_value = document.getElementById("%s").value;'
175 'window.domAutomationController.send(field_value);'
176 ) % key
177 form_values[key] = self.ExecuteJavascript(
178 js_returning_field_value, 0, 0)
179 self.assertEqual(
180 form_values[key], value,
181 'Original profile not equal to expected profile at key: "%s" \
182 \nExpected: "%s"\nReturned: "%s"' % (key, value, form_values[key]))
183
184 def FormFillLatencyAfterSubmit(self):
185 """Test latency time on form submit with lots of stored Autofill profiles.
186
187 This test verifies when a profile is selected from the Autofill dictionary,
188 that consists of thousands of profiles, the form does not hang after being
189 submitted.
190 """
191 # HTML file needs to be run from a http:// url.
192 url = self.GetHttpURLForDataPath(
193 os.path.join('autofill', 'latency_after_submit_test.html'))
194 # Run the generator script to generate the dictionary list needed for the
195 # profiles.
196 gen = autofill_dataset_generator.DatasetGenerator(
197 logging_level=logging.ERROR) # Set verbosity to INFO, WARNING, ERROR.
Ilya Sherman 2011/03/18 23:17:11 nit: I think this comment ("Set verbosity...") is
dyu1 2011/03/21 18:42:35 Removed.
198 list_of_dict = gen.GenerateDataset(num_of_records_to_generate=50)
Ilya Sherman 2011/03/18 23:17:11 Why 50 and not more like 1000?
dyu1 2011/03/21 18:42:35 I plan to change this to 1000 after I pass code re
Ilya Sherman 2011/03/22 01:18:58 Hmm... generally the idea of code review is to rev
dyu1 2011/03/22 02:52:35 I changed it to the value that was being reported
199 self.FillAutofillProfile(profiles=list_of_dict)
200 tab_keypress=0x09
201 down_keypress=0x28
202 return_keypress=0x0D
203 self.NavigateToURL(url)
204 self.SendWebkitKeyEvent(tab_keypress, windex=0, tab_index=0)
205 self.SendWebkitKeyEvent(down_keypress, windex=0, tab_index=0)
206 self.SendWebkitKeyEvent(down_keypress, windex=0, tab_index=0)
207 self.SendWebkitKeyEvent(return_keypress, windex=0, tab_index=0)
208 # Requires manual intervention to test the performance time after submitted
209 # the form.
210 raw_input()
Ilya Sherman 2011/03/18 23:17:11 Why do we need manual intervention? It would be g
dyu1 2011/03/21 18:42:35 There are no hooks exposed in pyauto to measure ti
211
212
150 def AutofillCrowdsourcing(self): 213 def AutofillCrowdsourcing(self):
151 """Test able to send POST request of web form to Autofill server. 214 """Test able to send POST request of web form to Autofill server.
152 215
153 The Autofill server processes the data offline, so it can take a few days 216 The Autofill server processes the data offline, so it can take a few days
154 for the result to be detectable. Manual verification is required. 217 for the result to be detectable. Manual verification is required.
155 """ 218 """
156 # HTML file needs to be run from a specific http:// url to be able to verify 219 # HTML file needs to be run from a specific http:// url to be able to verify
157 # the results a few days later by visiting the same url. 220 # the results a few days later by visiting the same url.
158 url = 'http://www.corp.google.com/~dyu/autofill/crowdsourcing-test.html' 221 url = 'http://www.corp.google.com/~dyu/autofill/crowdsourcing-test.html'
159 # Adding crowdsourcing Autofill profile. 222 # Adding crowdsourcing Autofill profile.
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 merged_profile = os.path.join(self.DataDir(), 'autofill', 275 merged_profile = os.path.join(self.DataDir(), 'autofill',
213 'merged-profiles.txt') 276 'merged-profiles.txt')
214 profile_dict = self.GetAutofillProfile()['profiles'] 277 profile_dict = self.GetAutofillProfile()['profiles']
215 output = open(merged_profile, 'wb') 278 output = open(merged_profile, 'wb')
216 pickle.dump(profile_dict, output) 279 pickle.dump(profile_dict, output)
217 output.close() 280 output.close()
218 281
219 282
220 if __name__ == '__main__': 283 if __name__ == '__main__':
221 pyauto_functional.Main() 284 pyauto_functional.Main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698