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