| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "content/browser/renderer_host/input/touch_selection_controller.h" | 5 #include "content/browser/renderer_host/input/touch_selection_controller.h" |
| 6 | 6 |
| 7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
| 8 #include "ui/events/test/mock_motion_event.h" | 8 #include "ui/events/test/mock_motion_event.h" |
| 9 | 9 |
| 10 using ui::test::MockMotionEvent; | 10 using ui::test::MockMotionEvent; |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 controller().HideAndDisallowShowingAutomatically(); | 249 controller().HideAndDisallowShowingAutomatically(); |
| 250 EXPECT_EQ(INSERTION_CLEARED, GetLastEventType()); | 250 EXPECT_EQ(INSERTION_CLEARED, GetLastEventType()); |
| 251 | 251 |
| 252 // Long-pressing should show the handle even if the editable region is empty. | 252 // Long-pressing should show the handle even if the editable region is empty. |
| 253 insertion_rect.Offset(2, -2); | 253 insertion_rect.Offset(2, -2); |
| 254 controller().OnLongPressEvent(); | 254 controller().OnLongPressEvent(); |
| 255 controller().OnSelectionEmpty(true); | 255 controller().OnSelectionEmpty(true); |
| 256 ChangeInsertion(insertion_rect, visible); | 256 ChangeInsertion(insertion_rect, visible); |
| 257 EXPECT_EQ(INSERTION_SHOWN, GetLastEventType()); | 257 EXPECT_EQ(INSERTION_SHOWN, GetLastEventType()); |
| 258 EXPECT_EQ(insertion_rect.bottom_left(), GetLastEventAnchor()); | 258 EXPECT_EQ(insertion_rect.bottom_left(), GetLastEventAnchor()); |
| 259 |
| 260 // Single Tap on an empty edit field should clear insertion handle. |
| 261 controller().OnTapEvent(); |
| 262 EXPECT_EQ(INSERTION_CLEARED, GetLastEventType()); |
| 259 } | 263 } |
| 260 | 264 |
| 261 TEST_F(TouchSelectionControllerTest, InsertionAppearsAfterTapFollowingTyping) { | 265 TEST_F(TouchSelectionControllerTest, InsertionAppearsAfterTapFollowingTyping) { |
| 262 gfx::RectF insertion_rect(5, 5, 0, 10); | 266 gfx::RectF insertion_rect(5, 5, 0, 10); |
| 263 bool visible = true; | 267 bool visible = true; |
| 264 | 268 |
| 265 // Simulate the user tapping an empty text field. | 269 // Simulate the user tapping an empty text field. |
| 266 controller().OnTapEvent(); | 270 controller().OnTapEvent(); |
| 267 controller().OnSelectionEditable(true); | 271 controller().OnSelectionEditable(true); |
| 268 controller().OnSelectionEmpty(true); | 272 controller().OnSelectionEmpty(true); |
| (...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 642 | 646 |
| 643 visible = true; | 647 visible = true; |
| 644 ChangeInsertion(insertion_rect, visible); | 648 ChangeInsertion(insertion_rect, visible); |
| 645 EXPECT_FALSE(GetAndResetNeedsAnimate()); | 649 EXPECT_FALSE(GetAndResetNeedsAnimate()); |
| 646 | 650 |
| 647 controller().SetTemporarilyHidden(false); | 651 controller().SetTemporarilyHidden(false); |
| 648 EXPECT_TRUE(GetAndResetNeedsAnimate()); | 652 EXPECT_TRUE(GetAndResetNeedsAnimate()); |
| 649 } | 653 } |
| 650 | 654 |
| 651 } // namespace content | 655 } // namespace content |
| OLD | NEW |