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

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

Issue 1123783002: Add ExecuteJavaScriptForTest and make all tests use it (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 years, 5 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 "base/command_line.h" 5 #include "base/command_line.h"
6 #include "base/files/file_util.h" 6 #include "base/files/file_util.h"
7 #include "base/strings/stringprintf.h" 7 #include "base/strings/stringprintf.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "chrome/test/base/chrome_render_view_test.h" 9 #include "chrome/test/base/chrome_render_view_test.h"
10 #include "chrome/test/base/ui_test_utils.h" 10 #include "chrome/test/base/ui_test_utils.h"
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 expected.name = ASCIIToUTF16("state"); 115 expected.name = ASCIIToUTF16("state");
116 expected.value = ASCIIToUTF16("?"); 116 expected.value = ASCIIToUTF16("?");
117 expected.form_control_type = "select-one"; 117 expected.form_control_type = "select-one";
118 expected.max_length = 0; 118 expected.max_length = 0;
119 EXPECT_FORM_FIELD_DATA_EQUALS(expected, forms[0].fields[3]); 119 EXPECT_FORM_FIELD_DATA_EQUALS(expected, forms[0].fields[3]);
120 120
121 render_thread_->sink().ClearMessages(); 121 render_thread_->sink().ClearMessages();
122 122
123 // Dynamically create a new form. A new message should be sent for it, but 123 // Dynamically create a new form. A new message should be sent for it, but
124 // not for the previous form. 124 // not for the previous form.
125 ExecuteJavaScript( 125 ExecuteJavaScriptForTests(
126 "var newForm=document.createElement('form');" 126 "var newForm=document.createElement('form');"
127 "newForm.id='new_testform';" 127 "newForm.id='new_testform';"
128 "newForm.action='http://google.com';" 128 "newForm.action='http://google.com';"
129 "newForm.method='post';" 129 "newForm.method='post';"
130 "var newFirstname=document.createElement('input');" 130 "var newFirstname=document.createElement('input');"
131 "newFirstname.setAttribute('type', 'text');" 131 "newFirstname.setAttribute('type', 'text');"
132 "newFirstname.setAttribute('id', 'second_firstname');" 132 "newFirstname.setAttribute('id', 'second_firstname');"
133 "newFirstname.value = 'Bob';" 133 "newFirstname.value = 'Bob';"
134 "var newLastname=document.createElement('input');" 134 "var newLastname=document.createElement('input');"
135 "newLastname.setAttribute('type', 'text');" 135 "newLastname.setAttribute('type', 'text');"
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 AutofillHostMsg_FormsSeen::ID); 213 AutofillHostMsg_FormsSeen::ID);
214 ASSERT_NE(nullptr, message); 214 ASSERT_NE(nullptr, message);
215 AutofillHostMsg_FormsSeen::Param params; 215 AutofillHostMsg_FormsSeen::Param params;
216 AutofillHostMsg_FormsSeen::Read(message, &params); 216 AutofillHostMsg_FormsSeen::Read(message, &params);
217 std::vector<FormData> forms = base::get<0>(params); 217 std::vector<FormData> forms = base::get<0>(params);
218 ASSERT_EQ(1UL, forms.size()); 218 ASSERT_EQ(1UL, forms.size());
219 ASSERT_EQ(7UL, forms[0].fields.size()); 219 ASSERT_EQ(7UL, forms[0].fields.size());
220 220
221 render_thread_->sink().ClearMessages(); 221 render_thread_->sink().ClearMessages();
222 222
223 ExecuteJavaScript("AddFields()"); 223 ExecuteJavaScriptForTests("AddFields()");
224 msg_loop_.RunUntilIdle(); 224 msg_loop_.RunUntilIdle();
225 225
226 message = render_thread_->sink().GetFirstMessageMatching( 226 message = render_thread_->sink().GetFirstMessageMatching(
227 AutofillHostMsg_FormsSeen::ID); 227 AutofillHostMsg_FormsSeen::ID);
228 ASSERT_NE(nullptr, message); 228 ASSERT_NE(nullptr, message);
229 AutofillHostMsg_FormsSeen::Read(message, &params); 229 AutofillHostMsg_FormsSeen::Read(message, &params);
230 forms = base::get<0>(params); 230 forms = base::get<0>(params);
231 ASSERT_EQ(1UL, forms.size()); 231 ASSERT_EQ(1UL, forms.size());
232 ASSERT_EQ(9UL, forms[0].fields.size()); 232 ASSERT_EQ(9UL, forms[0].fields.size());
233 233
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 }; 344 };
345 345
346 TEST_F(RequestAutocompleteRendererTest, InvokingTwiceOnlyShowsOnce) { 346 TEST_F(RequestAutocompleteRendererTest, InvokingTwiceOnlyShowsOnce) {
347 // Attempting to show the requestAutocomplete dialog again should be ignored. 347 // Attempting to show the requestAutocomplete dialog again should be ignored.
348 invoking_frame_->autofillClient()->didRequestAutocomplete(invoking_form()); 348 invoking_frame_->autofillClient()->didRequestAutocomplete(invoking_form());
349 EXPECT_FALSE(render_thread_->sink().GetFirstMessageMatching( 349 EXPECT_FALSE(render_thread_->sink().GetFirstMessageMatching(
350 AutofillHostMsg_RequestAutocomplete::ID)); 350 AutofillHostMsg_RequestAutocomplete::ID));
351 } 351 }
352 352
353 } // namespace autofill 353 } // namespace autofill
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/web_ui_test_handler.cc ('k') | chrome/renderer/autofill/form_autocomplete_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698