| 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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 | 85 |
| 86 def testGetProfilesEmpty(self): | 86 def testGetProfilesEmpty(self): |
| 87 """Test getting profiles when none have been filled.""" | 87 """Test getting profiles when none have been filled.""" |
| 88 profile = self.GetAutofillProfile() | 88 profile = self.GetAutofillProfile() |
| 89 self.assertEqual([], profile['profiles']) | 89 self.assertEqual([], profile['profiles']) |
| 90 self.assertEqual([], profile['credit_cards']) | 90 self.assertEqual([], profile['credit_cards']) |
| 91 | 91 |
| 92 def testAutofillInvalid(self): | 92 def testAutofillInvalid(self): |
| 93 """Test filling in invalid values for profiles are saved as-is. | 93 """Test filling in invalid values for profiles are saved as-is. |
| 94 | 94 |
| 95 Phone/Fax information entered into the prefs UI is not validated or rejected | 95 Phone information entered into the prefs UI is not validated or rejected |
| 96 except for duplicates. | 96 except for duplicates. |
| 97 """ | 97 """ |
| 98 # First try profiles with invalid ZIP input. | 98 # First try profiles with invalid ZIP input. |
| 99 without_invalid = {'NAME_FIRST': ['Will',], | 99 without_invalid = {'NAME_FIRST': ['Will',], |
| 100 'ADDRESS_HOME_CITY': ['Sunnyvale',], | 100 'ADDRESS_HOME_CITY': ['Sunnyvale',], |
| 101 'ADDRESS_HOME_STATE': ['CA',], | 101 'ADDRESS_HOME_STATE': ['CA',], |
| 102 'ADDRESS_HOME_ZIP': ['my_zip',], | 102 'ADDRESS_HOME_ZIP': ['my_zip',], |
| 103 'ADDRESS_HOME_COUNTRY': ['United States',]} | 103 'ADDRESS_HOME_COUNTRY': ['United States',]} |
| 104 # Add invalid data for phone and fax fields. | 104 # Add invalid data for phone field. |
| 105 with_invalid = without_invalid.copy() | 105 with_invalid = without_invalid.copy() |
| 106 with_invalid['PHONE_HOME_WHOLE_NUMBER'] = ['Invalid_Phone_Number',] | 106 with_invalid['PHONE_HOME_WHOLE_NUMBER'] = ['Invalid_Phone_Number',] |
| 107 with_invalid['PHONE_FAX_WHOLE_NUMBER'] = ['Invalid_Fax_Number',] | |
| 108 self.FillAutofillProfile(profiles=[with_invalid]) | 107 self.FillAutofillProfile(profiles=[with_invalid]) |
| 109 self.assertNotEqual( | 108 self.assertNotEqual( |
| 110 [without_invalid], self.GetAutofillProfile()['profiles'], | 109 [without_invalid], self.GetAutofillProfile()['profiles'], |
| 111 msg='Phone/Fax data entered into prefs UI is validated.') | 110 msg='Phone data entered into prefs UI is validated.') |
| 112 | 111 |
| 113 def testAutofillPrefsStringSavedAsIs(self): | 112 def testAutofillPrefsStringSavedAsIs(self): |
| 114 """Test invalid credit card numbers typed in prefs should be saved as-is.""" | 113 """Test invalid credit card numbers typed in prefs should be saved as-is.""" |
| 115 credit_card = {'CREDIT_CARD_NUMBER': 'Not_0123-5Checked'} | 114 credit_card = {'CREDIT_CARD_NUMBER': 'Not_0123-5Checked'} |
| 116 self.FillAutofillProfile(credit_cards=[credit_card]) | 115 self.FillAutofillProfile(credit_cards=[credit_card]) |
| 117 self.assertEqual([credit_card], | 116 self.assertEqual([credit_card], |
| 118 self.GetAutofillProfile()['credit_cards'], | 117 self.GetAutofillProfile()['credit_cards'], |
| 119 msg='Credit card number in prefs not saved as-is.') | 118 msg='Credit card number in prefs not saved as-is.') |
| 120 | 119 |
| 121 def _WaitForWebpageFormReadyToFillIn(self, form_profile, tab_index, windex): | 120 def _WaitForWebpageFormReadyToFillIn(self, form_profile, tab_index, windex): |
| (...skipping 678 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 800 # Refresh the page to ensure the UI is up-to-date. | 799 # Refresh the page to ensure the UI is up-to-date. |
| 801 driver.refresh() | 800 driver.refresh() |
| 802 list_entry = driver.find_element_by_class_name('autofill-list-item') | 801 list_entry = driver.find_element_by_class_name('autofill-list-item') |
| 803 self.assertTrue(list_entry.is_displayed) | 802 self.assertTrue(list_entry.is_displayed) |
| 804 self.assertEqual('Jane Doe', list_entry.text, | 803 self.assertEqual('Jane Doe', list_entry.text, |
| 805 msg='Saved CC line item not same as what was entered.') | 804 msg='Saved CC line item not same as what was entered.') |
| 806 | 805 |
| 807 | 806 |
| 808 if __name__ == '__main__': | 807 if __name__ == '__main__': |
| 809 pyauto_functional.Main() | 808 pyauto_functional.Main() |
| OLD | NEW |