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