⎇ 48e4800f14c6af5cd26275fb570d11b93e279654
tests/generated/flex/absolute_layout_align_items_center.rs
History
Who touched what
raw
Sort test fixtures and generated tests into folders (#514)
1#[test]
2fn absolute_layout_align_items_center() {
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 position: taffy::style::Position::Absolute,
9 size: taffy::geometry::Size {
10 width: taffy::style::Dimension::Length(60f32),
11 height: taffy::style::Dimension::Length(40f32),
12 },
13 ..Default::default()
14 })
15 .unwrap();
16 let node = taffy
17 .new_with_children(
18 taffy::style::Style {
19 align_items: Some(taffy::style::AlignItems::Center),
20 size: taffy::geometry::Size {
21 width: taffy::style::Dimension::Length(110f32),
22 height: taffy::style::Dimension::Length(100f32),
23 },
24 ..Default::default()
25 },
26 &[node0],
27 )
28 .unwrap();
29 taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
30 println!("\nComputed tree:");
31 taffy::util::print_tree(&taffy, node);
32 println!();
33 let Layout { size, location, .. } = taffy.layout(node).unwrap();
34 assert_eq!(size.width, 110f32, "width of node {:?}. Expected {}. Actual {}", node, 110f32, size.width);
35 assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height);
36 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
37 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
38 let Layout { size, location, .. } = taffy.layout(node0).unwrap();
39 assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node0, 60f32, size.width);
40 assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height);
41 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
42 assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node0, 30f32, location.y);
43}