⎇ 9e53f03adea2b770d68954e404d2fa407dfc7d40
tests/generated/gap_column_row_gap_wrapping.rs
History
Who touched what
raw
Implement "gap" property for flexbox algorithm (#248)
1#[test]
2fn gap_column_row_gap_wrapping() {
3 let mut taffy = taffy::Taffy::new();
4 let node0 = taffy
5 .new_with_children(
6 taffy::style::FlexboxLayout {
7 size: taffy::geometry::Size {
8 width: taffy::style::Dimension::Points(20f32),
9 height: taffy::style::Dimension::Points(20f32),
10 ..Default::default()
11 },
12 ..Default::default()
13 },
14 &[],
15 )
16 .unwrap();
17 let node1 = taffy
18 .new_with_children(
19 taffy::style::FlexboxLayout {
20 size: taffy::geometry::Size {
21 width: taffy::style::Dimension::Points(20f32),
22 height: taffy::style::Dimension::Points(20f32),
23 ..Default::default()
24 },
25 ..Default::default()
26 },
27 &[],
28 )
29 .unwrap();
30 let node2 = taffy
31 .new_with_children(
32 taffy::style::FlexboxLayout {
33 size: taffy::geometry::Size {
34 width: taffy::style::Dimension::Points(20f32),
35 height: taffy::style::Dimension::Points(20f32),
36 ..Default::default()
37 },
38 ..Default::default()
39 },
40 &[],
41 )
42 .unwrap();
43 let node3 = taffy
44 .new_with_children(
45 taffy::style::FlexboxLayout {
46 size: taffy::geometry::Size {
47 width: taffy::style::Dimension::Points(20f32),
48 height: taffy::style::Dimension::Points(20f32),
49 ..Default::default()
50 },
51 ..Default::default()
52 },
53 &[],
54 )
55 .unwrap();
56 let node4 = taffy
57 .new_with_children(
58 taffy::style::FlexboxLayout {
59 size: taffy::geometry::Size {
60 width: taffy::style::Dimension::Points(20f32),
61 height: taffy::style::Dimension::Points(20f32),
62 ..Default::default()
63 },
64 ..Default::default()
65 },
66 &[],
67 )
68 .unwrap();
69 let node5 = taffy
70 .new_with_children(
71 taffy::style::FlexboxLayout {
72 size: taffy::geometry::Size {
73 width: taffy::style::Dimension::Points(20f32),
74 height: taffy::style::Dimension::Points(20f32),
75 ..Default::default()
76 },
77 ..Default::default()
78 },
79 &[],
80 )
81 .unwrap();
82 let node6 = taffy
83 .new_with_children(
84 taffy::style::FlexboxLayout {
85 size: taffy::geometry::Size {
86 width: taffy::style::Dimension::Points(20f32),
87 height: taffy::style::Dimension::Points(20f32),
88 ..Default::default()
89 },
90 ..Default::default()
91 },
92 &[],
93 )
94 .unwrap();
95 let node7 = taffy
96 .new_with_children(
97 taffy::style::FlexboxLayout {
98 size: taffy::geometry::Size {
99 width: taffy::style::Dimension::Points(20f32),
100 height: taffy::style::Dimension::Points(20f32),
101 ..Default::default()
102 },
103 ..Default::default()
104 },
105 &[],
106 )
107 .unwrap();
108 let node8 = taffy
109 .new_with_children(
110 taffy::style::FlexboxLayout {
111 size: taffy::geometry::Size {
112 width: taffy::style::Dimension::Points(20f32),
113 height: taffy::style::Dimension::Points(20f32),
114 ..Default::default()
115 },
116 ..Default::default()
117 },
118 &[],
119 )
120 .unwrap();
121 let node = taffy
122 .new_with_children(
123 taffy::style::FlexboxLayout {
124 flex_wrap: taffy::style::FlexWrap::Wrap,
125 gap: taffy::geometry::Size {
126 width: taffy::style::Dimension::Points(10f32),
127 height: taffy::style::Dimension::Points(20f32),
128 ..Default::default()
129 },
130 size: taffy::geometry::Size { width: taffy::style::Dimension::Points(80f32), ..Default::default() },
131 ..Default::default()
132 },
133 &[node0, node1, node2, node3, node4, node5, node6, node7, node8],
134 )
135 .unwrap();
136 taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
137 assert_eq!(taffy.layout(node).unwrap().size.width, 80f32);
138 assert_eq!(taffy.layout(node).unwrap().size.height, 100f32);
139 assert_eq!(taffy.layout(node).unwrap().location.x, 0f32);
140 assert_eq!(taffy.layout(node).unwrap().location.y, 0f32);
141 assert_eq!(taffy.layout(node0).unwrap().size.width, 20f32);
142 assert_eq!(taffy.layout(node0).unwrap().size.height, 20f32);
143 assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32);
144 assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32);
145 assert_eq!(taffy.layout(node1).unwrap().size.width, 20f32);
146 assert_eq!(taffy.layout(node1).unwrap().size.height, 20f32);
147 assert_eq!(taffy.layout(node1).unwrap().location.x, 30f32);
148 assert_eq!(taffy.layout(node1).unwrap().location.y, 0f32);
149 assert_eq!(taffy.layout(node2).unwrap().size.width, 20f32);
150 assert_eq!(taffy.layout(node2).unwrap().size.height, 20f32);
151 assert_eq!(taffy.layout(node2).unwrap().location.x, 60f32);
152 assert_eq!(taffy.layout(node2).unwrap().location.y, 0f32);
153 assert_eq!(taffy.layout(node3).unwrap().size.width, 20f32);
154 assert_eq!(taffy.layout(node3).unwrap().size.height, 20f32);
155 assert_eq!(taffy.layout(node3).unwrap().location.x, 0f32);
156 assert_eq!(taffy.layout(node3).unwrap().location.y, 40f32);
157 assert_eq!(taffy.layout(node4).unwrap().size.width, 20f32);
158 assert_eq!(taffy.layout(node4).unwrap().size.height, 20f32);
159 assert_eq!(taffy.layout(node4).unwrap().location.x, 30f32);
160 assert_eq!(taffy.layout(node4).unwrap().location.y, 40f32);
161 assert_eq!(taffy.layout(node5).unwrap().size.width, 20f32);
162 assert_eq!(taffy.layout(node5).unwrap().size.height, 20f32);
163 assert_eq!(taffy.layout(node5).unwrap().location.x, 60f32);
164 assert_eq!(taffy.layout(node5).unwrap().location.y, 40f32);
165 assert_eq!(taffy.layout(node6).unwrap().size.width, 20f32);
166 assert_eq!(taffy.layout(node6).unwrap().size.height, 20f32);
167 assert_eq!(taffy.layout(node6).unwrap().location.x, 0f32);
168 assert_eq!(taffy.layout(node6).unwrap().location.y, 80f32);
169 assert_eq!(taffy.layout(node7).unwrap().size.width, 20f32);
170 assert_eq!(taffy.layout(node7).unwrap().size.height, 20f32);
171 assert_eq!(taffy.layout(node7).unwrap().location.x, 30f32);
172 assert_eq!(taffy.layout(node7).unwrap().location.y, 80f32);
173 assert_eq!(taffy.layout(node8).unwrap().size.width, 20f32);
174 assert_eq!(taffy.layout(node8).unwrap().size.height, 20f32);
175 assert_eq!(taffy.layout(node8).unwrap().location.x, 60f32);
176 assert_eq!(taffy.layout(node8).unwrap().location.y, 80f32);
177}