⎇ d67e82255da07928c7e415ea7364529d204bbaf9
tests/generated/percent_within_flex_grow.rs
Historia
Quién tocó qué
crudo
1#[test]
2fn percent_within_flex_grow() {
3 let mut stretch = stretch2::Stretch::new();
4 let node0 = stretch
5 .new_node(
6 stretch2::style::Style {
7 size: stretch2::geometry::Size {
8 width: stretch2::style::Dimension::Points(100f32),
9 ..Default::default()
10 },
11 ..Default::default()
12 },
13 &[],
14 )
15 .unwrap();
16 let node10 = stretch
17 .new_node(
18 stretch2::style::Style {
19 size: stretch2::geometry::Size {
20 width: stretch2::style::Dimension::Percent(1f32),
21 ..Default::default()
22 },
23 ..Default::default()
24 },
25 &[],
26 )
27 .unwrap();
28 let node1 = stretch
29 .new_node(
30 stretch2::style::Style {
31 flex_direction: stretch2::style::FlexDirection::Column,
32 flex_grow: 1f32,
33 ..Default::default()
34 },
35 &[node10],
36 )
37 .unwrap();
38 let node2 = stretch
39 .new_node(
40 stretch2::style::Style {
41 size: stretch2::geometry::Size {
42 width: stretch2::style::Dimension::Points(100f32),
43 ..Default::default()
44 },
45 ..Default::default()
46 },
47 &[],
48 )
49 .unwrap();
50 let node = stretch
51 .new_node(
52 stretch2::style::Style {
53 size: stretch2::geometry::Size {
54 width: stretch2::style::Dimension::Points(350f32),
55 height: stretch2::style::Dimension::Points(100f32),
56 ..Default::default()
57 },
58 ..Default::default()
59 },
60 &[node0, node1, node2],
61 )
62 .unwrap();
63 stretch.compute_layout(node, stretch2::geometry::Size::undefined()).unwrap();
64 assert_eq!(stretch.layout(node).unwrap().size.width, 350f32);
65 assert_eq!(stretch.layout(node).unwrap().size.height, 100f32);
66 assert_eq!(stretch.layout(node).unwrap().location.x, 0f32);
67 assert_eq!(stretch.layout(node).unwrap().location.y, 0f32);
68 assert_eq!(stretch.layout(node0).unwrap().size.width, 100f32);
69 assert_eq!(stretch.layout(node0).unwrap().size.height, 100f32);
70 assert_eq!(stretch.layout(node0).unwrap().location.x, 0f32);
71 assert_eq!(stretch.layout(node0).unwrap().location.y, 0f32);
72 assert_eq!(stretch.layout(node1).unwrap().size.width, 150f32);
73 assert_eq!(stretch.layout(node1).unwrap().size.height, 100f32);
74 assert_eq!(stretch.layout(node1).unwrap().location.x, 100f32);
75 assert_eq!(stretch.layout(node1).unwrap().location.y, 0f32);
76 assert_eq!(stretch.layout(node10).unwrap().size.width, 150f32);
77 assert_eq!(stretch.layout(node10).unwrap().size.height, 0f32);
78 assert_eq!(stretch.layout(node10).unwrap().location.x, 0f32);
79 assert_eq!(stretch.layout(node10).unwrap().location.y, 0f32);
80 assert_eq!(stretch.layout(node2).unwrap().size.width, 100f32);
81 assert_eq!(stretch.layout(node2).unwrap().size.height, 100f32);
82 assert_eq!(stretch.layout(node2).unwrap().location.x, 250f32);
83 assert_eq!(stretch.layout(node2).unwrap().location.y, 0f32);
84}