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