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 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
313 } | 313 } |
314 | 314 |
315 TEST_F(TouchSelectionControllerTest, InsertionDragged) { | 315 TEST_F(TouchSelectionControllerTest, InsertionDragged) { |
316 base::TimeTicks event_time = base::TimeTicks::Now(); | 316 base::TimeTicks event_time = base::TimeTicks::Now(); |
317 controller().OnTapEvent(); | 317 controller().OnTapEvent(); |
318 controller().OnSelectionEditable(true); | 318 controller().OnSelectionEditable(true); |
319 | 319 |
320 // The touch sequence should not be handled if insertion is not active. | 320 // The touch sequence should not be handled if insertion is not active. |
321 MockMotionEvent event(MockMotionEvent::ACTION_DOWN, event_time, 0, 0); | 321 MockMotionEvent event(MockMotionEvent::ACTION_DOWN, event_time, 0, 0); |
322 EXPECT_FALSE(controller().WillHandleTouchEvent(event)); | 322 EXPECT_FALSE(controller().WillHandleTouchEvent(event)); |
323 EXPECT_EQ(INSERTION_DRAG_STARTED, GetLastEventType()); | |
323 | 324 |
324 float line_height = 10.f; | 325 float line_height = 10.f; |
325 gfx::RectF start_rect(10, 0, 0, line_height); | 326 gfx::RectF start_rect(10, 0, 0, line_height); |
326 bool visible = true; | 327 bool visible = true; |
327 ChangeInsertion(start_rect, visible); | 328 ChangeInsertion(start_rect, visible); |
328 EXPECT_EQ(INSERTION_SHOWN, GetLastEventType()); | 329 EXPECT_EQ(INSERTION_SHOWN, GetLastEventType()); |
329 EXPECT_EQ(start_rect.bottom_left(), GetLastEventAnchor()); | 330 EXPECT_EQ(start_rect.bottom_left(), GetLastEventAnchor()); |
330 | 331 |
331 // The touch sequence should be handled only if the drawable reports a hit. | 332 // The touch sequence should be handled only if the drawable reports a hit. |
332 EXPECT_FALSE(controller().WillHandleTouchEvent(event)); | 333 EXPECT_FALSE(controller().WillHandleTouchEvent(event)); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
368 SetDraggingEnabled(true); | 369 SetDraggingEnabled(true); |
369 | 370 |
370 gfx::RectF start_rect(10, 0, 0, 10); | 371 gfx::RectF start_rect(10, 0, 0, 10); |
371 bool visible = true; | 372 bool visible = true; |
372 ChangeInsertion(start_rect, visible); | 373 ChangeInsertion(start_rect, visible); |
373 EXPECT_EQ(INSERTION_SHOWN, GetLastEventType()); | 374 EXPECT_EQ(INSERTION_SHOWN, GetLastEventType()); |
374 | 375 |
375 MockMotionEvent event(MockMotionEvent::ACTION_DOWN, event_time, 0, 0); | 376 MockMotionEvent event(MockMotionEvent::ACTION_DOWN, event_time, 0, 0); |
376 EXPECT_TRUE(controller().WillHandleTouchEvent(event)); | 377 EXPECT_TRUE(controller().WillHandleTouchEvent(event)); |
377 EXPECT_EQ(INSERTION_SHOWN, GetLastEventType()); | 378 EXPECT_EQ(INSERTION_SHOWN, GetLastEventType()); |
379 //TODO(AKV) this test case has to be modified once crbug.com/394093 is fixed | |
380 EXPECT_EQ(INSERTION_DRAG_STARTED, GetLastEventType()); | |
jdduke (slow)
2014/08/01 15:10:51
Thanks for adding this. One nit, add a colon ":"
AKVT
2014/08/01 15:23:25
Done.
| |
378 | 381 |
379 event = MockMotionEvent(MockMotionEvent::ACTION_UP, event_time, 0, 0); | 382 event = MockMotionEvent(MockMotionEvent::ACTION_UP, event_time, 0, 0); |
380 EXPECT_TRUE(controller().WillHandleTouchEvent(event)); | 383 EXPECT_TRUE(controller().WillHandleTouchEvent(event)); |
381 EXPECT_EQ(INSERTION_TAPPED, GetLastEventType()); | 384 EXPECT_EQ(INSERTION_TAPPED, GetLastEventType()); |
382 | 385 |
383 // Reset the insertion. | 386 // Reset the insertion. |
384 ClearInsertion(); | 387 ClearInsertion(); |
385 controller().OnTapEvent(); | 388 controller().OnTapEvent(); |
386 ChangeInsertion(start_rect, visible); | 389 ChangeInsertion(start_rect, visible); |
387 ASSERT_EQ(INSERTION_SHOWN, GetLastEventType()); | 390 ASSERT_EQ(INSERTION_SHOWN, GetLastEventType()); |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
575 | 578 |
576 visible = true; | 579 visible = true; |
577 ChangeInsertion(insertion_rect, visible); | 580 ChangeInsertion(insertion_rect, visible); |
578 EXPECT_FALSE(GetAndResetNeedsAnimate()); | 581 EXPECT_FALSE(GetAndResetNeedsAnimate()); |
579 | 582 |
580 controller().SetTemporarilyHidden(false); | 583 controller().SetTemporarilyHidden(false); |
581 EXPECT_TRUE(GetAndResetNeedsAnimate()); | 584 EXPECT_TRUE(GetAndResetNeedsAnimate()); |
582 } | 585 } |
583 | 586 |
584 } // namespace content | 587 } // namespace content |
OLD | NEW |