⎇ f99b57fbad456aa2756b374ff40c876e4b9574c2
tests/generated/grid/grid_percent_tracks_definite_underflow.rs
Historia
Quién tocó qué
crudo
Use tagged pointer to represent size/length values (#769)
1#[test]
2#[allow(non_snake_case)]
3fn grid_percent_tracks_definite_underflow__border_box() {
4 #[allow(unused_imports)]
5 use taffy::{prelude::*, Layout};
6 let mut taffy = crate::new_test_tree();
7 let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap();
8 let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap();
9 let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap();
10 let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap();
11 let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap();
12 let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap();
13 let node = taffy
14 .new_with_children(
15 taffy::style::Style {
16 display: taffy::style::Display::Grid,
17 grid_template_rows: vec![percent(0.3f32), percent(0.6f32)],
18 grid_template_columns: vec![percent(0.1f32), percent(0.2f32), percent(0.3f32)],
19 size: taffy::geometry::Size {
20 width: taffy::style::Dimension::from_length(120f32),
21 height: taffy::style::Dimension::from_length(60f32),
22 },
23 ..Default::default()
24 },
25 &[node0, node1, node2, node3, node4, node5],
26 )
27 .unwrap();
28 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
29 println!("\nComputed tree:");
30 taffy.print_tree(node);
31 println!();
32 let layout = taffy.layout(node).unwrap();
33 let Layout { size, location, .. } = layout;
34 assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node, 120f32, size.width);
35 assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node, 60f32, size.height);
36 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
37 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
38 let layout = taffy.layout(node0).unwrap();
39 let Layout { size, location, .. } = layout;
40 assert_eq!(size.width, 12f32, "width of node {:?}. Expected {}. Actual {}", node0, 12f32, size.width);
41 assert_eq!(size.height, 18f32, "height of node {:?}. Expected {}. Actual {}", node0, 18f32, size.height);
42 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
43 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y);
44 let layout = taffy.layout(node1).unwrap();
45 let Layout { size, location, .. } = layout;
46 assert_eq!(size.width, 24f32, "width of node {:?}. Expected {}. Actual {}", node1, 24f32, size.width);
47 assert_eq!(size.height, 18f32, "height of node {:?}. Expected {}. Actual {}", node1, 18f32, size.height);
48 assert_eq!(location.x, 12f32, "x of node {:?}. Expected {}. Actual {}", node1, 12f32, location.x);
49 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y);
50 let layout = taffy.layout(node2).unwrap();
51 let Layout { size, location, .. } = layout;
52 assert_eq!(size.width, 36f32, "width of node {:?}. Expected {}. Actual {}", node2, 36f32, size.width);
53 assert_eq!(size.height, 18f32, "height of node {:?}. Expected {}. Actual {}", node2, 18f32, size.height);
54 assert_eq!(location.x, 36f32, "x of node {:?}. Expected {}. Actual {}", node2, 36f32, location.x);
55 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y);
56 let layout = taffy.layout(node3).unwrap();
57 let Layout { size, location, .. } = layout;
58 assert_eq!(size.width, 12f32, "width of node {:?}. Expected {}. Actual {}", node3, 12f32, size.width);
59 assert_eq!(size.height, 36f32, "height of node {:?}. Expected {}. Actual {}", node3, 36f32, size.height);
60 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x);
61 assert_eq!(location.y, 18f32, "y of node {:?}. Expected {}. Actual {}", node3, 18f32, location.y);
62 let layout = taffy.layout(node4).unwrap();
63 let Layout { size, location, .. } = layout;
64 assert_eq!(size.width, 24f32, "width of node {:?}. Expected {}. Actual {}", node4, 24f32, size.width);
65 assert_eq!(size.height, 36f32, "height of node {:?}. Expected {}. Actual {}", node4, 36f32, size.height);
66 assert_eq!(location.x, 12f32, "x of node {:?}. Expected {}. Actual {}", node4, 12f32, location.x);
67 assert_eq!(location.y, 18f32, "y of node {:?}. Expected {}. Actual {}", node4, 18f32, location.y);
68 let layout = taffy.layout(node5).unwrap();
69 let Layout { size, location, .. } = layout;
70 assert_eq!(size.width, 36f32, "width of node {:?}. Expected {}. Actual {}", node5, 36f32, size.width);
71 assert_eq!(size.height, 36f32, "height of node {:?}. Expected {}. Actual {}", node5, 36f32, size.height);
72 assert_eq!(location.x, 36f32, "x of node {:?}. Expected {}. Actual {}", node5, 36f32, location.x);
73 assert_eq!(location.y, 18f32, "y of node {:?}. Expected {}. Actual {}", node5, 18f32, location.y);
74}
75
76#[test]
77#[allow(non_snake_case)]
78fn grid_percent_tracks_definite_underflow__content_box() {
79 #[allow(unused_imports)]
80 use taffy::{prelude::*, Layout};
81 let mut taffy = crate::new_test_tree();
82 let node0 = taffy
83 .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() })
84 .unwrap();
85 let node1 = taffy
86 .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() })
87 .unwrap();
88 let node2 = taffy
89 .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() })
90 .unwrap();
91 let node3 = taffy
92 .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() })
93 .unwrap();
94 let node4 = taffy
95 .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() })
96 .unwrap();
97 let node5 = taffy
98 .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() })
99 .unwrap();
100 let node = taffy
101 .new_with_children(
102 taffy::style::Style {
103 display: taffy::style::Display::Grid,
104 box_sizing: taffy::style::BoxSizing::ContentBox,
105 grid_template_rows: vec![percent(0.3f32), percent(0.6f32)],
106 grid_template_columns: vec![percent(0.1f32), percent(0.2f32), percent(0.3f32)],
107 size: taffy::geometry::Size {
108 width: taffy::style::Dimension::from_length(120f32),
109 height: taffy::style::Dimension::from_length(60f32),
110 },
111 ..Default::default()
112 },
113 &[node0, node1, node2, node3, node4, node5],
114 )
115 .unwrap();
116 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
117 println!("\nComputed tree:");
118 taffy.print_tree(node);
119 println!();
120 let layout = taffy.layout(node).unwrap();
121 let Layout { size, location, .. } = layout;
122 assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node, 120f32, size.width);
123 assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node, 60f32, size.height);
124 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
125 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
126 let layout = taffy.layout(node0).unwrap();
127 let Layout { size, location, .. } = layout;
128 assert_eq!(size.width, 12f32, "width of node {:?}. Expected {}. Actual {}", node0, 12f32, size.width);
129 assert_eq!(size.height, 18f32, "height of node {:?}. Expected {}. Actual {}", node0, 18f32, size.height);
130 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
131 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y);
132 let layout = taffy.layout(node1).unwrap();
133 let Layout { size, location, .. } = layout;
134 assert_eq!(size.width, 24f32, "width of node {:?}. Expected {}. Actual {}", node1, 24f32, size.width);
135 assert_eq!(size.height, 18f32, "height of node {:?}. Expected {}. Actual {}", node1, 18f32, size.height);
136 assert_eq!(location.x, 12f32, "x of node {:?}. Expected {}. Actual {}", node1, 12f32, location.x);
137 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y);
138 let layout = taffy.layout(node2).unwrap();
139 let Layout { size, location, .. } = layout;
140 assert_eq!(size.width, 36f32, "width of node {:?}. Expected {}. Actual {}", node2, 36f32, size.width);
141 assert_eq!(size.height, 18f32, "height of node {:?}. Expected {}. Actual {}", node2, 18f32, size.height);
142 assert_eq!(location.x, 36f32, "x of node {:?}. Expected {}. Actual {}", node2, 36f32, location.x);
143 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y);
144 let layout = taffy.layout(node3).unwrap();
145 let Layout { size, location, .. } = layout;
146 assert_eq!(size.width, 12f32, "width of node {:?}. Expected {}. Actual {}", node3, 12f32, size.width);
147 assert_eq!(size.height, 36f32, "height of node {:?}. Expected {}. Actual {}", node3, 36f32, size.height);
148 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x);
149 assert_eq!(location.y, 18f32, "y of node {:?}. Expected {}. Actual {}", node3, 18f32, location.y);
150 let layout = taffy.layout(node4).unwrap();
151 let Layout { size, location, .. } = layout;
152 assert_eq!(size.width, 24f32, "width of node {:?}. Expected {}. Actual {}", node4, 24f32, size.width);
153 assert_eq!(size.height, 36f32, "height of node {:?}. Expected {}. Actual {}", node4, 36f32, size.height);
154 assert_eq!(location.x, 12f32, "x of node {:?}. Expected {}. Actual {}", node4, 12f32, location.x);
155 assert_eq!(location.y, 18f32, "y of node {:?}. Expected {}. Actual {}", node4, 18f32, location.y);
156 let layout = taffy.layout(node5).unwrap();
157 let Layout { size, location, .. } = layout;
158 assert_eq!(size.width, 36f32, "width of node {:?}. Expected {}. Actual {}", node5, 36f32, size.width);
159 assert_eq!(size.height, 36f32, "height of node {:?}. Expected {}. Actual {}", node5, 36f32, size.height);
160 assert_eq!(location.x, 36f32, "x of node {:?}. Expected {}. Actual {}", node5, 36f32, location.x);
161 assert_eq!(location.y, 18f32, "y of node {:?}. Expected {}. Actual {}", node5, 18f32, location.y);
162}