⎇ float-layout
tests/generated/flex/absolute_aspect_ratio_fill_min_height.rs
Historia
Quién tocó qué
crudo
Use tagged pointer to represent size/length values (#769)
1#[test]
2#[allow(non_snake_case)]
3fn absolute_aspect_ratio_fill_min_height__border_box() {
4 #[allow(unused_imports)]
5 use taffy::{prelude::*, Layout};
6 let mut taffy = crate::new_test_tree();
7 let node0 = taffy
8 .new_leaf(taffy::style::Style {
9 position: taffy::style::Position::Absolute,
10 min_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() },
11 aspect_ratio: Some(3f32),
12 ..Default::default()
13 })
14 .unwrap();
15 let node = taffy
16 .new_with_children(
17 taffy::style::Style {
18 display: taffy::style::Display::Flex,
19 size: taffy::geometry::Size {
20 width: taffy::style::Dimension::from_length(400f32),
21 height: taffy::style::Dimension::from_length(300f32),
22 },
23 ..Default::default()
24 },
25 &[node0],
26 )
27 .unwrap();
28 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
29 println!("\nComputed tree:");
30 taffy.print_tree(node);
31 println!();
32 let layout = taffy.layout(node).unwrap();
33 let Layout { size, location, .. } = layout;
34 assert_eq!(size.width, 400f32, "width of node {:?}. Expected {}. Actual {}", node, 400f32, size.width);
35 assert_eq!(size.height, 300f32, "height of node {:?}. Expected {}. Actual {}", node, 300f32, size.height);
36 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
37 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
38 let layout = taffy.layout(node0).unwrap();
39 let Layout { size, location, .. } = layout;
40 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width);
41 assert_eq!(size.height, 17f32, "height of node {:?}. Expected {}. Actual {}", node0, 17f32, size.height);
42 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
43 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y);
44}
45
46#[test]
47#[allow(non_snake_case)]
48fn absolute_aspect_ratio_fill_min_height__content_box() {
49 #[allow(unused_imports)]
50 use taffy::{prelude::*, Layout};
51 let mut taffy = crate::new_test_tree();
52 let node0 = taffy
53 .new_leaf(taffy::style::Style {
54 box_sizing: taffy::style::BoxSizing::ContentBox,
55 position: taffy::style::Position::Absolute,
56 min_size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() },
57 aspect_ratio: Some(3f32),
58 ..Default::default()
59 })
60 .unwrap();
61 let node = taffy
62 .new_with_children(
63 taffy::style::Style {
64 display: taffy::style::Display::Flex,
65 box_sizing: taffy::style::BoxSizing::ContentBox,
66 size: taffy::geometry::Size {
67 width: taffy::style::Dimension::from_length(400f32),
68 height: taffy::style::Dimension::from_length(300f32),
69 },
70 ..Default::default()
71 },
72 &[node0],
73 )
74 .unwrap();
75 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
76 println!("\nComputed tree:");
77 taffy.print_tree(node);
78 println!();
79 let layout = taffy.layout(node).unwrap();
80 let Layout { size, location, .. } = layout;
81 assert_eq!(size.width, 400f32, "width of node {:?}. Expected {}. Actual {}", node, 400f32, size.width);
82 assert_eq!(size.height, 300f32, "height of node {:?}. Expected {}. Actual {}", node, 300f32, size.height);
83 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
84 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
85 let layout = taffy.layout(node0).unwrap();
86 let Layout { size, location, .. } = layout;
87 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width);
88 assert_eq!(size.height, 17f32, "height of node {:?}. Expected {}. Actual {}", node0, 17f32, size.height);
89 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
90 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y);
91}