⎇ 04e20d1de5cd584bf0760071cf130dd55f5b0089
tests/generated/flex/bevy_issue_7976_3_level.rs
Ñawpa willay
Pi imata llamkarqan
ch'uya
Rename Taffy struct to TaffyTree (#580)
1#[test]
2fn bevy_issue_7976_3_level() {
3 #[allow(unused_imports)]
4 use taffy::{prelude::*, tree::Layout, TaffyTree};
5 let mut taffy: TaffyTree<crate::TextMeasure> = TaffyTree::new();
6 let node00 = taffy
7 .new_leaf(taffy::style::Style {
8 size: taffy::geometry::Size {
9 width: taffy::style::Dimension::Percent(1f32),
10 height: taffy::style::Dimension::Percent(1f32),
11 },
12 padding: taffy::geometry::Rect {
13 left: taffy::style::LengthPercentage::Length(5f32),
14 right: taffy::style::LengthPercentage::Length(5f32),
15 top: taffy::style::LengthPercentage::Length(5f32),
16 bottom: taffy::style::LengthPercentage::Length(5f32),
17 },
18 ..Default::default()
19 })
20 .unwrap();
21 let node0 = taffy
22 .new_with_children(
23 taffy::style::Style {
24 min_size: taffy::geometry::Size {
25 width: taffy::style::Dimension::Length(40f32),
26 height: taffy::style::Dimension::Length(40f32),
27 },
28 margin: taffy::geometry::Rect {
29 left: taffy::style::LengthPercentageAuto::Length(5f32),
30 right: taffy::style::LengthPercentageAuto::Length(5f32),
31 top: taffy::style::LengthPercentageAuto::Length(5f32),
32 bottom: taffy::style::LengthPercentageAuto::Length(5f32),
33 },
34 padding: taffy::geometry::Rect {
35 left: taffy::style::LengthPercentage::Length(5f32),
36 right: taffy::style::LengthPercentage::Length(5f32),
37 top: taffy::style::LengthPercentage::Length(5f32),
38 bottom: taffy::style::LengthPercentage::Length(5f32),
39 },
40 ..Default::default()
41 },
42 &[node00],
43 )
44 .unwrap();
45 let node = taffy
46 .new_with_children(
47 taffy::style::Style {
48 align_content: Some(taffy::style::AlignContent::Start),
49 size: taffy::geometry::Size {
50 width: taffy::style::Dimension::Length(200f32),
51 height: taffy::style::Dimension::Length(200f32),
52 },
53 ..Default::default()
54 },
55 &[node0],
56 )
57 .unwrap();
58 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
59 println!("\nComputed tree:");
60 taffy.print_tree(node);
61 println!();
62 #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
63 let layout @ Layout { size, location, .. } = taffy.layout(node).unwrap();
64 assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width);
65 assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height);
66 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
67 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
68 #[cfg(feature = "content_size")]
69 assert_eq!(
70 layout.scroll_width(),
71 0f32,
72 "scroll_width of node {:?}. Expected {}. Actual {}",
73 node,
74 0f32,
75 layout.scroll_width()
76 );
77 #[cfg(feature = "content_size")]
78 assert_eq!(
79 layout.scroll_height(),
80 0f32,
81 "scroll_height of node {:?}. Expected {}. Actual {}",
82 node,
83 0f32,
84 layout.scroll_height()
85 );
86 #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
87 let layout @ Layout { size, location, .. } = taffy.layout(node0).unwrap();
88 assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width);
89 assert_eq!(size.height, 190f32, "height of node {:?}. Expected {}. Actual {}", node0, 190f32, size.height);
90 assert_eq!(location.x, 5f32, "x of node {:?}. Expected {}. Actual {}", node0, 5f32, location.x);
91 assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node0, 5f32, location.y);
92 #[cfg(feature = "content_size")]
93 assert_eq!(
94 layout.scroll_width(),
95 0f32,
96 "scroll_width of node {:?}. Expected {}. Actual {}",
97 node0,
98 0f32,
99 layout.scroll_width()
100 );
101 #[cfg(feature = "content_size")]
102 assert_eq!(
103 layout.scroll_height(),
104 0f32,
105 "scroll_height of node {:?}. Expected {}. Actual {}",
106 node0,
107 0f32,
108 layout.scroll_height()
109 );
110 #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
111 let layout @ Layout { size, location, .. } = taffy.layout(node00).unwrap();
112 assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node00, 30f32, size.width);
113 assert_eq!(size.height, 180f32, "height of node {:?}. Expected {}. Actual {}", node00, 180f32, size.height);
114 assert_eq!(location.x, 5f32, "x of node {:?}. Expected {}. Actual {}", node00, 5f32, location.x);
115 assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node00, 5f32, location.y);
116 #[cfg(feature = "content_size")]
117 assert_eq!(
118 layout.scroll_width(),
119 0f32,
120 "scroll_width of node {:?}. Expected {}. Actual {}",
121 node00,
122 0f32,
123 layout.scroll_width()
124 );
125 #[cfg(feature = "content_size")]
126 assert_eq!(
127 layout.scroll_height(),
128 0f32,
129 "scroll_height of node {:?}. Expected {}. Actual {}",
130 node00,
131 0f32,
132 layout.scroll_height()
133 );
134}