Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2011 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 import re | 9 import re |
| 10 | 10 |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 73 self.GetAutofillProfile()['credit_cards'], | 73 self.GetAutofillProfile()['credit_cards'], |
| 74 msg='Autofill credit card data does not match.') | 74 msg='Autofill credit card data does not match.') |
| 75 | 75 |
| 76 def testGetProfilesEmpty(self): | 76 def testGetProfilesEmpty(self): |
| 77 """Test getting profiles when none have been filled.""" | 77 """Test getting profiles when none have been filled.""" |
| 78 profile = self.GetAutofillProfile() | 78 profile = self.GetAutofillProfile() |
| 79 self.assertEqual([], profile['profiles']) | 79 self.assertEqual([], profile['profiles']) |
| 80 self.assertEqual([], profile['credit_cards']) | 80 self.assertEqual([], profile['credit_cards']) |
| 81 | 81 |
| 82 def testAutofillInvalid(self): | 82 def testAutofillInvalid(self): |
| 83 """Test filling in invalid values for profiles.""" | 83 """Test filling in invalid values for profiles are saved as-is. |
| 84 # First try profiles with invalid input. | 84 |
| 85 Phone/Fax information entered into the prefs UI is not validated or rejected | |
| 86 except for duplicates. | |
| 87 """ | |
| 88 # First try profiles with invalid ZIP input. | |
| 85 without_invalid = {'NAME_FIRST': u'Will', | 89 without_invalid = {'NAME_FIRST': u'Will', |
| 86 'ADDRESS_HOME_CITY': 'Sunnyvale', | 90 'ADDRESS_HOME_CITY': 'Sunnyvale', |
| 87 'ADDRESS_HOME_STATE': 'CA', | 91 'ADDRESS_HOME_STATE': 'CA', |
| 88 'ADDRESS_HOME_ZIP': 'my_zip', | 92 'ADDRESS_HOME_ZIP': 'my_zip', |
| 89 'ADDRESS_HOME_COUNTRY': 'United States'} | 93 'ADDRESS_HOME_COUNTRY': 'United States'} |
| 90 # Add some invalid fields. | 94 # Add invalid data for phone and fax fields. |
| 91 with_invalid = without_invalid.copy() | 95 with_invalid = without_invalid.copy() |
| 92 with_invalid['PHONE_HOME_WHOLE_NUMBER'] = 'Invalid_Phone_Number' | 96 with_invalid['PHONE_HOME_WHOLE_NUMBER'] = 'Invalid_Phone_Number' |
| 93 with_invalid['PHONE_FAX_WHOLE_NUMBER'] = 'Invalid_Fax_Number' | 97 with_invalid['PHONE_FAX_WHOLE_NUMBER'] = 'Invalid_Fax_Number' |
| 94 self.FillAutofillProfile(profiles=[with_invalid]) | 98 self.FillAutofillProfile(profiles=[with_invalid]) |
| 95 self.assertEqual([without_invalid], | 99 self.assertFalse([without_invalid], |
|
Nirnimesh
2011/05/24 02:39:43
you want assertNotEqual()
dyu1
2011/05/24 03:20:00
Done.
| |
| 96 self.GetAutofillProfile()['profiles']) | 100 self.GetAutofillProfile()['profiles'], |
| 101 msg='Phone/Fax data entered into prefs UI is validated.') | |
| 97 | 102 |
| 98 def testAutofillPrefsStringSavedAsIs(self): | 103 def testAutofillPrefsStringSavedAsIs(self): |
| 99 """Test invalid credit card numbers typed in prefs should be saved as-is.""" | 104 """Test invalid credit card numbers typed in prefs should be saved as-is.""" |
| 100 credit_card = {'CREDIT_CARD_NUMBER': 'Not_0123-5Checked'} | 105 credit_card = {'CREDIT_CARD_NUMBER': 'Not_0123-5Checked'} |
| 101 self.FillAutofillProfile(credit_cards=[credit_card]) | 106 self.FillAutofillProfile(credit_cards=[credit_card]) |
| 102 self.assertEqual([credit_card], | 107 self.assertEqual([credit_card], |
| 103 self.GetAutofillProfile()['credit_cards'], | 108 self.GetAutofillProfile()['credit_cards'], |
| 104 msg='Credit card number in prefs not saved as-is.') | 109 msg='Credit card number in prefs not saved as-is.') |
| 105 | 110 |
| 106 def _FillFormAndSubmit(self, dictionary, filename, tab_index=0, windex=0): | 111 def _FillFormAndSubmit(self, dictionary, filename, tab_index=0, windex=0): |
| (...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 620 'window.domAutomationController.send("done");') % (key, value) | 625 'window.domAutomationController.send("done");') % (key, value) |
| 621 self.ExecuteJavascript(script, 0, 0) | 626 self.ExecuteJavascript(script, 0, 0) |
| 622 self.ExecuteJavascript('document.getElementById("testform").submit();' | 627 self.ExecuteJavascript('document.getElementById("testform").submit();' |
| 623 'window.domAutomationController.send("done");', | 628 'window.domAutomationController.send("done");', |
| 624 0, 0) | 629 0, 0) |
| 625 return len(list_of_dict) | 630 return len(list_of_dict) |
| 626 | 631 |
| 627 | 632 |
| 628 if __name__ == '__main__': | 633 if __name__ == '__main__': |
| 629 pyauto_functional.Main() | 634 pyauto_functional.Main() |
| OLD | NEW |