⎇ bce89b1006f36ce35abfaf1f1c2b3dd95f3dffd3
tests/generated/absolute_layout_within_border.rs
History
Who touched what
raw
index: update tests to API changes
1#[test]
2fn absolute_layout_within_border() {
3 let mut stretch = stretch::Stretch::new();
4 let node0 = stretch
5 .new_node(
6 stretch::style::Style {
7 position_type: stretch::style::PositionType::Absolute,
8 size: stretch::geometry::Size {
9 width: stretch::style::Dimension::Points(50f32),
10 height: stretch::style::Dimension::Points(50f32),
11 ..Default::default()
12 },
13 position: stretch::geometry::Rect {
14 start: stretch::style::Dimension::Points(0f32),
15 top: stretch::style::Dimension::Points(0f32),
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 position_type: stretch::style::PositionType::Absolute,
27 size: stretch::geometry::Size {
28 width: stretch::style::Dimension::Points(50f32),
29 height: stretch::style::Dimension::Points(50f32),
30 ..Default::default()
31 },
32 position: stretch::geometry::Rect {
33 end: stretch::style::Dimension::Points(0f32),
34 bottom: stretch::style::Dimension::Points(0f32),
35 ..Default::default()
36 },
37 ..Default::default()
38 },
39 vec![],
40 )
41 .unwrap();
42 let node2 = stretch
43 .new_node(
44 stretch::style::Style {
45 position_type: stretch::style::PositionType::Absolute,
46 size: stretch::geometry::Size {
47 width: stretch::style::Dimension::Points(50f32),
48 height: stretch::style::Dimension::Points(50f32),
49 ..Default::default()
50 },
51 margin: stretch::geometry::Rect {
52 start: stretch::style::Dimension::Points(10f32),
53 end: stretch::style::Dimension::Points(10f32),
54 top: stretch::style::Dimension::Points(10f32),
55 bottom: stretch::style::Dimension::Points(10f32),
56 ..Default::default()
57 },
58 position: stretch::geometry::Rect {
59 start: stretch::style::Dimension::Points(0f32),
60 top: stretch::style::Dimension::Points(0f32),
61 ..Default::default()
62 },
63 ..Default::default()
64 },
65 vec![],
66 )
67 .unwrap();
68 let node3 = stretch
69 .new_node(
70 stretch::style::Style {
71 position_type: stretch::style::PositionType::Absolute,
72 size: stretch::geometry::Size {
73 width: stretch::style::Dimension::Points(50f32),
74 height: stretch::style::Dimension::Points(50f32),
75 ..Default::default()
76 },
77 margin: stretch::geometry::Rect {
78 start: stretch::style::Dimension::Points(10f32),
79 end: stretch::style::Dimension::Points(10f32),
80 top: stretch::style::Dimension::Points(10f32),
81 bottom: stretch::style::Dimension::Points(10f32),
82 ..Default::default()
83 },
84 position: stretch::geometry::Rect {
85 end: stretch::style::Dimension::Points(0f32),
86 bottom: stretch::style::Dimension::Points(0f32),
87 ..Default::default()
88 },
89 ..Default::default()
90 },
91 vec![],
92 )
93 .unwrap();
94 let node = stretch
95 .new_node(
96 stretch::style::Style {
97 size: stretch::geometry::Size {
98 width: stretch::style::Dimension::Points(100f32),
99 height: stretch::style::Dimension::Points(100f32),
100 ..Default::default()
101 },
102 padding: stretch::geometry::Rect {
103 start: stretch::style::Dimension::Points(10f32),
104 end: stretch::style::Dimension::Points(10f32),
105 top: stretch::style::Dimension::Points(10f32),
106 bottom: stretch::style::Dimension::Points(10f32),
107 ..Default::default()
108 },
109 border: stretch::geometry::Rect {
110 start: stretch::style::Dimension::Points(10f32),
111 end: stretch::style::Dimension::Points(10f32),
112 top: stretch::style::Dimension::Points(10f32),
113 bottom: stretch::style::Dimension::Points(10f32),
114 ..Default::default()
115 },
116 ..Default::default()
117 },
118 vec![node0, node1, node2, node3],
119 )
120 .unwrap();
121 stretch.compute_layout(node, stretch::geometry::Size::undefined()).unwrap();
122 assert_eq!(stretch.layout(node).unwrap().size.width, 100f32);
123 assert_eq!(stretch.layout(node).unwrap().size.height, 100f32);
124 assert_eq!(stretch.layout(node).unwrap().location.x, 0f32);
125 assert_eq!(stretch.layout(node).unwrap().location.y, 0f32);
126 assert_eq!(stretch.layout(node0).unwrap().size.width, 50f32);
127 assert_eq!(stretch.layout(node0).unwrap().size.height, 50f32);
128 assert_eq!(stretch.layout(node0).unwrap().location.x, 10f32);
129 assert_eq!(stretch.layout(node0).unwrap().location.y, 10f32);
130 assert_eq!(stretch.layout(node1).unwrap().size.width, 50f32);
131 assert_eq!(stretch.layout(node1).unwrap().size.height, 50f32);
132 assert_eq!(stretch.layout(node1).unwrap().location.x, 40f32);
133 assert_eq!(stretch.layout(node1).unwrap().location.y, 40f32);
134 assert_eq!(stretch.layout(node2).unwrap().size.width, 50f32);
135 assert_eq!(stretch.layout(node2).unwrap().size.height, 50f32);
136 assert_eq!(stretch.layout(node2).unwrap().location.x, 20f32);
137 assert_eq!(stretch.layout(node2).unwrap().location.y, 20f32);
138 assert_eq!(stretch.layout(node3).unwrap().size.width, 50f32);
139 assert_eq!(stretch.layout(node3).unwrap().size.height, 50f32);
140 assert_eq!(stretch.layout(node3).unwrap().location.x, 30f32);
141 assert_eq!(stretch.layout(node3).unwrap().location.y, 30f32);
142}