⎇ 48e4800f14c6af5cd26275fb570d11b93e279654
tests/generated/flex/align_baseline_multiline_column.rs
Historia
Quién tocó qué
crudo
Sort test fixtures and generated tests into folders (#514)
1#[test]
2fn align_baseline_multiline_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 ..Default::default()
13 })
14 .unwrap();
15 let node10 = taffy
16 .new_leaf(taffy::style::Style {
17 size: taffy::geometry::Size {
18 width: taffy::style::Dimension::Length(20f32),
19 height: taffy::style::Dimension::Length(20f32),
20 },
21 ..Default::default()
22 })
23 .unwrap();
24 let node1 = taffy
25 .new_with_children(
26 taffy::style::Style {
27 flex_direction: taffy::style::FlexDirection::Column,
28 size: taffy::geometry::Size {
29 width: taffy::style::Dimension::Length(30f32),
30 height: taffy::style::Dimension::Length(50f32),
31 },
32 ..Default::default()
33 },
34 &[node10],
35 )
36 .unwrap();
37 let node20 = taffy
38 .new_leaf(taffy::style::Style {
39 size: taffy::geometry::Size {
40 width: taffy::style::Dimension::Length(10f32),
41 height: taffy::style::Dimension::Length(10f32),
42 },
43 ..Default::default()
44 })
45 .unwrap();
46 let node2 = taffy
47 .new_with_children(
48 taffy::style::Style {
49 flex_direction: taffy::style::FlexDirection::Column,
50 size: taffy::geometry::Size {
51 width: taffy::style::Dimension::Length(40f32),
52 height: taffy::style::Dimension::Length(70f32),
53 },
54 ..Default::default()
55 },
56 &[node20],
57 )
58 .unwrap();
59 let node3 = taffy
60 .new_leaf(taffy::style::Style {
61 size: taffy::geometry::Size {
62 width: taffy::style::Dimension::Length(50f32),
63 height: taffy::style::Dimension::Length(20f32),
64 },
65 ..Default::default()
66 })
67 .unwrap();
68 let node = taffy
69 .new_with_children(
70 taffy::style::Style {
71 flex_direction: taffy::style::FlexDirection::Column,
72 flex_wrap: taffy::style::FlexWrap::Wrap,
73 align_items: Some(taffy::style::AlignItems::Baseline),
74 size: taffy::geometry::Size {
75 width: taffy::style::Dimension::Length(100f32),
76 height: taffy::style::Dimension::Length(100f32),
77 },
78 ..Default::default()
79 },
80 &[node0, node1, node2, node3],
81 )
82 .unwrap();
83 taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
84 println!("\nComputed tree:");
85 taffy::util::print_tree(&taffy, node);
86 println!();
87 let Layout { size, location, .. } = taffy.layout(node).unwrap();
88 assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width);
89 assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height);
90 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
91 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
92 let Layout { size, location, .. } = taffy.layout(node0).unwrap();
93 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width);
94 assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height);
95 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
96 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y);
97 let Layout { size, location, .. } = taffy.layout(node1).unwrap();
98 assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node1, 30f32, size.width);
99 assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height);
100 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x);
101 assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node1, 50f32, location.y);
102 let Layout { size, location, .. } = taffy.layout(node10).unwrap();
103 assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node10, 20f32, size.width);
104 assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node10, 20f32, size.height);
105 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x);
106 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y);
107 let Layout { size, location, .. } = taffy.layout(node2).unwrap();
108 assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width);
109 assert_eq!(size.height, 70f32, "height of node {:?}. Expected {}. Actual {}", node2, 70f32, size.height);
110 assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node2, 50f32, location.x);
111 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y);
112 let Layout { size, location, .. } = taffy.layout(node20).unwrap();
113 assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node20, 10f32, size.width);
114 assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node20, 10f32, size.height);
115 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node20, 0f32, location.x);
116 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node20, 0f32, location.y);
117 let Layout { size, location, .. } = taffy.layout(node3).unwrap();
118 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node3, 50f32, size.width);
119 assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node3, 20f32, size.height);
120 assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node3, 50f32, location.x);
121 assert_eq!(location.y, 70f32, "y of node {:?}. Expected {}. Actual {}", node3, 70f32, location.y);
122}