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