⎇ f99b57fbad456aa2756b374ff40c876e4b9574c2
tests/generated/grid/grid_percent_items_nested_inside_stretch_alignment.rs
History
Who touched what
raw
Use tagged pointer to represent size/length values (#769)
1#[test]
2#[allow(non_snake_case)]
3fn grid_percent_items_nested_inside_stretch_alignment__border_box() {
4 #[allow(unused_imports)]
5 use taffy::{prelude::*, Layout};
6 let mut taffy = crate::new_test_tree();
7 let node00 = taffy
8 .new_leaf(taffy::style::Style {
9 display: taffy::style::Display::Grid,
10 padding: taffy::geometry::Rect { left: zero(), right: zero(), top: percent(0.2f32), bottom: zero() },
11 ..Default::default()
12 })
13 .unwrap();
14 let node0 = taffy
15 .new_with_children(
16 taffy::style::Style { display: taffy::style::Display::Grid, ..Default::default() },
17 &[node00],
18 )
19 .unwrap();
20 let node = taffy
21 .new_with_children(
22 taffy::style::Style {
23 display: taffy::style::Display::Grid,
24 size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: auto() },
25 ..Default::default()
26 },
27 &[node0],
28 )
29 .unwrap();
30 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
31 println!("\nComputed tree:");
32 taffy.print_tree(node);
33 println!();
34 let layout = taffy.layout(node).unwrap();
35 let Layout { size, location, .. } = layout;
36 assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width);
37 assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height);
38 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
39 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
40 let layout = taffy.layout(node0).unwrap();
41 let Layout { size, location, .. } = layout;
42 assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width);
43 assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height);
44 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
45 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y);
46 let layout = taffy.layout(node00).unwrap();
47 let Layout { size, location, .. } = layout;
48 assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node00, 200f32, size.width);
49 assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node00, 40f32, size.height);
50 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x);
51 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y);
52}
53
54#[test]
55#[allow(non_snake_case)]
56fn grid_percent_items_nested_inside_stretch_alignment__content_box() {
57 #[allow(unused_imports)]
58 use taffy::{prelude::*, Layout};
59 let mut taffy = crate::new_test_tree();
60 let node00 = taffy
61 .new_leaf(taffy::style::Style {
62 display: taffy::style::Display::Grid,
63 box_sizing: taffy::style::BoxSizing::ContentBox,
64 padding: taffy::geometry::Rect { left: zero(), right: zero(), top: percent(0.2f32), bottom: zero() },
65 ..Default::default()
66 })
67 .unwrap();
68 let node0 = taffy
69 .new_with_children(
70 taffy::style::Style {
71 display: taffy::style::Display::Grid,
72 box_sizing: taffy::style::BoxSizing::ContentBox,
73 ..Default::default()
74 },
75 &[node00],
76 )
77 .unwrap();
78 let node = taffy
79 .new_with_children(
80 taffy::style::Style {
81 display: taffy::style::Display::Grid,
82 box_sizing: taffy::style::BoxSizing::ContentBox,
83 size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: auto() },
84 ..Default::default()
85 },
86 &[node0],
87 )
88 .unwrap();
89 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
90 println!("\nComputed tree:");
91 taffy.print_tree(node);
92 println!();
93 let layout = taffy.layout(node).unwrap();
94 let Layout { size, location, .. } = layout;
95 assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width);
96 assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height);
97 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
98 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
99 let layout = taffy.layout(node0).unwrap();
100 let Layout { size, location, .. } = layout;
101 assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width);
102 assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height);
103 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
104 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y);
105 let layout = taffy.layout(node00).unwrap();
106 let Layout { size, location, .. } = layout;
107 assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node00, 200f32, size.width);
108 assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node00, 40f32, size.height);
109 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x);
110 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y);
111}