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

Function TEST_F

snap_drawing/test/src/FlexboxLayer_tests.cpp:26–74  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

24};
25
26TEST_F(FlexboxLayerTests, canLayoutNonFlexLayers) {
27 auto child1 = makeLayer<Layer>(_resources);
28 auto child2 = makeLayer<Layer>(_resources);
29 auto child3 = makeLayer<Layer>(_resources);
30
31 _layer->addChild(child1);
32 _layer->addChild(child2);
33 _layer->addChild(child3);
34
35 _layer->updateLayoutAttributes()
36 .setFlexDirection(YGFlexDirectionRow)
37 .setJustifyContent(YGJustifyCenter)
38 .setAlignItems(YGAlignCenter);
39
40 _layer->updateLayoutAttributesForLayer(child1)
41 .setWidth(FlexValue::point(16))
42 .setHeight(FlexValue::point(16))
43 .setMargin(YGEdgeRight, FlexValue::point(8));
44
45 _layer->updateLayoutAttributesForLayer(child2).setWidth(FlexValue::point(10)).setHeight(FlexValue::point(10));
46
47 _layer->updateLayoutAttributesForLayer(child3)
48 .setWidth(FlexValue::point(8))
49 .setHeight(FlexValue::point(8))
50 .setMargin(YGEdgeLeft, FlexValue::point(8));
51
52 _layer->setFrame(Rect::makeXYWH(0, 0, 50, 16));
53 _layer->layoutIfNeeded();
54
55 ASSERT_EQ(Rect::makeXYWH(0, 0, 16, 16), child1->getFrame());
56 ASSERT_EQ(Rect::makeXYWH(24, 3, 10, 10), child2->getFrame());
57 ASSERT_EQ(Rect::makeXYWH(42, 4, 8, 8), child3->getFrame());
58
59 _layer->updateLayoutAttributesForLayer(child1).setMargin(YGEdgeRight, FlexValue::point(4));
60
61 _layer->updateLayoutAttributesForLayer(child3)
62 .setMargin(YGEdgeLeft, FlexValue::point(6))
63 .setMargin(YGEdgeRight, FlexValue::point(6));
64
65 ASSERT_EQ(Rect::makeXYWH(0, 0, 16, 16), child1->getFrame());
66 ASSERT_EQ(Rect::makeXYWH(24, 3, 10, 10), child2->getFrame());
67 ASSERT_EQ(Rect::makeXYWH(42, 4, 8, 8), child3->getFrame());
68
69 _layer->layoutIfNeeded();
70
71 ASSERT_EQ(Rect::makeXYWH(0, 0, 16, 16), child1->getFrame());
72 ASSERT_EQ(Rect::makeXYWH(20, 3, 10, 10), child2->getFrame());
73 ASSERT_EQ(Rect::makeXYWH(36, 4, 8, 8), child3->getFrame());
74}
75
76TEST_F(FlexboxLayerTests, canLayoutFlexLayers) {
77 auto child1 = makeLayer<Layer>(_resources);

Callers

nothing calls this directly

Calls 15

maxFunction · 0.85
setAlignItemsMethod · 0.80
setJustifyContentMethod · 0.80
setFlexDirectionMethod · 0.80
setHeightMethod · 0.80
getFrameMethod · 0.80
setNeedsLayoutMethod · 0.80
addChildMethod · 0.45
setMarginMethod · 0.45

Tested by

no test coverage detected