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

Side by Side Diff: chrome/browser/autofill/autofill_browsertest.cc

Issue 7327007: Moving notification types which are chrome specific to a new header file chrome_notification_type... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 <string> 5 #include <string>
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/memory/ref_counted.h" 8 #include "base/memory/ref_counted.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/string16.h" 10 #include "base/string16.h"
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 } 176 }
177 177
178 void TryBasicFormFill() { 178 void TryBasicFormFill() {
179 FocusFirstNameField(); 179 FocusFirstNameField();
180 180
181 // Start filling the first name field with "M" and wait for the popup to be 181 // Start filling the first name field with "M" and wait for the popup to be
182 // shown. 182 // shown.
183 LOG(WARNING) << "Typing 'M' to bring up the Autofill popup."; 183 LOG(WARNING) << "Typing 'M' to bring up the Autofill popup.";
184 ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait( 184 ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait(
185 browser(), ui::VKEY_M, false, true, false, false, 185 browser(), ui::VKEY_M, false, true, false, false,
186 NotificationType::AUTOFILL_DID_SHOW_SUGGESTIONS, 186 chrome::AUTOFILL_DID_SHOW_SUGGESTIONS,
187 Source<RenderViewHost>(render_view_host()))); 187 Source<RenderViewHost>(render_view_host())));
188 188
189 // Press the down arrow to select the suggestion and preview the autofilled 189 // Press the down arrow to select the suggestion and preview the autofilled
190 // form. 190 // form.
191 LOG(WARNING) << "Simulating down arrow press to initiate Autofill preview."; 191 LOG(WARNING) << "Simulating down arrow press to initiate Autofill preview.";
192 ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait( 192 ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait(
193 browser(), ui::VKEY_DOWN, false, false, false, false, 193 browser(), ui::VKEY_DOWN, false, false, false, false,
194 NotificationType::AUTOFILL_DID_FILL_FORM_DATA, 194 chrome::AUTOFILL_DID_FILL_FORM_DATA,
195 Source<RenderViewHost>(render_view_host()))); 195 Source<RenderViewHost>(render_view_host())));
196 196
197 // The previewed values should not be accessible to JavaScript. 197 // The previewed values should not be accessible to JavaScript.
198 ExpectFieldValue(L"firstname", "M"); 198 ExpectFieldValue(L"firstname", "M");
199 ExpectFieldValue(L"lastname", ""); 199 ExpectFieldValue(L"lastname", "");
200 ExpectFieldValue(L"address1", ""); 200 ExpectFieldValue(L"address1", "");
201 ExpectFieldValue(L"address2", ""); 201 ExpectFieldValue(L"address2", "");
202 ExpectFieldValue(L"city", ""); 202 ExpectFieldValue(L"city", "");
203 ExpectFieldValue(L"state", ""); 203 ExpectFieldValue(L"state", "");
204 ExpectFieldValue(L"zip", ""); 204 ExpectFieldValue(L"zip", "");
205 ExpectFieldValue(L"country", ""); 205 ExpectFieldValue(L"country", "");
206 ExpectFieldValue(L"phone", ""); 206 ExpectFieldValue(L"phone", "");
207 // TODO(isherman): It would be nice to test that the previewed values are 207 // TODO(isherman): It would be nice to test that the previewed values are
208 // displayed: http://crbug.com/57220 208 // displayed: http://crbug.com/57220
209 209
210 // Press Enter to accept the autofill suggestions. 210 // Press Enter to accept the autofill suggestions.
211 LOG(WARNING) << "Simulating Return press to fill the form."; 211 LOG(WARNING) << "Simulating Return press to fill the form.";
212 ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait( 212 ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait(
213 browser(), ui::VKEY_RETURN, false, false, false, false, 213 browser(), ui::VKEY_RETURN, false, false, false, false,
214 NotificationType::AUTOFILL_DID_FILL_FORM_DATA, 214 chrome::AUTOFILL_DID_FILL_FORM_DATA,
215 Source<RenderViewHost>(render_view_host()))); 215 Source<RenderViewHost>(render_view_host())));
216 216
217 // The form should be filled. 217 // The form should be filled.
218 ExpectFilledTestForm(); 218 ExpectFilledTestForm();
219 } 219 }
220 220
221 private: 221 private:
222 TestURLFetcherFactory url_fetcher_factory_; 222 TestURLFetcherFactory url_fetcher_factory_;
223 }; 223 };
224 224
(...skipping 19 matching lines...) Expand all
244 ASSERT_NO_FATAL_FAILURE(ui_test_utils::NavigateToURL(browser(), 244 ASSERT_NO_FATAL_FAILURE(ui_test_utils::NavigateToURL(browser(),
245 GURL(std::string(kDataURIPrefix) + kTestFormString))); 245 GURL(std::string(kDataURIPrefix) + kTestFormString)));
246 246
247 // Focus a fillable field. 247 // Focus a fillable field.
248 FocusFirstNameField(); 248 FocusFirstNameField();
249 249
250 // Press the down arrow to initiate Autofill and wait for the popup to be 250 // Press the down arrow to initiate Autofill and wait for the popup to be
251 // shown. 251 // shown.
252 ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait( 252 ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait(
253 browser(), ui::VKEY_DOWN, false, false, false, false, 253 browser(), ui::VKEY_DOWN, false, false, false, false,
254 NotificationType::AUTOFILL_DID_SHOW_SUGGESTIONS, 254 chrome::AUTOFILL_DID_SHOW_SUGGESTIONS,
255 Source<RenderViewHost>(render_view_host()))); 255 Source<RenderViewHost>(render_view_host())));
256 256
257 // Press the down arrow to select the suggestion and preview the autofilled 257 // Press the down arrow to select the suggestion and preview the autofilled
258 // form. 258 // form.
259 ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait( 259 ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait(
260 browser(), ui::VKEY_DOWN, false, false, false, false, 260 browser(), ui::VKEY_DOWN, false, false, false, false,
261 NotificationType::AUTOFILL_DID_FILL_FORM_DATA, 261 chrome::AUTOFILL_DID_FILL_FORM_DATA,
262 Source<RenderViewHost>(render_view_host()))); 262 Source<RenderViewHost>(render_view_host())));
263 263
264 // Press Enter to accept the autofill suggestions. 264 // Press Enter to accept the autofill suggestions.
265 ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait( 265 ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait(
266 browser(), ui::VKEY_RETURN, false, false, false, false, 266 browser(), ui::VKEY_RETURN, false, false, false, false,
267 NotificationType::AUTOFILL_DID_FILL_FORM_DATA, 267 chrome::AUTOFILL_DID_FILL_FORM_DATA,
268 Source<RenderViewHost>(render_view_host()))); 268 Source<RenderViewHost>(render_view_host())));
269 269
270 // The form should be filled. 270 // The form should be filled.
271 ExpectFilledTestForm(); 271 ExpectFilledTestForm();
272 } 272 }
273 273
274 // Test that a JavaScript onchange event is fired after auto-filling a form. 274 // Test that a JavaScript onchange event is fired after auto-filling a form.
275 IN_PROC_BROWSER_TEST_F(AutofillTest, OnChangeAfterAutofill) { 275 IN_PROC_BROWSER_TEST_F(AutofillTest, OnChangeAfterAutofill) {
276 CreateTestProfile(); 276 CreateTestProfile();
277 277
(...skipping 23 matching lines...) Expand all
301 ASSERT_NO_FATAL_FAILURE(ui_test_utils::NavigateToURL(browser(), 301 ASSERT_NO_FATAL_FAILURE(ui_test_utils::NavigateToURL(browser(),
302 GURL(std::string(kDataURIPrefix) + kTestFormString + kOnChangeScript))); 302 GURL(std::string(kDataURIPrefix) + kTestFormString + kOnChangeScript)));
303 303
304 // Invoke Autofill. 304 // Invoke Autofill.
305 FocusFirstNameField(); 305 FocusFirstNameField();
306 306
307 // Start filling the first name field with "M" and wait for the popup to be 307 // Start filling the first name field with "M" and wait for the popup to be
308 // shown. 308 // shown.
309 ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait( 309 ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait(
310 browser(), ui::VKEY_M, false, true, false, false, 310 browser(), ui::VKEY_M, false, true, false, false,
311 NotificationType::AUTOFILL_DID_SHOW_SUGGESTIONS, 311 chrome::AUTOFILL_DID_SHOW_SUGGESTIONS,
312 Source<RenderViewHost>(render_view_host()))); 312 Source<RenderViewHost>(render_view_host())));
313 313
314 // Press the down arrow to select the suggestion and preview the autofilled 314 // Press the down arrow to select the suggestion and preview the autofilled
315 // form. 315 // form.
316 ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait( 316 ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait(
317 browser(), ui::VKEY_DOWN, false, false, false, false, 317 browser(), ui::VKEY_DOWN, false, false, false, false,
318 NotificationType::AUTOFILL_DID_FILL_FORM_DATA, 318 chrome::AUTOFILL_DID_FILL_FORM_DATA,
319 Source<RenderViewHost>(render_view_host()))); 319 Source<RenderViewHost>(render_view_host())));
320 320
321 // Press Enter to accept the autofill suggestions. 321 // Press Enter to accept the autofill suggestions.
322 ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait( 322 ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait(
323 browser(), ui::VKEY_RETURN, false, false, false, false, 323 browser(), ui::VKEY_RETURN, false, false, false, false,
324 NotificationType::AUTOFILL_DID_FILL_FORM_DATA, 324 chrome::AUTOFILL_DID_FILL_FORM_DATA,
325 Source<RenderViewHost>(render_view_host()))); 325 Source<RenderViewHost>(render_view_host())));
326 326
327 // The form should be filled. 327 // The form should be filled.
328 ExpectFilledTestForm(); 328 ExpectFilledTestForm();
329 329
330 // The change event should have already fired for unfocused fields, both of 330 // The change event should have already fired for unfocused fields, both of
331 // <input> and of <select> type. However, it should not yet have fired for the 331 // <input> and of <select> type. However, it should not yet have fired for the
332 // focused field. 332 // focused field.
333 bool focused_fired = false; 333 bool focused_fired = false;
334 bool unfocused_fired = false; 334 bool unfocused_fired = false;
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
477 SimulateURLFetch(true); 477 SimulateURLFetch(true);
478 478
479 // Simulate translation to kick onTranslateElementLoad. 479 // Simulate translation to kick onTranslateElementLoad.
480 // But right now, the call stucks here. 480 // But right now, the call stucks here.
481 // Once click the text field, it starts again. 481 // Once click the text field, it starts again.
482 ASSERT_TRUE(ui_test_utils::ExecuteJavaScript( 482 ASSERT_TRUE(ui_test_utils::ExecuteJavaScript(
483 render_view_host(), L"", 483 render_view_host(), L"",
484 L"cr.googleTranslate.onTranslateElementLoad();")); 484 L"cr.googleTranslate.onTranslateElementLoad();"));
485 485
486 // Simulate the render notifying the translation has been done. 486 // Simulate the render notifying the translation has been done.
487 ui_test_utils::WaitForNotification(NotificationType::PAGE_TRANSLATED); 487 ui_test_utils::WaitForNotification(chrome::PAGE_TRANSLATED);
488 488
489 TryBasicFormFill(); 489 TryBasicFormFill();
490 } 490 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698