⎇ 48e4800f14c6af5cd26275fb570d11b93e279654
tests/generated/flex/align_content_stretch_row_with_fixed_height.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_fixed_height() {
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 {
15 width: taffy::style::Dimension::Length(50f32),
16 height: taffy::style::Dimension::Length(60f32),
17 },
18 ..Default::default()
19 })
20 .unwrap();
21 let node2 = taffy
22 .new_leaf(taffy::style::Style {
23 size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() },
24 ..Default::default()
25 })
26 .unwrap();
27 let node3 = taffy
28 .new_leaf(taffy::style::Style {
29 size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() },
30 ..Default::default()
31 })
32 .unwrap();
33 let node4 = taffy
34 .new_leaf(taffy::style::Style {
35 size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() },
36 ..Default::default()
37 })
38 .unwrap();
39 let node = taffy
40 .new_with_children(
41 taffy::style::Style {
42 flex_wrap: taffy::style::FlexWrap::Wrap,
43 align_content: Some(taffy::style::AlignContent::Stretch),
44 size: taffy::geometry::Size {
45 width: taffy::style::Dimension::Length(150f32),
46 height: taffy::style::Dimension::Length(100f32),
47 },
48 ..Default::default()
49 },
50 &[node0, node1, node2, node3, node4],
51 )
52 .unwrap();
53 taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
54 println!("\nComputed tree:");
55 taffy::util::print_tree(&taffy, node);
56 println!();
57 let Layout { size, location, .. } = taffy.layout(node).unwrap();
58 assert_eq!(size.width, 150f32, "width of node {:?}. Expected {}. Actual {}", node, 150f32, size.width);
59 assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height);
60 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
61 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
62 let Layout { size, location, .. } = taffy.layout(node0).unwrap();
63 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width);
64 assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node0, 80f32, size.height);
65 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
66 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y);
67 let Layout { size, location, .. } = taffy.layout(node1).unwrap();
68 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width);
69 assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node1, 60f32, size.height);
70 assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x);
71 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y);
72 let Layout { size, location, .. } = taffy.layout(node2).unwrap();
73 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width);
74 assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node2, 80f32, size.height);
75 assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node2, 100f32, location.x);
76 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y);
77 let Layout { size, location, .. } = taffy.layout(node3).unwrap();
78 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node3, 50f32, size.width);
79 assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node3, 20f32, size.height);
80 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x);
81 assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node3, 80f32, location.y);
82 let Layout { size, location, .. } = taffy.layout(node4).unwrap();
83 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node4, 50f32, size.width);
84 assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node4, 20f32, size.height);
85 assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node4, 50f32, location.x);
86 assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node4, 80f32, location.y);
87}