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

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"
11 #include "base/utf_string_conversions.h" 11 #include "base/utf_string_conversions.h"
12 #include "chrome/browser/autofill/autofill_common_test.h" 12 #include "chrome/browser/autofill/autofill_common_test.h"
13 #include "chrome/browser/autofill/autofill_profile.h" 13 #include "chrome/browser/autofill/autofill_profile.h"
14 #include "chrome/browser/autofill/personal_data_manager.h" 14 #include "chrome/browser/autofill/personal_data_manager.h"
15 #include "chrome/browser/net/predictor_api.h" 15 #include "chrome/browser/net/predictor_api.h"
16 #include "chrome/browser/profiles/profile.h" 16 #include "chrome/browser/profiles/profile.h"
17 #include "chrome/browser/translate/translate_infobar_delegate.h" 17 #include "chrome/browser/translate/translate_infobar_delegate.h"
18 #include "chrome/browser/translate/translate_manager.h" 18 #include "chrome/browser/translate/translate_manager.h"
19 #include "chrome/browser/ui/browser.h" 19 #include "chrome/browser/ui/browser.h"
20 #include "chrome/browser/ui/browser_window.h" 20 #include "chrome/browser/ui/browser_window.h"
21 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 21 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
22 #include "chrome/common/chrome_notification_types.h"
22 #include "chrome/common/render_messages.h" 23 #include "chrome/common/render_messages.h"
23 #include "chrome/renderer/translate_helper.h" 24 #include "chrome/renderer/translate_helper.h"
24 #include "chrome/test/in_process_browser_test.h" 25 #include "chrome/test/in_process_browser_test.h"
25 #include "chrome/test/ui_test_utils.h" 26 #include "chrome/test/ui_test_utils.h"
26 #include "content/browser/renderer_host/mock_render_process_host.h" 27 #include "content/browser/renderer_host/mock_render_process_host.h"
27 #include "content/browser/renderer_host/render_view_host.h" 28 #include "content/browser/renderer_host/render_view_host.h"
28 #include "content/browser/tab_contents/tab_contents.h" 29 #include "content/browser/tab_contents/tab_contents.h"
29 #include "content/common/test_url_fetcher_factory.h" 30 #include "content/common/test_url_fetcher_factory.h"
30 #include "testing/gtest/include/gtest/gtest.h" 31 #include "testing/gtest/include/gtest/gtest.h"
31 #include "ui/base/keycodes/keyboard_codes.h" 32 #include "ui/base/keycodes/keyboard_codes.h"
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 } 177 }
177 178
178 void TryBasicFormFill() { 179 void TryBasicFormFill() {
179 FocusFirstNameField(); 180 FocusFirstNameField();
180 181
181 // Start filling the first name field with "M" and wait for the popup to be 182 // Start filling the first name field with "M" and wait for the popup to be
182 // shown. 183 // shown.
183 LOG(WARNING) << "Typing 'M' to bring up the Autofill popup."; 184 LOG(WARNING) << "Typing 'M' to bring up the Autofill popup.";
184 ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait( 185 ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait(
185 browser(), ui::VKEY_M, false, true, false, false, 186 browser(), ui::VKEY_M, false, true, false, false,
186 NotificationType::AUTOFILL_DID_SHOW_SUGGESTIONS, 187 chrome::NOTIFICATION_AUTOFILL_DID_SHOW_SUGGESTIONS,
187 Source<RenderViewHost>(render_view_host()))); 188 Source<RenderViewHost>(render_view_host())));
188 189
189 // Press the down arrow to select the suggestion and preview the autofilled 190 // Press the down arrow to select the suggestion and preview the autofilled
190 // form. 191 // form.
191 LOG(WARNING) << "Simulating down arrow press to initiate Autofill preview."; 192 LOG(WARNING) << "Simulating down arrow press to initiate Autofill preview.";
192 ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait( 193 ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait(
193 browser(), ui::VKEY_DOWN, false, false, false, false, 194 browser(), ui::VKEY_DOWN, false, false, false, false,
194 NotificationType::AUTOFILL_DID_FILL_FORM_DATA, 195 chrome::NOTIFICATION_AUTOFILL_DID_FILL_FORM_DATA,
195 Source<RenderViewHost>(render_view_host()))); 196 Source<RenderViewHost>(render_view_host())));
196 197
197 // The previewed values should not be accessible to JavaScript. 198 // The previewed values should not be accessible to JavaScript.
198 ExpectFieldValue(L"firstname", "M"); 199 ExpectFieldValue(L"firstname", "M");
199 ExpectFieldValue(L"lastname", ""); 200 ExpectFieldValue(L"lastname", "");
200 ExpectFieldValue(L"address1", ""); 201 ExpectFieldValue(L"address1", "");
201 ExpectFieldValue(L"address2", ""); 202 ExpectFieldValue(L"address2", "");
202 ExpectFieldValue(L"city", ""); 203 ExpectFieldValue(L"city", "");
203 ExpectFieldValue(L"state", ""); 204 ExpectFieldValue(L"state", "");
204 ExpectFieldValue(L"zip", ""); 205 ExpectFieldValue(L"zip", "");
205 ExpectFieldValue(L"country", ""); 206 ExpectFieldValue(L"country", "");
206 ExpectFieldValue(L"phone", ""); 207 ExpectFieldValue(L"phone", "");
207 // TODO(isherman): It would be nice to test that the previewed values are 208 // TODO(isherman): It would be nice to test that the previewed values are
208 // displayed: http://crbug.com/57220 209 // displayed: http://crbug.com/57220
209 210
210 // Press Enter to accept the autofill suggestions. 211 // Press Enter to accept the autofill suggestions.
211 LOG(WARNING) << "Simulating Return press to fill the form."; 212 LOG(WARNING) << "Simulating Return press to fill the form.";
212 ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait( 213 ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait(
213 browser(), ui::VKEY_RETURN, false, false, false, false, 214 browser(), ui::VKEY_RETURN, false, false, false, false,
214 NotificationType::AUTOFILL_DID_FILL_FORM_DATA, 215 chrome::NOTIFICATION_AUTOFILL_DID_FILL_FORM_DATA,
215 Source<RenderViewHost>(render_view_host()))); 216 Source<RenderViewHost>(render_view_host())));
216 217
217 // The form should be filled. 218 // The form should be filled.
218 ExpectFilledTestForm(); 219 ExpectFilledTestForm();
219 } 220 }
220 221
221 private: 222 private:
222 TestURLFetcherFactory url_fetcher_factory_; 223 TestURLFetcherFactory url_fetcher_factory_;
223 }; 224 };
224 225
(...skipping 19 matching lines...) Expand all
244 ASSERT_NO_FATAL_FAILURE(ui_test_utils::NavigateToURL(browser(), 245 ASSERT_NO_FATAL_FAILURE(ui_test_utils::NavigateToURL(browser(),
245 GURL(std::string(kDataURIPrefix) + kTestFormString))); 246 GURL(std::string(kDataURIPrefix) + kTestFormString)));
246 247
247 // Focus a fillable field. 248 // Focus a fillable field.
248 FocusFirstNameField(); 249 FocusFirstNameField();
249 250
250 // Press the down arrow to initiate Autofill and wait for the popup to be 251 // Press the down arrow to initiate Autofill and wait for the popup to be
251 // shown. 252 // shown.
252 ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait( 253 ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait(
253 browser(), ui::VKEY_DOWN, false, false, false, false, 254 browser(), ui::VKEY_DOWN, false, false, false, false,
254 NotificationType::AUTOFILL_DID_SHOW_SUGGESTIONS, 255 chrome::NOTIFICATION_AUTOFILL_DID_SHOW_SUGGESTIONS,
255 Source<RenderViewHost>(render_view_host()))); 256 Source<RenderViewHost>(render_view_host())));
256 257
257 // Press the down arrow to select the suggestion and preview the autofilled 258 // Press the down arrow to select the suggestion and preview the autofilled
258 // form. 259 // form.
259 ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait( 260 ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait(
260 browser(), ui::VKEY_DOWN, false, false, false, false, 261 browser(), ui::VKEY_DOWN, false, false, false, false,
261 NotificationType::AUTOFILL_DID_FILL_FORM_DATA, 262 chrome::NOTIFICATION_AUTOFILL_DID_FILL_FORM_DATA,
262 Source<RenderViewHost>(render_view_host()))); 263 Source<RenderViewHost>(render_view_host())));
263 264
264 // Press Enter to accept the autofill suggestions. 265 // Press Enter to accept the autofill suggestions.
265 ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait( 266 ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait(
266 browser(), ui::VKEY_RETURN, false, false, false, false, 267 browser(), ui::VKEY_RETURN, false, false, false, false,
267 NotificationType::AUTOFILL_DID_FILL_FORM_DATA, 268 chrome::NOTIFICATION_AUTOFILL_DID_FILL_FORM_DATA,
268 Source<RenderViewHost>(render_view_host()))); 269 Source<RenderViewHost>(render_view_host())));
269 270
270 // The form should be filled. 271 // The form should be filled.
271 ExpectFilledTestForm(); 272 ExpectFilledTestForm();
272 } 273 }
273 274
274 // Test that a JavaScript onchange event is fired after auto-filling a form. 275 // Test that a JavaScript onchange event is fired after auto-filling a form.
275 IN_PROC_BROWSER_TEST_F(AutofillTest, OnChangeAfterAutofill) { 276 IN_PROC_BROWSER_TEST_F(AutofillTest, OnChangeAfterAutofill) {
276 CreateTestProfile(); 277 CreateTestProfile();
277 278
(...skipping 23 matching lines...) Expand all
301 ASSERT_NO_FATAL_FAILURE(ui_test_utils::NavigateToURL(browser(), 302 ASSERT_NO_FATAL_FAILURE(ui_test_utils::NavigateToURL(browser(),
302 GURL(std::string(kDataURIPrefix) + kTestFormString + kOnChangeScript))); 303 GURL(std::string(kDataURIPrefix) + kTestFormString + kOnChangeScript)));
303 304
304 // Invoke Autofill. 305 // Invoke Autofill.
305 FocusFirstNameField(); 306 FocusFirstNameField();
306 307
307 // Start filling the first name field with "M" and wait for the popup to be 308 // Start filling the first name field with "M" and wait for the popup to be
308 // shown. 309 // shown.
309 ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait( 310 ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait(
310 browser(), ui::VKEY_M, false, true, false, false, 311 browser(), ui::VKEY_M, false, true, false, false,
311 NotificationType::AUTOFILL_DID_SHOW_SUGGESTIONS, 312 chrome::NOTIFICATION_AUTOFILL_DID_SHOW_SUGGESTIONS,
312 Source<RenderViewHost>(render_view_host()))); 313 Source<RenderViewHost>(render_view_host())));
313 314
314 // Press the down arrow to select the suggestion and preview the autofilled 315 // Press the down arrow to select the suggestion and preview the autofilled
315 // form. 316 // form.
316 ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait( 317 ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait(
317 browser(), ui::VKEY_DOWN, false, false, false, false, 318 browser(), ui::VKEY_DOWN, false, false, false, false,
318 NotificationType::AUTOFILL_DID_FILL_FORM_DATA, 319 chrome::NOTIFICATION_AUTOFILL_DID_FILL_FORM_DATA,
319 Source<RenderViewHost>(render_view_host()))); 320 Source<RenderViewHost>(render_view_host())));
320 321
321 // Press Enter to accept the autofill suggestions. 322 // Press Enter to accept the autofill suggestions.
322 ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait( 323 ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait(
323 browser(), ui::VKEY_RETURN, false, false, false, false, 324 browser(), ui::VKEY_RETURN, false, false, false, false,
324 NotificationType::AUTOFILL_DID_FILL_FORM_DATA, 325 chrome::NOTIFICATION_AUTOFILL_DID_FILL_FORM_DATA,
325 Source<RenderViewHost>(render_view_host()))); 326 Source<RenderViewHost>(render_view_host())));
326 327
327 // The form should be filled. 328 // The form should be filled.
328 ExpectFilledTestForm(); 329 ExpectFilledTestForm();
329 330
330 // The change event should have already fired for unfocused fields, both of 331 // 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 332 // <input> and of <select> type. However, it should not yet have fired for the
332 // focused field. 333 // focused field.
333 bool focused_fired = false; 334 bool focused_fired = false;
334 bool unfocused_fired = false; 335 bool unfocused_fired = false;
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
477 SimulateURLFetch(true); 478 SimulateURLFetch(true);
478 479
479 // Simulate translation to kick onTranslateElementLoad. 480 // Simulate translation to kick onTranslateElementLoad.
480 // But right now, the call stucks here. 481 // But right now, the call stucks here.
481 // Once click the text field, it starts again. 482 // Once click the text field, it starts again.
482 ASSERT_TRUE(ui_test_utils::ExecuteJavaScript( 483 ASSERT_TRUE(ui_test_utils::ExecuteJavaScript(
483 render_view_host(), L"", 484 render_view_host(), L"",
484 L"cr.googleTranslate.onTranslateElementLoad();")); 485 L"cr.googleTranslate.onTranslateElementLoad();"));
485 486
486 // Simulate the render notifying the translation has been done. 487 // Simulate the render notifying the translation has been done.
487 ui_test_utils::WaitForNotification(NotificationType::PAGE_TRANSLATED); 488 ui_test_utils::WaitForNotification(chrome::NOTIFICATION_PAGE_TRANSLATED);
488 489
489 TryBasicFormFill(); 490 TryBasicFormFill();
490 } 491 }
OLDNEW
« no previous file with comments | « chrome/browser/autocomplete/shortcuts_provider.cc ('k') | chrome/browser/autofill/autofill_feedback_infobar_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698