⎇ 568f643327ec6b4879df0087def7f4e66b6acafb
tests/generated/gap_column_row_gap_wrapping.rs
Ñawpa willay
Pi imata llamkarqan
ch'uya
Rename `Points`/`points` to `Length`/`length` in many APIs (#459)
1#[test]
2fn gap_column_row_gap_wrapping() {
3 #[allow(unused_imports)]
4 use taffy::{prelude::*, tree::Layout};
5 let mut taffy = taffy::Taffy::new();
6 let node0 = taffy
7 .new_leaf(taffy::style::Style {
8 size: taffy::geometry::Size {
9 width: taffy::style::Dimension::Length(20f32),
10 height: taffy::style::Dimension::Length(20f32),
11 },
12 ..Default::default()
13 })
14 .unwrap();
15 let node1 = taffy
16 .new_leaf(taffy::style::Style {
17 size: taffy::geometry::Size {
18 width: taffy::style::Dimension::Length(20f32),
19 height: taffy::style::Dimension::Length(20f32),
20 },
21 ..Default::default()
22 })
23 .unwrap();
24 let node2 = taffy
25 .new_leaf(taffy::style::Style {
26 size: taffy::geometry::Size {
27 width: taffy::style::Dimension::Length(20f32),
28 height: taffy::style::Dimension::Length(20f32),
29 },
30 ..Default::default()
31 })
32 .unwrap();
33 let node3 = taffy
34 .new_leaf(taffy::style::Style {
35 size: taffy::geometry::Size {
36 width: taffy::style::Dimension::Length(20f32),
37 height: taffy::style::Dimension::Length(20f32),
38 },
39 ..Default::default()
40 })
41 .unwrap();
42 let node4 = taffy
43 .new_leaf(taffy::style::Style {
44 size: taffy::geometry::Size {
45 width: taffy::style::Dimension::Length(20f32),
46 height: taffy::style::Dimension::Length(20f32),
47 },
48 ..Default::default()
49 })
50 .unwrap();
51 let node5 = taffy
52 .new_leaf(taffy::style::Style {
53 size: taffy::geometry::Size {
54 width: taffy::style::Dimension::Length(20f32),
55 height: taffy::style::Dimension::Length(20f32),
56 },
57 ..Default::default()
58 })
59 .unwrap();
60 let node6 = taffy
61 .new_leaf(taffy::style::Style {
62 size: taffy::geometry::Size {
63 width: taffy::style::Dimension::Length(20f32),
64 height: taffy::style::Dimension::Length(20f32),
65 },
66 ..Default::default()
67 })
68 .unwrap();
69 let node7 = taffy
70 .new_leaf(taffy::style::Style {
71 size: taffy::geometry::Size {
72 width: taffy::style::Dimension::Length(20f32),
73 height: taffy::style::Dimension::Length(20f32),
74 },
75 ..Default::default()
76 })
77 .unwrap();
78 let node8 = taffy
79 .new_leaf(taffy::style::Style {
80 size: taffy::geometry::Size {
81 width: taffy::style::Dimension::Length(20f32),
82 height: taffy::style::Dimension::Length(20f32),
83 },
84 ..Default::default()
85 })
86 .unwrap();
87 let node = taffy
88 .new_with_children(
89 taffy::style::Style {
90 flex_wrap: taffy::style::FlexWrap::Wrap,
91 gap: taffy::geometry::Size {
92 width: taffy::style::LengthPercentage::Length(10f32),
93 height: taffy::style::LengthPercentage::Length(20f32),
94 },
95 size: taffy::geometry::Size { width: taffy::style::Dimension::Length(80f32), height: auto() },
96 ..Default::default()
97 },
98 &[node0, node1, node2, node3, node4, node5, node6, node7, node8],
99 )
100 .unwrap();
101 taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
102 println!("\nComputed tree:");
103 taffy::util::print_tree(&taffy, node);
104 println!();
105 let Layout { size, location, .. } = taffy.layout(node).unwrap();
106 assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node, 80f32, size.width);
107 assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height);
108 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
109 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
110 let Layout { size, location, .. } = taffy.layout(node0).unwrap();
111 assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width);
112 assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height);
113 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
114 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y);
115 let Layout { size, location, .. } = taffy.layout(node1).unwrap();
116 assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width);
117 assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height);
118 assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node1, 30f32, location.x);
119 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y);
120 let Layout { size, location, .. } = taffy.layout(node2).unwrap();
121 assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node2, 20f32, size.width);
122 assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node2, 20f32, size.height);
123 assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node2, 60f32, location.x);
124 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y);
125 let Layout { size, location, .. } = taffy.layout(node3).unwrap();
126 assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node3, 20f32, size.width);
127 assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node3, 20f32, size.height);
128 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x);
129 assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3, 40f32, location.y);
130 let Layout { size, location, .. } = taffy.layout(node4).unwrap();
131 assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node4, 20f32, size.width);
132 assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node4, 20f32, size.height);
133 assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node4, 30f32, location.x);
134 assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4, 40f32, location.y);
135 let Layout { size, location, .. } = taffy.layout(node5).unwrap();
136 assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node5, 20f32, size.width);
137 assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node5, 20f32, size.height);
138 assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node5, 60f32, location.x);
139 assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node5, 40f32, location.y);
140 let Layout { size, location, .. } = taffy.layout(node6).unwrap();
141 assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node6, 20f32, size.width);
142 assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node6, 20f32, size.height);
143 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node6, 0f32, location.x);
144 assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node6, 80f32, location.y);
145 let Layout { size, location, .. } = taffy.layout(node7).unwrap();
146 assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node7, 20f32, size.width);
147 assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node7, 20f32, size.height);
148 assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node7, 30f32, location.x);
149 assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node7, 80f32, location.y);
150 let Layout { size, location, .. } = taffy.layout(node8).unwrap();
151 assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node8, 20f32, size.width);
152 assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node8, 20f32, size.height);
153 assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node8, 60f32, location.x);
154 assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node8, 80f32, location.y);
155}