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