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