OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 <stdio.h> | 5 #include <stdio.h> |
6 | 6 |
7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
8 #include "base/string16.h" | 8 #include "base/string16.h" |
9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
10 #include "base/time.h" | 10 #include "base/time.h" |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 const wchar_t kSearchSingleCharKeys[] = { ui::VKEY_Z, 0 }; | 58 const wchar_t kSearchSingleCharKeys[] = { ui::VKEY_Z, 0 }; |
59 const char kSearchSingleCharURL[] = "http://www.foo.com/search?q=z"; | 59 const char kSearchSingleCharURL[] = "http://www.foo.com/search?q=z"; |
60 | 60 |
61 const char kHistoryPageURL[] = "chrome://history/#q=abc"; | 61 const char kHistoryPageURL[] = "chrome://history/#q=abc"; |
62 | 62 |
63 const char kDesiredTLDHostname[] = "www.bar.com"; | 63 const char kDesiredTLDHostname[] = "www.bar.com"; |
64 const wchar_t kDesiredTLDKeys[] = { | 64 const wchar_t kDesiredTLDKeys[] = { |
65 ui::VKEY_B, ui::VKEY_A, ui::VKEY_R, 0 | 65 ui::VKEY_B, ui::VKEY_A, ui::VKEY_R, 0 |
66 }; | 66 }; |
67 | 67 |
| 68 const char kInlineAutocompleteText[] = "def"; |
| 69 const wchar_t kInlineAutocompleteTextKeys[] = { |
| 70 ui::VKEY_D, ui::VKEY_E, ui::VKEY_F, 0 |
| 71 }; |
| 72 |
68 // Hostnames that shall be blocked by host resolver. | 73 // Hostnames that shall be blocked by host resolver. |
69 const char *kBlockedHostnames[] = { | 74 const char *kBlockedHostnames[] = { |
70 "foo", | 75 "foo", |
71 "*.foo.com", | 76 "*.foo.com", |
72 "bar", | 77 "bar", |
73 "*.bar.com", | 78 "*.bar.com", |
74 "abc", | 79 "abc", |
75 "*.abc.com", | 80 "*.abc.com", |
| 81 "def", |
| 82 "*.def.com", |
76 "history", | 83 "history", |
77 "z" | 84 "z" |
78 }; | 85 }; |
79 | 86 |
80 const struct TestHistoryEntry { | 87 const struct TestHistoryEntry { |
81 const char* url; | 88 const char* url; |
82 const char* title; | 89 const char* title; |
83 const char* body; | 90 const char* body; |
84 int visit_count; | 91 int visit_count; |
85 int typed_count; | 92 int typed_count; |
86 bool starred; | 93 bool starred; |
87 } kHistoryEntries[] = { | 94 } kHistoryEntries[] = { |
88 {"http://www.bar.com/1", "Page 1", kSearchText, 1, 1, false }, | 95 {"http://www.bar.com/1", "Page 1", kSearchText, 1, 1, false }, |
89 {"http://www.bar.com/2", "Page 2", kSearchText, 1, 1, false }, | 96 {"http://www.bar.com/2", "Page 2", kSearchText, 1, 1, false }, |
90 {"http://www.bar.com/3", "Page 3", kSearchText, 1, 1, false }, | 97 {"http://www.bar.com/3", "Page 3", kSearchText, 1, 1, false }, |
91 {"http://www.bar.com/4", "Page 4", kSearchText, 1, 1, false }, | 98 {"http://www.bar.com/4", "Page 4", kSearchText, 1, 1, false }, |
92 {"http://www.bar.com/5", "Page 5", kSearchText, 1, 1, false }, | 99 {"http://www.bar.com/5", "Page 5", kSearchText, 1, 1, false }, |
93 {"http://www.bar.com/6", "Page 6", kSearchText, 1, 1, false }, | 100 {"http://www.bar.com/6", "Page 6", kSearchText, 1, 1, false }, |
94 {"http://www.bar.com/7", "Page 7", kSearchText, 1, 1, false }, | 101 {"http://www.bar.com/7", "Page 7", kSearchText, 1, 1, false }, |
95 {"http://www.bar.com/8", "Page 8", kSearchText, 1, 1, false }, | 102 {"http://www.bar.com/8", "Page 8", kSearchText, 1, 1, false }, |
96 {"http://www.bar.com/9", "Page 9", kSearchText, 1, 1, false }, | 103 {"http://www.bar.com/9", "Page 9", kSearchText, 1, 1, false }, |
97 | 104 |
98 // To trigger inline autocomplete. | 105 // To trigger inline autocomplete. |
99 {"http://www.abc.com", "Page abc", kSearchText, 10000, 10000, true }, | 106 {"http://www.def.com", "Page def", kSearchText, 10000, 10000, true }, |
100 }; | 107 }; |
101 | 108 |
102 #if defined(OS_LINUX) | 109 #if defined(OS_LINUX) |
103 // Returns the text stored in the PRIMARY clipboard. | 110 // Returns the text stored in the PRIMARY clipboard. |
104 std::string GetPrimarySelectionText() { | 111 std::string GetPrimarySelectionText() { |
105 GtkClipboard* clipboard = gtk_clipboard_get(GDK_SELECTION_PRIMARY); | 112 GtkClipboard* clipboard = gtk_clipboard_get(GDK_SELECTION_PRIMARY); |
106 DCHECK(clipboard); | 113 DCHECK(clipboard); |
107 | 114 |
108 gchar* selection_text = gtk_clipboard_wait_for_text(clipboard); | 115 gchar* selection_text = gtk_clipboard_wait_for_text(clipboard); |
109 std::string result(selection_text ? selection_text : ""); | 116 std::string result(selection_text ? selection_text : ""); |
(...skipping 12 matching lines...) Expand all Loading... |
122 | 129 |
123 } // namespace | 130 } // namespace |
124 | 131 |
125 class AutocompleteEditViewTest : public InProcessBrowserTest, | 132 class AutocompleteEditViewTest : public InProcessBrowserTest, |
126 public NotificationObserver { | 133 public NotificationObserver { |
127 protected: | 134 protected: |
128 AutocompleteEditViewTest() { | 135 AutocompleteEditViewTest() { |
129 set_show_window(true); | 136 set_show_window(true); |
130 } | 137 } |
131 | 138 |
| 139 virtual void SetUpOnMainThread() { |
| 140 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); |
| 141 ASSERT_NO_FATAL_FAILURE(SetupComponents()); |
| 142 browser()->FocusLocationBar(); |
| 143 ASSERT_TRUE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_LOCATION_BAR)); |
| 144 } |
| 145 |
132 static void GetAutocompleteEditViewForBrowser( | 146 static void GetAutocompleteEditViewForBrowser( |
133 const Browser* browser, | 147 const Browser* browser, |
134 AutocompleteEditView** edit_view) { | 148 AutocompleteEditView** edit_view) { |
135 BrowserWindow* window = browser->window(); | 149 BrowserWindow* window = browser->window(); |
136 ASSERT_TRUE(window); | 150 ASSERT_TRUE(window); |
137 LocationBar* loc_bar = window->GetLocationBar(); | 151 LocationBar* loc_bar = window->GetLocationBar(); |
138 ASSERT_TRUE(loc_bar); | 152 ASSERT_TRUE(loc_bar); |
139 *edit_view = loc_bar->location_entry(); | 153 *edit_view = loc_bar->location_entry(); |
140 ASSERT_TRUE(*edit_view); | 154 ASSERT_TRUE(*edit_view); |
141 } | 155 } |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
300 } | 314 } |
301 MessageLoopForUI::current()->Quit(); | 315 MessageLoopForUI::current()->Quit(); |
302 } | 316 } |
303 }; | 317 }; |
304 | 318 |
305 // Test if ctrl-* accelerators are workable in omnibox. | 319 // Test if ctrl-* accelerators are workable in omnibox. |
306 // See http://crbug.com/19193: omnibox blocks ctrl-* commands | 320 // See http://crbug.com/19193: omnibox blocks ctrl-* commands |
307 // | 321 // |
308 // Flaky on interactive tests (dbg), http://crbug.com/69433 | 322 // Flaky on interactive tests (dbg), http://crbug.com/69433 |
309 IN_PROC_BROWSER_TEST_F(AutocompleteEditViewTest, FLAKY_BrowserAccelerators) { | 323 IN_PROC_BROWSER_TEST_F(AutocompleteEditViewTest, FLAKY_BrowserAccelerators) { |
310 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); | |
311 | |
312 browser()->FocusLocationBar(); | |
313 AutocompleteEditView* edit_view = NULL; | 324 AutocompleteEditView* edit_view = NULL; |
314 ASSERT_NO_FATAL_FAILURE(GetAutocompleteEditView(&edit_view)); | 325 ASSERT_NO_FATAL_FAILURE(GetAutocompleteEditView(&edit_view)); |
315 | 326 |
316 int tab_count = browser()->tab_count(); | 327 int tab_count = browser()->tab_count(); |
317 | 328 |
318 // Create a new Tab. | 329 // Create a new Tab. |
319 browser()->NewTab(); | 330 browser()->NewTab(); |
320 ASSERT_NO_FATAL_FAILURE(WaitForTabOpenOrClose(tab_count + 1)); | 331 ASSERT_NO_FATAL_FAILURE(WaitForTabOpenOrClose(tab_count + 1)); |
321 | 332 |
322 // Select the first Tab. | 333 // Select the first Tab. |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
355 | 366 |
356 #if !defined(OS_CHROMEOS) | 367 #if !defined(OS_CHROMEOS) |
357 // Try alt-f4 to close the browser. | 368 // Try alt-f4 to close the browser. |
358 ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait( | 369 ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait( |
359 browser(), ui::VKEY_F4, false, false, true, false, | 370 browser(), ui::VKEY_F4, false, false, true, false, |
360 NotificationType::BROWSER_CLOSED, Source<Browser>(browser()))); | 371 NotificationType::BROWSER_CLOSED, Source<Browser>(browser()))); |
361 #endif | 372 #endif |
362 } | 373 } |
363 | 374 |
364 IN_PROC_BROWSER_TEST_F(AutocompleteEditViewTest, PopupAccelerators) { | 375 IN_PROC_BROWSER_TEST_F(AutocompleteEditViewTest, PopupAccelerators) { |
365 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); | |
366 | |
367 // Create a popup. | 376 // Create a popup. |
368 Browser* popup = CreateBrowserForPopup(browser()->profile()); | 377 Browser* popup = CreateBrowserForPopup(browser()->profile()); |
369 AutocompleteEditView* edit_view = NULL; | 378 AutocompleteEditView* edit_view = NULL; |
370 ASSERT_NO_FATAL_FAILURE(GetAutocompleteEditViewForBrowser(popup, &edit_view)); | 379 ASSERT_NO_FATAL_FAILURE(GetAutocompleteEditViewForBrowser(popup, &edit_view)); |
371 popup->FocusLocationBar(); | 380 popup->FocusLocationBar(); |
372 EXPECT_TRUE(edit_view->IsSelectAll()); | 381 EXPECT_TRUE(edit_view->IsSelectAll()); |
373 | 382 |
374 // Try ctrl-w to close the popup. | 383 // Try ctrl-w to close the popup. |
375 ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait( | 384 ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait( |
376 popup, ui::VKEY_W, true, false, false, false, | 385 popup, ui::VKEY_W, true, false, false, false, |
(...skipping 27 matching lines...) Expand all Loading... |
404 | 413 |
405 #if !defined(OS_CHROMEOS) | 414 #if !defined(OS_CHROMEOS) |
406 // Try alt-f4 to close the popup. | 415 // Try alt-f4 to close the popup. |
407 ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait( | 416 ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait( |
408 popup, ui::VKEY_F4, false, false, true, false, | 417 popup, ui::VKEY_F4, false, false, true, false, |
409 NotificationType::BROWSER_CLOSED, Source<Browser>(popup))); | 418 NotificationType::BROWSER_CLOSED, Source<Browser>(popup))); |
410 #endif | 419 #endif |
411 } | 420 } |
412 | 421 |
413 IN_PROC_BROWSER_TEST_F(AutocompleteEditViewTest, BackspaceInKeywordMode) { | 422 IN_PROC_BROWSER_TEST_F(AutocompleteEditViewTest, BackspaceInKeywordMode) { |
414 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); | |
415 | |
416 ASSERT_NO_FATAL_FAILURE(SetupComponents()); | |
417 browser()->FocusLocationBar(); | |
418 | |
419 AutocompleteEditView* edit_view = NULL; | 423 AutocompleteEditView* edit_view = NULL; |
420 ASSERT_NO_FATAL_FAILURE(GetAutocompleteEditView(&edit_view)); | 424 ASSERT_NO_FATAL_FAILURE(GetAutocompleteEditView(&edit_view)); |
421 | 425 |
422 // Trigger keyword hint mode. | 426 // Trigger keyword hint mode. |
423 ASSERT_NO_FATAL_FAILURE(SendKeySequence(kSearchKeywordKeys)); | 427 ASSERT_NO_FATAL_FAILURE(SendKeySequence(kSearchKeywordKeys)); |
424 ASSERT_TRUE(edit_view->model()->is_keyword_hint()); | 428 ASSERT_TRUE(edit_view->model()->is_keyword_hint()); |
425 ASSERT_EQ(kSearchKeyword, WideToUTF8(edit_view->model()->keyword())); | 429 ASSERT_EQ(kSearchKeyword, WideToUTF8(edit_view->model()->keyword())); |
426 | 430 |
427 // Trigger keyword mode. | 431 // Trigger keyword mode. |
428 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_TAB, false, false, false)); | 432 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_TAB, false, false, false)); |
(...skipping 29 matching lines...) Expand all Loading... |
458 // Backspace at the beginning of the search text shall turn off | 462 // Backspace at the beginning of the search text shall turn off |
459 // the keyword mode. | 463 // the keyword mode. |
460 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_BACK, false, false, false)); | 464 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_BACK, false, false, false)); |
461 ASSERT_FALSE(edit_view->model()->is_keyword_hint()); | 465 ASSERT_FALSE(edit_view->model()->is_keyword_hint()); |
462 ASSERT_EQ(std::string(), WideToUTF8(edit_view->model()->keyword())); | 466 ASSERT_EQ(std::string(), WideToUTF8(edit_view->model()->keyword())); |
463 ASSERT_EQ(std::string(kSearchKeyword) + kSearchText, | 467 ASSERT_EQ(std::string(kSearchKeyword) + kSearchText, |
464 WideToUTF8(edit_view->GetText())); | 468 WideToUTF8(edit_view->GetText())); |
465 } | 469 } |
466 | 470 |
467 IN_PROC_BROWSER_TEST_F(AutocompleteEditViewTest, Escape) { | 471 IN_PROC_BROWSER_TEST_F(AutocompleteEditViewTest, Escape) { |
468 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); | |
469 | |
470 ASSERT_NO_FATAL_FAILURE(SetupComponents()); | |
471 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUIHistoryURL)); | 472 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUIHistoryURL)); |
472 browser()->FocusLocationBar(); | 473 browser()->FocusLocationBar(); |
473 | 474 |
474 AutocompleteEditView* edit_view = NULL; | 475 AutocompleteEditView* edit_view = NULL; |
475 ASSERT_NO_FATAL_FAILURE(GetAutocompleteEditView(&edit_view)); | 476 ASSERT_NO_FATAL_FAILURE(GetAutocompleteEditView(&edit_view)); |
476 | 477 |
477 std::wstring old_text = edit_view->GetText(); | 478 std::wstring old_text = edit_view->GetText(); |
478 EXPECT_FALSE(old_text.empty()); | 479 EXPECT_FALSE(old_text.empty()); |
479 EXPECT_TRUE(edit_view->IsSelectAll()); | 480 EXPECT_TRUE(edit_view->IsSelectAll()); |
480 | 481 |
481 // Delete all text in omnibox. | 482 // Delete all text in omnibox. |
482 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_BACK, false, false, false)); | 483 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_BACK, false, false, false)); |
483 EXPECT_TRUE(edit_view->GetText().empty()); | 484 EXPECT_TRUE(edit_view->GetText().empty()); |
484 | 485 |
485 // Escape shall revert the text in omnibox. | 486 // Escape shall revert the text in omnibox. |
486 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_ESCAPE, false, false, false)); | 487 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_ESCAPE, false, false, false)); |
487 EXPECT_EQ(old_text, edit_view->GetText()); | 488 EXPECT_EQ(old_text, edit_view->GetText()); |
488 EXPECT_TRUE(edit_view->IsSelectAll()); | 489 EXPECT_TRUE(edit_view->IsSelectAll()); |
489 } | 490 } |
490 | 491 |
491 IN_PROC_BROWSER_TEST_F(AutocompleteEditViewTest, DesiredTLD) { | 492 IN_PROC_BROWSER_TEST_F(AutocompleteEditViewTest, DesiredTLD) { |
492 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); | |
493 | |
494 ASSERT_NO_FATAL_FAILURE(SetupComponents()); | |
495 browser()->FocusLocationBar(); | |
496 | |
497 AutocompleteEditView* edit_view = NULL; | 493 AutocompleteEditView* edit_view = NULL; |
498 ASSERT_NO_FATAL_FAILURE(GetAutocompleteEditView(&edit_view)); | 494 ASSERT_NO_FATAL_FAILURE(GetAutocompleteEditView(&edit_view)); |
499 AutocompletePopupModel* popup_model = edit_view->model()->popup_model(); | 495 AutocompletePopupModel* popup_model = edit_view->model()->popup_model(); |
500 ASSERT_TRUE(popup_model); | 496 ASSERT_TRUE(popup_model); |
501 | 497 |
502 // Test ctrl-Enter. | 498 // Test ctrl-Enter. |
503 ASSERT_NO_FATAL_FAILURE(SendKeySequence(kDesiredTLDKeys)); | 499 ASSERT_NO_FATAL_FAILURE(SendKeySequence(kDesiredTLDKeys)); |
504 ASSERT_NO_FATAL_FAILURE(WaitForAutocompleteControllerDone()); | 500 ASSERT_NO_FATAL_FAILURE(WaitForAutocompleteControllerDone()); |
505 ASSERT_TRUE(popup_model->IsOpen()); | 501 ASSERT_TRUE(popup_model->IsOpen()); |
506 // ctrl-Enter triggers desired_tld feature, thus www.bar.com shall be opened. | 502 // ctrl-Enter triggers desired_tld feature, thus www.bar.com shall be opened. |
507 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_RETURN, true, false, false)); | 503 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_RETURN, true, false, false)); |
508 | 504 |
509 GURL url = browser()->GetSelectedTabContents()->GetURL(); | 505 GURL url = browser()->GetSelectedTabContents()->GetURL(); |
510 EXPECT_STREQ(kDesiredTLDHostname, url.host().c_str()); | 506 EXPECT_STREQ(kDesiredTLDHostname, url.host().c_str()); |
511 } | 507 } |
512 | 508 |
513 IN_PROC_BROWSER_TEST_F(AutocompleteEditViewTest, AltEnter) { | 509 IN_PROC_BROWSER_TEST_F(AutocompleteEditViewTest, AltEnter) { |
514 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); | |
515 | |
516 ASSERT_NO_FATAL_FAILURE(SetupComponents()); | |
517 browser()->FocusLocationBar(); | |
518 | |
519 AutocompleteEditView* edit_view = NULL; | 510 AutocompleteEditView* edit_view = NULL; |
520 ASSERT_NO_FATAL_FAILURE(GetAutocompleteEditView(&edit_view)); | 511 ASSERT_NO_FATAL_FAILURE(GetAutocompleteEditView(&edit_view)); |
521 | 512 |
522 edit_view->SetUserText(ASCIIToWide(chrome::kChromeUIHistoryURL)); | 513 edit_view->SetUserText(ASCIIToWide(chrome::kChromeUIHistoryURL)); |
523 int tab_count = browser()->tab_count(); | 514 int tab_count = browser()->tab_count(); |
524 // alt-Enter opens a new tab. | 515 // alt-Enter opens a new tab. |
525 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_RETURN, false, false, true)); | 516 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_RETURN, false, false, true)); |
526 ASSERT_NO_FATAL_FAILURE(WaitForTabOpenOrClose(tab_count + 1)); | 517 ASSERT_NO_FATAL_FAILURE(WaitForTabOpenOrClose(tab_count + 1)); |
527 } | 518 } |
528 | 519 |
529 IN_PROC_BROWSER_TEST_F(AutocompleteEditViewTest, EnterToSearch) { | 520 IN_PROC_BROWSER_TEST_F(AutocompleteEditViewTest, EnterToSearch) { |
530 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); | |
531 | |
532 ASSERT_NO_FATAL_FAILURE(SetupHostResolver()); | |
533 ASSERT_NO_FATAL_FAILURE(SetupSearchEngine()); | |
534 browser()->FocusLocationBar(); | |
535 | |
536 AutocompleteEditView* edit_view = NULL; | 521 AutocompleteEditView* edit_view = NULL; |
537 ASSERT_NO_FATAL_FAILURE(GetAutocompleteEditView(&edit_view)); | 522 ASSERT_NO_FATAL_FAILURE(GetAutocompleteEditView(&edit_view)); |
538 AutocompletePopupModel* popup_model = edit_view->model()->popup_model(); | 523 AutocompletePopupModel* popup_model = edit_view->model()->popup_model(); |
539 ASSERT_TRUE(popup_model); | 524 ASSERT_TRUE(popup_model); |
540 | 525 |
541 // Test Enter to search. | 526 // Test Enter to search. |
542 ASSERT_NO_FATAL_FAILURE(SendKeySequence(kSearchTextKeys)); | 527 ASSERT_NO_FATAL_FAILURE(SendKeySequence(kSearchTextKeys)); |
543 ASSERT_NO_FATAL_FAILURE(WaitForAutocompleteControllerDone()); | 528 ASSERT_NO_FATAL_FAILURE(WaitForAutocompleteControllerDone()); |
544 ASSERT_TRUE(popup_model->IsOpen()); | 529 ASSERT_TRUE(popup_model->IsOpen()); |
545 | 530 |
(...skipping 20 matching lines...) Expand all Loading... |
566 | 551 |
567 // Open the default match. | 552 // Open the default match. |
568 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_RETURN, false, false, false)); | 553 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_RETURN, false, false, false)); |
569 url = browser()->GetSelectedTabContents()->GetURL(); | 554 url = browser()->GetSelectedTabContents()->GetURL(); |
570 EXPECT_STREQ(kSearchSingleCharURL, url.spec().c_str()); | 555 EXPECT_STREQ(kSearchSingleCharURL, url.spec().c_str()); |
571 } | 556 } |
572 | 557 |
573 // See http://crbug.com/20934: Omnibox keyboard behavior wrong for | 558 // See http://crbug.com/20934: Omnibox keyboard behavior wrong for |
574 // "See recent pages in history" | 559 // "See recent pages in history" |
575 IN_PROC_BROWSER_TEST_F(AutocompleteEditViewTest, EnterToOpenHistoryPage) { | 560 IN_PROC_BROWSER_TEST_F(AutocompleteEditViewTest, EnterToOpenHistoryPage) { |
576 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); | |
577 | |
578 ASSERT_NO_FATAL_FAILURE(SetupComponents()); | |
579 browser()->FocusLocationBar(); | |
580 | |
581 AutocompleteEditView* edit_view = NULL; | 561 AutocompleteEditView* edit_view = NULL; |
582 ASSERT_NO_FATAL_FAILURE(GetAutocompleteEditView(&edit_view)); | 562 ASSERT_NO_FATAL_FAILURE(GetAutocompleteEditView(&edit_view)); |
583 AutocompletePopupModel* popup_model = edit_view->model()->popup_model(); | 563 AutocompletePopupModel* popup_model = edit_view->model()->popup_model(); |
584 ASSERT_TRUE(popup_model); | 564 ASSERT_TRUE(popup_model); |
585 | 565 |
586 ASSERT_NO_FATAL_FAILURE(SendKeySequence(kSearchTextKeys)); | 566 ASSERT_NO_FATAL_FAILURE(SendKeySequence(kSearchTextKeys)); |
587 ASSERT_NO_FATAL_FAILURE(WaitForAutocompleteControllerDone()); | 567 ASSERT_NO_FATAL_FAILURE(WaitForAutocompleteControllerDone()); |
588 ASSERT_TRUE(popup_model->IsOpen()); | 568 ASSERT_TRUE(popup_model->IsOpen()); |
589 EXPECT_EQ(0U, popup_model->selected_line()); | 569 EXPECT_EQ(0U, popup_model->selected_line()); |
590 | 570 |
(...skipping 14 matching lines...) Expand all Loading... |
605 ASSERT_EQ(AutocompleteMatch::OPEN_HISTORY_PAGE, | 585 ASSERT_EQ(AutocompleteMatch::OPEN_HISTORY_PAGE, |
606 popup_model->result().match_at(popup_model->selected_line()).type); | 586 popup_model->result().match_at(popup_model->selected_line()).type); |
607 | 587 |
608 // Open the history page item. | 588 // Open the history page item. |
609 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_RETURN, false, false, false)); | 589 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_RETURN, false, false, false)); |
610 GURL url = browser()->GetSelectedTabContents()->GetURL(); | 590 GURL url = browser()->GetSelectedTabContents()->GetURL(); |
611 EXPECT_STREQ(kHistoryPageURL, url.spec().c_str()); | 591 EXPECT_STREQ(kHistoryPageURL, url.spec().c_str()); |
612 } | 592 } |
613 | 593 |
614 IN_PROC_BROWSER_TEST_F(AutocompleteEditViewTest, EscapeToDefaultMatch) { | 594 IN_PROC_BROWSER_TEST_F(AutocompleteEditViewTest, EscapeToDefaultMatch) { |
615 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); | |
616 | |
617 ASSERT_NO_FATAL_FAILURE(SetupComponents()); | |
618 browser()->FocusLocationBar(); | |
619 | |
620 AutocompleteEditView* edit_view = NULL; | 595 AutocompleteEditView* edit_view = NULL; |
621 ASSERT_NO_FATAL_FAILURE(GetAutocompleteEditView(&edit_view)); | 596 ASSERT_NO_FATAL_FAILURE(GetAutocompleteEditView(&edit_view)); |
622 AutocompletePopupModel* popup_model = edit_view->model()->popup_model(); | 597 AutocompletePopupModel* popup_model = edit_view->model()->popup_model(); |
623 ASSERT_TRUE(popup_model); | 598 ASSERT_TRUE(popup_model); |
624 | 599 |
625 // Input something to trigger inline autocomplete. | 600 // Input something to trigger inline autocomplete. |
626 ASSERT_NO_FATAL_FAILURE(SendKeySequence(kSearchTextKeys)); | 601 ASSERT_NO_FATAL_FAILURE(SendKeySequence(kInlineAutocompleteTextKeys)); |
627 ASSERT_NO_FATAL_FAILURE(WaitForAutocompleteControllerDone()); | 602 ASSERT_NO_FATAL_FAILURE(WaitForAutocompleteControllerDone()); |
628 ASSERT_TRUE(popup_model->IsOpen()); | 603 ASSERT_TRUE(popup_model->IsOpen()); |
629 | 604 |
630 std::wstring old_text = edit_view->GetText(); | 605 std::wstring old_text = edit_view->GetText(); |
631 | 606 |
632 // Make sure inline autocomplete is triggerred. | 607 // Make sure inline autocomplete is triggerred. |
633 EXPECT_GT(old_text.length(), arraysize(kSearchText) - 1); | 608 EXPECT_GT(old_text.length(), arraysize(kInlineAutocompleteText) - 1); |
634 | 609 |
635 size_t old_selected_line = popup_model->selected_line(); | 610 size_t old_selected_line = popup_model->selected_line(); |
636 EXPECT_EQ(0U, old_selected_line); | 611 EXPECT_EQ(0U, old_selected_line); |
637 | 612 |
638 // Move to another line with different text. | 613 // Move to another line with different text. |
639 size_t size = popup_model->result().size(); | 614 size_t size = popup_model->result().size(); |
640 while (popup_model->selected_line() < size - 1) { | 615 while (popup_model->selected_line() < size - 1) { |
641 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_DOWN, false, false, false)); | 616 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_DOWN, false, false, false)); |
642 ASSERT_NE(old_selected_line, popup_model->selected_line()); | 617 ASSERT_NE(old_selected_line, popup_model->selected_line()); |
643 if (old_text != edit_view->GetText()) | 618 if (old_text != edit_view->GetText()) |
644 break; | 619 break; |
645 } | 620 } |
646 | 621 |
647 EXPECT_NE(old_text, edit_view->GetText()); | 622 EXPECT_NE(old_text, edit_view->GetText()); |
648 | 623 |
649 // Escape shall revert back to the default match item. | 624 // Escape shall revert back to the default match item. |
650 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_ESCAPE, false, false, false)); | 625 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_ESCAPE, false, false, false)); |
651 EXPECT_EQ(old_text, edit_view->GetText()); | 626 EXPECT_EQ(old_text, edit_view->GetText()); |
652 EXPECT_EQ(old_selected_line, popup_model->selected_line()); | 627 EXPECT_EQ(old_selected_line, popup_model->selected_line()); |
653 } | 628 } |
654 | 629 |
655 IN_PROC_BROWSER_TEST_F(AutocompleteEditViewTest, BasicTextOperations) { | 630 IN_PROC_BROWSER_TEST_F(AutocompleteEditViewTest, BasicTextOperations) { |
656 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); | |
657 | |
658 ASSERT_NO_FATAL_FAILURE(SetupComponents()); | |
659 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kAboutBlankURL)); | 631 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kAboutBlankURL)); |
660 browser()->FocusLocationBar(); | 632 browser()->FocusLocationBar(); |
661 | 633 |
662 AutocompleteEditView* edit_view = NULL; | 634 AutocompleteEditView* edit_view = NULL; |
663 ASSERT_NO_FATAL_FAILURE(GetAutocompleteEditView(&edit_view)); | 635 ASSERT_NO_FATAL_FAILURE(GetAutocompleteEditView(&edit_view)); |
664 | 636 |
665 std::wstring old_text = edit_view->GetText(); | 637 std::wstring old_text = edit_view->GetText(); |
666 EXPECT_EQ(UTF8ToWide(chrome::kAboutBlankURL), old_text); | 638 EXPECT_EQ(UTF8ToWide(chrome::kAboutBlankURL), old_text); |
667 EXPECT_TRUE(edit_view->IsSelectAll()); | 639 EXPECT_TRUE(edit_view->IsSelectAll()); |
668 | 640 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
706 | 678 |
707 // Check if RevertAll() can set text and cursor correctly. | 679 // Check if RevertAll() can set text and cursor correctly. |
708 edit_view->RevertAll(); | 680 edit_view->RevertAll(); |
709 EXPECT_FALSE(edit_view->IsSelectAll()); | 681 EXPECT_FALSE(edit_view->IsSelectAll()); |
710 EXPECT_EQ(old_text, edit_view->GetText()); | 682 EXPECT_EQ(old_text, edit_view->GetText()); |
711 edit_view->GetSelectionBounds(&start, &end); | 683 edit_view->GetSelectionBounds(&start, &end); |
712 EXPECT_EQ(old_text.size(), start); | 684 EXPECT_EQ(old_text.size(), start); |
713 EXPECT_EQ(old_text.size(), end); | 685 EXPECT_EQ(old_text.size(), end); |
714 } | 686 } |
715 | 687 |
| 688 IN_PROC_BROWSER_TEST_F(AutocompleteEditViewTest, AcceptKeywordBySpace) { |
| 689 AutocompleteEditView* edit_view = NULL; |
| 690 ASSERT_NO_FATAL_FAILURE(GetAutocompleteEditView(&edit_view)); |
| 691 |
| 692 std::wstring text = UTF8ToWide(kSearchKeyword); |
| 693 |
| 694 // Trigger keyword hint mode. |
| 695 ASSERT_NO_FATAL_FAILURE(SendKeySequence(kSearchKeywordKeys)); |
| 696 ASSERT_TRUE(edit_view->model()->is_keyword_hint()); |
| 697 ASSERT_EQ(text, edit_view->model()->keyword()); |
| 698 ASSERT_EQ(text, edit_view->GetText()); |
| 699 |
| 700 // Trigger keyword mode by space. |
| 701 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_SPACE, false, false, false)); |
| 702 ASSERT_FALSE(edit_view->model()->is_keyword_hint()); |
| 703 ASSERT_EQ(text, edit_view->model()->keyword()); |
| 704 ASSERT_TRUE(edit_view->GetText().empty()); |
| 705 |
| 706 // Revert to keyword hint mode. |
| 707 edit_view->model()->ClearKeyword(std::wstring()); |
| 708 ASSERT_TRUE(edit_view->model()->is_keyword_hint()); |
| 709 ASSERT_EQ(text, edit_view->model()->keyword()); |
| 710 ASSERT_EQ(text, edit_view->GetText()); |
| 711 |
| 712 // Keyword should also be accepted by typing an ideographic space. |
| 713 edit_view->OnBeforePossibleChange(); |
| 714 edit_view->SetWindowTextAndCaretPos(text + L"\x3000", text.length() + 1); |
| 715 edit_view->OnAfterPossibleChange(); |
| 716 ASSERT_FALSE(edit_view->model()->is_keyword_hint()); |
| 717 ASSERT_EQ(text, edit_view->model()->keyword()); |
| 718 ASSERT_TRUE(edit_view->GetText().empty()); |
| 719 |
| 720 // Revert to keyword hint mode. |
| 721 edit_view->model()->ClearKeyword(std::wstring()); |
| 722 ASSERT_TRUE(edit_view->model()->is_keyword_hint()); |
| 723 ASSERT_EQ(text, edit_view->model()->keyword()); |
| 724 ASSERT_EQ(text, edit_view->GetText()); |
| 725 |
| 726 // Keyword shouldn't be accepted by pasting. |
| 727 // Simulate pasting a whitespace to the end of content. |
| 728 edit_view->OnBeforePossibleChange(); |
| 729 edit_view->model()->OnPaste(false); |
| 730 edit_view->SetWindowTextAndCaretPos(text + L" ", text.length() + 1); |
| 731 edit_view->OnAfterPossibleChange(); |
| 732 // Should be still in keyword hint mode. |
| 733 ASSERT_TRUE(edit_view->model()->is_keyword_hint()); |
| 734 ASSERT_EQ(text, edit_view->model()->keyword()); |
| 735 ASSERT_EQ(text + L" ", edit_view->GetText()); |
| 736 |
| 737 // Keyword shouldn't be accepted by pressing space with a trailing whitespace. |
| 738 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_SPACE, false, false, false)); |
| 739 ASSERT_TRUE(edit_view->model()->is_keyword_hint()); |
| 740 ASSERT_EQ(text, edit_view->model()->keyword()); |
| 741 ASSERT_EQ(text + L" ", edit_view->GetText()); |
| 742 |
| 743 // Keyword shouldn't be accepted by deleting the trailing space. |
| 744 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_BACK, false, false, false)); |
| 745 ASSERT_TRUE(edit_view->model()->is_keyword_hint()); |
| 746 ASSERT_EQ(text, edit_view->model()->keyword()); |
| 747 ASSERT_EQ(text + L" ", edit_view->GetText()); |
| 748 |
| 749 // Keyword shouldn't be accepted by pressing space in the middle of content. |
| 750 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_LEFT, false, false, false)); |
| 751 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_SPACE, false, false, false)); |
| 752 ASSERT_TRUE(edit_view->model()->is_keyword_hint()); |
| 753 ASSERT_EQ(text, edit_view->model()->keyword()); |
| 754 ASSERT_EQ(text + L" ", edit_view->GetText()); |
| 755 |
| 756 // Keyword shouldn't be accepted by pasting "foo bar". |
| 757 edit_view->SetUserText(std::wstring()); |
| 758 ASSERT_FALSE(edit_view->model()->is_keyword_hint()); |
| 759 ASSERT_TRUE(edit_view->model()->keyword().empty()); |
| 760 |
| 761 edit_view->OnBeforePossibleChange(); |
| 762 edit_view->model()->OnPaste(true); |
| 763 edit_view->SetWindowTextAndCaretPos(text + L" bar", text.length() + 4); |
| 764 edit_view->OnAfterPossibleChange(); |
| 765 ASSERT_FALSE(edit_view->model()->is_keyword_hint()); |
| 766 ASSERT_TRUE(edit_view->model()->keyword().empty()); |
| 767 ASSERT_EQ(text + L" bar", edit_view->GetText()); |
| 768 |
| 769 // Keyword shouldn't be accepted by pressing space with a selected range. |
| 770 edit_view->OnBeforePossibleChange(); |
| 771 edit_view->OnInlineAutocompleteTextMaybeChanged(text + L" ", text.length()); |
| 772 edit_view->OnAfterPossibleChange(); |
| 773 ASSERT_TRUE(edit_view->model()->is_keyword_hint()); |
| 774 ASSERT_EQ(text, edit_view->model()->keyword()); |
| 775 ASSERT_EQ(text + L" ", edit_view->GetText()); |
| 776 |
| 777 std::wstring::size_type start, end; |
| 778 edit_view->GetSelectionBounds(&start, &end); |
| 779 ASSERT_NE(start, end); |
| 780 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_SPACE, false, false, false)); |
| 781 ASSERT_TRUE(edit_view->model()->is_keyword_hint()); |
| 782 ASSERT_EQ(text, edit_view->model()->keyword()); |
| 783 ASSERT_EQ(text + L" ", edit_view->GetText()); |
| 784 |
| 785 edit_view->GetSelectionBounds(&start, &end); |
| 786 ASSERT_EQ(start, end); |
| 787 } |
| 788 |
716 #if defined(OS_LINUX) | 789 #if defined(OS_LINUX) |
717 IN_PROC_BROWSER_TEST_F(AutocompleteEditViewTest, UndoRedoLinux) { | 790 IN_PROC_BROWSER_TEST_F(AutocompleteEditViewTest, UndoRedoLinux) { |
718 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); | |
719 | |
720 ASSERT_NO_FATAL_FAILURE(SetupComponents()); | |
721 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kAboutBlankURL)); | 791 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kAboutBlankURL)); |
722 browser()->FocusLocationBar(); | 792 browser()->FocusLocationBar(); |
723 | 793 |
724 AutocompleteEditView* edit_view = NULL; | 794 AutocompleteEditView* edit_view = NULL; |
725 ASSERT_NO_FATAL_FAILURE(GetAutocompleteEditView(&edit_view)); | 795 ASSERT_NO_FATAL_FAILURE(GetAutocompleteEditView(&edit_view)); |
726 | 796 |
727 std::wstring old_text = edit_view->GetText(); | 797 std::wstring old_text = edit_view->GetText(); |
728 EXPECT_EQ(UTF8ToWide(chrome::kAboutBlankURL), old_text); | 798 EXPECT_EQ(UTF8ToWide(chrome::kAboutBlankURL), old_text); |
729 EXPECT_TRUE(edit_view->IsSelectAll()); | 799 EXPECT_TRUE(edit_view->IsSelectAll()); |
730 | 800 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
775 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_Z, true, false, false)); | 845 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_Z, true, false, false)); |
776 EXPECT_EQ(old_text, edit_view->GetText()); | 846 EXPECT_EQ(old_text, edit_view->GetText()); |
777 | 847 |
778 // Undo again. | 848 // Undo again. |
779 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_Z, true, false, false)); | 849 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_Z, true, false, false)); |
780 EXPECT_TRUE(edit_view->GetText().empty()); | 850 EXPECT_TRUE(edit_view->GetText().empty()); |
781 } | 851 } |
782 | 852 |
783 // See http://crbug.com/63860 | 853 // See http://crbug.com/63860 |
784 IN_PROC_BROWSER_TEST_F(AutocompleteEditViewTest, PrimarySelection) { | 854 IN_PROC_BROWSER_TEST_F(AutocompleteEditViewTest, PrimarySelection) { |
785 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); | |
786 | |
787 browser()->FocusLocationBar(); | |
788 AutocompleteEditView* edit_view = NULL; | 855 AutocompleteEditView* edit_view = NULL; |
789 ASSERT_NO_FATAL_FAILURE(GetAutocompleteEditView(&edit_view)); | 856 ASSERT_NO_FATAL_FAILURE(GetAutocompleteEditView(&edit_view)); |
790 edit_view->SetUserText(L"Hello world"); | 857 edit_view->SetUserText(L"Hello world"); |
791 EXPECT_FALSE(edit_view->IsSelectAll()); | 858 EXPECT_FALSE(edit_view->IsSelectAll()); |
792 | 859 |
793 // Move the cursor to the end. | 860 // Move the cursor to the end. |
794 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_END, false, false, false)); | 861 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_END, false, false, false)); |
795 | 862 |
796 // Select all text by pressing Shift+Home | 863 // Select all text by pressing Shift+Home |
797 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_HOME, false, true, false)); | 864 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_HOME, false, true, false)); |
798 EXPECT_TRUE(edit_view->IsSelectAll()); | 865 EXPECT_TRUE(edit_view->IsSelectAll()); |
799 | 866 |
800 // The selected content should be saved to the PRIMARY clipboard. | 867 // The selected content should be saved to the PRIMARY clipboard. |
801 EXPECT_EQ("Hello world", GetPrimarySelectionText()); | 868 EXPECT_EQ("Hello world", GetPrimarySelectionText()); |
802 | 869 |
803 // Move the cursor to the end. | 870 // Move the cursor to the end. |
804 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_END, false, false, false)); | 871 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_END, false, false, false)); |
805 EXPECT_FALSE(edit_view->IsSelectAll()); | 872 EXPECT_FALSE(edit_view->IsSelectAll()); |
806 | 873 |
807 // The content in the PRIMARY clipboard should not be cleared. | 874 // The content in the PRIMARY clipboard should not be cleared. |
808 EXPECT_EQ("Hello world", GetPrimarySelectionText()); | 875 EXPECT_EQ("Hello world", GetPrimarySelectionText()); |
809 } | 876 } |
810 | 877 |
811 // See http://crosbug.com/10306 | 878 // See http://crosbug.com/10306 |
812 IN_PROC_BROWSER_TEST_F(AutocompleteEditViewTest, | 879 IN_PROC_BROWSER_TEST_F(AutocompleteEditViewTest, |
813 BackspaceDeleteHalfWidthKatakana) { | 880 BackspaceDeleteHalfWidthKatakana) { |
814 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); | |
815 | |
816 browser()->FocusLocationBar(); | |
817 AutocompleteEditView* edit_view = NULL; | 881 AutocompleteEditView* edit_view = NULL; |
818 ASSERT_NO_FATAL_FAILURE(GetAutocompleteEditView(&edit_view)); | 882 ASSERT_NO_FATAL_FAILURE(GetAutocompleteEditView(&edit_view)); |
819 // Insert text: ダ | 883 // Insert text: ダ |
820 edit_view->SetUserText(UTF8ToWide("\357\276\200\357\276\236")); | 884 edit_view->SetUserText(UTF8ToWide("\357\276\200\357\276\236")); |
821 | 885 |
822 // Move the cursor to the end. | 886 // Move the cursor to the end. |
823 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_END, false, false, false)); | 887 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_END, false, false, false)); |
824 | 888 |
825 // Backspace should delete one character. | 889 // Backspace should delete one character. |
826 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_BACK, false, false, false)); | 890 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_BACK, false, false, false)); |
827 EXPECT_EQ(UTF8ToWide("\357\276\200"), edit_view->GetText()); | 891 EXPECT_EQ(UTF8ToWide("\357\276\200"), edit_view->GetText()); |
828 } | 892 } |
829 | 893 |
830 // http://crbug.com/12316 | 894 // http://crbug.com/12316 |
831 IN_PROC_BROWSER_TEST_F(AutocompleteEditViewTest, PasteReplacingAll) { | 895 IN_PROC_BROWSER_TEST_F(AutocompleteEditViewTest, PasteReplacingAll) { |
832 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); | |
833 | |
834 ASSERT_NO_FATAL_FAILURE(SetupComponents()); | |
835 browser()->FocusLocationBar(); | |
836 | |
837 AutocompleteEditView* edit_view = NULL; | 896 AutocompleteEditView* edit_view = NULL; |
838 ASSERT_NO_FATAL_FAILURE(GetAutocompleteEditView(&edit_view)); | 897 ASSERT_NO_FATAL_FAILURE(GetAutocompleteEditView(&edit_view)); |
839 AutocompletePopupModel* popup_model = edit_view->model()->popup_model(); | 898 AutocompletePopupModel* popup_model = edit_view->model()->popup_model(); |
840 ASSERT_TRUE(popup_model); | 899 ASSERT_TRUE(popup_model); |
841 | 900 |
842 SetClipboardText(kSearchText); | 901 SetClipboardText(kSearchText); |
843 | 902 |
844 // Paste text. | 903 // Paste text. |
845 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_V, true, false, false)); | 904 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_V, true, false, false)); |
846 ASSERT_NO_FATAL_FAILURE(WaitForAutocompleteControllerDone()); | 905 ASSERT_NO_FATAL_FAILURE(WaitForAutocompleteControllerDone()); |
847 ASSERT_TRUE(popup_model->IsOpen()); | 906 ASSERT_TRUE(popup_model->IsOpen()); |
848 | 907 |
849 // Inline autocomplete shouldn't be triggered. | 908 // Inline autocomplete shouldn't be triggered. |
850 ASSERT_EQ(L"abc", edit_view->GetText()); | 909 ASSERT_EQ(L"abc", edit_view->GetText()); |
851 } | 910 } |
852 #endif | 911 #endif |
OLD | NEW |