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