⎇ 1cc9406849daf4163f4c7780c73f58409c79b7ae
tests/generated/bevy_issue_8017.rs
History
Who touched what
raw
Update 0.3.x for 0.3.11 (#455)
1#[test]
2fn bevy_issue_8017() {
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::Percent(1f32),
11 height: taffy::style::Dimension::Percent(1f32),
12 },
13 ..Default::default()
14 })
15 .unwrap();
16 let node01 = taffy
17 .new_leaf(taffy::style::Style {
18 size: taffy::geometry::Size {
19 width: taffy::style::Dimension::Percent(1f32),
20 height: taffy::style::Dimension::Percent(1f32),
21 },
22 ..Default::default()
23 })
24 .unwrap();
25 let node0 = taffy
26 .new_with_children(
27 taffy::style::Style {
28 display: taffy::style::Display::Flex,
29 gap: taffy::geometry::Size {
30 width: taffy::style::LengthPercentage::Points(8f32),
31 height: taffy::style::LengthPercentage::Points(8f32),
32 },
33 size: taffy::geometry::Size {
34 width: taffy::style::Dimension::Percent(1f32),
35 height: taffy::style::Dimension::Percent(0.5f32),
36 },
37 ..Default::default()
38 },
39 &[node00, node01],
40 )
41 .unwrap();
42 let node10 = taffy
43 .new_leaf(taffy::style::Style {
44 size: taffy::geometry::Size {
45 width: taffy::style::Dimension::Percent(1f32),
46 height: taffy::style::Dimension::Percent(1f32),
47 },
48 ..Default::default()
49 })
50 .unwrap();
51 let node11 = taffy
52 .new_leaf(taffy::style::Style {
53 size: taffy::geometry::Size {
54 width: taffy::style::Dimension::Percent(1f32),
55 height: taffy::style::Dimension::Percent(1f32),
56 },
57 ..Default::default()
58 })
59 .unwrap();
60 let node1 = taffy
61 .new_with_children(
62 taffy::style::Style {
63 display: taffy::style::Display::Flex,
64 gap: taffy::geometry::Size {
65 width: taffy::style::LengthPercentage::Points(8f32),
66 height: taffy::style::LengthPercentage::Points(8f32),
67 },
68 size: taffy::geometry::Size {
69 width: taffy::style::Dimension::Percent(1f32),
70 height: taffy::style::Dimension::Percent(0.5f32),
71 },
72 ..Default::default()
73 },
74 &[node10, node11],
75 )
76 .unwrap();
77 let node = taffy
78 .new_with_children(
79 taffy::style::Style {
80 display: taffy::style::Display::Flex,
81 flex_direction: taffy::style::FlexDirection::Column,
82 gap: taffy::geometry::Size {
83 width: taffy::style::LengthPercentage::Points(8f32),
84 height: taffy::style::LengthPercentage::Points(8f32),
85 },
86 size: taffy::geometry::Size {
87 width: taffy::style::Dimension::Points(400f32),
88 height: taffy::style::Dimension::Points(400f32),
89 },
90 padding: taffy::geometry::Rect {
91 left: taffy::style::LengthPercentage::Points(8f32),
92 right: taffy::style::LengthPercentage::Points(8f32),
93 top: taffy::style::LengthPercentage::Points(8f32),
94 bottom: taffy::style::LengthPercentage::Points(8f32),
95 },
96 ..Default::default()
97 },
98 &[node0, node1],
99 )
100 .unwrap();
101 taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
102 println!("\nComputed tree:");
103 taffy::debug::print_tree(&taffy, node);
104 println!();
105 let Layout { size, location, .. } = taffy.layout(node).unwrap();
106 assert_eq!(size.width, 400f32, "width of node {:?}. Expected {}. Actual {}", node.data(), 400f32, size.width);
107 assert_eq!(size.height, 400f32, "height of node {:?}. Expected {}. Actual {}", node.data(), 400f32, size.height);
108 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.x);
109 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.y);
110 let Layout { size, location, .. } = taffy.layout(node0).unwrap();
111 assert_eq!(size.width, 384f32, "width of node {:?}. Expected {}. Actual {}", node0.data(), 384f32, size.width);
112 assert_eq!(size.height, 188f32, "height of node {:?}. Expected {}. Actual {}", node0.data(), 188f32, size.height);
113 assert_eq!(location.x, 8f32, "x of node {:?}. Expected {}. Actual {}", node0.data(), 8f32, location.x);
114 assert_eq!(location.y, 8f32, "y of node {:?}. Expected {}. Actual {}", node0.data(), 8f32, location.y);
115 let Layout { size, location, .. } = taffy.layout(node00).unwrap();
116 assert_eq!(size.width, 188f32, "width of node {:?}. Expected {}. Actual {}", node00.data(), 188f32, size.width);
117 assert_eq!(size.height, 188f32, "height of node {:?}. Expected {}. Actual {}", node00.data(), 188f32, size.height);
118 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00.data(), 0f32, location.x);
119 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00.data(), 0f32, location.y);
120 let Layout { size, location, .. } = taffy.layout(node01).unwrap();
121 assert_eq!(size.width, 188f32, "width of node {:?}. Expected {}. Actual {}", node01.data(), 188f32, size.width);
122 assert_eq!(size.height, 188f32, "height of node {:?}. Expected {}. Actual {}", node01.data(), 188f32, size.height);
123 assert_eq!(location.x, 196f32, "x of node {:?}. Expected {}. Actual {}", node01.data(), 196f32, location.x);
124 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node01.data(), 0f32, location.y);
125 let Layout { size, location, .. } = taffy.layout(node1).unwrap();
126 assert_eq!(size.width, 384f32, "width of node {:?}. Expected {}. Actual {}", node1.data(), 384f32, size.width);
127 assert_eq!(size.height, 188f32, "height of node {:?}. Expected {}. Actual {}", node1.data(), 188f32, size.height);
128 assert_eq!(location.x, 8f32, "x of node {:?}. Expected {}. Actual {}", node1.data(), 8f32, location.x);
129 assert_eq!(location.y, 204f32, "y of node {:?}. Expected {}. Actual {}", node1.data(), 204f32, location.y);
130 let Layout { size, location, .. } = taffy.layout(node10).unwrap();
131 assert_eq!(size.width, 188f32, "width of node {:?}. Expected {}. Actual {}", node10.data(), 188f32, size.width);
132 assert_eq!(size.height, 188f32, "height of node {:?}. Expected {}. Actual {}", node10.data(), 188f32, size.height);
133 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10.data(), 0f32, location.x);
134 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10.data(), 0f32, location.y);
135 let Layout { size, location, .. } = taffy.layout(node11).unwrap();
136 assert_eq!(size.width, 188f32, "width of node {:?}. Expected {}. Actual {}", node11.data(), 188f32, size.width);
137 assert_eq!(size.height, 188f32, "height of node {:?}. Expected {}. Actual {}", node11.data(), 188f32, size.height);
138 assert_eq!(location.x, 196f32, "x of node {:?}. Expected {}. Actual {}", node11.data(), 196f32, location.x);
139 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node11.data(), 0f32, location.y);
140}