⎇ 9e53f03adea2b770d68954e404d2fa407dfc7d40
tests/generated/gap_row_gap_row_wrap_child_margins.rs
History
Who touched what
raw
Implement "gap" property for flexbox algorithm (#248)
1#[test]
2fn gap_row_gap_row_wrap_child_margins() {
3 let mut taffy = taffy::Taffy::new();
4 let node0 = taffy
5 .new_with_children(
6 taffy::style::FlexboxLayout {
7 size: taffy::geometry::Size { width: taffy::style::Dimension::Points(60f32), ..Default::default() },
8 margin: taffy::geometry::Rect {
9 top: taffy::style::Dimension::Points(2f32),
10 bottom: taffy::style::Dimension::Points(2f32),
11 ..Default::default()
12 },
13 ..Default::default()
14 },
15 &[],
16 )
17 .unwrap();
18 let node1 = taffy
19 .new_with_children(
20 taffy::style::FlexboxLayout {
21 size: taffy::geometry::Size { width: taffy::style::Dimension::Points(60f32), ..Default::default() },
22 margin: taffy::geometry::Rect {
23 top: taffy::style::Dimension::Points(10f32),
24 bottom: taffy::style::Dimension::Points(10f32),
25 ..Default::default()
26 },
27 ..Default::default()
28 },
29 &[],
30 )
31 .unwrap();
32 let node2 = taffy
33 .new_with_children(
34 taffy::style::FlexboxLayout {
35 size: taffy::geometry::Size { width: taffy::style::Dimension::Points(60f32), ..Default::default() },
36 margin: taffy::geometry::Rect {
37 top: taffy::style::Dimension::Points(15f32),
38 bottom: taffy::style::Dimension::Points(15f32),
39 ..Default::default()
40 },
41 ..Default::default()
42 },
43 &[],
44 )
45 .unwrap();
46 let node = taffy
47 .new_with_children(
48 taffy::style::FlexboxLayout {
49 flex_wrap: taffy::style::FlexWrap::Wrap,
50 gap: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Default::default() },
51 size: taffy::geometry::Size {
52 width: taffy::style::Dimension::Points(100f32),
53 height: taffy::style::Dimension::Points(200f32),
54 ..Default::default()
55 },
56 ..Default::default()
57 },
58 &[node0, node1, node2],
59 )
60 .unwrap();
61 taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
62 assert_eq!(taffy.layout(node).unwrap().size.width, 100f32);
63 assert_eq!(taffy.layout(node).unwrap().size.height, 200f32);
64 assert_eq!(taffy.layout(node).unwrap().location.x, 0f32);
65 assert_eq!(taffy.layout(node).unwrap().location.y, 0f32);
66 assert_eq!(taffy.layout(node0).unwrap().size.width, 60f32);
67 assert_eq!(taffy.layout(node0).unwrap().size.height, 42f32);
68 assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32);
69 assert_eq!(taffy.layout(node0).unwrap().location.y, 2f32);
70 assert_eq!(taffy.layout(node1).unwrap().size.width, 60f32);
71 assert_eq!(taffy.layout(node1).unwrap().size.height, 42f32);
72 assert_eq!(taffy.layout(node1).unwrap().location.x, 0f32);
73 assert_eq!(taffy.layout(node1).unwrap().location.y, 66f32);
74 assert_eq!(taffy.layout(node2).unwrap().size.width, 60f32);
75 assert_eq!(taffy.layout(node2).unwrap().size.height, 42f32);
76 assert_eq!(taffy.layout(node2).unwrap().location.x, 0f32);
77 assert_eq!(taffy.layout(node2).unwrap().location.y, 143f32);
78}