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

Function TEST

snap_drawing/test/src/TouchDispatcher_tests.cpp:9–44  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7namespace snap::drawing {
8
9TEST(Layer, canResolveCoordinates) {
10 auto rootView = createView(25, 25, 100, 100);
11 auto middleView = createView(5, 5, 50, 50);
12 auto leafView = createView(7, 9, 10, 10);
13
14 rootView->addChild(middleView);
15 middleView->addChild(leafView);
16
17 ASSERT_EQ(Rect::makeXYWH(25, 25, 100, 100), rootView->getVisualFrame());
18 ASSERT_EQ(Rect::makeXYWH(5, 5, 50, 50), middleView->getVisualFrame());
19 ASSERT_EQ(Rect::makeXYWH(7, 9, 10, 10), leafView->getVisualFrame());
20
21 ASSERT_EQ(Rect::makeXYWH(25, 25, 100, 100), rootView->getAbsoluteVisualFrame());
22 ASSERT_EQ(Rect::makeXYWH(30, 30, 50, 50), middleView->getAbsoluteVisualFrame());
23 ASSERT_EQ(Rect::makeXYWH(37, 39, 10, 10), leafView->getAbsoluteVisualFrame());
24
25 // 7, 9
26 // 12, 14
27 //
28
29 auto result = rootView->convertPointToLayer(Point::make(2, 15), rootView);
30 ASSERT_TRUE(result.has_value());
31 ASSERT_EQ(Point::make(2, 15), result.value());
32
33 result = rootView->convertPointToLayer(Point::make(2, 15), middleView);
34 ASSERT_TRUE(result.has_value());
35 ASSERT_EQ(Point::make(-3, 10), result.value());
36
37 result = rootView->convertPointToLayer(Point::make(2, 15), leafView);
38 ASSERT_TRUE(result.has_value());
39 ASSERT_EQ(Point::make(-10, 1), result.value());
40
41 result = middleView->convertPointToLayer(Point::make(-3, 10), leafView);
42 ASSERT_TRUE(result.has_value());
43 ASSERT_EQ(Point::make(-10, 1), result.value());
44}
45
46TEST(Layer, canResolveCoordinatesWithTranslate) {
47 auto rootView = createView(25, 25, 100, 100);

Callers

nothing calls this directly

Calls 15

createViewFunction · 0.85
makeContainerFunction · 0.85
addCustomTouchGestureFunction · 0.85
addCustomTapGestureFunction · 0.85
makeRootFunction · 0.85
createTouchEventFunction · 0.85
addDragGestureFunction · 0.85
convertPointToLayerMethod · 0.80
setContentLayerMethod · 0.80
setTouchEnabledMethod · 0.80
refreshTouchesMethod · 0.80

Tested by

no test coverage detected