Index: chrome/test/functional/autofill.py |
=================================================================== |
--- chrome/test/functional/autofill.py (revision 78925) |
+++ chrome/test/functional/autofill.py (working copy) |
@@ -1,5 +1,5 @@ |
#!/usr/bin/python |
-# Copyright (c) 2011 The Chromium Authors. All rights reserved. |
+# Copyright (c) 2010 The Chromium Authors. All rights reserved. |
Ilya Sherman
2011/03/22 04:08:58
nit: Please don't reverse copyright updates ;)
dyu1
2011/03/24 19:46:51
Done.
|
# Use of this source code is governed by a BSD-style license that can be |
# found in the LICENSE file. |
@@ -8,11 +8,15 @@ |
import pickle |
import autofill_dataset_converter |
+import autofill_dataset_generator |
import pyauto_functional # Must be imported before pyauto |
import pyauto |
+TAB_KEYPRESS = 0x09 # Tab keyboard key press. |
+DOWN_KEYPRESS = 0x28 # Down arrow keyboard key press. |
+RETURN_KEYPRESS = 0x0D # Return keyboard key press. |
-class AutofillTest(pyauto.PyUITest): |
+class AutoFillTest(pyauto.PyUITest): |
"""Tests that autofill works correctly""" |
def Debug(self): |
@@ -104,7 +108,7 @@ |
'COMPANY_NAME': 'Company X', |
'PHONE_HOME_WHOLE_NUMBER': '650-123-4567',} |
url = self.GetHttpURLForDataPath( |
- os.path.join('autofill', 'dup-profiles-test.html')) |
+ os.path.join('autofill', 'duplicate_profiles_test.html')) |
self.NavigateToURL(url) |
for key, value in profile.iteritems(): |
script = ('document.getElementById("%s").value = "%s"; ' |
@@ -131,7 +135,7 @@ |
'COMPANY_NAME': 'Company X', |
'PHONE_HOME_WHOLE_NUMBER': '408-123-4567',} |
url = self.GetHttpURLForDataPath( |
- os.path.join('autofill', 'dup-profiles-test.html')) |
+ os.path.join('autofill', 'duplicate_profiles_test.html')) |
self.NavigateToURL(url) |
for key, value in profile.iteritems(): |
script = ('document.getElementById("%s").value = "%s"; ' |
@@ -147,6 +151,70 @@ |
if 'EMAIL_ADDRESS' in self.GetAutofillProfile()['profiles'][0]: |
raise KeyError('TEST FAIL: Malformed email address is saved in profiles.') |
+ def testComparePhoneNumbers(self): |
+ """Test phone fields parses correctly from a given profile.""" |
+ profile_path = os.path.join(self.DataDir(), 'autofill', |
+ 'phone_pinput_autofill.txt') |
+ profile_expected_path = os.path.join(self.DataDir(), 'autofill', |
+ 'phone_pexpected_autofill.txt') |
+ profiles = self.EvalDataFrom(profile_path) |
+ profiles_expected = self.EvalDataFrom(profile_expected_path) |
+ self.FillAutofillProfile(profiles=profiles) |
+ url = self.GetHttpURLForDataPath( |
+ os.path.join('autofill', 'form_phones.html')) |
+ for profile_expected in profiles_expected: |
+ self.NavigateToURL(url) |
+ # Tab keyboard key press. |
+ self.SendWebkitKeyEvent(TAB_KEYPRESS, tab_index=0, windex=0) |
+ # Down arrow keyboard key press. |
+ self.SendWebkitKeyEvent(DOWN_KEYPRESS, tab_index=0, windex=0) |
+ # Down arrow keyboard key press. |
+ self.SendWebkitKeyEvent(DOWN_KEYPRESS, tab_index=0, windex=0) |
+ # Return keyboard key press. |
+ self.SendWebkitKeyEvent(RETURN_KEYPRESS, tab_index=0, windex=0) |
+ form_values = {} |
+ for key, value in profile_expected.iteritems(): |
+ js_returning_field_value = ( |
+ 'var field_value = document.getElementById("%s").value;' |
+ 'window.domAutomationController.send(field_value);' |
+ ) % key |
+ form_values[key] = self.ExecuteJavascript( |
+ js_returning_field_value, 0, 0) |
+ self.assertEqual( |
+ form_values[key], value, |
+ ('Original profile not equal to expected profile at key: "%s"\n' |
+ 'Expected: "%s"\nReturned: "%s"' % (key, value, form_values[key]))) |
+ |
+ def FormFillLatencyAfterSubmit(self): |
+ """Test latency time on form submit with lots of stored Autofill profiles. |
+ |
+ This test verifies when a profile is selected from the Autofill dictionary |
+ that consists of thousands of profiles, the form does not hang after being |
+ submitted. |
+ """ |
+ # HTML file needs to be run from a http:// url. |
+ url = self.GetHttpURLForDataPath( |
+ os.path.join('autofill', 'latency_after_submit_test.html')) |
+ # Run the generator script to generate the dictionary list needed for the |
+ # profiles. |
+ gen = autofill_dataset_generator.DatasetGenerator( |
+ logging_level=logging.ERROR) |
+ list_of_dict = gen.GenerateDataset(num_of_dict_to_generate=50) |
+ self.FillAutofillProfile(profiles=list_of_dict) |
+ self.NavigateToURL(url) |
+ # Tab keyboard key press. |
+ self.SendWebkitKeyEvent(TAB_KEYPRESS, windex=0, tab_index=0) |
+ # Down arrow keyboard key press. |
+ self.SendWebkitKeyEvent(DOWN_KEYPRESS, windex=0, tab_index=0) |
+ # Down arrow keyboard key press. |
+ self.SendWebkitKeyEvent(DOWN_KEYPRESS, windex=0, tab_index=0) |
+ # Return keyboard key press. |
+ self.SendWebkitKeyEvent(RETURN_KEYPRESS, windex=0, tab_index=0) |
+ # Requires manual intervention to test the performance time after submitting |
+ # the form. |
+ raw_input() |
+ |
+ |
def AutofillCrowdsourcing(self): |
"""Test able to send POST request of web form to Autofill server. |