1#[test]
2fn flex_grow_within_constrained_max_width() {
3 let mut taffy = taffy::Taffy::new();
4 let node00 = taffy
5 .new_node(
6 taffy::style::Style {
7 flex_grow: 1f32,
8 size: taffy::geometry::Size { height: taffy::style::Dimension::Points(20f32), ..Default::default() },
9 ..Default::default()
10 },
11 &[],
12 )
13 .unwrap();
14 let node0 = taffy
15 .new_node(
16 taffy::style::Style {
17 max_size: taffy::geometry::Size {
18 width: taffy::style::Dimension::Points(300f32),
19 ..Default::default()
20 },
21 ..Default::default()
22 },
23 &[node00],
24 )
25 .unwrap();
26 let node = taffy
27 .new_node(
28 taffy::style::Style {
29 flex_direction: taffy::style::FlexDirection::Column,
30 size: taffy::geometry::Size {
31 width: taffy::style::Dimension::Points(200f32),
32 height: taffy::style::Dimension::Points(100f32),
33 ..Default::default()
34 },
35 ..Default::default()
36 },
37 &[node0],
38 )
39 .unwrap();
40 taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap();
41 assert_eq!(taffy.layout(node).unwrap().size.width, 200f32);
42 assert_eq!(taffy.layout(node).unwrap().size.height, 100f32);
43 assert_eq!(taffy.layout(node).unwrap().location.x, 0f32);
44 assert_eq!(taffy.layout(node).unwrap().location.y, 0f32);
45 assert_eq!(taffy.layout(node0).unwrap().size.width, 200f32);
46 assert_eq!(taffy.layout(node0).unwrap().size.height, 20f32);
47 assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32);
48 assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32);
49 assert_eq!(taffy.layout(node00).unwrap().size.width, 200f32);
50 assert_eq!(taffy.layout(node00).unwrap().size.height, 20f32);
51 assert_eq!(taffy.layout(node00).unwrap().location.x, 0f32);
52 assert_eq!(taffy.layout(node00).unwrap().location.y, 0f32);
53}