Chromium Code Reviews| 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 "base/basictypes.h" | 5 #include "base/basictypes.h" |
| 6 #include "base/logging.h" | 6 #include "base/logging.h" |
| 7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "base/time/time.h" | 9 #include "base/time/time.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| (...skipping 805 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 816 | 816 |
| 817 ASSERT_LT(0U, GetReceivedGestureCount()); | 817 ASSERT_LT(0U, GetReceivedGestureCount()); |
| 818 GestureEventData gesture = GetMostRecentGestureEvent(); | 818 GestureEventData gesture = GetMostRecentGestureEvent(); |
| 819 EXPECT_EQ(ET_GESTURE_SCROLL_UPDATE, gesture.type()); | 819 EXPECT_EQ(ET_GESTURE_SCROLL_UPDATE, gesture.type()); |
| 820 EXPECT_EQ(event_time + kOneMicrosecond * i, gesture.time); | 820 EXPECT_EQ(event_time + kOneMicrosecond * i, gesture.time); |
| 821 EXPECT_EQ(1, gesture.details.touch_points()); | 821 EXPECT_EQ(1, gesture.details.touch_points()); |
| 822 | 822 |
| 823 // Verify that the event co-ordinates are still the precise values we | 823 // Verify that the event co-ordinates are still the precise values we |
| 824 // supplied. | 824 // supplied. |
| 825 EXPECT_EQ(kFakeCoordX + delta_x * i, gesture.x); | 825 EXPECT_EQ(kFakeCoordX + delta_x * i, gesture.x); |
| 826 EXPECT_EQ(kFakeCoordY + delta_y * i, gesture.y); | 826 EXPECT_FLOAT_EQ(kFakeCoordY + delta_y * i, gesture.y); |
| 827 | 827 |
| 828 // Verify that we're scrolling vertically by the expected amount | 828 // Verify that we're scrolling vertically by the expected amount |
| 829 // (modulo rounding). | 829 // (modulo rounding). |
| 830 EXPECT_GE(gesture.details.scroll_y(), (int)delta_y); | 830 EXPECT_GE(gesture.details.scroll_y(), (int)delta_y); |
| 831 EXPECT_LE(gesture.details.scroll_y(), ((int)delta_y) + 1); | 831 EXPECT_LE(gesture.details.scroll_y(), ((int)delta_y) + 1); |
| 832 | 832 |
| 833 // And that there has been no horizontal motion at all. | 833 // And that there has been no horizontal motion at all. |
| 834 EXPECT_EQ(0, gesture.details.scroll_x()); | 834 EXPECT_EQ(0, gesture.details.scroll_x()); |
| 835 } | 835 } |
| 836 } | 836 } |
| (...skipping 1496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2333 event = | 2333 event = |
| 2334 ObtainMotionEvent(event_time + kOneMicrosecond, MotionEvent::ACTION_UP); | 2334 ObtainMotionEvent(event_time + kOneMicrosecond, MotionEvent::ACTION_UP); |
| 2335 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); | 2335 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); |
| 2336 EXPECT_EQ(ET_GESTURE_TAP, GetMostRecentGestureEventType()); | 2336 EXPECT_EQ(ET_GESTURE_TAP, GetMostRecentGestureEventType()); |
| 2337 EXPECT_EQ(kMaxGestureBoundsLength, | 2337 EXPECT_EQ(kMaxGestureBoundsLength, |
| 2338 GetMostRecentGestureEvent().details.bounding_box_f().width()); | 2338 GetMostRecentGestureEvent().details.bounding_box_f().width()); |
| 2339 EXPECT_EQ(kMaxGestureBoundsLength, | 2339 EXPECT_EQ(kMaxGestureBoundsLength, |
| 2340 GetMostRecentGestureEvent().details.bounding_box_f().height()); | 2340 GetMostRecentGestureEvent().details.bounding_box_f().height()); |
| 2341 } | 2341 } |
| 2342 | 2342 |
| 2343 TEST_F(GestureProviderTest, ZeroRadiusBoundingBox) { | |
| 2344 base::TimeTicks event_time = base::TimeTicks::Now(); | |
| 2345 int motion_event_id = 0; | |
| 2346 | |
| 2347 MockMotionEvent event = | |
| 2348 ObtainMotionEvent(event_time, MotionEvent::ACTION_DOWN, 10, 20); | |
| 2349 event.SetTouchMajor(0); | |
| 2350 event.set_id(++motion_event_id); | |
|
jdduke (slow)
2014/08/12 20:33:48
I'd ditch the |motion_event_id| and |set_id|'s in
tdresser
2014/08/12 21:09:39
Done.
| |
| 2351 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); | |
| 2352 EXPECT_EQ(gfx::RectF(10, 20, 0, 0), | |
| 2353 GetMostRecentGestureEvent().details.bounding_box()); | |
| 2354 | |
| 2355 event = ObtainMotionEvent( | |
| 2356 event_time, MotionEvent::ACTION_POINTER_DOWN, 10, 20, 110, 120); | |
| 2357 event.SetTouchMajor(0); | |
| 2358 event.set_id(++motion_event_id); | |
| 2359 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); | |
| 2360 | |
| 2361 event = ObtainMotionEvent( | |
| 2362 event_time, MotionEvent::ACTION_MOVE, 10, 20, 110, 150); | |
| 2363 event.SetTouchMajor(0); | |
| 2364 event.set_id(++motion_event_id); | |
| 2365 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); | |
| 2366 | |
| 2367 EXPECT_EQ(gfx::RectF(10, 20, 100, 130), | |
| 2368 GetMostRecentGestureEvent().details.bounding_box()); | |
| 2369 } | |
| 2370 | |
| 2343 } // namespace ui | 2371 } // namespace ui |
| OLD | NEW |