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

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

Issue 1767343004: Replace base::Tuple in //chrome with std::tuple (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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 unified diff | Download patch
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 <tuple>
6
5 #include "base/command_line.h" 7 #include "base/command_line.h"
6 #include "base/files/file_util.h" 8 #include "base/files/file_util.h"
7 #include "base/macros.h" 9 #include "base/macros.h"
8 #include "base/strings/stringprintf.h" 10 #include "base/strings/stringprintf.h"
9 #include "base/strings/utf_string_conversions.h" 11 #include "base/strings/utf_string_conversions.h"
10 #include "chrome/test/base/chrome_render_view_test.h" 12 #include "chrome/test/base/chrome_render_view_test.h"
11 #include "chrome/test/base/ui_test_utils.h" 13 #include "chrome/test/base/ui_test_utils.h"
12 #include "components/autofill/content/common/autofill_messages.h" 14 #include "components/autofill/content/common/autofill_messages.h"
13 #include "components/autofill/content/renderer/autofill_agent.h" 15 #include "components/autofill/content/renderer/autofill_agent.h"
14 #include "components/autofill/core/common/form_data.h" 16 #include "components/autofill/core/common/form_data.h"
(...skipping 16 matching lines...) Expand all
31 using blink::WebFormElement; 33 using blink::WebFormElement;
32 using blink::WebFrame; 34 using blink::WebFrame;
33 using blink::WebLocalFrame; 35 using blink::WebLocalFrame;
34 using blink::WebInputElement; 36 using blink::WebInputElement;
35 using blink::WebString; 37 using blink::WebString;
36 using blink::WebURLRequest; 38 using blink::WebURLRequest;
37 using blink::WebVector; 39 using blink::WebVector;
38 40
39 namespace autofill { 41 namespace autofill {
40 42
41 typedef base::Tuple<int, autofill::FormData, autofill::FormFieldData, 43 typedef std::tuple<int, autofill::FormData, autofill::FormFieldData,
danakj 2016/03/08 18:22:24 nit: using
tzik 2016/03/09 05:26:51 Done.
42 gfx::RectF> AutofillQueryParam; 44 gfx::RectF> AutofillQueryParam;
43 45
44 class AutofillRendererTest : public ChromeRenderViewTest { 46 class AutofillRendererTest : public ChromeRenderViewTest {
45 public: 47 public:
46 AutofillRendererTest() {} 48 AutofillRendererTest() {}
47 ~AutofillRendererTest() override {} 49 ~AutofillRendererTest() override {}
48 50
49 protected: 51 protected:
50 void SetUp() override { 52 void SetUp() override {
51 ChromeRenderViewTest::SetUp(); 53 ChromeRenderViewTest::SetUp();
52 54
(...skipping 27 matching lines...) Expand all
80 " <option>Texas</option>" 82 " <option>Texas</option>"
81 " </select>" 83 " </select>"
82 "</form>"); 84 "</form>");
83 85
84 // Verify that "FormsSeen" sends the expected number of fields. 86 // Verify that "FormsSeen" sends the expected number of fields.
85 const IPC::Message* message = render_thread_->sink().GetFirstMessageMatching( 87 const IPC::Message* message = render_thread_->sink().GetFirstMessageMatching(
86 AutofillHostMsg_FormsSeen::ID); 88 AutofillHostMsg_FormsSeen::ID);
87 ASSERT_NE(nullptr, message); 89 ASSERT_NE(nullptr, message);
88 AutofillHostMsg_FormsSeen::Param params; 90 AutofillHostMsg_FormsSeen::Param params;
89 AutofillHostMsg_FormsSeen::Read(message, &params); 91 AutofillHostMsg_FormsSeen::Read(message, &params);
90 std::vector<FormData> forms = base::get<0>(params); 92 std::vector<FormData> forms = std::get<0>(params);
91 ASSERT_EQ(1UL, forms.size()); 93 ASSERT_EQ(1UL, forms.size());
92 ASSERT_EQ(4UL, forms[0].fields.size()); 94 ASSERT_EQ(4UL, forms[0].fields.size());
93 95
94 FormFieldData expected; 96 FormFieldData expected;
95 97
96 expected.name = ASCIIToUTF16("firstname"); 98 expected.name = ASCIIToUTF16("firstname");
97 expected.value = base::string16(); 99 expected.value = base::string16();
98 expected.form_control_type = "text"; 100 expected.form_control_type = "text";
99 expected.max_length = WebInputElement::defaultMaxLength(); 101 expected.max_length = WebInputElement::defaultMaxLength();
100 EXPECT_FORM_FIELD_DATA_EQUALS(expected, forms[0].fields[0]); 102 EXPECT_FORM_FIELD_DATA_EQUALS(expected, forms[0].fields[0]);
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 "newForm.appendChild(newFirstname);" 145 "newForm.appendChild(newFirstname);"
144 "newForm.appendChild(newLastname);" 146 "newForm.appendChild(newLastname);"
145 "newForm.appendChild(newEmail);" 147 "newForm.appendChild(newEmail);"
146 "document.body.appendChild(newForm);"); 148 "document.body.appendChild(newForm);");
147 msg_loop_.RunUntilIdle(); 149 msg_loop_.RunUntilIdle();
148 150
149 message = render_thread_->sink().GetFirstMessageMatching( 151 message = render_thread_->sink().GetFirstMessageMatching(
150 AutofillHostMsg_FormsSeen::ID); 152 AutofillHostMsg_FormsSeen::ID);
151 ASSERT_NE(nullptr, message); 153 ASSERT_NE(nullptr, message);
152 AutofillHostMsg_FormsSeen::Read(message, &params); 154 AutofillHostMsg_FormsSeen::Read(message, &params);
153 forms = base::get<0>(params); 155 forms = std::get<0>(params);
154 ASSERT_EQ(1UL, forms.size()); 156 ASSERT_EQ(1UL, forms.size());
155 ASSERT_EQ(3UL, forms[0].fields.size()); 157 ASSERT_EQ(3UL, forms[0].fields.size());
156 158
157 expected.form_control_type = "text"; 159 expected.form_control_type = "text";
158 expected.max_length = WebInputElement::defaultMaxLength(); 160 expected.max_length = WebInputElement::defaultMaxLength();
159 161
160 expected.name = ASCIIToUTF16("second_firstname"); 162 expected.name = ASCIIToUTF16("second_firstname");
161 expected.value = ASCIIToUTF16("Bob"); 163 expected.value = ASCIIToUTF16("Bob");
162 EXPECT_FORM_FIELD_DATA_EQUALS(expected, forms[0].fields[0]); 164 EXPECT_FORM_FIELD_DATA_EQUALS(expected, forms[0].fields[0]);
163 165
(...skipping 11 matching lines...) Expand all
175 " <input type='text' id='firstname'/>" 177 " <input type='text' id='firstname'/>"
176 " <input type='text' id='middlename'/>" 178 " <input type='text' id='middlename'/>"
177 "</form>"); 179 "</form>");
178 180
179 // Verify that "FormsSeen" isn't sent, as there are too few fields. 181 // Verify that "FormsSeen" isn't sent, as there are too few fields.
180 const IPC::Message* message = render_thread_->sink().GetFirstMessageMatching( 182 const IPC::Message* message = render_thread_->sink().GetFirstMessageMatching(
181 AutofillHostMsg_FormsSeen::ID); 183 AutofillHostMsg_FormsSeen::ID);
182 ASSERT_NE(nullptr, message); 184 ASSERT_NE(nullptr, message);
183 AutofillHostMsg_FormsSeen::Param params; 185 AutofillHostMsg_FormsSeen::Param params;
184 AutofillHostMsg_FormsSeen::Read(message, &params); 186 AutofillHostMsg_FormsSeen::Read(message, &params);
185 const std::vector<FormData>& forms = base::get<0>(params); 187 const std::vector<FormData>& forms = std::get<0>(params);
186 ASSERT_EQ(0UL, forms.size()); 188 ASSERT_EQ(0UL, forms.size());
187 } 189 }
188 190
189 // Regression test for [ http://crbug.com/346010 ]. 191 // Regression test for [ http://crbug.com/346010 ].
190 TEST_F(AutofillRendererTest, DontCrashWhileAssociatingForms) { 192 TEST_F(AutofillRendererTest, DontCrashWhileAssociatingForms) {
191 LoadHTML("<form id='form'>" 193 LoadHTML("<form id='form'>"
192 "<foo id='foo'>" 194 "<foo id='foo'>"
193 "<script id='script'>" 195 "<script id='script'>"
194 "document.documentElement.appendChild(foo);" 196 "document.documentElement.appendChild(foo);"
195 "newDoc = document.implementation.createDocument(" 197 "newDoc = document.implementation.createDocument("
(...skipping 12 matching lines...) Expand all
208 base::FilePath(FILE_PATH_LITERAL("autofill_noform_dynamic.html"))); 210 base::FilePath(FILE_PATH_LITERAL("autofill_noform_dynamic.html")));
209 ASSERT_TRUE(base::ReadFileToString(test_path, &html_data)); 211 ASSERT_TRUE(base::ReadFileToString(test_path, &html_data));
210 LoadHTML(html_data.c_str()); 212 LoadHTML(html_data.c_str());
211 213
212 // Verify that "FormsSeen" sends the expected number of fields. 214 // Verify that "FormsSeen" sends the expected number of fields.
213 const IPC::Message* message = render_thread_->sink().GetFirstMessageMatching( 215 const IPC::Message* message = render_thread_->sink().GetFirstMessageMatching(
214 AutofillHostMsg_FormsSeen::ID); 216 AutofillHostMsg_FormsSeen::ID);
215 ASSERT_NE(nullptr, message); 217 ASSERT_NE(nullptr, message);
216 AutofillHostMsg_FormsSeen::Param params; 218 AutofillHostMsg_FormsSeen::Param params;
217 AutofillHostMsg_FormsSeen::Read(message, &params); 219 AutofillHostMsg_FormsSeen::Read(message, &params);
218 std::vector<FormData> forms = base::get<0>(params); 220 std::vector<FormData> forms = std::get<0>(params);
219 ASSERT_EQ(1UL, forms.size()); 221 ASSERT_EQ(1UL, forms.size());
220 ASSERT_EQ(7UL, forms[0].fields.size()); 222 ASSERT_EQ(7UL, forms[0].fields.size());
221 223
222 render_thread_->sink().ClearMessages(); 224 render_thread_->sink().ClearMessages();
223 225
224 ExecuteJavaScriptForTests("AddFields()"); 226 ExecuteJavaScriptForTests("AddFields()");
225 msg_loop_.RunUntilIdle(); 227 msg_loop_.RunUntilIdle();
226 228
227 message = render_thread_->sink().GetFirstMessageMatching( 229 message = render_thread_->sink().GetFirstMessageMatching(
228 AutofillHostMsg_FormsSeen::ID); 230 AutofillHostMsg_FormsSeen::ID);
229 ASSERT_NE(nullptr, message); 231 ASSERT_NE(nullptr, message);
230 AutofillHostMsg_FormsSeen::Read(message, &params); 232 AutofillHostMsg_FormsSeen::Read(message, &params);
231 forms = base::get<0>(params); 233 forms = std::get<0>(params);
232 ASSERT_EQ(1UL, forms.size()); 234 ASSERT_EQ(1UL, forms.size());
233 ASSERT_EQ(9UL, forms[0].fields.size()); 235 ASSERT_EQ(9UL, forms[0].fields.size());
234 236
235 FormFieldData expected; 237 FormFieldData expected;
236 238
237 expected.name = ASCIIToUTF16("EMAIL_ADDRESS"); 239 expected.name = ASCIIToUTF16("EMAIL_ADDRESS");
238 expected.value.clear(); 240 expected.value.clear();
239 expected.form_control_type = "text"; 241 expected.form_control_type = "text";
240 expected.max_length = WebInputElement::defaultMaxLength(); 242 expected.max_length = WebInputElement::defaultMaxLength();
241 EXPECT_FORM_FIELD_DATA_EQUALS(expected, forms[0].fields[7]); 243 EXPECT_FORM_FIELD_DATA_EQUALS(expected, forms[0].fields[7]);
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 }; 346 };
345 347
346 TEST_F(RequestAutocompleteRendererTest, InvokingTwiceOnlyShowsOnce) { 348 TEST_F(RequestAutocompleteRendererTest, InvokingTwiceOnlyShowsOnce) {
347 // Attempting to show the requestAutocomplete dialog again should be ignored. 349 // Attempting to show the requestAutocomplete dialog again should be ignored.
348 invoking_frame_->autofillClient()->didRequestAutocomplete(invoking_form()); 350 invoking_frame_->autofillClient()->didRequestAutocomplete(invoking_form());
349 EXPECT_FALSE(render_thread_->sink().GetFirstMessageMatching( 351 EXPECT_FALSE(render_thread_->sink().GetFirstMessageMatching(
350 AutofillHostMsg_RequestAutocomplete::ID)); 352 AutofillHostMsg_RequestAutocomplete::ID));
351 } 353 }
352 354
353 } // namespace autofill 355 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698