⎇ e8253b1ae8ad9e95777144ce91aa6fb1ec8d4e32
tests/generated/wrap_nodes_with_content_sizing_overflowing_margin.rs
Historia
Quién tocó qué
crudo
1#[test]
2fn wrap_nodes_with_content_sizing_overflowing_margin() {
3 use slotmap::Key;
4 #[allow(unused_imports)]
5 use taffy::{layout::Layout, prelude::*};
6 let mut taffy = taffy::Taffy::new();
7 let node000 = taffy
8 .new_leaf(taffy::style::Style {
9 size: taffy::geometry::Size {
10 width: taffy::style::Dimension::Points(40f32),
11 height: taffy::style::Dimension::Points(40f32),
12 },
13 ..Default::default()
14 })
15 .unwrap();
16 let node00 = taffy
17 .new_with_children(
18 taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, ..Default::default() },
19 &[node000],
20 )
21 .unwrap();
22 let node010 = taffy
23 .new_leaf(taffy::style::Style {
24 size: taffy::geometry::Size {
25 width: taffy::style::Dimension::Points(40f32),
26 height: taffy::style::Dimension::Points(40f32),
27 },
28 ..Default::default()
29 })
30 .unwrap();
31 let node01 = taffy
32 .new_with_children(
33 taffy::style::Style {
34 flex_direction: taffy::style::FlexDirection::Column,
35 margin: taffy::geometry::Rect {
36 left: zero(),
37 right: taffy::style::LengthPercentageAuto::Points(10f32),
38 top: zero(),
39 bottom: zero(),
40 },
41 ..Default::default()
42 },
43 &[node010],
44 )
45 .unwrap();
46 let node0 = taffy
47 .new_with_children(
48 taffy::style::Style {
49 flex_wrap: taffy::style::FlexWrap::Wrap,
50 size: taffy::geometry::Size { width: taffy::style::Dimension::Points(85f32), height: auto() },
51 ..Default::default()
52 },
53 &[node00, node01],
54 )
55 .unwrap();
56 let node = taffy
57 .new_with_children(
58 taffy::style::Style {
59 flex_direction: taffy::style::FlexDirection::Column,
60 size: taffy::geometry::Size {
61 width: taffy::style::Dimension::Points(500f32),
62 height: taffy::style::Dimension::Points(500f32),
63 },
64 ..Default::default()
65 },
66 &[node0],
67 )
68 .unwrap();
69 taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
70 println!("\nComputed tree:");
71 taffy::debug::print_tree(&taffy, node);
72 println!();
73 let Layout { size, location, .. } = taffy.layout(node).unwrap();
74 assert_eq!(size.width, 500f32, "width of node {:?}. Expected {}. Actual {}", node.data(), 500f32, size.width);
75 assert_eq!(size.height, 500f32, "height of node {:?}. Expected {}. Actual {}", node.data(), 500f32, size.height);
76 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.x);
77 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.y);
78 let Layout { size, location, .. } = taffy.layout(node0).unwrap();
79 assert_eq!(size.width, 85f32, "width of node {:?}. Expected {}. Actual {}", node0.data(), 85f32, size.width);
80 assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node0.data(), 80f32, size.height);
81 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.x);
82 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.y);
83 let Layout { size, location, .. } = taffy.layout(node00).unwrap();
84 assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node00.data(), 40f32, size.width);
85 assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node00.data(), 40f32, size.height);
86 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00.data(), 0f32, location.x);
87 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00.data(), 0f32, location.y);
88 let Layout { size, location, .. } = taffy.layout(node000).unwrap();
89 assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node000.data(), 40f32, size.width);
90 assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node000.data(), 40f32, size.height);
91 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000.data(), 0f32, location.x);
92 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node000.data(), 0f32, location.y);
93 let Layout { size, location, .. } = taffy.layout(node01).unwrap();
94 assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node01.data(), 40f32, size.width);
95 assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node01.data(), 40f32, size.height);
96 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node01.data(), 0f32, location.x);
97 assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node01.data(), 40f32, location.y);
98 let Layout { size, location, .. } = taffy.layout(node010).unwrap();
99 assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node010.data(), 40f32, size.width);
100 assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node010.data(), 40f32, size.height);
101 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node010.data(), 0f32, location.x);
102 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node010.data(), 0f32, location.y);
103}