⎇ 06471455e8cc93ab7ffee650a033ae7df8943611
tests/generated/flex_basis_and_main_dimen_set_when_flexing.rs
Ñawpa willay
Pi imata llamkarqan
ch'uya
1#[test]
2fn flex_basis_and_main_dimen_set_when_flexing() {
3 let mut stretch = stretch2::Stretch::new();
4 let node0 = stretch
5 .new_node(
6 stretch2::style::Style {
7 flex_grow: 1f32,
8 flex_basis: stretch2::style::Dimension::Points(10f32),
9 size: stretch2::geometry::Size {
10 width: stretch2::style::Dimension::Points(50f32),
11 height: stretch2::style::Dimension::Points(50f32),
12 ..Default::default()
13 },
14 ..Default::default()
15 },
16 &[],
17 )
18 .unwrap();
19 let node1 = stretch
20 .new_node(
21 stretch2::style::Style {
22 flex_grow: 1f32,
23 flex_basis: stretch2::style::Dimension::Points(10f32),
24 size: stretch2::geometry::Size {
25 width: stretch2::style::Dimension::Points(0f32),
26 height: stretch2::style::Dimension::Points(50f32),
27 ..Default::default()
28 },
29 ..Default::default()
30 },
31 &[],
32 )
33 .unwrap();
34 let node = stretch
35 .new_node(
36 stretch2::style::Style {
37 size: stretch2::geometry::Size {
38 width: stretch2::style::Dimension::Points(100f32),
39 ..Default::default()
40 },
41 ..Default::default()
42 },
43 &[node0, node1],
44 )
45 .unwrap();
46 stretch.compute_layout(node, stretch2::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}