⎇ bce89b1006f36ce35abfaf1f1c2b3dd95f3dffd3
tests/generated/align_self_baseline.rs
History
Who touched what
raw
index: update tests to API changes
1#[test]
2fn align_self_baseline() {
3 let mut stretch = stretch::Stretch::new();
4 let node0 = stretch
5 .new_node(
6 stretch::style::Style {
7 align_self: stretch::style::AlignSelf::Baseline,
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 node10 = stretch
19 .new_node(
20 stretch::style::Style {
21 size: stretch::geometry::Size {
22 width: stretch::style::Dimension::Points(50f32),
23 height: stretch::style::Dimension::Points(10f32),
24 ..Default::default()
25 },
26 ..Default::default()
27 },
28 vec![],
29 )
30 .unwrap();
31 let node1 = stretch
32 .new_node(
33 stretch::style::Style {
34 align_self: stretch::style::AlignSelf::Baseline,
35 size: stretch::geometry::Size {
36 width: stretch::style::Dimension::Points(50f32),
37 height: stretch::style::Dimension::Points(20f32),
38 ..Default::default()
39 },
40 ..Default::default()
41 },
42 vec![node10],
43 )
44 .unwrap();
45 let node = stretch
46 .new_node(
47 stretch::style::Style {
48 size: stretch::geometry::Size {
49 width: stretch::style::Dimension::Points(100f32),
50 height: stretch::style::Dimension::Points(100f32),
51 ..Default::default()
52 },
53 ..Default::default()
54 },
55 vec![node0, node1],
56 )
57 .unwrap();
58 stretch.compute_layout(node, stretch::geometry::Size::undefined()).unwrap();
59 assert_eq!(stretch.layout(node).unwrap().size.width, 100f32);
60 assert_eq!(stretch.layout(node).unwrap().size.height, 100f32);
61 assert_eq!(stretch.layout(node).unwrap().location.x, 0f32);
62 assert_eq!(stretch.layout(node).unwrap().location.y, 0f32);
63 assert_eq!(stretch.layout(node0).unwrap().size.width, 50f32);
64 assert_eq!(stretch.layout(node0).unwrap().size.height, 50f32);
65 assert_eq!(stretch.layout(node0).unwrap().location.x, 0f32);
66 assert_eq!(stretch.layout(node0).unwrap().location.y, 0f32);
67 assert_eq!(stretch.layout(node1).unwrap().size.width, 50f32);
68 assert_eq!(stretch.layout(node1).unwrap().size.height, 20f32);
69 assert_eq!(stretch.layout(node1).unwrap().location.x, 50f32);
70 assert_eq!(stretch.layout(node1).unwrap().location.y, 40f32);
71 assert_eq!(stretch.layout(node10).unwrap().size.width, 50f32);
72 assert_eq!(stretch.layout(node10).unwrap().size.height, 10f32);
73 assert_eq!(stretch.layout(node10).unwrap().location.x, 0f32);
74 assert_eq!(stretch.layout(node10).unwrap().location.y, 0f32);
75}