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