⎇ d67e82255da07928c7e415ea7364529d204bbaf9
tests/generated/flex_grow_within_constrained_max_row.rs
History
Who touched what
raw
1#[test]
2fn flex_grow_within_constrained_max_row() {
3 let mut stretch = stretch2::Stretch::new();
4 let node00 = stretch
5 .new_node(
6 stretch2::style::Style {
7 flex_shrink: 1f32,
8 flex_basis: stretch2::style::Dimension::Points(100f32),
9 ..Default::default()
10 },
11 &[],
12 )
13 .unwrap();
14 let node01 = stretch
15 .new_node(
16 stretch2::style::Style {
17 size: stretch2::geometry::Size {
18 width: stretch2::style::Dimension::Points(50f32),
19 ..Default::default()
20 },
21 ..Default::default()
22 },
23 &[],
24 )
25 .unwrap();
26 let node0 = stretch
27 .new_node(
28 stretch2::style::Style {
29 size: stretch2::geometry::Size {
30 height: stretch2::style::Dimension::Points(100f32),
31 ..Default::default()
32 },
33 max_size: stretch2::geometry::Size {
34 width: stretch2::style::Dimension::Points(100f32),
35 ..Default::default()
36 },
37 ..Default::default()
38 },
39 &[node00, node01],
40 )
41 .unwrap();
42 let node = stretch
43 .new_node(
44 stretch2::style::Style {
45 flex_direction: stretch2::style::FlexDirection::Column,
46 size: stretch2::geometry::Size {
47 width: stretch2::style::Dimension::Points(200f32),
48 ..Default::default()
49 },
50 ..Default::default()
51 },
52 &[node0],
53 )
54 .unwrap();
55 stretch.compute_layout(node, stretch2::geometry::Size::undefined()).unwrap();
56 assert_eq!(stretch.layout(node).unwrap().size.width, 200f32);
57 assert_eq!(stretch.layout(node).unwrap().size.height, 100f32);
58 assert_eq!(stretch.layout(node).unwrap().location.x, 0f32);
59 assert_eq!(stretch.layout(node).unwrap().location.y, 0f32);
60 assert_eq!(stretch.layout(node0).unwrap().size.width, 100f32);
61 assert_eq!(stretch.layout(node0).unwrap().size.height, 100f32);
62 assert_eq!(stretch.layout(node0).unwrap().location.x, 0f32);
63 assert_eq!(stretch.layout(node0).unwrap().location.y, 0f32);
64 assert_eq!(stretch.layout(node00).unwrap().size.width, 67f32);
65 assert_eq!(stretch.layout(node00).unwrap().size.height, 100f32);
66 assert_eq!(stretch.layout(node00).unwrap().location.x, 0f32);
67 assert_eq!(stretch.layout(node00).unwrap().location.y, 0f32);
68 assert_eq!(stretch.layout(node01).unwrap().size.width, 33f32);
69 assert_eq!(stretch.layout(node01).unwrap().size.height, 100f32);
70 assert_eq!(stretch.layout(node01).unwrap().location.x, 67f32);
71 assert_eq!(stretch.layout(node01).unwrap().location.y, 0f32);
72}