⎇ 568f643327ec6b4879df0087def7f4e66b6acafb
tests/generated/align_content_flex_start_without_height_on_children.rs
Ñawpa willay
Pi imata llamkarqan
ch'uya
Rename `Points`/`points` to `Length`/`length` in many APIs (#459)
1#[test]
2fn align_content_flex_start_without_height_on_children() {
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(10f32),
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 {
30 width: taffy::style::Dimension::Length(50f32),
31 height: taffy::style::Dimension::Length(10f32),
32 },
33 ..Default::default()
34 })
35 .unwrap();
36 let node4 = taffy
37 .new_leaf(taffy::style::Style {
38 size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() },
39 ..Default::default()
40 })
41 .unwrap();
42 let node = taffy
43 .new_with_children(
44 taffy::style::Style {
45 flex_direction: taffy::style::FlexDirection::Column,
46 flex_wrap: taffy::style::FlexWrap::Wrap,
47 align_content: Some(taffy::style::AlignContent::FlexStart),
48 size: taffy::geometry::Size {
49 width: taffy::style::Dimension::Length(100f32),
50 height: taffy::style::Dimension::Length(100f32),
51 },
52 ..Default::default()
53 },
54 &[node0, node1, node2, node3, node4],
55 )
56 .unwrap();
57 taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
58 println!("\nComputed tree:");
59 taffy::util::print_tree(&taffy, node);
60 println!();
61 let Layout { size, location, .. } = taffy.layout(node).unwrap();
62 assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width);
63 assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height);
64 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
65 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
66 let Layout { size, location, .. } = taffy.layout(node0).unwrap();
67 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width);
68 assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height);
69 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
70 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y);
71 let Layout { size, location, .. } = taffy.layout(node1).unwrap();
72 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width);
73 assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height);
74 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x);
75 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y);
76 let Layout { size, location, .. } = taffy.layout(node2).unwrap();
77 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width);
78 assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node2, 0f32, size.height);
79 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x);
80 assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node2, 10f32, location.y);
81 let Layout { size, location, .. } = taffy.layout(node3).unwrap();
82 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node3, 50f32, size.width);
83 assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node3, 10f32, size.height);
84 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x);
85 assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node3, 10f32, location.y);
86 let Layout { size, location, .. } = taffy.layout(node4).unwrap();
87 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node4, 50f32, size.width);
88 assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node4, 0f32, size.height);
89 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node4, 0f32, location.x);
90 assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node4, 20f32, location.y);
91}