Index: chrome/test/functional/autofill.py |
=================================================================== |
--- chrome/test/functional/autofill.py (revision 74040) |
+++ chrome/test/functional/autofill.py (working copy) |
@@ -5,6 +5,7 @@ |
import os |
+import pickle |
Nirnimesh
2011/02/07 23:26:20
group with os above.
pickle is a system import
dyu1
2011/02/09 19:44:56
Done.
|
import pyauto_functional # Must be imported before pyauto |
import pyauto |
@@ -93,9 +94,9 @@ |
self.assertEqual([expected_credit_card], |
self.GetAutoFillProfile()['credit_cards']) |
- def testAutofillCrowdSourcing(self): |
- """Test able to send POST request of web form to crowd source server. |
- Require a loop of 1000 submits as the source server only collects 1% of |
+ def testAutofillCrowdsourcing(self): |
+ """Test able to send POST request of web form to Autofill server. |
+ Require a loop of 1000 submits as the Autofill server only collects 1% of |
the data posted.""" |
# HTML file needs to be run from a specific http:// url to be able to verify |
# the results a few days later by visiting the same url. |
@@ -124,6 +125,33 @@ |
'window.domAutomationController.send("done")', |
0, 0) |
+ def testMergeDuplicateProfilesInAutofill(self): |
+ """Test Autofill ability to merge duplicate profiles and throw away junk |
+ profiles. The goal is to submit a couple hundred profiles and see the merge |
+ outcome.""" |
+ # HTML file needs to be run from a http:// url. |
+ url = self.GetHttpURLForDataPath( |
+ os.path.join('autofill', 'dup-profiles-test.html')) |
+ # Add and set Autofill profiles. |
+ file_path = os.path.join(self.DataDir(), 'autofill', |
+ 'dataset_duplicate-profiles.txt') |
Nirnimesh
2011/02/07 23:26:20
Why use this precooked file? Why not call the csv
dyu1
2011/02/09 19:44:56
Done.
|
+ profiles = self.EvalDataFrom(file_path) |
+ self.FillAutoFillProfile(profiles=profiles) |
+ for i in range(len(self.GetAutoFillProfile()['profiles'])): |
+ self.NavigateToURL(url) |
+ for key, value in self.GetAutoFillProfile()['profiles'][i].iteritems(): |
+ script = 'document.getElementById("%s").value = "%s"; ' \ |
+ 'window.domAutomationController.send("done")' % (key, value) |
+ self.ExecuteJavascript(script, 0, 0) |
+ self.ExecuteJavascript('document.getElementById("merge_dup").submit();' |
+ 'window.domAutomationController.send("done")', |
+ 0, 0) |
+ # Write profile dictionary to a file. |
+ profile_dict = self.GetAutoFillProfile()['profiles'] |
+ output = open('merged-profile.txt', 'wb') |
+ pickle.dump(profile_dict, output) |
+ output.close() |
+ |
if __name__ == '__main__': |
pyauto_functional.Main() |