⎇ direction-floats
tests/generated/flex/rounding_inner_node_controversy_horizontal.rs
History
Who touched what
raw
Use tagged pointer to represent size/length values (#769)
1#[test]
2#[allow(non_snake_case)]
3fn rounding_inner_node_controversy_horizontal__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 size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) },
11 ..Default::default()
12 })
13 .unwrap();
14 let node10 = taffy
15 .new_leaf(taffy::style::Style {
16 flex_grow: 1f32,
17 size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) },
18 ..Default::default()
19 })
20 .unwrap();
21 let node1 = taffy
22 .new_with_children(
23 taffy::style::Style {
24 flex_direction: taffy::style::FlexDirection::Column,
25 flex_grow: 1f32,
26 size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) },
27 ..Default::default()
28 },
29 &[node10],
30 )
31 .unwrap();
32 let node2 = taffy
33 .new_leaf(taffy::style::Style {
34 flex_grow: 1f32,
35 size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) },
36 ..Default::default()
37 })
38 .unwrap();
39 let node = taffy
40 .new_with_children(
41 taffy::style::Style {
42 size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(320f32), height: auto() },
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 let layout = taffy.layout(node).unwrap();
53 let Layout { size, location, .. } = layout;
54 assert_eq!(size.width, 320f32, "width of node {:?}. Expected {}. Actual {}", node, 320f32, size.width);
55 assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node, 10f32, 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 let layout = taffy.layout(node0).unwrap();
59 let Layout { size, location, .. } = layout;
60 assert_eq!(size.width, 107f32, "width of node {:?}. Expected {}. Actual {}", node0, 107f32, size.width);
61 assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height);
62 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
63 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y);
64 let layout = taffy.layout(node1).unwrap();
65 let Layout { size, location, .. } = layout;
66 assert_eq!(size.width, 106f32, "width of node {:?}. Expected {}. Actual {}", node1, 106f32, size.width);
67 assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height);
68 assert_eq!(location.x, 107f32, "x of node {:?}. Expected {}. Actual {}", node1, 107f32, location.x);
69 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y);
70 let layout = taffy.layout(node10).unwrap();
71 let Layout { size, location, .. } = layout;
72 assert_eq!(size.width, 106f32, "width of node {:?}. Expected {}. Actual {}", node10, 106f32, size.width);
73 assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node10, 10f32, size.height);
74 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x);
75 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y);
76 let layout = taffy.layout(node2).unwrap();
77 let Layout { size, location, .. } = layout;
78 assert_eq!(size.width, 107f32, "width of node {:?}. Expected {}. Actual {}", node2, 107f32, size.width);
79 assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height);
80 assert_eq!(location.x, 213f32, "x of node {:?}. Expected {}. Actual {}", node2, 213f32, location.x);
81 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y);
82}
83
84#[test]
85#[allow(non_snake_case)]
86fn rounding_inner_node_controversy_horizontal__content_box() {
87 #[allow(unused_imports)]
88 use taffy::{prelude::*, Layout};
89 let mut taffy = crate::new_test_tree();
90 let node0 = taffy
91 .new_leaf(taffy::style::Style {
92 box_sizing: taffy::style::BoxSizing::ContentBox,
93 flex_grow: 1f32,
94 size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) },
95 ..Default::default()
96 })
97 .unwrap();
98 let node10 = taffy
99 .new_leaf(taffy::style::Style {
100 box_sizing: taffy::style::BoxSizing::ContentBox,
101 flex_grow: 1f32,
102 size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) },
103 ..Default::default()
104 })
105 .unwrap();
106 let node1 = taffy
107 .new_with_children(
108 taffy::style::Style {
109 box_sizing: taffy::style::BoxSizing::ContentBox,
110 flex_direction: taffy::style::FlexDirection::Column,
111 flex_grow: 1f32,
112 size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) },
113 ..Default::default()
114 },
115 &[node10],
116 )
117 .unwrap();
118 let node2 = taffy
119 .new_leaf(taffy::style::Style {
120 box_sizing: taffy::style::BoxSizing::ContentBox,
121 flex_grow: 1f32,
122 size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) },
123 ..Default::default()
124 })
125 .unwrap();
126 let node = taffy
127 .new_with_children(
128 taffy::style::Style {
129 box_sizing: taffy::style::BoxSizing::ContentBox,
130 size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(320f32), height: auto() },
131 ..Default::default()
132 },
133 &[node0, node1, node2],
134 )
135 .unwrap();
136 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
137 println!("\nComputed tree:");
138 taffy.print_tree(node);
139 println!();
140 let layout = taffy.layout(node).unwrap();
141 let Layout { size, location, .. } = layout;
142 assert_eq!(size.width, 320f32, "width of node {:?}. Expected {}. Actual {}", node, 320f32, size.width);
143 assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node, 10f32, size.height);
144 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
145 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
146 let layout = taffy.layout(node0).unwrap();
147 let Layout { size, location, .. } = layout;
148 assert_eq!(size.width, 107f32, "width of node {:?}. Expected {}. Actual {}", node0, 107f32, size.width);
149 assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height);
150 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
151 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y);
152 let layout = taffy.layout(node1).unwrap();
153 let Layout { size, location, .. } = layout;
154 assert_eq!(size.width, 106f32, "width of node {:?}. Expected {}. Actual {}", node1, 106f32, size.width);
155 assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height);
156 assert_eq!(location.x, 107f32, "x of node {:?}. Expected {}. Actual {}", node1, 107f32, location.x);
157 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y);
158 let layout = taffy.layout(node10).unwrap();
159 let Layout { size, location, .. } = layout;
160 assert_eq!(size.width, 106f32, "width of node {:?}. Expected {}. Actual {}", node10, 106f32, size.width);
161 assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node10, 10f32, size.height);
162 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x);
163 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y);
164 let layout = taffy.layout(node2).unwrap();
165 let Layout { size, location, .. } = layout;
166 assert_eq!(size.width, 107f32, "width of node {:?}. Expected {}. Actual {}", node2, 107f32, size.width);
167 assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height);
168 assert_eq!(location.x, 213f32, "x of node {:?}. Expected {}. Actual {}", node2, 213f32, location.x);
169 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y);
170}