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