⎇ 04e20d1de5cd584bf0760071cf130dd55f5b0089
tests/generated/flex/bevy_issue_10343_block.rs
History
Who touched what
raw
Fixes for content alignment spec updates (#635)
1#[test]
2fn bevy_issue_10343_block() {
3 #[allow(unused_imports)]
4 use taffy::{prelude::*, tree::Layout, TaffyTree};
5 let mut taffy: TaffyTree<crate::TextMeasure> = TaffyTree::new();
6 let node000 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap();
7 let node00 = taffy
8 .new_with_children(
9 taffy::style::Style {
10 display: taffy::style::Display::Block,
11 size: taffy::geometry::Size {
12 width: taffy::style::Dimension::Length(200f32),
13 height: taffy::style::Dimension::Length(200f32),
14 },
15 margin: taffy::geometry::Rect {
16 left: taffy::style::LengthPercentageAuto::Length(5f32),
17 right: taffy::style::LengthPercentageAuto::Length(5f32),
18 top: taffy::style::LengthPercentageAuto::Length(5f32),
19 bottom: taffy::style::LengthPercentageAuto::Length(5f32),
20 },
21 ..Default::default()
22 },
23 &[node000],
24 )
25 .unwrap();
26 let node0 = taffy
27 .new_with_children(
28 taffy::style::Style { display: taffy::style::Display::Flex, ..Default::default() },
29 &[node00],
30 )
31 .unwrap();
32 let node = taffy
33 .new_with_children(
34 taffy::style::Style {
35 display: taffy::style::Display::Flex,
36 flex_direction: taffy::style::FlexDirection::Column,
37 justify_content: Some(taffy::style::JustifyContent::SpaceAround),
38 size: taffy::geometry::Size {
39 width: taffy::style::Dimension::Length(100f32),
40 height: taffy::style::Dimension::Length(100f32),
41 },
42 ..Default::default()
43 },
44 &[node0],
45 )
46 .unwrap();
47 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
48 println!("\nComputed tree:");
49 taffy.print_tree(node);
50 println!();
51 #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
52 let layout @ Layout { size, location, .. } = taffy.layout(node).unwrap();
53 assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width);
54 assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height);
55 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
56 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
57 #[cfg(feature = "content_size")]
58 assert_eq!(
59 layout.scroll_width(),
60 0f32,
61 "scroll_width of node {:?}. Expected {}. Actual {}",
62 node,
63 0f32,
64 layout.scroll_width()
65 );
66 #[cfg(feature = "content_size")]
67 assert_eq!(
68 layout.scroll_height(),
69 110f32,
70 "scroll_height of node {:?}. Expected {}. Actual {}",
71 node,
72 110f32,
73 layout.scroll_height()
74 );
75 #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
76 let layout @ Layout { size, location, .. } = taffy.layout(node0).unwrap();
77 assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width);
78 assert_eq!(size.height, 210f32, "height of node {:?}. Expected {}. Actual {}", node0, 210f32, size.height);
79 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
80 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y);
81 #[cfg(feature = "content_size")]
82 assert_eq!(
83 layout.scroll_width(),
84 0f32,
85 "scroll_width of node {:?}. Expected {}. Actual {}",
86 node0,
87 0f32,
88 layout.scroll_width()
89 );
90 #[cfg(feature = "content_size")]
91 assert_eq!(
92 layout.scroll_height(),
93 0f32,
94 "scroll_height of node {:?}. Expected {}. Actual {}",
95 node0,
96 0f32,
97 layout.scroll_height()
98 );
99 #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
100 let layout @ Layout { size, location, .. } = taffy.layout(node00).unwrap();
101 assert_eq!(size.width, 90f32, "width of node {:?}. Expected {}. Actual {}", node00, 90f32, size.width);
102 assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node00, 200f32, size.height);
103 assert_eq!(location.x, 5f32, "x of node {:?}. Expected {}. Actual {}", node00, 5f32, location.x);
104 assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node00, 5f32, location.y);
105 #[cfg(feature = "content_size")]
106 assert_eq!(
107 layout.scroll_width(),
108 0f32,
109 "scroll_width of node {:?}. Expected {}. Actual {}",
110 node00,
111 0f32,
112 layout.scroll_width()
113 );
114 #[cfg(feature = "content_size")]
115 assert_eq!(
116 layout.scroll_height(),
117 0f32,
118 "scroll_height of node {:?}. Expected {}. Actual {}",
119 node00,
120 0f32,
121 layout.scroll_height()
122 );
123 #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
124 let layout @ Layout { size, location, .. } = taffy.layout(node000).unwrap();
125 assert_eq!(size.width, 90f32, "width of node {:?}. Expected {}. Actual {}", node000, 90f32, size.width);
126 assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node000, 0f32, size.height);
127 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x);
128 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node000, 0f32, location.y);
129 #[cfg(feature = "content_size")]
130 assert_eq!(
131 layout.scroll_width(),
132 0f32,
133 "scroll_width of node {:?}. Expected {}. Actual {}",
134 node000,
135 0f32,
136 layout.scroll_width()
137 );
138 #[cfg(feature = "content_size")]
139 assert_eq!(
140 layout.scroll_height(),
141 0f32,
142 "scroll_height of node {:?}. Expected {}. Actual {}",
143 node000,
144 0f32,
145 layout.scroll_height()
146 );
147}