| OLD | NEW |
| 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 <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 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 | 237 |
| 238 void WaitForTabOpenOrClose(int expected_tab_count) { | 238 void WaitForTabOpenOrClose(int expected_tab_count) { |
| 239 WaitForTabOpenOrCloseForBrowser(browser(), expected_tab_count); | 239 WaitForTabOpenOrCloseForBrowser(browser(), expected_tab_count); |
| 240 } | 240 } |
| 241 | 241 |
| 242 void WaitForAutocompleteControllerDone() { | 242 void WaitForAutocompleteControllerDone() { |
| 243 OmniboxView* omnibox_view = NULL; | 243 OmniboxView* omnibox_view = NULL; |
| 244 ASSERT_NO_FATAL_FAILURE(GetOmniboxView(&omnibox_view)); | 244 ASSERT_NO_FATAL_FAILURE(GetOmniboxView(&omnibox_view)); |
| 245 | 245 |
| 246 AutocompleteController* controller = | 246 AutocompleteController* controller = |
| 247 omnibox_view->model()->autocomplete_controller(); | 247 omnibox_view->GetModel()->autocomplete_controller(); |
| 248 ASSERT_TRUE(controller); | 248 ASSERT_TRUE(controller); |
| 249 | 249 |
| 250 if (controller->done()) | 250 if (controller->done()) |
| 251 return; | 251 return; |
| 252 | 252 |
| 253 content::NotificationRegistrar registrar; | 253 content::NotificationRegistrar registrar; |
| 254 registrar.Add(this, | 254 registrar.Add(this, |
| 255 chrome::NOTIFICATION_AUTOCOMPLETE_CONTROLLER_RESULT_READY, | 255 chrome::NOTIFICATION_AUTOCOMPLETE_CONTROLLER_RESULT_READY, |
| 256 content::Source<AutocompleteController>(controller)); | 256 content::Source<AutocompleteController>(controller)); |
| 257 | 257 |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 492 chrome::NOTIFICATION_BROWSER_CLOSED, content::Source<Browser>(popup))); | 492 chrome::NOTIFICATION_BROWSER_CLOSED, content::Source<Browser>(popup))); |
| 493 #endif | 493 #endif |
| 494 } | 494 } |
| 495 | 495 |
| 496 void BackspaceInKeywordModeTest() { | 496 void BackspaceInKeywordModeTest() { |
| 497 OmniboxView* omnibox_view = NULL; | 497 OmniboxView* omnibox_view = NULL; |
| 498 ASSERT_NO_FATAL_FAILURE(GetOmniboxView(&omnibox_view)); | 498 ASSERT_NO_FATAL_FAILURE(GetOmniboxView(&omnibox_view)); |
| 499 | 499 |
| 500 // Trigger keyword hint mode. | 500 // Trigger keyword hint mode. |
| 501 ASSERT_NO_FATAL_FAILURE(SendKeySequence(kSearchKeywordKeys)); | 501 ASSERT_NO_FATAL_FAILURE(SendKeySequence(kSearchKeywordKeys)); |
| 502 ASSERT_TRUE(omnibox_view->model()->is_keyword_hint()); | 502 ASSERT_TRUE(omnibox_view->GetModel()->is_keyword_hint()); |
| 503 ASSERT_EQ(kSearchKeyword, UTF16ToUTF8(omnibox_view->model()->keyword())); | 503 ASSERT_EQ(kSearchKeyword, UTF16ToUTF8(omnibox_view->GetModel()->keyword())); |
| 504 | 504 |
| 505 // Trigger keyword mode. | 505 // Trigger keyword mode. |
| 506 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_TAB, 0)); | 506 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_TAB, 0)); |
| 507 ASSERT_FALSE(omnibox_view->model()->is_keyword_hint()); | 507 ASSERT_FALSE(omnibox_view->GetModel()->is_keyword_hint()); |
| 508 ASSERT_EQ(kSearchKeyword, UTF16ToUTF8(omnibox_view->model()->keyword())); | 508 ASSERT_EQ(kSearchKeyword, UTF16ToUTF8(omnibox_view->GetModel()->keyword())); |
| 509 | 509 |
| 510 // Backspace without search text should bring back keyword hint mode. | 510 // Backspace without search text should bring back keyword hint mode. |
| 511 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_BACK, 0)); | 511 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_BACK, 0)); |
| 512 ASSERT_TRUE(omnibox_view->model()->is_keyword_hint()); | 512 ASSERT_TRUE(omnibox_view->GetModel()->is_keyword_hint()); |
| 513 ASSERT_EQ(kSearchKeyword, UTF16ToUTF8(omnibox_view->model()->keyword())); | 513 ASSERT_EQ(kSearchKeyword, UTF16ToUTF8(omnibox_view->GetModel()->keyword())); |
| 514 | 514 |
| 515 // Trigger keyword mode again. | 515 // Trigger keyword mode again. |
| 516 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_TAB, 0)); | 516 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_TAB, 0)); |
| 517 ASSERT_FALSE(omnibox_view->model()->is_keyword_hint()); | 517 ASSERT_FALSE(omnibox_view->GetModel()->is_keyword_hint()); |
| 518 ASSERT_EQ(kSearchKeyword, UTF16ToUTF8(omnibox_view->model()->keyword())); | 518 ASSERT_EQ(kSearchKeyword, UTF16ToUTF8(omnibox_view->GetModel()->keyword())); |
| 519 | 519 |
| 520 // Input something as search text. | 520 // Input something as search text. |
| 521 ASSERT_NO_FATAL_FAILURE(SendKeySequence(kSearchTextKeys)); | 521 ASSERT_NO_FATAL_FAILURE(SendKeySequence(kSearchTextKeys)); |
| 522 | 522 |
| 523 // Should stay in keyword mode while deleting search text by pressing | 523 // Should stay in keyword mode while deleting search text by pressing |
| 524 // backspace. | 524 // backspace. |
| 525 for (size_t i = 0; i < arraysize(kSearchText) - 1; ++i) { | 525 for (size_t i = 0; i < arraysize(kSearchText) - 1; ++i) { |
| 526 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_BACK, 0)); | 526 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_BACK, 0)); |
| 527 ASSERT_FALSE(omnibox_view->model()->is_keyword_hint()); | 527 ASSERT_FALSE(omnibox_view->GetModel()->is_keyword_hint()); |
| 528 ASSERT_EQ(kSearchKeyword, UTF16ToUTF8(omnibox_view->model()->keyword())); | 528 ASSERT_EQ(kSearchKeyword, |
| 529 UTF16ToUTF8(omnibox_view->GetModel()->keyword())); |
| 529 } | 530 } |
| 530 | 531 |
| 531 // Input something as search text. | 532 // Input something as search text. |
| 532 ASSERT_NO_FATAL_FAILURE(SendKeySequence(kSearchTextKeys)); | 533 ASSERT_NO_FATAL_FAILURE(SendKeySequence(kSearchTextKeys)); |
| 533 | 534 |
| 534 // Move cursor to the beginning of the search text. | 535 // Move cursor to the beginning of the search text. |
| 535 #if defined(OS_MACOSX) | 536 #if defined(OS_MACOSX) |
| 536 // Home doesn't work on Mac trybot. | 537 // Home doesn't work on Mac trybot. |
| 537 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_A, ui::EF_CONTROL_DOWN)); | 538 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_A, ui::EF_CONTROL_DOWN)); |
| 538 #else | 539 #else |
| 539 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_HOME, 0)); | 540 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_HOME, 0)); |
| 540 #endif | 541 #endif |
| 541 // Backspace at the beginning of the search text shall turn off | 542 // Backspace at the beginning of the search text shall turn off |
| 542 // the keyword mode. | 543 // the keyword mode. |
| 543 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_BACK, 0)); | 544 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_BACK, 0)); |
| 544 ASSERT_FALSE(omnibox_view->model()->is_keyword_hint()); | 545 ASSERT_FALSE(omnibox_view->GetModel()->is_keyword_hint()); |
| 545 ASSERT_EQ(string16(), omnibox_view->model()->keyword()); | 546 ASSERT_EQ(string16(), omnibox_view->GetModel()->keyword()); |
| 546 ASSERT_EQ(std::string(kSearchKeyword) + kSearchText, | 547 ASSERT_EQ(std::string(kSearchKeyword) + kSearchText, |
| 547 UTF16ToUTF8(omnibox_view->GetText())); | 548 UTF16ToUTF8(omnibox_view->GetText())); |
| 548 } | 549 } |
| 549 | 550 |
| 550 void EscapeTest() { | 551 void EscapeTest() { |
| 551 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUIHistoryURL)); | 552 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUIHistoryURL)); |
| 552 chrome::FocusLocationBar(browser()); | 553 chrome::FocusLocationBar(browser()); |
| 553 | 554 |
| 554 OmniboxView* omnibox_view = NULL; | 555 OmniboxView* omnibox_view = NULL; |
| 555 ASSERT_NO_FATAL_FAILURE(GetOmniboxView(&omnibox_view)); | 556 ASSERT_NO_FATAL_FAILURE(GetOmniboxView(&omnibox_view)); |
| 556 | 557 |
| 557 string16 old_text = omnibox_view->GetText(); | 558 string16 old_text = omnibox_view->GetText(); |
| 558 EXPECT_FALSE(old_text.empty()); | 559 EXPECT_FALSE(old_text.empty()); |
| 559 EXPECT_TRUE(omnibox_view->IsSelectAll()); | 560 EXPECT_TRUE(omnibox_view->IsSelectAll()); |
| 560 | 561 |
| 561 // Delete all text in omnibox. | 562 // Delete all text in omnibox. |
| 562 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_BACK, 0)); | 563 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_BACK, 0)); |
| 563 EXPECT_TRUE(omnibox_view->GetText().empty()); | 564 EXPECT_TRUE(omnibox_view->GetText().empty()); |
| 564 | 565 |
| 565 // Escape shall revert the text in omnibox. | 566 // Escape shall revert the text in omnibox. |
| 566 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_ESCAPE, 0)); | 567 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_ESCAPE, 0)); |
| 567 EXPECT_EQ(old_text, omnibox_view->GetText()); | 568 EXPECT_EQ(old_text, omnibox_view->GetText()); |
| 568 EXPECT_TRUE(omnibox_view->IsSelectAll()); | 569 EXPECT_TRUE(omnibox_view->IsSelectAll()); |
| 569 } | 570 } |
| 570 | 571 |
| 571 void DesiredTLDTest() { | 572 void DesiredTLDTest() { |
| 572 OmniboxView* omnibox_view = NULL; | 573 OmniboxView* omnibox_view = NULL; |
| 573 ASSERT_NO_FATAL_FAILURE(GetOmniboxView(&omnibox_view)); | 574 ASSERT_NO_FATAL_FAILURE(GetOmniboxView(&omnibox_view)); |
| 574 OmniboxPopupModel* popup_model = omnibox_view->model()->popup_model(); | 575 OmniboxPopupModel* popup_model = omnibox_view->GetModel()->popup_model(); |
| 575 ASSERT_TRUE(popup_model); | 576 ASSERT_TRUE(popup_model); |
| 576 | 577 |
| 577 // Test ctrl-Enter. | 578 // Test ctrl-Enter. |
| 578 ASSERT_NO_FATAL_FAILURE(SendKeySequence(kDesiredTLDKeys)); | 579 ASSERT_NO_FATAL_FAILURE(SendKeySequence(kDesiredTLDKeys)); |
| 579 ASSERT_NO_FATAL_FAILURE(WaitForAutocompleteControllerDone()); | 580 ASSERT_NO_FATAL_FAILURE(WaitForAutocompleteControllerDone()); |
| 580 ASSERT_TRUE(popup_model->IsOpen()); | 581 ASSERT_TRUE(popup_model->IsOpen()); |
| 581 // ctrl-Enter triggers desired_tld feature, thus www.bar.com shall be | 582 // ctrl-Enter triggers desired_tld feature, thus www.bar.com shall be |
| 582 // opened. | 583 // opened. |
| 583 ASSERT_TRUE(SendKeyAndWait(browser(), ui::VKEY_RETURN, ui::EF_CONTROL_DOWN, | 584 ASSERT_TRUE(SendKeyAndWait(browser(), ui::VKEY_RETURN, ui::EF_CONTROL_DOWN, |
| 584 content::NOTIFICATION_NAV_ENTRY_COMMITTED, | 585 content::NOTIFICATION_NAV_ENTRY_COMMITTED, |
| (...skipping 11 matching lines...) Expand all Loading... |
| 596 omnibox_view->SetUserText(ASCIIToUTF16(chrome::kChromeUIHistoryURL)); | 597 omnibox_view->SetUserText(ASCIIToUTF16(chrome::kChromeUIHistoryURL)); |
| 597 int tab_count = browser()->tab_count(); | 598 int tab_count = browser()->tab_count(); |
| 598 // alt-Enter opens a new tab. | 599 // alt-Enter opens a new tab. |
| 599 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_RETURN, ui::EF_ALT_DOWN)); | 600 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_RETURN, ui::EF_ALT_DOWN)); |
| 600 ASSERT_NO_FATAL_FAILURE(WaitForTabOpenOrClose(tab_count + 1)); | 601 ASSERT_NO_FATAL_FAILURE(WaitForTabOpenOrClose(tab_count + 1)); |
| 601 } | 602 } |
| 602 | 603 |
| 603 void EnterToSearchTest() { | 604 void EnterToSearchTest() { |
| 604 OmniboxView* omnibox_view = NULL; | 605 OmniboxView* omnibox_view = NULL; |
| 605 ASSERT_NO_FATAL_FAILURE(GetOmniboxView(&omnibox_view)); | 606 ASSERT_NO_FATAL_FAILURE(GetOmniboxView(&omnibox_view)); |
| 606 OmniboxPopupModel* popup_model = omnibox_view->model()->popup_model(); | 607 OmniboxPopupModel* popup_model = omnibox_view->GetModel()->popup_model(); |
| 607 ASSERT_TRUE(popup_model); | 608 ASSERT_TRUE(popup_model); |
| 608 | 609 |
| 609 // Test Enter to search. | 610 // Test Enter to search. |
| 610 ASSERT_NO_FATAL_FAILURE(SendKeySequence(kSearchTextKeys)); | 611 ASSERT_NO_FATAL_FAILURE(SendKeySequence(kSearchTextKeys)); |
| 611 ASSERT_NO_FATAL_FAILURE(WaitForAutocompleteControllerDone()); | 612 ASSERT_NO_FATAL_FAILURE(WaitForAutocompleteControllerDone()); |
| 612 ASSERT_TRUE(popup_model->IsOpen()); | 613 ASSERT_TRUE(popup_model->IsOpen()); |
| 613 | 614 |
| 614 // Check if the default match result is Search Primary Provider. | 615 // Check if the default match result is Search Primary Provider. |
| 615 ASSERT_EQ(AutocompleteMatch::SEARCH_WHAT_YOU_TYPED, | 616 ASSERT_EQ(AutocompleteMatch::SEARCH_WHAT_YOU_TYPED, |
| 616 popup_model->result().default_match()->type); | 617 popup_model->result().default_match()->type); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 640 content::NOTIFICATION_NAV_ENTRY_COMMITTED, | 641 content::NOTIFICATION_NAV_ENTRY_COMMITTED, |
| 641 content::Source<content::NavigationController>( | 642 content::Source<content::NavigationController>( |
| 642 &chrome::GetActiveWebContents(browser())->GetController()))); | 643 &chrome::GetActiveWebContents(browser())->GetController()))); |
| 643 url = chrome::GetActiveWebContents(browser())->GetURL(); | 644 url = chrome::GetActiveWebContents(browser())->GetURL(); |
| 644 EXPECT_STREQ(kSearchSingleCharURL, url.spec().c_str()); | 645 EXPECT_STREQ(kSearchSingleCharURL, url.spec().c_str()); |
| 645 } | 646 } |
| 646 | 647 |
| 647 void EscapeToDefaultMatchTest() { | 648 void EscapeToDefaultMatchTest() { |
| 648 OmniboxView* omnibox_view = NULL; | 649 OmniboxView* omnibox_view = NULL; |
| 649 ASSERT_NO_FATAL_FAILURE(GetOmniboxView(&omnibox_view)); | 650 ASSERT_NO_FATAL_FAILURE(GetOmniboxView(&omnibox_view)); |
| 650 OmniboxPopupModel* popup_model = omnibox_view->model()->popup_model(); | 651 OmniboxPopupModel* popup_model = omnibox_view->GetModel()->popup_model(); |
| 651 ASSERT_TRUE(popup_model); | 652 ASSERT_TRUE(popup_model); |
| 652 | 653 |
| 653 // Input something to trigger inline autocomplete. | 654 // Input something to trigger inline autocomplete. |
| 654 ASSERT_NO_FATAL_FAILURE(SendKeySequence(kInlineAutocompleteTextKeys)); | 655 ASSERT_NO_FATAL_FAILURE(SendKeySequence(kInlineAutocompleteTextKeys)); |
| 655 ASSERT_NO_FATAL_FAILURE(WaitForAutocompleteControllerDone()); | 656 ASSERT_NO_FATAL_FAILURE(WaitForAutocompleteControllerDone()); |
| 656 ASSERT_TRUE(popup_model->IsOpen()); | 657 ASSERT_TRUE(popup_model->IsOpen()); |
| 657 | 658 |
| 658 string16 old_text = omnibox_view->GetText(); | 659 string16 old_text = omnibox_view->GetText(); |
| 659 | 660 |
| 660 // Make sure inline autocomplete is triggerred. | 661 // Make sure inline autocomplete is triggerred. |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 744 } | 745 } |
| 745 | 746 |
| 746 void AcceptKeywordBySpaceTest() { | 747 void AcceptKeywordBySpaceTest() { |
| 747 OmniboxView* omnibox_view = NULL; | 748 OmniboxView* omnibox_view = NULL; |
| 748 ASSERT_NO_FATAL_FAILURE(GetOmniboxView(&omnibox_view)); | 749 ASSERT_NO_FATAL_FAILURE(GetOmniboxView(&omnibox_view)); |
| 749 | 750 |
| 750 string16 search_keyword(ASCIIToUTF16(kSearchKeyword)); | 751 string16 search_keyword(ASCIIToUTF16(kSearchKeyword)); |
| 751 | 752 |
| 752 // Trigger keyword hint mode. | 753 // Trigger keyword hint mode. |
| 753 ASSERT_NO_FATAL_FAILURE(SendKeySequence(kSearchKeywordKeys)); | 754 ASSERT_NO_FATAL_FAILURE(SendKeySequence(kSearchKeywordKeys)); |
| 754 ASSERT_TRUE(omnibox_view->model()->is_keyword_hint()); | 755 ASSERT_TRUE(omnibox_view->GetModel()->is_keyword_hint()); |
| 755 ASSERT_EQ(search_keyword, omnibox_view->model()->keyword()); | 756 ASSERT_EQ(search_keyword, omnibox_view->GetModel()->keyword()); |
| 756 ASSERT_EQ(search_keyword, omnibox_view->GetText()); | 757 ASSERT_EQ(search_keyword, omnibox_view->GetText()); |
| 757 | 758 |
| 758 // Trigger keyword mode by space. | 759 // Trigger keyword mode by space. |
| 759 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_SPACE, 0)); | 760 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_SPACE, 0)); |
| 760 ASSERT_FALSE(omnibox_view->model()->is_keyword_hint()); | 761 ASSERT_FALSE(omnibox_view->GetModel()->is_keyword_hint()); |
| 761 ASSERT_EQ(search_keyword, omnibox_view->model()->keyword()); | 762 ASSERT_EQ(search_keyword, omnibox_view->GetModel()->keyword()); |
| 762 ASSERT_TRUE(omnibox_view->GetText().empty()); | 763 ASSERT_TRUE(omnibox_view->GetText().empty()); |
| 763 | 764 |
| 764 // Revert to keyword hint mode. | 765 // Revert to keyword hint mode. |
| 765 omnibox_view->model()->ClearKeyword(string16()); | 766 omnibox_view->GetModel()->ClearKeyword(string16()); |
| 766 ASSERT_TRUE(omnibox_view->model()->is_keyword_hint()); | 767 ASSERT_TRUE(omnibox_view->GetModel()->is_keyword_hint()); |
| 767 ASSERT_EQ(search_keyword, omnibox_view->model()->keyword()); | 768 ASSERT_EQ(search_keyword, omnibox_view->GetModel()->keyword()); |
| 768 ASSERT_EQ(search_keyword, omnibox_view->GetText()); | 769 ASSERT_EQ(search_keyword, omnibox_view->GetText()); |
| 769 | 770 |
| 770 // Keyword should also be accepted by typing an ideographic space. | 771 // Keyword should also be accepted by typing an ideographic space. |
| 771 omnibox_view->OnBeforePossibleChange(); | 772 omnibox_view->OnBeforePossibleChange(); |
| 772 omnibox_view->SetWindowTextAndCaretPos(search_keyword + | 773 omnibox_view->SetWindowTextAndCaretPos(search_keyword + |
| 773 WideToUTF16(L"\x3000"), search_keyword.length() + 1, false, false); | 774 WideToUTF16(L"\x3000"), search_keyword.length() + 1, false, false); |
| 774 omnibox_view->OnAfterPossibleChange(); | 775 omnibox_view->OnAfterPossibleChange(); |
| 775 ASSERT_FALSE(omnibox_view->model()->is_keyword_hint()); | 776 ASSERT_FALSE(omnibox_view->GetModel()->is_keyword_hint()); |
| 776 ASSERT_EQ(search_keyword, omnibox_view->model()->keyword()); | 777 ASSERT_EQ(search_keyword, omnibox_view->GetModel()->keyword()); |
| 777 ASSERT_TRUE(omnibox_view->GetText().empty()); | 778 ASSERT_TRUE(omnibox_view->GetText().empty()); |
| 778 | 779 |
| 779 // Revert to keyword hint mode. | 780 // Revert to keyword hint mode. |
| 780 omnibox_view->model()->ClearKeyword(string16()); | 781 omnibox_view->GetModel()->ClearKeyword(string16()); |
| 781 ASSERT_TRUE(omnibox_view->model()->is_keyword_hint()); | 782 ASSERT_TRUE(omnibox_view->GetModel()->is_keyword_hint()); |
| 782 ASSERT_EQ(search_keyword, omnibox_view->model()->keyword()); | 783 ASSERT_EQ(search_keyword, omnibox_view->GetModel()->keyword()); |
| 783 ASSERT_EQ(search_keyword, omnibox_view->GetText()); | 784 ASSERT_EQ(search_keyword, omnibox_view->GetText()); |
| 784 | 785 |
| 785 // Keyword shouldn't be accepted by pressing space with a trailing | 786 // Keyword shouldn't be accepted by pressing space with a trailing |
| 786 // whitespace. | 787 // whitespace. |
| 787 omnibox_view->SetWindowTextAndCaretPos(search_keyword + char16(' '), | 788 omnibox_view->SetWindowTextAndCaretPos(search_keyword + char16(' '), |
| 788 search_keyword.length() + 1, false, false); | 789 search_keyword.length() + 1, false, false); |
| 789 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_SPACE, 0)); | 790 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_SPACE, 0)); |
| 790 ASSERT_TRUE(omnibox_view->model()->is_keyword_hint()); | 791 ASSERT_TRUE(omnibox_view->GetModel()->is_keyword_hint()); |
| 791 ASSERT_EQ(search_keyword, omnibox_view->model()->keyword()); | 792 ASSERT_EQ(search_keyword, omnibox_view->GetModel()->keyword()); |
| 792 ASSERT_EQ(search_keyword + ASCIIToUTF16(" "), omnibox_view->GetText()); | 793 ASSERT_EQ(search_keyword + ASCIIToUTF16(" "), omnibox_view->GetText()); |
| 793 | 794 |
| 794 // Keyword shouldn't be accepted by deleting the trailing space. | 795 // Keyword shouldn't be accepted by deleting the trailing space. |
| 795 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_BACK, 0)); | 796 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_BACK, 0)); |
| 796 ASSERT_TRUE(omnibox_view->model()->is_keyword_hint()); | 797 ASSERT_TRUE(omnibox_view->GetModel()->is_keyword_hint()); |
| 797 ASSERT_EQ(search_keyword, omnibox_view->model()->keyword()); | 798 ASSERT_EQ(search_keyword, omnibox_view->GetModel()->keyword()); |
| 798 ASSERT_EQ(search_keyword + char16(' '), omnibox_view->GetText()); | 799 ASSERT_EQ(search_keyword + char16(' '), omnibox_view->GetText()); |
| 799 | 800 |
| 800 // Keyword shouldn't be accepted by pressing space before a trailing space. | 801 // Keyword shouldn't be accepted by pressing space before a trailing space. |
| 801 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_LEFT, 0)); | 802 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_LEFT, 0)); |
| 802 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_SPACE, 0)); | 803 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_SPACE, 0)); |
| 803 ASSERT_TRUE(omnibox_view->model()->is_keyword_hint()); | 804 ASSERT_TRUE(omnibox_view->GetModel()->is_keyword_hint()); |
| 804 ASSERT_EQ(search_keyword, omnibox_view->model()->keyword()); | 805 ASSERT_EQ(search_keyword, omnibox_view->GetModel()->keyword()); |
| 805 ASSERT_EQ(search_keyword + ASCIIToUTF16(" "), omnibox_view->GetText()); | 806 ASSERT_EQ(search_keyword + ASCIIToUTF16(" "), omnibox_view->GetText()); |
| 806 | 807 |
| 807 // Keyword should be accepted by pressing space in the middle of context and | 808 // Keyword should be accepted by pressing space in the middle of context and |
| 808 // just after the keyword. | 809 // just after the keyword. |
| 809 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_BACK, 0)); | 810 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_BACK, 0)); |
| 810 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_A, 0)); | 811 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_A, 0)); |
| 811 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_LEFT, 0)); | 812 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_LEFT, 0)); |
| 812 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_SPACE, 0)); | 813 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_SPACE, 0)); |
| 813 ASSERT_FALSE(omnibox_view->model()->is_keyword_hint()); | 814 ASSERT_FALSE(omnibox_view->GetModel()->is_keyword_hint()); |
| 814 ASSERT_EQ(search_keyword, omnibox_view->model()->keyword()); | 815 ASSERT_EQ(search_keyword, omnibox_view->GetModel()->keyword()); |
| 815 ASSERT_EQ(ASCIIToUTF16("a "), omnibox_view->GetText()); | 816 ASSERT_EQ(ASCIIToUTF16("a "), omnibox_view->GetText()); |
| 816 | 817 |
| 817 // Keyword shouldn't be accepted by pasting "foo bar". | 818 // Keyword shouldn't be accepted by pasting "foo bar". |
| 818 omnibox_view->SetUserText(string16()); | 819 omnibox_view->SetUserText(string16()); |
| 819 ASSERT_FALSE(omnibox_view->model()->is_keyword_hint()); | 820 ASSERT_FALSE(omnibox_view->GetModel()->is_keyword_hint()); |
| 820 ASSERT_TRUE(omnibox_view->model()->keyword().empty()); | 821 ASSERT_TRUE(omnibox_view->GetModel()->keyword().empty()); |
| 821 | 822 |
| 822 omnibox_view->OnBeforePossibleChange(); | 823 omnibox_view->OnBeforePossibleChange(); |
| 823 omnibox_view->model()->on_paste(); | 824 omnibox_view->GetModel()->on_paste(); |
| 824 omnibox_view->SetWindowTextAndCaretPos(search_keyword + | 825 omnibox_view->SetWindowTextAndCaretPos(search_keyword + |
| 825 ASCIIToUTF16(" bar"), search_keyword.length() + 4, false, false); | 826 ASCIIToUTF16(" bar"), search_keyword.length() + 4, false, false); |
| 826 omnibox_view->OnAfterPossibleChange(); | 827 omnibox_view->OnAfterPossibleChange(); |
| 827 ASSERT_FALSE(omnibox_view->model()->is_keyword_hint()); | 828 ASSERT_FALSE(omnibox_view->GetModel()->is_keyword_hint()); |
| 828 ASSERT_TRUE(omnibox_view->model()->keyword().empty()); | 829 ASSERT_TRUE(omnibox_view->GetModel()->keyword().empty()); |
| 829 ASSERT_EQ(search_keyword + ASCIIToUTF16(" bar"), omnibox_view->GetText()); | 830 ASSERT_EQ(search_keyword + ASCIIToUTF16(" bar"), omnibox_view->GetText()); |
| 830 | 831 |
| 831 // Keyword shouldn't be accepted for case like: "foo b|ar" -> "foo b |ar". | 832 // Keyword shouldn't be accepted for case like: "foo b|ar" -> "foo b |ar". |
| 832 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_LEFT, 0)); | 833 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_LEFT, 0)); |
| 833 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_LEFT, 0)); | 834 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_LEFT, 0)); |
| 834 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_SPACE, 0)); | 835 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_SPACE, 0)); |
| 835 ASSERT_FALSE(omnibox_view->model()->is_keyword_hint()); | 836 ASSERT_FALSE(omnibox_view->GetModel()->is_keyword_hint()); |
| 836 ASSERT_TRUE(omnibox_view->model()->keyword().empty()); | 837 ASSERT_TRUE(omnibox_view->GetModel()->keyword().empty()); |
| 837 ASSERT_EQ(search_keyword + ASCIIToUTF16(" b ar"), omnibox_view->GetText()); | 838 ASSERT_EQ(search_keyword + ASCIIToUTF16(" b ar"), omnibox_view->GetText()); |
| 838 | 839 |
| 839 // Keyword could be accepted by pressing space with a selected range at the | 840 // Keyword could be accepted by pressing space with a selected range at the |
| 840 // end of text. | 841 // end of text. |
| 841 omnibox_view->OnBeforePossibleChange(); | 842 omnibox_view->OnBeforePossibleChange(); |
| 842 omnibox_view->OnInlineAutocompleteTextMaybeChanged( | 843 omnibox_view->OnInlineAutocompleteTextMaybeChanged( |
| 843 search_keyword + ASCIIToUTF16(" "), search_keyword.length()); | 844 search_keyword + ASCIIToUTF16(" "), search_keyword.length()); |
| 844 omnibox_view->OnAfterPossibleChange(); | 845 omnibox_view->OnAfterPossibleChange(); |
| 845 ASSERT_TRUE(omnibox_view->model()->is_keyword_hint()); | 846 ASSERT_TRUE(omnibox_view->GetModel()->is_keyword_hint()); |
| 846 ASSERT_EQ(search_keyword, omnibox_view->model()->keyword()); | 847 ASSERT_EQ(search_keyword, omnibox_view->GetModel()->keyword()); |
| 847 ASSERT_EQ(search_keyword + ASCIIToUTF16(" "), omnibox_view->GetText()); | 848 ASSERT_EQ(search_keyword + ASCIIToUTF16(" "), omnibox_view->GetText()); |
| 848 | 849 |
| 849 size_t start, end; | 850 size_t start, end; |
| 850 omnibox_view->GetSelectionBounds(&start, &end); | 851 omnibox_view->GetSelectionBounds(&start, &end); |
| 851 ASSERT_NE(start, end); | 852 ASSERT_NE(start, end); |
| 852 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_SPACE, 0)); | 853 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_SPACE, 0)); |
| 853 ASSERT_FALSE(omnibox_view->model()->is_keyword_hint()); | 854 ASSERT_FALSE(omnibox_view->GetModel()->is_keyword_hint()); |
| 854 ASSERT_EQ(search_keyword, omnibox_view->model()->keyword()); | 855 ASSERT_EQ(search_keyword, omnibox_view->GetModel()->keyword()); |
| 855 ASSERT_EQ(string16(), omnibox_view->GetText()); | 856 ASSERT_EQ(string16(), omnibox_view->GetText()); |
| 856 | 857 |
| 857 // Space should accept keyword even when inline autocomplete is available. | 858 // Space should accept keyword even when inline autocomplete is available. |
| 858 omnibox_view->SetUserText(string16()); | 859 omnibox_view->SetUserText(string16()); |
| 859 const TestHistoryEntry kHistoryFoobar = { | 860 const TestHistoryEntry kHistoryFoobar = { |
| 860 "http://www.foobar.com", "Page foobar", kSearchText, 100, 100, true | 861 "http://www.foobar.com", "Page foobar", kSearchText, 100, 100, true |
| 861 }; | 862 }; |
| 862 | 863 |
| 863 // Add a history entry to trigger inline autocomplete when typing "foo". | 864 // Add a history entry to trigger inline autocomplete when typing "foo". |
| 864 ASSERT_NO_FATAL_FAILURE( | 865 ASSERT_NO_FATAL_FAILURE( |
| 865 AddHistoryEntry(kHistoryFoobar, Time::Now() - TimeDelta::FromHours(1))); | 866 AddHistoryEntry(kHistoryFoobar, Time::Now() - TimeDelta::FromHours(1))); |
| 866 | 867 |
| 867 // Type "foo" to trigger inline autocomplete. | 868 // Type "foo" to trigger inline autocomplete. |
| 868 ASSERT_NO_FATAL_FAILURE(SendKeySequence(kSearchKeywordKeys)); | 869 ASSERT_NO_FATAL_FAILURE(SendKeySequence(kSearchKeywordKeys)); |
| 869 ASSERT_NO_FATAL_FAILURE(WaitForAutocompleteControllerDone()); | 870 ASSERT_NO_FATAL_FAILURE(WaitForAutocompleteControllerDone()); |
| 870 ASSERT_TRUE(omnibox_view->model()->popup_model()->IsOpen()); | 871 ASSERT_TRUE(omnibox_view->GetModel()->popup_model()->IsOpen()); |
| 871 ASSERT_NE(search_keyword, omnibox_view->GetText()); | 872 ASSERT_NE(search_keyword, omnibox_view->GetText()); |
| 872 | 873 |
| 873 // Keyword hint shouldn't be visible. | 874 // Keyword hint shouldn't be visible. |
| 874 ASSERT_FALSE(omnibox_view->model()->is_keyword_hint()); | 875 ASSERT_FALSE(omnibox_view->GetModel()->is_keyword_hint()); |
| 875 ASSERT_TRUE(omnibox_view->model()->keyword().empty()); | 876 ASSERT_TRUE(omnibox_view->GetModel()->keyword().empty()); |
| 876 | 877 |
| 877 // Trigger keyword mode by space. | 878 // Trigger keyword mode by space. |
| 878 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_SPACE, 0)); | 879 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_SPACE, 0)); |
| 879 ASSERT_FALSE(omnibox_view->model()->is_keyword_hint()); | 880 ASSERT_FALSE(omnibox_view->GetModel()->is_keyword_hint()); |
| 880 ASSERT_EQ(search_keyword, omnibox_view->model()->keyword()); | 881 ASSERT_EQ(search_keyword, omnibox_view->GetModel()->keyword()); |
| 881 ASSERT_TRUE(omnibox_view->GetText().empty()); | 882 ASSERT_TRUE(omnibox_view->GetText().empty()); |
| 882 | 883 |
| 883 // Space in the middle of a temporary text, which separates the text into | 884 // Space in the middle of a temporary text, which separates the text into |
| 884 // keyword and replacement portions, should trigger keyword mode. | 885 // keyword and replacement portions, should trigger keyword mode. |
| 885 omnibox_view->SetUserText(string16()); | 886 omnibox_view->SetUserText(string16()); |
| 886 ASSERT_NO_FATAL_FAILURE(SendKeySequence(kSearchKeywordKeys)); | 887 ASSERT_NO_FATAL_FAILURE(SendKeySequence(kSearchKeywordKeys)); |
| 887 ASSERT_NO_FATAL_FAILURE(WaitForAutocompleteControllerDone()); | 888 ASSERT_NO_FATAL_FAILURE(WaitForAutocompleteControllerDone()); |
| 888 OmniboxPopupModel* popup_model = omnibox_view->model()->popup_model(); | 889 OmniboxPopupModel* popup_model = omnibox_view->GetModel()->popup_model(); |
| 889 ASSERT_TRUE(popup_model->IsOpen()); | 890 ASSERT_TRUE(popup_model->IsOpen()); |
| 890 ASSERT_EQ(ASCIIToUTF16("foobar.com"), omnibox_view->GetText()); | 891 ASSERT_EQ(ASCIIToUTF16("foobar.com"), omnibox_view->GetText()); |
| 891 omnibox_view->model()->OnUpOrDownKeyPressed(1); | 892 omnibox_view->GetModel()->OnUpOrDownKeyPressed(1); |
| 892 omnibox_view->model()->OnUpOrDownKeyPressed(-1); | 893 omnibox_view->GetModel()->OnUpOrDownKeyPressed(-1); |
| 893 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_LEFT, 0)); | 894 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_LEFT, 0)); |
| 894 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_LEFT, 0)); | 895 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_LEFT, 0)); |
| 895 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_LEFT, 0)); | 896 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_LEFT, 0)); |
| 896 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_LEFT, 0)); | 897 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_LEFT, 0)); |
| 897 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_LEFT, 0)); | 898 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_LEFT, 0)); |
| 898 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_LEFT, 0)); | 899 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_LEFT, 0)); |
| 899 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_LEFT, 0)); | 900 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_LEFT, 0)); |
| 900 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_SPACE, 0)); | 901 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_SPACE, 0)); |
| 901 ASSERT_FALSE(omnibox_view->model()->is_keyword_hint()); | 902 ASSERT_FALSE(omnibox_view->GetModel()->is_keyword_hint()); |
| 902 ASSERT_EQ(search_keyword, omnibox_view->model()->keyword()); | 903 ASSERT_EQ(search_keyword, omnibox_view->GetModel()->keyword()); |
| 903 ASSERT_EQ(ASCIIToUTF16("bar.com"), omnibox_view->GetText()); | 904 ASSERT_EQ(ASCIIToUTF16("bar.com"), omnibox_view->GetText()); |
| 904 | 905 |
| 905 // Space after temporary text that looks like a keyword, when the original | 906 // Space after temporary text that looks like a keyword, when the original |
| 906 // input does not look like a keyword, should trigger keyword mode. | 907 // input does not look like a keyword, should trigger keyword mode. |
| 907 omnibox_view->SetUserText(string16()); | 908 omnibox_view->SetUserText(string16()); |
| 908 const TestHistoryEntry kHistoryFoo = { | 909 const TestHistoryEntry kHistoryFoo = { |
| 909 "http://footest.com", "Page footest", kSearchText, 1000, 1000, true | 910 "http://footest.com", "Page footest", kSearchText, 1000, 1000, true |
| 910 }; | 911 }; |
| 911 | 912 |
| 912 // Add a history entry to trigger HQP matching with text == keyword when | 913 // Add a history entry to trigger HQP matching with text == keyword when |
| 913 // typing "fo te". | 914 // typing "fo te". |
| 914 ASSERT_NO_FATAL_FAILURE( | 915 ASSERT_NO_FATAL_FAILURE( |
| 915 AddHistoryEntry(kHistoryFoo, Time::Now() - TimeDelta::FromMinutes(10))); | 916 AddHistoryEntry(kHistoryFoo, Time::Now() - TimeDelta::FromMinutes(10))); |
| 916 | 917 |
| 917 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_F, 0)); | 918 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_F, 0)); |
| 918 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_O, 0)); | 919 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_O, 0)); |
| 919 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_SPACE, 0)); | 920 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_SPACE, 0)); |
| 920 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_T, 0)); | 921 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_T, 0)); |
| 921 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_E, 0)); | 922 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_E, 0)); |
| 922 ASSERT_NO_FATAL_FAILURE(WaitForAutocompleteControllerDone()); | 923 ASSERT_NO_FATAL_FAILURE(WaitForAutocompleteControllerDone()); |
| 923 ASSERT_TRUE(popup_model->IsOpen()); | 924 ASSERT_TRUE(popup_model->IsOpen()); |
| 924 string16 search_keyword2(ASCIIToUTF16(kSearchKeyword2)); | 925 string16 search_keyword2(ASCIIToUTF16(kSearchKeyword2)); |
| 925 while ((omnibox_view->GetText() != search_keyword2) && | 926 while ((omnibox_view->GetText() != search_keyword2) && |
| 926 (popup_model->selected_line() < popup_model->result().size() - 1)) | 927 (popup_model->selected_line() < popup_model->result().size() - 1)) |
| 927 omnibox_view->model()->OnUpOrDownKeyPressed(1); | 928 omnibox_view->GetModel()->OnUpOrDownKeyPressed(1); |
| 928 ASSERT_EQ(search_keyword2, omnibox_view->GetText()); | 929 ASSERT_EQ(search_keyword2, omnibox_view->GetText()); |
| 929 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_SPACE, 0)); | 930 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_SPACE, 0)); |
| 930 ASSERT_FALSE(omnibox_view->model()->is_keyword_hint()); | 931 ASSERT_FALSE(omnibox_view->GetModel()->is_keyword_hint()); |
| 931 ASSERT_EQ(search_keyword2, omnibox_view->model()->keyword()); | 932 ASSERT_EQ(search_keyword2, omnibox_view->GetModel()->keyword()); |
| 932 ASSERT_TRUE(omnibox_view->GetText().empty()); | 933 ASSERT_TRUE(omnibox_view->GetText().empty()); |
| 933 } | 934 } |
| 934 | 935 |
| 935 void NonSubstitutingKeywordTest() { | 936 void NonSubstitutingKeywordTest() { |
| 936 OmniboxView* omnibox_view = NULL; | 937 OmniboxView* omnibox_view = NULL; |
| 937 ASSERT_NO_FATAL_FAILURE(GetOmniboxView(&omnibox_view)); | 938 ASSERT_NO_FATAL_FAILURE(GetOmniboxView(&omnibox_view)); |
| 938 OmniboxPopupModel* popup_model = omnibox_view->model()->popup_model(); | 939 OmniboxPopupModel* popup_model = omnibox_view->GetModel()->popup_model(); |
| 939 ASSERT_TRUE(popup_model); | 940 ASSERT_TRUE(popup_model); |
| 940 | 941 |
| 941 Profile* profile = browser()->profile(); | 942 Profile* profile = browser()->profile(); |
| 942 TemplateURLService* template_url_service = | 943 TemplateURLService* template_url_service = |
| 943 TemplateURLServiceFactory::GetForProfile(profile); | 944 TemplateURLServiceFactory::GetForProfile(profile); |
| 944 | 945 |
| 945 // Add a non-default substituting keyword. | 946 // Add a non-default substituting keyword. |
| 946 TemplateURLData data; | 947 TemplateURLData data; |
| 947 data.short_name = ASCIIToUTF16("Search abc"); | 948 data.short_name = ASCIIToUTF16("Search abc"); |
| 948 data.SetKeyword(ASCIIToUTF16(kSearchText)); | 949 data.SetKeyword(ASCIIToUTF16(kSearchText)); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 989 TemplateURLService* model = | 990 TemplateURLService* model = |
| 990 TemplateURLServiceFactory::GetForProfile(browser()->profile()); | 991 TemplateURLServiceFactory::GetForProfile(browser()->profile()); |
| 991 model->SetDefaultSearchProvider(NULL); | 992 model->SetDefaultSearchProvider(NULL); |
| 992 | 993 |
| 993 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kAboutBlankURL)); | 994 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kAboutBlankURL)); |
| 994 chrome::FocusLocationBar(browser()); | 995 chrome::FocusLocationBar(browser()); |
| 995 | 996 |
| 996 OmniboxView* omnibox_view = NULL; | 997 OmniboxView* omnibox_view = NULL; |
| 997 ASSERT_NO_FATAL_FAILURE(GetOmniboxView(&omnibox_view)); | 998 ASSERT_NO_FATAL_FAILURE(GetOmniboxView(&omnibox_view)); |
| 998 | 999 |
| 999 OmniboxPopupModel* popup_model = omnibox_view->model()->popup_model(); | 1000 OmniboxPopupModel* popup_model = omnibox_view->GetModel()->popup_model(); |
| 1000 ASSERT_TRUE(popup_model); | 1001 ASSERT_TRUE(popup_model); |
| 1001 | 1002 |
| 1002 string16 old_text = omnibox_view->GetText(); | 1003 string16 old_text = omnibox_view->GetText(); |
| 1003 | 1004 |
| 1004 // Input something that can match history items. | 1005 // Input something that can match history items. |
| 1005 omnibox_view->SetUserText(ASCIIToUTF16("bar")); | 1006 omnibox_view->SetUserText(ASCIIToUTF16("bar")); |
| 1006 ASSERT_NO_FATAL_FAILURE(WaitForAutocompleteControllerDone()); | 1007 ASSERT_NO_FATAL_FAILURE(WaitForAutocompleteControllerDone()); |
| 1007 ASSERT_TRUE(popup_model->IsOpen()); | 1008 ASSERT_TRUE(popup_model->IsOpen()); |
| 1008 | 1009 |
| 1009 // Delete the inline autocomplete part. | 1010 // Delete the inline autocomplete part. |
| 1010 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_DELETE, 0)); | 1011 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_DELETE, 0)); |
| 1011 ASSERT_NO_FATAL_FAILURE(WaitForAutocompleteControllerDone()); | 1012 ASSERT_NO_FATAL_FAILURE(WaitForAutocompleteControllerDone()); |
| 1012 ASSERT_TRUE(popup_model->IsOpen()); | 1013 ASSERT_TRUE(popup_model->IsOpen()); |
| 1013 ASSERT_GE(popup_model->result().size(), 3U); | 1014 ASSERT_GE(popup_model->result().size(), 3U); |
| 1014 | 1015 |
| 1015 string16 user_text = omnibox_view->GetText(); | 1016 string16 user_text = omnibox_view->GetText(); |
| 1016 ASSERT_EQ(ASCIIToUTF16("bar"), user_text); | 1017 ASSERT_EQ(ASCIIToUTF16("bar"), user_text); |
| 1017 omnibox_view->SelectAll(true); | 1018 omnibox_view->SelectAll(true); |
| 1018 ASSERT_TRUE(omnibox_view->IsSelectAll()); | 1019 ASSERT_TRUE(omnibox_view->IsSelectAll()); |
| 1019 | 1020 |
| 1020 // The first item should be the default match. | 1021 // The first item should be the default match. |
| 1021 size_t default_line = popup_model->selected_line(); | 1022 size_t default_line = popup_model->selected_line(); |
| 1022 std::string default_url = | 1023 std::string default_url = |
| 1023 popup_model->result().match_at(default_line).destination_url.spec(); | 1024 popup_model->result().match_at(default_line).destination_url.spec(); |
| 1024 | 1025 |
| 1025 // Move down. | 1026 // Move down. |
| 1026 omnibox_view->model()->OnUpOrDownKeyPressed(1); | 1027 omnibox_view->GetModel()->OnUpOrDownKeyPressed(1); |
| 1027 ASSERT_EQ(default_line + 1, popup_model->selected_line()); | 1028 ASSERT_EQ(default_line + 1, popup_model->selected_line()); |
| 1028 string16 selected_text = | 1029 string16 selected_text = |
| 1029 popup_model->result().match_at(default_line + 1).fill_into_edit; | 1030 popup_model->result().match_at(default_line + 1).fill_into_edit; |
| 1030 // Temporary text is shown. | 1031 // Temporary text is shown. |
| 1031 ASSERT_EQ(selected_text, omnibox_view->GetText()); | 1032 ASSERT_EQ(selected_text, omnibox_view->GetText()); |
| 1032 ASSERT_FALSE(omnibox_view->IsSelectAll()); | 1033 ASSERT_FALSE(omnibox_view->IsSelectAll()); |
| 1033 | 1034 |
| 1034 // Delete the item. | 1035 // Delete the item. |
| 1035 popup_model->TryDeletingCurrentItem(); | 1036 popup_model->TryDeletingCurrentItem(); |
| 1036 ASSERT_NO_FATAL_FAILURE(WaitForAutocompleteControllerDone()); | 1037 ASSERT_NO_FATAL_FAILURE(WaitForAutocompleteControllerDone()); |
| 1037 // The selected line shouldn't be changed, because we have more than two | 1038 // The selected line shouldn't be changed, because we have more than two |
| 1038 // items. | 1039 // items. |
| 1039 ASSERT_EQ(default_line + 1, popup_model->selected_line()); | 1040 ASSERT_EQ(default_line + 1, popup_model->selected_line()); |
| 1040 // Make sure the item is really deleted. | 1041 // Make sure the item is really deleted. |
| 1041 ASSERT_NE(selected_text, | 1042 ASSERT_NE(selected_text, |
| 1042 popup_model->result().match_at(default_line + 1).fill_into_edit); | 1043 popup_model->result().match_at(default_line + 1).fill_into_edit); |
| 1043 selected_text = | 1044 selected_text = |
| 1044 popup_model->result().match_at(default_line + 1).fill_into_edit; | 1045 popup_model->result().match_at(default_line + 1).fill_into_edit; |
| 1045 // New temporary text is shown. | 1046 // New temporary text is shown. |
| 1046 ASSERT_EQ(selected_text, omnibox_view->GetText()); | 1047 ASSERT_EQ(selected_text, omnibox_view->GetText()); |
| 1047 | 1048 |
| 1048 // Revert to the default match. | 1049 // Revert to the default match. |
| 1049 ASSERT_TRUE(omnibox_view->model()->OnEscapeKeyPressed()); | 1050 ASSERT_TRUE(omnibox_view->GetModel()->OnEscapeKeyPressed()); |
| 1050 ASSERT_EQ(default_line, popup_model->selected_line()); | 1051 ASSERT_EQ(default_line, popup_model->selected_line()); |
| 1051 ASSERT_EQ(user_text, omnibox_view->GetText()); | 1052 ASSERT_EQ(user_text, omnibox_view->GetText()); |
| 1052 ASSERT_TRUE(omnibox_view->IsSelectAll()); | 1053 ASSERT_TRUE(omnibox_view->IsSelectAll()); |
| 1053 | 1054 |
| 1054 // Move down and up to select the default match as temporary text. | 1055 // Move down and up to select the default match as temporary text. |
| 1055 omnibox_view->model()->OnUpOrDownKeyPressed(1); | 1056 omnibox_view->GetModel()->OnUpOrDownKeyPressed(1); |
| 1056 ASSERT_EQ(default_line + 1, popup_model->selected_line()); | 1057 ASSERT_EQ(default_line + 1, popup_model->selected_line()); |
| 1057 omnibox_view->model()->OnUpOrDownKeyPressed(-1); | 1058 omnibox_view->GetModel()->OnUpOrDownKeyPressed(-1); |
| 1058 ASSERT_EQ(default_line, popup_model->selected_line()); | 1059 ASSERT_EQ(default_line, popup_model->selected_line()); |
| 1059 | 1060 |
| 1060 selected_text = popup_model->result().match_at(default_line).fill_into_edit; | 1061 selected_text = popup_model->result().match_at(default_line).fill_into_edit; |
| 1061 // New temporary text is shown. | 1062 // New temporary text is shown. |
| 1062 ASSERT_EQ(selected_text, omnibox_view->GetText()); | 1063 ASSERT_EQ(selected_text, omnibox_view->GetText()); |
| 1063 ASSERT_FALSE(omnibox_view->IsSelectAll()); | 1064 ASSERT_FALSE(omnibox_view->IsSelectAll()); |
| 1064 | 1065 |
| 1065 #if 0 | 1066 #if 0 |
| 1066 // TODO(mrossetti): http://crbug.com/82335 | 1067 // TODO(mrossetti): http://crbug.com/82335 |
| 1067 // Delete the default item. | 1068 // Delete the default item. |
| 1068 popup_model->TryDeletingCurrentItem(); | 1069 popup_model->TryDeletingCurrentItem(); |
| 1069 ASSERT_NO_FATAL_FAILURE(WaitForAutocompleteControllerDone()); | 1070 ASSERT_NO_FATAL_FAILURE(WaitForAutocompleteControllerDone()); |
| 1070 // The selected line shouldn't be changed, but the default item should have | 1071 // The selected line shouldn't be changed, but the default item should have |
| 1071 // been changed. | 1072 // been changed. |
| 1072 ASSERT_EQ(default_line, popup_model->selected_line()); | 1073 ASSERT_EQ(default_line, popup_model->selected_line()); |
| 1073 // Make sure the item is really deleted. | 1074 // Make sure the item is really deleted. |
| 1074 EXPECT_NE(selected_text, | 1075 EXPECT_NE(selected_text, |
| 1075 popup_model->result().match_at(default_line).fill_into_edit); | 1076 popup_model->result().match_at(default_line).fill_into_edit); |
| 1076 selected_text = | 1077 selected_text = |
| 1077 popup_model->result().match_at(default_line).fill_into_edit; | 1078 popup_model->result().match_at(default_line).fill_into_edit; |
| 1078 // New temporary text is shown. | 1079 // New temporary text is shown. |
| 1079 ASSERT_EQ(selected_text, omnibox_view->GetText()); | 1080 ASSERT_EQ(selected_text, omnibox_view->GetText()); |
| 1080 #endif | 1081 #endif |
| 1081 | 1082 |
| 1082 // As the current selected item is the new default item, pressing Escape key | 1083 // As the current selected item is the new default item, pressing Escape key |
| 1083 // should revert all directly. | 1084 // should revert all directly. |
| 1084 ASSERT_TRUE(omnibox_view->model()->OnEscapeKeyPressed()); | 1085 ASSERT_TRUE(omnibox_view->GetModel()->OnEscapeKeyPressed()); |
| 1085 ASSERT_EQ(old_text, omnibox_view->GetText()); | 1086 ASSERT_EQ(old_text, omnibox_view->GetText()); |
| 1086 ASSERT_TRUE(omnibox_view->IsSelectAll()); | 1087 ASSERT_TRUE(omnibox_view->IsSelectAll()); |
| 1087 } | 1088 } |
| 1088 | 1089 |
| 1089 void TabAcceptKeyword() { | 1090 void TabAcceptKeyword() { |
| 1090 OmniboxView* omnibox_view = NULL; | 1091 OmniboxView* omnibox_view = NULL; |
| 1091 ASSERT_NO_FATAL_FAILURE(GetOmniboxView(&omnibox_view)); | 1092 ASSERT_NO_FATAL_FAILURE(GetOmniboxView(&omnibox_view)); |
| 1092 | 1093 |
| 1093 string16 text = ASCIIToUTF16(kSearchKeyword); | 1094 string16 text = ASCIIToUTF16(kSearchKeyword); |
| 1094 | 1095 |
| 1095 // Trigger keyword hint mode. | 1096 // Trigger keyword hint mode. |
| 1096 ASSERT_NO_FATAL_FAILURE(SendKeySequence(kSearchKeywordKeys)); | 1097 ASSERT_NO_FATAL_FAILURE(SendKeySequence(kSearchKeywordKeys)); |
| 1097 ASSERT_TRUE(omnibox_view->model()->is_keyword_hint()); | 1098 ASSERT_TRUE(omnibox_view->GetModel()->is_keyword_hint()); |
| 1098 ASSERT_EQ(text, omnibox_view->model()->keyword()); | 1099 ASSERT_EQ(text, omnibox_view->GetModel()->keyword()); |
| 1099 ASSERT_EQ(text, omnibox_view->GetText()); | 1100 ASSERT_EQ(text, omnibox_view->GetText()); |
| 1100 | 1101 |
| 1101 // Trigger keyword mode by tab. | 1102 // Trigger keyword mode by tab. |
| 1102 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_TAB, 0)); | 1103 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_TAB, 0)); |
| 1103 ASSERT_FALSE(omnibox_view->model()->is_keyword_hint()); | 1104 ASSERT_FALSE(omnibox_view->GetModel()->is_keyword_hint()); |
| 1104 ASSERT_EQ(text, omnibox_view->model()->keyword()); | 1105 ASSERT_EQ(text, omnibox_view->GetModel()->keyword()); |
| 1105 ASSERT_TRUE(omnibox_view->GetText().empty()); | 1106 ASSERT_TRUE(omnibox_view->GetText().empty()); |
| 1106 | 1107 |
| 1107 // Revert to keyword hint mode. | 1108 // Revert to keyword hint mode. |
| 1108 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_BACK, 0)); | 1109 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_BACK, 0)); |
| 1109 ASSERT_TRUE(omnibox_view->model()->is_keyword_hint()); | 1110 ASSERT_TRUE(omnibox_view->GetModel()->is_keyword_hint()); |
| 1110 ASSERT_EQ(text, omnibox_view->model()->keyword()); | 1111 ASSERT_EQ(text, omnibox_view->GetModel()->keyword()); |
| 1111 ASSERT_EQ(text, omnibox_view->GetText()); | 1112 ASSERT_EQ(text, omnibox_view->GetText()); |
| 1112 | 1113 |
| 1113 // The location bar should still have focus. | 1114 // The location bar should still have focus. |
| 1114 ASSERT_TRUE(ui_test_utils::IsViewFocused(browser(), | 1115 ASSERT_TRUE(ui_test_utils::IsViewFocused(browser(), |
| 1115 location_bar_focus_view_id_)); | 1116 location_bar_focus_view_id_)); |
| 1116 | 1117 |
| 1117 // Trigger keyword mode by tab. | 1118 // Trigger keyword mode by tab. |
| 1118 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_TAB, 0)); | 1119 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_TAB, 0)); |
| 1119 ASSERT_FALSE(omnibox_view->model()->is_keyword_hint()); | 1120 ASSERT_FALSE(omnibox_view->GetModel()->is_keyword_hint()); |
| 1120 ASSERT_EQ(text, omnibox_view->model()->keyword()); | 1121 ASSERT_EQ(text, omnibox_view->GetModel()->keyword()); |
| 1121 ASSERT_TRUE(omnibox_view->GetText().empty()); | 1122 ASSERT_TRUE(omnibox_view->GetText().empty()); |
| 1122 | 1123 |
| 1123 // Revert to keyword hint mode with SHIFT+TAB. | 1124 // Revert to keyword hint mode with SHIFT+TAB. |
| 1124 #if defined(OS_MACOSX) | 1125 #if defined(OS_MACOSX) |
| 1125 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_BACKTAB, 0)); | 1126 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_BACKTAB, 0)); |
| 1126 #else | 1127 #else |
| 1127 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_TAB, ui::EF_SHIFT_DOWN)); | 1128 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_TAB, ui::EF_SHIFT_DOWN)); |
| 1128 #endif | 1129 #endif |
| 1129 ASSERT_TRUE(omnibox_view->model()->is_keyword_hint()); | 1130 ASSERT_TRUE(omnibox_view->GetModel()->is_keyword_hint()); |
| 1130 ASSERT_EQ(text, omnibox_view->model()->keyword()); | 1131 ASSERT_EQ(text, omnibox_view->GetModel()->keyword()); |
| 1131 ASSERT_EQ(text, omnibox_view->GetText()); | 1132 ASSERT_EQ(text, omnibox_view->GetText()); |
| 1132 | 1133 |
| 1133 ASSERT_TRUE(ui_test_utils::IsViewFocused(browser(), | 1134 ASSERT_TRUE(ui_test_utils::IsViewFocused(browser(), |
| 1134 location_bar_focus_view_id_)); | 1135 location_bar_focus_view_id_)); |
| 1135 } | 1136 } |
| 1136 | 1137 |
| 1137 void TabTraverseResultsTest() { | 1138 void TabTraverseResultsTest() { |
| 1138 OmniboxView* omnibox_view = NULL; | 1139 OmniboxView* omnibox_view = NULL; |
| 1139 ASSERT_NO_FATAL_FAILURE(GetOmniboxView(&omnibox_view)); | 1140 ASSERT_NO_FATAL_FAILURE(GetOmniboxView(&omnibox_view)); |
| 1140 OmniboxPopupModel* popup_model = omnibox_view->model()->popup_model(); | 1141 OmniboxPopupModel* popup_model = omnibox_view->GetModel()->popup_model(); |
| 1141 ASSERT_TRUE(popup_model); | 1142 ASSERT_TRUE(popup_model); |
| 1142 | 1143 |
| 1143 // Input something to trigger results. | 1144 // Input something to trigger results. |
| 1144 ASSERT_NO_FATAL_FAILURE(SendKeySequence(kDesiredTLDKeys)); | 1145 ASSERT_NO_FATAL_FAILURE(SendKeySequence(kDesiredTLDKeys)); |
| 1145 ASSERT_NO_FATAL_FAILURE(WaitForAutocompleteControllerDone()); | 1146 ASSERT_NO_FATAL_FAILURE(WaitForAutocompleteControllerDone()); |
| 1146 ASSERT_TRUE(popup_model->IsOpen()); | 1147 ASSERT_TRUE(popup_model->IsOpen()); |
| 1147 | 1148 |
| 1148 size_t old_selected_line = popup_model->selected_line(); | 1149 size_t old_selected_line = popup_model->selected_line(); |
| 1149 EXPECT_EQ(0U, old_selected_line); | 1150 EXPECT_EQ(0U, old_selected_line); |
| 1150 | 1151 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1184 AddHistoryEntry(kHistoryFoo, Time::Now() - TimeDelta::FromHours(1))); | 1185 AddHistoryEntry(kHistoryFoo, Time::Now() - TimeDelta::FromHours(1))); |
| 1185 | 1186 |
| 1186 // Load results. | 1187 // Load results. |
| 1187 ASSERT_NO_FATAL_FAILURE(omnibox_view->SelectAll(false)); | 1188 ASSERT_NO_FATAL_FAILURE(omnibox_view->SelectAll(false)); |
| 1188 ASSERT_NO_FATAL_FAILURE(SendKeySequence(kSearchKeywordKeys)); | 1189 ASSERT_NO_FATAL_FAILURE(SendKeySequence(kSearchKeywordKeys)); |
| 1189 ASSERT_NO_FATAL_FAILURE(WaitForAutocompleteControllerDone()); | 1190 ASSERT_NO_FATAL_FAILURE(WaitForAutocompleteControllerDone()); |
| 1190 | 1191 |
| 1191 // Trigger keyword mode by tab. | 1192 // Trigger keyword mode by tab. |
| 1192 string16 text = ASCIIToUTF16(kSearchKeyword); | 1193 string16 text = ASCIIToUTF16(kSearchKeyword); |
| 1193 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_TAB, 0)); | 1194 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_TAB, 0)); |
| 1194 ASSERT_FALSE(omnibox_view->model()->is_keyword_hint()); | 1195 ASSERT_FALSE(omnibox_view->GetModel()->is_keyword_hint()); |
| 1195 ASSERT_EQ(text, omnibox_view->model()->keyword()); | 1196 ASSERT_EQ(text, omnibox_view->GetModel()->keyword()); |
| 1196 ASSERT_TRUE(omnibox_view->GetText().empty()); | 1197 ASSERT_TRUE(omnibox_view->GetText().empty()); |
| 1197 | 1198 |
| 1198 // The location bar should still have focus. | 1199 // The location bar should still have focus. |
| 1199 ASSERT_TRUE(ui_test_utils::IsViewFocused(browser(), | 1200 ASSERT_TRUE(ui_test_utils::IsViewFocused(browser(), |
| 1200 location_bar_focus_view_id_)); | 1201 location_bar_focus_view_id_)); |
| 1201 | 1202 |
| 1202 // Pressing tab again should move to the next result and clear keyword | 1203 // Pressing tab again should move to the next result and clear keyword |
| 1203 // mode. | 1204 // mode. |
| 1204 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_TAB, 0)); | 1205 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_TAB, 0)); |
| 1205 ASSERT_EQ(1U, omnibox_view->model()->popup_model()->selected_line()); | 1206 ASSERT_EQ(1U, omnibox_view->GetModel()->popup_model()->selected_line()); |
| 1206 ASSERT_FALSE(omnibox_view->model()->is_keyword_hint()); | 1207 ASSERT_FALSE(omnibox_view->GetModel()->is_keyword_hint()); |
| 1207 ASSERT_NE(text, omnibox_view->model()->keyword()); | 1208 ASSERT_NE(text, omnibox_view->GetModel()->keyword()); |
| 1208 | 1209 |
| 1209 // The location bar should still have focus. | 1210 // The location bar should still have focus. |
| 1210 ASSERT_TRUE(ui_test_utils::IsViewFocused(browser(), | 1211 ASSERT_TRUE(ui_test_utils::IsViewFocused(browser(), |
| 1211 location_bar_focus_view_id_)); | 1212 location_bar_focus_view_id_)); |
| 1212 | 1213 |
| 1213 // Moving back up should not show keyword mode. | 1214 // Moving back up should not show keyword mode. |
| 1214 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_TAB, ui::EF_SHIFT_DOWN)); | 1215 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_TAB, ui::EF_SHIFT_DOWN)); |
| 1215 ASSERT_TRUE(omnibox_view->model()->is_keyword_hint()); | 1216 ASSERT_TRUE(omnibox_view->GetModel()->is_keyword_hint()); |
| 1216 ASSERT_EQ(text, omnibox_view->model()->keyword()); | 1217 ASSERT_EQ(text, omnibox_view->GetModel()->keyword()); |
| 1217 | 1218 |
| 1218 ASSERT_TRUE(ui_test_utils::IsViewFocused(browser(), | 1219 ASSERT_TRUE(ui_test_utils::IsViewFocused(browser(), |
| 1219 location_bar_focus_view_id_)); | 1220 location_bar_focus_view_id_)); |
| 1220 } | 1221 } |
| 1221 | 1222 |
| 1222 void PersistKeywordModeOnTabSwitch() { | 1223 void PersistKeywordModeOnTabSwitch() { |
| 1223 OmniboxView* omnibox_view = NULL; | 1224 OmniboxView* omnibox_view = NULL; |
| 1224 ASSERT_NO_FATAL_FAILURE(GetOmniboxView(&omnibox_view)); | 1225 ASSERT_NO_FATAL_FAILURE(GetOmniboxView(&omnibox_view)); |
| 1225 | 1226 |
| 1226 // Trigger keyword hint mode. | 1227 // Trigger keyword hint mode. |
| 1227 ASSERT_NO_FATAL_FAILURE(SendKeySequence(kSearchKeywordKeys)); | 1228 ASSERT_NO_FATAL_FAILURE(SendKeySequence(kSearchKeywordKeys)); |
| 1228 ASSERT_TRUE(omnibox_view->model()->is_keyword_hint()); | 1229 ASSERT_TRUE(omnibox_view->GetModel()->is_keyword_hint()); |
| 1229 ASSERT_EQ(kSearchKeyword, UTF16ToUTF8(omnibox_view->model()->keyword())); | 1230 ASSERT_EQ(kSearchKeyword, UTF16ToUTF8(omnibox_view->GetModel()->keyword())); |
| 1230 | 1231 |
| 1231 // Trigger keyword mode. | 1232 // Trigger keyword mode. |
| 1232 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_TAB, 0)); | 1233 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_TAB, 0)); |
| 1233 ASSERT_FALSE(omnibox_view->model()->is_keyword_hint()); | 1234 ASSERT_FALSE(omnibox_view->GetModel()->is_keyword_hint()); |
| 1234 ASSERT_EQ(kSearchKeyword, UTF16ToUTF8(omnibox_view->model()->keyword())); | 1235 ASSERT_EQ(kSearchKeyword, UTF16ToUTF8(omnibox_view->GetModel()->keyword())); |
| 1235 | 1236 |
| 1236 // Input something as search text. | 1237 // Input something as search text. |
| 1237 ASSERT_NO_FATAL_FAILURE(SendKeySequence(kSearchTextKeys)); | 1238 ASSERT_NO_FATAL_FAILURE(SendKeySequence(kSearchTextKeys)); |
| 1238 | 1239 |
| 1239 // Create a new tab. | 1240 // Create a new tab. |
| 1240 chrome::NewTab(browser()); | 1241 chrome::NewTab(browser()); |
| 1241 | 1242 |
| 1242 // Switch back to the first tab. | 1243 // Switch back to the first tab. |
| 1243 chrome::ActivateTabAt(browser(), 0, true); | 1244 chrome::ActivateTabAt(browser(), 0, true); |
| 1244 | 1245 |
| 1245 // Make sure we're still in keyword mode. | 1246 // Make sure we're still in keyword mode. |
| 1246 ASSERT_EQ(kSearchKeyword, UTF16ToUTF8(omnibox_view->model()->keyword())); | 1247 ASSERT_EQ(kSearchKeyword, UTF16ToUTF8(omnibox_view->GetModel()->keyword())); |
| 1247 } | 1248 } |
| 1248 | 1249 |
| 1249 void CtrlKeyPressedWithInlineAutocompleteTest() { | 1250 void CtrlKeyPressedWithInlineAutocompleteTest() { |
| 1250 OmniboxView* omnibox_view = NULL; | 1251 OmniboxView* omnibox_view = NULL; |
| 1251 ASSERT_NO_FATAL_FAILURE(GetOmniboxView(&omnibox_view)); | 1252 ASSERT_NO_FATAL_FAILURE(GetOmniboxView(&omnibox_view)); |
| 1252 OmniboxPopupModel* popup_model = omnibox_view->model()->popup_model(); | 1253 OmniboxPopupModel* popup_model = omnibox_view->GetModel()->popup_model(); |
| 1253 ASSERT_TRUE(popup_model); | 1254 ASSERT_TRUE(popup_model); |
| 1254 | 1255 |
| 1255 // Input something to trigger inline autocomplete. | 1256 // Input something to trigger inline autocomplete. |
| 1256 ASSERT_NO_FATAL_FAILURE(SendKeySequence(kInlineAutocompleteTextKeys)); | 1257 ASSERT_NO_FATAL_FAILURE(SendKeySequence(kInlineAutocompleteTextKeys)); |
| 1257 ASSERT_NO_FATAL_FAILURE(WaitForAutocompleteControllerDone()); | 1258 ASSERT_NO_FATAL_FAILURE(WaitForAutocompleteControllerDone()); |
| 1258 ASSERT_TRUE(popup_model->IsOpen()); | 1259 ASSERT_TRUE(popup_model->IsOpen()); |
| 1259 | 1260 |
| 1260 string16 old_text = omnibox_view->GetText(); | 1261 string16 old_text = omnibox_view->GetText(); |
| 1261 | 1262 |
| 1262 // Make sure inline autocomplete is triggerred. | 1263 // Make sure inline autocomplete is triggerred. |
| 1263 EXPECT_GT(old_text.length(), arraysize(kInlineAutocompleteText) - 1); | 1264 EXPECT_GT(old_text.length(), arraysize(kInlineAutocompleteText) - 1); |
| 1264 | 1265 |
| 1265 // Press ctrl key. | 1266 // Press ctrl key. |
| 1266 omnibox_view->model()->OnControlKeyChanged(true); | 1267 omnibox_view->GetModel()->OnControlKeyChanged(true); |
| 1267 | 1268 |
| 1268 // Inline autocomplete should still be there. | 1269 // Inline autocomplete should still be there. |
| 1269 EXPECT_EQ(old_text, omnibox_view->GetText()); | 1270 EXPECT_EQ(old_text, omnibox_view->GetText()); |
| 1270 } | 1271 } |
| 1271 | 1272 |
| 1272 #if defined(USE_AURA) | 1273 #if defined(USE_AURA) |
| 1273 const BrowserView* GetBrowserView() const { | 1274 const BrowserView* GetBrowserView() const { |
| 1274 return static_cast<BrowserView*>(browser()->window()); | 1275 return static_cast<BrowserView*>(browser()->window()); |
| 1275 } | 1276 } |
| 1276 | 1277 |
| (...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1588 #if defined(OS_LINUX) | 1589 #if defined(OS_LINUX) |
| 1589 #define MAYBE_PasteReplacingAll DISABLED_PasteReplacingAll | 1590 #define MAYBE_PasteReplacingAll DISABLED_PasteReplacingAll |
| 1590 #else | 1591 #else |
| 1591 #define MAYBE_PasteReplacingAll PasteReplacingAll | 1592 #define MAYBE_PasteReplacingAll PasteReplacingAll |
| 1592 #endif | 1593 #endif |
| 1593 | 1594 |
| 1594 // http://crbug.com/12316 | 1595 // http://crbug.com/12316 |
| 1595 IN_PROC_BROWSER_TEST_F(OmniboxViewTest, MAYBE_PasteReplacingAll) { | 1596 IN_PROC_BROWSER_TEST_F(OmniboxViewTest, MAYBE_PasteReplacingAll) { |
| 1596 OmniboxView* omnibox_view = NULL; | 1597 OmniboxView* omnibox_view = NULL; |
| 1597 ASSERT_NO_FATAL_FAILURE(GetOmniboxView(&omnibox_view)); | 1598 ASSERT_NO_FATAL_FAILURE(GetOmniboxView(&omnibox_view)); |
| 1598 OmniboxPopupModel* popup_model = omnibox_view->model()->popup_model(); | 1599 OmniboxPopupModel* popup_model = omnibox_view->GetModel()->popup_model(); |
| 1599 ASSERT_TRUE(popup_model); | 1600 ASSERT_TRUE(popup_model); |
| 1600 | 1601 |
| 1601 SetClipboardText(kSearchText); | 1602 SetClipboardText(kSearchText); |
| 1602 | 1603 |
| 1603 // Paste text. | 1604 // Paste text. |
| 1604 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_V, ui::EF_CONTROL_DOWN)); | 1605 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_V, ui::EF_CONTROL_DOWN)); |
| 1605 ASSERT_NO_FATAL_FAILURE(WaitForAutocompleteControllerDone()); | 1606 ASSERT_NO_FATAL_FAILURE(WaitForAutocompleteControllerDone()); |
| 1606 ASSERT_TRUE(popup_model->IsOpen()); | 1607 ASSERT_TRUE(popup_model->IsOpen()); |
| 1607 | 1608 |
| 1608 // Inline autocomplete shouldn't be triggered. | 1609 // Inline autocomplete shouldn't be triggered. |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1665 | 1666 |
| 1666 // Middle-clicking shouldn't select all the text either. | 1667 // Middle-clicking shouldn't select all the text either. |
| 1667 ASSERT_NO_FATAL_FAILURE( | 1668 ASSERT_NO_FATAL_FAILURE( |
| 1668 ClickFocusViewOrigin(ui_controls::LEFT, kClickOffset, kClickOffset)); | 1669 ClickFocusViewOrigin(ui_controls::LEFT, kClickOffset, kClickOffset)); |
| 1669 ASSERT_NO_FATAL_FAILURE(ClickBrowserWindowCenter()); | 1670 ASSERT_NO_FATAL_FAILURE(ClickBrowserWindowCenter()); |
| 1670 ASSERT_NO_FATAL_FAILURE( | 1671 ASSERT_NO_FATAL_FAILURE( |
| 1671 ClickFocusViewOrigin(ui_controls::MIDDLE, kClickOffset, kClickOffset)); | 1672 ClickFocusViewOrigin(ui_controls::MIDDLE, kClickOffset, kClickOffset)); |
| 1672 EXPECT_FALSE(omnibox_view->IsSelectAll()); | 1673 EXPECT_FALSE(omnibox_view->IsSelectAll()); |
| 1673 } | 1674 } |
| 1674 #endif // defined(USE_AURA) | 1675 #endif // defined(USE_AURA) |
| OLD | NEW |