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