⎇ 568f643327ec6b4879df0087def7f4e66b6acafb
tests/generated/absolute_child_with_max_height.rs
Historia
Quién tocó qué
crudo
Rename `Points`/`points` to `Length`/`length` in many APIs (#459)
1#[test]
2fn absolute_child_with_max_height() {
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 size: taffy::geometry::Size {
9 width: taffy::style::Dimension::Length(100f32),
10 height: taffy::style::Dimension::Length(30f32),
11 },
12 ..Default::default()
13 })
14 .unwrap();
15 let node0 = taffy
16 .new_with_children(
17 taffy::style::Style {
18 position: taffy::style::Position::Absolute,
19 flex_direction: taffy::style::FlexDirection::Column,
20 max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(100f32) },
21 inset: taffy::geometry::Rect {
22 left: auto(),
23 right: auto(),
24 top: auto(),
25 bottom: taffy::style::LengthPercentageAuto::Length(20f32),
26 },
27 ..Default::default()
28 },
29 &[node00],
30 )
31 .unwrap();
32 let node = taffy
33 .new_with_children(
34 taffy::style::Style {
35 flex_direction: taffy::style::FlexDirection::Column,
36 size: taffy::geometry::Size {
37 width: taffy::style::Dimension::Length(100f32),
38 height: taffy::style::Dimension::Length(200f32),
39 },
40 ..Default::default()
41 },
42 &[node0],
43 )
44 .unwrap();
45 taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
46 println!("\nComputed tree:");
47 taffy::util::print_tree(&taffy, node);
48 println!();
49 let Layout { size, location, .. } = taffy.layout(node).unwrap();
50 assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width);
51 assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height);
52 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
53 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
54 let Layout { size, location, .. } = taffy.layout(node0).unwrap();
55 assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width);
56 assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node0, 30f32, size.height);
57 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
58 assert_eq!(location.y, 150f32, "y of node {:?}. Expected {}. Actual {}", node0, 150f32, location.y);
59 let Layout { size, location, .. } = taffy.layout(node00).unwrap();
60 assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node00, 100f32, size.width);
61 assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node00, 30f32, size.height);
62 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x);
63 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y);
64}