Index: chrome/test/functional/autofill.py |
=================================================================== |
--- chrome/test/functional/autofill.py (revision 78641) |
+++ chrome/test/functional/autofill.py (working copy) |
@@ -8,6 +8,7 @@ |
import pickle |
import autofill_dataset_converter |
+import autofill_dataset_generator |
import pyauto_functional # Must be imported before pyauto |
import pyauto |
@@ -147,6 +148,69 @@ |
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) |
+ tab_keypress=0x09 |
+ down_keypress=0x28 |
+ return_keypress=0x0D |
dennis_jeffrey
2011/03/18 21:44:01
I think the above 3 lines are better declared as n
dyu1
2011/03/21 18:42:35
Done.
|
+ self.FillAutofillProfile(profiles=profiles) |
+ url = self.GetHttpURLForDataPath( |
+ os.path.join('autofill', 'form_phones.html')) |
+ for profile_expected in profiles_expected: |
+ self.NavigateToURL(url) |
+ self.SendKeyEvent(tab_keypress, windex=0, tab_index=0) |
dennis_jeffrey
2011/03/18 21:44:01
Could you add a comment to explain what you're doi
dyu1
2011/03/21 18:42:35
I thought the named variables was self explanatory
|
+ self.SendKeyEvent(down_keypress, windex=0, tab_index=0) |
+ self.SendKeyEvent(down_keypress, windex=0, tab_index=0) |
+ self.SendKeyEvent(return_keypress, windex=0, tab_index=0) |
+ raw_input() |
dennis_jeffrey
2011/03/18 21:44:01
This line shouldn't be here in an automated test,
dyu1
2011/03/21 18:42:35
Left it in for debugging but removed it in my last
|
+ 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" \ |
+ \nExpected: "%s"\nReturned: "%s"' % (key, value, form_values[key])) |
dennis_jeffrey
2011/03/18 21:44:01
Rather than using "\" to continue the string onto
dyu1
2011/03/21 18:42:35
Done.
|
+ |
+ def FormFillLatencyAfterSubmit(self): |
dennis_jeffrey
2011/03/18 21:44:01
Shouldn't this function name begin with the substr
dyu1
2011/03/21 18:42:35
Since this test is only partially automated I didn
|
+ """Test latency time on form submit with lots of stored Autofill profiles. |
+ |
+ This test verifies when a profile is selected from the Autofill dictionary, |
dennis_jeffrey
2011/03/18 21:44:01
Remove the comma at the end of this line.
dyu1
2011/03/21 18:42:35
Done.
|
+ 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) # Set verbosity to INFO, WARNING, ERROR. |
+ list_of_dict = gen.GenerateDataset(num_of_records_to_generate=50) |
dennis_jeffrey
2011/03/18 21:44:01
Does this mean you're generating 50 profiles? The
dyu1
2011/03/21 18:42:35
Only left 50 for testing purposes. Will change to
|
+ self.FillAutofillProfile(profiles=list_of_dict) |
+ tab_keypress=0x09 |
+ down_keypress=0x28 |
+ return_keypress=0x0D |
dennis_jeffrey
2011/03/18 21:44:01
Perhaps better as constants defined at the top of
dyu1
2011/03/21 18:42:35
Done.
|
+ self.NavigateToURL(url) |
+ self.SendKeyEvent(tab_keypress, windex=0, tab_index=0) |
dennis_jeffrey
2011/03/18 21:44:01
Add a comment to describe what this sequence of ke
dyu1
2011/03/21 18:42:35
Done.
|
+ self.SendKeyEvent(down_keypress, windex=0, tab_index=0) |
+ self.SendKeyEvent(down_keypress, windex=0, tab_index=0) |
+ self.SendKeyEvent(return_keypress, windex=0, tab_index=0) |
+ # Requires manual intervention to test the performance time after submitted |
dennis_jeffrey
2011/03/18 21:44:01
"submitted" --> "submitting"
dyu1
2011/03/21 18:42:35
Done.
|
+ # the form. |
+ raw_input() |
dennis_jeffrey
2011/03/18 21:44:01
Is it considered acceptable to check in PyAuto tes
dyu1
2011/03/21 18:42:35
Yes, should be fine as Nir approved of two other t
|
+ |
+ |
def AutofillCrowdsourcing(self): |
"""Test able to send POST request of web form to Autofill server. |