Chromium Code Reviews| Index: chrome/browser/ui/views/omnibox/omnibox_view_views_browsertest.cc |
| diff --git a/chrome/browser/ui/views/omnibox/omnibox_view_views_browsertest.cc b/chrome/browser/ui/views/omnibox/omnibox_view_views_browsertest.cc |
| index 91b12dd6237d52870b183983672973778281b1cf..58ef71144fa93e428440e0557757f7dbf9fc40d5 100644 |
| --- a/chrome/browser/ui/views/omnibox/omnibox_view_views_browsertest.cc |
| +++ b/chrome/browser/ui/views/omnibox/omnibox_view_views_browsertest.cc |
| @@ -301,7 +301,7 @@ IN_PROC_BROWSER_TEST_F(OmniboxViewViewsTest, SelectAllOnTabToFocus) { |
| } |
| IN_PROC_BROWSER_TEST_F(OmniboxViewViewsTest, CloseOmniboxPopupOnTextDrag) { |
| - OmniboxView* omnibox_view = NULL; |
| + OmniboxView* omnibox_view = nullptr; |
| ASSERT_NO_FATAL_FAILURE(GetOmniboxViewForBrowser(browser(), &omnibox_view)); |
| OmniboxViewViews* omnibox_view_views = |
| static_cast<OmniboxViewViews*>(omnibox_view); |
| @@ -317,8 +317,6 @@ IN_PROC_BROWSER_TEST_F(OmniboxViewViewsTest, CloseOmniboxPopupOnTextDrag) { |
| match.type = AutocompleteMatchType::HISTORY_TITLE; |
| match.relevance = 500; |
| matches.push_back(match); |
| - match.destination_url = GURL("http://autocomplete-result2/"); |
| - matches.push_back(match); |
| const AutocompleteInput input( |
| base::ASCIIToUTF16("a"), base::string16::npos, std::string(), GURL(), |
| metrics::OmniboxEventProto::INVALID_SPEC, false, false, true, true, false, |
| @@ -335,7 +333,7 @@ IN_PROC_BROWSER_TEST_F(OmniboxViewViewsTest, CloseOmniboxPopupOnTextDrag) { |
| EXPECT_TRUE(omnibox_view->IsSelectAll()); |
| // Simulate a mouse click before dragging the mouse. |
| - gfx::Point point(omnibox_view_views->x(), omnibox_view_views->y()); |
| + gfx::Point point(omnibox_view_views->origin()); |
| ui::MouseEvent pressed(ui::ET_MOUSE_PRESSED, point, point, |
| ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON, |
| ui::EF_LEFT_MOUSE_BUTTON); |
| @@ -350,6 +348,68 @@ IN_PROC_BROWSER_TEST_F(OmniboxViewViewsTest, CloseOmniboxPopupOnTextDrag) { |
| EXPECT_FALSE(omnibox_view->model()->popup_model()->IsOpen()); |
| } |
| +IN_PROC_BROWSER_TEST_F(OmniboxViewViewsTest, MaintainCursorAfterFocusCycle) { |
| + OmniboxView* omnibox_view = nullptr; |
| + ASSERT_NO_FATAL_FAILURE(GetOmniboxViewForBrowser(browser(), &omnibox_view)); |
| + OmniboxViewViews* omnibox_view_views = |
| + static_cast<OmniboxViewViews*>(omnibox_view); |
| + |
| + // Populate suggestions for the omnibox popup. |
| + AutocompleteController* autocomplete_controller = |
| + omnibox_view->model()->popup_model()->autocomplete_controller(); |
| + AutocompleteResult& results = autocomplete_controller->result_; |
| + ACMatches matches; |
| + AutocompleteMatch match; |
|
Peter Kasting
2017/04/12 23:48:24
Nit: Could do
AutocompleteMatch match(nullptr,
Kevin Bailey
2017/04/18 19:45:13
Done.
|
| + match.destination_url = GURL("http://autocomplete-result/"); |
| + match.allowed_to_be_default_match = true; |
| + match.type = AutocompleteMatchType::HISTORY_TITLE; |
| + match.relevance = 500; |
| + matches.push_back(match); |
| + const AutocompleteInput input( |
| + base::ASCIIToUTF16("autocomplete-result"), 19, "autocomplete-result", |
| + GURL("http://autocomplete-result/"), |
| + metrics::OmniboxEventProto::INVALID_SPEC, false, false, true, true, false, |
| + TestSchemeClassifier()); |
| + results.AppendMatches(input, matches); |
| + results.SortAndCull( |
| + input, TemplateURLServiceFactory::GetForProfile(browser()->profile())); |
| + |
| + // The omnibox popup should open with suggestions displayed. |
| + omnibox_view->model()->popup_model()->OnResultChanged(); |
| + EXPECT_TRUE(omnibox_view->model()->popup_model()->IsOpen()); |
| + |
| + // The omnibox text should be selected. |
| + EXPECT_TRUE(omnibox_view->IsSelectAll()); |
| + |
| + // Simulate a mouse click to trigger focus. |
| + gfx::Point point(omnibox_view_views->origin()); |
| + ui::MouseEvent pressed(ui::ET_MOUSE_PRESSED, point, point, |
| + ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON, |
| + ui::EF_LEFT_MOUSE_BUTTON); |
| + omnibox_view_views->OnMousePressed(pressed); |
| + omnibox_view_views->OnMouseReleased(pressed); |
| + EXPECT_TRUE(omnibox_view->model()->popup_model()->IsOpen()); |
| + |
| + omnibox_view_views->OnBlur(); |
| + EXPECT_FALSE(omnibox_view->model()->popup_model()->IsOpen()); |
| + |
| + // Redo the above |
|
Peter Kasting
2017/04/12 23:48:24
Nit: Be clearer (since "the above" covers a lot);
Kevin Bailey
2017/04/18 19:45:13
Done.
|
| + omnibox_view_views->OnFocus(); |
| + results.AppendMatches(input, matches); |
| + results.SortAndCull( |
| + input, TemplateURLServiceFactory::GetForProfile(browser()->profile())); |
| + omnibox_view->model()->popup_model()->OnResultChanged(); |
| + EXPECT_TRUE(omnibox_view->model()->popup_model()->IsOpen()); |
| + size_t start = 0, end; |
| + omnibox_view->GetSelectionBounds(&start, &end); |
| + // Make sure cursor isn't homed. |
|
Peter Kasting
2017/04/12 23:48:24
Nit: This really goes above the declaration of sta
Kevin Bailey
2017/04/18 19:45:13
Done.
|
| + EXPECT_NE(0U, start); |
|
Peter Kasting
2017/04/12 23:48:25
Nit: It's not immediately obvious why this should
Kevin Bailey
2017/04/18 19:45:13
Done.
|
| + // Blur or it dchecks when rendering. The above queues messages for the |
| + // task which get handled after the test is finished. Blurring quiesces |
| + // them. |
|
Peter Kasting
2017/04/12 23:48:24
OK... this doesn't really make things clearer than
Kevin Bailey
2017/04/13 00:07:12
The part about this that bothers me is that the ne
Peter Kasting
2017/04/13 00:12:15
Yes, I agree with your instinct. Spinning the mes
Kevin Bailey
2017/04/17 16:39:11
(For the reader, since this was discussed off-line
|
| + omnibox_view_views->OnBlur(); |
| +} |
| + |
| IN_PROC_BROWSER_TEST_F(OmniboxViewViewsTest, BackgroundIsOpaque) { |
| // The omnibox text should be rendered on an opaque background. Otherwise, we |
| // can't use subpixel rendering. |