⎇ 568f643327ec6b4879df0087def7f4e66b6acafb
tests/generated/min_height.rs
Ñawpa willay
Pi imata llamkarqan
ch'uya
Rename `Points`/`points` to `Length`/`length` in many APIs (#459)
1#[test]
2fn min_height() {
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 flex_grow: 1f32,
9 min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(60f32) },
10 ..Default::default()
11 })
12 .unwrap();
13 let node1 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }).unwrap();
14 let node = taffy
15 .new_with_children(
16 taffy::style::Style {
17 flex_direction: taffy::style::FlexDirection::Column,
18 size: taffy::geometry::Size {
19 width: taffy::style::Dimension::Length(100f32),
20 height: taffy::style::Dimension::Length(100f32),
21 },
22 ..Default::default()
23 },
24 &[node0, node1],
25 )
26 .unwrap();
27 taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
28 println!("\nComputed tree:");
29 taffy::util::print_tree(&taffy, node);
30 println!();
31 let Layout { size, location, .. } = taffy.layout(node).unwrap();
32 assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width);
33 assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height);
34 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
35 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
36 let Layout { size, location, .. } = taffy.layout(node0).unwrap();
37 assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width);
38 assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node0, 60f32, size.height);
39 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
40 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y);
41 let Layout { size, location, .. } = taffy.layout(node1).unwrap();
42 assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width);
43 assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height);
44 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x);
45 assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node1, 60f32, location.y);
46}