⎇ 568f643327ec6b4879df0087def7f4e66b6acafb
tests/generated/margin_auto_mutiple_children_column.rs
History
Who touched what
raw
Rename `Points`/`points` to `Length`/`length` in many APIs (#459)
1#[test]
2fn margin_auto_mutiple_children_column() {
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 {
9 width: taffy::style::Dimension::Length(50f32),
10 height: taffy::style::Dimension::Length(50f32),
11 },
12 margin: taffy::geometry::Rect {
13 left: zero(),
14 right: zero(),
15 top: taffy::style::LengthPercentageAuto::Auto,
16 bottom: zero(),
17 },
18 ..Default::default()
19 })
20 .unwrap();
21 let node1 = taffy
22 .new_leaf(taffy::style::Style {
23 size: taffy::geometry::Size {
24 width: taffy::style::Dimension::Length(50f32),
25 height: taffy::style::Dimension::Length(50f32),
26 },
27 margin: taffy::geometry::Rect {
28 left: zero(),
29 right: zero(),
30 top: taffy::style::LengthPercentageAuto::Auto,
31 bottom: zero(),
32 },
33 ..Default::default()
34 })
35 .unwrap();
36 let node2 = taffy
37 .new_leaf(taffy::style::Style {
38 size: taffy::geometry::Size {
39 width: taffy::style::Dimension::Length(50f32),
40 height: taffy::style::Dimension::Length(50f32),
41 },
42 ..Default::default()
43 })
44 .unwrap();
45 let node = taffy
46 .new_with_children(
47 taffy::style::Style {
48 flex_direction: taffy::style::FlexDirection::Column,
49 align_items: Some(taffy::style::AlignItems::Center),
50 size: taffy::geometry::Size {
51 width: taffy::style::Dimension::Length(200f32),
52 height: taffy::style::Dimension::Length(200f32),
53 },
54 ..Default::default()
55 },
56 &[node0, node1, node2],
57 )
58 .unwrap();
59 taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
60 println!("\nComputed tree:");
61 taffy::util::print_tree(&taffy, node);
62 println!();
63 let Layout { size, location, .. } = taffy.layout(node).unwrap();
64 assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width);
65 assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height);
66 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
67 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
68 let Layout { size, location, .. } = taffy.layout(node0).unwrap();
69 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width);
70 assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height);
71 assert_eq!(location.x, 75f32, "x of node {:?}. Expected {}. Actual {}", node0, 75f32, location.x);
72 assert_eq!(location.y, 25f32, "y of node {:?}. Expected {}. Actual {}", node0, 25f32, location.y);
73 let Layout { size, location, .. } = taffy.layout(node1).unwrap();
74 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width);
75 assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height);
76 assert_eq!(location.x, 75f32, "x of node {:?}. Expected {}. Actual {}", node1, 75f32, location.x);
77 assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node1, 100f32, location.y);
78 let Layout { size, location, .. } = taffy.layout(node2).unwrap();
79 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width);
80 assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node2, 50f32, size.height);
81 assert_eq!(location.x, 75f32, "x of node {:?}. Expected {}. Actual {}", node2, 75f32, location.x);
82 assert_eq!(location.y, 150f32, "y of node {:?}. Expected {}. Actual {}", node2, 150f32, location.y);
83}