Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6710)

Unified Diff: chrome/renderer/autofill/autofill_browsertest.cc

Issue 7576001: Refactor webkit_glue::FormField to remove hacky methods (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Only FormField class refactoring Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/renderer/autofill/autofill_browsertest.cc
diff --git a/chrome/renderer/autofill/autofill_browsertest.cc b/chrome/renderer/autofill/autofill_browsertest.cc
index 671698c08c5fe4194b087d066bbd81be24b1612a..840a6d776179f0cdc89bb63b09613d5377af1eee 100644
--- a/chrome/renderer/autofill/autofill_browsertest.cc
+++ b/chrome/renderer/autofill/autofill_browsertest.cc
@@ -19,6 +19,19 @@ using WebKit::WebString;
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
+
TEST_F(RenderViewTest, SendForms) {
// Don't want any delay for form state sync changes. This will still post a
// message so updates will get coalesced, but as soon as we spin the message
@@ -46,27 +59,26 @@ TEST_F(RenderViewTest, SendForms) {
const std::vector<FormData>& forms = params.a;
ASSERT_EQ(1UL, forms.size());
ASSERT_EQ(3UL, forms[0].fields.size());
- EXPECT_TRUE(forms[0].fields[0].StrictlyEqualsHack(
- FormField(string16(),
- ASCIIToUTF16("firstname"),
- string16(),
- ASCIIToUTF16("text"),
- WebInputElement::defaultMaxLength(),
- false))) << forms[0].fields[0];
- EXPECT_TRUE(forms[0].fields[1].StrictlyEqualsHack(
- FormField(string16(),
- ASCIIToUTF16("middlename"),
- string16(),
- ASCIIToUTF16("text"),
- WebInputElement::defaultMaxLength(),
- false))) << forms[0].fields[1];
- EXPECT_TRUE(forms[0].fields[2].StrictlyEqualsHack(
- FormField(string16(),
- ASCIIToUTF16("state"),
- ASCIIToUTF16("?"),
- ASCIIToUTF16("select-one"),
- 0,
- false))) << forms[0].fields[2];
+
+ FormField expected;
+
+ expected.name = ASCIIToUTF16("firstname");
+ expected.value = string16();
+ expected.form_control_type = ASCIIToUTF16("text");
+ expected.max_length = WebInputElement::defaultMaxLength();
+ ExpectFieldEquals(expected, forms[0].fields[0]);
+
+ expected.name = ASCIIToUTF16("middlename");
+ expected.value = string16();
+ expected.form_control_type = ASCIIToUTF16("text");
+ expected.max_length = WebInputElement::defaultMaxLength();
+ ExpectFieldEquals(expected, forms[0].fields[1]);
+
+ expected.name = ASCIIToUTF16("state");
+ expected.value = ASCIIToUTF16("?");
+ expected.form_control_type = ASCIIToUTF16("select-one");
+ expected.max_length = 0;
+ ExpectFieldEquals(expected, forms[0].fields[2]);
// Verify that |didAcceptAutofillSuggestion()| sends the expected number of
// fields.
@@ -93,27 +105,24 @@ TEST_F(RenderViewTest, SendForms) {
AutofillHostMsg_FillAutofillFormData::Read(message2, &params2);
const FormData& form2 = params2.b;
ASSERT_EQ(3UL, form2.fields.size());
- EXPECT_TRUE(form2.fields[0].StrictlyEqualsHack(
- FormField(string16(),
- ASCIIToUTF16("firstname"),
- string16(),
- ASCIIToUTF16("text"),
- WebInputElement::defaultMaxLength(),
- false))) << form2.fields[0];
- EXPECT_TRUE(form2.fields[1].StrictlyEqualsHack(
- FormField(string16(),
- ASCIIToUTF16("middlename"),
- string16(),
- ASCIIToUTF16("text"),
- WebInputElement::defaultMaxLength(),
- false))) << form2.fields[1];
- EXPECT_TRUE(form2.fields[2].StrictlyEqualsHack(
- FormField(string16(),
- ASCIIToUTF16("state"),
- ASCIIToUTF16("?"),
- ASCIIToUTF16("select-one"),
- 0,
- false))) << form2.fields[2];
+
+ expected.name = ASCIIToUTF16("firstname");
+ expected.value = string16();
+ expected.form_control_type = ASCIIToUTF16("text");
+ expected.max_length = WebInputElement::defaultMaxLength();
+ ExpectFieldEquals(expected, form2.fields[0]);
+
+ expected.name = ASCIIToUTF16("middlename");
+ expected.value = string16();
+ expected.form_control_type = ASCIIToUTF16("text");
+ expected.max_length = WebInputElement::defaultMaxLength();
+ ExpectFieldEquals(expected, form2.fields[1]);
+
+ expected.name = ASCIIToUTF16("state");
+ expected.value = ASCIIToUTF16("?");
+ expected.form_control_type = ASCIIToUTF16("select-one");
+ expected.max_length = 0;
+ ExpectFieldEquals(expected, form2.fields[2]);
}
TEST_F(RenderViewTest, FillFormElement) {

Powered by Google App Engine
This is Rietveld 408576698