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

Omnibox UI Experiments: Steady State Elisions double/triple click tests

This CL tests that double-click triggers unelision of steady state
elided URLs with the proper portion selected afterwards. This unelision
occurs on the second mousedown.

It also tests that triple-click triggers unelision and ends with
everything selected.

Bug: 797354
Change-Id: I3174242ad5f188ef0808a859a376bc0393a76faf
Reviewed-on: https://chromium-review.googlesource.com/1008866
Commit-Queue: Tommy Li <tommycli@chromium.org>
Reviewed-by: default avatarJustin Donnelly <jdonnelly@chromium.org>
Cr-Commit-Position: refs/heads/master@{#550624}
parent df0c7397
......@@ -121,8 +121,14 @@ class OmniboxViewViews : public OmniboxView,
FRIEND_TEST_ALL_PREFIXES(OmniboxViewViewsTest, MaintainCursorAfterFocusCycle);
FRIEND_TEST_ALL_PREFIXES(OmniboxViewViewsTest, OnBlur);
FRIEND_TEST_ALL_PREFIXES(OmniboxViewViewsTest, DoNotNavigateOnDrop);
FRIEND_TEST_ALL_PREFIXES(OmniboxViewViewsSteadyStateElisionsTest,
FirstMouseClickFocusesOnly);
FRIEND_TEST_ALL_PREFIXES(OmniboxViewViewsSteadyStateElisionsTest,
CaretPlacementByMouse);
FRIEND_TEST_ALL_PREFIXES(OmniboxViewViewsSteadyStateElisionsTest,
MouseDoubleClick);
FRIEND_TEST_ALL_PREFIXES(OmniboxViewViewsSteadyStateElisionsTest,
MouseTripleClick);
friend class OmniboxViewViewsTest;
friend class OmniboxViewViewsSteadyStateElisionsTest;
......
......@@ -446,12 +446,16 @@ TEST_F(OmniboxViewViewsTest, RevertOnBlur) {
class OmniboxViewViewsSteadyStateElisionsTest : public OmniboxViewViewsTest {
protected:
const gfx::Point kPointInText = gfx::Point(20, 20);
void SetUp() override {
scoped_feature_list_.InitAndEnableFeature(
omnibox::kUIExperimentHideSteadyStateUrlSchemeAndSubdomains);
OmniboxViewViewsTest::SetUp();
// Advance 5 seconds from epoch so the time is not considered null.
clock_.Advance(base::TimeDelta::FromSeconds(5));
ui::SetEventTickClockForTesting(&clock_);
toolbar_model()->set_formatted_full_url(
......@@ -495,6 +499,14 @@ class OmniboxViewViewsSteadyStateElisionsTest : public OmniboxViewViewsTest {
ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON);
}
// Sends a mouse down and mouse up event.
void SendMouseClick(const gfx::Point& point) {
omnibox_view()->OnMousePressed(
CreateMouseEvent(ui::ET_MOUSE_PRESSED, point));
omnibox_view()->OnMouseReleased(
CreateMouseEvent(ui::ET_MOUSE_RELEASED, point));
}
// Used to access members that are marked private in views::TextField.
views::View* omnibox_textfield_view() { return omnibox_view(); }
base::SimpleTestTickClock* clock() { return &clock_; }
......@@ -571,30 +583,59 @@ TEST_F(OmniboxViewViewsSteadyStateElisionsTest, GestureTaps) {
ExpectFullUrlDisplayed();
}
TEST_F(OmniboxViewViewsSteadyStateElisionsTest, CaretPlacementByMouse) {
TEST_F(OmniboxViewViewsSteadyStateElisionsTest, FirstMouseClickFocusesOnly) {
EXPECT_FALSE(omnibox_view()->IsSelectAll());
// First click should select all, but not unelide.
omnibox_view()->OnMousePressed(
CreateMouseEvent(ui::ET_MOUSE_PRESSED, gfx::Point()));
omnibox_view()->OnMouseReleased(
CreateMouseEvent(ui::ET_MOUSE_RELEASED, gfx::Point()));
SendMouseClick(gfx::Point());
ExpectElidedUrlDisplayed();
EXPECT_TRUE(omnibox_view()->IsSelectAll());
EXPECT_TRUE(omnibox_view()->HasFocus());
}
TEST_F(OmniboxViewViewsSteadyStateElisionsTest, CaretPlacementByMouse) {
SendMouseClick(kPointInText);
// Advance the clock 5 seconds so the second click is not interpreted as a
// double click.
clock()->Advance(base::TimeDelta::FromSeconds(10));
// Second click should unelide only on mouse release.
EXPECT_EQ(OMNIBOX_FOCUS_VISIBLE, omnibox_view()->model()->focus_state());
gfx::Point point_in_text = gfx::Point(20, 20);
omnibox_view()->OnMousePressed(
CreateMouseEvent(ui::ET_MOUSE_PRESSED, point_in_text));
CreateMouseEvent(ui::ET_MOUSE_PRESSED, kPointInText));
ExpectElidedUrlDisplayed();
omnibox_view()->OnMouseReleased(
CreateMouseEvent(ui::ET_MOUSE_RELEASED, point_in_text));
CreateMouseEvent(ui::ET_MOUSE_RELEASED, kPointInText));
ExpectFullUrlDisplayed();
}
TEST_F(OmniboxViewViewsSteadyStateElisionsTest, MouseDoubleClick) {
SendMouseClick(kPointInText);
// Second click without advancing the clock should be a double-click, which
// should do a single word selection and unelide the text on mousedown.
omnibox_view()->OnMousePressed(
CreateMouseEvent(ui::ET_MOUSE_PRESSED, kPointInText));
ExpectFullUrlDisplayed();
// Verify that the proper portion of the full URL is selected.
size_t start, end;
omnibox_view()->GetSelectionBounds(&start, &end);
EXPECT_EQ(8U, start);
EXPECT_EQ(15U, end);
}
TEST_F(OmniboxViewViewsSteadyStateElisionsTest, MouseTripleClick) {
SendMouseClick(kPointInText);
SendMouseClick(kPointInText);
SendMouseClick(kPointInText);
ExpectFullUrlDisplayed();
// Verify that the whole full URL is selected.
EXPECT_TRUE(omnibox_view()->IsSelectAll());
size_t start, end;
omnibox_view()->GetSelectionBounds(&start, &end);
EXPECT_EQ(0U, start);
EXPECT_EQ(19U, 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