| Index: ui/touch_selection/touch_selection_controller_unittest.cc
|
| diff --git a/ui/touch_selection/touch_selection_controller_unittest.cc b/ui/touch_selection/touch_selection_controller_unittest.cc
|
| index bdbde62cedb918fe3c94406b62391acb6a297bb3..7cf14c7466089c8229fb2fc6677799c3aa30cd95 100644
|
| --- a/ui/touch_selection/touch_selection_controller_unittest.cc
|
| +++ b/ui/touch_selection/touch_selection_controller_unittest.cc
|
| @@ -51,10 +51,7 @@ class TouchSelectionControllerTest : public testing::Test,
|
|
|
| // testing::Test implementation.
|
| void SetUp() override {
|
| - controller_.reset(new TouchSelectionController(
|
| - this,
|
| - base::TimeDelta::FromMilliseconds(kDefaultTapTimeoutMs),
|
| - kDefaulTapSlop));
|
| + Reset(false);
|
| }
|
|
|
| void TearDown() override { controller_.reset(); }
|
| @@ -95,11 +92,30 @@ class TouchSelectionControllerTest : public testing::Test,
|
| new MockTouchHandleDrawable(&dragging_enabled_));
|
| }
|
|
|
| + void Reset(bool show_on_tap_for_empty_editable) {
|
| + controller_.reset(new TouchSelectionController(
|
| + this,
|
| + base::TimeDelta::FromMilliseconds(kDefaultTapTimeoutMs),
|
| + kDefaulTapSlop,
|
| + show_on_tap_for_empty_editable));
|
| + last_event_start_ = gfx::PointF();
|
| + caret_position_ = gfx::PointF();
|
| + selection_start_ = gfx::PointF();
|
| + selection_end_ = gfx::PointF();
|
| + last_event_ = SELECTION_CLEARED;
|
| + caret_moved_ = false;
|
| + selection_moved_ = false;
|
| + selection_points_swapped_ = false;
|
| + needs_animate_ = false;
|
| + animation_enabled_ = true;
|
| + dragging_enabled_ = false;
|
| +}
|
| +
|
| void SetAnimationEnabled(bool enabled) { animation_enabled_ = enabled; }
|
| void SetDraggingEnabled(bool enabled) { dragging_enabled_ = enabled; }
|
|
|
| void ClearSelection() {
|
| - controller_->OnSelectionBoundsChanged(SelectionBound(),
|
| + controller_->OnSelectionBoundsUpdated(SelectionBound(),
|
| SelectionBound());
|
| }
|
|
|
| @@ -110,7 +126,7 @@ class TouchSelectionControllerTest : public testing::Test,
|
| bound.set_type(SelectionBound::CENTER);
|
| bound.SetEdge(rect.origin(), rect.bottom_left());
|
| bound.set_visible(visible);
|
| - controller_->OnSelectionBoundsChanged(bound, bound);
|
| + controller_->OnSelectionBoundsUpdated(bound, bound);
|
| }
|
|
|
| void ChangeSelection(const gfx::RectF& start_rect,
|
| @@ -124,7 +140,7 @@ class TouchSelectionControllerTest : public testing::Test,
|
| end_bound.SetEdge(end_rect.origin(), end_rect.bottom_left());
|
| start_bound.set_visible(start_visible);
|
| end_bound.set_visible(end_visible);
|
| - controller_->OnSelectionBoundsChanged(start_bound, end_bound);
|
| + controller_->OnSelectionBoundsUpdated(start_bound, end_bound);
|
| }
|
|
|
| void Animate() {
|
| @@ -163,7 +179,7 @@ class TouchSelectionControllerTest : public testing::Test,
|
| const gfx::PointF& GetLastSelectionStart() const { return selection_start_; }
|
| const gfx::PointF& GetLastSelectionEnd() const { return selection_end_; }
|
| SelectionEventType GetLastEventType() const { return last_event_; }
|
| - const gfx::PointF& GetLastEventAnchor() const { return last_event_start_; }
|
| + const gfx::PointF& GetLastEventAnchor() { return last_event_start_; }
|
|
|
| TouchSelectionController& controller() { return *controller_; }
|
|
|
| @@ -229,18 +245,30 @@ TEST_F(TouchSelectionControllerTest, InsertionClearedWhenNoLongerEditable) {
|
| EXPECT_EQ(INSERTION_CLEARED, GetLastEventType());
|
| }
|
|
|
| -TEST_F(TouchSelectionControllerTest, InsertionStaysHiddenIfEmptyRegionTapped) {
|
| +TEST_F(TouchSelectionControllerTest, EmptyRegionTapped) {
|
| gfx::RectF insertion_rect(5, 5, 0, 10);
|
| bool visible = true;
|
| +
|
| + // Taps on an empty editable region should show the insertion handle if the
|
| + // controller is created with show_on_tap_for_empty_editable set to true.
|
| + Reset(true);
|
| controller().OnSelectionEditable(true);
|
| + controller().OnTapEvent();
|
| + controller().OnSelectionEmpty(true);
|
| + ChangeInsertion(insertion_rect, visible);
|
| + EXPECT_EQ(INSERTION_SHOWN, GetLastEventType());
|
| + EXPECT_EQ(insertion_rect.bottom_left(), GetLastEventAnchor());
|
|
|
| - // Taps should be ignored if they're in an empty editable region.
|
| + // Taps on an empty editable region should be ignored if the controller is
|
| + // created with show_on_tap_for_empty_editable set to false.
|
| + Reset(false);
|
| + controller().OnSelectionEditable(true);
|
| controller().OnTapEvent();
|
| controller().OnSelectionEmpty(true);
|
| ChangeInsertion(insertion_rect, visible);
|
| EXPECT_EQ(gfx::PointF(), GetLastEventAnchor());
|
|
|
| - // Once the region becomes editable, taps should show the insertion handle.
|
| + // Once the region becomes non-empty, taps should show the insertion handle.
|
| controller().OnTapEvent();
|
| controller().OnSelectionEmpty(false);
|
| ChangeInsertion(insertion_rect, visible);
|
|
|