⎇ b91874d4e34ecc9054b468a338ffcae6f61a1b4a
tests/generated/align_baseline_child_multiline_no_override_on_secondline.rs
Historia
Quién tocó qué
crudo
Fix flexbox baseline alignment (#325)
1#[test]
2fn align_baseline_child_multiline_no_override_on_secondline() {
3 use slotmap::Key;
4 #[allow(unused_imports)]
5 use taffy::{layout::Layout, prelude::*};
6 let mut taffy = taffy::Taffy::new();
7 let node0 = taffy
8 .new_leaf(taffy::style::Style {
9 size: taffy::geometry::Size {
10 width: taffy::style::Dimension::Points(50f32),
11 height: taffy::style::Dimension::Points(60f32),
12 },
13 ..Default::default()
14 })
15 .unwrap();
16 let node10 = taffy
17 .new_leaf(taffy::style::Style {
18 size: taffy::geometry::Size {
19 width: taffy::style::Dimension::Points(25f32),
20 height: taffy::style::Dimension::Points(20f32),
21 },
22 ..Default::default()
23 })
24 .unwrap();
25 let node11 = taffy
26 .new_leaf(taffy::style::Style {
27 size: taffy::geometry::Size {
28 width: taffy::style::Dimension::Points(25f32),
29 height: taffy::style::Dimension::Points(10f32),
30 },
31 ..Default::default()
32 })
33 .unwrap();
34 let node12 = taffy
35 .new_leaf(taffy::style::Style {
36 size: taffy::geometry::Size {
37 width: taffy::style::Dimension::Points(25f32),
38 height: taffy::style::Dimension::Points(20f32),
39 },
40 ..Default::default()
41 })
42 .unwrap();
43 let node13 = taffy
44 .new_leaf(taffy::style::Style {
45 align_self: Some(taffy::style::AlignSelf::Baseline),
46 size: taffy::geometry::Size {
47 width: taffy::style::Dimension::Points(25f32),
48 height: taffy::style::Dimension::Points(10f32),
49 },
50 ..Default::default()
51 })
52 .unwrap();
53 let node1 = taffy
54 .new_with_children(
55 taffy::style::Style {
56 flex_wrap: taffy::style::FlexWrap::Wrap,
57 size: taffy::geometry::Size {
58 width: taffy::style::Dimension::Points(50f32),
59 height: taffy::style::Dimension::Points(25f32),
60 },
61 ..Default::default()
62 },
63 &[node10, node11, node12, node13],
64 )
65 .unwrap();
66 let node = taffy
67 .new_with_children(
68 taffy::style::Style {
69 align_items: Some(taffy::style::AlignItems::Baseline),
70 size: taffy::geometry::Size {
71 width: taffy::style::Dimension::Points(100f32),
72 height: taffy::style::Dimension::Points(100f32),
73 },
74 ..Default::default()
75 },
76 &[node0, node1],
77 )
78 .unwrap();
79 taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
80 println!("\nComputed tree:");
81 taffy::debug::print_tree(&taffy, node);
82 println!();
83 let Layout { size, location, .. } = taffy.layout(node).unwrap();
84 assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node.data(), 100f32, size.width);
85 assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node.data(), 100f32, size.height);
86 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.x);
87 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.y);
88 let Layout { size, location, .. } = taffy.layout(node0).unwrap();
89 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0.data(), 50f32, size.width);
90 assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node0.data(), 60f32, size.height);
91 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.x);
92 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.y);
93 let Layout { size, location, .. } = taffy.layout(node1).unwrap();
94 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1.data(), 50f32, size.width);
95 assert_eq!(size.height, 25f32, "height of node {:?}. Expected {}. Actual {}", node1.data(), 25f32, size.height);
96 assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1.data(), 50f32, location.x);
97 assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node1.data(), 40f32, location.y);
98 let Layout { size, location, .. } = taffy.layout(node10).unwrap();
99 assert_eq!(size.width, 25f32, "width of node {:?}. Expected {}. Actual {}", node10.data(), 25f32, size.width);
100 assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node10.data(), 20f32, size.height);
101 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10.data(), 0f32, location.x);
102 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10.data(), 0f32, location.y);
103 let Layout { size, location, .. } = taffy.layout(node11).unwrap();
104 assert_eq!(size.width, 25f32, "width of node {:?}. Expected {}. Actual {}", node11.data(), 25f32, size.width);
105 assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node11.data(), 10f32, size.height);
106 assert_eq!(location.x, 25f32, "x of node {:?}. Expected {}. Actual {}", node11.data(), 25f32, location.x);
107 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node11.data(), 0f32, location.y);
108 let Layout { size, location, .. } = taffy.layout(node12).unwrap();
109 assert_eq!(size.width, 25f32, "width of node {:?}. Expected {}. Actual {}", node12.data(), 25f32, size.width);
110 assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node12.data(), 20f32, size.height);
111 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node12.data(), 0f32, location.x);
112 assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node12.data(), 20f32, location.y);
113 let Layout { size, location, .. } = taffy.layout(node13).unwrap();
114 assert_eq!(size.width, 25f32, "width of node {:?}. Expected {}. Actual {}", node13.data(), 25f32, size.width);
115 assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node13.data(), 10f32, size.height);
116 assert_eq!(location.x, 25f32, "x of node {:?}. Expected {}. Actual {}", node13.data(), 25f32, location.x);
117 assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node13.data(), 20f32, location.y);
118}