⎇ bce89b1006f36ce35abfaf1f1c2b3dd95f3dffd3
tests/generated/flex_shrink_to_zero.rs
Historia
Quién tocó qué
crudo
index: update tests to API changes
1#[test]
2fn flex_shrink_to_zero() {
3 let mut stretch = stretch::Stretch::new();
4 let node0 = stretch
5 .new_node(
6 stretch::style::Style {
7 flex_shrink: 0f32,
8 size: stretch::geometry::Size {
9 width: stretch::style::Dimension::Points(50f32),
10 height: stretch::style::Dimension::Points(50f32),
11 ..Default::default()
12 },
13 ..Default::default()
14 },
15 vec![],
16 )
17 .unwrap();
18 let node1 = stretch
19 .new_node(
20 stretch::style::Style {
21 flex_shrink: 1f32,
22 size: stretch::geometry::Size {
23 width: stretch::style::Dimension::Points(50f32),
24 height: stretch::style::Dimension::Points(50f32),
25 ..Default::default()
26 },
27 ..Default::default()
28 },
29 vec![],
30 )
31 .unwrap();
32 let node2 = stretch
33 .new_node(
34 stretch::style::Style {
35 flex_shrink: 0f32,
36 size: stretch::geometry::Size {
37 width: stretch::style::Dimension::Points(50f32),
38 height: stretch::style::Dimension::Points(50f32),
39 ..Default::default()
40 },
41 ..Default::default()
42 },
43 vec![],
44 )
45 .unwrap();
46 let node = stretch
47 .new_node(
48 stretch::style::Style {
49 size: stretch::geometry::Size { width: stretch::style::Dimension::Points(75f32), ..Default::default() },
50 ..Default::default()
51 },
52 vec![node0, node1, node2],
53 )
54 .unwrap();
55 stretch.compute_layout(node, stretch::geometry::Size::undefined()).unwrap();
56 assert_eq!(stretch.layout(node).unwrap().size.width, 75f32);
57 assert_eq!(stretch.layout(node).unwrap().size.height, 50f32);
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, 50f32);
61 assert_eq!(stretch.layout(node0).unwrap().size.height, 50f32);
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(node1).unwrap().size.width, 0f32);
65 assert_eq!(stretch.layout(node1).unwrap().size.height, 50f32);
66 assert_eq!(stretch.layout(node1).unwrap().location.x, 50f32);
67 assert_eq!(stretch.layout(node1).unwrap().location.y, 0f32);
68 assert_eq!(stretch.layout(node2).unwrap().size.width, 50f32);
69 assert_eq!(stretch.layout(node2).unwrap().size.height, 50f32);
70 assert_eq!(stretch.layout(node2).unwrap().location.x, 50f32);
71 assert_eq!(stretch.layout(node2).unwrap().location.y, 0f32);
72}