OLD | NEW |
---|---|
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "chrome/browser/ui/views/omnibox/omnibox_view_views.h" | 5 #include "chrome/browser/ui/views/omnibox/omnibox_view_views.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
343 EXPECT_TRUE(omnibox_view->model()->popup_model()->IsOpen()); | 343 EXPECT_TRUE(omnibox_view->model()->popup_model()->IsOpen()); |
344 | 344 |
345 // Simulate a mouse drag of the omnibox text, and the omnibox should close. | 345 // Simulate a mouse drag of the omnibox text, and the omnibox should close. |
346 ui::MouseEvent dragged(ui::ET_MOUSE_DRAGGED, point, point, | 346 ui::MouseEvent dragged(ui::ET_MOUSE_DRAGGED, point, point, |
347 ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON, 0); | 347 ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON, 0); |
348 omnibox_view_views->OnMouseDragged(dragged); | 348 omnibox_view_views->OnMouseDragged(dragged); |
349 | 349 |
350 EXPECT_FALSE(omnibox_view->model()->popup_model()->IsOpen()); | 350 EXPECT_FALSE(omnibox_view->model()->popup_model()->IsOpen()); |
351 } | 351 } |
352 | 352 |
353 IN_PROC_BROWSER_TEST_F(OmniboxViewViewsTest, MaintainCursorAfterFocusCycle) { | |
354 OmniboxView* omnibox_view = NULL; | |
Peter Kasting
2017/04/10 23:04:13
Nit: nullptr_t
Kevin Bailey
2017/04/11 14:12:42
Fixed above too.
| |
355 ASSERT_NO_FATAL_FAILURE(GetOmniboxViewForBrowser(browser(), &omnibox_view)); | |
356 OmniboxViewViews* omnibox_view_views = | |
357 static_cast<OmniboxViewViews*>(omnibox_view); | |
358 | |
359 // Populate suggestions for the omnibox popup. | |
360 AutocompleteController* autocomplete_controller = | |
361 omnibox_view->model()->popup_model()->autocomplete_controller(); | |
362 AutocompleteResult& results = autocomplete_controller->result_; | |
363 ACMatches matches; | |
364 AutocompleteMatch match; | |
365 match.destination_url = GURL("http://autocomplete-result/"); | |
366 match.allowed_to_be_default_match = true; | |
367 match.type = AutocompleteMatchType::HISTORY_TITLE; | |
368 match.relevance = 500; | |
Peter Kasting
2017/04/10 23:04:13
Do things like the type and relevance matter?
Kevin Bailey
2017/04/11 14:12:42
I copy-pasted the previous test, since it was most
Peter Kasting
2017/04/11 20:04:39
I would likely shrink rather than refactor. Maybe
Kevin Bailey
2017/04/12 14:57:03
It needs the type and relevance, but only needed o
| |
369 matches.push_back(match); | |
370 match.destination_url = GURL("http://autocomplete-result2/"); | |
371 matches.push_back(match); | |
Peter Kasting
2017/04/10 23:04:13
Do we need two suggestions instead of just the one
Kevin Bailey
2017/04/11 14:12:41
Same as above.
| |
372 const AutocompleteInput input( | |
373 base::ASCIIToUTF16("autocomplete-result"), 19, "autocomplete-result", | |
374 GURL("http://autocomplete-result/"), | |
375 metrics::OmniboxEventProto::INVALID_SPEC, false, false, true, true, false, | |
376 TestSchemeClassifier()); | |
377 results.AppendMatches(input, matches); | |
378 results.SortAndCull( | |
379 input, TemplateURLServiceFactory::GetForProfile(browser()->profile())); | |
380 | |
381 // The omnibox popup should open with suggestions displayed. | |
382 omnibox_view->model()->popup_model()->OnResultChanged(); | |
383 EXPECT_TRUE(omnibox_view->model()->popup_model()->IsOpen()); | |
384 | |
385 // The omnibox text should be selected. | |
386 EXPECT_TRUE(omnibox_view->IsSelectAll()); | |
387 | |
388 // Simulate a mouse click before dragging the mouse. | |
Peter Kasting
2017/04/10 23:04:13
(a) I don't understand the "why" of this
(b) I don
Kevin Bailey
2017/04/11 14:12:41
Stale. All I want is a mouse click and release. Co
| |
389 gfx::Point point(omnibox_view_views->x(), omnibox_view_views->y()); | |
Peter Kasting
2017/04/10 23:04:13
Nit: (omnibox_view_views->origin())?
Kevin Bailey
2017/04/11 14:12:41
Fixed above too.
| |
390 ui::MouseEvent pressed(ui::ET_MOUSE_PRESSED, point, point, | |
391 ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON, | |
392 ui::EF_LEFT_MOUSE_BUTTON); | |
393 omnibox_view_views->OnMousePressed(pressed); | |
394 omnibox_view_views->OnMouseReleased(pressed); | |
395 EXPECT_TRUE(omnibox_view->model()->popup_model()->IsOpen()); | |
396 | |
397 omnibox_view_views->OnBlur(); | |
398 EXPECT_FALSE(omnibox_view->model()->popup_model()->IsOpen()); | |
399 | |
400 // Redo the above | |
401 omnibox_view_views->OnFocus(); | |
402 results.AppendMatches(input, matches); | |
403 results.SortAndCull( | |
404 input, TemplateURLServiceFactory::GetForProfile(browser()->profile())); | |
405 omnibox_view->model()->popup_model()->OnResultChanged(); | |
406 EXPECT_TRUE(omnibox_view->model()->popup_model()->IsOpen()); | |
407 size_t start = 0, end; | |
408 omnibox_view->GetSelectionBounds(&start, &end); | |
409 // Make sure cursor isn't homed. | |
410 EXPECT_NE(static_cast<size_t>(0), start); | |
Peter Kasting
2017/04/10 23:04:13
Nit: Just say 0U
Kevin Bailey
2017/04/11 14:12:41
Done.
| |
411 // Blur or it dchecks when rendering. | |
Peter Kasting
2017/04/10 23:04:13
What dchecks? Why?
Kevin Bailey
2017/04/11 14:12:42
There seem to be stale messages in the work queue
Peter Kasting
2017/04/11 20:04:39
OK. I'm not sure I fully understand the problem y
Kevin Bailey
2017/04/12 14:57:03
Done.
| |
412 omnibox_view_views->OnBlur(); | |
413 } | |
414 | |
353 IN_PROC_BROWSER_TEST_F(OmniboxViewViewsTest, BackgroundIsOpaque) { | 415 IN_PROC_BROWSER_TEST_F(OmniboxViewViewsTest, BackgroundIsOpaque) { |
354 // The omnibox text should be rendered on an opaque background. Otherwise, we | 416 // The omnibox text should be rendered on an opaque background. Otherwise, we |
355 // can't use subpixel rendering. | 417 // can't use subpixel rendering. |
356 OmniboxViewViews* view = BrowserView::GetBrowserViewForBrowser(browser())-> | 418 OmniboxViewViews* view = BrowserView::GetBrowserViewForBrowser(browser())-> |
357 toolbar()->location_bar()->omnibox_view(); | 419 toolbar()->location_bar()->omnibox_view(); |
358 ASSERT_TRUE(view); | 420 ASSERT_TRUE(view); |
359 EXPECT_FALSE(view->GetRenderText()->subpixel_rendering_suppressed()); | 421 EXPECT_FALSE(view->GetRenderText()->subpixel_rendering_suppressed()); |
360 } | 422 } |
361 | 423 |
362 // Tests if executing a command hides touch editing handles. | 424 // Tests if executing a command hides touch editing handles. |
(...skipping 23 matching lines...) Expand all Loading... | |
386 IN_PROC_BROWSER_TEST_F(OmniboxViewViewsTest, FocusedTextInputClient) { | 448 IN_PROC_BROWSER_TEST_F(OmniboxViewViewsTest, FocusedTextInputClient) { |
387 chrome::FocusLocationBar(browser()); | 449 chrome::FocusLocationBar(browser()); |
388 OmniboxView* view = NULL; | 450 OmniboxView* view = NULL; |
389 ASSERT_NO_FATAL_FAILURE(GetOmniboxViewForBrowser(browser(), &view)); | 451 ASSERT_NO_FATAL_FAILURE(GetOmniboxViewForBrowser(browser(), &view)); |
390 OmniboxViewViews* omnibox_view_views = static_cast<OmniboxViewViews*>(view); | 452 OmniboxViewViews* omnibox_view_views = static_cast<OmniboxViewViews*>(view); |
391 ui::InputMethod* input_method = | 453 ui::InputMethod* input_method = |
392 omnibox_view_views->GetWidget()->GetInputMethod(); | 454 omnibox_view_views->GetWidget()->GetInputMethod(); |
393 EXPECT_EQ(static_cast<ui::TextInputClient*>(omnibox_view_views), | 455 EXPECT_EQ(static_cast<ui::TextInputClient*>(omnibox_view_views), |
394 input_method->GetTextInputClient()); | 456 input_method->GetTextInputClient()); |
395 } | 457 } |
OLD | NEW |