⎇ 48e4800f14c6af5cd26275fb570d11b93e279654
tests/generated/flex/align_baseline.rs
History
Who touched what
raw
Sort test fixtures and generated tests into folders (#514)
1#[test]
2fn align_baseline() {
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 node1 = taffy
16 .new_leaf(taffy::style::Style {
17 size: taffy::geometry::Size {
18 width: taffy::style::Dimension::Length(50f32),
19 height: taffy::style::Dimension::Length(20f32),
20 },
21 ..Default::default()
22 })
23 .unwrap();
24 let node = taffy
25 .new_with_children(
26 taffy::style::Style {
27 align_items: Some(taffy::style::AlignItems::Baseline),
28 size: taffy::geometry::Size {
29 width: taffy::style::Dimension::Length(100f32),
30 height: taffy::style::Dimension::Length(100f32),
31 },
32 ..Default::default()
33 },
34 &[node0, node1],
35 )
36 .unwrap();
37 taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
38 println!("\nComputed tree:");
39 taffy::util::print_tree(&taffy, node);
40 println!();
41 let Layout { size, location, .. } = taffy.layout(node).unwrap();
42 assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width);
43 assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height);
44 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
45 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
46 let Layout { size, location, .. } = taffy.layout(node0).unwrap();
47 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width);
48 assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height);
49 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
50 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y);
51 let Layout { size, location, .. } = taffy.layout(node1).unwrap();
52 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width);
53 assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height);
54 assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x);
55 assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node1, 30f32, location.y);
56}