Chromium Code Reviews| Index: chrome/browser/ui/omnibox/omnibox_view_browsertest.cc |
| diff --git a/chrome/browser/ui/omnibox/omnibox_view_browsertest.cc b/chrome/browser/ui/omnibox/omnibox_view_browsertest.cc |
| index 23e28df07691b091d7845d493d205a8e7d2d49c5..5e378446190d800f845a66b9c5eed1a75a07ccb8 100644 |
| --- a/chrome/browser/ui/omnibox/omnibox_view_browsertest.cc |
| +++ b/chrome/browser/ui/omnibox/omnibox_view_browsertest.cc |
| @@ -884,6 +884,60 @@ IN_PROC_BROWSER_TEST_F(OmniboxViewTest, FocusSearchLongUrl) { |
| ASSERT_NO_FATAL_FAILURE(WaitForAutocompleteControllerDone()); |
| } |
| +// Make sure the display text is preserved on a focus search when the display |
|
Peter Kasting
2016/10/25 02:46:33
Nit: on a focus search when -> when calling FocusS
Tom (Use chromium acct)
2016/10/25 18:50:31
Done.
|
| +// text is not the permanent text. |
| +IN_PROC_BROWSER_TEST_F(OmniboxViewTest, PreserveDisplayTextOnFocusSearch) { |
| + OmniboxView* omnibox_view = NULL; |
| + ASSERT_NO_FATAL_FAILURE(GetOmniboxView(&omnibox_view)); |
| + |
| + OmniboxPopupModel* popup_model = omnibox_view->model()->popup_model(); |
| + ASSERT_TRUE(popup_model); |
| + |
| + // Input something that can match history items. |
| + omnibox_view->SetUserText(ASCIIToUTF16("site.com/p")); |
| + ASSERT_NO_FATAL_FAILURE(WaitForAutocompleteControllerDone()); |
| + ASSERT_TRUE(popup_model->IsOpen()); |
|
Peter Kasting
2016/10/25 02:46:33
Nit: Change ASSERT to EXPECT on any of these where
Tom (Use chromium acct)
2016/10/25 18:50:31
Done.
|
| + ASSERT_EQ(ASCIIToUTF16("site.com/path/1"), omnibox_view->GetText()); |
| + base::string16::size_type start, end; |
| + omnibox_view->GetSelectionBounds(&start, &end); |
| + ASSERT_EQ(10U, std::min(start, end)); |
| + ASSERT_EQ(15U, std::max(start, end)); |
| + |
| + // Focus searching with autocomplete text should preserve the autocompleted |
|
Peter Kasting
2016/10/25 02:46:33
Nit: Focus searching with autocomplete text -> Cal
Tom (Use chromium acct)
2016/10/25 18:50:31
Done.
|
| + // text, and should select all. |
| + chrome::FocusSearch(browser()); |
| + ASSERT_NO_FATAL_FAILURE(WaitForAutocompleteControllerDone()); |
| + ASSERT_EQ(ASCIIToUTF16("site.com/path/1"), omnibox_view->GetText()); |
| + omnibox_view->GetSelectionBounds(&start, &end); |
| + ASSERT_EQ(0U, std::min(start, end)); |
| + ASSERT_EQ(15U, std::max(start, end)); |
| + |
| + // Press backspace twice and the omnibox should be empty. |
| + ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_BACK, 0)); |
| + ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_BACK, 0)); |
| + EXPECT_EQ(base::string16(), omnibox_view->GetText()); |
| + omnibox_view->GetSelectionBounds(&start, &end); |
| + ASSERT_EQ(0U, start); |
| + ASSERT_EQ(0U, end); |
| + |
| + // Focus searching when we select a non-default autocomplete entry should |
|
Peter Kasting
2016/10/25 02:46:33
Nit: Calling FocusSearch() with temporary text sho
Tom (Use chromium acct)
2016/10/25 18:50:31
Done.
|
| + // preserve the suggested text, and should select all. |
| + omnibox_view->SetUserText(ASCIIToUTF16("site.com/p")); |
| + ASSERT_NO_FATAL_FAILURE(WaitForAutocompleteControllerDone()); |
| + ASSERT_TRUE(popup_model->IsOpen()); |
| + omnibox_view->model()->OnUpOrDownKeyPressed(1); |
| + ASSERT_EQ(ASCIIToUTF16("www.site.com/path/2"), omnibox_view->GetText()); |
| + omnibox_view->GetSelectionBounds(&start, &end); |
| + ASSERT_EQ(start, end); |
| + |
| + chrome::FocusSearch(browser()); |
| + ASSERT_NO_FATAL_FAILURE(WaitForAutocompleteControllerDone()); |
| + ASSERT_EQ(ASCIIToUTF16("www.site.com/path/2"), omnibox_view->GetText()); |
| + omnibox_view->GetSelectionBounds(&start, &end); |
| + ASSERT_EQ(0U, std::min(start, end)); |
| + ASSERT_EQ(19U, std::max(start, end)); |
| +} |
| + |
| IN_PROC_BROWSER_TEST_F(OmniboxViewTest, AcceptKeywordByTypingQuestionMark) { |
| OmniboxView* omnibox_view = NULL; |
| ASSERT_NO_FATAL_FAILURE(GetOmniboxView(&omnibox_view)); |