⎇ float-layout
tests/generated/block/block_absolute_margin_auto_bottom_with_inset.rs
Historia
Quién tocó qué
crudo
Use tagged pointer to represent size/length values (#769)
1#[test]
2#[allow(non_snake_case)]
3fn block_absolute_margin_auto_bottom_with_inset__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(50f32),
12 height: taffy::style::Dimension::from_length(50f32),
13 },
14 margin: taffy::geometry::Rect {
15 left: zero(),
16 right: zero(),
17 top: zero(),
18 bottom: taffy::style::LengthPercentageAuto::AUTO,
19 },
20 inset: taffy::geometry::Rect { left: auto(), right: auto(), top: length(10f32), bottom: length(20f32) },
21 ..Default::default()
22 })
23 .unwrap();
24 let node = taffy
25 .new_with_children(
26 taffy::style::Style {
27 display: taffy::style::Display::Block,
28 align_items: Some(taffy::style::AlignItems::Center),
29 size: taffy::geometry::Size {
30 width: taffy::style::Dimension::from_length(200f32),
31 height: taffy::style::Dimension::from_length(200f32),
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, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width);
45 assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, 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, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height);
52 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
53 assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y);
54}
55
56#[test]
57#[allow(non_snake_case)]
58fn block_absolute_margin_auto_bottom_with_inset__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(50f32),
68 height: taffy::style::Dimension::from_length(50f32),
69 },
70 margin: taffy::geometry::Rect {
71 left: zero(),
72 right: zero(),
73 top: zero(),
74 bottom: taffy::style::LengthPercentageAuto::AUTO,
75 },
76 inset: taffy::geometry::Rect { left: auto(), right: auto(), top: length(10f32), bottom: length(20f32) },
77 ..Default::default()
78 })
79 .unwrap();
80 let node = taffy
81 .new_with_children(
82 taffy::style::Style {
83 display: taffy::style::Display::Block,
84 box_sizing: taffy::style::BoxSizing::ContentBox,
85 align_items: Some(taffy::style::AlignItems::Center),
86 size: taffy::geometry::Size {
87 width: taffy::style::Dimension::from_length(200f32),
88 height: taffy::style::Dimension::from_length(200f32),
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, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width);
102 assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, 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, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height);
109 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
110 assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y);
111}