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