⎇ f99b57fbad456aa2756b374ff40c876e4b9574c2
tests/generated/flex/flex_grow_within_constrained_max_column.rs
History
Who touched what
raw
Use tagged pointer to represent size/length values (#769)
1#[test]
2#[allow(non_snake_case)]
3fn flex_grow_within_constrained_max_column__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 flex_shrink: 1f32,
10 flex_basis: taffy::style::Dimension::from_length(100f32),
11 ..Default::default()
12 })
13 .unwrap();
14 let node1 = taffy
15 .new_leaf(taffy::style::Style {
16 size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(50f32) },
17 ..Default::default()
18 })
19 .unwrap();
20 let node = taffy
21 .new_with_children(
22 taffy::style::Style {
23 flex_direction: taffy::style::FlexDirection::Column,
24 size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() },
25 max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(100f32) },
26 ..Default::default()
27 },
28 &[node0, node1],
29 )
30 .unwrap();
31 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
32 println!("\nComputed tree:");
33 taffy.print_tree(node);
34 println!();
35 let layout = taffy.layout(node).unwrap();
36 let Layout { size, location, .. } = layout;
37 assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width);
38 assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height);
39 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
40 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
41 let layout = taffy.layout(node0).unwrap();
42 let Layout { size, location, .. } = layout;
43 assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width);
44 assert_eq!(size.height, 67f32, "height of node {:?}. Expected {}. Actual {}", node0, 67f32, size.height);
45 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
46 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y);
47 let layout = taffy.layout(node1).unwrap();
48 let Layout { size, location, .. } = layout;
49 assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width);
50 assert_eq!(size.height, 33f32, "height of node {:?}. Expected {}. Actual {}", node1, 33f32, size.height);
51 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x);
52 assert_eq!(location.y, 67f32, "y of node {:?}. Expected {}. Actual {}", node1, 67f32, location.y);
53}
54
55#[test]
56#[allow(non_snake_case)]
57fn flex_grow_within_constrained_max_column__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 flex_shrink: 1f32,
65 flex_basis: taffy::style::Dimension::from_length(100f32),
66 ..Default::default()
67 })
68 .unwrap();
69 let node1 = taffy
70 .new_leaf(taffy::style::Style {
71 box_sizing: taffy::style::BoxSizing::ContentBox,
72 size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(50f32) },
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 flex_direction: taffy::style::FlexDirection::Column,
81 size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() },
82 max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(100f32) },
83 ..Default::default()
84 },
85 &[node0, node1],
86 )
87 .unwrap();
88 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
89 println!("\nComputed tree:");
90 taffy.print_tree(node);
91 println!();
92 let layout = taffy.layout(node).unwrap();
93 let Layout { size, location, .. } = layout;
94 assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width);
95 assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height);
96 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
97 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
98 let layout = taffy.layout(node0).unwrap();
99 let Layout { size, location, .. } = layout;
100 assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width);
101 assert_eq!(size.height, 67f32, "height of node {:?}. Expected {}. Actual {}", node0, 67f32, size.height);
102 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
103 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y);
104 let layout = taffy.layout(node1).unwrap();
105 let Layout { size, location, .. } = layout;
106 assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width);
107 assert_eq!(size.height, 33f32, "height of node {:?}. Expected {}. Actual {}", node1, 33f32, size.height);
108 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x);
109 assert_eq!(location.y, 67f32, "y of node {:?}. Expected {}. Actual {}", node1, 67f32, location.y);
110}