⎇ 40dd6120fc73aa866f30e52a51d1abaf39adce6f
tests/generated/flex/absolute_margin_bottom_left.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_margin_bottom_left__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(10f32),
12 height: taffy::style::Dimension::from_length(10f32),
13 },
14 margin: taffy::geometry::Rect { left: length(10f32), right: zero(), top: zero(), bottom: length(10f32) },
15 ..Default::default()
16 })
17 .unwrap();
18 let node = taffy
19 .new_with_children(
20 taffy::style::Style {
21 flex_direction: taffy::style::FlexDirection::Column,
22 justify_content: Some(taffy::style::JustifyContent::FlexEnd),
23 size: taffy::geometry::Size {
24 width: taffy::style::Dimension::from_length(100f32),
25 height: taffy::style::Dimension::from_length(100f32),
26 },
27 ..Default::default()
28 },
29 &[node0],
30 )
31 .unwrap();
32 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
33 println!("\nComputed tree:");
34 taffy.print_tree(node);
35 println!();
36 let layout = taffy.layout(node).unwrap();
37 let Layout { size, location, .. } = layout;
38 assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width);
39 assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height);
40 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
41 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
42 let layout = taffy.layout(node0).unwrap();
43 let Layout { size, location, .. } = layout;
44 assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width);
45 assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height);
46 assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0, 10f32, location.x);
47 assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node0, 80f32, location.y);
48}
49
50#[test]
51#[allow(non_snake_case)]
52fn absolute_margin_bottom_left__content_box() {
53 #[allow(unused_imports)]
54 use taffy::{prelude::*, Layout};
55 let mut taffy = crate::new_test_tree();
56 let node0 = taffy
57 .new_leaf(taffy::style::Style {
58 box_sizing: taffy::style::BoxSizing::ContentBox,
59 position: taffy::style::Position::Absolute,
60 size: taffy::geometry::Size {
61 width: taffy::style::Dimension::from_length(10f32),
62 height: taffy::style::Dimension::from_length(10f32),
63 },
64 margin: taffy::geometry::Rect { left: length(10f32), right: zero(), top: zero(), bottom: length(10f32) },
65 ..Default::default()
66 })
67 .unwrap();
68 let node = taffy
69 .new_with_children(
70 taffy::style::Style {
71 box_sizing: taffy::style::BoxSizing::ContentBox,
72 flex_direction: taffy::style::FlexDirection::Column,
73 justify_content: Some(taffy::style::JustifyContent::FlexEnd),
74 size: taffy::geometry::Size {
75 width: taffy::style::Dimension::from_length(100f32),
76 height: taffy::style::Dimension::from_length(100f32),
77 },
78 ..Default::default()
79 },
80 &[node0],
81 )
82 .unwrap();
83 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
84 println!("\nComputed tree:");
85 taffy.print_tree(node);
86 println!();
87 let layout = taffy.layout(node).unwrap();
88 let Layout { size, location, .. } = layout;
89 assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width);
90 assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height);
91 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
92 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
93 let layout = taffy.layout(node0).unwrap();
94 let Layout { size, location, .. } = layout;
95 assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width);
96 assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height);
97 assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0, 10f32, location.x);
98 assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node0, 80f32, location.y);
99}