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