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