⎇ 477ff4aff498cbae4cdfbf0cda1ee5b04c784f08
tests/generated/flex/absolute_minmax_bottom_right_min_max_preferred.rs
Ñawpa willay
Pi imata llamkarqan
ch'uya
Rename Taffy struct to TaffyTree (#580)
1#[test]
2fn absolute_minmax_bottom_right_min_max_preferred() {
3 #[allow(unused_imports)]
4 use taffy::{prelude::*, tree::Layout, TaffyTree};
5 let mut taffy: TaffyTree<crate::TextMeasure> = TaffyTree::new();
6 let node0 = taffy
7 .new_leaf(taffy::style::Style {
8 position: taffy::style::Position::Absolute,
9 size: taffy::geometry::Size {
10 width: taffy::style::Dimension::Length(200f32),
11 height: taffy::style::Dimension::Length(200f32),
12 },
13 min_size: taffy::geometry::Size {
14 width: taffy::style::Dimension::Length(50f32),
15 height: taffy::style::Dimension::Length(60f32),
16 },
17 max_size: taffy::geometry::Size {
18 width: taffy::style::Dimension::Length(40f32),
19 height: taffy::style::Dimension::Length(30f32),
20 },
21 inset: taffy::geometry::Rect {
22 left: auto(),
23 right: taffy::style::LengthPercentageAuto::Length(10f32),
24 top: auto(),
25 bottom: taffy::style::LengthPercentageAuto::Length(10f32),
26 },
27 ..Default::default()
28 })
29 .unwrap();
30 let node = taffy
31 .new_with_children(
32 taffy::style::Style {
33 size: taffy::geometry::Size {
34 width: taffy::style::Dimension::Length(100f32),
35 height: taffy::style::Dimension::Length(100f32),
36 },
37 ..Default::default()
38 },
39 &[node0],
40 )
41 .unwrap();
42 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
43 println!("\nComputed tree:");
44 taffy.print_tree(node);
45 println!();
46 #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
47 let layout @ Layout { size, location, .. } = taffy.layout(node).unwrap();
48 assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width);
49 assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height);
50 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
51 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
52 #[cfg(feature = "content_size")]
53 assert_eq!(
54 layout.scroll_width(),
55 0f32,
56 "scroll_width of node {:?}. Expected {}. Actual {}",
57 node,
58 0f32,
59 layout.scroll_width()
60 );
61 #[cfg(feature = "content_size")]
62 assert_eq!(
63 layout.scroll_height(),
64 0f32,
65 "scroll_height of node {:?}. Expected {}. Actual {}",
66 node,
67 0f32,
68 layout.scroll_height()
69 );
70 #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
71 let layout @ Layout { size, location, .. } = taffy.layout(node0).unwrap();
72 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width);
73 assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node0, 60f32, size.height);
74 assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node0, 40f32, location.x);
75 assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node0, 30f32, location.y);
76 #[cfg(feature = "content_size")]
77 assert_eq!(
78 layout.scroll_width(),
79 0f32,
80 "scroll_width of node {:?}. Expected {}. Actual {}",
81 node0,
82 0f32,
83 layout.scroll_width()
84 );
85 #[cfg(feature = "content_size")]
86 assert_eq!(
87 layout.scroll_height(),
88 0f32,
89 "scroll_height of node {:?}. Expected {}. Actual {}",
90 node0,
91 0f32,
92 layout.scroll_height()
93 );
94}