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