⎇ 04e20d1de5cd584bf0760071cf130dd55f5b0089
tests/generated/flex/rounding_inner_node_controversy_vertical.rs
Historia
Quién tocó qué
crudo
Rename Taffy struct to TaffyTree (#580)
1#[test]
2fn rounding_inner_node_controversy_vertical() {
3 #[allow(unused_imports)]
4 use taffy::{prelude::*, tree::Layout, TaffyTree};
5 let mut taffy: TaffyTree<crate::TextMeasure> = TaffyTree::new();
6 let node0 = taffy
7 .new_leaf(taffy::style::Style {
8 flex_grow: 1f32,
9 size: taffy::geometry::Size { width: taffy::style::Dimension::Length(10f32), height: auto() },
10 ..Default::default()
11 })
12 .unwrap();
13 let node10 = taffy
14 .new_leaf(taffy::style::Style {
15 flex_grow: 1f32,
16 size: taffy::geometry::Size { width: taffy::style::Dimension::Length(10f32), height: auto() },
17 ..Default::default()
18 })
19 .unwrap();
20 let node1 = taffy
21 .new_with_children(
22 taffy::style::Style {
23 flex_direction: taffy::style::FlexDirection::Column,
24 flex_grow: 1f32,
25 size: taffy::geometry::Size { width: taffy::style::Dimension::Length(10f32), height: auto() },
26 ..Default::default()
27 },
28 &[node10],
29 )
30 .unwrap();
31 let node2 = taffy
32 .new_leaf(taffy::style::Style {
33 flex_grow: 1f32,
34 size: taffy::geometry::Size { width: taffy::style::Dimension::Length(10f32), height: auto() },
35 ..Default::default()
36 })
37 .unwrap();
38 let node = taffy
39 .new_with_children(
40 taffy::style::Style {
41 flex_direction: taffy::style::FlexDirection::Column,
42 size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(320f32) },
43 ..Default::default()
44 },
45 &[node0, node1, node2],
46 )
47 .unwrap();
48 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
49 println!("\nComputed tree:");
50 taffy.print_tree(node);
51 println!();
52 #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
53 let layout @ Layout { size, location, .. } = taffy.layout(node).unwrap();
54 assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node, 10f32, size.width);
55 assert_eq!(size.height, 320f32, "height of node {:?}. Expected {}. Actual {}", node, 320f32, size.height);
56 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
57 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
58 #[cfg(feature = "content_size")]
59 assert_eq!(
60 layout.scroll_width(),
61 0f32,
62 "scroll_width of node {:?}. Expected {}. Actual {}",
63 node,
64 0f32,
65 layout.scroll_width()
66 );
67 #[cfg(feature = "content_size")]
68 assert_eq!(
69 layout.scroll_height(),
70 0f32,
71 "scroll_height of node {:?}. Expected {}. Actual {}",
72 node,
73 0f32,
74 layout.scroll_height()
75 );
76 #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
77 let layout @ Layout { size, location, .. } = taffy.layout(node0).unwrap();
78 assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width);
79 assert_eq!(size.height, 107f32, "height of node {:?}. Expected {}. Actual {}", node0, 107f32, size.height);
80 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
81 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y);
82 #[cfg(feature = "content_size")]
83 assert_eq!(
84 layout.scroll_width(),
85 0f32,
86 "scroll_width of node {:?}. Expected {}. Actual {}",
87 node0,
88 0f32,
89 layout.scroll_width()
90 );
91 #[cfg(feature = "content_size")]
92 assert_eq!(
93 layout.scroll_height(),
94 0f32,
95 "scroll_height of node {:?}. Expected {}. Actual {}",
96 node0,
97 0f32,
98 layout.scroll_height()
99 );
100 #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
101 let layout @ Layout { size, location, .. } = taffy.layout(node1).unwrap();
102 assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node1, 10f32, size.width);
103 assert_eq!(size.height, 106f32, "height of node {:?}. Expected {}. Actual {}", node1, 106f32, size.height);
104 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x);
105 assert_eq!(location.y, 107f32, "y of node {:?}. Expected {}. Actual {}", node1, 107f32, location.y);
106 #[cfg(feature = "content_size")]
107 assert_eq!(
108 layout.scroll_width(),
109 0f32,
110 "scroll_width of node {:?}. Expected {}. Actual {}",
111 node1,
112 0f32,
113 layout.scroll_width()
114 );
115 #[cfg(feature = "content_size")]
116 assert_eq!(
117 layout.scroll_height(),
118 0f32,
119 "scroll_height of node {:?}. Expected {}. Actual {}",
120 node1,
121 0f32,
122 layout.scroll_height()
123 );
124 #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
125 let layout @ Layout { size, location, .. } = taffy.layout(node10).unwrap();
126 assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node10, 10f32, size.width);
127 assert_eq!(size.height, 106f32, "height of node {:?}. Expected {}. Actual {}", node10, 106f32, size.height);
128 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x);
129 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y);
130 #[cfg(feature = "content_size")]
131 assert_eq!(
132 layout.scroll_width(),
133 0f32,
134 "scroll_width of node {:?}. Expected {}. Actual {}",
135 node10,
136 0f32,
137 layout.scroll_width()
138 );
139 #[cfg(feature = "content_size")]
140 assert_eq!(
141 layout.scroll_height(),
142 0f32,
143 "scroll_height of node {:?}. Expected {}. Actual {}",
144 node10,
145 0f32,
146 layout.scroll_height()
147 );
148 #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
149 let layout @ Layout { size, location, .. } = taffy.layout(node2).unwrap();
150 assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node2, 10f32, size.width);
151 assert_eq!(size.height, 107f32, "height of node {:?}. Expected {}. Actual {}", node2, 107f32, size.height);
152 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x);
153 assert_eq!(location.y, 213f32, "y of node {:?}. Expected {}. Actual {}", node2, 213f32, location.y);
154 #[cfg(feature = "content_size")]
155 assert_eq!(
156 layout.scroll_width(),
157 0f32,
158 "scroll_width of node {:?}. Expected {}. Actual {}",
159 node2,
160 0f32,
161 layout.scroll_width()
162 );
163 #[cfg(feature = "content_size")]
164 assert_eq!(
165 layout.scroll_height(),
166 0f32,
167 "scroll_height of node {:?}. Expected {}. Actual {}",
168 node2,
169 0f32,
170 layout.scroll_height()
171 );
172}