⎇ 568f643327ec6b4879df0087def7f4e66b6acafb
tests/generated/grid_percent_items_nested_inside_stretch_alignment.rs
Ñawpa willay
Pi imata llamkarqan
ch'uya
Rename `Points`/`points` to `Length`/`length` in many APIs (#459)
1#[test]
2fn grid_percent_items_nested_inside_stretch_alignment() {
3 #[allow(unused_imports)]
4 use taffy::{prelude::*, tree::Layout};
5 let mut taffy = taffy::Taffy::new();
6 let node00 = taffy
7 .new_leaf(taffy::style::Style {
8 display: taffy::style::Display::Grid,
9 padding: taffy::geometry::Rect {
10 left: zero(),
11 right: zero(),
12 top: taffy::style::LengthPercentage::Percent(0.2f32),
13 bottom: zero(),
14 },
15 ..Default::default()
16 })
17 .unwrap();
18 let node0 = taffy
19 .new_with_children(
20 taffy::style::Style { display: taffy::style::Display::Grid, ..Default::default() },
21 &[node00],
22 )
23 .unwrap();
24 let node = taffy
25 .new_with_children(
26 taffy::style::Style {
27 display: taffy::style::Display::Grid,
28 size: taffy::geometry::Size { width: taffy::style::Dimension::Length(200f32), height: auto() },
29 ..Default::default()
30 },
31 &[node0],
32 )
33 .unwrap();
34 taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
35 println!("\nComputed tree:");
36 taffy::util::print_tree(&taffy, node);
37 println!();
38 let Layout { size, location, .. } = taffy.layout(node).unwrap();
39 assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width);
40 assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height);
41 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
42 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
43 let Layout { size, location, .. } = taffy.layout(node0).unwrap();
44 assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width);
45 assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height);
46 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
47 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y);
48 let Layout { size, location, .. } = taffy.layout(node00).unwrap();
49 assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node00, 200f32, size.width);
50 assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node00, 40f32, size.height);
51 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x);
52 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y);
53}