diff options
author | alyssad@chromium.org <alyssad@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-09 16:29:31 +0000 |
---|---|---|
committer | alyssad@chromium.org <alyssad@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-09 16:29:31 +0000 |
commit | 92ae3884f0208cdf97e7bf3236379d85b810d8d5 (patch) | |
tree | 0119f37945afeb29d70b63797f875ffb03f3dda7 /chrome | |
parent | 071b4b94196fafbf3557771d41db81fa9a7d0ba7 (diff) | |
download | chromium_src-92ae3884f0208cdf97e7bf3236379d85b810d8d5.zip chromium_src-92ae3884f0208cdf97e7bf3236379d85b810d8d5.tar.gz chromium_src-92ae3884f0208cdf97e7bf3236379d85b810d8d5.tar.bz2 |
New autofill pyauto functional tests
This adds some more tests to autofill.py that test invalid input and unicode input.
Review URL: http://codereview.chromium.org/3054049
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@55407 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/test/data/autofill/crazy_autofill.txt | 23 | ||||
-rw-r--r-- | chrome/test/data/autofill/crazy_creditcards.txt | 13 | ||||
-rw-r--r-- | chrome/test/functional/autofill.py | 51 |
3 files changed, 80 insertions, 7 deletions
diff --git a/chrome/test/data/autofill/crazy_autofill.txt b/chrome/test/data/autofill/crazy_autofill.txt new file mode 100644 index 0000000..d1b4b3c --- /dev/null +++ b/chrome/test/data/autofill/crazy_autofill.txt @@ -0,0 +1,23 @@ +# List of crazy autofill profile dictionaries. +# Filenames contain i18n chars, special chars. +# These files are created on-the-fly instead of checking-in because i18n +# chars in filenames causes svn problems on win. +# The filenames are provided as unicode strings so that this file can remain +# ascii. +# Used by: chrome/test/functional/autofill.py +[ + {u'label': u'3243444', u'NAME_FIRST': u'\u0623\u0648\u0628\u0627\u0645\u0627 \u064a\u0639\u062a\u0630\u0631 \u0647\u0627\u062a\u0641\u064a\u0627 \u0644\u0645\u0648\u0638\u0641\u0629 \u0633\u0648\u062f\u0627\u0621 \u0627\u0633\u062a\u0642\u0627\u0644\u062a \u0628\u0633\u0628\u0628 \u062a\u0635\u0631\u064a\u062d\u0627\u062a \u0645\u062c\u062a\u0632\u0623\u0629', u'NAME_MIDDLE': u'BANK\xdcBERF\xc4LLE', u'EMAIL_ADDRESS': u'\uacbd\uc81c \ub274\uc2a4 \ub354\ubcf4\uae30@google.com', u'ADDRESS_HOME_LINE1': u'\uad6d\uc815\uc6d0\xb7\uac80\ucc30, \ub178\ubb34\ud604\uc815\ubd80 \ub300\ubd81\uc811\ucd09 \ub2f4\ub2f9 \uc778\uc0ac\ub4e4 \uc870\uc0ac', u'ADDRESS_HOME_CITY': u'\u653f\u5e9c\u4e0d\u6392\u9664\u7acb\u6cd5\u898f\u7ba1\u5c0e\u904a', u'ADDRESS_HOME_ZIP': u'YOHO_54676', u'PHONE_HOME_NUMBER': u'861088828000',u'ADDRESS_HOME_COUNTRY': u'INDIA', u'PHONE_FAX_NUMBER': u'861088828000',}, + + {u'label': u'Profile 1', u'NAME_FIRST': u'\u4e0a\u6d77\u5e02\u91d1\u5c71\u533a \u677e\u9690\u9547\u4ead\u67ab\u516c\u8def1915\u53f7','NAME_LAST': u'aguantó', u'ADDRESS_HOME_ZIP': u'HOME 94043',}, + + {u'label': u'\u4e0a\u6d77\u5e02\u91d1\u5c71\u533a \u677e\u9690\u9547\u4ead\u67ab\u516c\u8def1915\u53f7', u'EMAIL_ADDRESS': u'sue@example.com','COMPANY_NAME': u'Company X',}, + + {u'label': u'Profile 3', u'NAME_FIRST': u'Joe 3254','NAME_LAST': u'\u8bb0\u8d262\u5e74\u591a', u'ADDRESS_HOME_ZIP': u'\uff08\u90ae\u7f16\uff1a201504\uff09',u'EMAIL_ADDRESS': u'télévision@example.com','COMPANY_NAME': u'\u0907\u0932\u0947\u0915\u093f\u091f\u094d\u0930\u0928\u093f\u0915\u094d\u0938, \u0905\u092a\u094b\u0932\u094b \u091f\u093e\u092f\u0930\u094d\u0938 \u0906\u0926\u093f',}, + + {u'label': u'Profile_SAKA', u'NAME_FIRST': u'Larry','NAME_LAST': u'\u0938\u094d\u091f\u093e\u0902\u092a \u0921\u094d\u092f\u0942\u091f\u0940', u'ADDRESS_HOME_ZIP': u'111111111111110000GOOGLE',u'EMAIL_ADDRESS': u'page@000000.com','COMPANY_NAME': u'Google',}, + + {u'label': u'U d\xe1lni\u010dn\xedho p\u0159ivad\u011b\u010de n\u011bkdo odp\xe1lil n\xe1lo\u017e', u'NAME_FIRST': u'\u4e0a\u6d77\u5e02\u91d1\u5c71\u533a \u677e\u9690\u9547\u4ead\u67ab\u516c\u8def1915\u53f7','NAME_LAST': u'\u0646\u062c\u0627\u0645\u064a\u0646\u0627 \u062f\u0639\u0645\u0647\u0627 \u0644\u0644\u0631\u0626\u064a\u0633 \u0627\u0644\u0633\u0648\u062f\u0627\u0646\u064a \u0639\u0645\u0631 \u0627\u0644\u0628\u0634\u064a\u0631', u'ADDRESS_HOME_ZIP': u'HOME 94043',}, + + {u'label': u'HOHO_tryuitty' , u'NAME_FIRST': u'&$%$$$ TESTO *&*&^&^& MOKO',u'NAME_MIDDLE': + u'WOHOOOO$$$$$$$$****',u'EMAIL_ADDRESS': u'yuvu@example.com', u'ADDRESS_HOME_LINE1': u'34544, anderson ST.(120230)', u'ADDRESS_HOME_CITY': u'Sunnyvale', 'ADDRESS_HOME_STATE': u'CA', u'ADDRESS_HOME_ZIP': u'94086', u'PHONE_HOME_NUMBER': u'15466784565', u'ADDRESS_HOME_COUNTRY': u'USA', u'PHONE_FAX_NUMBER': u'6505674567',}, +] diff --git a/chrome/test/data/autofill/crazy_creditcards.txt b/chrome/test/data/autofill/crazy_creditcards.txt new file mode 100644 index 0000000..413a497 --- /dev/null +++ b/chrome/test/data/autofill/crazy_creditcards.txt @@ -0,0 +1,13 @@ +# List of crazy credit card dictionaries. +# Filenames contain i18n chars, special chars. +# These files are created on-the-fly instead of checking-in because i18n +# chars in filenames causes svn problems on win. +# The filenames are provided as unicode strings so that this file can remain +# ascii. +# Used by: chrome/test/functional/autofill.py +[ +{'label': 'Credit Card 1', 'CREDIT_CARD_NAME': u'\u751f\u6d3b\u5f88\u6709\u89c4\u5f8b \u4ee5\u73a9\u4e3a\u4e3b', 'CREDIT_CARD_NUMBER': '6011111111111117', 'CREDIT_CARD_EXP_MONTH': '12', 'CREDIT_CARD_EXP_4_DIGIT_YEAR': '2011'}, +{'label': u'\u88dc\u511f\u8ad6\u8b70\u3068\u5207\u308a\u96e2\u3057\u305f\u3044\u8003\u3048\u3060', 'CREDIT_CARD_NAME': 'John Williams', 'CREDIT_CARD_NUMBER': 'WokoAwesome12345', 'CREDIT_CARD_EXP_MONTH': '10', 'CREDIT_CARD_EXP_4_DIGIT_YEAR': '2015'}, +{'label': u'Wohlt\xe4tigkeitsorganisationen flie\xdfen', 'CREDIT_CARD_NAME': u'\u0623\u062d\u0645\u062f\u064a \u0646\u062c\u0627\u062f \u0644\u0645\u062d\u0627\u0648\u0644\u0647 \u0627\u063a\u062a\u064a\u0627\u0644 \u0641\u064a \u0645\u062f\u064a\u0646\u0629 \u0647\u0645\u062f\u0627\u0646 ', 'CREDIT_CARD_NUMBER':u'\u092a\u0941\u0928\u0930\u094d\u091c\u0940\u0935\u093f\u0924 \u0939\u094b\u0917\u093e \u0928\u093e\u0932\u0902\u0926\u093e', 'CREDIT_CARD_EXP_MONTH': '10', 'CREDIT_CARD_EXP_4_DIGIT_YEAR': '2015'}, +{'label': u'\u05ea\u05d5\u05e9\u05d1\u05ea \u05d9-\u05dd \u05d8\u05d1\u05e2\u05d4 \u05d1\u05d1\u05d9\u05dc\u05d5\u05d9 \u05e2\u05dd \u05d0\u05d7\u05d5\u05ea\u05d4 \u05d1\u05d7\u05d5\u05e3 \u05d1\u05ea"\u05d0', 'CREDIT_CARD_NAME': u'\u039d\u03ad\u03b5\u03c2 \u03c3\u03c5\u03b3\u03c7\u03c9\u03bd\u03b5\u03cd\u03c3\u03b5\u03b9\u03c2 \u03ba\u03b1\u03b9 \u03ba\u03b1\u03c4\u03b1\u03c1\u03b3\u03ae\u03c3\u03b5\u03b9\u03c2', 'CREDIT_CARD_NUMBER':'00000000000000000000000', 'CREDIT_CARD_EXP_MONTH': '01', 'CREDIT_CARD_EXP_4_DIGIT_YEAR': '2016'}, +] diff --git a/chrome/test/functional/autofill.py b/chrome/test/functional/autofill.py index 53323e1..248a7a8 100644 --- a/chrome/test/functional/autofill.py +++ b/chrome/test/functional/autofill.py @@ -3,6 +3,8 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. +import os + import pyauto_functional # Must be imported before pyauto import pyauto @@ -11,7 +13,7 @@ class AutoFillTest(pyauto.PyUITest): """Tests that autofill works correctly""" def testFillProfile(self): - """Test filling profiles and overwriting with new profiles""" + """Test filling profiles and overwriting with new profiles.""" profiles = [{'label': 'Profile 1', 'NAME_FIRST': 'Bob', 'NAME_LAST': 'Smith', 'ADDRESS_HOME_ZIP': '94043',}, {'label': 'Profile 2', 'EMAIL_ADDRESS': 'sue@example.com', @@ -34,19 +36,54 @@ class AutoFillTest(pyauto.PyUITest): self.assertEqual(profiles, profile['profiles']) self.assertEqual(credit_cards, profile['credit_cards']) - def testFillProfileUnicode(self): - """Test filling profiles with unicode strings""" - profiles = [{'label': u'unic\u00F3de', 'NAME_FIRST': u'J\u00E4n', - 'ADDRESS_HOME_LINE1': u'123 R\u00F6d'}] - self.FillAutoFillProfile(profiles) + def testFillProfileCrazyCharacters(self): + """Test filling profiles with unicode strings and crazy characters.""" + # Adding autofill profiles. + file_path = os.path.join(self.DataDir(), 'autofill', 'crazy_autofill.txt') + profiles = self.EvalDataFrom(file_path) + self.FillAutoFillProfile(profiles=profiles) self.assertEqual(profiles, self.GetAutoFillProfile()['profiles']) + # Adding credit cards. + file_path = os.path.join(self.DataDir(), 'autofill', + 'crazy_creditcards.txt') + credit_cards = self.EvalDataFrom(file_path) + self.FillAutoFillProfile(credit_cards=credit_cards) + self.assertEqual(credit_cards, + self.GetAutoFillProfile()['credit_cards']) + def testGetProfilesEmpty(self): - """Test getting profiles when none have been filled""" + """Test getting profiles when none have been filled.""" profile = self.GetAutoFillProfile() self.assertEqual([], profile['profiles']) self.assertEqual([], profile['credit_cards']) + def testAutofillInvalid(self): + """Test filling in invalid values for profiles and credit cards.""" + # First try profiles with invalid input. + without_invalid = {'label': 'Invalid_Profile' , 'NAME_FIRST': u'Will', + 'ADDRESS_HOME_CITY': 'Sunnyvale', + 'ADDRESS_HOME_STATE': 'CA', + 'ADDRESS_HOME_ZIP': 'my_zip', + 'ADDRESS_HOME_COUNTRY': 'USA'} + # Add some invalid fields. + with_invalid = without_invalid.copy() + with_invalid['PHONE_HOME_NUMBER'] = 'Invalid_Phone_Number' + with_invalid['PHONE_FAX_NUMBER'] = 'Invalid_Fax_Number' + self.FillAutoFillProfile(profiles=[with_invalid]) + self.assertEqual([without_invalid], self.GetAutoFillProfile()['profiles']) + + # Then try credit cards with invalid input. + without_invalid = {'label': 'Invalid_CC', + 'CREDIT_CARD_NUMBER': 'Not_Checked'} + # Add some invalid fields. + with_invalid = without_invalid.copy() + with_invalid['CREDIT_CARD_EXP_MONTH'] = 'Not_A_Month' + with_invalid['CREDIT_CARD_EXP_4_DIGIT_YEAR'] = 'Not_A_Year' + self.FillAutoFillProfile(credit_cards=[with_invalid]) + self.assertEqual([without_invalid], + self.GetAutoFillProfile()['credit_cards']) + if __name__ == '__main__': pyauto_functional.Main() |