Chromium Code Reviews| Index: chrome/renderer/autofill/form_manager_browsertest.cc |
| diff --git a/chrome/renderer/autofill/form_manager_browsertest.cc b/chrome/renderer/autofill/form_manager_browsertest.cc |
| index 6d160549796a40f8695293440348ff5a88258336..ec30f6aa044d9924f894b02606fbca764f3fad40 100644 |
| --- a/chrome/renderer/autofill/form_manager_browsertest.cc |
| +++ b/chrome/renderer/autofill/form_manager_browsertest.cc |
| @@ -4,8 +4,10 @@ |
| #include <vector> |
| +#include "base/format_macros.h" |
| #include "base/string16.h" |
| #include "base/string_util.h" |
| +#include "base/stringprintf.h" |
| #include "base/utf_string_conversions.h" |
| #include "chrome/renderer/autofill/form_manager.h" |
| #include "chrome/test/base/render_view_test.h" |
| @@ -38,6 +40,19 @@ using autofill::FormManager; |
| using webkit_glue::FormData; |
| using webkit_glue::FormField; |
| +namespace { |
| + |
| +void ExpectFieldEquals(const FormField& expected, const FormField& actual) { |
| + EXPECT_EQ(expected.label, actual.label); |
| + EXPECT_EQ(expected.name, actual.name); |
| + EXPECT_EQ(expected.value, actual.value); |
| + EXPECT_EQ(expected.form_control_type, actual.form_control_type); |
| + EXPECT_EQ(expected.max_length, actual.max_length); |
| + EXPECT_EQ(expected.is_autofilled, actual.is_autofilled); |
| +} |
| + |
| +} // namespace |
| + |
| class FormManagerTest : public RenderViewTest { |
| public: |
| FormManagerTest() : RenderViewTest() {} |
| @@ -80,14 +95,14 @@ class FormManagerTest : public RenderViewTest { |
| for (size_t i = 0; i < labels.size(); ++i) { |
| int max_length = control_types[i] == ASCIIToUTF16("text") ? |
| WebInputElement::defaultMaxLength() : 0; |
| - FormField expected = FormField(labels[i], |
| - names[i], |
| - values[i], |
| - control_types[i], |
| - max_length, |
| - false); |
| - EXPECT_TRUE(fields[i].StrictlyEqualsHack(expected)) |
| - << "Expected \"" << expected << "\", got \"" << fields[i] << "\""; |
| + FormField expected; |
| + expected.label = labels[i]; |
| + expected.name = names[i]; |
| + expected.value = values[i]; |
| + expected.form_control_type = control_types[i]; |
| + expected.max_length = max_length; |
| + SCOPED_TRACE(StringPrintf("i: %" PRIuS, i)); |
| + ExpectFieldEquals(expected, fields[i]); |
| } |
| } |
| @@ -126,24 +141,25 @@ TEST_F(FormManagerTest, WebFormControlElementToFormField) { |
| FormManager::WebFormControlElementToFormField(element, |
| FormManager::EXTRACT_NONE, |
| &result1); |
| - EXPECT_TRUE(result1.StrictlyEqualsHack( |
| - FormField(string16(), |
| - ASCIIToUTF16("element"), |
| - string16(), |
| - ASCIIToUTF16("text"), |
| - WebInputElement::defaultMaxLength(), |
| - false))); |
| + |
| + FormField expected; |
| + expected.form_control_type = ASCIIToUTF16("text"); |
| + expected.max_length = WebInputElement::defaultMaxLength(); |
| + |
| + expected.name = ASCIIToUTF16("element"); |
| + expected.value = string16(); |
| + SCOPED_TRACE(""); |
|
dhollowa
2011/08/08 21:40:39
This is a touch magical. It is also repeated ever
Ilya Sherman
2011/08/09 00:13:43
Done.
|
| + ExpectFieldEquals(expected, result1); |
| + |
| FormField result2; |
| FormManager::WebFormControlElementToFormField(element, |
| FormManager::EXTRACT_VALUE, |
| &result2); |
| - EXPECT_TRUE(result2.StrictlyEqualsHack( |
| - FormField(string16(), |
| - ASCIIToUTF16("element"), |
| - ASCIIToUTF16("value"), |
| - ASCIIToUTF16("text"), |
| - WebInputElement::defaultMaxLength(), |
| - false))); |
| + |
| + expected.name = ASCIIToUTF16("element"); |
| + expected.value = ASCIIToUTF16("value"); |
| + SCOPED_TRACE(""); |
| + ExpectFieldEquals(expected, result2); |
| } |
| // We should be able to extract a text field with autocomplete="off". |
| @@ -160,13 +176,14 @@ TEST_F(FormManagerTest, WebFormControlElementToFormFieldAutocompleteOff) { |
| FormManager::WebFormControlElementToFormField(element, |
| FormManager::EXTRACT_VALUE, |
| &result); |
| - EXPECT_TRUE(result.StrictlyEqualsHack( |
| - FormField(string16(), |
| - ASCIIToUTF16("element"), |
| - ASCIIToUTF16("value"), |
| - ASCIIToUTF16("text"), |
| - WebInputElement::defaultMaxLength(), |
| - false))); |
| + |
| + FormField expected; |
| + expected.name = ASCIIToUTF16("element"); |
| + expected.value = ASCIIToUTF16("value"); |
| + expected.form_control_type = ASCIIToUTF16("text"); |
| + expected.max_length = WebInputElement::defaultMaxLength(); |
| + SCOPED_TRACE(""); |
| + ExpectFieldEquals(expected, result); |
| } |
| // We should be able to extract a text field with maxlength specified. |
| @@ -183,12 +200,14 @@ TEST_F(FormManagerTest, WebFormControlElementToFormFieldMaxLength) { |
| FormManager::WebFormControlElementToFormField(element, |
| FormManager::EXTRACT_VALUE, |
| &result); |
| - EXPECT_TRUE(result.StrictlyEqualsHack(FormField(string16(), |
| - ASCIIToUTF16("element"), |
| - ASCIIToUTF16("value"), |
| - ASCIIToUTF16("text"), |
| - 5, |
| - false))); |
| + |
| + FormField expected; |
| + expected.name = ASCIIToUTF16("element"); |
| + expected.value = ASCIIToUTF16("value"); |
| + expected.form_control_type = ASCIIToUTF16("text"); |
| + expected.max_length = 5; |
| + SCOPED_TRACE(""); |
| + ExpectFieldEquals(expected, result); |
| } |
| // We should be able to extract a text field that has been autofilled. |
| @@ -205,13 +224,15 @@ TEST_F(FormManagerTest, WebFormControlElementToFormFieldAutofilled) { |
| FormManager::WebFormControlElementToFormField(element, |
| FormManager::EXTRACT_VALUE, |
| &result); |
| - EXPECT_TRUE(result.StrictlyEqualsHack( |
| - FormField(string16(), |
| - ASCIIToUTF16("element"), |
| - ASCIIToUTF16("value"), |
| - ASCIIToUTF16("text"), |
| - WebInputElement::defaultMaxLength(), |
| - true))); |
| + |
| + FormField expected; |
| + expected.name = ASCIIToUTF16("element"); |
| + expected.value = ASCIIToUTF16("value"); |
| + expected.form_control_type = ASCIIToUTF16("text"); |
| + expected.max_length = WebInputElement::defaultMaxLength(); |
| + expected.is_autofilled = true; |
| + SCOPED_TRACE(""); |
| + ExpectFieldEquals(expected, result); |
| } |
| // We should be able to extract a <select> field. |
| @@ -230,34 +251,34 @@ TEST_F(FormManagerTest, WebFormControlElementToFormFieldSelect) { |
| FormManager::WebFormControlElementToFormField(element, |
| FormManager::EXTRACT_VALUE, |
| &result1); |
| - EXPECT_TRUE(result1.StrictlyEqualsHack(FormField(string16(), |
| - ASCIIToUTF16("element"), |
| - ASCIIToUTF16("CA"), |
| - ASCIIToUTF16("select-one"), |
| - 0, |
| - false))); |
| + |
| + FormField expected; |
| + expected.name = ASCIIToUTF16("element"); |
| + expected.max_length = 0; |
| + expected.form_control_type = ASCIIToUTF16("select-one"); |
| + |
| + expected.value = ASCIIToUTF16("CA"); |
| + SCOPED_TRACE(""); |
| + ExpectFieldEquals(expected, result1); |
| + |
| FormField result2; |
| FormManager::WebFormControlElementToFormField( |
| element, |
| static_cast<FormManager::ExtractMask>(FormManager::EXTRACT_VALUE | |
| FormManager::EXTRACT_OPTION_TEXT), |
| &result2); |
| - EXPECT_TRUE(result2.StrictlyEqualsHack(FormField(string16(), |
| - ASCIIToUTF16("element"), |
| - ASCIIToUTF16("California"), |
| - ASCIIToUTF16("select-one"), |
| - 0, |
| - false))); |
| + expected.value = ASCIIToUTF16("California"); |
| + SCOPED_TRACE(""); |
| + ExpectFieldEquals(expected, result2); |
| + |
| FormField result3; |
| FormManager::WebFormControlElementToFormField(element, |
| FormManager::EXTRACT_OPTIONS, |
| &result3); |
| - EXPECT_TRUE(result3.StrictlyEqualsHack(FormField(string16(), |
| - ASCIIToUTF16("element"), |
| - string16(), |
| - ASCIIToUTF16("select-one"), |
| - 0, |
| - false))); |
| + expected.value = string16(); |
| + SCOPED_TRACE(""); |
| + ExpectFieldEquals(expected, result3); |
| + |
| ASSERT_EQ(2U, result3.option_values.size()); |
| ASSERT_EQ(2U, result3.option_contents.size()); |
| EXPECT_EQ(ASCIIToUTF16("CA"), result3.option_values[0]); |
| @@ -266,7 +287,7 @@ TEST_F(FormManagerTest, WebFormControlElementToFormFieldSelect) { |
| EXPECT_EQ(ASCIIToUTF16("Texas"), result3.option_contents[1]); |
| } |
| -// We should be not extract the value for non-text and non-select fields. |
| +// We should not extract the value for non-text and non-select fields. |
| TEST_F(FormManagerTest, WebFormControlElementToFormFieldInvalidType) { |
| LoadHTML("<FORM name=\"TestForm\" action=\"http://cnn.com\" method=\"post\">" |
| " <INPUT type=\"hidden\" id=\"hidden\" value=\"apple\"/>" |
| @@ -285,60 +306,55 @@ TEST_F(FormManagerTest, WebFormControlElementToFormFieldInvalidType) { |
| FormManager::WebFormControlElementToFormField(element, |
| FormManager::EXTRACT_VALUE, |
| &result); |
| - EXPECT_TRUE(result.StrictlyEqualsHack(FormField(string16(), |
| - ASCIIToUTF16("hidden"), |
| - string16(), |
| - ASCIIToUTF16("hidden"), |
| - 0, |
| - false))); |
| + |
| + FormField expected; |
| + expected.max_length = 0; |
| + |
| + expected.name = ASCIIToUTF16("hidden"); |
| + expected.form_control_type = ASCIIToUTF16("hidden"); |
| + SCOPED_TRACE(""); |
| + ExpectFieldEquals(expected, result); |
| web_element = frame->document().getElementById("password"); |
| element = web_element.to<WebFormControlElement>(); |
| FormManager::WebFormControlElementToFormField(element, |
| FormManager::EXTRACT_VALUE, |
| &result); |
| - EXPECT_TRUE(result.StrictlyEqualsHack(FormField(string16(), |
| - ASCIIToUTF16("password"), |
| - string16(), |
| - ASCIIToUTF16("password"), |
| - 0, |
| - false))); |
| + expected.name = ASCIIToUTF16("password"); |
| + expected.form_control_type = ASCIIToUTF16("password"); |
| + SCOPED_TRACE(""); |
| + ExpectFieldEquals(expected, result); |
| web_element = frame->document().getElementById("checkbox"); |
| element = web_element.to<WebFormControlElement>(); |
| FormManager::WebFormControlElementToFormField(element, |
| FormManager::EXTRACT_VALUE, |
| &result); |
| - EXPECT_TRUE(result.StrictlyEqualsHack(FormField(string16(), |
| - ASCIIToUTF16("checkbox"), |
| - string16(), |
| - ASCIIToUTF16("checkbox"), |
| - 0, |
| - false))); |
| + expected.name = ASCIIToUTF16("checkbox"); |
| + expected.form_control_type = ASCIIToUTF16("checkbox"); |
| + SCOPED_TRACE(""); |
| + ExpectFieldEquals(expected, result); |
| web_element = frame->document().getElementById("radio"); |
| element = web_element.to<WebFormControlElement>(); |
| FormManager::WebFormControlElementToFormField(element, |
| FormManager::EXTRACT_VALUE, |
| &result); |
| - EXPECT_TRUE(result.StrictlyEqualsHack(FormField(string16(), |
| - ASCIIToUTF16("radio"), |
| - string16(), |
| - ASCIIToUTF16("radio"), |
| - 0, |
| - false))); |
| + expected.name = ASCIIToUTF16("radio"); |
| + expected.form_control_type = ASCIIToUTF16("radio"); |
| + SCOPED_TRACE(""); |
| + ExpectFieldEquals(expected, result); |
| + |
| web_element = frame->document().getElementById("submit"); |
| element = web_element.to<WebFormControlElement>(); |
| FormManager::WebFormControlElementToFormField(element, |
| FormManager::EXTRACT_VALUE, |
| &result); |
| - EXPECT_TRUE(result.StrictlyEqualsHack(FormField(string16(), |
| - ASCIIToUTF16("submit"), |
| - string16(), |
| - ASCIIToUTF16("submit"), |
| - 0, |
| - false))); |
| + expected.name = ASCIIToUTF16("submit"); |
| + expected.form_control_type = ASCIIToUTF16("submit"); |
| + SCOPED_TRACE(""); |
| + ExpectFieldEquals(expected, result); |
| } |
| TEST_F(FormManagerTest, WebFormElementToFormData) { |
| @@ -373,27 +389,28 @@ TEST_F(FormManagerTest, WebFormElementToFormData) { |
| const std::vector<FormField>& fields = form.fields; |
| ASSERT_EQ(3U, fields.size()); |
| - EXPECT_TRUE(fields[0].StrictlyEqualsHack( |
| - FormField(string16(), |
| - ASCIIToUTF16("firstname"), |
| - ASCIIToUTF16("John"), |
| - ASCIIToUTF16("text"), |
| - WebInputElement::defaultMaxLength(), |
| - false))); |
| - EXPECT_TRUE(fields[1].StrictlyEqualsHack( |
| - FormField(string16(), |
| - ASCIIToUTF16("lastname"), |
| - ASCIIToUTF16("Smith"), |
| - ASCIIToUTF16("text"), |
| - WebInputElement::defaultMaxLength(), |
| - false))); |
| - EXPECT_TRUE(fields[2].StrictlyEqualsHack( |
| - FormField(string16(), |
| - ASCIIToUTF16("state"), |
| - ASCIIToUTF16("CA"), |
| - ASCIIToUTF16("select-one"), |
| - 0, |
| - false))); |
| + |
| + FormField expected; |
| + expected.name = ASCIIToUTF16("firstname"); |
| + expected.value = ASCIIToUTF16("John"); |
| + expected.form_control_type = ASCIIToUTF16("text"); |
| + expected.max_length = WebInputElement::defaultMaxLength(); |
| + SCOPED_TRACE(""); |
| + ExpectFieldEquals(expected, fields[0]); |
| + |
| + expected.name = ASCIIToUTF16("lastname"); |
| + expected.value = ASCIIToUTF16("Smith"); |
| + expected.form_control_type = ASCIIToUTF16("text"); |
| + expected.max_length = WebInputElement::defaultMaxLength(); |
| + SCOPED_TRACE(""); |
| + ExpectFieldEquals(expected, fields[1]); |
| + |
| + expected.name = ASCIIToUTF16("state"); |
| + expected.value = ASCIIToUTF16("CA"); |
| + expected.form_control_type = ASCIIToUTF16("select-one"); |
| + expected.max_length = 0; |
| + SCOPED_TRACE(""); |
| + ExpectFieldEquals(expected, fields[2]); |
| } |
| TEST_F(FormManagerTest, ExtractForms) { |
| @@ -436,27 +453,25 @@ TEST_F(FormManagerTest, ExtractMultipleForms) { |
| const std::vector<FormField>& fields = form.fields; |
| ASSERT_EQ(3U, fields.size()); |
| - EXPECT_EQ(FormField(string16(), |
| - ASCIIToUTF16("firstname"), |
| - ASCIIToUTF16("John"), |
| - ASCIIToUTF16("text"), |
| - WebInputElement::defaultMaxLength(), |
| - false), |
| - fields[0]); |
| - EXPECT_EQ(FormField(string16(), |
| - ASCIIToUTF16("lastname"), |
| - ASCIIToUTF16("Smith"), |
| - ASCIIToUTF16("text"), |
| - WebInputElement::defaultMaxLength(), |
| - false), |
| - fields[1]); |
| - EXPECT_EQ(FormField(string16(), |
| - ASCIIToUTF16("email"), |
| - ASCIIToUTF16("john@example.com"), |
| - ASCIIToUTF16("text"), |
| - WebInputElement::defaultMaxLength(), |
| - false), |
| - fields[2]); |
| + |
| + FormField expected; |
| + expected.form_control_type = ASCIIToUTF16("text"); |
| + expected.max_length = WebInputElement::defaultMaxLength(); |
| + |
| + expected.name = ASCIIToUTF16("firstname"); |
| + expected.value = ASCIIToUTF16("John"); |
| + SCOPED_TRACE(""); |
| + ExpectFieldEquals(expected, fields[0]); |
| + |
| + expected.name = ASCIIToUTF16("lastname"); |
| + expected.value = ASCIIToUTF16("Smith"); |
| + SCOPED_TRACE(""); |
| + ExpectFieldEquals(expected, fields[1]); |
| + |
| + expected.name = ASCIIToUTF16("email"); |
| + expected.value = ASCIIToUTF16("john@example.com"); |
| + SCOPED_TRACE(""); |
| + ExpectFieldEquals(expected, fields[2]); |
| // Second form. |
| const FormData& form2 = forms[1]; |
| @@ -466,27 +481,21 @@ TEST_F(FormManagerTest, ExtractMultipleForms) { |
| const std::vector<FormField>& fields2 = form2.fields; |
| ASSERT_EQ(3U, fields2.size()); |
| - EXPECT_EQ(FormField(string16(), |
| - ASCIIToUTF16("firstname"), |
| - ASCIIToUTF16("Jack"), |
| - ASCIIToUTF16("text"), |
| - WebInputElement::defaultMaxLength(), |
| - false), |
| - fields2[0]); |
| - EXPECT_EQ(FormField(string16(), |
| - ASCIIToUTF16("lastname"), |
| - ASCIIToUTF16("Adams"), |
| - ASCIIToUTF16("text"), |
| - WebInputElement::defaultMaxLength(), |
| - false), |
| - fields2[1]); |
| - EXPECT_EQ(FormField(string16(), |
| - ASCIIToUTF16("email"), |
| - ASCIIToUTF16("jack@example.com"), |
| - ASCIIToUTF16("text"), |
| - WebInputElement::defaultMaxLength(), |
| - false), |
| - fields[2]); |
| + |
| + expected.name = ASCIIToUTF16("firstname"); |
| + expected.value = ASCIIToUTF16("Jack"); |
| + SCOPED_TRACE(""); |
| + ExpectFieldEquals(expected, fields2[0]); |
| + |
| + expected.name = ASCIIToUTF16("lastname"); |
| + expected.value = ASCIIToUTF16("Adams"); |
| + SCOPED_TRACE(""); |
| + ExpectFieldEquals(expected, fields2[1]); |
| + |
| + expected.name = ASCIIToUTF16("email"); |
| + expected.value = ASCIIToUTF16("jack@example.com"); |
| + SCOPED_TRACE(""); |
| + ExpectFieldEquals(expected, fields2[2]); |
| } |
| // We should not extract a form if it has too few fillable fields. |
| @@ -555,7 +564,7 @@ TEST_F(FormManagerTest, WebFormElementToFormDataAutocomplete) { |
| FormData form; |
| EXPECT_TRUE(FormManager::WebFormElementToFormData( |
| - web_form, FormManager::REQUIRE_AUTOCOMPLETE, FormManager::EXTRACT_NONE, |
| + web_form, FormManager::REQUIRE_AUTOCOMPLETE, FormManager::EXTRACT_VALUE, |
| &form)); |
| EXPECT_EQ(ASCIIToUTF16("TestForm"), form.name); |
| @@ -564,27 +573,25 @@ TEST_F(FormManagerTest, WebFormElementToFormDataAutocomplete) { |
| const std::vector<FormField>& fields = form.fields; |
| ASSERT_EQ(3U, fields.size()); |
| - EXPECT_EQ(FormField(string16(), |
| - ASCIIToUTF16("middlename"), |
| - ASCIIToUTF16("Jack"), |
| - ASCIIToUTF16("text"), |
| - WebInputElement::defaultMaxLength(), |
| - false), |
| - fields[0]); |
| - EXPECT_EQ(FormField(string16(), |
| - ASCIIToUTF16("lastname"), |
| - ASCIIToUTF16("Smith"), |
| - ASCIIToUTF16("text"), |
| - WebInputElement::defaultMaxLength(), |
| - false), |
| - fields[1]); |
| - EXPECT_EQ(FormField(string16(), |
| - ASCIIToUTF16("email"), |
| - ASCIIToUTF16("john@example.com"), |
| - ASCIIToUTF16("text"), |
| - WebInputElement::defaultMaxLength(), |
| - false), |
| - fields[2]); |
| + |
| + FormField expected; |
| + expected.form_control_type = ASCIIToUTF16("text"); |
| + expected.max_length = WebInputElement::defaultMaxLength(); |
| + |
| + expected.name = ASCIIToUTF16("middlename"); |
| + expected.value = ASCIIToUTF16("Jack"); |
| + SCOPED_TRACE(""); |
| + ExpectFieldEquals(expected, fields[0]); |
| + |
| + expected.name = ASCIIToUTF16("lastname"); |
| + expected.value = ASCIIToUTF16("Smith"); |
| + SCOPED_TRACE(""); |
| + ExpectFieldEquals(expected, fields[1]); |
| + |
| + expected.name = ASCIIToUTF16("email"); |
| + expected.value = ASCIIToUTF16("john@example.com"); |
| + SCOPED_TRACE(""); |
| + ExpectFieldEquals(expected, fields[2]); |
| } |
| } |
| @@ -608,7 +615,7 @@ TEST_F(FormManagerTest, WebFormElementToFormDataEnabled) { |
| FormData form; |
| EXPECT_TRUE(FormManager::WebFormElementToFormData( |
| - web_form, FormManager::REQUIRE_ENABLED, FormManager::EXTRACT_NONE, |
| + web_form, FormManager::REQUIRE_ENABLED, FormManager::EXTRACT_VALUE, |
| &form)); |
| EXPECT_EQ(ASCIIToUTF16("TestForm"), form.name); |
| @@ -617,27 +624,25 @@ TEST_F(FormManagerTest, WebFormElementToFormDataEnabled) { |
| const std::vector<FormField>& fields = form.fields; |
| ASSERT_EQ(3U, fields.size()); |
| - EXPECT_EQ(FormField(string16(), |
| - ASCIIToUTF16("middlename"), |
| - ASCIIToUTF16("Jack"), |
| - ASCIIToUTF16("text"), |
| - WebInputElement::defaultMaxLength(), |
| - false), |
| - fields[0]); |
| - EXPECT_EQ(FormField(string16(), |
| - ASCIIToUTF16("lastname"), |
| - ASCIIToUTF16("Smith"), |
| - ASCIIToUTF16("text"), |
| - WebInputElement::defaultMaxLength(), |
| - false), |
| - fields[1]); |
| - EXPECT_EQ(FormField(string16(), |
| - ASCIIToUTF16("email"), |
| - ASCIIToUTF16("jack@example.com"), |
| - ASCIIToUTF16("text"), |
| - WebInputElement::defaultMaxLength(), |
| - false), |
| - fields[2]); |
| + |
| + FormField expected; |
| + expected.form_control_type = ASCIIToUTF16("text"); |
| + expected.max_length = WebInputElement::defaultMaxLength(); |
| + |
| + expected.name = ASCIIToUTF16("middlename"); |
| + expected.value = ASCIIToUTF16("Jack"); |
| + SCOPED_TRACE(""); |
| + ExpectFieldEquals(expected, fields[0]); |
| + |
| + expected.name = ASCIIToUTF16("lastname"); |
| + expected.value = ASCIIToUTF16("Smith"); |
| + SCOPED_TRACE(""); |
| + ExpectFieldEquals(expected, fields[1]); |
| + |
| + expected.name = ASCIIToUTF16("email"); |
| + expected.value = ASCIIToUTF16("jack@example.com"); |
| + SCOPED_TRACE(""); |
| + ExpectFieldEquals(expected, fields[2]); |
| } |
| TEST_F(FormManagerTest, FindForm) { |
| @@ -670,27 +675,25 @@ TEST_F(FormManagerTest, FindForm) { |
| const std::vector<FormField>& fields = form.fields; |
| ASSERT_EQ(3U, fields.size()); |
| - EXPECT_EQ(FormField(string16(), |
| - ASCIIToUTF16("firstname"), |
| - ASCIIToUTF16("John"), |
| - ASCIIToUTF16("text"), |
| - WebInputElement::defaultMaxLength(), |
| - false), |
| - fields[0]); |
| - EXPECT_EQ(FormField(string16(), |
| - ASCIIToUTF16("lastname"), |
| - ASCIIToUTF16("Smith"), |
| - ASCIIToUTF16("text"), |
| - WebInputElement::defaultMaxLength(), |
| - false), |
| - fields[1]); |
| - EXPECT_EQ(FormField(string16(), |
| - ASCIIToUTF16("email"), |
| - ASCIIToUTF16("john@example.com"), |
| - ASCIIToUTF16("text"), |
| - WebInputElement::defaultMaxLength(), |
| - false), |
| - fields[2]); |
| + |
| + FormField expected; |
| + expected.form_control_type = ASCIIToUTF16("text"); |
| + expected.max_length = WebInputElement::defaultMaxLength(); |
| + |
| + expected.name = ASCIIToUTF16("firstname"); |
| + expected.value = ASCIIToUTF16("John"); |
| + SCOPED_TRACE(""); |
| + ExpectFieldEquals(expected, fields[0]); |
| + |
| + expected.name = ASCIIToUTF16("lastname"); |
| + expected.value = ASCIIToUTF16("Smith"); |
| + SCOPED_TRACE(""); |
| + ExpectFieldEquals(expected, fields[1]); |
| + |
| + expected.name = ASCIIToUTF16("email"); |
| + expected.value = ASCIIToUTF16("john@example.com"); |
| + SCOPED_TRACE(""); |
| + ExpectFieldEquals(expected, fields[2]); |
| } |
| TEST_F(FormManagerTest, FillForm) { |
| @@ -730,62 +733,50 @@ TEST_F(FormManagerTest, FillForm) { |
| const std::vector<FormField>& fields = form.fields; |
| ASSERT_EQ(8U, fields.size()); |
| - EXPECT_EQ(FormField(string16(), |
| - ASCIIToUTF16("firstname"), |
| - string16(), |
| - ASCIIToUTF16("text"), |
| - WebInputElement::defaultMaxLength(), |
| - false), |
| - fields[0]); |
| - EXPECT_EQ(FormField(string16(), |
| - ASCIIToUTF16("lastname"), |
| - string16(), |
| - ASCIIToUTF16("text"), |
| - WebInputElement::defaultMaxLength(), |
| - false), |
| - fields[1]); |
| - EXPECT_EQ(FormField(string16(), |
| - ASCIIToUTF16("notempty"), |
| - ASCIIToUTF16("Hi"), |
| - ASCIIToUTF16("text"), |
| - WebInputElement::defaultMaxLength(), |
| - false), |
| - fields[2]); |
| - EXPECT_EQ(FormField(string16(), |
| - ASCIIToUTF16("noautocomplete"), |
| - string16(), |
| - ASCIIToUTF16("text"), |
| - WebInputElement::defaultMaxLength(), |
| - false), |
| - fields[3]); |
| - EXPECT_EQ(FormField(string16(), |
| - ASCIIToUTF16("notenabled"), |
| - string16(), |
| - ASCIIToUTF16("text"), |
| - WebInputElement::defaultMaxLength(), |
| - false), |
| - fields[4]); |
| - EXPECT_EQ(FormField(string16(), |
| - ASCIIToUTF16("readonly"), |
| - string16(), |
| - ASCIIToUTF16("text"), |
| - WebInputElement::defaultMaxLength(), |
| - false), |
| - fields[5]); |
| - EXPECT_EQ(FormField(string16(), |
| - ASCIIToUTF16("invisible"), |
| - string16(), |
| - ASCIIToUTF16("text"), |
| - WebInputElement::defaultMaxLength(), |
| - false), |
| - fields[6]); |
| - EXPECT_EQ(FormField(string16(), |
| - ASCIIToUTF16("displaynone"), |
| - string16(), |
| - ASCIIToUTF16("text"), |
| - WebInputElement::defaultMaxLength(), |
| - false), |
| - fields[7]); |
| + |
| + FormField expected; |
| + expected.form_control_type = ASCIIToUTF16("text"); |
| + expected.max_length = WebInputElement::defaultMaxLength(); |
| + |
| + expected.name = ASCIIToUTF16("firstname"); |
| + expected.value = string16(); |
| + SCOPED_TRACE(""); |
| + ExpectFieldEquals(expected, fields[0]); |
| + |
| + expected.name = ASCIIToUTF16("lastname"); |
| + expected.value = string16(); |
| + SCOPED_TRACE(""); |
| + ExpectFieldEquals(expected, fields[1]); |
| + |
| + expected.name = ASCIIToUTF16("notempty"); |
| + expected.value = ASCIIToUTF16("Hi"); |
| + SCOPED_TRACE(""); |
| + ExpectFieldEquals(expected, fields[2]); |
| + |
| + expected.name = ASCIIToUTF16("noautocomplete"); |
| + expected.value = string16(); |
| + SCOPED_TRACE(""); |
| + ExpectFieldEquals(expected, fields[3]); |
| + |
| + expected.name = ASCIIToUTF16("notenabled"); |
| + expected.value = string16(); |
| + SCOPED_TRACE(""); |
| + ExpectFieldEquals(expected, fields[4]); |
| + |
| + expected.name = ASCIIToUTF16("readonly"); |
| + expected.value = string16(); |
| + SCOPED_TRACE(""); |
| + ExpectFieldEquals(expected, fields[5]); |
| + |
| + expected.name = ASCIIToUTF16("invisible"); |
| + expected.value = string16(); |
| + SCOPED_TRACE(""); |
| + ExpectFieldEquals(expected, fields[6]); |
| + |
| + expected.name = ASCIIToUTF16("displaynone"); |
| + expected.value = string16(); |
| + SCOPED_TRACE(""); |
| + ExpectFieldEquals(expected, fields[7]); |
| // Fill the form. |
| form.fields[0].value = ASCIIToUTF16("Wyatt"); |
| @@ -881,41 +872,35 @@ TEST_F(FormManagerTest, PreviewForm) { |
| const std::vector<FormField>& fields = form.fields; |
| ASSERT_EQ(5U, fields.size()); |
| - EXPECT_EQ(FormField(string16(), |
| - ASCIIToUTF16("firstname"), |
| - string16(), |
| - ASCIIToUTF16("text"), |
| - WebInputElement::defaultMaxLength(), |
| - false), |
| - fields[0]); |
| - EXPECT_EQ(FormField(string16(), |
| - ASCIIToUTF16("lastname"), |
| - string16(), |
| - ASCIIToUTF16("text"), |
| - WebInputElement::defaultMaxLength(), |
| - false), |
| - fields[1]); |
| - EXPECT_EQ(FormField(string16(), |
| - ASCIIToUTF16("notempty"), |
| - ASCIIToUTF16("Hi"), |
| - ASCIIToUTF16("text"), |
| - WebInputElement::defaultMaxLength(), |
| - false), |
| - fields[2]); |
| - EXPECT_EQ(FormField(string16(), |
| - ASCIIToUTF16("noautocomplete"), |
| - string16(), |
| - ASCIIToUTF16("text"), |
| - WebInputElement::defaultMaxLength(), |
| - false), |
| - fields[3]); |
| - EXPECT_EQ(FormField(string16(), |
| - ASCIIToUTF16("notenabled"), |
| - string16(), |
| - ASCIIToUTF16("text"), |
| - WebInputElement::defaultMaxLength(), |
| - false), |
| - fields[4]); |
| + |
| + FormField expected; |
| + expected.form_control_type = ASCIIToUTF16("text"); |
| + expected.max_length = WebInputElement::defaultMaxLength(); |
| + |
| + expected.name = ASCIIToUTF16("firstname"); |
| + expected.value = string16(); |
| + SCOPED_TRACE(""); |
| + ExpectFieldEquals(expected, fields[0]); |
| + |
| + expected.name = ASCIIToUTF16("lastname"); |
| + expected.value = string16(); |
| + SCOPED_TRACE(""); |
| + ExpectFieldEquals(expected, fields[1]); |
| + |
| + expected.name = ASCIIToUTF16("notempty"); |
| + expected.value = ASCIIToUTF16("Hi"); |
| + SCOPED_TRACE(""); |
| + ExpectFieldEquals(expected, fields[2]); |
| + |
| + expected.name = ASCIIToUTF16("noautocomplete"); |
| + expected.value = string16(); |
| + SCOPED_TRACE(""); |
| + ExpectFieldEquals(expected, fields[3]); |
| + |
| + expected.name = ASCIIToUTF16("notenabled"); |
| + expected.value = string16(); |
| + SCOPED_TRACE(""); |
| + ExpectFieldEquals(expected, fields[4]); |
| // Preview the form. |
| form.fields[0].value = ASCIIToUTF16("Wyatt"); |
| @@ -1123,6 +1108,7 @@ TEST_F(FormManagerTest, LabelsInferredFromTableCellTH) { |
| "</TABLE>" |
| "</FORM>"); |
| } |
| + |
| TEST_F(FormManagerTest, LabelsInferredFromTableCellNested) { |
| std::vector<string16> labels, names, values; |
| @@ -1846,27 +1832,27 @@ TEST_F(FormManagerTest, FillFormMaxLength) { |
| const std::vector<FormField>& fields = form.fields; |
| ASSERT_EQ(3U, fields.size()); |
| - EXPECT_EQ(FormField(string16(), |
| - ASCIIToUTF16("firstname"), |
| - string16(), |
| - ASCIIToUTF16("text"), |
| - 5, |
| - false), |
| - fields[0]); |
| - EXPECT_EQ(FormField(string16(), |
| - ASCIIToUTF16("lastname"), |
| - string16(), |
| - ASCIIToUTF16("text"), |
| - 7, |
| - false), |
| - fields[1]); |
| - EXPECT_EQ(FormField(string16(), |
| - ASCIIToUTF16("email"), |
| - string16(), |
| - ASCIIToUTF16("text"), |
| - 9, |
| - false), |
| - fields[2]); |
| + |
| + FormField expected; |
| + expected.form_control_type = ASCIIToUTF16("text"); |
| + |
| + expected.name = ASCIIToUTF16("firstname"); |
| + expected.max_length = 5; |
| + expected.is_autofilled = false; |
| + SCOPED_TRACE(""); |
| + ExpectFieldEquals(expected, fields[0]); |
| + |
| + expected.name = ASCIIToUTF16("lastname"); |
| + expected.max_length = 7; |
| + expected.is_autofilled = false; |
| + SCOPED_TRACE(""); |
| + ExpectFieldEquals(expected, fields[1]); |
| + |
| + expected.name = ASCIIToUTF16("email"); |
| + expected.max_length = 9; |
| + expected.is_autofilled = false; |
| + SCOPED_TRACE(""); |
| + ExpectFieldEquals(expected, fields[2]); |
| // Fill the form. |
| form.fields[0].value = ASCIIToUTF16("Brother"); |
| @@ -1884,24 +1870,29 @@ TEST_F(FormManagerTest, FillFormMaxLength) { |
| const std::vector<FormField>& fields2 = form2.fields; |
| ASSERT_EQ(3U, fields2.size()); |
| - EXPECT_TRUE(fields2[0].StrictlyEqualsHack(FormField(string16(), |
| - ASCIIToUTF16("firstname"), |
| - ASCIIToUTF16("Broth"), |
| - ASCIIToUTF16("text"), |
| - 5, |
| - false))); |
| - EXPECT_TRUE(fields2[1].StrictlyEqualsHack(FormField(string16(), |
| - ASCIIToUTF16("lastname"), |
| - ASCIIToUTF16("Jonatha"), |
| - ASCIIToUTF16("text"), |
| - 7, |
| - false))); |
| - EXPECT_TRUE(fields2[2].StrictlyEqualsHack(FormField(string16(), |
| - ASCIIToUTF16("email"), |
| - ASCIIToUTF16("brotherj@"), |
| - ASCIIToUTF16("text"), |
| - 9, |
| - false))); |
| + |
| + expected.form_control_type = ASCIIToUTF16("text"); |
| + |
| + expected.name = ASCIIToUTF16("firstname"); |
| + expected.value = ASCIIToUTF16("Broth"); |
| + expected.max_length = 5; |
| + expected.is_autofilled = true; |
| + SCOPED_TRACE(""); |
| + ExpectFieldEquals(expected, fields2[0]); |
| + |
| + expected.name = ASCIIToUTF16("lastname"); |
| + expected.value = ASCIIToUTF16("Jonatha"); |
| + expected.max_length = 7; |
| + expected.is_autofilled = true; |
| + SCOPED_TRACE(""); |
| + ExpectFieldEquals(expected, fields2[1]); |
| + |
| + expected.name = ASCIIToUTF16("email"); |
| + expected.value = ASCIIToUTF16("brotherj@"); |
| + expected.max_length = 9; |
| + expected.is_autofilled = true; |
| + SCOPED_TRACE(""); |
| + ExpectFieldEquals(expected, fields2[2]); |
| } |
| // This test uses negative values of the maxlength attribute for input elements. |
| @@ -1937,27 +1928,22 @@ TEST_F(FormManagerTest, FillFormNegativeMaxLength) { |
| const std::vector<FormField>& fields = form.fields; |
| ASSERT_EQ(3U, fields.size()); |
| - EXPECT_EQ(FormField(string16(), |
| - ASCIIToUTF16("firstname"), |
| - string16(), |
| - ASCIIToUTF16("text"), |
| - WebInputElement::defaultMaxLength(), |
| - false), |
| - fields[0]); |
| - EXPECT_EQ(FormField(string16(), |
| - ASCIIToUTF16("lastname"), |
| - string16(), |
| - ASCIIToUTF16("text"), |
| - WebInputElement::defaultMaxLength(), |
| - false), |
| - fields[1]); |
| - EXPECT_EQ(FormField(string16(), |
| - ASCIIToUTF16("email"), |
| - string16(), |
| - ASCIIToUTF16("text"), |
| - WebInputElement::defaultMaxLength(), |
| - false), |
| - fields[2]); |
| + |
| + FormField expected; |
| + expected.form_control_type = ASCIIToUTF16("text"); |
| + expected.max_length = WebInputElement::defaultMaxLength(); |
| + |
| + expected.name = ASCIIToUTF16("firstname"); |
| + SCOPED_TRACE(""); |
| + ExpectFieldEquals(expected, fields[0]); |
| + |
| + expected.name = ASCIIToUTF16("lastname"); |
| + SCOPED_TRACE(""); |
| + ExpectFieldEquals(expected, fields[1]); |
| + |
| + expected.name = ASCIIToUTF16("email"); |
| + SCOPED_TRACE(""); |
| + ExpectFieldEquals(expected, fields[2]); |
| // Fill the form. |
| form.fields[0].value = ASCIIToUTF16("Brother"); |
| @@ -1975,27 +1961,21 @@ TEST_F(FormManagerTest, FillFormNegativeMaxLength) { |
| const std::vector<FormField>& fields2 = form2.fields; |
| ASSERT_EQ(3U, fields2.size()); |
| - EXPECT_TRUE(fields2[0].StrictlyEqualsHack( |
| - FormField(string16(), |
| - ASCIIToUTF16("firstname"), |
| - ASCIIToUTF16("Brother"), |
| - ASCIIToUTF16("text"), |
| - WebInputElement::defaultMaxLength(), |
| - false))); |
| - EXPECT_TRUE(fields2[1].StrictlyEqualsHack( |
| - FormField(string16(), |
| - ASCIIToUTF16("lastname"), |
| - ASCIIToUTF16("Jonathan"), |
| - ASCIIToUTF16("text"), |
| - WebInputElement::defaultMaxLength(), |
| - false))); |
| - EXPECT_TRUE(fields2[2].StrictlyEqualsHack( |
| - FormField(string16(), |
| - ASCIIToUTF16("email"), |
| - ASCIIToUTF16("brotherj@example.com"), |
| - ASCIIToUTF16("text"), |
| - WebInputElement::defaultMaxLength(), |
| - false))); |
| + |
| + expected.name = ASCIIToUTF16("firstname"); |
| + expected.value = ASCIIToUTF16("Brother"); |
| + SCOPED_TRACE(""); |
| + ExpectFieldEquals(expected, fields[0]); |
| + |
| + expected.name = ASCIIToUTF16("lastname"); |
| + expected.value = ASCIIToUTF16("Jonathan"); |
| + SCOPED_TRACE(""); |
| + ExpectFieldEquals(expected, fields[1]); |
| + |
| + expected.name = ASCIIToUTF16("email"); |
| + expected.value = ASCIIToUTF16("brotherj@example.com"); |
| + SCOPED_TRACE(""); |
| + ExpectFieldEquals(expected, fields[2]); |
| } |
| // This test sends a FormData object to FillForm with more fields than are in |
| @@ -2027,36 +2007,28 @@ TEST_F(FormManagerTest, FillFormMoreFormDataFields) { |
| // postfix |
| FormData* form = &forms[0]; |
| - FormField field1(string16(), |
| - ASCIIToUTF16("prefix"), |
| - string16(), |
| - ASCIIToUTF16("text"), |
| - WebInputElement::defaultMaxLength(), |
| - false); |
| + FormField field1; |
| + field1.name = ASCIIToUTF16("prefix"); |
| + field1.form_control_type = ASCIIToUTF16("text"); |
| + field1.max_length = WebInputElement::defaultMaxLength(); |
| form->fields.insert(form->fields.begin(), field1); |
| - FormField field2(string16(), |
| - ASCIIToUTF16("hidden"), |
| - string16(), |
| - ASCIIToUTF16("text"), |
| - WebInputElement::defaultMaxLength(), |
| - false); |
| + FormField field2; |
| + field2.name = ASCIIToUTF16("hidden"); |
| + field2.form_control_type = ASCIIToUTF16("text"); |
| + field2.max_length = WebInputElement::defaultMaxLength(); |
| form->fields.insert(form->fields.begin() + 2, field2); |
| - FormField field3(string16(), |
| - ASCIIToUTF16("second"), |
| - string16(), |
| - ASCIIToUTF16("text"), |
| - WebInputElement::defaultMaxLength(), |
| - false); |
| + FormField field3; |
| + field3.name = ASCIIToUTF16("second"); |
| + field3.form_control_type = ASCIIToUTF16("text"); |
| + field3.max_length = WebInputElement::defaultMaxLength(); |
| form->fields.insert(form->fields.begin() + 4, field3); |
| - FormField field4(string16(), |
| - ASCIIToUTF16("postfix"), |
| - string16(), |
| - ASCIIToUTF16("text"), |
| - WebInputElement::defaultMaxLength(), |
| - false); |
| + FormField field4; |
| + field4.name = ASCIIToUTF16("postfix"); |
| + field4.form_control_type = ASCIIToUTF16("text"); |
| + field4.max_length = WebInputElement::defaultMaxLength(); |
| form->fields.insert(form->fields.begin() + 6, field4); |
| // Fill the form. |
| @@ -2083,27 +2055,26 @@ TEST_F(FormManagerTest, FillFormMoreFormDataFields) { |
| const std::vector<FormField>& fields = form2.fields; |
| ASSERT_EQ(3U, fields.size()); |
| - EXPECT_TRUE(fields[0].StrictlyEqualsHack( |
| - FormField(string16(), |
| - ASCIIToUTF16("firstname"), |
| - ASCIIToUTF16("Brother"), |
| - ASCIIToUTF16("text"), |
| - WebInputElement::defaultMaxLength(), |
| - false))); |
| - EXPECT_TRUE(fields[1].StrictlyEqualsHack( |
| - FormField(string16(), |
| - ASCIIToUTF16("middlename"), |
| - ASCIIToUTF16("Joseph"), |
| - ASCIIToUTF16("text"), |
| - WebInputElement::defaultMaxLength(), |
| - false))); |
| - EXPECT_TRUE(fields[2].StrictlyEqualsHack( |
| - FormField(string16(), |
| - ASCIIToUTF16("lastname"), |
| - ASCIIToUTF16("Jonathan"), |
| - ASCIIToUTF16("text"), |
| - WebInputElement::defaultMaxLength(), |
| - false))); |
| + |
| + FormField expected; |
| + expected.form_control_type = ASCIIToUTF16("text"); |
| + expected.max_length = WebInputElement::defaultMaxLength(); |
| + expected.is_autofilled = true; |
| + |
| + expected.name = ASCIIToUTF16("firstname"); |
| + expected.value = ASCIIToUTF16("Brother"); |
| + SCOPED_TRACE(""); |
| + ExpectFieldEquals(expected, fields[0]); |
| + |
| + expected.name = ASCIIToUTF16("middlename"); |
| + expected.value = ASCIIToUTF16("Joseph"); |
| + SCOPED_TRACE(""); |
| + ExpectFieldEquals(expected, fields[1]); |
| + |
| + expected.name = ASCIIToUTF16("lastname"); |
| + expected.value = ASCIIToUTF16("Jonathan"); |
| + SCOPED_TRACE(""); |
| + ExpectFieldEquals(expected, fields[2]); |
| } |
| // This test sends a FormData object to FillForm with fewer fields than are in |
| @@ -2159,55 +2130,52 @@ TEST_F(FormManagerTest, FillFormFewerFormDataFields) { |
| const std::vector<FormField>& fields = form2.fields; |
| ASSERT_EQ(7U, fields.size()); |
| - EXPECT_TRUE(fields[0].StrictlyEqualsHack( |
| - FormField(string16(), |
| - ASCIIToUTF16("prefix"), |
| - string16(), |
| - ASCIIToUTF16("text"), |
| - WebInputElement::defaultMaxLength(), |
| - false))); |
| - EXPECT_TRUE(fields[1].StrictlyEqualsHack( |
| - FormField(string16(), |
| - ASCIIToUTF16("firstname"), |
| - ASCIIToUTF16("Brother"), |
| - ASCIIToUTF16("text"), |
| - WebInputElement::defaultMaxLength(), |
| - false))); |
| - EXPECT_TRUE(fields[2].StrictlyEqualsHack( |
| - FormField(string16(), |
| - ASCIIToUTF16("hidden"), |
| - string16(), |
| - ASCIIToUTF16("text"), |
| - WebInputElement::defaultMaxLength(), |
| - false))); |
| - EXPECT_TRUE(fields[3].StrictlyEqualsHack( |
| - FormField(string16(), |
| - ASCIIToUTF16("middlename"), |
| - ASCIIToUTF16("Joseph"), |
| - ASCIIToUTF16("text"), |
| - WebInputElement::defaultMaxLength(), |
| - false))); |
| - EXPECT_TRUE(fields[4].StrictlyEqualsHack( |
| - FormField(string16(), |
| - ASCIIToUTF16("second"), |
| - string16(), |
| - ASCIIToUTF16("text"), |
| - WebInputElement::defaultMaxLength(), |
| - false))); |
| - EXPECT_TRUE(fields[5].StrictlyEqualsHack( |
| - FormField(string16(), |
| - ASCIIToUTF16("lastname"), |
| - ASCIIToUTF16("Jonathan"), |
| - ASCIIToUTF16("text"), |
| - WebInputElement::defaultMaxLength(), |
| - false))); |
| - EXPECT_TRUE(fields[6].StrictlyEqualsHack( |
| - FormField(string16(), |
| - ASCIIToUTF16("postfix"), |
| - string16(), |
| - ASCIIToUTF16("text"), |
| - WebInputElement::defaultMaxLength(), |
| - false))); |
| + |
| + FormField expected; |
| + expected.form_control_type = ASCIIToUTF16("text"); |
| + expected.max_length = WebInputElement::defaultMaxLength(); |
| + |
| + expected.name = ASCIIToUTF16("prefix"); |
| + expected.value = string16(); |
| + expected.is_autofilled = false; |
| + SCOPED_TRACE(""); |
| + ExpectFieldEquals(expected, fields[0]); |
| + |
| + expected.name = ASCIIToUTF16("firstname"); |
| + expected.value = ASCIIToUTF16("Brother"); |
| + expected.is_autofilled = true; |
| + SCOPED_TRACE(""); |
| + ExpectFieldEquals(expected, fields[1]); |
| + |
| + expected.name = ASCIIToUTF16("hidden"); |
| + expected.value = string16(); |
| + expected.is_autofilled = false; |
| + SCOPED_TRACE(""); |
| + ExpectFieldEquals(expected, fields[2]); |
| + |
| + expected.name = ASCIIToUTF16("middlename"); |
| + expected.value = ASCIIToUTF16("Joseph"); |
| + expected.is_autofilled = true; |
| + SCOPED_TRACE(""); |
| + ExpectFieldEquals(expected, fields[3]); |
| + |
| + expected.name = ASCIIToUTF16("second"); |
| + expected.value = string16(); |
| + expected.is_autofilled = false; |
| + SCOPED_TRACE(""); |
| + ExpectFieldEquals(expected, fields[4]); |
| + |
| + expected.name = ASCIIToUTF16("lastname"); |
| + expected.value = ASCIIToUTF16("Jonathan"); |
| + expected.is_autofilled = true; |
| + SCOPED_TRACE(""); |
| + ExpectFieldEquals(expected, fields[5]); |
| + |
| + expected.name = ASCIIToUTF16("postfix"); |
| + expected.value = string16(); |
| + expected.is_autofilled = false; |
| + SCOPED_TRACE(""); |
| + ExpectFieldEquals(expected, fields[6]); |
| } |
| // This test sends a FormData object to FillForm with a field changed from |
| @@ -2260,24 +2228,28 @@ TEST_F(FormManagerTest, FillFormChangedFormDataFields) { |
| const std::vector<FormField>& fields = form2.fields; |
| ASSERT_EQ(3U, fields.size()); |
| - EXPECT_TRUE(fields[0].StrictlyEqualsHack(FormField(string16(), |
| - ASCIIToUTF16("firstname"), |
| - ASCIIToUTF16("Brother"), |
| - ASCIIToUTF16("text"), |
| - WebInputElement::defaultMaxLength(), |
| - false))); |
| - EXPECT_TRUE(fields[1].StrictlyEqualsHack(FormField(string16(), |
| - ASCIIToUTF16("middlename"), |
| - string16(), |
| - ASCIIToUTF16("text"), |
| - WebInputElement::defaultMaxLength(), |
| - false))); |
| - EXPECT_TRUE(fields[2].StrictlyEqualsHack(FormField(string16(), |
| - ASCIIToUTF16("lastname"), |
| - ASCIIToUTF16("Jonathan"), |
| - ASCIIToUTF16("text"), |
| - WebInputElement::defaultMaxLength(), |
| - false))); |
| + |
| + FormField expected; |
| + expected.form_control_type = ASCIIToUTF16("text"); |
| + expected.max_length = WebInputElement::defaultMaxLength(); |
| + |
| + expected.name = ASCIIToUTF16("firstname"); |
| + expected.value = ASCIIToUTF16("Brother"); |
| + expected.is_autofilled = true; |
| + SCOPED_TRACE(""); |
| + ExpectFieldEquals(expected, fields[0]); |
| + |
| + expected.name = ASCIIToUTF16("middlename"); |
| + expected.value = ASCIIToUTF16(""); |
| + expected.is_autofilled = false; |
| + SCOPED_TRACE(""); |
| + ExpectFieldEquals(expected, fields[1]); |
| + |
| + expected.name = ASCIIToUTF16("lastname"); |
| + expected.value = ASCIIToUTF16("Jonathan"); |
| + expected.is_autofilled = true; |
| + SCOPED_TRACE(""); |
| + ExpectFieldEquals(expected, fields[2]); |
| } |
| // This test sends a FormData object to FillForm with fewer fields than are in |
| @@ -2327,34 +2299,34 @@ TEST_F(FormManagerTest, FillFormExtraFieldInCache) { |
| const std::vector<FormField>& fields = form2.fields; |
| ASSERT_EQ(4U, fields.size()); |
| - EXPECT_TRUE(fields[0].StrictlyEqualsHack( |
| - FormField(string16(), |
| - ASCIIToUTF16("firstname"), |
| - ASCIIToUTF16("Brother"), |
| - ASCIIToUTF16("text"), |
| - WebInputElement::defaultMaxLength(), |
| - false))); |
| - EXPECT_TRUE(fields[1].StrictlyEqualsHack( |
| - FormField(string16(), |
| - ASCIIToUTF16("middlename"), |
| - ASCIIToUTF16("Joseph"), |
| - ASCIIToUTF16("text"), |
| - WebInputElement::defaultMaxLength(), |
| - false))); |
| - EXPECT_TRUE(fields[2].StrictlyEqualsHack( |
| - FormField(string16(), |
| - ASCIIToUTF16("lastname"), |
| - ASCIIToUTF16("Jonathan"), |
| - ASCIIToUTF16("text"), |
| - WebInputElement::defaultMaxLength(), |
| - false))); |
| - EXPECT_TRUE(fields[3].StrictlyEqualsHack( |
| - FormField(string16(), |
| - ASCIIToUTF16("postfix"), |
| - string16(), |
| - ASCIIToUTF16("text"), |
| - WebInputElement::defaultMaxLength(), |
| - false))); |
| + |
| + FormField expected; |
| + expected.form_control_type = ASCIIToUTF16("text"); |
| + expected.max_length = WebInputElement::defaultMaxLength(); |
| + |
| + expected.name = ASCIIToUTF16("firstname"); |
| + expected.value = ASCIIToUTF16("Brother"); |
| + expected.is_autofilled = true; |
| + SCOPED_TRACE(""); |
| + ExpectFieldEquals(expected, fields[0]); |
| + |
| + expected.name = ASCIIToUTF16("middlename"); |
| + expected.value = ASCIIToUTF16("Joseph"); |
| + expected.is_autofilled = true; |
| + SCOPED_TRACE(""); |
| + ExpectFieldEquals(expected, fields[1]); |
| + |
| + expected.name = ASCIIToUTF16("lastname"); |
| + expected.value = ASCIIToUTF16("Jonathan"); |
| + expected.is_autofilled = true; |
| + SCOPED_TRACE(""); |
| + ExpectFieldEquals(expected, fields[2]); |
| + |
| + expected.name = ASCIIToUTF16("postfix"); |
| + expected.value = string16(); |
| + expected.is_autofilled = false; |
| + SCOPED_TRACE(""); |
| + ExpectFieldEquals(expected, fields[3]); |
| } |
| TEST_F(FormManagerTest, FillFormEmptyName) { |
| @@ -2387,27 +2359,22 @@ TEST_F(FormManagerTest, FillFormEmptyName) { |
| const std::vector<FormField>& fields = form.fields; |
| ASSERT_EQ(3U, fields.size()); |
| - EXPECT_EQ(FormField(string16(), |
| - ASCIIToUTF16("firstname"), |
| - string16(), |
| - ASCIIToUTF16("text"), |
| - WebInputElement::defaultMaxLength(), |
| - false), |
| - fields[0]); |
| - EXPECT_EQ(FormField(string16(), |
| - ASCIIToUTF16("lastname"), |
| - string16(), |
| - ASCIIToUTF16("text"), |
| - WebInputElement::defaultMaxLength(), |
| - false), |
| - fields[1]); |
| - EXPECT_EQ(FormField(string16(), |
| - ASCIIToUTF16("email"), |
| - string16(), |
| - ASCIIToUTF16("text"), |
| - WebInputElement::defaultMaxLength(), |
| - false), |
| - fields[2]); |
| + |
| + FormField expected; |
| + expected.form_control_type = ASCIIToUTF16("text"); |
| + expected.max_length = WebInputElement::defaultMaxLength(); |
| + |
| + expected.name = ASCIIToUTF16("firstname"); |
| + SCOPED_TRACE(""); |
| + ExpectFieldEquals(expected, fields[0]); |
| + |
| + expected.name = ASCIIToUTF16("lastname"); |
| + SCOPED_TRACE(""); |
| + ExpectFieldEquals(expected, fields[1]); |
| + |
| + expected.name = ASCIIToUTF16("email"); |
| + SCOPED_TRACE(""); |
| + ExpectFieldEquals(expected, fields[2]); |
| // Fill the form. |
| form.fields[0].value = ASCIIToUTF16("Wyatt"); |
| @@ -2425,27 +2392,24 @@ TEST_F(FormManagerTest, FillFormEmptyName) { |
| const std::vector<FormField>& fields2 = form2.fields; |
| ASSERT_EQ(3U, fields2.size()); |
| - EXPECT_EQ(FormField(string16(), |
| - ASCIIToUTF16("firstname"), |
| - ASCIIToUTF16("Wyatt"), |
| - ASCIIToUTF16("text"), |
| - WebInputElement::defaultMaxLength(), |
| - false), |
| - fields2[0]); |
| - EXPECT_EQ(FormField(string16(), |
| - ASCIIToUTF16("lastname"), |
| - ASCIIToUTF16("Earp"), |
| - ASCIIToUTF16("text"), |
| - WebInputElement::defaultMaxLength(), |
| - false), |
| - fields2[1]); |
| - EXPECT_EQ(FormField(string16(), |
| - ASCIIToUTF16("email"), |
| - ASCIIToUTF16("wyatt@example.com"), |
| - ASCIIToUTF16("text"), |
| - WebInputElement::defaultMaxLength(), |
| - false), |
| - fields2[2]); |
| + |
| + expected.form_control_type = ASCIIToUTF16("text"); |
| + expected.max_length = WebInputElement::defaultMaxLength(); |
| + |
| + expected.name = ASCIIToUTF16("firstname"); |
| + expected.value = ASCIIToUTF16("Wyatt"); |
| + SCOPED_TRACE(""); |
| + ExpectFieldEquals(expected, fields[0]); |
| + |
| + expected.name = ASCIIToUTF16("lastname"); |
| + expected.value = ASCIIToUTF16("Earp"); |
| + SCOPED_TRACE(""); |
| + ExpectFieldEquals(expected, fields[1]); |
| + |
| + expected.name = ASCIIToUTF16("email"); |
| + expected.value = ASCIIToUTF16("wyatt@example.com"); |
| + SCOPED_TRACE(""); |
| + ExpectFieldEquals(expected, fields[2]); |
| } |
| TEST_F(FormManagerTest, FillFormEmptyFormNames) { |
| @@ -2484,27 +2448,25 @@ TEST_F(FormManagerTest, FillFormEmptyFormNames) { |
| const std::vector<FormField>& fields = form.fields; |
| ASSERT_EQ(3U, fields.size()); |
| - EXPECT_EQ(FormField(string16(), |
| - ASCIIToUTF16("apple"), |
| - string16(), |
| - ASCIIToUTF16("text"), |
| - WebInputElement::defaultMaxLength(), |
| - false), |
| - fields[0]); |
| - EXPECT_EQ(FormField(string16(), |
| - ASCIIToUTF16("banana"), |
| - string16(), |
| - ASCIIToUTF16("text"), |
| - WebInputElement::defaultMaxLength(), |
| - false), |
| - fields[1]); |
| - EXPECT_EQ(FormField(string16(), |
| - ASCIIToUTF16("cantelope"), |
| - string16(), |
| - ASCIIToUTF16("text"), |
| - WebInputElement::defaultMaxLength(), |
| - false), |
| - fields[2]); |
| + |
| + FormField expected; |
| + expected.form_control_type = ASCIIToUTF16("text"); |
| + expected.max_length = WebInputElement::defaultMaxLength(); |
| + |
| + expected.name = ASCIIToUTF16("apple"); |
| + expected.is_autofilled = false; |
| + SCOPED_TRACE(""); |
| + ExpectFieldEquals(expected, fields[0]); |
| + |
| + expected.name = ASCIIToUTF16("banana"); |
| + expected.is_autofilled = false; |
| + SCOPED_TRACE(""); |
| + ExpectFieldEquals(expected, fields[1]); |
| + |
| + expected.name = ASCIIToUTF16("cantelope"); |
| + expected.is_autofilled = false; |
| + SCOPED_TRACE(""); |
| + ExpectFieldEquals(expected, fields[2]); |
| // Fill the form. |
| form.fields[0].value = ASCIIToUTF16("Red"); |
| @@ -2522,27 +2484,24 @@ TEST_F(FormManagerTest, FillFormEmptyFormNames) { |
| const std::vector<FormField>& fields2 = form2.fields; |
| ASSERT_EQ(3U, fields2.size()); |
| - EXPECT_EQ(FormField(string16(), |
| - ASCIIToUTF16("apple"), |
| - ASCIIToUTF16("Red"), |
| - ASCIIToUTF16("text"), |
| - WebInputElement::defaultMaxLength(), |
| - false), |
| - fields2[0]); |
| - EXPECT_EQ(FormField(string16(), |
| - ASCIIToUTF16("banana"), |
| - ASCIIToUTF16("Yellow"), |
| - ASCIIToUTF16("text"), |
| - WebInputElement::defaultMaxLength(), |
| - false), |
| - fields2[1]); |
| - EXPECT_EQ(FormField(string16(), |
| - ASCIIToUTF16("cantelope"), |
| - ASCIIToUTF16("Also Yellow"), |
| - ASCIIToUTF16("text"), |
| - WebInputElement::defaultMaxLength(), |
| - false), |
| - fields2[2]); |
| + |
| + expected.name = ASCIIToUTF16("apple"); |
| + expected.value = ASCIIToUTF16("Red"); |
| + expected.is_autofilled = true; |
| + SCOPED_TRACE(""); |
| + ExpectFieldEquals(expected, fields2[0]); |
| + |
| + expected.name = ASCIIToUTF16("banana"); |
| + expected.value = ASCIIToUTF16("Yellow"); |
| + expected.is_autofilled = true; |
| + SCOPED_TRACE(""); |
| + ExpectFieldEquals(expected, fields2[1]); |
| + |
| + expected.name = ASCIIToUTF16("cantelope"); |
| + expected.value = ASCIIToUTF16("Also Yellow"); |
| + expected.is_autofilled = true; |
| + SCOPED_TRACE(""); |
| + ExpectFieldEquals(expected, fields2[2]); |
| } |
| TEST_F(FormManagerTest, ThreePartPhone) { |
| @@ -2577,34 +2536,30 @@ TEST_F(FormManagerTest, ThreePartPhone) { |
| const std::vector<FormField>& fields = form.fields; |
| ASSERT_EQ(4U, fields.size()); |
| - EXPECT_EQ(FormField(ASCIIToUTF16("Phone:"), |
| - ASCIIToUTF16("dayphone1"), |
| - string16(), |
| - ASCIIToUTF16("text"), |
| - WebInputElement::defaultMaxLength(), |
| - false), |
| - fields[0]); |
| - EXPECT_EQ(FormField(ASCIIToUTF16("-"), |
| - ASCIIToUTF16("dayphone2"), |
| - string16(), |
| - ASCIIToUTF16("text"), |
| - WebInputElement::defaultMaxLength(), |
| - false), |
| - fields[1]); |
| - EXPECT_EQ(FormField(ASCIIToUTF16("-"), |
| - ASCIIToUTF16("dayphone3"), |
| - string16(), |
| - ASCIIToUTF16("text"), |
| - WebInputElement::defaultMaxLength(), |
| - false), |
| - fields[2]); |
| - EXPECT_EQ(FormField(ASCIIToUTF16("ext.:"), |
| - ASCIIToUTF16("dayphone4"), |
| - string16(), |
| - ASCIIToUTF16("text"), |
| - WebInputElement::defaultMaxLength(), |
| - false), |
| - fields[3]); |
| + |
| + FormField expected; |
| + expected.form_control_type = ASCIIToUTF16("text"); |
| + expected.max_length = WebInputElement::defaultMaxLength(); |
| + |
| + expected.label = ASCIIToUTF16("Phone:"); |
| + expected.name = ASCIIToUTF16("dayphone1"); |
| + SCOPED_TRACE(""); |
| + ExpectFieldEquals(expected, fields[0]); |
| + |
| + expected.label = ASCIIToUTF16("-"); |
| + expected.name = ASCIIToUTF16("dayphone2"); |
| + SCOPED_TRACE(""); |
| + ExpectFieldEquals(expected, fields[1]); |
| + |
| + expected.label = ASCIIToUTF16("-"); |
| + expected.name = ASCIIToUTF16("dayphone3"); |
| + SCOPED_TRACE(""); |
| + ExpectFieldEquals(expected, fields[2]); |
| + |
| + expected.label = ASCIIToUTF16("ext.:"); |
| + expected.name = ASCIIToUTF16("dayphone4"); |
| + SCOPED_TRACE(""); |
| + ExpectFieldEquals(expected, fields[3]); |
| } |
| @@ -2642,50 +2597,47 @@ TEST_F(FormManagerTest, MaxLengthFields) { |
| const std::vector<FormField>& fields = form.fields; |
| ASSERT_EQ(6U, fields.size()); |
| - EXPECT_EQ(FormField(ASCIIToUTF16("Phone:"), |
| - ASCIIToUTF16("dayphone1"), |
| - string16(), |
| - ASCIIToUTF16("text"), |
| - 3, |
| - false), |
| - fields[0]); |
| - EXPECT_EQ(FormField(ASCIIToUTF16("-"), |
| - ASCIIToUTF16("dayphone2"), |
| - string16(), |
| - ASCIIToUTF16("text"), |
| - 3, |
| - false), |
| - fields[1]); |
| - EXPECT_EQ(FormField(ASCIIToUTF16("-"), |
| - ASCIIToUTF16("dayphone3"), |
| - string16(), |
| - ASCIIToUTF16("text"), |
| - 4, |
| - false), |
| - fields[2]); |
| - EXPECT_EQ(FormField(ASCIIToUTF16("ext.:"), |
| - ASCIIToUTF16("dayphone4"), |
| - string16(), |
| - ASCIIToUTF16("text"), |
| - 5, |
| - false), |
| - fields[3]); |
| + |
| + FormField expected; |
| + expected.form_control_type = ASCIIToUTF16("text"); |
| + |
| + expected.label = ASCIIToUTF16("Phone:"); |
| + expected.name = ASCIIToUTF16("dayphone1"); |
| + expected.max_length = 3; |
| + SCOPED_TRACE(""); |
| + ExpectFieldEquals(expected, fields[0]); |
| + |
| + expected.label = ASCIIToUTF16("-"); |
| + expected.name = ASCIIToUTF16("dayphone2"); |
| + expected.max_length = 3; |
| + SCOPED_TRACE(""); |
| + ExpectFieldEquals(expected, fields[1]); |
| + |
| + expected.label = ASCIIToUTF16("-"); |
| + expected.name = ASCIIToUTF16("dayphone3"); |
| + expected.max_length = 4; |
| + SCOPED_TRACE(""); |
| + ExpectFieldEquals(expected, fields[2]); |
| + |
| + expected.label = ASCIIToUTF16("ext.:"); |
| + expected.name = ASCIIToUTF16("dayphone4"); |
| + expected.max_length = 5; |
| + SCOPED_TRACE(""); |
| + ExpectFieldEquals(expected, fields[3]); |
| + |
| // When unspecified |size|, default is returned. |
| - EXPECT_EQ(FormField(string16(), |
| - ASCIIToUTF16("default1"), |
| - string16(), |
| - ASCIIToUTF16("text"), |
| - WebInputElement::defaultMaxLength(), |
| - false), |
| - fields[4]); |
| + expected.label = string16(); |
| + expected.name = ASCIIToUTF16("default1"); |
| + expected.max_length = WebInputElement::defaultMaxLength(); |
| + SCOPED_TRACE(""); |
| + ExpectFieldEquals(expected, fields[4]); |
| + |
| // When invalid |size|, default is returned. |
| - EXPECT_EQ(FormField(string16(), |
| - ASCIIToUTF16("invalid1"), |
| - string16(), |
| - ASCIIToUTF16("text"), |
| - WebInputElement::defaultMaxLength(), |
| - false), |
| - fields[5]); |
| + expected.label = string16(); |
| + expected.name = ASCIIToUTF16("invalid1"); |
| + expected.max_length = WebInputElement::defaultMaxLength(); |
| + SCOPED_TRACE(""); |
| + ExpectFieldEquals(expected, fields[5]); |
| } |
| // This test re-creates the experience of typing in a field then selecting a |
| @@ -2724,27 +2676,28 @@ TEST_F(FormManagerTest, FillFormNonEmptyField) { |
| const std::vector<FormField>& fields = form.fields; |
| ASSERT_EQ(3U, fields.size()); |
| - EXPECT_EQ(FormField(string16(), |
| - ASCIIToUTF16("firstname"), |
| - string16(), |
| - ASCIIToUTF16("text"), |
| - WebInputElement::defaultMaxLength(), |
| - false), |
| - fields[0]); |
| - EXPECT_EQ(FormField(string16(), |
| - ASCIIToUTF16("lastname"), |
| - string16(), |
| - ASCIIToUTF16("text"), |
| - WebInputElement::defaultMaxLength(), |
| - false), |
| - fields[1]); |
| - EXPECT_EQ(FormField(string16(), |
| - ASCIIToUTF16("email"), |
| - string16(), |
| - ASCIIToUTF16("text"), |
| - WebInputElement::defaultMaxLength(), |
| - false), |
| - fields[2]); |
| + |
| + FormField expected; |
| + expected.form_control_type = ASCIIToUTF16("text"); |
| + expected.max_length = WebInputElement::defaultMaxLength(); |
| + |
| + expected.name = ASCIIToUTF16("firstname"); |
| + expected.value = ASCIIToUTF16("Wy"); |
| + expected.is_autofilled = false; |
| + SCOPED_TRACE(""); |
| + ExpectFieldEquals(expected, fields[0]); |
| + |
| + expected.name = ASCIIToUTF16("lastname"); |
| + expected.value = string16(); |
| + expected.is_autofilled = false; |
| + SCOPED_TRACE(""); |
| + ExpectFieldEquals(expected, fields[1]); |
| + |
| + expected.name = ASCIIToUTF16("email"); |
| + expected.value = string16(); |
| + expected.is_autofilled = false; |
| + SCOPED_TRACE(""); |
| + ExpectFieldEquals(expected, fields[2]); |
| // Preview the form and verify that the cursor position has been updated. |
| form.fields[0].value = ASCIIToUTF16("Wyatt"); |
| @@ -2767,27 +2720,24 @@ TEST_F(FormManagerTest, FillFormNonEmptyField) { |
| const std::vector<FormField>& fields2 = form2.fields; |
| ASSERT_EQ(3U, fields2.size()); |
| - EXPECT_EQ(FormField(string16(), |
| - ASCIIToUTF16("firstname"), |
| - ASCIIToUTF16("Wyatt"), |
| - ASCIIToUTF16("text"), |
| - WebInputElement::defaultMaxLength(), |
| - false), |
| - fields2[0]); |
| - EXPECT_EQ(FormField(string16(), |
| - ASCIIToUTF16("lastname"), |
| - ASCIIToUTF16("Earp"), |
| - ASCIIToUTF16("text"), |
| - WebInputElement::defaultMaxLength(), |
| - false), |
| - fields2[1]); |
| - EXPECT_EQ(FormField(string16(), |
| - ASCIIToUTF16("email"), |
| - ASCIIToUTF16("wyatt@example.com"), |
| - ASCIIToUTF16("text"), |
| - WebInputElement::defaultMaxLength(), |
| - false), |
| - fields2[2]); |
| + |
| + expected.name = ASCIIToUTF16("firstname"); |
| + expected.value = ASCIIToUTF16("Wyatt"); |
| + expected.is_autofilled = true; |
| + SCOPED_TRACE(""); |
| + ExpectFieldEquals(expected, fields2[0]); |
| + |
| + expected.name = ASCIIToUTF16("lastname"); |
| + expected.value = ASCIIToUTF16("Earp"); |
| + expected.is_autofilled = true; |
| + SCOPED_TRACE(""); |
| + ExpectFieldEquals(expected, fields2[1]); |
| + |
| + expected.name = ASCIIToUTF16("email"); |
| + expected.value = ASCIIToUTF16("wyatt@example.com"); |
| + expected.is_autofilled = true; |
| + SCOPED_TRACE(""); |
| + ExpectFieldEquals(expected, fields2[2]); |
| // Verify that the cursor position has been updated. |
| EXPECT_EQ(5, input_element.selectionStart()); |
| @@ -2837,34 +2787,30 @@ TEST_F(FormManagerTest, ClearFormWithNode) { |
| const std::vector<FormField>& fields2 = form2.fields; |
| ASSERT_EQ(4U, fields2.size()); |
| - EXPECT_TRUE(fields2[0].StrictlyEqualsHack( |
| - FormField(string16(), |
| - ASCIIToUTF16("firstname"), |
| - string16(), |
| - ASCIIToUTF16("text"), |
| - WebInputElement::defaultMaxLength(), |
| - false))); |
| - EXPECT_TRUE(fields2[1].StrictlyEqualsHack( |
| - FormField(string16(), |
| - ASCIIToUTF16("lastname"), |
| - string16(), |
| - ASCIIToUTF16("text"), |
| - WebInputElement::defaultMaxLength(), |
| - false))); |
| - EXPECT_TRUE(fields2[2].StrictlyEqualsHack( |
| - FormField(string16(), |
| - ASCIIToUTF16("noAC"), |
| - string16(), |
| - ASCIIToUTF16("text"), |
| - WebInputElement::defaultMaxLength(), |
| - false))); |
| - EXPECT_TRUE(fields2[3].StrictlyEqualsHack( |
| - FormField(string16(), |
| - ASCIIToUTF16("notenabled"), |
| - ASCIIToUTF16("no clear"), |
| - ASCIIToUTF16("text"), |
| - WebInputElement::defaultMaxLength(), |
| - false))); |
| + |
| + FormField expected; |
| + expected.form_control_type = ASCIIToUTF16("text"); |
| + expected.max_length = WebInputElement::defaultMaxLength(); |
| + |
| + expected.name = ASCIIToUTF16("firstname"); |
| + expected.value = string16(); |
| + SCOPED_TRACE(""); |
| + ExpectFieldEquals(expected, fields2[0]); |
| + |
| + expected.name = ASCIIToUTF16("lastname"); |
| + expected.value = string16(); |
| + SCOPED_TRACE(""); |
| + ExpectFieldEquals(expected, fields2[1]); |
| + |
| + expected.name = ASCIIToUTF16("noAC"); |
| + expected.value = string16(); |
| + SCOPED_TRACE(""); |
| + ExpectFieldEquals(expected, fields2[2]); |
| + |
| + expected.name = ASCIIToUTF16("notenabled"); |
| + expected.value = ASCIIToUTF16("no clear"); |
| + SCOPED_TRACE(""); |
| + ExpectFieldEquals(expected, fields2[3]); |
| // Verify that the cursor position has been updated. |
| EXPECT_EQ(0, firstname.selectionStart()); |
| @@ -2918,27 +2864,29 @@ TEST_F(FormManagerTest, ClearFormWithNodeContainingSelectOne) { |
| const std::vector<FormField>& fields2 = form2.fields; |
| ASSERT_EQ(3U, fields2.size()); |
| - EXPECT_TRUE(fields2[0].StrictlyEqualsHack( |
| - FormField(string16(), |
| - ASCIIToUTF16("firstname"), |
| - string16(), |
| - ASCIIToUTF16("text"), |
| - WebInputElement::defaultMaxLength(), |
| - false))); |
| - EXPECT_TRUE(fields2[1].StrictlyEqualsHack( |
| - FormField(string16(), |
| - ASCIIToUTF16("lastname"), |
| - string16(), |
| - ASCIIToUTF16("text"), |
| - WebInputElement::defaultMaxLength(), |
| - false))); |
| - EXPECT_TRUE(fields2[2].StrictlyEqualsHack( |
| - FormField(string16(), |
| - ASCIIToUTF16("state"), |
| - ASCIIToUTF16("?"), |
| - ASCIIToUTF16("select-one"), |
| - 0, |
| - false))); |
| + |
| + FormField expected; |
| + |
| + expected.name = ASCIIToUTF16("firstname"); |
| + expected.value = string16(); |
| + expected.form_control_type = ASCIIToUTF16("text"); |
| + expected.max_length = WebInputElement::defaultMaxLength(); |
| + SCOPED_TRACE(""); |
| + ExpectFieldEquals(expected, fields2[0]); |
| + |
| + expected.name = ASCIIToUTF16("lastname"); |
| + expected.value = string16(); |
| + expected.form_control_type = ASCIIToUTF16("text"); |
| + expected.max_length = WebInputElement::defaultMaxLength(); |
| + SCOPED_TRACE(""); |
| + ExpectFieldEquals(expected, fields2[1]); |
| + |
| + expected.name = ASCIIToUTF16("state"); |
| + expected.value = ASCIIToUTF16("?"); |
| + expected.form_control_type = ASCIIToUTF16("select-one"); |
| + expected.max_length = 0; |
| + SCOPED_TRACE(""); |
| + ExpectFieldEquals(expected, fields2[2]); |
| // Verify that the cursor position has been updated. |
| EXPECT_EQ(0, firstname.selectionStart()); |
| @@ -3268,27 +3216,29 @@ TEST_F(FormManagerTest, SelectOneAsText) { |
| const std::vector<FormField>& fields = form.fields; |
| ASSERT_EQ(3U, fields.size()); |
| - EXPECT_TRUE(fields[0].StrictlyEqualsHack( |
| - FormField(string16(), |
| - ASCIIToUTF16("firstname"), |
| - ASCIIToUTF16("John"), |
| - ASCIIToUTF16("text"), |
| - WebInputElement::defaultMaxLength(), |
| - false))); |
| - EXPECT_TRUE(fields[1].StrictlyEqualsHack( |
| - FormField(string16(), |
| - ASCIIToUTF16("lastname"), |
| - ASCIIToUTF16("Smith"), |
| - ASCIIToUTF16("text"), |
| - WebInputElement::defaultMaxLength(), |
| - false))); |
| - EXPECT_TRUE(fields[2].StrictlyEqualsHack( |
| - FormField(string16(), |
| - ASCIIToUTF16("country"), |
| - ASCIIToUTF16("Albania"), |
| - ASCIIToUTF16("select-one"), |
| - 0, |
| - false))); |
| + |
| + FormField expected; |
| + |
| + expected.name = ASCIIToUTF16("firstname"); |
| + expected.value = ASCIIToUTF16("John"); |
| + expected.form_control_type = ASCIIToUTF16("text"); |
| + expected.max_length = WebInputElement::defaultMaxLength(); |
| + SCOPED_TRACE(""); |
| + ExpectFieldEquals(expected, fields[0]); |
| + |
| + expected.name = ASCIIToUTF16("lastname"); |
| + expected.value = ASCIIToUTF16("Smith"); |
| + expected.form_control_type = ASCIIToUTF16("text"); |
| + expected.max_length = WebInputElement::defaultMaxLength(); |
| + SCOPED_TRACE(""); |
| + ExpectFieldEquals(expected, fields[1]); |
| + |
| + expected.name = ASCIIToUTF16("country"); |
| + expected.value = ASCIIToUTF16("Albania"); |
| + expected.form_control_type = ASCIIToUTF16("select-one"); |
| + expected.max_length = 0; |
| + SCOPED_TRACE(""); |
| + ExpectFieldEquals(expected, fields[2]); |
| form.fields.clear(); |
| // Extract the country select-one value as value. |
| @@ -3301,25 +3251,25 @@ TEST_F(FormManagerTest, SelectOneAsText) { |
| EXPECT_EQ(GURL("http://cnn.com"), form.action); |
| ASSERT_EQ(3U, fields.size()); |
| - EXPECT_TRUE(fields[0].StrictlyEqualsHack( |
| - FormField(string16(), |
| - ASCIIToUTF16("firstname"), |
| - ASCIIToUTF16("John"), |
| - ASCIIToUTF16("text"), |
| - WebInputElement::defaultMaxLength(), |
| - false))); |
| - EXPECT_TRUE(fields[1].StrictlyEqualsHack( |
| - FormField(string16(), |
| - ASCIIToUTF16("lastname"), |
| - ASCIIToUTF16("Smith"), |
| - ASCIIToUTF16("text"), |
| - WebInputElement::defaultMaxLength(), |
| - false))); |
| - EXPECT_TRUE(fields[2].StrictlyEqualsHack( |
| - FormField(string16(), |
| - ASCIIToUTF16("country"), |
| - ASCIIToUTF16("AL"), |
| - ASCIIToUTF16("select-one"), |
| - 0, |
| - false))); |
| + |
| + expected.name = ASCIIToUTF16("firstname"); |
| + expected.value = ASCIIToUTF16("John"); |
| + expected.form_control_type = ASCIIToUTF16("text"); |
| + expected.max_length = WebInputElement::defaultMaxLength(); |
| + SCOPED_TRACE(""); |
| + ExpectFieldEquals(expected, fields[0]); |
| + |
| + expected.name = ASCIIToUTF16("lastname"); |
| + expected.value = ASCIIToUTF16("Smith"); |
| + expected.form_control_type = ASCIIToUTF16("text"); |
| + expected.max_length = WebInputElement::defaultMaxLength(); |
| + SCOPED_TRACE(""); |
| + ExpectFieldEquals(expected, fields[1]); |
| + |
| + expected.name = ASCIIToUTF16("country"); |
| + expected.value = ASCIIToUTF16("AL"); |
| + expected.form_control_type = ASCIIToUTF16("select-one"); |
| + expected.max_length = 0; |
| + SCOPED_TRACE(""); |
| + ExpectFieldEquals(expected, fields[2]); |
| } |