⎇ 9e53f03adea2b770d68954e404d2fa407dfc7d40
tests/generated/flex_grow_root_minimized.rs
Historia
Quién tocó qué
crudo
Layout algorithm decoupling, Sizing Constraints & Perf Improvements (#246)
1#[test]
2fn flex_grow_root_minimized() {
3 let mut taffy = taffy::Taffy::new();
4 let node00 = taffy
5 .new_with_children(
6 taffy::style::FlexboxLayout {
7 flex_grow: 1f32,
8 flex_basis: taffy::style::Dimension::Points(200f32),
9 ..Default::default()
10 },
11 &[],
12 )
13 .unwrap();
14 let node01 = taffy
15 .new_with_children(
16 taffy::style::FlexboxLayout {
17 size: taffy::geometry::Size { height: taffy::style::Dimension::Points(100f32), ..Default::default() },
18 ..Default::default()
19 },
20 &[],
21 )
22 .unwrap();
23 let node0 = taffy
24 .new_with_children(
25 taffy::style::FlexboxLayout {
26 flex_direction: taffy::style::FlexDirection::Column,
27 flex_grow: 1f32,
28 min_size: taffy::geometry::Size {
29 height: taffy::style::Dimension::Points(100f32),
30 ..Default::default()
31 },
32 max_size: taffy::geometry::Size {
33 height: taffy::style::Dimension::Points(500f32),
34 ..Default::default()
35 },
36 ..Default::default()
37 },
38 &[node00, node01],
39 )
40 .unwrap();
41 let node = taffy
42 .new_with_children(
43 taffy::style::FlexboxLayout {
44 flex_direction: taffy::style::FlexDirection::Column,
45 size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Default::default() },
46 min_size: taffy::geometry::Size {
47 height: taffy::style::Dimension::Points(100f32),
48 ..Default::default()
49 },
50 max_size: taffy::geometry::Size {
51 height: taffy::style::Dimension::Points(500f32),
52 ..Default::default()
53 },
54 ..Default::default()
55 },
56 &[node0],
57 )
58 .unwrap();
59 taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
60 assert_eq!(taffy.layout(node).unwrap().size.width, 100f32);
61 assert_eq!(taffy.layout(node).unwrap().size.height, 300f32);
62 assert_eq!(taffy.layout(node).unwrap().location.x, 0f32);
63 assert_eq!(taffy.layout(node).unwrap().location.y, 0f32);
64 assert_eq!(taffy.layout(node0).unwrap().size.width, 100f32);
65 assert_eq!(taffy.layout(node0).unwrap().size.height, 300f32);
66 assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32);
67 assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32);
68 assert_eq!(taffy.layout(node00).unwrap().size.width, 100f32);
69 assert_eq!(taffy.layout(node00).unwrap().size.height, 200f32);
70 assert_eq!(taffy.layout(node00).unwrap().location.x, 0f32);
71 assert_eq!(taffy.layout(node00).unwrap().location.y, 0f32);
72 assert_eq!(taffy.layout(node01).unwrap().size.width, 100f32);
73 assert_eq!(taffy.layout(node01).unwrap().size.height, 100f32);
74 assert_eq!(taffy.layout(node01).unwrap().location.x, 0f32);
75 assert_eq!(taffy.layout(node01).unwrap().location.y, 200f32);
76}