⎇ 568f643327ec6b4879df0087def7f4e66b6acafb
tests/generated/absolute_aspect_ratio_fill_width_from_inset.rs
History
Who touched what
raw
Rename `Points`/`points` to `Length`/`length` in many APIs (#459)
1#[test]
2fn absolute_aspect_ratio_fill_width_from_inset() {
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 aspect_ratio: Some(3f32),
10 inset: taffy::geometry::Rect {
11 left: auto(),
12 right: auto(),
13 top: taffy::style::LengthPercentageAuto::Percent(0.3f32),
14 bottom: taffy::style::LengthPercentageAuto::Percent(0.5f32),
15 },
16 ..Default::default()
17 })
18 .unwrap();
19 let node = taffy
20 .new_with_children(
21 taffy::style::Style {
22 display: taffy::style::Display::Flex,
23 size: taffy::geometry::Size {
24 width: taffy::style::Dimension::Length(400f32),
25 height: taffy::style::Dimension::Length(300f32),
26 },
27 ..Default::default()
28 },
29 &[node0],
30 )
31 .unwrap();
32 taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
33 println!("\nComputed tree:");
34 taffy::util::print_tree(&taffy, node);
35 println!();
36 let Layout { size, location, .. } = taffy.layout(node).unwrap();
37 assert_eq!(size.width, 400f32, "width of node {:?}. Expected {}. Actual {}", node, 400f32, size.width);
38 assert_eq!(size.height, 300f32, "height of node {:?}. Expected {}. Actual {}", node, 300f32, size.height);
39 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
40 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
41 let Layout { size, location, .. } = taffy.layout(node0).unwrap();
42 assert_eq!(size.width, 180f32, "width of node {:?}. Expected {}. Actual {}", node0, 180f32, size.width);
43 assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node0, 60f32, size.height);
44 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
45 assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node0, 90f32, location.y);
46}