⎇ a149c6b6b8f7d25328e78ba649b76d1841c55d9d
tests/generated/flex_grow_flex_basis_percent_min_max.rs
History
Who touched what
raw
index: update tests to API changes
1#[test]
2fn flex_grow_flex_basis_percent_min_max() {
3 let mut stretch = stretch::Stretch::new();
4 let node0 = stretch
5 .new_node(
6 stretch::style::Style {
7 flex_grow: 1f32,
8 flex_shrink: 0f32,
9 flex_basis: stretch::style::Dimension::Points(0f32),
10 size: stretch::geometry::Size {
11 height: stretch::style::Dimension::Points(20f32),
12 ..Default::default()
13 },
14 min_size: stretch::geometry::Size {
15 width: stretch::style::Dimension::Points(60f32),
16 ..Default::default()
17 },
18 ..Default::default()
19 },
20 vec![],
21 )
22 .unwrap();
23 let node1 = stretch
24 .new_node(
25 stretch::style::Style {
26 flex_grow: 1f32,
27 flex_shrink: 0f32,
28 flex_basis: stretch::style::Dimension::Percent(0.5f32),
29 size: stretch::geometry::Size {
30 width: stretch::style::Dimension::Points(20f32),
31 height: stretch::style::Dimension::Points(20f32),
32 ..Default::default()
33 },
34 max_size: stretch::geometry::Size {
35 width: stretch::style::Dimension::Points(20f32),
36 ..Default::default()
37 },
38 ..Default::default()
39 },
40 vec![],
41 )
42 .unwrap();
43 let node = stretch
44 .new_node(
45 stretch::style::Style {
46 size: stretch::geometry::Size {
47 width: stretch::style::Dimension::Points(120f32),
48 ..Default::default()
49 },
50 ..Default::default()
51 },
52 vec![node0, node1],
53 )
54 .unwrap();
55 stretch.compute_layout(node, stretch::geometry::Size::undefined()).unwrap();
56 assert_eq!(stretch.layout(node).unwrap().size.width, 120f32);
57 assert_eq!(stretch.layout(node).unwrap().size.height, 20f32);
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, 100f32);
61 assert_eq!(stretch.layout(node0).unwrap().size.height, 20f32);
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, 20f32);
65 assert_eq!(stretch.layout(node1).unwrap().size.height, 20f32);
66 assert_eq!(stretch.layout(node1).unwrap().location.x, 100f32);
67 assert_eq!(stretch.layout(node1).unwrap().location.y, 0f32);
68}