⎇ 1cc9406849daf4163f4c7780c73f58409c79b7ae
tests/generated/bevy_issue_8082.rs
Ñawpa willay
Pi imata llamkarqan
ch'uya
Update 0.3.x for 0.3.11 (#455)
1#[test]
2fn bevy_issue_8082() {
3 use slotmap::Key;
4 #[allow(unused_imports)]
5 use taffy::{layout::Layout, prelude::*};
6 let mut taffy = taffy::Taffy::new();
7 let node00 = taffy
8 .new_leaf(taffy::style::Style {
9 size: taffy::geometry::Size {
10 width: taffy::style::Dimension::Points(50f32),
11 height: taffy::style::Dimension::Points(50f32),
12 },
13 margin: taffy::geometry::Rect {
14 left: taffy::style::LengthPercentageAuto::Points(10f32),
15 right: taffy::style::LengthPercentageAuto::Points(10f32),
16 top: taffy::style::LengthPercentageAuto::Points(10f32),
17 bottom: taffy::style::LengthPercentageAuto::Points(10f32),
18 },
19 ..Default::default()
20 })
21 .unwrap();
22 let node01 = taffy
23 .new_leaf(taffy::style::Style {
24 size: taffy::geometry::Size {
25 width: taffy::style::Dimension::Points(50f32),
26 height: taffy::style::Dimension::Points(50f32),
27 },
28 margin: taffy::geometry::Rect {
29 left: taffy::style::LengthPercentageAuto::Points(10f32),
30 right: taffy::style::LengthPercentageAuto::Points(10f32),
31 top: taffy::style::LengthPercentageAuto::Points(10f32),
32 bottom: taffy::style::LengthPercentageAuto::Points(10f32),
33 },
34 ..Default::default()
35 })
36 .unwrap();
37 let node02 = taffy
38 .new_leaf(taffy::style::Style {
39 size: taffy::geometry::Size {
40 width: taffy::style::Dimension::Points(50f32),
41 height: taffy::style::Dimension::Points(50f32),
42 },
43 margin: taffy::geometry::Rect {
44 left: taffy::style::LengthPercentageAuto::Points(10f32),
45 right: taffy::style::LengthPercentageAuto::Points(10f32),
46 top: taffy::style::LengthPercentageAuto::Points(10f32),
47 bottom: taffy::style::LengthPercentageAuto::Points(10f32),
48 },
49 ..Default::default()
50 })
51 .unwrap();
52 let node03 = taffy
53 .new_leaf(taffy::style::Style {
54 size: taffy::geometry::Size {
55 width: taffy::style::Dimension::Points(50f32),
56 height: taffy::style::Dimension::Points(50f32),
57 },
58 margin: taffy::geometry::Rect {
59 left: taffy::style::LengthPercentageAuto::Points(10f32),
60 right: taffy::style::LengthPercentageAuto::Points(10f32),
61 top: taffy::style::LengthPercentageAuto::Points(10f32),
62 bottom: taffy::style::LengthPercentageAuto::Points(10f32),
63 },
64 ..Default::default()
65 })
66 .unwrap();
67 let node0 = taffy
68 .new_with_children(
69 taffy::style::Style {
70 flex_wrap: taffy::style::FlexWrap::Wrap,
71 align_items: Some(taffy::style::AlignItems::FlexStart),
72 align_content: Some(taffy::style::AlignContent::Center),
73 justify_content: Some(taffy::style::JustifyContent::Center),
74 ..Default::default()
75 },
76 &[node00, node01, node02, node03],
77 )
78 .unwrap();
79 let node = taffy
80 .new_with_children(
81 taffy::style::Style {
82 flex_direction: taffy::style::FlexDirection::Column,
83 align_items: Some(taffy::style::AlignItems::Stretch),
84 align_content: Some(taffy::style::AlignContent::Center),
85 justify_content: Some(taffy::style::JustifyContent::FlexStart),
86 size: taffy::geometry::Size {
87 width: taffy::style::Dimension::Points(200f32),
88 height: taffy::style::Dimension::Points(400f32),
89 },
90 ..Default::default()
91 },
92 &[node0],
93 )
94 .unwrap();
95 taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
96 println!("\nComputed tree:");
97 taffy::debug::print_tree(&taffy, node);
98 println!();
99 let Layout { size, location, .. } = taffy.layout(node).unwrap();
100 assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node.data(), 200f32, size.width);
101 assert_eq!(size.height, 400f32, "height of node {:?}. Expected {}. Actual {}", node.data(), 400f32, size.height);
102 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.x);
103 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.y);
104 let Layout { size, location, .. } = taffy.layout(node0).unwrap();
105 assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0.data(), 200f32, size.width);
106 assert_eq!(size.height, 140f32, "height of node {:?}. Expected {}. Actual {}", node0.data(), 140f32, size.height);
107 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.x);
108 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.y);
109 let Layout { size, location, .. } = taffy.layout(node00).unwrap();
110 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00.data(), 50f32, size.width);
111 assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node00.data(), 50f32, size.height);
112 assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node00.data(), 40f32, location.x);
113 assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node00.data(), 10f32, location.y);
114 let Layout { size, location, .. } = taffy.layout(node01).unwrap();
115 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node01.data(), 50f32, size.width);
116 assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node01.data(), 50f32, size.height);
117 assert_eq!(location.x, 110f32, "x of node {:?}. Expected {}. Actual {}", node01.data(), 110f32, location.x);
118 assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node01.data(), 10f32, location.y);
119 let Layout { size, location, .. } = taffy.layout(node02).unwrap();
120 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node02.data(), 50f32, size.width);
121 assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node02.data(), 50f32, size.height);
122 assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node02.data(), 40f32, location.x);
123 assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node02.data(), 80f32, location.y);
124 let Layout { size, location, .. } = taffy.layout(node03).unwrap();
125 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node03.data(), 50f32, size.width);
126 assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node03.data(), 50f32, size.height);
127 assert_eq!(location.x, 110f32, "x of node {:?}. Expected {}. Actual {}", node03.data(), 110f32, location.x);
128 assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node03.data(), 80f32, location.y);
129}