MCPcopy Create free account
hub / github.com/Snapchat/Valdi / TEST

Function TEST

snap_drawing/test/src/DragGestureRecognizer_tests.cpp:9–35  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7namespace snap::drawing {
8
9TEST(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
37TEST(DragGestureRecognizer, canHandleDragWithSingleTap) {
38 auto container = makeContainer(0, 0, 100, 100);

Callers

nothing calls this directly

Calls 8

makeContainerFunction · 0.85
createViewFunction · 0.85
addDragGestureFunction · 0.85
addSingleTapGestureFunction · 0.85
addLongPressGestureFunction · 0.85
addChildMethod · 0.45
dispatchEventMethod · 0.45
isEmptyMethod · 0.45

Tested by

no test coverage detected