1#[test]
2fn align_self_baseline() {
3 let mut taffy = taffy::Taffy::new();
4 let node0 = taffy
5 .new_node(
6 taffy::style::Style {
7 align_self: taffy::style::AlignSelf::Baseline,
8 size: taffy::geometry::Size {
9 width: taffy::style::Dimension::Points(50f32),
10 height: taffy::style::Dimension::Points(50f32),
11 ..Default::default()
12 },
13 ..Default::default()
14 },
15 &[],
16 )
17 .unwrap();
18 let node10 = taffy
19 .new_node(
20 taffy::style::Style {
21 size: taffy::geometry::Size {
22 width: taffy::style::Dimension::Points(50f32),
23 height: taffy::style::Dimension::Points(10f32),
24 ..Default::default()
25 },
26 ..Default::default()
27 },
28 &[],
29 )
30 .unwrap();
31 let node1 = taffy
32 .new_node(
33 taffy::style::Style {
34 align_self: taffy::style::AlignSelf::Baseline,
35 size: taffy::geometry::Size {
36 width: taffy::style::Dimension::Points(50f32),
37 height: taffy::style::Dimension::Points(20f32),
38 ..Default::default()
39 },
40 ..Default::default()
41 },
42 &[node10],
43 )
44 .unwrap();
45 let node = taffy
46 .new_node(
47 taffy::style::Style {
48 size: taffy::geometry::Size {
49 width: taffy::style::Dimension::Points(100f32),
50 height: taffy::style::Dimension::Points(100f32),
51 ..Default::default()
52 },
53 ..Default::default()
54 },
55 &[node0, node1],
56 )
57 .unwrap();
58 taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap();
59 assert_eq!(taffy.layout(node).unwrap().size.width, 100f32);
60 assert_eq!(taffy.layout(node).unwrap().size.height, 100f32);
61 assert_eq!(taffy.layout(node).unwrap().location.x, 0f32);
62 assert_eq!(taffy.layout(node).unwrap().location.y, 0f32);
63 assert_eq!(taffy.layout(node0).unwrap().size.width, 50f32);
64 assert_eq!(taffy.layout(node0).unwrap().size.height, 50f32);
65 assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32);
66 assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32);
67 assert_eq!(taffy.layout(node1).unwrap().size.width, 50f32);
68 assert_eq!(taffy.layout(node1).unwrap().size.height, 20f32);
69 assert_eq!(taffy.layout(node1).unwrap().location.x, 50f32);
70 assert_eq!(taffy.layout(node1).unwrap().location.y, 40f32);
71 assert_eq!(taffy.layout(node10).unwrap().size.width, 50f32);
72 assert_eq!(taffy.layout(node10).unwrap().size.height, 10f32);
73 assert_eq!(taffy.layout(node10).unwrap().location.x, 0f32);
74 assert_eq!(taffy.layout(node10).unwrap().location.y, 0f32);
75}