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

Side by Side Diff: chrome/renderer/autofill/autofill_renderer_browsertest.cc

Issue 11198048: [Autofill] Update the autocomplete types implementation to match the current HTML spec. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Update AutofillFieldTest expectations Created 8 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/common/form_field_data.cc ('k') | chrome/renderer/autofill/form_autofill_browsertest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/utf_string_conversions.h" 5 #include "base/utf_string_conversions.h"
6 #include "chrome/common/autofill_messages.h" 6 #include "chrome/common/autofill_messages.h"
7 #include "chrome/common/form_data.h" 7 #include "chrome/common/form_data.h"
8 #include "chrome/common/form_field_data.h" 8 #include "chrome/common/form_field_data.h"
9 #include "chrome/test/base/chrome_render_view_test.h" 9 #include "chrome/test/base/chrome_render_view_test.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 AutofillHostMsg_FormsSeen::Param params; 44 AutofillHostMsg_FormsSeen::Param params;
45 AutofillHostMsg_FormsSeen::Read(message, &params); 45 AutofillHostMsg_FormsSeen::Read(message, &params);
46 const std::vector<FormData>& forms = params.a; 46 const std::vector<FormData>& forms = params.a;
47 ASSERT_EQ(1UL, forms.size()); 47 ASSERT_EQ(1UL, forms.size());
48 ASSERT_EQ(4UL, forms[0].fields.size()); 48 ASSERT_EQ(4UL, forms[0].fields.size());
49 49
50 FormFieldData expected; 50 FormFieldData expected;
51 51
52 expected.name = ASCIIToUTF16("firstname"); 52 expected.name = ASCIIToUTF16("firstname");
53 expected.value = string16(); 53 expected.value = string16();
54 expected.form_control_type = ASCIIToUTF16("text"); 54 expected.form_control_type = "text";
55 expected.max_length = WebInputElement::defaultMaxLength(); 55 expected.max_length = WebInputElement::defaultMaxLength();
56 EXPECT_FORM_FIELD_DATA_EQUALS(expected, forms[0].fields[0]); 56 EXPECT_FORM_FIELD_DATA_EQUALS(expected, forms[0].fields[0]);
57 57
58 expected.name = ASCIIToUTF16("middlename"); 58 expected.name = ASCIIToUTF16("middlename");
59 expected.value = string16(); 59 expected.value = string16();
60 expected.form_control_type = ASCIIToUTF16("text"); 60 expected.form_control_type = "text";
61 expected.max_length = WebInputElement::defaultMaxLength(); 61 expected.max_length = WebInputElement::defaultMaxLength();
62 EXPECT_FORM_FIELD_DATA_EQUALS(expected, forms[0].fields[1]); 62 EXPECT_FORM_FIELD_DATA_EQUALS(expected, forms[0].fields[1]);
63 63
64 expected.name = ASCIIToUTF16("lastname"); 64 expected.name = ASCIIToUTF16("lastname");
65 expected.value = string16(); 65 expected.value = string16();
66 expected.form_control_type = ASCIIToUTF16("text"); 66 expected.form_control_type = "text";
67 expected.autocomplete_attribute = "off";
67 expected.max_length = WebInputElement::defaultMaxLength(); 68 expected.max_length = WebInputElement::defaultMaxLength();
68 EXPECT_FORM_FIELD_DATA_EQUALS(expected, forms[0].fields[2]); 69 EXPECT_FORM_FIELD_DATA_EQUALS(expected, forms[0].fields[2]);
70 expected.autocomplete_attribute = std::string(); // reset
69 71
70 expected.name = ASCIIToUTF16("state"); 72 expected.name = ASCIIToUTF16("state");
71 expected.value = ASCIIToUTF16("?"); 73 expected.value = ASCIIToUTF16("?");
72 expected.form_control_type = ASCIIToUTF16("select-one"); 74 expected.form_control_type = "select-one";
73 expected.max_length = 0; 75 expected.max_length = 0;
74 EXPECT_FORM_FIELD_DATA_EQUALS(expected, forms[0].fields[3]); 76 EXPECT_FORM_FIELD_DATA_EQUALS(expected, forms[0].fields[3]);
75 77
76 // Verify that |didAcceptAutofillSuggestion()| sends the expected number of 78 // Verify that |didAcceptAutofillSuggestion()| sends the expected number of
77 // fields. 79 // fields.
78 WebFrame* web_frame = GetMainFrame(); 80 WebFrame* web_frame = GetMainFrame();
79 WebDocument document = web_frame->document(); 81 WebDocument document = web_frame->document();
80 WebInputElement firstname = 82 WebInputElement firstname =
81 document.getElementById("firstname").to<WebInputElement>(); 83 document.getElementById("firstname").to<WebInputElement>();
82 84
(...skipping 16 matching lines...) Expand all
99 render_thread_->sink().GetUniqueMessageMatching( 101 render_thread_->sink().GetUniqueMessageMatching(
100 AutofillHostMsg_FillAutofillFormData::ID); 102 AutofillHostMsg_FillAutofillFormData::ID);
101 ASSERT_NE(static_cast<IPC::Message*>(NULL), message2); 103 ASSERT_NE(static_cast<IPC::Message*>(NULL), message2);
102 AutofillHostMsg_FillAutofillFormData::Param params2; 104 AutofillHostMsg_FillAutofillFormData::Param params2;
103 AutofillHostMsg_FillAutofillFormData::Read(message2, &params2); 105 AutofillHostMsg_FillAutofillFormData::Read(message2, &params2);
104 const FormData& form2 = params2.b; 106 const FormData& form2 = params2.b;
105 ASSERT_EQ(3UL, form2.fields.size()); 107 ASSERT_EQ(3UL, form2.fields.size());
106 108
107 expected.name = ASCIIToUTF16("firstname"); 109 expected.name = ASCIIToUTF16("firstname");
108 expected.value = string16(); 110 expected.value = string16();
109 expected.form_control_type = ASCIIToUTF16("text"); 111 expected.form_control_type = "text";
110 expected.max_length = WebInputElement::defaultMaxLength(); 112 expected.max_length = WebInputElement::defaultMaxLength();
111 EXPECT_FORM_FIELD_DATA_EQUALS(expected, form2.fields[0]); 113 EXPECT_FORM_FIELD_DATA_EQUALS(expected, form2.fields[0]);
112 114
113 expected.name = ASCIIToUTF16("middlename"); 115 expected.name = ASCIIToUTF16("middlename");
114 expected.value = string16(); 116 expected.value = string16();
115 expected.form_control_type = ASCIIToUTF16("text"); 117 expected.form_control_type = "text";
116 expected.max_length = WebInputElement::defaultMaxLength(); 118 expected.max_length = WebInputElement::defaultMaxLength();
117 EXPECT_FORM_FIELD_DATA_EQUALS(expected, form2.fields[1]); 119 EXPECT_FORM_FIELD_DATA_EQUALS(expected, form2.fields[1]);
118 120
119 expected.name = ASCIIToUTF16("state"); 121 expected.name = ASCIIToUTF16("state");
120 expected.value = ASCIIToUTF16("?"); 122 expected.value = ASCIIToUTF16("?");
121 expected.form_control_type = ASCIIToUTF16("select-one"); 123 expected.form_control_type = "select-one";
122 expected.max_length = 0; 124 expected.max_length = 0;
123 EXPECT_FORM_FIELD_DATA_EQUALS(expected, form2.fields[2]); 125 EXPECT_FORM_FIELD_DATA_EQUALS(expected, form2.fields[2]);
124 } 126 }
125 127
126 TEST_F(ChromeRenderViewTest, FillFormElement) { 128 TEST_F(ChromeRenderViewTest, FillFormElement) {
127 // Don't want any delay for form state sync changes. This will still post a 129 // Don't want any delay for form state sync changes. This will still post a
128 // message so updates will get coalesced, but as soon as we spin the message 130 // message so updates will get coalesced, but as soon as we spin the message
129 // loop, it will generate an update. 131 // loop, it will generate an update.
130 SendContentStateImmediately(); 132 SendContentStateImmediately();
131 133
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 const IPC::Message* message2 = 167 const IPC::Message* message2 =
166 render_thread_->sink().GetUniqueMessageMatching( 168 render_thread_->sink().GetUniqueMessageMatching(
167 AutofillHostMsg_FillAutofillFormData::ID); 169 AutofillHostMsg_FillAutofillFormData::ID);
168 170
169 // No message should be sent in this case. |firstname| is filled directly. 171 // No message should be sent in this case. |firstname| is filled directly.
170 ASSERT_EQ(static_cast<IPC::Message*>(NULL), message2); 172 ASSERT_EQ(static_cast<IPC::Message*>(NULL), message2);
171 EXPECT_EQ(firstname.value(), WebKit::WebString::fromUTF8("David")); 173 EXPECT_EQ(firstname.value(), WebKit::WebString::fromUTF8("David"));
172 } 174 }
173 175
174 } // namespace autofill 176 } // namespace autofill
OLDNEW
« no previous file with comments | « chrome/common/form_field_data.cc ('k') | chrome/renderer/autofill/form_autofill_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698