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 "ui/touch_selection/touch_handle.h" | 5 #include "ui/touch_selection/touch_handle.h" |
6 | 6 |
7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
8 #include "ui/events/test/motion_event_test_utils.h" | 8 #include "ui/events/test/motion_event_test_utils.h" |
9 #include "ui/gfx/geometry/rect_f.h" | 9 #include "ui/gfx/geometry/rect_f.h" |
10 #include "ui/touch_selection/touch_handle_orientation.h" | 10 #include "ui/touch_selection/touch_handle_orientation.h" |
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
451 EXPECT_TRUE(IsDragging()); | 451 EXPECT_TRUE(IsDragging()); |
452 | 452 |
453 // Ensure a touch size of 0 can still register a hit. | 453 // Ensure a touch size of 0 can still register a hit. |
454 event = MockMotionEvent(MockMotionEvent::ACTION_DOWN, | 454 event = MockMotionEvent(MockMotionEvent::ACTION_DOWN, |
455 event_time, | 455 event_time, |
456 kDefaultDrawableSize / 2.f, | 456 kDefaultDrawableSize / 2.f, |
457 kDefaultDrawableSize / 2.f); | 457 kDefaultDrawableSize / 2.f); |
458 event.SetTouchMajor(0); | 458 event.SetTouchMajor(0); |
459 EXPECT_TRUE(handle.WillHandleTouchEvent(event)); | 459 EXPECT_TRUE(handle.WillHandleTouchEvent(event)); |
460 EXPECT_TRUE(IsDragging()); | 460 EXPECT_TRUE(IsDragging()); |
| 461 |
| 462 // Touches centered above the handle region should never register a hit, even |
| 463 // if the touch region intersects the handle region. |
| 464 event = MockMotionEvent(MockMotionEvent::ACTION_DOWN, event_time, |
| 465 kDefaultDrawableSize / 2.f, -kTouchSize / 3.f); |
| 466 event.SetTouchMajor(kTouchSize); |
| 467 EXPECT_FALSE(handle.WillHandleTouchEvent(event)); |
| 468 EXPECT_FALSE(IsDragging()); |
461 } | 469 } |
462 | 470 |
463 TEST_F(TouchHandleTest, Tap) { | 471 TEST_F(TouchHandleTest, Tap) { |
464 TouchHandle handle(this, TouchHandleOrientation::CENTER); | 472 TouchHandle handle(this, TouchHandleOrientation::CENTER); |
465 handle.SetVisible(true, TouchHandle::ANIMATION_NONE); | 473 handle.SetVisible(true, TouchHandle::ANIMATION_NONE); |
466 | 474 |
467 base::TimeTicks event_time = base::TimeTicks::Now(); | 475 base::TimeTicks event_time = base::TimeTicks::Now(); |
468 | 476 |
469 // ACTION_CANCEL shouldn't trigger a tap. | 477 // ACTION_CANCEL shouldn't trigger a tap. |
470 MockMotionEvent event(MockMotionEvent::ACTION_DOWN, event_time, 0, 0); | 478 MockMotionEvent event(MockMotionEvent::ACTION_DOWN, event_time, 0, 0); |
(...skipping 30 matching lines...) Expand all Loading... |
501 event = MockMotionEvent( | 509 event = MockMotionEvent( |
502 MockMotionEvent::ACTION_MOVE, event_time, kDefaultTapSlop * 2.f, 0); | 510 MockMotionEvent::ACTION_MOVE, event_time, kDefaultTapSlop * 2.f, 0); |
503 EXPECT_TRUE(handle.WillHandleTouchEvent(event)); | 511 EXPECT_TRUE(handle.WillHandleTouchEvent(event)); |
504 event = MockMotionEvent( | 512 event = MockMotionEvent( |
505 MockMotionEvent::ACTION_UP, event_time, kDefaultTapSlop * 2.f, 0); | 513 MockMotionEvent::ACTION_UP, event_time, kDefaultTapSlop * 2.f, 0); |
506 EXPECT_TRUE(handle.WillHandleTouchEvent(event)); | 514 EXPECT_TRUE(handle.WillHandleTouchEvent(event)); |
507 EXPECT_FALSE(GetAndResetHandleTapped()); | 515 EXPECT_FALSE(GetAndResetHandleTapped()); |
508 } | 516 } |
509 | 517 |
510 } // namespace ui | 518 } // namespace ui |
OLD | NEW |