⎇ float-layout
tests/generated/flex/display_none_with_child.rs
Ñawpa willay
Pi imata llamkarqan
ch'uya
Use tagged pointer to represent size/length values (#769)
1#[test]
2#[allow(non_snake_case)]
3fn display_none_with_child__border_box() {
4 #[allow(unused_imports)]
5 use taffy::{prelude::*, Layout};
6 let mut taffy = crate::new_test_tree();
7 let node0 = taffy
8 .new_leaf(taffy::style::Style {
9 flex_grow: 1f32,
10 flex_shrink: 1f32,
11 flex_basis: taffy::style::Dimension::from_percent(0f32),
12 ..Default::default()
13 })
14 .unwrap();
15 let node10 = taffy
16 .new_leaf(taffy::style::Style {
17 flex_grow: 1f32,
18 flex_shrink: 1f32,
19 flex_basis: taffy::style::Dimension::from_percent(0f32),
20 size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: auto() },
21 ..Default::default()
22 })
23 .unwrap();
24 let node1 = taffy
25 .new_with_children(
26 taffy::style::Style {
27 display: taffy::style::Display::None,
28 flex_direction: taffy::style::FlexDirection::Column,
29 flex_grow: 1f32,
30 flex_shrink: 1f32,
31 flex_basis: taffy::style::Dimension::from_percent(0f32),
32 ..Default::default()
33 },
34 &[node10],
35 )
36 .unwrap();
37 let node2 = taffy
38 .new_leaf(taffy::style::Style {
39 flex_grow: 1f32,
40 flex_shrink: 1f32,
41 flex_basis: taffy::style::Dimension::from_percent(0f32),
42 ..Default::default()
43 })
44 .unwrap();
45 let node = taffy
46 .new_with_children(
47 taffy::style::Style {
48 size: taffy::geometry::Size {
49 width: taffy::style::Dimension::from_length(100f32),
50 height: taffy::style::Dimension::from_length(100f32),
51 },
52 ..Default::default()
53 },
54 &[node0, node1, node2],
55 )
56 .unwrap();
57 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
58 println!("\nComputed tree:");
59 taffy.print_tree(node);
60 println!();
61 let layout = taffy.layout(node).unwrap();
62 let Layout { size, location, .. } = layout;
63 assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width);
64 assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height);
65 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
66 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
67 let layout = taffy.layout(node0).unwrap();
68 let Layout { size, location, .. } = layout;
69 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width);
70 assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height);
71 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
72 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y);
73 let layout = taffy.layout(node1).unwrap();
74 let Layout { size, location, .. } = layout;
75 assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node1, 0f32, size.width);
76 assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height);
77 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x);
78 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y);
79 let layout = taffy.layout(node10).unwrap();
80 let Layout { size, location, .. } = layout;
81 assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node10, 0f32, size.width);
82 assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node10, 0f32, size.height);
83 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x);
84 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y);
85 let layout = taffy.layout(node2).unwrap();
86 let Layout { size, location, .. } = layout;
87 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width);
88 assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node2, 100f32, size.height);
89 assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node2, 50f32, location.x);
90 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y);
91}
92
93#[test]
94#[allow(non_snake_case)]
95fn display_none_with_child__content_box() {
96 #[allow(unused_imports)]
97 use taffy::{prelude::*, Layout};
98 let mut taffy = crate::new_test_tree();
99 let node0 = taffy
100 .new_leaf(taffy::style::Style {
101 box_sizing: taffy::style::BoxSizing::ContentBox,
102 flex_grow: 1f32,
103 flex_shrink: 1f32,
104 flex_basis: taffy::style::Dimension::from_percent(0f32),
105 ..Default::default()
106 })
107 .unwrap();
108 let node10 = taffy
109 .new_leaf(taffy::style::Style {
110 box_sizing: taffy::style::BoxSizing::ContentBox,
111 flex_grow: 1f32,
112 flex_shrink: 1f32,
113 flex_basis: taffy::style::Dimension::from_percent(0f32),
114 size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(20f32), height: auto() },
115 ..Default::default()
116 })
117 .unwrap();
118 let node1 = taffy
119 .new_with_children(
120 taffy::style::Style {
121 display: taffy::style::Display::None,
122 box_sizing: taffy::style::BoxSizing::ContentBox,
123 flex_direction: taffy::style::FlexDirection::Column,
124 flex_grow: 1f32,
125 flex_shrink: 1f32,
126 flex_basis: taffy::style::Dimension::from_percent(0f32),
127 ..Default::default()
128 },
129 &[node10],
130 )
131 .unwrap();
132 let node2 = taffy
133 .new_leaf(taffy::style::Style {
134 box_sizing: taffy::style::BoxSizing::ContentBox,
135 flex_grow: 1f32,
136 flex_shrink: 1f32,
137 flex_basis: taffy::style::Dimension::from_percent(0f32),
138 ..Default::default()
139 })
140 .unwrap();
141 let node = taffy
142 .new_with_children(
143 taffy::style::Style {
144 box_sizing: taffy::style::BoxSizing::ContentBox,
145 size: taffy::geometry::Size {
146 width: taffy::style::Dimension::from_length(100f32),
147 height: taffy::style::Dimension::from_length(100f32),
148 },
149 ..Default::default()
150 },
151 &[node0, node1, node2],
152 )
153 .unwrap();
154 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
155 println!("\nComputed tree:");
156 taffy.print_tree(node);
157 println!();
158 let layout = taffy.layout(node).unwrap();
159 let Layout { size, location, .. } = layout;
160 assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width);
161 assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height);
162 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
163 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
164 let layout = taffy.layout(node0).unwrap();
165 let Layout { size, location, .. } = layout;
166 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width);
167 assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height);
168 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
169 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y);
170 let layout = taffy.layout(node1).unwrap();
171 let Layout { size, location, .. } = layout;
172 assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node1, 0f32, size.width);
173 assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height);
174 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x);
175 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y);
176 let layout = taffy.layout(node10).unwrap();
177 let Layout { size, location, .. } = layout;
178 assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node10, 0f32, size.width);
179 assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node10, 0f32, size.height);
180 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x);
181 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y);
182 let layout = taffy.layout(node2).unwrap();
183 let Layout { size, location, .. } = layout;
184 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width);
185 assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node2, 100f32, size.height);
186 assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node2, 50f32, location.x);
187 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y);
188}