| 7 | namespace snap::drawing { |
| 8 | |
| 9 | TEST(DragGestureRecognizer, canHandleDrag) { |
| 10 | auto container = makeContainer(0, 0, 100, 100); |
| 11 | |
| 12 | auto childView = createView(25, 25, 25, 25); |
| 13 | container->view->addChild(childView); |
| 14 | |
| 15 | auto dragSnapshot = addDragGesture(childView); |
| 16 | |
| 17 | container->dispatchEvent(TouchEventTypeDown, 30, 35); |
| 18 | ASSERT_EQ(GestureRecognizerStatePossible, dragSnapshot->state); |
| 19 | |
| 20 | container->dispatchEvent(TouchEventTypeMoved, 30, 35); |
| 21 | ASSERT_EQ(GestureRecognizerStatePossible, dragSnapshot->state); |
| 22 | |
| 23 | container->dispatchEvent(TouchEventTypeMoved, 30 + GesturesConfiguration::getDefault().dragTouchSlop, 35); |
| 24 | ASSERT_EQ(GestureRecognizerStateBegan, dragSnapshot->state); |
| 25 | ASSERT_EQ(30 + GesturesConfiguration::getDefault().dragTouchSlop - 25, dragSnapshot->location.x); |
| 26 | ASSERT_EQ(35 - 25, dragSnapshot->location.y); |
| 27 | |
| 28 | container->dispatchEvent(TouchEventTypeMoved, 30 + GesturesConfiguration::getDefault().dragTouchSlop, 35); |
| 29 | ASSERT_EQ(GestureRecognizerStateChanged, dragSnapshot->state); |
| 30 | |
| 31 | container->dispatchEvent(TouchEventTypeUp, 30, 35); |
| 32 | ASSERT_EQ(GestureRecognizerStateEnded, dragSnapshot->state); |
| 33 | |
| 34 | ASSERT_TRUE(container->root->getTouchDispatcher().isEmpty()); |
| 35 | } |
| 36 | |
| 37 | TEST(DragGestureRecognizer, canHandleDragWithSingleTap) { |
| 38 | auto container = makeContainer(0, 0, 100, 100); |
nothing calls this directly
no test coverage detected