Chromium Code Reviews| Index: chrome/browser/autofill/form_structure_unittest.cc |
| diff --git a/chrome/browser/autofill/form_structure_unittest.cc b/chrome/browser/autofill/form_structure_unittest.cc |
| index e0c77fe0ab2211367a5f6afee3de511f422de8f0..5f60cea0b0777224f9cbd6b818f4f17ec3344414 100644 |
| --- a/chrome/browser/autofill/form_structure_unittest.cc |
| +++ b/chrome/browser/autofill/form_structure_unittest.cc |
| @@ -4,10 +4,12 @@ |
| #include "chrome/browser/autofill/form_structure.h" |
| +#include "base/command_line.h" |
| #include "base/memory/scoped_ptr.h" |
| #include "base/string_util.h" |
| #include "base/utf_string_conversions.h" |
| #include "chrome/browser/autofill/autofill_metrics.h" |
| +#include "chrome/common/chrome_switches.h" |
| #include "chrome/common/form_data.h" |
| #include "chrome/common/form_field_data.h" |
| #include "googleurl/src/gurl.h" |
| @@ -1430,6 +1432,13 @@ TEST(FormStructureTest, EncodeQueryRequest) { |
| field.name = ASCIIToUTF16("expiration_year"); |
| form.fields.push_back(field); |
| + // Add checkable field. |
| + FormFieldData checkable_field; |
| + checkable_field.is_checkable = true; |
| + checkable_field.label = ASCIIToUTF16("Checkable1"); |
| + checkable_field.name = ASCIIToUTF16("Checkable1"); |
| + form.fields.push_back(checkable_field); |
| + |
| ScopedVector<FormStructure> forms; |
| forms.push_back(new FormStructure(form)); |
| std::vector<std::string> encoded_signatures; |
| @@ -1487,15 +1496,16 @@ TEST(FormStructureTest, EncodeQueryRequest) { |
| "signature=\"509334676\"/></form></autofillquery>"; |
| EXPECT_EQ(kResponse2, encoded_xml); |
| + FormData malformed_form(form); |
| // Add 50 address fields - the form is not valid anymore, but previous ones |
| // are. The result should be the same as in previous test. |
| for (size_t i = 0; i < 50; ++i) { |
| field.label = ASCIIToUTF16("Address"); |
| field.name = ASCIIToUTF16("address"); |
| - form.fields.push_back(field); |
| + malformed_form.fields.push_back(field); |
| } |
| - forms.push_back(new FormStructure(form)); |
| + forms.push_back(new FormStructure(malformed_form)); |
| ASSERT_TRUE(FormStructure::EncodeQueryRequest(forms.get(), |
| &encoded_signatures, |
| &encoded_xml)); |
| @@ -1506,12 +1516,37 @@ TEST(FormStructureTest, EncodeQueryRequest) { |
| // Check that we fail if there are only bad form(s). |
| ScopedVector<FormStructure> bad_forms; |
| - bad_forms.push_back(new FormStructure(form)); |
| + bad_forms.push_back(new FormStructure(malformed_form)); |
| EXPECT_FALSE(FormStructure::EncodeQueryRequest(bad_forms.get(), |
| &encoded_signatures, |
| &encoded_xml)); |
| EXPECT_EQ(0U, encoded_signatures.size()); |
| EXPECT_EQ("", encoded_xml); |
| + |
| + // Check the behaviour with kEnableExperimentalFormFilling switch on. |
| + CommandLine::ForCurrentProcess()->AppendSwitch( |
| + switches::kEnableExperimentalFormFilling); |
| + // Add the previous form but with flag set. |
| + ScopedVector<FormStructure> checkable_forms; |
| + checkable_forms.push_back(new FormStructure(form)); |
| + |
| + ASSERT_TRUE(FormStructure::EncodeQueryRequest(checkable_forms.get(), |
| + &encoded_signatures, |
| + &encoded_xml)); |
| + const char * const kSignature3 = "7747357776717901584"; |
| + const char * const kResponse3 = |
| + "<?xml version=\"1.0\" encoding=\"UTF-8\"?><autofillquery " |
| + "clientversion=\"6.1.1715.1442/en (GGLL)\" accepts=\"e\">" |
| + "<form signature=\"7747357776717901584\"><field signature=\"412125936\"/>" |
| + "<field signature=\"1917667676\"/><field signature=\"2226358947\"/><field" |
| + " signature=\"747221617\"/><field signature=\"4108155786\"/><field " |
| + "signature=\"3410250678\"/><field signature=\"509334676\"/><field " |
| + "signature=\"509334676\"/><field signature=\"509334676\"/><field " |
| + "signature=\"509334676\"/><field signature=\"509334676\"/></form>" |
| + "</autofillquery>"; |
| + ASSERT_EQ(1U, encoded_signatures.size()); |
| + EXPECT_EQ(kSignature3, encoded_signatures[0]); |
| + EXPECT_EQ(kResponse3, encoded_xml); |
|
Ilya Sherman
2012/12/01 00:54:12
Please also add a similar test within EncodeUpload
Raman Kakilate
2012/12/06 01:54:05
Done. and fixed the code to not consider checkable
|
| } |
| TEST(FormStructureTest, EncodeUploadRequest) { |