⎇ 368b7da13d700e20ed1ef0fa2399fade0ca5ea3f
tests/generated/flex/absolute_minmax_bottom_right_min_max_preferred.rs
Ñawpa willay
Pi imata llamkarqan
ch'uya
Use tagged pointer to represent size/length values (#769)
1#[test]
2#[allow(non_snake_case)]
3fn absolute_minmax_bottom_right_min_max_preferred__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 size: taffy::geometry::Size {
11 width: taffy::style::Dimension::from_length(200f32),
12 height: taffy::style::Dimension::from_length(200f32),
13 },
14 min_size: taffy::geometry::Size {
15 width: taffy::style::Dimension::from_length(50f32),
16 height: taffy::style::Dimension::from_length(60f32),
17 },
18 max_size: taffy::geometry::Size {
19 width: taffy::style::Dimension::from_length(40f32),
20 height: taffy::style::Dimension::from_length(30f32),
21 },
22 inset: taffy::geometry::Rect { left: auto(), right: length(10f32), top: auto(), bottom: length(10f32) },
23 ..Default::default()
24 })
25 .unwrap();
26 let node = taffy
27 .new_with_children(
28 taffy::style::Style {
29 size: taffy::geometry::Size {
30 width: taffy::style::Dimension::from_length(100f32),
31 height: taffy::style::Dimension::from_length(100f32),
32 },
33 ..Default::default()
34 },
35 &[node0],
36 )
37 .unwrap();
38 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
39 println!("\nComputed tree:");
40 taffy.print_tree(node);
41 println!();
42 let layout = taffy.layout(node).unwrap();
43 let Layout { size, location, .. } = layout;
44 assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width);
45 assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height);
46 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
47 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
48 let layout = taffy.layout(node0).unwrap();
49 let Layout { size, location, .. } = layout;
50 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width);
51 assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node0, 60f32, size.height);
52 assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node0, 40f32, location.x);
53 assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node0, 30f32, location.y);
54}
55
56#[test]
57#[allow(non_snake_case)]
58fn absolute_minmax_bottom_right_min_max_preferred__content_box() {
59 #[allow(unused_imports)]
60 use taffy::{prelude::*, Layout};
61 let mut taffy = crate::new_test_tree();
62 let node0 = taffy
63 .new_leaf(taffy::style::Style {
64 box_sizing: taffy::style::BoxSizing::ContentBox,
65 position: taffy::style::Position::Absolute,
66 size: taffy::geometry::Size {
67 width: taffy::style::Dimension::from_length(200f32),
68 height: taffy::style::Dimension::from_length(200f32),
69 },
70 min_size: taffy::geometry::Size {
71 width: taffy::style::Dimension::from_length(50f32),
72 height: taffy::style::Dimension::from_length(60f32),
73 },
74 max_size: taffy::geometry::Size {
75 width: taffy::style::Dimension::from_length(40f32),
76 height: taffy::style::Dimension::from_length(30f32),
77 },
78 inset: taffy::geometry::Rect { left: auto(), right: length(10f32), top: auto(), bottom: length(10f32) },
79 ..Default::default()
80 })
81 .unwrap();
82 let node = taffy
83 .new_with_children(
84 taffy::style::Style {
85 box_sizing: taffy::style::BoxSizing::ContentBox,
86 size: taffy::geometry::Size {
87 width: taffy::style::Dimension::from_length(100f32),
88 height: taffy::style::Dimension::from_length(100f32),
89 },
90 ..Default::default()
91 },
92 &[node0],
93 )
94 .unwrap();
95 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
96 println!("\nComputed tree:");
97 taffy.print_tree(node);
98 println!();
99 let layout = taffy.layout(node).unwrap();
100 let Layout { size, location, .. } = layout;
101 assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width);
102 assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height);
103 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
104 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
105 let layout = taffy.layout(node0).unwrap();
106 let Layout { size, location, .. } = layout;
107 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width);
108 assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node0, 60f32, size.height);
109 assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node0, 40f32, location.x);
110 assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node0, 30f32, location.y);
111}