⎇ b952c2b38dc58e87f43dc263e17beb4174bc68e2
tests/generated/child_min_max_width_flexing.rs
History
Who touched what
raw
Rename FlexboxLayout back to Style (#251)
1#[test]
2fn child_min_max_width_flexing() {
3 let mut taffy = taffy::Taffy::new();
4 let node0 = taffy
5 .new_with_children(
6 taffy::style::Style {
7 flex_grow: 1f32,
8 flex_shrink: 0f32,
9 flex_basis: taffy::style::Dimension::Points(0f32),
10 min_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(60f32), ..Default::default() },
11 ..Default::default()
12 },
13 &[],
14 )
15 .unwrap();
16 let node1 = taffy
17 .new_with_children(
18 taffy::style::Style {
19 flex_grow: 1f32,
20 flex_shrink: 0f32,
21 flex_basis: taffy::style::Dimension::Percent(0.5f32),
22 max_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), ..Default::default() },
23 ..Default::default()
24 },
25 &[],
26 )
27 .unwrap();
28 let node = taffy
29 .new_with_children(
30 taffy::style::Style {
31 size: taffy::geometry::Size {
32 width: taffy::style::Dimension::Points(120f32),
33 height: taffy::style::Dimension::Points(50f32),
34 ..Default::default()
35 },
36 ..Default::default()
37 },
38 &[node0, node1],
39 )
40 .unwrap();
41 taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
42 assert_eq!(taffy.layout(node).unwrap().size.width, 120f32);
43 assert_eq!(taffy.layout(node).unwrap().size.height, 50f32);
44 assert_eq!(taffy.layout(node).unwrap().location.x, 0f32);
45 assert_eq!(taffy.layout(node).unwrap().location.y, 0f32);
46 assert_eq!(taffy.layout(node0).unwrap().size.width, 100f32);
47 assert_eq!(taffy.layout(node0).unwrap().size.height, 50f32);
48 assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32);
49 assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32);
50 assert_eq!(taffy.layout(node1).unwrap().size.width, 20f32);
51 assert_eq!(taffy.layout(node1).unwrap().size.height, 50f32);
52 assert_eq!(taffy.layout(node1).unwrap().location.x, 100f32);
53 assert_eq!(taffy.layout(node1).unwrap().location.y, 0f32);
54}