Commit 1ec35aa2 authored by Tommy C. Li's avatar Tommy C. Li Committed by Commit Bot

Omnibox UI Experiments: Steady State Elision - double click drag test

When the user double-click drags, we should unelide on the second mouse
down and start word selection mode.

This CL adds a test for the above behavior.

Bug: 797354
Change-Id: I64d0b880a0b560c6f249e2a15f9e38b36cb51364
Reviewed-on: https://chromium-review.googlesource.com/1012512Reviewed-by: default avatarJustin Donnelly <jdonnelly@chromium.org>
Commit-Queue: Tommy Li <tommycli@chromium.org>
Cr-Commit-Position: refs/heads/master@{#550801}
parent 0ed91b16
...@@ -131,6 +131,8 @@ class OmniboxViewViews : public OmniboxView, ...@@ -131,6 +131,8 @@ class OmniboxViewViews : public OmniboxView,
MouseTripleClick); MouseTripleClick);
FRIEND_TEST_ALL_PREFIXES(OmniboxViewViewsSteadyStateElisionsTest, FRIEND_TEST_ALL_PREFIXES(OmniboxViewViewsSteadyStateElisionsTest,
MouseClickDrag); MouseClickDrag);
FRIEND_TEST_ALL_PREFIXES(OmniboxViewViewsSteadyStateElisionsTest,
MouseDoubleClickDrag);
friend class OmniboxViewViewsTest; friend class OmniboxViewViewsTest;
friend class OmniboxViewViewsSteadyStateElisionsTest; friend class OmniboxViewViewsSteadyStateElisionsTest;
......
...@@ -252,7 +252,7 @@ void OmniboxViewViewsTest::SetUp() { ...@@ -252,7 +252,7 @@ void OmniboxViewViewsTest::SetUp() {
views::Widget::InitParams params = views::Widget::InitParams params =
CreateParams(views::Widget::InitParams::TYPE_POPUP); CreateParams(views::Widget::InitParams::TYPE_POPUP);
params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
params.bounds = gfx::Rect(0, 0, 100, 40); params.bounds = gfx::Rect(0, 0, 400, 40);
widget_->Init(params); widget_->Init(params);
widget_->Show(); widget_->Show();
...@@ -688,3 +688,35 @@ TEST_F(OmniboxViewViewsSteadyStateElisionsTest, MouseClickDrag) { ...@@ -688,3 +688,35 @@ TEST_F(OmniboxViewViewsSteadyStateElisionsTest, MouseClickDrag) {
EXPECT_EQ(10U, start); EXPECT_EQ(10U, start);
EXPECT_EQ(12U, end); EXPECT_EQ(12U, end);
} }
TEST_F(OmniboxViewViewsSteadyStateElisionsTest, MouseDoubleClickDrag) {
// Expect that after a double-click after the third character of the elided
// text, the text is unelided, and https://|example|.com is selected.
SendMouseClick(4 * kCharacterWidth);
omnibox_view()->OnMousePressed(CreateMouseEvent(
ui::ET_MOUSE_PRESSED, GetPointInTextAtXOffset(4 * kCharacterWidth)));
ExpectFullUrlDisplayed();
size_t start, end;
omnibox_view()->GetSelectionBounds(&start, &end);
EXPECT_EQ(8U, start);
EXPECT_EQ(15U, end);
// Expect that dragging to the fourth character of the full URL (between the
// the 'p' and the 's' of https), will word-select the scheme and domain, so
// the new selection will be |https://example|.com. The expected selection is
// backwards, since we are dragging the mouse from the domain to the scheme.
omnibox_view()->OnMouseDragged(CreateMouseEvent(
ui::ET_MOUSE_DRAGGED, GetPointInTextAtXOffset(2 * kCharacterWidth)));
ExpectFullUrlDisplayed();
omnibox_view()->GetSelectionBounds(&start, &end);
EXPECT_EQ(15U, start);
EXPECT_EQ(0U, end);
// Expect the selection to stay the same after mouse-release.
omnibox_view()->OnMouseReleased(CreateMouseEvent(
ui::ET_MOUSE_RELEASED, GetPointInTextAtXOffset(2 * kCharacterWidth)));
ExpectFullUrlDisplayed();
omnibox_view()->GetSelectionBounds(&start, &end);
EXPECT_EQ(15U, start);
EXPECT_EQ(0U, end);
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment