gioser

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 701HTML 654Markdown 12TOML 62332 Definiciones

⎇ 59cd7a4b3ab55aed5f1eb7cdf2dd4a739875345d tests/generated.rs Rust · 11923 líneas · 512.2 KB Historia Quién tocó qué crudo

Update percentage tests to use different width/android on container 59cd7a4b3 · Emil Sjölander ·

1#[cfg(test)]
2mod generated {
3    #[test]
4    fn justify_content_row_space_around() {
5        let layout = stretch::compute(
6            &stretch::style::Node {
7                justify_content: stretch::style::JustifyContent::SpaceAround,
8                size: stretch::geometry::Size {
9                    width: stretch::style::Dimension::Points(100.0000),
10                    height: stretch::style::Dimension::Points(100.0000),
11                    ..Default::default()
12                },
13                children: vec![
14                    stretch::style::Node {
15                        size: stretch::geometry::Size {
16                            width: stretch::style::Dimension::Points(10.0000),
17                            ..Default::default()
18                        },
19                        ..Default::default()
20                    },
21                    stretch::style::Node {
22                        size: stretch::geometry::Size {
23                            width: stretch::style::Dimension::Points(10.0000),
24                            ..Default::default()
25                        },
26                        ..Default::default()
27                    },
28                    stretch::style::Node {
29                        size: stretch::geometry::Size {
30                            width: stretch::style::Dimension::Points(10.0000),
31                            ..Default::default()
32                        },
33                        ..Default::default()
34                    },
35                ],
36                ..Default::default()
37            },
38            stretch::geometry::Size::undefined(),
39        );
40
41        assert_eq!(layout.size.width, 100.0000);
42        assert_eq!(layout.size.height, 100.0000);
43        assert_eq!(layout.location.x, 0.0000);
44        assert_eq!(layout.location.y, 0.0000);
45
46        assert_eq!(layout.children[0].size.width, 10.0000);
47        assert_eq!(layout.children[0].size.height, 100.0000);
48        assert_eq!(layout.children[0].location.x, 12.0000);
49        assert_eq!(layout.children[0].location.y, 0.0000);
50
51        assert_eq!(layout.children[1].size.width, 10.0000);
52        assert_eq!(layout.children[1].size.height, 100.0000);
53        assert_eq!(layout.children[1].location.x, 45.0000);
54        assert_eq!(layout.children[1].location.y, 0.0000);
55
56        assert_eq!(layout.children[2].size.width, 10.0000);
57        assert_eq!(layout.children[2].size.height, 100.0000);
58        assert_eq!(layout.children[2].location.x, 78.0000);
59        assert_eq!(layout.children[2].location.y, 0.0000);
60    }
61
62    #[test]
63    fn align_items_center() {
64        let layout = stretch::compute(
65            &stretch::style::Node {
66                align_items: stretch::style::AlignItems::Center,
67                size: stretch::geometry::Size {
68                    width: stretch::style::Dimension::Points(100.0000),
69                    height: stretch::style::Dimension::Points(100.0000),
70                    ..Default::default()
71                },
72                children: vec![stretch::style::Node {
73                    size: stretch::geometry::Size {
74                        width: stretch::style::Dimension::Points(10.0000),
75                        height: stretch::style::Dimension::Points(10.0000),
76                        ..Default::default()
77                    },
78                    ..Default::default()
79                }],
80                ..Default::default()
81            },
82            stretch::geometry::Size::undefined(),
83        );
84
85        assert_eq!(layout.size.width, 100.0000);
86        assert_eq!(layout.size.height, 100.0000);
87        assert_eq!(layout.location.x, 0.0000);
88        assert_eq!(layout.location.y, 0.0000);
89
90        assert_eq!(layout.children[0].size.width, 10.0000);
91        assert_eq!(layout.children[0].size.height, 10.0000);
92        assert_eq!(layout.children[0].location.x, 0.0000);
93        assert_eq!(layout.children[0].location.y, 45.0000);
94    }
95
96    #[test]
97    fn absolute_layout_justify_content_center() {
98        let layout = stretch::compute(
99            &stretch::style::Node {
100                justify_content: stretch::style::JustifyContent::Center,
101                size: stretch::geometry::Size {
102                    width: stretch::style::Dimension::Points(110.0000),
103                    height: stretch::style::Dimension::Points(100.0000),
104                    ..Default::default()
105                },
106                children: vec![stretch::style::Node {
107                    position_type: stretch::style::PositionType::Absolute,
108                    size: stretch::geometry::Size {
109                        width: stretch::style::Dimension::Points(60.0000),
110                        height: stretch::style::Dimension::Points(40.0000),
111                        ..Default::default()
112                    },
113                    ..Default::default()
114                }],
115                ..Default::default()
116            },
117            stretch::geometry::Size::undefined(),
118        );
119
120        assert_eq!(layout.size.width, 110.0000);
121        assert_eq!(layout.size.height, 100.0000);
122        assert_eq!(layout.location.x, 0.0000);
123        assert_eq!(layout.location.y, 0.0000);
124
125        assert_eq!(layout.children[0].size.width, 60.0000);
126        assert_eq!(layout.children[0].size.height, 40.0000);
127        assert_eq!(layout.children[0].location.x, 25.0000);
128        assert_eq!(layout.children[0].location.y, 0.0000);
129    }
130
131    #[test]
132    fn margin_auto_bottom_and_top() {
133        let layout = stretch::compute(
134            &stretch::style::Node {
135                align_items: stretch::style::AlignItems::Center,
136                size: stretch::geometry::Size {
137                    width: stretch::style::Dimension::Points(200.0000),
138                    height: stretch::style::Dimension::Points(200.0000),
139                    ..Default::default()
140                },
141                children: vec![
142                    stretch::style::Node {
143                        size: stretch::geometry::Size {
144                            width: stretch::style::Dimension::Points(50.0000),
145                            height: stretch::style::Dimension::Points(50.0000),
146                            ..Default::default()
147                        },
148                        margin: stretch::geometry::Rect {
149                            top: stretch::style::Dimension::Auto,
150                            bottom: stretch::style::Dimension::Auto,
151                            ..Default::default()
152                        },
153                        ..Default::default()
154                    },
155                    stretch::style::Node {
156                        size: stretch::geometry::Size {
157                            width: stretch::style::Dimension::Points(50.0000),
158                            height: stretch::style::Dimension::Points(50.0000),
159                            ..Default::default()
160                        },
161                        ..Default::default()
162                    },
163                ],
164                ..Default::default()
165            },
166            stretch::geometry::Size::undefined(),
167        );
168
169        assert_eq!(layout.size.width, 200.0000);
170        assert_eq!(layout.size.height, 200.0000);
171        assert_eq!(layout.location.x, 0.0000);
172        assert_eq!(layout.location.y, 0.0000);
173
174        assert_eq!(layout.children[0].size.width, 50.0000);
175        assert_eq!(layout.children[0].size.height, 50.0000);
176        assert_eq!(layout.children[0].location.x, 0.0000);
177        assert_eq!(layout.children[0].location.y, 75.0000);
178
179        assert_eq!(layout.children[1].size.width, 50.0000);
180        assert_eq!(layout.children[1].size.height, 50.0000);
181        assert_eq!(layout.children[1].location.x, 50.0000);
182        assert_eq!(layout.children[1].location.y, 75.0000);
183    }
184
185    #[test]
186    fn margin_auto_left_and_right_strech() {
187        let layout = stretch::compute(
188            &stretch::style::Node {
189                size: stretch::geometry::Size {
190                    width: stretch::style::Dimension::Points(200.0000),
191                    height: stretch::style::Dimension::Points(200.0000),
192                    ..Default::default()
193                },
194                children: vec![
195                    stretch::style::Node {
196                        size: stretch::geometry::Size {
197                            width: stretch::style::Dimension::Points(50.0000),
198                            height: stretch::style::Dimension::Points(50.0000),
199                            ..Default::default()
200                        },
201                        margin: stretch::geometry::Rect {
202                            start: stretch::style::Dimension::Auto,
203                            end: stretch::style::Dimension::Auto,
204                            ..Default::default()
205                        },
206                        ..Default::default()
207                    },
208                    stretch::style::Node {
209                        size: stretch::geometry::Size {
210                            width: stretch::style::Dimension::Points(50.0000),
211                            height: stretch::style::Dimension::Points(50.0000),
212                            ..Default::default()
213                        },
214                        ..Default::default()
215                    },
216                ],
217                ..Default::default()
218            },
219            stretch::geometry::Size::undefined(),
220        );
221
222        assert_eq!(layout.size.width, 200.0000);
223        assert_eq!(layout.size.height, 200.0000);
224        assert_eq!(layout.location.x, 0.0000);
225        assert_eq!(layout.location.y, 0.0000);
226
227        assert_eq!(layout.children[0].size.width, 50.0000);
228        assert_eq!(layout.children[0].size.height, 50.0000);
229        assert_eq!(layout.children[0].location.x, 50.0000);
230        assert_eq!(layout.children[0].location.y, 0.0000);
231
232        assert_eq!(layout.children[1].size.width, 50.0000);
233        assert_eq!(layout.children[1].size.height, 50.0000);
234        assert_eq!(layout.children[1].location.x, 150.0000);
235        assert_eq!(layout.children[1].location.y, 0.0000);
236    }
237
238    #[test]
239    fn rounding_flex_basis_overrides_main_size() {
240        let layout = stretch::compute(
241            &stretch::style::Node {
242                flex_direction: stretch::style::FlexDirection::Column,
243                size: stretch::geometry::Size {
244                    width: stretch::style::Dimension::Points(100.0000),
245                    height: stretch::style::Dimension::Points(113.0000),
246                    ..Default::default()
247                },
248                children: vec![
249                    stretch::style::Node {
250                        flex_grow: 1.0000,
251                        flex_basis: stretch::style::Dimension::Points(50.0000),
252                        size: stretch::geometry::Size {
253                            height: stretch::style::Dimension::Points(20.0000),
254                            ..Default::default()
255                        },
256                        ..Default::default()
257                    },
258                    stretch::style::Node {
259                        flex_grow: 1.0000,
260                        size: stretch::geometry::Size {
261                            height: stretch::style::Dimension::Points(10.0000),
262                            ..Default::default()
263                        },
264                        ..Default::default()
265                    },
266                    stretch::style::Node {
267                        flex_grow: 1.0000,
268                        size: stretch::geometry::Size {
269                            height: stretch::style::Dimension::Points(10.0000),
270                            ..Default::default()
271                        },
272                        ..Default::default()
273                    },
274                ],
275                ..Default::default()
276            },
277            stretch::geometry::Size::undefined(),
278        );
279
280        assert_eq!(layout.size.width, 100.0000);
281        assert_eq!(layout.size.height, 113.0000);
282        assert_eq!(layout.location.x, 0.0000);
283        assert_eq!(layout.location.y, 0.0000);
284
285        assert_eq!(layout.children[0].size.width, 100.0000);
286        assert_eq!(layout.children[0].size.height, 64.0000);
287        assert_eq!(layout.children[0].location.x, 0.0000);
288        assert_eq!(layout.children[0].location.y, 0.0000);
289
290        assert_eq!(layout.children[1].size.width, 100.0000);
291        assert_eq!(layout.children[1].size.height, 25.0000);
292        assert_eq!(layout.children[1].location.x, 0.0000);
293        assert_eq!(layout.children[1].location.y, 64.0000);
294
295        assert_eq!(layout.children[2].size.width, 100.0000);
296        assert_eq!(layout.children[2].size.height, 24.0000);
297        assert_eq!(layout.children[2].location.x, 0.0000);
298        assert_eq!(layout.children[2].location.y, 89.0000);
299    }
300
301    #[test]
302    fn percentage_flex_basis() {
303        let layout = stretch::compute(
304            &stretch::style::Node {
305                size: stretch::geometry::Size {
306                    width: stretch::style::Dimension::Points(200.0000),
307                    height: stretch::style::Dimension::Points(200.0000),
308                    ..Default::default()
309                },
310                children: vec![
311                    stretch::style::Node {
312                        flex_grow: 1.0000,
313                        flex_basis: stretch::style::Dimension::Percent(0.5000),
314                        ..Default::default()
315                    },
316                    stretch::style::Node {
317                        flex_grow: 1.0000,
318                        flex_basis: stretch::style::Dimension::Percent(0.2500),
319                        ..Default::default()
320                    },
321                ],
322                ..Default::default()
323            },
324            stretch::geometry::Size::undefined(),
325        );
326
327        assert_eq!(layout.size.width, 200.0000);
328        assert_eq!(layout.size.height, 200.0000);
329        assert_eq!(layout.location.x, 0.0000);
330        assert_eq!(layout.location.y, 0.0000);
331
332        assert_eq!(layout.children[0].size.width, 125.0000);
333        assert_eq!(layout.children[0].size.height, 200.0000);
334        assert_eq!(layout.children[0].location.x, 0.0000);
335        assert_eq!(layout.children[0].location.y, 0.0000);
336
337        assert_eq!(layout.children[1].size.width, 75.0000);
338        assert_eq!(layout.children[1].size.height, 200.0000);
339        assert_eq!(layout.children[1].location.x, 125.0000);
340        assert_eq!(layout.children[1].location.y, 0.0000);
341    }
342
343    #[test]
344    fn rounding_fractial_input_3() {
345        let layout = stretch::compute(
346            &stretch::style::Node {
347                flex_direction: stretch::style::FlexDirection::Column,
348                size: stretch::geometry::Size {
349                    width: stretch::style::Dimension::Points(100.0000),
350                    height: stretch::style::Dimension::Points(113.4000),
351                    ..Default::default()
352                },
353                children: vec![
354                    stretch::style::Node {
355                        flex_grow: 1.0000,
356                        flex_basis: stretch::style::Dimension::Points(50.0000),
357                        size: stretch::geometry::Size {
358                            height: stretch::style::Dimension::Points(20.0000),
359                            ..Default::default()
360                        },
361                        ..Default::default()
362                    },
363                    stretch::style::Node {
364                        flex_grow: 1.0000,
365                        size: stretch::geometry::Size {
366                            height: stretch::style::Dimension::Points(10.0000),
367                            ..Default::default()
368                        },
369                        ..Default::default()
370                    },
371                    stretch::style::Node {
372                        flex_grow: 1.0000,
373                        size: stretch::geometry::Size {
374                            height: stretch::style::Dimension::Points(10.0000),
375                            ..Default::default()
376                        },
377                        ..Default::default()
378                    },
379                ],
380                ..Default::default()
381            },
382            stretch::geometry::Size::undefined(),
383        );
384
385        assert_eq!(layout.size.width, 100.0000);
386        assert_eq!(layout.size.height, 113.0000);
387        assert_eq!(layout.location.x, 0.0000);
388        assert_eq!(layout.location.y, 0.0000);
389
390        assert_eq!(layout.children[0].size.width, 100.0000);
391        assert_eq!(layout.children[0].size.height, 64.0000);
392        assert_eq!(layout.children[0].location.x, 0.0000);
393        assert_eq!(layout.children[0].location.y, 0.0000);
394
395        assert_eq!(layout.children[1].size.width, 100.0000);
396        assert_eq!(layout.children[1].size.height, 25.0000);
397        assert_eq!(layout.children[1].location.x, 0.0000);
398        assert_eq!(layout.children[1].location.y, 64.0000);
399
400        assert_eq!(layout.children[2].size.width, 100.0000);
401        assert_eq!(layout.children[2].size.height, 24.0000);
402        assert_eq!(layout.children[2].location.x, 0.0000);
403        assert_eq!(layout.children[2].location.y, 89.0000);
404    }
405
406    #[test]
407    fn margin_and_stretch_column() {
408        let layout = stretch::compute(
409            &stretch::style::Node {
410                flex_direction: stretch::style::FlexDirection::Column,
411                size: stretch::geometry::Size {
412                    width: stretch::style::Dimension::Points(100.0000),
413                    height: stretch::style::Dimension::Points(100.0000),
414                    ..Default::default()
415                },
416                children: vec![stretch::style::Node {
417                    flex_grow: 1.0000,
418                    margin: stretch::geometry::Rect {
419                        start: stretch::style::Dimension::Points(10.0000),
420                        end: stretch::style::Dimension::Points(10.0000),
421                        ..Default::default()
422                    },
423                    ..Default::default()
424                }],
425                ..Default::default()
426            },
427            stretch::geometry::Size::undefined(),
428        );
429
430        assert_eq!(layout.size.width, 100.0000);
431        assert_eq!(layout.size.height, 100.0000);
432        assert_eq!(layout.location.x, 0.0000);
433        assert_eq!(layout.location.y, 0.0000);
434
435        assert_eq!(layout.children[0].size.width, 80.0000);
436        assert_eq!(layout.children[0].size.height, 100.0000);
437        assert_eq!(layout.children[0].location.x, 10.0000);
438        assert_eq!(layout.children[0].location.y, 0.0000);
439    }
440
441    #[test]
442    fn wrapped_column_max_height_flex() {
443        let layout = stretch::compute(
444            &stretch::style::Node {
445                flex_direction: stretch::style::FlexDirection::Column,
446                flex_wrap: stretch::style::FlexWrap::Wrap,
447                align_items: stretch::style::AlignItems::Center,
448                align_content: stretch::style::AlignContent::Center,
449                justify_content: stretch::style::JustifyContent::Center,
450                size: stretch::geometry::Size {
451                    width: stretch::style::Dimension::Points(700.0000),
452                    height: stretch::style::Dimension::Points(500.0000),
453                    ..Default::default()
454                },
455                children: vec![
456                    stretch::style::Node {
457                        flex_grow: 1.0000,
458                        flex_shrink: 1.0000,
459                        flex_basis: stretch::style::Dimension::Percent(0.0000),
460                        size: stretch::geometry::Size {
461                            width: stretch::style::Dimension::Points(100.0000),
462                            height: stretch::style::Dimension::Points(500.0000),
463                            ..Default::default()
464                        },
465                        max_size: stretch::geometry::Size {
466                            height: stretch::style::Dimension::Points(200.0000),
467                            ..Default::default()
468                        },
469                        ..Default::default()
470                    },
471                    stretch::style::Node {
472                        flex_grow: 1.0000,
473                        flex_shrink: 1.0000,
474                        flex_basis: stretch::style::Dimension::Percent(0.0000),
475                        size: stretch::geometry::Size {
476                            width: stretch::style::Dimension::Points(200.0000),
477                            height: stretch::style::Dimension::Points(200.0000),
478                            ..Default::default()
479                        },
480                        margin: stretch::geometry::Rect {
481                            start: stretch::style::Dimension::Points(20.0000),
482                            end: stretch::style::Dimension::Points(20.0000),
483                            top: stretch::style::Dimension::Points(20.0000),
484                            bottom: stretch::style::Dimension::Points(20.0000),
485                            ..Default::default()
486                        },
487                        ..Default::default()
488                    },
489                    stretch::style::Node {
490                        size: stretch::geometry::Size {
491                            width: stretch::style::Dimension::Points(100.0000),
492                            height: stretch::style::Dimension::Points(100.0000),
493                            ..Default::default()
494                        },
495                        ..Default::default()
496                    },
497                ],
498                ..Default::default()
499            },
500            stretch::geometry::Size::undefined(),
501        );
502
503        assert_eq!(layout.size.width, 700.0000);
504        assert_eq!(layout.size.height, 500.0000);
505        assert_eq!(layout.location.x, 0.0000);
506        assert_eq!(layout.location.y, 0.0000);
507
508        assert_eq!(layout.children[0].size.width, 100.0000);
509        assert_eq!(layout.children[0].size.height, 180.0000);
510        assert_eq!(layout.children[0].location.x, 300.0000);
511        assert_eq!(layout.children[0].location.y, 0.0000);
512
513        assert_eq!(layout.children[1].size.width, 200.0000);
514        assert_eq!(layout.children[1].size.height, 180.0000);
515        assert_eq!(layout.children[1].location.x, 250.0000);
516        assert_eq!(layout.children[1].location.y, 200.0000);
517
518        assert_eq!(layout.children[2].size.width, 100.0000);
519        assert_eq!(layout.children[2].size.height, 100.0000);
520        assert_eq!(layout.children[2].location.x, 300.0000);
521        assert_eq!(layout.children[2].location.y, 400.0000);
522    }
523
524    #[test]
525    fn align_baseline_nested_child() {
526        let layout = stretch::compute(
527            &stretch::style::Node {
528                align_items: stretch::style::AlignItems::Baseline,
529                size: stretch::geometry::Size {
530                    width: stretch::style::Dimension::Points(100.0000),
531                    height: stretch::style::Dimension::Points(100.0000),
532                    ..Default::default()
533                },
534                children: vec![
535                    stretch::style::Node {
536                        size: stretch::geometry::Size {
537                            width: stretch::style::Dimension::Points(50.0000),
538                            height: stretch::style::Dimension::Points(50.0000),
539                            ..Default::default()
540                        },
541                        ..Default::default()
542                    },
543                    stretch::style::Node {
544                        flex_direction: stretch::style::FlexDirection::Column,
545                        size: stretch::geometry::Size {
546                            width: stretch::style::Dimension::Points(50.0000),
547                            height: stretch::style::Dimension::Points(20.0000),
548                            ..Default::default()
549                        },
550                        children: vec![stretch::style::Node {
551                            size: stretch::geometry::Size {
552                                width: stretch::style::Dimension::Points(50.0000),
553                                height: stretch::style::Dimension::Points(10.0000),
554                                ..Default::default()
555                            },
556                            ..Default::default()
557                        }],
558                        ..Default::default()
559                    },
560                ],
561                ..Default::default()
562            },
563            stretch::geometry::Size::undefined(),
564        );
565
566        assert_eq!(layout.size.width, 100.0000);
567        assert_eq!(layout.size.height, 100.0000);
568        assert_eq!(layout.location.x, 0.0000);
569        assert_eq!(layout.location.y, 0.0000);
570
571        assert_eq!(layout.children[0].size.width, 50.0000);
572        assert_eq!(layout.children[0].size.height, 50.0000);
573        assert_eq!(layout.children[0].location.x, 0.0000);
574        assert_eq!(layout.children[0].location.y, 0.0000);
575
576        assert_eq!(layout.children[1].size.width, 50.0000);
577        assert_eq!(layout.children[1].size.height, 20.0000);
578        assert_eq!(layout.children[1].location.x, 50.0000);
579        assert_eq!(layout.children[1].location.y, 40.0000);
580
581        assert_eq!(layout.children[1].children[0].size.width, 50.0000);
582        assert_eq!(layout.children[1].children[0].size.height, 10.0000);
583        assert_eq!(layout.children[1].children[0].location.x, 0.0000);
584        assert_eq!(layout.children[1].children[0].location.y, 0.0000);
585    }
586
587    #[test]
588    fn max_height_overrides_height_on_root() {
589        let layout = stretch::compute(
590            &stretch::style::Node {
591                size: stretch::geometry::Size {
592                    height: stretch::style::Dimension::Points(200.0000),
593                    ..Default::default()
594                },
595                max_size: stretch::geometry::Size {
596                    height: stretch::style::Dimension::Points(100.0000),
597                    ..Default::default()
598                },
599                ..Default::default()
600            },
601            stretch::geometry::Size::undefined(),
602        );
603
604        assert_eq!(layout.size.width, 0.0000);
605        assert_eq!(layout.size.height, 100.0000);
606        assert_eq!(layout.location.x, 0.0000);
607        assert_eq!(layout.location.y, 0.0000);
608    }
609
610    #[test]
611    fn padding_center_child() {
612        let layout = stretch::compute(
613            &stretch::style::Node {
614                align_items: stretch::style::AlignItems::Center,
615                justify_content: stretch::style::JustifyContent::Center,
616                size: stretch::geometry::Size {
617                    width: stretch::style::Dimension::Points(100.0000),
618                    height: stretch::style::Dimension::Points(100.0000),
619                    ..Default::default()
620                },
621                padding: stretch::geometry::Rect {
622                    start: stretch::style::Dimension::Points(10.0000),
623                    end: stretch::style::Dimension::Points(20.0000),
624                    top: stretch::style::Dimension::Points(10.0000),
625                    bottom: stretch::style::Dimension::Points(20.0000),
626                    ..Default::default()
627                },
628                children: vec![stretch::style::Node {
629                    size: stretch::geometry::Size {
630                        width: stretch::style::Dimension::Points(10.0000),
631                        height: stretch::style::Dimension::Points(10.0000),
632                        ..Default::default()
633                    },
634                    ..Default::default()
635                }],
636                ..Default::default()
637            },
638            stretch::geometry::Size::undefined(),
639        );
640
641        assert_eq!(layout.size.width, 100.0000);
642        assert_eq!(layout.size.height, 100.0000);
643        assert_eq!(layout.location.x, 0.0000);
644        assert_eq!(layout.location.y, 0.0000);
645
646        assert_eq!(layout.children[0].size.width, 10.0000);
647        assert_eq!(layout.children[0].size.height, 10.0000);
648        assert_eq!(layout.children[0].location.x, 40.0000);
649        assert_eq!(layout.children[0].location.y, 40.0000);
650    }
651
652    #[test]
653    fn align_flex_start_with_stretching_children() {
654        let layout = stretch::compute(
655            &stretch::style::Node {
656                size: stretch::geometry::Size {
657                    width: stretch::style::Dimension::Points(500.0000),
658                    height: stretch::style::Dimension::Points(500.0000),
659                    ..Default::default()
660                },
661                children: vec![stretch::style::Node {
662                    children: vec![stretch::style::Node {
663                        flex_grow: 1.0000,
664                        flex_shrink: 1.0000,
665                        children: vec![stretch::style::Node {
666                            flex_grow: 1.0000,
667                            flex_shrink: 1.0000,
668                            ..Default::default()
669                        }],
670                        ..Default::default()
671                    }],
672                    ..Default::default()
673                }],
674                ..Default::default()
675            },
676            stretch::geometry::Size::undefined(),
677        );
678
679        assert_eq!(layout.size.width, 500.0000);
680        assert_eq!(layout.size.height, 500.0000);
681        assert_eq!(layout.location.x, 0.0000);
682        assert_eq!(layout.location.y, 0.0000);
683
684        assert_eq!(layout.children[0].size.width, 0.0000);
685        assert_eq!(layout.children[0].size.height, 500.0000);
686        assert_eq!(layout.children[0].location.x, 0.0000);
687        assert_eq!(layout.children[0].location.y, 0.0000);
688
689        assert_eq!(layout.children[0].children[0].size.width, 0.0000);
690        assert_eq!(layout.children[0].children[0].size.height, 500.0000);
691        assert_eq!(layout.children[0].children[0].location.x, 0.0000);
692        assert_eq!(layout.children[0].children[0].location.y, 0.0000);
693
694        assert_eq!(layout.children[0].children[0].children[0].size.width, 0.0000);
695        assert_eq!(layout.children[0].children[0].children[0].size.height, 500.0000);
696        assert_eq!(layout.children[0].children[0].children[0].location.x, 0.0000);
697        assert_eq!(layout.children[0].children[0].children[0].location.y, 0.0000);
698    }
699
700    #[test]
701    fn min_width_overrides_width() {
702        let layout = stretch::compute(
703            &stretch::style::Node {
704                children: vec![stretch::style::Node {
705                    size: stretch::geometry::Size {
706                        width: stretch::style::Dimension::Points(50.0000),
707                        ..Default::default()
708                    },
709                    min_size: stretch::geometry::Size {
710                        width: stretch::style::Dimension::Points(100.0000),
711                        ..Default::default()
712                    },
713                    ..Default::default()
714                }],
715                ..Default::default()
716            },
717            stretch::geometry::Size::undefined(),
718        );
719
720        assert_eq!(layout.size.width, 100.0000);
721        assert_eq!(layout.size.height, 0.0000);
722        assert_eq!(layout.location.x, 0.0000);
723        assert_eq!(layout.location.y, 0.0000);
724
725        assert_eq!(layout.children[0].size.width, 100.0000);
726        assert_eq!(layout.children[0].size.height, 0.0000);
727        assert_eq!(layout.children[0].location.x, 0.0000);
728        assert_eq!(layout.children[0].location.y, 0.0000);
729    }
730
731    #[test]
732    fn flex_wrap_align_stretch_fits_one_row() {
733        let layout = stretch::compute(
734            &stretch::style::Node {
735                flex_wrap: stretch::style::FlexWrap::Wrap,
736                size: stretch::geometry::Size {
737                    width: stretch::style::Dimension::Points(150.0000),
738                    height: stretch::style::Dimension::Points(100.0000),
739                    ..Default::default()
740                },
741                children: vec![
742                    stretch::style::Node {
743                        size: stretch::geometry::Size {
744                            width: stretch::style::Dimension::Points(50.0000),
745                            ..Default::default()
746                        },
747                        ..Default::default()
748                    },
749                    stretch::style::Node {
750                        size: stretch::geometry::Size {
751                            width: stretch::style::Dimension::Points(50.0000),
752                            ..Default::default()
753                        },
754                        ..Default::default()
755                    },
756                ],
757                ..Default::default()
758            },
759            stretch::geometry::Size::undefined(),
760        );
761
762        assert_eq!(layout.size.width, 150.0000);
763        assert_eq!(layout.size.height, 100.0000);
764        assert_eq!(layout.location.x, 0.0000);
765        assert_eq!(layout.location.y, 0.0000);
766
767        assert_eq!(layout.children[0].size.width, 50.0000);
768        assert_eq!(layout.children[0].size.height, 100.0000);
769        assert_eq!(layout.children[0].location.x, 0.0000);
770        assert_eq!(layout.children[0].location.y, 0.0000);
771
772        assert_eq!(layout.children[1].size.width, 50.0000);
773        assert_eq!(layout.children[1].size.height, 100.0000);
774        assert_eq!(layout.children[1].location.x, 50.0000);
775        assert_eq!(layout.children[1].location.y, 0.0000);
776    }
777
778    #[test]
779    fn justify_content_row_space_evenly() {
780        let layout = stretch::compute(
781            &stretch::style::Node {
782                justify_content: stretch::style::JustifyContent::SpaceEvenly,
783                size: stretch::geometry::Size {
784                    width: stretch::style::Dimension::Points(100.0000),
785                    height: stretch::style::Dimension::Points(100.0000),
786                    ..Default::default()
787                },
788                children: vec![
789                    stretch::style::Node {
790                        size: stretch::geometry::Size {
791                            height: stretch::style::Dimension::Points(10.0000),
792                            ..Default::default()
793                        },
794                        ..Default::default()
795                    },
796                    stretch::style::Node {
797                        size: stretch::geometry::Size {
798                            height: stretch::style::Dimension::Points(10.0000),
799                            ..Default::default()
800                        },
801                        ..Default::default()
802                    },
803                    stretch::style::Node {
804                        size: stretch::geometry::Size {
805                            height: stretch::style::Dimension::Points(10.0000),
806                            ..Default::default()
807                        },
808                        ..Default::default()
809                    },
810                ],
811                ..Default::default()
812            },
813            stretch::geometry::Size::undefined(),
814        );
815
816        assert_eq!(layout.size.width, 100.0000);
817        assert_eq!(layout.size.height, 100.0000);
818        assert_eq!(layout.location.x, 0.0000);
819        assert_eq!(layout.location.y, 0.0000);
820
821        assert_eq!(layout.children[0].size.width, 0.0000);
822        assert_eq!(layout.children[0].size.height, 10.0000);
823        assert_eq!(layout.children[0].location.x, 25.0000);
824        assert_eq!(layout.children[0].location.y, 0.0000);
825
826        assert_eq!(layout.children[1].size.width, 0.0000);
827        assert_eq!(layout.children[1].size.height, 10.0000);
828        assert_eq!(layout.children[1].location.x, 50.0000);
829        assert_eq!(layout.children[1].location.y, 0.0000);
830
831        assert_eq!(layout.children[2].size.width, 0.0000);
832        assert_eq!(layout.children[2].size.height, 10.0000);
833        assert_eq!(layout.children[2].location.x, 75.0000);
834        assert_eq!(layout.children[2].location.y, 0.0000);
835    }
836
837    #[test]
838    fn absolute_layout_child_order() {
839        let layout = stretch::compute(
840            &stretch::style::Node {
841                align_items: stretch::style::AlignItems::Center,
842                justify_content: stretch::style::JustifyContent::Center,
843                size: stretch::geometry::Size {
844                    width: stretch::style::Dimension::Points(110.0000),
845                    height: stretch::style::Dimension::Points(100.0000),
846                    ..Default::default()
847                },
848                children: vec![
849                    stretch::style::Node {
850                        size: stretch::geometry::Size {
851                            width: stretch::style::Dimension::Points(60.0000),
852                            height: stretch::style::Dimension::Points(40.0000),
853                            ..Default::default()
854                        },
855                        ..Default::default()
856                    },
857                    stretch::style::Node {
858                        position_type: stretch::style::PositionType::Absolute,
859                        size: stretch::geometry::Size {
860                            width: stretch::style::Dimension::Points(60.0000),
861                            height: stretch::style::Dimension::Points(40.0000),
862                            ..Default::default()
863                        },
864                        ..Default::default()
865                    },
866                    stretch::style::Node {
867                        size: stretch::geometry::Size {
868                            width: stretch::style::Dimension::Points(60.0000),
869                            height: stretch::style::Dimension::Points(40.0000),
870                            ..Default::default()
871                        },
872                        ..Default::default()
873                    },
874                ],
875                ..Default::default()
876            },
877            stretch::geometry::Size::undefined(),
878        );
879
880        assert_eq!(layout.size.width, 110.0000);
881        assert_eq!(layout.size.height, 100.0000);
882        assert_eq!(layout.location.x, 0.0000);
883        assert_eq!(layout.location.y, 0.0000);
884
885        assert_eq!(layout.children[0].size.width, 55.0000);
886        assert_eq!(layout.children[0].size.height, 40.0000);
887        assert_eq!(layout.children[0].location.x, 0.0000);
888        assert_eq!(layout.children[0].location.y, 30.0000);
889
890        assert_eq!(layout.children[1].size.width, 60.0000);
891        assert_eq!(layout.children[1].size.height, 40.0000);
892        assert_eq!(layout.children[1].location.x, 25.0000);
893        assert_eq!(layout.children[1].location.y, 30.0000);
894
895        assert_eq!(layout.children[2].size.width, 55.0000);
896        assert_eq!(layout.children[2].size.height, 40.0000);
897        assert_eq!(layout.children[2].location.x, 55.0000);
898        assert_eq!(layout.children[2].location.y, 30.0000);
899    }
900
901    #[test]
902    fn absolute_layout_percentage_bottom_based_on_parent_height() {
903        let layout = stretch::compute(
904            &stretch::style::Node {
905                size: stretch::geometry::Size {
906                    width: stretch::style::Dimension::Points(100.0000),
907                    height: stretch::style::Dimension::Points(200.0000),
908                    ..Default::default()
909                },
910                children: vec![
911                    stretch::style::Node {
912                        position_type: stretch::style::PositionType::Absolute,
913                        size: stretch::geometry::Size {
914                            width: stretch::style::Dimension::Points(10.0000),
915                            height: stretch::style::Dimension::Points(10.0000),
916                            ..Default::default()
917                        },
918                        position: stretch::geometry::Rect {
919                            top: stretch::style::Dimension::Percent(0.5000),
920                            ..Default::default()
921                        },
922                        ..Default::default()
923                    },
924                    stretch::style::Node {
925                        position_type: stretch::style::PositionType::Absolute,
926                        size: stretch::geometry::Size {
927                            width: stretch::style::Dimension::Points(10.0000),
928                            height: stretch::style::Dimension::Points(10.0000),
929                            ..Default::default()
930                        },
931                        position: stretch::geometry::Rect {
932                            bottom: stretch::style::Dimension::Percent(0.5000),
933                            ..Default::default()
934                        },
935                        ..Default::default()
936                    },
937                    stretch::style::Node {
938                        position_type: stretch::style::PositionType::Absolute,
939                        size: stretch::geometry::Size {
940                            width: stretch::style::Dimension::Points(10.0000),
941                            ..Default::default()
942                        },
943                        position: stretch::geometry::Rect {
944                            top: stretch::style::Dimension::Percent(0.1000),
945                            bottom: stretch::style::Dimension::Percent(0.1000),
946                            ..Default::default()
947                        },
948                        ..Default::default()
949                    },
950                ],
951                ..Default::default()
952            },
953            stretch::geometry::Size::undefined(),
954        );
955
956        assert_eq!(layout.size.width, 100.0000);
957        assert_eq!(layout.size.height, 200.0000);
958        assert_eq!(layout.location.x, 0.0000);
959        assert_eq!(layout.location.y, 0.0000);
960
961        assert_eq!(layout.children[0].size.width, 10.0000);
962        assert_eq!(layout.children[0].size.height, 10.0000);
963        assert_eq!(layout.children[0].location.x, 0.0000);
964        assert_eq!(layout.children[0].location.y, 100.0000);
965
966        assert_eq!(layout.children[1].size.width, 10.0000);
967        assert_eq!(layout.children[1].size.height, 10.0000);
968        assert_eq!(layout.children[1].location.x, 0.0000);
969        assert_eq!(layout.children[1].location.y, 90.0000);
970
971        assert_eq!(layout.children[2].size.width, 10.0000);
972        assert_eq!(layout.children[2].size.height, 160.0000);
973        assert_eq!(layout.children[2].location.x, 0.0000);
974        assert_eq!(layout.children[2].location.y, 20.0000);
975    }
976
977    #[test]
978    fn absolute_layout_align_items_and_justify_content_flex_end() {
979        let layout = stretch::compute(
980            &stretch::style::Node {
981                align_items: stretch::style::AlignItems::FlexEnd,
982                justify_content: stretch::style::JustifyContent::FlexEnd,
983                size: stretch::geometry::Size {
984                    width: stretch::style::Dimension::Points(110.0000),
985                    height: stretch::style::Dimension::Points(100.0000),
986                    ..Default::default()
987                },
988                children: vec![stretch::style::Node {
989                    position_type: stretch::style::PositionType::Absolute,
990                    size: stretch::geometry::Size {
991                        width: stretch::style::Dimension::Points(60.0000),
992                        height: stretch::style::Dimension::Points(40.0000),
993                        ..Default::default()
994                    },
995                    ..Default::default()
996                }],
997                ..Default::default()
998            },
999            stretch::geometry::Size::undefined(),
1000        );
1001
1002        assert_eq!(layout.size.width, 110.0000);
1003        assert_eq!(layout.size.height, 100.0000);
1004        assert_eq!(layout.location.x, 0.0000);
1005        assert_eq!(layout.location.y, 0.0000);
1006
1007        assert_eq!(layout.children[0].size.width, 60.0000);
1008        assert_eq!(layout.children[0].size.height, 40.0000);
1009        assert_eq!(layout.children[0].location.x, 50.0000);
1010        assert_eq!(layout.children[0].location.y, 60.0000);
1011    }
1012
1013    #[test]
1014    fn nested_overflowing_child() {
1015        let layout = stretch::compute(
1016            &stretch::style::Node {
1017                size: stretch::geometry::Size {
1018                    width: stretch::style::Dimension::Points(100.0000),
1019                    height: stretch::style::Dimension::Points(100.0000),
1020                    ..Default::default()
1021                },
1022                children: vec![stretch::style::Node {
1023                    children: vec![stretch::style::Node {
1024                        size: stretch::geometry::Size {
1025                            width: stretch::style::Dimension::Points(200.0000),
1026                            height: stretch::style::Dimension::Points(200.0000),
1027                            ..Default::default()
1028                        },
1029                        ..Default::default()
1030                    }],
1031                    ..Default::default()
1032                }],
1033                ..Default::default()
1034            },
1035            stretch::geometry::Size::undefined(),
1036        );
1037
1038        assert_eq!(layout.size.width, 100.0000);
1039        assert_eq!(layout.size.height, 100.0000);
1040        assert_eq!(layout.location.x, 0.0000);
1041        assert_eq!(layout.location.y, 0.0000);
1042
1043        assert_eq!(layout.children[0].size.width, 200.0000);
1044        assert_eq!(layout.children[0].size.height, 100.0000);
1045        assert_eq!(layout.children[0].location.x, 0.0000);
1046        assert_eq!(layout.children[0].location.y, 0.0000);
1047
1048        assert_eq!(layout.children[0].children[0].size.width, 200.0000);
1049        assert_eq!(layout.children[0].children[0].size.height, 200.0000);
1050        assert_eq!(layout.children[0].children[0].location.x, 0.0000);
1051        assert_eq!(layout.children[0].children[0].location.y, 0.0000);
1052    }
1053
1054    #[test]
1055    fn flex_direction_row() {
1056        let layout = stretch::compute(
1057            &stretch::style::Node {
1058                size: stretch::geometry::Size {
1059                    width: stretch::style::Dimension::Points(100.0000),
1060                    height: stretch::style::Dimension::Points(100.0000),
1061                    ..Default::default()
1062                },
1063                children: vec![
1064                    stretch::style::Node {
1065                        size: stretch::geometry::Size {
1066                            width: stretch::style::Dimension::Points(10.0000),
1067                            ..Default::default()
1068                        },
1069                        ..Default::default()
1070                    },
1071                    stretch::style::Node {
1072                        size: stretch::geometry::Size {
1073                            width: stretch::style::Dimension::Points(10.0000),
1074                            ..Default::default()
1075                        },
1076                        ..Default::default()
1077                    },
1078                    stretch::style::Node {
1079                        size: stretch::geometry::Size {
1080                            width: stretch::style::Dimension::Points(10.0000),
1081                            ..Default::default()
1082                        },
1083                        ..Default::default()
1084                    },
1085                ],
1086                ..Default::default()
1087            },
1088            stretch::geometry::Size::undefined(),
1089        );
1090
1091        assert_eq!(layout.size.width, 100.0000);
1092        assert_eq!(layout.size.height, 100.0000);
1093        assert_eq!(layout.location.x, 0.0000);
1094        assert_eq!(layout.location.y, 0.0000);
1095
1096        assert_eq!(layout.children[0].size.width, 10.0000);
1097        assert_eq!(layout.children[0].size.height, 100.0000);
1098        assert_eq!(layout.children[0].location.x, 0.0000);
1099        assert_eq!(layout.children[0].location.y, 0.0000);
1100
1101        assert_eq!(layout.children[1].size.width, 10.0000);
1102        assert_eq!(layout.children[1].size.height, 100.0000);
1103        assert_eq!(layout.children[1].location.x, 10.0000);
1104        assert_eq!(layout.children[1].location.y, 0.0000);
1105
1106        assert_eq!(layout.children[2].size.width, 10.0000);
1107        assert_eq!(layout.children[2].size.height, 100.0000);
1108        assert_eq!(layout.children[2].location.x, 20.0000);
1109        assert_eq!(layout.children[2].location.y, 0.0000);
1110    }
1111
1112    #[test]
1113    fn child_min_max_width_flexing() {
1114        let layout = stretch::compute(
1115            &stretch::style::Node {
1116                size: stretch::geometry::Size {
1117                    width: stretch::style::Dimension::Points(120.0000),
1118                    height: stretch::style::Dimension::Points(50.0000),
1119                    ..Default::default()
1120                },
1121                children: vec![
1122                    stretch::style::Node {
1123                        flex_grow: 1.0000,
1124                        flex_shrink: 0.0000,
1125                        flex_basis: stretch::style::Dimension::Points(0.0000),
1126                        min_size: stretch::geometry::Size {
1127                            width: stretch::style::Dimension::Points(60.0000),
1128                            ..Default::default()
1129                        },
1130                        ..Default::default()
1131                    },
1132                    stretch::style::Node {
1133                        flex_grow: 1.0000,
1134                        flex_shrink: 0.0000,
1135                        flex_basis: stretch::style::Dimension::Percent(0.5000),
1136                        max_size: stretch::geometry::Size {
1137                            width: stretch::style::Dimension::Points(20.0000),
1138                            ..Default::default()
1139                        },
1140                        ..Default::default()
1141                    },
1142                ],
1143                ..Default::default()
1144            },
1145            stretch::geometry::Size::undefined(),
1146        );
1147
1148        assert_eq!(layout.size.width, 120.0000);
1149        assert_eq!(layout.size.height, 50.0000);
1150        assert_eq!(layout.location.x, 0.0000);
1151        assert_eq!(layout.location.y, 0.0000);
1152
1153        assert_eq!(layout.children[0].size.width, 100.0000);
1154        assert_eq!(layout.children[0].size.height, 50.0000);
1155        assert_eq!(layout.children[0].location.x, 0.0000);
1156        assert_eq!(layout.children[0].location.y, 0.0000);
1157
1158        assert_eq!(layout.children[1].size.width, 20.0000);
1159        assert_eq!(layout.children[1].size.height, 50.0000);
1160        assert_eq!(layout.children[1].location.x, 100.0000);
1161        assert_eq!(layout.children[1].location.y, 0.0000);
1162    }
1163
1164    #[test]
1165    fn absolute_layout_in_wrap_reverse_row_container_flex_end() {
1166        let layout = stretch::compute(
1167            &stretch::style::Node {
1168                flex_wrap: stretch::style::FlexWrap::WrapReverse,
1169                size: stretch::geometry::Size {
1170                    width: stretch::style::Dimension::Points(100.0000),
1171                    height: stretch::style::Dimension::Points(100.0000),
1172                    ..Default::default()
1173                },
1174                children: vec![stretch::style::Node {
1175                    position_type: stretch::style::PositionType::Absolute,
1176                    align_self: stretch::style::AlignSelf::FlexEnd,
1177                    size: stretch::geometry::Size {
1178                        width: stretch::style::Dimension::Points(20.0000),
1179                        height: stretch::style::Dimension::Points(20.0000),
1180                        ..Default::default()
1181                    },
1182                    ..Default::default()
1183                }],
1184                ..Default::default()
1185            },
1186            stretch::geometry::Size::undefined(),
1187        );
1188
1189        assert_eq!(layout.size.width, 100.0000);
1190        assert_eq!(layout.size.height, 100.0000);
1191        assert_eq!(layout.location.x, 0.0000);
1192        assert_eq!(layout.location.y, 0.0000);
1193
1194        assert_eq!(layout.children[0].size.width, 20.0000);
1195        assert_eq!(layout.children[0].size.height, 20.0000);
1196        assert_eq!(layout.children[0].location.x, 0.0000);
1197        assert_eq!(layout.children[0].location.y, 0.0000);
1198    }
1199
1200    #[test]
1201    fn margin_and_flex_column() {
1202        let layout = stretch::compute(
1203            &stretch::style::Node {
1204                flex_direction: stretch::style::FlexDirection::Column,
1205                size: stretch::geometry::Size {
1206                    width: stretch::style::Dimension::Points(100.0000),
1207                    height: stretch::style::Dimension::Points(100.0000),
1208                    ..Default::default()
1209                },
1210                children: vec![stretch::style::Node {
1211                    flex_grow: 1.0000,
1212                    margin: stretch::geometry::Rect {
1213                        top: stretch::style::Dimension::Points(10.0000),
1214                        bottom: stretch::style::Dimension::Points(10.0000),
1215                        ..Default::default()
1216                    },
1217                    ..Default::default()
1218                }],
1219                ..Default::default()
1220            },
1221            stretch::geometry::Size::undefined(),
1222        );
1223
1224        assert_eq!(layout.size.width, 100.0000);
1225        assert_eq!(layout.size.height, 100.0000);
1226        assert_eq!(layout.location.x, 0.0000);
1227        assert_eq!(layout.location.y, 0.0000);
1228
1229        assert_eq!(layout.children[0].size.width, 100.0000);
1230        assert_eq!(layout.children[0].size.height, 80.0000);
1231        assert_eq!(layout.children[0].location.x, 0.0000);
1232        assert_eq!(layout.children[0].location.y, 10.0000);
1233    }
1234
1235    #[test]
1236    fn flex_basis_flex_shrink_row() {
1237        let layout = stretch::compute(
1238            &stretch::style::Node {
1239                size: stretch::geometry::Size {
1240                    width: stretch::style::Dimension::Points(100.0000),
1241                    height: stretch::style::Dimension::Points(100.0000),
1242                    ..Default::default()
1243                },
1244                children: vec![
1245                    stretch::style::Node {
1246                        flex_basis: stretch::style::Dimension::Points(100.0000),
1247                        ..Default::default()
1248                    },
1249                    stretch::style::Node {
1250                        flex_basis: stretch::style::Dimension::Points(50.0000),
1251                        ..Default::default()
1252                    },
1253                ],
1254                ..Default::default()
1255            },
1256            stretch::geometry::Size::undefined(),
1257        );
1258
1259        assert_eq!(layout.size.width, 100.0000);
1260        assert_eq!(layout.size.height, 100.0000);
1261        assert_eq!(layout.location.x, 0.0000);
1262        assert_eq!(layout.location.y, 0.0000);
1263
1264        assert_eq!(layout.children[0].size.width, 67.0000);
1265        assert_eq!(layout.children[0].size.height, 100.0000);
1266        assert_eq!(layout.children[0].location.x, 0.0000);
1267        assert_eq!(layout.children[0].location.y, 0.0000);
1268
1269        assert_eq!(layout.children[1].size.width, 33.0000);
1270        assert_eq!(layout.children[1].size.height, 100.0000);
1271        assert_eq!(layout.children[1].location.x, 67.0000);
1272        assert_eq!(layout.children[1].location.y, 0.0000);
1273    }
1274
1275    #[test]
1276    fn justify_content_column_min_height_and_margin_top() {
1277        let layout = stretch::compute(
1278            &stretch::style::Node {
1279                flex_direction: stretch::style::FlexDirection::Column,
1280                justify_content: stretch::style::JustifyContent::Center,
1281                min_size: stretch::geometry::Size {
1282                    height: stretch::style::Dimension::Points(50.0000),
1283                    ..Default::default()
1284                },
1285                children: vec![stretch::style::Node {
1286                    size: stretch::geometry::Size {
1287                        width: stretch::style::Dimension::Points(20.0000),
1288                        height: stretch::style::Dimension::Points(20.0000),
1289                        ..Default::default()
1290                    },
1291                    margin: stretch::geometry::Rect {
1292                        top: stretch::style::Dimension::Points(10.0000),
1293                        ..Default::default()
1294                    },
1295                    ..Default::default()
1296                }],
1297                ..Default::default()
1298            },
1299            stretch::geometry::Size::undefined(),
1300        );
1301
1302        assert_eq!(layout.size.width, 20.0000);
1303        assert_eq!(layout.size.height, 50.0000);
1304        assert_eq!(layout.location.x, 0.0000);
1305        assert_eq!(layout.location.y, 0.0000);
1306
1307        assert_eq!(layout.children[0].size.width, 20.0000);
1308        assert_eq!(layout.children[0].size.height, 20.0000);
1309        assert_eq!(layout.children[0].location.x, 0.0000);
1310        assert_eq!(layout.children[0].location.y, 20.0000);
1311    }
1312
1313    #[test]
1314    fn justify_content_overflow_min_max() {
1315        let layout = stretch::compute(
1316            &stretch::style::Node {
1317                flex_direction: stretch::style::FlexDirection::Column,
1318                justify_content: stretch::style::JustifyContent::Center,
1319                min_size: stretch::geometry::Size {
1320                    height: stretch::style::Dimension::Points(100.0000),
1321                    ..Default::default()
1322                },
1323                max_size: stretch::geometry::Size {
1324                    height: stretch::style::Dimension::Points(110.0000),
1325                    ..Default::default()
1326                },
1327                children: vec![
1328                    stretch::style::Node {
1329                        flex_shrink: 0.0000,
1330                        size: stretch::geometry::Size {
1331                            width: stretch::style::Dimension::Points(50.0000),
1332                            height: stretch::style::Dimension::Points(50.0000),
1333                            ..Default::default()
1334                        },
1335                        ..Default::default()
1336                    },
1337                    stretch::style::Node {
1338                        flex_shrink: 0.0000,
1339                        size: stretch::geometry::Size {
1340                            width: stretch::style::Dimension::Points(50.0000),
1341                            height: stretch::style::Dimension::Points(50.0000),
1342                            ..Default::default()
1343                        },
1344                        ..Default::default()
1345                    },
1346                    stretch::style::Node {
1347                        flex_shrink: 0.0000,
1348                        size: stretch::geometry::Size {
1349                            width: stretch::style::Dimension::Points(50.0000),
1350                            height: stretch::style::Dimension::Points(50.0000),
1351                            ..Default::default()
1352                        },
1353                        ..Default::default()
1354                    },
1355                ],
1356                ..Default::default()
1357            },
1358            stretch::geometry::Size::undefined(),
1359        );
1360
1361        assert_eq!(layout.size.width, 50.0000);
1362        assert_eq!(layout.size.height, 110.0000);
1363        assert_eq!(layout.location.x, 0.0000);
1364        assert_eq!(layout.location.y, 0.0000);
1365
1366        assert_eq!(layout.children[0].size.width, 50.0000);
1367        assert_eq!(layout.children[0].size.height, 50.0000);
1368        assert_eq!(layout.children[0].location.x, 0.0000);
1369        assert_eq!(layout.children[0].location.y, -20.0000);
1370
1371        assert_eq!(layout.children[1].size.width, 50.0000);
1372        assert_eq!(layout.children[1].size.height, 50.0000);
1373        assert_eq!(layout.children[1].location.x, 0.0000);
1374        assert_eq!(layout.children[1].location.y, 30.0000);
1375
1376        assert_eq!(layout.children[2].size.width, 50.0000);
1377        assert_eq!(layout.children[2].size.height, 50.0000);
1378        assert_eq!(layout.children[2].location.x, 0.0000);
1379        assert_eq!(layout.children[2].location.y, 80.0000);
1380    }
1381
1382    #[test]
1383    fn wrap_reverse_column_fixed_size() {
1384        let layout = stretch::compute(
1385            &stretch::style::Node {
1386                flex_direction: stretch::style::FlexDirection::Column,
1387                flex_wrap: stretch::style::FlexWrap::WrapReverse,
1388                align_items: stretch::style::AlignItems::Center,
1389                size: stretch::geometry::Size {
1390                    width: stretch::style::Dimension::Points(200.0000),
1391                    height: stretch::style::Dimension::Points(100.0000),
1392                    ..Default::default()
1393                },
1394                children: vec![
1395                    stretch::style::Node {
1396                        size: stretch::geometry::Size {
1397                            width: stretch::style::Dimension::Points(30.0000),
1398                            height: stretch::style::Dimension::Points(10.0000),
1399                            ..Default::default()
1400                        },
1401                        ..Default::default()
1402                    },
1403                    stretch::style::Node {
1404                        size: stretch::geometry::Size {
1405                            width: stretch::style::Dimension::Points(30.0000),
1406                            height: stretch::style::Dimension::Points(20.0000),
1407                            ..Default::default()
1408                        },
1409                        ..Default::default()
1410                    },
1411                    stretch::style::Node {
1412                        size: stretch::geometry::Size {
1413                            width: stretch::style::Dimension::Points(30.0000),
1414                            height: stretch::style::Dimension::Points(30.0000),
1415                            ..Default::default()
1416                        },
1417                        ..Default::default()
1418                    },
1419                    stretch::style::Node {
1420                        size: stretch::geometry::Size {
1421                            width: stretch::style::Dimension::Points(30.0000),
1422                            height: stretch::style::Dimension::Points(40.0000),
1423                            ..Default::default()
1424                        },
1425                        ..Default::default()
1426                    },
1427                    stretch::style::Node {
1428                        size: stretch::geometry::Size {
1429                            width: stretch::style::Dimension::Points(30.0000),
1430                            height: stretch::style::Dimension::Points(50.0000),
1431                            ..Default::default()
1432                        },
1433                        ..Default::default()
1434                    },
1435                ],
1436                ..Default::default()
1437            },
1438            stretch::geometry::Size::undefined(),
1439        );
1440
1441        assert_eq!(layout.size.width, 200.0000);
1442        assert_eq!(layout.size.height, 100.0000);
1443        assert_eq!(layout.location.x, 0.0000);
1444        assert_eq!(layout.location.y, 0.0000);
1445
1446        assert_eq!(layout.children[0].size.width, 30.0000);
1447        assert_eq!(layout.children[0].size.height, 10.0000);
1448        assert_eq!(layout.children[0].location.x, 135.0000);
1449        assert_eq!(layout.children[0].location.y, 0.0000);
1450
1451        assert_eq!(layout.children[1].size.width, 30.0000);
1452        assert_eq!(layout.children[1].size.height, 20.0000);
1453        assert_eq!(layout.children[1].location.x, 135.0000);
1454        assert_eq!(layout.children[1].location.y, 10.0000);
1455
1456        assert_eq!(layout.children[2].size.width, 30.0000);
1457        assert_eq!(layout.children[2].size.height, 30.0000);
1458        assert_eq!(layout.children[2].location.x, 135.0000);
1459        assert_eq!(layout.children[2].location.y, 30.0000);
1460
1461        assert_eq!(layout.children[3].size.width, 30.0000);
1462        assert_eq!(layout.children[3].size.height, 40.0000);
1463        assert_eq!(layout.children[3].location.x, 135.0000);
1464        assert_eq!(layout.children[3].location.y, 60.0000);
1465
1466        assert_eq!(layout.children[4].size.width, 30.0000);
1467        assert_eq!(layout.children[4].size.height, 50.0000);
1468        assert_eq!(layout.children[4].location.x, 35.0000);
1469        assert_eq!(layout.children[4].location.y, 0.0000);
1470    }
1471
1472    #[test]
1473    fn max_width() {
1474        let layout = stretch::compute(
1475            &stretch::style::Node {
1476                flex_direction: stretch::style::FlexDirection::Column,
1477                size: stretch::geometry::Size {
1478                    width: stretch::style::Dimension::Points(100.0000),
1479                    height: stretch::style::Dimension::Points(100.0000),
1480                    ..Default::default()
1481                },
1482                children: vec![stretch::style::Node {
1483                    size: stretch::geometry::Size {
1484                        height: stretch::style::Dimension::Points(10.0000),
1485                        ..Default::default()
1486                    },
1487                    max_size: stretch::geometry::Size {
1488                        width: stretch::style::Dimension::Points(50.0000),
1489                        ..Default::default()
1490                    },
1491                    ..Default::default()
1492                }],
1493                ..Default::default()
1494            },
1495            stretch::geometry::Size::undefined(),
1496        );
1497
1498        assert_eq!(layout.size.width, 100.0000);
1499        assert_eq!(layout.size.height, 100.0000);
1500        assert_eq!(layout.location.x, 0.0000);
1501        assert_eq!(layout.location.y, 0.0000);
1502
1503        assert_eq!(layout.children[0].size.width, 50.0000);
1504        assert_eq!(layout.children[0].size.height, 10.0000);
1505        assert_eq!(layout.children[0].location.x, 0.0000);
1506        assert_eq!(layout.children[0].location.y, 0.0000);
1507    }
1508
1509    #[test]
1510    fn justify_content_row_center() {
1511        let layout = stretch::compute(
1512            &stretch::style::Node {
1513                justify_content: stretch::style::JustifyContent::Center,
1514                size: stretch::geometry::Size {
1515                    width: stretch::style::Dimension::Points(100.0000),
1516                    height: stretch::style::Dimension::Points(100.0000),
1517                    ..Default::default()
1518                },
1519                children: vec![
1520                    stretch::style::Node {
1521                        size: stretch::geometry::Size {
1522                            width: stretch::style::Dimension::Points(10.0000),
1523                            ..Default::default()
1524                        },
1525                        ..Default::default()
1526                    },
1527                    stretch::style::Node {
1528                        size: stretch::geometry::Size {
1529                            width: stretch::style::Dimension::Points(10.0000),
1530                            ..Default::default()
1531                        },
1532                        ..Default::default()
1533                    },
1534                    stretch::style::Node {
1535                        size: stretch::geometry::Size {
1536                            width: stretch::style::Dimension::Points(10.0000),
1537                            ..Default::default()
1538                        },
1539                        ..Default::default()
1540                    },
1541                ],
1542                ..Default::default()
1543            },
1544            stretch::geometry::Size::undefined(),
1545        );
1546
1547        assert_eq!(layout.size.width, 100.0000);
1548        assert_eq!(layout.size.height, 100.0000);
1549        assert_eq!(layout.location.x, 0.0000);
1550        assert_eq!(layout.location.y, 0.0000);
1551
1552        assert_eq!(layout.children[0].size.width, 10.0000);
1553        assert_eq!(layout.children[0].size.height, 100.0000);
1554        assert_eq!(layout.children[0].location.x, 35.0000);
1555        assert_eq!(layout.children[0].location.y, 0.0000);
1556
1557        assert_eq!(layout.children[1].size.width, 10.0000);
1558        assert_eq!(layout.children[1].size.height, 100.0000);
1559        assert_eq!(layout.children[1].location.x, 45.0000);
1560        assert_eq!(layout.children[1].location.y, 0.0000);
1561
1562        assert_eq!(layout.children[2].size.width, 10.0000);
1563        assert_eq!(layout.children[2].size.height, 100.0000);
1564        assert_eq!(layout.children[2].location.x, 55.0000);
1565        assert_eq!(layout.children[2].location.y, 0.0000);
1566    }
1567
1568    #[test]
1569    fn flex_grow_root_minimized() {
1570        let layout = stretch::compute(
1571            &stretch::style::Node {
1572                flex_direction: stretch::style::FlexDirection::Column,
1573                size: stretch::geometry::Size {
1574                    width: stretch::style::Dimension::Points(100.0000),
1575                    ..Default::default()
1576                },
1577                min_size: stretch::geometry::Size {
1578                    height: stretch::style::Dimension::Points(100.0000),
1579                    ..Default::default()
1580                },
1581                max_size: stretch::geometry::Size {
1582                    height: stretch::style::Dimension::Points(500.0000),
1583                    ..Default::default()
1584                },
1585                children: vec![stretch::style::Node {
1586                    flex_direction: stretch::style::FlexDirection::Column,
1587                    flex_grow: 1.0000,
1588                    min_size: stretch::geometry::Size {
1589                        height: stretch::style::Dimension::Points(100.0000),
1590                        ..Default::default()
1591                    },
1592                    max_size: stretch::geometry::Size {
1593                        height: stretch::style::Dimension::Points(500.0000),
1594                        ..Default::default()
1595                    },
1596                    children: vec![
1597                        stretch::style::Node {
1598                            flex_grow: 1.0000,
1599                            flex_basis: stretch::style::Dimension::Points(200.0000),
1600                            ..Default::default()
1601                        },
1602                        stretch::style::Node {
1603                            size: stretch::geometry::Size {
1604                                height: stretch::style::Dimension::Points(100.0000),
1605                                ..Default::default()
1606                            },
1607                            ..Default::default()
1608                        },
1609                    ],
1610                    ..Default::default()
1611                }],
1612                ..Default::default()
1613            },
1614            stretch::geometry::Size::undefined(),
1615        );
1616
1617        assert_eq!(layout.size.width, 100.0000);
1618        assert_eq!(layout.size.height, 300.0000);
1619        assert_eq!(layout.location.x, 0.0000);
1620        assert_eq!(layout.location.y, 0.0000);
1621
1622        assert_eq!(layout.children[0].size.width, 100.0000);
1623        assert_eq!(layout.children[0].size.height, 300.0000);
1624        assert_eq!(layout.children[0].location.x, 0.0000);
1625        assert_eq!(layout.children[0].location.y, 0.0000);
1626
1627        assert_eq!(layout.children[0].children[0].size.width, 100.0000);
1628        assert_eq!(layout.children[0].children[0].size.height, 200.0000);
1629        assert_eq!(layout.children[0].children[0].location.x, 0.0000);
1630        assert_eq!(layout.children[0].children[0].location.y, 0.0000);
1631
1632        assert_eq!(layout.children[0].children[1].size.width, 100.0000);
1633        assert_eq!(layout.children[0].children[1].size.height, 100.0000);
1634        assert_eq!(layout.children[0].children[1].location.x, 0.0000);
1635        assert_eq!(layout.children[0].children[1].location.y, 200.0000);
1636    }
1637
1638    #[test]
1639    fn container_with_unsized_child() {
1640        let layout = stretch::compute(
1641            &stretch::style::Node {
1642                size: stretch::geometry::Size {
1643                    width: stretch::style::Dimension::Points(100.0000),
1644                    height: stretch::style::Dimension::Points(100.0000),
1645                    ..Default::default()
1646                },
1647                children: vec![stretch::style::Node { ..Default::default() }],
1648                ..Default::default()
1649            },
1650            stretch::geometry::Size::undefined(),
1651        );
1652
1653        assert_eq!(layout.size.width, 100.0000);
1654        assert_eq!(layout.size.height, 100.0000);
1655        assert_eq!(layout.location.x, 0.0000);
1656        assert_eq!(layout.location.y, 0.0000);
1657
1658        assert_eq!(layout.children[0].size.width, 0.0000);
1659        assert_eq!(layout.children[0].size.height, 100.0000);
1660        assert_eq!(layout.children[0].location.x, 0.0000);
1661        assert_eq!(layout.children[0].location.y, 0.0000);
1662    }
1663
1664    #[test]
1665    fn flex_grow_within_constrained_min_row() {
1666        let layout = stretch::compute(
1667            &stretch::style::Node {
1668                size: stretch::geometry::Size {
1669                    height: stretch::style::Dimension::Points(100.0000),
1670                    ..Default::default()
1671                },
1672                min_size: stretch::geometry::Size {
1673                    width: stretch::style::Dimension::Points(100.0000),
1674                    ..Default::default()
1675                },
1676                children: vec![
1677                    stretch::style::Node { flex_grow: 1.0000, ..Default::default() },
1678                    stretch::style::Node {
1679                        size: stretch::geometry::Size {
1680                            width: stretch::style::Dimension::Points(50.0000),
1681                            ..Default::default()
1682                        },
1683                        ..Default::default()
1684                    },
1685                ],
1686                ..Default::default()
1687            },
1688            stretch::geometry::Size::undefined(),
1689        );
1690
1691        assert_eq!(layout.size.width, 100.0000);
1692        assert_eq!(layout.size.height, 100.0000);
1693        assert_eq!(layout.location.x, 0.0000);
1694        assert_eq!(layout.location.y, 0.0000);
1695
1696        assert_eq!(layout.children[0].size.width, 50.0000);
1697        assert_eq!(layout.children[0].size.height, 100.0000);
1698        assert_eq!(layout.children[0].location.x, 0.0000);
1699        assert_eq!(layout.children[0].location.y, 0.0000);
1700
1701        assert_eq!(layout.children[1].size.width, 50.0000);
1702        assert_eq!(layout.children[1].size.height, 100.0000);
1703        assert_eq!(layout.children[1].location.x, 50.0000);
1704        assert_eq!(layout.children[1].location.y, 0.0000);
1705    }
1706
1707    #[test]
1708    fn flex_shrink_by_outer_margin_with_max_size() {
1709        let layout = stretch::compute(
1710            &stretch::style::Node {
1711                flex_direction: stretch::style::FlexDirection::Column,
1712                size: stretch::geometry::Size {
1713                    height: stretch::style::Dimension::Points(100.0000),
1714                    ..Default::default()
1715                },
1716                max_size: stretch::geometry::Size {
1717                    height: stretch::style::Dimension::Points(80.0000),
1718                    ..Default::default()
1719                },
1720                children: vec![stretch::style::Node {
1721                    size: stretch::geometry::Size {
1722                        width: stretch::style::Dimension::Points(20.0000),
1723                        height: stretch::style::Dimension::Points(20.0000),
1724                        ..Default::default()
1725                    },
1726                    margin: stretch::geometry::Rect {
1727                        top: stretch::style::Dimension::Points(100.0000),
1728                        ..Default::default()
1729                    },
1730                    ..Default::default()
1731                }],
1732                ..Default::default()
1733            },
1734            stretch::geometry::Size::undefined(),
1735        );
1736
1737        assert_eq!(layout.size.width, 20.0000);
1738        assert_eq!(layout.size.height, 80.0000);
1739        assert_eq!(layout.location.x, 0.0000);
1740        assert_eq!(layout.location.y, 0.0000);
1741
1742        assert_eq!(layout.children[0].size.width, 20.0000);
1743        assert_eq!(layout.children[0].size.height, 0.0000);
1744        assert_eq!(layout.children[0].location.x, 0.0000);
1745        assert_eq!(layout.children[0].location.y, 100.0000);
1746    }
1747
1748    #[test]
1749    fn absolute_layout_width_height_start_top_end_bottom() {
1750        let layout = stretch::compute(
1751            &stretch::style::Node {
1752                size: stretch::geometry::Size {
1753                    width: stretch::style::Dimension::Points(100.0000),
1754                    height: stretch::style::Dimension::Points(100.0000),
1755                    ..Default::default()
1756                },
1757                children: vec![stretch::style::Node {
1758                    position_type: stretch::style::PositionType::Absolute,
1759                    size: stretch::geometry::Size {
1760                        width: stretch::style::Dimension::Points(10.0000),
1761                        height: stretch::style::Dimension::Points(10.0000),
1762                        ..Default::default()
1763                    },
1764                    position: stretch::geometry::Rect {
1765                        start: stretch::style::Dimension::Points(10.0000),
1766                        end: stretch::style::Dimension::Points(10.0000),
1767                        top: stretch::style::Dimension::Points(10.0000),
1768                        bottom: stretch::style::Dimension::Points(10.0000),
1769                        ..Default::default()
1770                    },
1771                    ..Default::default()
1772                }],
1773                ..Default::default()
1774            },
1775            stretch::geometry::Size::undefined(),
1776        );
1777
1778        assert_eq!(layout.size.width, 100.0000);
1779        assert_eq!(layout.size.height, 100.0000);
1780        assert_eq!(layout.location.x, 0.0000);
1781        assert_eq!(layout.location.y, 0.0000);
1782
1783        assert_eq!(layout.children[0].size.width, 10.0000);
1784        assert_eq!(layout.children[0].size.height, 10.0000);
1785        assert_eq!(layout.children[0].location.x, 10.0000);
1786        assert_eq!(layout.children[0].location.y, 10.0000);
1787    }
1788
1789    #[test]
1790    fn overflow_main_axis() {
1791        let layout = stretch::compute(
1792            &stretch::style::Node {
1793                size: stretch::geometry::Size {
1794                    width: stretch::style::Dimension::Points(100.0000),
1795                    height: stretch::style::Dimension::Points(100.0000),
1796                    ..Default::default()
1797                },
1798                children: vec![stretch::style::Node {
1799                    flex_shrink: 0.0000,
1800                    size: stretch::geometry::Size {
1801                        width: stretch::style::Dimension::Points(200.0000),
1802                        ..Default::default()
1803                    },
1804                    ..Default::default()
1805                }],
1806                ..Default::default()
1807            },
1808            stretch::geometry::Size::undefined(),
1809        );
1810
1811        assert_eq!(layout.size.width, 100.0000);
1812        assert_eq!(layout.size.height, 100.0000);
1813        assert_eq!(layout.location.x, 0.0000);
1814        assert_eq!(layout.location.y, 0.0000);
1815
1816        assert_eq!(layout.children[0].size.width, 200.0000);
1817        assert_eq!(layout.children[0].size.height, 100.0000);
1818        assert_eq!(layout.children[0].location.x, 0.0000);
1819        assert_eq!(layout.children[0].location.y, 0.0000);
1820    }
1821
1822    #[test]
1823    fn flex_grow_to_min() {
1824        let layout = stretch::compute(
1825            &stretch::style::Node {
1826                flex_direction: stretch::style::FlexDirection::Column,
1827                size: stretch::geometry::Size {
1828                    width: stretch::style::Dimension::Points(100.0000),
1829                    ..Default::default()
1830                },
1831                min_size: stretch::geometry::Size {
1832                    height: stretch::style::Dimension::Points(100.0000),
1833                    ..Default::default()
1834                },
1835                max_size: stretch::geometry::Size {
1836                    height: stretch::style::Dimension::Points(500.0000),
1837                    ..Default::default()
1838                },
1839                children: vec![
1840                    stretch::style::Node { flex_grow: 1.0000, flex_shrink: 1.0000, ..Default::default() },
1841                    stretch::style::Node {
1842                        size: stretch::geometry::Size {
1843                            height: stretch::style::Dimension::Points(50.0000),
1844                            ..Default::default()
1845                        },
1846                        ..Default::default()
1847                    },
1848                ],
1849                ..Default::default()
1850            },
1851            stretch::geometry::Size::undefined(),
1852        );
1853
1854        assert_eq!(layout.size.width, 100.0000);
1855        assert_eq!(layout.size.height, 100.0000);
1856        assert_eq!(layout.location.x, 0.0000);
1857        assert_eq!(layout.location.y, 0.0000);
1858
1859        assert_eq!(layout.children[0].size.width, 100.0000);
1860        assert_eq!(layout.children[0].size.height, 50.0000);
1861        assert_eq!(layout.children[0].location.x, 0.0000);
1862        assert_eq!(layout.children[0].location.y, 0.0000);
1863
1864        assert_eq!(layout.children[1].size.width, 100.0000);
1865        assert_eq!(layout.children[1].size.height, 50.0000);
1866        assert_eq!(layout.children[1].location.x, 0.0000);
1867        assert_eq!(layout.children[1].location.y, 50.0000);
1868    }
1869
1870    #[test]
1871    fn absolute_layout_align_items_and_justify_content_center_and_top_position() {
1872        let layout = stretch::compute(
1873            &stretch::style::Node {
1874                align_items: stretch::style::AlignItems::Center,
1875                justify_content: stretch::style::JustifyContent::Center,
1876                size: stretch::geometry::Size {
1877                    width: stretch::style::Dimension::Points(110.0000),
1878                    height: stretch::style::Dimension::Points(100.0000),
1879                    ..Default::default()
1880                },
1881                children: vec![stretch::style::Node {
1882                    position_type: stretch::style::PositionType::Absolute,
1883                    size: stretch::geometry::Size {
1884                        width: stretch::style::Dimension::Points(60.0000),
1885                        height: stretch::style::Dimension::Points(40.0000),
1886                        ..Default::default()
1887                    },
1888                    position: stretch::geometry::Rect {
1889                        top: stretch::style::Dimension::Points(10.0000),
1890                        ..Default::default()
1891                    },
1892                    ..Default::default()
1893                }],
1894                ..Default::default()
1895            },
1896            stretch::geometry::Size::undefined(),
1897        );
1898
1899        assert_eq!(layout.size.width, 110.0000);
1900        assert_eq!(layout.size.height, 100.0000);
1901        assert_eq!(layout.location.x, 0.0000);
1902        assert_eq!(layout.location.y, 0.0000);
1903
1904        assert_eq!(layout.children[0].size.width, 60.0000);
1905        assert_eq!(layout.children[0].size.height, 40.0000);
1906        assert_eq!(layout.children[0].location.x, 25.0000);
1907        assert_eq!(layout.children[0].location.y, 10.0000);
1908    }
1909
1910    #[test]
1911    fn min_height() {
1912        let layout = stretch::compute(
1913            &stretch::style::Node {
1914                flex_direction: stretch::style::FlexDirection::Column,
1915                size: stretch::geometry::Size {
1916                    width: stretch::style::Dimension::Points(100.0000),
1917                    height: stretch::style::Dimension::Points(100.0000),
1918                    ..Default::default()
1919                },
1920                children: vec![
1921                    stretch::style::Node {
1922                        flex_grow: 1.0000,
1923                        min_size: stretch::geometry::Size {
1924                            height: stretch::style::Dimension::Points(60.0000),
1925                            ..Default::default()
1926                        },
1927                        ..Default::default()
1928                    },
1929                    stretch::style::Node { flex_grow: 1.0000, ..Default::default() },
1930                ],
1931                ..Default::default()
1932            },
1933            stretch::geometry::Size::undefined(),
1934        );
1935
1936        assert_eq!(layout.size.width, 100.0000);
1937        assert_eq!(layout.size.height, 100.0000);
1938        assert_eq!(layout.location.x, 0.0000);
1939        assert_eq!(layout.location.y, 0.0000);
1940
1941        assert_eq!(layout.children[0].size.width, 100.0000);
1942        assert_eq!(layout.children[0].size.height, 80.0000);
1943        assert_eq!(layout.children[0].location.x, 0.0000);
1944        assert_eq!(layout.children[0].location.y, 0.0000);
1945
1946        assert_eq!(layout.children[1].size.width, 100.0000);
1947        assert_eq!(layout.children[1].size.height, 20.0000);
1948        assert_eq!(layout.children[1].location.x, 0.0000);
1949        assert_eq!(layout.children[1].location.y, 80.0000);
1950    }
1951
1952    #[test]
1953    fn justify_content_column_flex_start() {
1954        let layout = stretch::compute(
1955            &stretch::style::Node {
1956                flex_direction: stretch::style::FlexDirection::Column,
1957                size: stretch::geometry::Size {
1958                    width: stretch::style::Dimension::Points(100.0000),
1959                    height: stretch::style::Dimension::Points(100.0000),
1960                    ..Default::default()
1961                },
1962                children: vec![
1963                    stretch::style::Node {
1964                        size: stretch::geometry::Size {
1965                            height: stretch::style::Dimension::Points(10.0000),
1966                            ..Default::default()
1967                        },
1968                        ..Default::default()
1969                    },
1970                    stretch::style::Node {
1971                        size: stretch::geometry::Size {
1972                            height: stretch::style::Dimension::Points(10.0000),
1973                            ..Default::default()
1974                        },
1975                        ..Default::default()
1976                    },
1977                    stretch::style::Node {
1978                        size: stretch::geometry::Size {
1979                            height: stretch::style::Dimension::Points(10.0000),
1980                            ..Default::default()
1981                        },
1982                        ..Default::default()
1983                    },
1984                ],
1985                ..Default::default()
1986            },
1987            stretch::geometry::Size::undefined(),
1988        );
1989
1990        assert_eq!(layout.size.width, 100.0000);
1991        assert_eq!(layout.size.height, 100.0000);
1992        assert_eq!(layout.location.x, 0.0000);
1993        assert_eq!(layout.location.y, 0.0000);
1994
1995        assert_eq!(layout.children[0].size.width, 100.0000);
1996        assert_eq!(layout.children[0].size.height, 10.0000);
1997        assert_eq!(layout.children[0].location.x, 0.0000);
1998        assert_eq!(layout.children[0].location.y, 0.0000);
1999
2000        assert_eq!(layout.children[1].size.width, 100.0000);
2001        assert_eq!(layout.children[1].size.height, 10.0000);
2002        assert_eq!(layout.children[1].location.x, 0.0000);
2003        assert_eq!(layout.children[1].location.y, 10.0000);
2004
2005        assert_eq!(layout.children[2].size.width, 100.0000);
2006        assert_eq!(layout.children[2].size.height, 10.0000);
2007        assert_eq!(layout.children[2].location.x, 0.0000);
2008        assert_eq!(layout.children[2].location.y, 20.0000);
2009    }
2010
2011    #[test]
2012    fn absolute_layout_in_wrap_reverse_column_container() {
2013        let layout = stretch::compute(
2014            &stretch::style::Node {
2015                flex_direction: stretch::style::FlexDirection::Column,
2016                flex_wrap: stretch::style::FlexWrap::WrapReverse,
2017                size: stretch::geometry::Size {
2018                    width: stretch::style::Dimension::Points(100.0000),
2019                    height: stretch::style::Dimension::Points(100.0000),
2020                    ..Default::default()
2021                },
2022                children: vec![stretch::style::Node {
2023                    position_type: stretch::style::PositionType::Absolute,
2024                    size: stretch::geometry::Size {
2025                        width: stretch::style::Dimension::Points(20.0000),
2026                        height: stretch::style::Dimension::Points(20.0000),
2027                        ..Default::default()
2028                    },
2029                    ..Default::default()
2030                }],
2031                ..Default::default()
2032            },
2033            stretch::geometry::Size::undefined(),
2034        );
2035
2036        assert_eq!(layout.size.width, 100.0000);
2037        assert_eq!(layout.size.height, 100.0000);
2038        assert_eq!(layout.location.x, 0.0000);
2039        assert_eq!(layout.location.y, 0.0000);
2040
2041        assert_eq!(layout.children[0].size.width, 20.0000);
2042        assert_eq!(layout.children[0].size.height, 20.0000);
2043        assert_eq!(layout.children[0].location.x, 80.0000);
2044        assert_eq!(layout.children[0].location.y, 0.0000);
2045    }
2046
2047    #[test]
2048    fn margin_should_not_be_part_of_max_width() {
2049        let layout = stretch::compute(
2050            &stretch::style::Node {
2051                size: stretch::geometry::Size {
2052                    width: stretch::style::Dimension::Points(250.0000),
2053                    height: stretch::style::Dimension::Points(250.0000),
2054                    ..Default::default()
2055                },
2056                children: vec![stretch::style::Node {
2057                    size: stretch::geometry::Size {
2058                        width: stretch::style::Dimension::Points(100.0000),
2059                        height: stretch::style::Dimension::Points(100.0000),
2060                        ..Default::default()
2061                    },
2062                    max_size: stretch::geometry::Size {
2063                        width: stretch::style::Dimension::Points(100.0000),
2064                        ..Default::default()
2065                    },
2066                    margin: stretch::geometry::Rect {
2067                        start: stretch::style::Dimension::Points(20.0000),
2068                        ..Default::default()
2069                    },
2070                    ..Default::default()
2071                }],
2072                ..Default::default()
2073            },
2074            stretch::geometry::Size::undefined(),
2075        );
2076
2077        assert_eq!(layout.size.width, 250.0000);
2078        assert_eq!(layout.size.height, 250.0000);
2079        assert_eq!(layout.location.x, 0.0000);
2080        assert_eq!(layout.location.y, 0.0000);
2081
2082        assert_eq!(layout.children[0].size.width, 100.0000);
2083        assert_eq!(layout.children[0].size.height, 100.0000);
2084        assert_eq!(layout.children[0].location.x, 20.0000);
2085        assert_eq!(layout.children[0].location.y, 0.0000);
2086    }
2087
2088    #[test]
2089    fn absolute_layout_no_size() {
2090        let layout = stretch::compute(
2091            &stretch::style::Node {
2092                size: stretch::geometry::Size {
2093                    width: stretch::style::Dimension::Points(100.0000),
2094                    height: stretch::style::Dimension::Points(100.0000),
2095                    ..Default::default()
2096                },
2097                children: vec![stretch::style::Node {
2098                    position_type: stretch::style::PositionType::Absolute,
2099                    ..Default::default()
2100                }],
2101                ..Default::default()
2102            },
2103            stretch::geometry::Size::undefined(),
2104        );
2105
2106        assert_eq!(layout.size.width, 100.0000);
2107        assert_eq!(layout.size.height, 100.0000);
2108        assert_eq!(layout.location.x, 0.0000);
2109        assert_eq!(layout.location.y, 0.0000);
2110
2111        assert_eq!(layout.children[0].size.width, 0.0000);
2112        assert_eq!(layout.children[0].size.height, 0.0000);
2113        assert_eq!(layout.children[0].location.x, 0.0000);
2114        assert_eq!(layout.children[0].location.y, 0.0000);
2115    }
2116
2117    #[test]
2118    fn border_flex_child() {
2119        let layout = stretch::compute(
2120            &stretch::style::Node {
2121                size: stretch::geometry::Size {
2122                    width: stretch::style::Dimension::Points(100.0000),
2123                    height: stretch::style::Dimension::Points(100.0000),
2124                    ..Default::default()
2125                },
2126                border: stretch::geometry::Rect {
2127                    start: stretch::style::Dimension::Points(10.0000),
2128                    end: stretch::style::Dimension::Points(10.0000),
2129                    top: stretch::style::Dimension::Points(10.0000),
2130                    bottom: stretch::style::Dimension::Points(10.0000),
2131                    ..Default::default()
2132                },
2133                children: vec![stretch::style::Node {
2134                    flex_grow: 1.0000,
2135                    size: stretch::geometry::Size {
2136                        width: stretch::style::Dimension::Points(10.0000),
2137                        ..Default::default()
2138                    },
2139                    ..Default::default()
2140                }],
2141                ..Default::default()
2142            },
2143            stretch::geometry::Size::undefined(),
2144        );
2145
2146        assert_eq!(layout.size.width, 100.0000);
2147        assert_eq!(layout.size.height, 100.0000);
2148        assert_eq!(layout.location.x, 0.0000);
2149        assert_eq!(layout.location.y, 0.0000);
2150
2151        assert_eq!(layout.children[0].size.width, 80.0000);
2152        assert_eq!(layout.children[0].size.height, 80.0000);
2153        assert_eq!(layout.children[0].location.x, 10.0000);
2154        assert_eq!(layout.children[0].location.y, 10.0000);
2155    }
2156
2157    #[test]
2158    fn wrap_reverse_row() {
2159        let layout = stretch::compute(
2160            &stretch::style::Node {
2161                flex_wrap: stretch::style::FlexWrap::WrapReverse,
2162                size: stretch::geometry::Size {
2163                    width: stretch::style::Dimension::Points(100.0000),
2164                    ..Default::default()
2165                },
2166                children: vec![
2167                    stretch::style::Node {
2168                        size: stretch::geometry::Size {
2169                            width: stretch::style::Dimension::Points(31.0000),
2170                            height: stretch::style::Dimension::Points(30.0000),
2171                            ..Default::default()
2172                        },
2173                        ..Default::default()
2174                    },
2175                    stretch::style::Node {
2176                        size: stretch::geometry::Size {
2177                            width: stretch::style::Dimension::Points(32.0000),
2178                            height: stretch::style::Dimension::Points(30.0000),
2179                            ..Default::default()
2180                        },
2181                        ..Default::default()
2182                    },
2183                    stretch::style::Node {
2184                        size: stretch::geometry::Size {
2185                            width: stretch::style::Dimension::Points(33.0000),
2186                            height: stretch::style::Dimension::Points(30.0000),
2187                            ..Default::default()
2188                        },
2189                        ..Default::default()
2190                    },
2191                    stretch::style::Node {
2192                        size: stretch::geometry::Size {
2193                            width: stretch::style::Dimension::Points(34.0000),
2194                            height: stretch::style::Dimension::Points(30.0000),
2195                            ..Default::default()
2196                        },
2197                        ..Default::default()
2198                    },
2199                ],
2200                ..Default::default()
2201            },
2202            stretch::geometry::Size::undefined(),
2203        );
2204
2205        assert_eq!(layout.size.width, 100.0000);
2206        assert_eq!(layout.size.height, 60.0000);
2207        assert_eq!(layout.location.x, 0.0000);
2208        assert_eq!(layout.location.y, 0.0000);
2209
2210        assert_eq!(layout.children[0].size.width, 31.0000);
2211        assert_eq!(layout.children[0].size.height, 30.0000);
2212        assert_eq!(layout.children[0].location.x, 0.0000);
2213        assert_eq!(layout.children[0].location.y, 30.0000);
2214
2215        assert_eq!(layout.children[1].size.width, 32.0000);
2216        assert_eq!(layout.children[1].size.height, 30.0000);
2217        assert_eq!(layout.children[1].location.x, 31.0000);
2218        assert_eq!(layout.children[1].location.y, 30.0000);
2219
2220        assert_eq!(layout.children[2].size.width, 33.0000);
2221        assert_eq!(layout.children[2].size.height, 30.0000);
2222        assert_eq!(layout.children[2].location.x, 63.0000);
2223        assert_eq!(layout.children[2].location.y, 30.0000);
2224
2225        assert_eq!(layout.children[3].size.width, 34.0000);
2226        assert_eq!(layout.children[3].size.height, 30.0000);
2227        assert_eq!(layout.children[3].location.x, 0.0000);
2228        assert_eq!(layout.children[3].location.y, 0.0000);
2229    }
2230
2231    #[test]
2232    fn margin_right() {
2233        let layout = stretch::compute(
2234            &stretch::style::Node {
2235                justify_content: stretch::style::JustifyContent::FlexEnd,
2236                size: stretch::geometry::Size {
2237                    width: stretch::style::Dimension::Points(100.0000),
2238                    height: stretch::style::Dimension::Points(100.0000),
2239                    ..Default::default()
2240                },
2241                children: vec![stretch::style::Node {
2242                    size: stretch::geometry::Size {
2243                        width: stretch::style::Dimension::Points(10.0000),
2244                        ..Default::default()
2245                    },
2246                    margin: stretch::geometry::Rect {
2247                        end: stretch::style::Dimension::Points(10.0000),
2248                        ..Default::default()
2249                    },
2250                    ..Default::default()
2251                }],
2252                ..Default::default()
2253            },
2254            stretch::geometry::Size::undefined(),
2255        );
2256
2257        assert_eq!(layout.size.width, 100.0000);
2258        assert_eq!(layout.size.height, 100.0000);
2259        assert_eq!(layout.location.x, 0.0000);
2260        assert_eq!(layout.location.y, 0.0000);
2261
2262        assert_eq!(layout.children[0].size.width, 10.0000);
2263        assert_eq!(layout.children[0].size.height, 100.0000);
2264        assert_eq!(layout.children[0].location.x, 80.0000);
2265        assert_eq!(layout.children[0].location.y, 0.0000);
2266    }
2267
2268    #[test]
2269    fn display_none_with_child() {
2270        let layout = stretch::compute(
2271            &stretch::style::Node {
2272                size: stretch::geometry::Size {
2273                    width: stretch::style::Dimension::Points(100.0000),
2274                    height: stretch::style::Dimension::Points(100.0000),
2275                    ..Default::default()
2276                },
2277                children: vec![
2278                    stretch::style::Node {
2279                        flex_grow: 1.0000,
2280                        flex_shrink: 1.0000,
2281                        flex_basis: stretch::style::Dimension::Percent(0.0000),
2282                        ..Default::default()
2283                    },
2284                    stretch::style::Node {
2285                        display: stretch::style::Display::None,
2286                        flex_direction: stretch::style::FlexDirection::Column,
2287                        flex_grow: 1.0000,
2288                        flex_shrink: 1.0000,
2289                        flex_basis: stretch::style::Dimension::Percent(0.0000),
2290                        children: vec![stretch::style::Node {
2291                            flex_grow: 1.0000,
2292                            flex_shrink: 1.0000,
2293                            flex_basis: stretch::style::Dimension::Percent(0.0000),
2294                            size: stretch::geometry::Size {
2295                                width: stretch::style::Dimension::Points(20.0000),
2296                                ..Default::default()
2297                            },
2298                            ..Default::default()
2299                        }],
2300                        ..Default::default()
2301                    },
2302                    stretch::style::Node {
2303                        flex_grow: 1.0000,
2304                        flex_shrink: 1.0000,
2305                        flex_basis: stretch::style::Dimension::Percent(0.0000),
2306                        ..Default::default()
2307                    },
2308                ],
2309                ..Default::default()
2310            },
2311            stretch::geometry::Size::undefined(),
2312        );
2313
2314        assert_eq!(layout.size.width, 100.0000);
2315        assert_eq!(layout.size.height, 100.0000);
2316        assert_eq!(layout.location.x, 0.0000);
2317        assert_eq!(layout.location.y, 0.0000);
2318
2319        assert_eq!(layout.children[0].size.width, 50.0000);
2320        assert_eq!(layout.children[0].size.height, 100.0000);
2321        assert_eq!(layout.children[0].location.x, 0.0000);
2322        assert_eq!(layout.children[0].location.y, 0.0000);
2323
2324        assert_eq!(layout.children[1].size.width, 0.0000);
2325        assert_eq!(layout.children[1].size.height, 0.0000);
2326        assert_eq!(layout.children[1].location.x, 0.0000);
2327        assert_eq!(layout.children[1].location.y, 0.0000);
2328
2329        assert_eq!(layout.children[1].children[0].size.width, 0.0000);
2330        assert_eq!(layout.children[1].children[0].size.height, 0.0000);
2331        assert_eq!(layout.children[1].children[0].location.x, 0.0000);
2332        assert_eq!(layout.children[1].children[0].location.y, 0.0000);
2333
2334        assert_eq!(layout.children[2].size.width, 50.0000);
2335        assert_eq!(layout.children[2].size.height, 100.0000);
2336        assert_eq!(layout.children[2].location.x, 50.0000);
2337        assert_eq!(layout.children[2].location.y, 0.0000);
2338    }
2339
2340    #[test]
2341    fn align_flex_start_with_shrinking_children_with_stretch() {
2342        let layout = stretch::compute(
2343            &stretch::style::Node {
2344                size: stretch::geometry::Size {
2345                    width: stretch::style::Dimension::Points(500.0000),
2346                    height: stretch::style::Dimension::Points(500.0000),
2347                    ..Default::default()
2348                },
2349                children: vec![stretch::style::Node {
2350                    align_items: stretch::style::AlignItems::FlexStart,
2351                    children: vec![stretch::style::Node {
2352                        flex_grow: 1.0000,
2353                        flex_shrink: 1.0000,
2354                        children: vec![stretch::style::Node {
2355                            flex_grow: 1.0000,
2356                            flex_shrink: 1.0000,
2357                            ..Default::default()
2358                        }],
2359                        ..Default::default()
2360                    }],
2361                    ..Default::default()
2362                }],
2363                ..Default::default()
2364            },
2365            stretch::geometry::Size::undefined(),
2366        );
2367
2368        assert_eq!(layout.size.width, 500.0000);
2369        assert_eq!(layout.size.height, 500.0000);
2370        assert_eq!(layout.location.x, 0.0000);
2371        assert_eq!(layout.location.y, 0.0000);
2372
2373        assert_eq!(layout.children[0].size.width, 0.0000);
2374        assert_eq!(layout.children[0].size.height, 500.0000);
2375        assert_eq!(layout.children[0].location.x, 0.0000);
2376        assert_eq!(layout.children[0].location.y, 0.0000);
2377
2378        assert_eq!(layout.children[0].children[0].size.width, 0.0000);
2379        assert_eq!(layout.children[0].children[0].size.height, 0.0000);
2380        assert_eq!(layout.children[0].children[0].location.x, 0.0000);
2381        assert_eq!(layout.children[0].children[0].location.y, 0.0000);
2382
2383        assert_eq!(layout.children[0].children[0].children[0].size.width, 0.0000);
2384        assert_eq!(layout.children[0].children[0].children[0].size.height, 0.0000);
2385        assert_eq!(layout.children[0].children[0].children[0].location.x, 0.0000);
2386        assert_eq!(layout.children[0].children[0].children[0].location.y, 0.0000);
2387    }
2388
2389    #[test]
2390    fn flex_basis_smaller_then_content_with_flex_grow_large_size() {
2391        let layout = stretch::compute(
2392            &stretch::style::Node {
2393                size: stretch::geometry::Size {
2394                    width: stretch::style::Dimension::Points(100.0000),
2395                    ..Default::default()
2396                },
2397                children: vec![
2398                    stretch::style::Node {
2399                        flex_direction: stretch::style::FlexDirection::Column,
2400                        flex_grow: 1.0000,
2401                        flex_basis: stretch::style::Dimension::Points(0.0000),
2402                        children: vec![stretch::style::Node {
2403                            size: stretch::geometry::Size {
2404                                width: stretch::style::Dimension::Points(70.0000),
2405                                height: stretch::style::Dimension::Points(100.0000),
2406                                ..Default::default()
2407                            },
2408                            ..Default::default()
2409                        }],
2410                        ..Default::default()
2411                    },
2412                    stretch::style::Node {
2413                        flex_direction: stretch::style::FlexDirection::Column,
2414                        flex_grow: 1.0000,
2415                        flex_basis: stretch::style::Dimension::Points(0.0000),
2416                        children: vec![stretch::style::Node {
2417                            size: stretch::geometry::Size {
2418                                width: stretch::style::Dimension::Points(20.0000),
2419                                height: stretch::style::Dimension::Points(100.0000),
2420                                ..Default::default()
2421                            },
2422                            ..Default::default()
2423                        }],
2424                        ..Default::default()
2425                    },
2426                ],
2427                ..Default::default()
2428            },
2429            stretch::geometry::Size::undefined(),
2430        );
2431
2432        assert_eq!(layout.size.width, 100.0000);
2433        assert_eq!(layout.size.height, 100.0000);
2434        assert_eq!(layout.location.x, 0.0000);
2435        assert_eq!(layout.location.y, 0.0000);
2436
2437        assert_eq!(layout.children[0].size.width, 70.0000);
2438        assert_eq!(layout.children[0].size.height, 100.0000);
2439        assert_eq!(layout.children[0].location.x, 0.0000);
2440        assert_eq!(layout.children[0].location.y, 0.0000);
2441
2442        assert_eq!(layout.children[0].children[0].size.width, 70.0000);
2443        assert_eq!(layout.children[0].children[0].size.height, 100.0000);
2444        assert_eq!(layout.children[0].children[0].location.x, 0.0000);
2445        assert_eq!(layout.children[0].children[0].location.y, 0.0000);
2446
2447        assert_eq!(layout.children[1].size.width, 30.0000);
2448        assert_eq!(layout.children[1].size.height, 100.0000);
2449        assert_eq!(layout.children[1].location.x, 70.0000);
2450        assert_eq!(layout.children[1].location.y, 0.0000);
2451
2452        assert_eq!(layout.children[1].children[0].size.width, 20.0000);
2453        assert_eq!(layout.children[1].children[0].size.height, 100.0000);
2454        assert_eq!(layout.children[1].children[0].location.x, 0.0000);
2455        assert_eq!(layout.children[1].children[0].location.y, 0.0000);
2456    }
2457
2458    #[test]
2459    fn align_items_stretch() {
2460        let layout = stretch::compute(
2461            &stretch::style::Node {
2462                size: stretch::geometry::Size {
2463                    width: stretch::style::Dimension::Points(100.0000),
2464                    height: stretch::style::Dimension::Points(100.0000),
2465                    ..Default::default()
2466                },
2467                children: vec![stretch::style::Node {
2468                    size: stretch::geometry::Size {
2469                        width: stretch::style::Dimension::Points(10.0000),
2470                        ..Default::default()
2471                    },
2472                    ..Default::default()
2473                }],
2474                ..Default::default()
2475            },
2476            stretch::geometry::Size::undefined(),
2477        );
2478
2479        assert_eq!(layout.size.width, 100.0000);
2480        assert_eq!(layout.size.height, 100.0000);
2481        assert_eq!(layout.location.x, 0.0000);
2482        assert_eq!(layout.location.y, 0.0000);
2483
2484        assert_eq!(layout.children[0].size.width, 10.0000);
2485        assert_eq!(layout.children[0].size.height, 100.0000);
2486        assert_eq!(layout.children[0].location.x, 0.0000);
2487        assert_eq!(layout.children[0].location.y, 0.0000);
2488    }
2489
2490    #[test]
2491    fn parent_wrap_child_size_overflowing_parent() {
2492        let layout = stretch::compute(
2493            &stretch::style::Node {
2494                size: stretch::geometry::Size {
2495                    width: stretch::style::Dimension::Points(100.0000),
2496                    height: stretch::style::Dimension::Points(100.0000),
2497                    ..Default::default()
2498                },
2499                children: vec![stretch::style::Node {
2500                    size: stretch::geometry::Size {
2501                        width: stretch::style::Dimension::Points(100.0000),
2502                        ..Default::default()
2503                    },
2504                    children: vec![stretch::style::Node {
2505                        size: stretch::geometry::Size {
2506                            width: stretch::style::Dimension::Points(100.0000),
2507                            height: stretch::style::Dimension::Points(200.0000),
2508                            ..Default::default()
2509                        },
2510                        ..Default::default()
2511                    }],
2512                    ..Default::default()
2513                }],
2514                ..Default::default()
2515            },
2516            stretch::geometry::Size::undefined(),
2517        );
2518
2519        assert_eq!(layout.size.width, 100.0000);
2520        assert_eq!(layout.size.height, 100.0000);
2521        assert_eq!(layout.location.x, 0.0000);
2522        assert_eq!(layout.location.y, 0.0000);
2523
2524        assert_eq!(layout.children[0].size.width, 100.0000);
2525        assert_eq!(layout.children[0].size.height, 100.0000);
2526        assert_eq!(layout.children[0].location.x, 0.0000);
2527        assert_eq!(layout.children[0].location.y, 0.0000);
2528
2529        assert_eq!(layout.children[0].children[0].size.width, 100.0000);
2530        assert_eq!(layout.children[0].children[0].size.height, 200.0000);
2531        assert_eq!(layout.children[0].children[0].location.x, 0.0000);
2532        assert_eq!(layout.children[0].children[0].location.y, 0.0000);
2533    }
2534
2535    #[test]
2536    fn padding_stretch_child() {
2537        let layout = stretch::compute(
2538            &stretch::style::Node {
2539                size: stretch::geometry::Size {
2540                    width: stretch::style::Dimension::Points(100.0000),
2541                    height: stretch::style::Dimension::Points(100.0000),
2542                    ..Default::default()
2543                },
2544                padding: stretch::geometry::Rect {
2545                    start: stretch::style::Dimension::Points(10.0000),
2546                    end: stretch::style::Dimension::Points(10.0000),
2547                    top: stretch::style::Dimension::Points(10.0000),
2548                    bottom: stretch::style::Dimension::Points(10.0000),
2549                    ..Default::default()
2550                },
2551                children: vec![stretch::style::Node {
2552                    size: stretch::geometry::Size {
2553                        height: stretch::style::Dimension::Points(10.0000),
2554                        ..Default::default()
2555                    },
2556                    ..Default::default()
2557                }],
2558                ..Default::default()
2559            },
2560            stretch::geometry::Size::undefined(),
2561        );
2562
2563        assert_eq!(layout.size.width, 100.0000);
2564        assert_eq!(layout.size.height, 100.0000);
2565        assert_eq!(layout.location.x, 0.0000);
2566        assert_eq!(layout.location.y, 0.0000);
2567
2568        assert_eq!(layout.children[0].size.width, 0.0000);
2569        assert_eq!(layout.children[0].size.height, 10.0000);
2570        assert_eq!(layout.children[0].location.x, 10.0000);
2571        assert_eq!(layout.children[0].location.y, 10.0000);
2572    }
2573
2574    #[test]
2575    fn wrap_nodes_with_content_sizing_overflowing_margin() {
2576        let layout = stretch::compute(
2577            &stretch::style::Node {
2578                flex_direction: stretch::style::FlexDirection::Column,
2579                size: stretch::geometry::Size {
2580                    width: stretch::style::Dimension::Points(500.0000),
2581                    height: stretch::style::Dimension::Points(500.0000),
2582                    ..Default::default()
2583                },
2584                children: vec![stretch::style::Node {
2585                    flex_wrap: stretch::style::FlexWrap::Wrap,
2586                    size: stretch::geometry::Size {
2587                        width: stretch::style::Dimension::Points(85.0000),
2588                        ..Default::default()
2589                    },
2590                    children: vec![
2591                        stretch::style::Node {
2592                            flex_direction: stretch::style::FlexDirection::Column,
2593                            children: vec![stretch::style::Node {
2594                                size: stretch::geometry::Size {
2595                                    width: stretch::style::Dimension::Points(40.0000),
2596                                    height: stretch::style::Dimension::Points(40.0000),
2597                                    ..Default::default()
2598                                },
2599                                ..Default::default()
2600                            }],
2601                            ..Default::default()
2602                        },
2603                        stretch::style::Node {
2604                            flex_direction: stretch::style::FlexDirection::Column,
2605                            margin: stretch::geometry::Rect {
2606                                end: stretch::style::Dimension::Points(10.0000),
2607                                ..Default::default()
2608                            },
2609                            children: vec![stretch::style::Node {
2610                                size: stretch::geometry::Size {
2611                                    width: stretch::style::Dimension::Points(40.0000),
2612                                    height: stretch::style::Dimension::Points(40.0000),
2613                                    ..Default::default()
2614                                },
2615                                ..Default::default()
2616                            }],
2617                            ..Default::default()
2618                        },
2619                    ],
2620                    ..Default::default()
2621                }],
2622                ..Default::default()
2623            },
2624            stretch::geometry::Size::undefined(),
2625        );
2626
2627        assert_eq!(layout.size.width, 500.0000);
2628        assert_eq!(layout.size.height, 500.0000);
2629        assert_eq!(layout.location.x, 0.0000);
2630        assert_eq!(layout.location.y, 0.0000);
2631
2632        assert_eq!(layout.children[0].size.width, 85.0000);
2633        assert_eq!(layout.children[0].size.height, 80.0000);
2634        assert_eq!(layout.children[0].location.x, 0.0000);
2635        assert_eq!(layout.children[0].location.y, 0.0000);
2636
2637        assert_eq!(layout.children[0].children[0].size.width, 40.0000);
2638        assert_eq!(layout.children[0].children[0].size.height, 40.0000);
2639        assert_eq!(layout.children[0].children[0].location.x, 0.0000);
2640        assert_eq!(layout.children[0].children[0].location.y, 0.0000);
2641
2642        assert_eq!(layout.children[0].children[0].children[0].size.width, 40.0000);
2643        assert_eq!(layout.children[0].children[0].children[0].size.height, 40.0000);
2644        assert_eq!(layout.children[0].children[0].children[0].location.x, 0.0000);
2645        assert_eq!(layout.children[0].children[0].children[0].location.y, 0.0000);
2646
2647        assert_eq!(layout.children[0].children[1].size.width, 40.0000);
2648        assert_eq!(layout.children[0].children[1].size.height, 40.0000);
2649        assert_eq!(layout.children[0].children[1].location.x, 0.0000);
2650        assert_eq!(layout.children[0].children[1].location.y, 40.0000);
2651
2652        assert_eq!(layout.children[0].children[1].children[0].size.width, 40.0000);
2653        assert_eq!(layout.children[0].children[1].children[0].size.height, 40.0000);
2654        assert_eq!(layout.children[0].children[1].children[0].location.x, 0.0000);
2655        assert_eq!(layout.children[0].children[1].children[0].location.y, 0.0000);
2656    }
2657
2658    #[test]
2659    fn flex_shrink_flex_grow_row() {
2660        let layout = stretch::compute(
2661            &stretch::style::Node {
2662                size: stretch::geometry::Size {
2663                    width: stretch::style::Dimension::Points(500.0000),
2664                    height: stretch::style::Dimension::Points(500.0000),
2665                    ..Default::default()
2666                },
2667                children: vec![
2668                    stretch::style::Node {
2669                        flex_grow: 0.0000,
2670                        flex_shrink: 1.0000,
2671                        size: stretch::geometry::Size {
2672                            width: stretch::style::Dimension::Points(500.0000),
2673                            height: stretch::style::Dimension::Points(100.0000),
2674                            ..Default::default()
2675                        },
2676                        ..Default::default()
2677                    },
2678                    stretch::style::Node {
2679                        flex_grow: 0.0000,
2680                        flex_shrink: 1.0000,
2681                        size: stretch::geometry::Size {
2682                            width: stretch::style::Dimension::Points(500.0000),
2683                            height: stretch::style::Dimension::Points(100.0000),
2684                            ..Default::default()
2685                        },
2686                        ..Default::default()
2687                    },
2688                ],
2689                ..Default::default()
2690            },
2691            stretch::geometry::Size::undefined(),
2692        );
2693
2694        assert_eq!(layout.size.width, 500.0000);
2695        assert_eq!(layout.size.height, 500.0000);
2696        assert_eq!(layout.location.x, 0.0000);
2697        assert_eq!(layout.location.y, 0.0000);
2698
2699        assert_eq!(layout.children[0].size.width, 250.0000);
2700        assert_eq!(layout.children[0].size.height, 100.0000);
2701        assert_eq!(layout.children[0].location.x, 0.0000);
2702        assert_eq!(layout.children[0].location.y, 0.0000);
2703
2704        assert_eq!(layout.children[1].size.width, 250.0000);
2705        assert_eq!(layout.children[1].size.height, 100.0000);
2706        assert_eq!(layout.children[1].location.x, 250.0000);
2707        assert_eq!(layout.children[1].location.y, 0.0000);
2708    }
2709
2710    #[test]
2711    fn flex_basis_flex_shrink_column() {
2712        let layout = stretch::compute(
2713            &stretch::style::Node {
2714                flex_direction: stretch::style::FlexDirection::Column,
2715                size: stretch::geometry::Size {
2716                    width: stretch::style::Dimension::Points(100.0000),
2717                    height: stretch::style::Dimension::Points(100.0000),
2718                    ..Default::default()
2719                },
2720                children: vec![
2721                    stretch::style::Node {
2722                        flex_basis: stretch::style::Dimension::Points(100.0000),
2723                        ..Default::default()
2724                    },
2725                    stretch::style::Node {
2726                        flex_basis: stretch::style::Dimension::Points(50.0000),
2727                        ..Default::default()
2728                    },
2729                ],
2730                ..Default::default()
2731            },
2732            stretch::geometry::Size::undefined(),
2733        );
2734
2735        assert_eq!(layout.size.width, 100.0000);
2736        assert_eq!(layout.size.height, 100.0000);
2737        assert_eq!(layout.location.x, 0.0000);
2738        assert_eq!(layout.location.y, 0.0000);
2739
2740        assert_eq!(layout.children[0].size.width, 100.0000);
2741        assert_eq!(layout.children[0].size.height, 67.0000);
2742        assert_eq!(layout.children[0].location.x, 0.0000);
2743        assert_eq!(layout.children[0].location.y, 0.0000);
2744
2745        assert_eq!(layout.children[1].size.width, 100.0000);
2746        assert_eq!(layout.children[1].size.height, 33.0000);
2747        assert_eq!(layout.children[1].location.x, 0.0000);
2748        assert_eq!(layout.children[1].location.y, 67.0000);
2749    }
2750
2751    #[test]
2752    fn align_items_min_max() {
2753        let layout = stretch::compute(
2754            &stretch::style::Node {
2755                flex_direction: stretch::style::FlexDirection::Column,
2756                align_items: stretch::style::AlignItems::Center,
2757                size: stretch::geometry::Size {
2758                    height: stretch::style::Dimension::Points(100.0000),
2759                    ..Default::default()
2760                },
2761                min_size: stretch::geometry::Size {
2762                    width: stretch::style::Dimension::Points(100.0000),
2763                    ..Default::default()
2764                },
2765                max_size: stretch::geometry::Size {
2766                    width: stretch::style::Dimension::Points(200.0000),
2767                    ..Default::default()
2768                },
2769                children: vec![stretch::style::Node {
2770                    size: stretch::geometry::Size {
2771                        width: stretch::style::Dimension::Points(60.0000),
2772                        height: stretch::style::Dimension::Points(60.0000),
2773                        ..Default::default()
2774                    },
2775                    ..Default::default()
2776                }],
2777                ..Default::default()
2778            },
2779            stretch::geometry::Size::undefined(),
2780        );
2781
2782        assert_eq!(layout.size.width, 100.0000);
2783        assert_eq!(layout.size.height, 100.0000);
2784        assert_eq!(layout.location.x, 0.0000);
2785        assert_eq!(layout.location.y, 0.0000);
2786
2787        assert_eq!(layout.children[0].size.width, 60.0000);
2788        assert_eq!(layout.children[0].size.height, 60.0000);
2789        assert_eq!(layout.children[0].location.x, 20.0000);
2790        assert_eq!(layout.children[0].location.y, 0.0000);
2791    }
2792
2793    #[test]
2794    fn flex_basis_smaller_then_content_with_flex_grow_unconstraint_size() {
2795        let layout = stretch::compute(
2796            &stretch::style::Node {
2797                children: vec![
2798                    stretch::style::Node {
2799                        flex_direction: stretch::style::FlexDirection::Column,
2800                        flex_grow: 1.0000,
2801                        flex_basis: stretch::style::Dimension::Points(0.0000),
2802                        children: vec![stretch::style::Node {
2803                            size: stretch::geometry::Size {
2804                                width: stretch::style::Dimension::Points(70.0000),
2805                                height: stretch::style::Dimension::Points(100.0000),
2806                                ..Default::default()
2807                            },
2808                            ..Default::default()
2809                        }],
2810                        ..Default::default()
2811                    },
2812                    stretch::style::Node {
2813                        flex_direction: stretch::style::FlexDirection::Column,
2814                        flex_grow: 1.0000,
2815                        flex_basis: stretch::style::Dimension::Points(0.0000),
2816                        children: vec![stretch::style::Node {
2817                            size: stretch::geometry::Size {
2818                                width: stretch::style::Dimension::Points(20.0000),
2819                                height: stretch::style::Dimension::Points(100.0000),
2820                                ..Default::default()
2821                            },
2822                            ..Default::default()
2823                        }],
2824                        ..Default::default()
2825                    },
2826                ],
2827                ..Default::default()
2828            },
2829            stretch::geometry::Size::undefined(),
2830        );
2831
2832        assert_eq!(layout.size.width, 90.0000);
2833        assert_eq!(layout.size.height, 100.0000);
2834        assert_eq!(layout.location.x, 0.0000);
2835        assert_eq!(layout.location.y, 0.0000);
2836
2837        assert_eq!(layout.children[0].size.width, 70.0000);
2838        assert_eq!(layout.children[0].size.height, 100.0000);
2839        assert_eq!(layout.children[0].location.x, 0.0000);
2840        assert_eq!(layout.children[0].location.y, 0.0000);
2841
2842        assert_eq!(layout.children[0].children[0].size.width, 70.0000);
2843        assert_eq!(layout.children[0].children[0].size.height, 100.0000);
2844        assert_eq!(layout.children[0].children[0].location.x, 0.0000);
2845        assert_eq!(layout.children[0].children[0].location.y, 0.0000);
2846
2847        assert_eq!(layout.children[1].size.width, 20.0000);
2848        assert_eq!(layout.children[1].size.height, 100.0000);
2849        assert_eq!(layout.children[1].location.x, 70.0000);
2850        assert_eq!(layout.children[1].location.y, 0.0000);
2851
2852        assert_eq!(layout.children[1].children[0].size.width, 20.0000);
2853        assert_eq!(layout.children[1].children[0].size.height, 100.0000);
2854        assert_eq!(layout.children[1].children[0].location.x, 0.0000);
2855        assert_eq!(layout.children[1].children[0].location.y, 0.0000);
2856    }
2857
2858    #[test]
2859    fn justify_content_row_min_width_and_margin() {
2860        let layout = stretch::compute(
2861            &stretch::style::Node {
2862                justify_content: stretch::style::JustifyContent::Center,
2863                min_size: stretch::geometry::Size {
2864                    width: stretch::style::Dimension::Points(50.0000),
2865                    ..Default::default()
2866                },
2867                children: vec![stretch::style::Node {
2868                    size: stretch::geometry::Size {
2869                        width: stretch::style::Dimension::Points(20.0000),
2870                        height: stretch::style::Dimension::Points(20.0000),
2871                        ..Default::default()
2872                    },
2873                    margin: stretch::geometry::Rect {
2874                        start: stretch::style::Dimension::Points(10.0000),
2875                        ..Default::default()
2876                    },
2877                    ..Default::default()
2878                }],
2879                ..Default::default()
2880            },
2881            stretch::geometry::Size::undefined(),
2882        );
2883
2884        assert_eq!(layout.size.width, 50.0000);
2885        assert_eq!(layout.size.height, 20.0000);
2886        assert_eq!(layout.location.x, 0.0000);
2887        assert_eq!(layout.location.y, 0.0000);
2888
2889        assert_eq!(layout.children[0].size.width, 20.0000);
2890        assert_eq!(layout.children[0].size.height, 20.0000);
2891        assert_eq!(layout.children[0].location.x, 20.0000);
2892        assert_eq!(layout.children[0].location.y, 0.0000);
2893    }
2894
2895    #[test]
2896    fn align_self_flex_start() {
2897        let layout = stretch::compute(
2898            &stretch::style::Node {
2899                size: stretch::geometry::Size {
2900                    width: stretch::style::Dimension::Points(100.0000),
2901                    height: stretch::style::Dimension::Points(100.0000),
2902                    ..Default::default()
2903                },
2904                children: vec![stretch::style::Node {
2905                    align_self: stretch::style::AlignSelf::FlexStart,
2906                    size: stretch::geometry::Size {
2907                        width: stretch::style::Dimension::Points(10.0000),
2908                        height: stretch::style::Dimension::Points(10.0000),
2909                        ..Default::default()
2910                    },
2911                    ..Default::default()
2912                }],
2913                ..Default::default()
2914            },
2915            stretch::geometry::Size::undefined(),
2916        );
2917
2918        assert_eq!(layout.size.width, 100.0000);
2919        assert_eq!(layout.size.height, 100.0000);
2920        assert_eq!(layout.location.x, 0.0000);
2921        assert_eq!(layout.location.y, 0.0000);
2922
2923        assert_eq!(layout.children[0].size.width, 10.0000);
2924        assert_eq!(layout.children[0].size.height, 10.0000);
2925        assert_eq!(layout.children[0].location.x, 0.0000);
2926        assert_eq!(layout.children[0].location.y, 0.0000);
2927    }
2928
2929    #[test]
2930    fn percentage_position_left_top() {
2931        let layout = stretch::compute(
2932            &stretch::style::Node {
2933                size: stretch::geometry::Size {
2934                    width: stretch::style::Dimension::Points(400.0000),
2935                    height: stretch::style::Dimension::Points(400.0000),
2936                    ..Default::default()
2937                },
2938                children: vec![stretch::style::Node {
2939                    size: stretch::geometry::Size {
2940                        width: stretch::style::Dimension::Percent(0.4500),
2941                        height: stretch::style::Dimension::Percent(0.5500),
2942                        ..Default::default()
2943                    },
2944                    position: stretch::geometry::Rect {
2945                        start: stretch::style::Dimension::Percent(0.1000),
2946                        top: stretch::style::Dimension::Percent(0.2000),
2947                        ..Default::default()
2948                    },
2949                    ..Default::default()
2950                }],
2951                ..Default::default()
2952            },
2953            stretch::geometry::Size::undefined(),
2954        );
2955
2956        assert_eq!(layout.size.width, 400.0000);
2957        assert_eq!(layout.size.height, 400.0000);
2958        assert_eq!(layout.location.x, 0.0000);
2959        assert_eq!(layout.location.y, 0.0000);
2960
2961        assert_eq!(layout.children[0].size.width, 180.0000);
2962        assert_eq!(layout.children[0].size.height, 220.0000);
2963        assert_eq!(layout.children[0].location.x, 40.0000);
2964        assert_eq!(layout.children[0].location.y, 80.0000);
2965    }
2966
2967    #[test]
2968    fn border_stretch_child() {
2969        let layout = stretch::compute(
2970            &stretch::style::Node {
2971                size: stretch::geometry::Size {
2972                    width: stretch::style::Dimension::Points(100.0000),
2973                    height: stretch::style::Dimension::Points(100.0000),
2974                    ..Default::default()
2975                },
2976                border: stretch::geometry::Rect {
2977                    start: stretch::style::Dimension::Points(10.0000),
2978                    end: stretch::style::Dimension::Points(10.0000),
2979                    top: stretch::style::Dimension::Points(10.0000),
2980                    bottom: stretch::style::Dimension::Points(10.0000),
2981                    ..Default::default()
2982                },
2983                children: vec![stretch::style::Node {
2984                    size: stretch::geometry::Size {
2985                        width: stretch::style::Dimension::Points(10.0000),
2986                        ..Default::default()
2987                    },
2988                    ..Default::default()
2989                }],
2990                ..Default::default()
2991            },
2992            stretch::geometry::Size::undefined(),
2993        );
2994
2995        assert_eq!(layout.size.width, 100.0000);
2996        assert_eq!(layout.size.height, 100.0000);
2997        assert_eq!(layout.location.x, 0.0000);
2998        assert_eq!(layout.location.y, 0.0000);
2999
3000        assert_eq!(layout.children[0].size.width, 10.0000);
3001        assert_eq!(layout.children[0].size.height, 80.0000);
3002        assert_eq!(layout.children[0].location.x, 10.0000);
3003        assert_eq!(layout.children[0].location.y, 10.0000);
3004    }
3005
3006    #[test]
3007    fn rounding_fractial_input_2() {
3008        let layout = stretch::compute(
3009            &stretch::style::Node {
3010                flex_direction: stretch::style::FlexDirection::Column,
3011                size: stretch::geometry::Size {
3012                    width: stretch::style::Dimension::Points(100.0000),
3013                    height: stretch::style::Dimension::Points(113.6000),
3014                    ..Default::default()
3015                },
3016                children: vec![
3017                    stretch::style::Node {
3018                        flex_grow: 1.0000,
3019                        flex_basis: stretch::style::Dimension::Points(50.0000),
3020                        size: stretch::geometry::Size {
3021                            height: stretch::style::Dimension::Points(20.0000),
3022                            ..Default::default()
3023                        },
3024                        ..Default::default()
3025                    },
3026                    stretch::style::Node {
3027                        flex_grow: 1.0000,
3028                        size: stretch::geometry::Size {
3029                            height: stretch::style::Dimension::Points(10.0000),
3030                            ..Default::default()
3031                        },
3032                        ..Default::default()
3033                    },
3034                    stretch::style::Node {
3035                        flex_grow: 1.0000,
3036                        size: stretch::geometry::Size {
3037                            height: stretch::style::Dimension::Points(10.0000),
3038                            ..Default::default()
3039                        },
3040                        ..Default::default()
3041                    },
3042                ],
3043                ..Default::default()
3044            },
3045            stretch::geometry::Size::undefined(),
3046        );
3047
3048        assert_eq!(layout.size.width, 100.0000);
3049        assert_eq!(layout.size.height, 114.0000);
3050        assert_eq!(layout.location.x, 0.0000);
3051        assert_eq!(layout.location.y, 0.0000);
3052
3053        assert_eq!(layout.children[0].size.width, 100.0000);
3054        assert_eq!(layout.children[0].size.height, 65.0000);
3055        assert_eq!(layout.children[0].location.x, 0.0000);
3056        assert_eq!(layout.children[0].location.y, 0.0000);
3057
3058        assert_eq!(layout.children[1].size.width, 100.0000);
3059        assert_eq!(layout.children[1].size.height, 24.0000);
3060        assert_eq!(layout.children[1].location.x, 0.0000);
3061        assert_eq!(layout.children[1].location.y, 65.0000);
3062
3063        assert_eq!(layout.children[2].size.width, 100.0000);
3064        assert_eq!(layout.children[2].size.height, 25.0000);
3065        assert_eq!(layout.children[2].location.x, 0.0000);
3066        assert_eq!(layout.children[2].location.y, 89.0000);
3067    }
3068
3069    #[test]
3070    fn percentage_flex_basis_main_max_width() {
3071        let layout = stretch::compute(
3072            &stretch::style::Node {
3073                size: stretch::geometry::Size {
3074                    width: stretch::style::Dimension::Points(200.0000),
3075                    height: stretch::style::Dimension::Points(400.0000),
3076                    ..Default::default()
3077                },
3078                children: vec![
3079                    stretch::style::Node {
3080                        flex_grow: 1.0000,
3081                        flex_basis: stretch::style::Dimension::Percent(0.1500),
3082                        max_size: stretch::geometry::Size {
3083                            width: stretch::style::Dimension::Percent(0.6000),
3084                            ..Default::default()
3085                        },
3086                        ..Default::default()
3087                    },
3088                    stretch::style::Node {
3089                        flex_grow: 4.0000,
3090                        flex_basis: stretch::style::Dimension::Percent(0.1000),
3091                        max_size: stretch::geometry::Size {
3092                            width: stretch::style::Dimension::Percent(0.2000),
3093                            ..Default::default()
3094                        },
3095                        ..Default::default()
3096                    },
3097                ],
3098                ..Default::default()
3099            },
3100            stretch::geometry::Size::undefined(),
3101        );
3102
3103        assert_eq!(layout.size.width, 200.0000);
3104        assert_eq!(layout.size.height, 400.0000);
3105        assert_eq!(layout.location.x, 0.0000);
3106        assert_eq!(layout.location.y, 0.0000);
3107
3108        assert_eq!(layout.children[0].size.width, 120.0000);
3109        assert_eq!(layout.children[0].size.height, 400.0000);
3110        assert_eq!(layout.children[0].location.x, 0.0000);
3111        assert_eq!(layout.children[0].location.y, 0.0000);
3112
3113        assert_eq!(layout.children[1].size.width, 40.0000);
3114        assert_eq!(layout.children[1].size.height, 400.0000);
3115        assert_eq!(layout.children[1].location.x, 120.0000);
3116        assert_eq!(layout.children[1].location.y, 0.0000);
3117    }
3118
3119    #[test]
3120    fn margin_auto_top_and_bottom_strech() {
3121        let layout = stretch::compute(
3122            &stretch::style::Node {
3123                flex_direction: stretch::style::FlexDirection::Column,
3124                size: stretch::geometry::Size {
3125                    width: stretch::style::Dimension::Points(200.0000),
3126                    height: stretch::style::Dimension::Points(200.0000),
3127                    ..Default::default()
3128                },
3129                children: vec![
3130                    stretch::style::Node {
3131                        size: stretch::geometry::Size {
3132                            width: stretch::style::Dimension::Points(50.0000),
3133                            height: stretch::style::Dimension::Points(50.0000),
3134                            ..Default::default()
3135                        },
3136                        margin: stretch::geometry::Rect {
3137                            top: stretch::style::Dimension::Auto,
3138                            bottom: stretch::style::Dimension::Auto,
3139                            ..Default::default()
3140                        },
3141                        ..Default::default()
3142                    },
3143                    stretch::style::Node {
3144                        size: stretch::geometry::Size {
3145                            width: stretch::style::Dimension::Points(50.0000),
3146                            height: stretch::style::Dimension::Points(50.0000),
3147                            ..Default::default()
3148                        },
3149                        ..Default::default()
3150                    },
3151                ],
3152                ..Default::default()
3153            },
3154            stretch::geometry::Size::undefined(),
3155        );
3156
3157        assert_eq!(layout.size.width, 200.0000);
3158        assert_eq!(layout.size.height, 200.0000);
3159        assert_eq!(layout.location.x, 0.0000);
3160        assert_eq!(layout.location.y, 0.0000);
3161
3162        assert_eq!(layout.children[0].size.width, 50.0000);
3163        assert_eq!(layout.children[0].size.height, 50.0000);
3164        assert_eq!(layout.children[0].location.x, 0.0000);
3165        assert_eq!(layout.children[0].location.y, 50.0000);
3166
3167        assert_eq!(layout.children[1].size.width, 50.0000);
3168        assert_eq!(layout.children[1].size.height, 50.0000);
3169        assert_eq!(layout.children[1].location.x, 0.0000);
3170        assert_eq!(layout.children[1].location.y, 150.0000);
3171    }
3172
3173    #[test]
3174    fn percentage_multiple_nested_with_padding_margin_and_percentage_values() {
3175        let layout = stretch::compute(
3176            &stretch::style::Node {
3177                flex_direction: stretch::style::FlexDirection::Column,
3178                size: stretch::geometry::Size {
3179                    width: stretch::style::Dimension::Points(200.0000),
3180                    height: stretch::style::Dimension::Points(200.0000),
3181                    ..Default::default()
3182                },
3183                children: vec![
3184                    stretch::style::Node {
3185                        flex_direction: stretch::style::FlexDirection::Column,
3186                        flex_grow: 1.0000,
3187                        flex_basis: stretch::style::Dimension::Percent(0.1000),
3188                        min_size: stretch::geometry::Size {
3189                            width: stretch::style::Dimension::Percent(0.6000),
3190                            ..Default::default()
3191                        },
3192                        margin: stretch::geometry::Rect {
3193                            start: stretch::style::Dimension::Points(5.0000),
3194                            end: stretch::style::Dimension::Points(5.0000),
3195                            top: stretch::style::Dimension::Points(5.0000),
3196                            bottom: stretch::style::Dimension::Points(5.0000),
3197                            ..Default::default()
3198                        },
3199                        padding: stretch::geometry::Rect {
3200                            start: stretch::style::Dimension::Points(3.0000),
3201                            end: stretch::style::Dimension::Points(3.0000),
3202                            top: stretch::style::Dimension::Points(3.0000),
3203                            bottom: stretch::style::Dimension::Points(3.0000),
3204                            ..Default::default()
3205                        },
3206                        children: vec![stretch::style::Node {
3207                            flex_direction: stretch::style::FlexDirection::Column,
3208                            size: stretch::geometry::Size {
3209                                width: stretch::style::Dimension::Percent(0.5000),
3210                                ..Default::default()
3211                            },
3212                            margin: stretch::geometry::Rect {
3213                                start: stretch::style::Dimension::Points(5.0000),
3214                                end: stretch::style::Dimension::Points(5.0000),
3215                                top: stretch::style::Dimension::Points(5.0000),
3216                                bottom: stretch::style::Dimension::Points(5.0000),
3217                                ..Default::default()
3218                            },
3219                            padding: stretch::geometry::Rect {
3220                                start: stretch::style::Dimension::Percent(0.0300),
3221                                end: stretch::style::Dimension::Percent(0.0300),
3222                                top: stretch::style::Dimension::Percent(0.0300),
3223                                bottom: stretch::style::Dimension::Percent(0.0300),
3224                                ..Default::default()
3225                            },
3226                            children: vec![stretch::style::Node {
3227                                size: stretch::geometry::Size {
3228                                    width: stretch::style::Dimension::Percent(0.4500),
3229                                    ..Default::default()
3230                                },
3231                                margin: stretch::geometry::Rect {
3232                                    start: stretch::style::Dimension::Percent(0.0500),
3233                                    end: stretch::style::Dimension::Percent(0.0500),
3234                                    top: stretch::style::Dimension::Percent(0.0500),
3235                                    bottom: stretch::style::Dimension::Percent(0.0500),
3236                                    ..Default::default()
3237                                },
3238                                padding: stretch::geometry::Rect {
3239                                    start: stretch::style::Dimension::Points(3.0000),
3240                                    end: stretch::style::Dimension::Points(3.0000),
3241                                    top: stretch::style::Dimension::Points(3.0000),
3242                                    bottom: stretch::style::Dimension::Points(3.0000),
3243                                    ..Default::default()
3244                                },
3245                                ..Default::default()
3246                            }],
3247                            ..Default::default()
3248                        }],
3249                        ..Default::default()
3250                    },
3251                    stretch::style::Node {
3252                        flex_grow: 4.0000,
3253                        flex_basis: stretch::style::Dimension::Percent(0.1500),
3254                        min_size: stretch::geometry::Size {
3255                            width: stretch::style::Dimension::Percent(0.2000),
3256                            ..Default::default()
3257                        },
3258                        ..Default::default()
3259                    },
3260                ],
3261                ..Default::default()
3262            },
3263            stretch::geometry::Size::undefined(),
3264        );
3265
3266        assert_eq!(layout.size.width, 200.0000);
3267        assert_eq!(layout.size.height, 200.0000);
3268        assert_eq!(layout.location.x, 0.0000);
3269        assert_eq!(layout.location.y, 0.0000);
3270
3271        assert_eq!(layout.children[0].size.width, 190.0000);
3272        assert_eq!(layout.children[0].size.height, 48.0000);
3273        assert_eq!(layout.children[0].location.x, 5.0000);
3274        assert_eq!(layout.children[0].location.y, 5.0000);
3275
3276        assert_eq!(layout.children[0].children[0].size.width, 92.0000);
3277        assert_eq!(layout.children[0].children[0].size.height, 25.0000);
3278        assert_eq!(layout.children[0].children[0].location.x, 8.0000);
3279        assert_eq!(layout.children[0].children[0].location.y, 8.0000);
3280
3281        assert_eq!(layout.children[0].children[0].children[0].size.width, 36.0000);
3282        assert_eq!(layout.children[0].children[0].children[0].size.height, 6.0000);
3283        assert_eq!(layout.children[0].children[0].children[0].location.x, 10.0000);
3284        assert_eq!(layout.children[0].children[0].children[0].location.y, 10.0000);
3285
3286        assert_eq!(layout.children[1].size.width, 200.0000);
3287        assert_eq!(layout.children[1].size.height, 142.0000);
3288        assert_eq!(layout.children[1].location.x, 0.0000);
3289        assert_eq!(layout.children[1].location.y, 58.0000);
3290    }
3291
3292    #[test]
3293    fn flex_grow_within_constrained_min_column() {
3294        let layout = stretch::compute(
3295            &stretch::style::Node {
3296                flex_direction: stretch::style::FlexDirection::Column,
3297                min_size: stretch::geometry::Size {
3298                    height: stretch::style::Dimension::Points(100.0000),
3299                    ..Default::default()
3300                },
3301                children: vec![
3302                    stretch::style::Node { flex_grow: 1.0000, ..Default::default() },
3303                    stretch::style::Node {
3304                        size: stretch::geometry::Size {
3305                            height: stretch::style::Dimension::Points(50.0000),
3306                            ..Default::default()
3307                        },
3308                        ..Default::default()
3309                    },
3310                ],
3311                ..Default::default()
3312            },
3313            stretch::geometry::Size::undefined(),
3314        );
3315
3316        assert_eq!(layout.size.width, 0.0000);
3317        assert_eq!(layout.size.height, 100.0000);
3318        assert_eq!(layout.location.x, 0.0000);
3319        assert_eq!(layout.location.y, 0.0000);
3320
3321        assert_eq!(layout.children[0].size.width, 0.0000);
3322        assert_eq!(layout.children[0].size.height, 50.0000);
3323        assert_eq!(layout.children[0].location.x, 0.0000);
3324        assert_eq!(layout.children[0].location.y, 0.0000);
3325
3326        assert_eq!(layout.children[1].size.width, 0.0000);
3327        assert_eq!(layout.children[1].size.height, 50.0000);
3328        assert_eq!(layout.children[1].location.x, 0.0000);
3329        assert_eq!(layout.children[1].location.y, 50.0000);
3330    }
3331
3332    #[test]
3333    fn flex_grow_in_at_most_container() {
3334        let layout = stretch::compute(
3335            &stretch::style::Node {
3336                align_items: stretch::style::AlignItems::FlexStart,
3337                size: stretch::geometry::Size {
3338                    width: stretch::style::Dimension::Points(100.0000),
3339                    height: stretch::style::Dimension::Points(100.0000),
3340                    ..Default::default()
3341                },
3342                children: vec![stretch::style::Node {
3343                    children: vec![stretch::style::Node {
3344                        flex_grow: 1.0000,
3345                        flex_basis: stretch::style::Dimension::Points(0.0000),
3346                        ..Default::default()
3347                    }],
3348                    ..Default::default()
3349                }],
3350                ..Default::default()
3351            },
3352            stretch::geometry::Size::undefined(),
3353        );
3354
3355        assert_eq!(layout.size.width, 100.0000);
3356        assert_eq!(layout.size.height, 100.0000);
3357        assert_eq!(layout.location.x, 0.0000);
3358        assert_eq!(layout.location.y, 0.0000);
3359
3360        assert_eq!(layout.children[0].size.width, 0.0000);
3361        assert_eq!(layout.children[0].size.height, 0.0000);
3362        assert_eq!(layout.children[0].location.x, 0.0000);
3363        assert_eq!(layout.children[0].location.y, 0.0000);
3364
3365        assert_eq!(layout.children[0].children[0].size.width, 0.0000);
3366        assert_eq!(layout.children[0].children[0].size.height, 0.0000);
3367        assert_eq!(layout.children[0].children[0].location.x, 0.0000);
3368        assert_eq!(layout.children[0].children[0].location.y, 0.0000);
3369    }
3370
3371    #[test]
3372    fn margin_auto_left() {
3373        let layout = stretch::compute(
3374            &stretch::style::Node {
3375                align_items: stretch::style::AlignItems::Center,
3376                size: stretch::geometry::Size {
3377                    width: stretch::style::Dimension::Points(200.0000),
3378                    height: stretch::style::Dimension::Points(200.0000),
3379                    ..Default::default()
3380                },
3381                children: vec![
3382                    stretch::style::Node {
3383                        size: stretch::geometry::Size {
3384                            width: stretch::style::Dimension::Points(50.0000),
3385                            height: stretch::style::Dimension::Points(50.0000),
3386                            ..Default::default()
3387                        },
3388                        margin: stretch::geometry::Rect {
3389                            start: stretch::style::Dimension::Auto,
3390                            ..Default::default()
3391                        },
3392                        ..Default::default()
3393                    },
3394                    stretch::style::Node {
3395                        size: stretch::geometry::Size {
3396                            width: stretch::style::Dimension::Points(50.0000),
3397                            height: stretch::style::Dimension::Points(50.0000),
3398                            ..Default::default()
3399                        },
3400                        ..Default::default()
3401                    },
3402                ],
3403                ..Default::default()
3404            },
3405            stretch::geometry::Size::undefined(),
3406        );
3407
3408        assert_eq!(layout.size.width, 200.0000);
3409        assert_eq!(layout.size.height, 200.0000);
3410        assert_eq!(layout.location.x, 0.0000);
3411        assert_eq!(layout.location.y, 0.0000);
3412
3413        assert_eq!(layout.children[0].size.width, 50.0000);
3414        assert_eq!(layout.children[0].size.height, 50.0000);
3415        assert_eq!(layout.children[0].location.x, 100.0000);
3416        assert_eq!(layout.children[0].location.y, 75.0000);
3417
3418        assert_eq!(layout.children[1].size.width, 50.0000);
3419        assert_eq!(layout.children[1].size.height, 50.0000);
3420        assert_eq!(layout.children[1].location.x, 150.0000);
3421        assert_eq!(layout.children[1].location.y, 75.0000);
3422    }
3423
3424    #[test]
3425    fn percentage_flex_basis_cross() {
3426        let layout = stretch::compute(
3427            &stretch::style::Node {
3428                flex_direction: stretch::style::FlexDirection::Column,
3429                size: stretch::geometry::Size {
3430                    width: stretch::style::Dimension::Points(200.0000),
3431                    height: stretch::style::Dimension::Points(400.0000),
3432                    ..Default::default()
3433                },
3434                children: vec![
3435                    stretch::style::Node {
3436                        flex_grow: 1.0000,
3437                        flex_basis: stretch::style::Dimension::Percent(0.5000),
3438                        ..Default::default()
3439                    },
3440                    stretch::style::Node {
3441                        flex_grow: 1.0000,
3442                        flex_basis: stretch::style::Dimension::Percent(0.2500),
3443                        ..Default::default()
3444                    },
3445                ],
3446                ..Default::default()
3447            },
3448            stretch::geometry::Size::undefined(),
3449        );
3450
3451        assert_eq!(layout.size.width, 200.0000);
3452        assert_eq!(layout.size.height, 400.0000);
3453        assert_eq!(layout.location.x, 0.0000);
3454        assert_eq!(layout.location.y, 0.0000);
3455
3456        assert_eq!(layout.children[0].size.width, 200.0000);
3457        assert_eq!(layout.children[0].size.height, 250.0000);
3458        assert_eq!(layout.children[0].location.x, 0.0000);
3459        assert_eq!(layout.children[0].location.y, 0.0000);
3460
3461        assert_eq!(layout.children[1].size.width, 200.0000);
3462        assert_eq!(layout.children[1].size.height, 150.0000);
3463        assert_eq!(layout.children[1].location.x, 0.0000);
3464        assert_eq!(layout.children[1].location.y, 250.0000);
3465    }
3466
3467    #[test]
3468    fn percentage_absolute_position() {
3469        let layout = stretch::compute(
3470            &stretch::style::Node {
3471                flex_direction: stretch::style::FlexDirection::Column,
3472                size: stretch::geometry::Size {
3473                    width: stretch::style::Dimension::Points(200.0000),
3474                    height: stretch::style::Dimension::Points(100.0000),
3475                    ..Default::default()
3476                },
3477                children: vec![stretch::style::Node {
3478                    position_type: stretch::style::PositionType::Absolute,
3479                    size: stretch::geometry::Size {
3480                        width: stretch::style::Dimension::Points(10.0000),
3481                        height: stretch::style::Dimension::Points(10.0000),
3482                        ..Default::default()
3483                    },
3484                    position: stretch::geometry::Rect {
3485                        start: stretch::style::Dimension::Percent(0.3000),
3486                        top: stretch::style::Dimension::Percent(0.1000),
3487                        ..Default::default()
3488                    },
3489                    ..Default::default()
3490                }],
3491                ..Default::default()
3492            },
3493            stretch::geometry::Size::undefined(),
3494        );
3495
3496        assert_eq!(layout.size.width, 200.0000);
3497        assert_eq!(layout.size.height, 100.0000);
3498        assert_eq!(layout.location.x, 0.0000);
3499        assert_eq!(layout.location.y, 0.0000);
3500
3501        assert_eq!(layout.children[0].size.width, 10.0000);
3502        assert_eq!(layout.children[0].size.height, 10.0000);
3503        assert_eq!(layout.children[0].location.x, 60.0000);
3504        assert_eq!(layout.children[0].location.y, 10.0000);
3505    }
3506
3507    #[test]
3508    fn flex_basis_flex_grow_row() {
3509        let layout = stretch::compute(
3510            &stretch::style::Node {
3511                size: stretch::geometry::Size {
3512                    width: stretch::style::Dimension::Points(100.0000),
3513                    height: stretch::style::Dimension::Points(100.0000),
3514                    ..Default::default()
3515                },
3516                children: vec![
3517                    stretch::style::Node {
3518                        flex_grow: 1.0000,
3519                        flex_basis: stretch::style::Dimension::Points(50.0000),
3520                        ..Default::default()
3521                    },
3522                    stretch::style::Node { flex_grow: 1.0000, ..Default::default() },
3523                ],
3524                ..Default::default()
3525            },
3526            stretch::geometry::Size::undefined(),
3527        );
3528
3529        assert_eq!(layout.size.width, 100.0000);
3530        assert_eq!(layout.size.height, 100.0000);
3531        assert_eq!(layout.location.x, 0.0000);
3532        assert_eq!(layout.location.y, 0.0000);
3533
3534        assert_eq!(layout.children[0].size.width, 75.0000);
3535        assert_eq!(layout.children[0].size.height, 100.0000);
3536        assert_eq!(layout.children[0].location.x, 0.0000);
3537        assert_eq!(layout.children[0].location.y, 0.0000);
3538
3539        assert_eq!(layout.children[1].size.width, 25.0000);
3540        assert_eq!(layout.children[1].size.height, 100.0000);
3541        assert_eq!(layout.children[1].location.x, 75.0000);
3542        assert_eq!(layout.children[1].location.y, 0.0000);
3543    }
3544
3545    #[test]
3546    fn absolute_layout_in_wrap_reverse_column_container_flex_end() {
3547        let layout = stretch::compute(
3548            &stretch::style::Node {
3549                flex_direction: stretch::style::FlexDirection::Column,
3550                flex_wrap: stretch::style::FlexWrap::WrapReverse,
3551                size: stretch::geometry::Size {
3552                    width: stretch::style::Dimension::Points(100.0000),
3553                    height: stretch::style::Dimension::Points(100.0000),
3554                    ..Default::default()
3555                },
3556                children: vec![stretch::style::Node {
3557                    position_type: stretch::style::PositionType::Absolute,
3558                    align_self: stretch::style::AlignSelf::FlexEnd,
3559                    size: stretch::geometry::Size {
3560                        width: stretch::style::Dimension::Points(20.0000),
3561                        height: stretch::style::Dimension::Points(20.0000),
3562                        ..Default::default()
3563                    },
3564                    ..Default::default()
3565                }],
3566                ..Default::default()
3567            },
3568            stretch::geometry::Size::undefined(),
3569        );
3570
3571        assert_eq!(layout.size.width, 100.0000);
3572        assert_eq!(layout.size.height, 100.0000);
3573        assert_eq!(layout.location.x, 0.0000);
3574        assert_eq!(layout.location.y, 0.0000);
3575
3576        assert_eq!(layout.children[0].size.width, 20.0000);
3577        assert_eq!(layout.children[0].size.height, 20.0000);
3578        assert_eq!(layout.children[0].location.x, 0.0000);
3579        assert_eq!(layout.children[0].location.y, 0.0000);
3580    }
3581
3582    #[test]
3583    fn justify_content_row_flex_start() {
3584        let layout = stretch::compute(
3585            &stretch::style::Node {
3586                size: stretch::geometry::Size {
3587                    width: stretch::style::Dimension::Points(100.0000),
3588                    height: stretch::style::Dimension::Points(100.0000),
3589                    ..Default::default()
3590                },
3591                children: vec![
3592                    stretch::style::Node {
3593                        size: stretch::geometry::Size {
3594                            width: stretch::style::Dimension::Points(10.0000),
3595                            ..Default::default()
3596                        },
3597                        ..Default::default()
3598                    },
3599                    stretch::style::Node {
3600                        size: stretch::geometry::Size {
3601                            width: stretch::style::Dimension::Points(10.0000),
3602                            ..Default::default()
3603                        },
3604                        ..Default::default()
3605                    },
3606                    stretch::style::Node {
3607                        size: stretch::geometry::Size {
3608                            width: stretch::style::Dimension::Points(10.0000),
3609                            ..Default::default()
3610                        },
3611                        ..Default::default()
3612                    },
3613                ],
3614                ..Default::default()
3615            },
3616            stretch::geometry::Size::undefined(),
3617        );
3618
3619        assert_eq!(layout.size.width, 100.0000);
3620        assert_eq!(layout.size.height, 100.0000);
3621        assert_eq!(layout.location.x, 0.0000);
3622        assert_eq!(layout.location.y, 0.0000);
3623
3624        assert_eq!(layout.children[0].size.width, 10.0000);
3625        assert_eq!(layout.children[0].size.height, 100.0000);
3626        assert_eq!(layout.children[0].location.x, 0.0000);
3627        assert_eq!(layout.children[0].location.y, 0.0000);
3628
3629        assert_eq!(layout.children[1].size.width, 10.0000);
3630        assert_eq!(layout.children[1].size.height, 100.0000);
3631        assert_eq!(layout.children[1].location.x, 10.0000);
3632        assert_eq!(layout.children[1].location.y, 0.0000);
3633
3634        assert_eq!(layout.children[2].size.width, 10.0000);
3635        assert_eq!(layout.children[2].size.height, 100.0000);
3636        assert_eq!(layout.children[2].location.x, 20.0000);
3637        assert_eq!(layout.children[2].location.y, 0.0000);
3638    }
3639
3640    #[test]
3641    fn margin_auto_left_right_child_bigger_than_parent() {
3642        let layout = stretch::compute(
3643            &stretch::style::Node {
3644                justify_content: stretch::style::JustifyContent::Center,
3645                size: stretch::geometry::Size {
3646                    width: stretch::style::Dimension::Points(52.0000),
3647                    height: stretch::style::Dimension::Points(52.0000),
3648                    ..Default::default()
3649                },
3650                children: vec![stretch::style::Node {
3651                    size: stretch::geometry::Size {
3652                        width: stretch::style::Dimension::Points(72.0000),
3653                        height: stretch::style::Dimension::Points(72.0000),
3654                        ..Default::default()
3655                    },
3656                    margin: stretch::geometry::Rect {
3657                        start: stretch::style::Dimension::Auto,
3658                        end: stretch::style::Dimension::Auto,
3659                        ..Default::default()
3660                    },
3661                    ..Default::default()
3662                }],
3663                ..Default::default()
3664            },
3665            stretch::geometry::Size::undefined(),
3666        );
3667
3668        assert_eq!(layout.size.width, 52.0000);
3669        assert_eq!(layout.size.height, 52.0000);
3670        assert_eq!(layout.location.x, 0.0000);
3671        assert_eq!(layout.location.y, 0.0000);
3672
3673        assert_eq!(layout.children[0].size.width, 52.0000);
3674        assert_eq!(layout.children[0].size.height, 72.0000);
3675        assert_eq!(layout.children[0].location.x, 0.0000);
3676        assert_eq!(layout.children[0].location.y, 0.0000);
3677    }
3678
3679    #[test]
3680    fn flex_basis_larger_than_content_column() {
3681        let layout = stretch::compute(
3682            &stretch::style::Node {
3683                flex_direction: stretch::style::FlexDirection::Column,
3684                size: stretch::geometry::Size {
3685                    height: stretch::style::Dimension::Points(100.0000),
3686                    ..Default::default()
3687                },
3688                children: vec![stretch::style::Node {
3689                    flex_direction: stretch::style::FlexDirection::Column,
3690                    flex_basis: stretch::style::Dimension::Points(50.0000),
3691                    children: vec![stretch::style::Node {
3692                        size: stretch::geometry::Size {
3693                            width: stretch::style::Dimension::Points(100.0000),
3694                            height: stretch::style::Dimension::Points(10.0000),
3695                            ..Default::default()
3696                        },
3697                        ..Default::default()
3698                    }],
3699                    ..Default::default()
3700                }],
3701                ..Default::default()
3702            },
3703            stretch::geometry::Size::undefined(),
3704        );
3705
3706        assert_eq!(layout.size.width, 100.0000);
3707        assert_eq!(layout.size.height, 100.0000);
3708        assert_eq!(layout.location.x, 0.0000);
3709        assert_eq!(layout.location.y, 0.0000);
3710
3711        assert_eq!(layout.children[0].size.width, 100.0000);
3712        assert_eq!(layout.children[0].size.height, 50.0000);
3713        assert_eq!(layout.children[0].location.x, 0.0000);
3714        assert_eq!(layout.children[0].location.y, 0.0000);
3715
3716        assert_eq!(layout.children[0].children[0].size.width, 100.0000);
3717        assert_eq!(layout.children[0].children[0].size.height, 10.0000);
3718        assert_eq!(layout.children[0].children[0].location.x, 0.0000);
3719        assert_eq!(layout.children[0].children[0].location.y, 0.0000);
3720    }
3721
3722    #[test]
3723    fn margin_fix_left_auto_right_child_bigger_than_parent() {
3724        let layout = stretch::compute(
3725            &stretch::style::Node {
3726                justify_content: stretch::style::JustifyContent::Center,
3727                size: stretch::geometry::Size {
3728                    width: stretch::style::Dimension::Points(52.0000),
3729                    height: stretch::style::Dimension::Points(52.0000),
3730                    ..Default::default()
3731                },
3732                children: vec![stretch::style::Node {
3733                    size: stretch::geometry::Size {
3734                        width: stretch::style::Dimension::Points(72.0000),
3735                        height: stretch::style::Dimension::Points(72.0000),
3736                        ..Default::default()
3737                    },
3738                    margin: stretch::geometry::Rect {
3739                        start: stretch::style::Dimension::Points(10.0000),
3740                        end: stretch::style::Dimension::Auto,
3741                        ..Default::default()
3742                    },
3743                    ..Default::default()
3744                }],
3745                ..Default::default()
3746            },
3747            stretch::geometry::Size::undefined(),
3748        );
3749
3750        assert_eq!(layout.size.width, 52.0000);
3751        assert_eq!(layout.size.height, 52.0000);
3752        assert_eq!(layout.location.x, 0.0000);
3753        assert_eq!(layout.location.y, 0.0000);
3754
3755        assert_eq!(layout.children[0].size.width, 42.0000);
3756        assert_eq!(layout.children[0].size.height, 72.0000);
3757        assert_eq!(layout.children[0].location.x, 10.0000);
3758        assert_eq!(layout.children[0].location.y, 0.0000);
3759    }
3760
3761    #[test]
3762    fn percentage_container_in_wrapping_container() {
3763        let layout = stretch::compute(
3764            &stretch::style::Node {
3765                flex_direction: stretch::style::FlexDirection::Column,
3766                align_items: stretch::style::AlignItems::Center,
3767                justify_content: stretch::style::JustifyContent::Center,
3768                size: stretch::geometry::Size {
3769                    width: stretch::style::Dimension::Points(200.0000),
3770                    height: stretch::style::Dimension::Points(200.0000),
3771                    ..Default::default()
3772                },
3773                children: vec![stretch::style::Node {
3774                    flex_direction: stretch::style::FlexDirection::Column,
3775                    children: vec![stretch::style::Node {
3776                        justify_content: stretch::style::JustifyContent::Center,
3777                        size: stretch::geometry::Size {
3778                            width: stretch::style::Dimension::Percent(1.0000),
3779                            ..Default::default()
3780                        },
3781                        children: vec![
3782                            stretch::style::Node {
3783                                size: stretch::geometry::Size {
3784                                    width: stretch::style::Dimension::Points(50.0000),
3785                                    height: stretch::style::Dimension::Points(50.0000),
3786                                    ..Default::default()
3787                                },
3788                                ..Default::default()
3789                            },
3790                            stretch::style::Node {
3791                                size: stretch::geometry::Size {
3792                                    width: stretch::style::Dimension::Points(50.0000),
3793                                    height: stretch::style::Dimension::Points(50.0000),
3794                                    ..Default::default()
3795                                },
3796                                ..Default::default()
3797                            },
3798                        ],
3799                        ..Default::default()
3800                    }],
3801                    ..Default::default()
3802                }],
3803                ..Default::default()
3804            },
3805            stretch::geometry::Size::undefined(),
3806        );
3807
3808        assert_eq!(layout.size.width, 200.0000);
3809        assert_eq!(layout.size.height, 200.0000);
3810        assert_eq!(layout.location.x, 0.0000);
3811        assert_eq!(layout.location.y, 0.0000);
3812
3813        assert_eq!(layout.children[0].size.width, 100.0000);
3814        assert_eq!(layout.children[0].size.height, 50.0000);
3815        assert_eq!(layout.children[0].location.x, 50.0000);
3816        assert_eq!(layout.children[0].location.y, 75.0000);
3817
3818        assert_eq!(layout.children[0].children[0].size.width, 100.0000);
3819        assert_eq!(layout.children[0].children[0].size.height, 50.0000);
3820        assert_eq!(layout.children[0].children[0].location.x, 0.0000);
3821        assert_eq!(layout.children[0].children[0].location.y, 0.0000);
3822
3823        assert_eq!(layout.children[0].children[0].children[0].size.width, 50.0000);
3824        assert_eq!(layout.children[0].children[0].children[0].size.height, 50.0000);
3825        assert_eq!(layout.children[0].children[0].children[0].location.x, 0.0000);
3826        assert_eq!(layout.children[0].children[0].children[0].location.y, 0.0000);
3827
3828        assert_eq!(layout.children[0].children[0].children[1].size.width, 50.0000);
3829        assert_eq!(layout.children[0].children[0].children[1].size.height, 50.0000);
3830        assert_eq!(layout.children[0].children[0].children[1].location.x, 50.0000);
3831        assert_eq!(layout.children[0].children[0].children[1].location.y, 0.0000);
3832    }
3833
3834    #[test]
3835    fn margin_auto_left_stretching_child() {
3836        let layout = stretch::compute(
3837            &stretch::style::Node {
3838                align_items: stretch::style::AlignItems::Center,
3839                size: stretch::geometry::Size {
3840                    width: stretch::style::Dimension::Points(200.0000),
3841                    height: stretch::style::Dimension::Points(200.0000),
3842                    ..Default::default()
3843                },
3844                children: vec![
3845                    stretch::style::Node {
3846                        flex_grow: 1.0000,
3847                        flex_shrink: 1.0000,
3848                        flex_basis: stretch::style::Dimension::Percent(0.0000),
3849                        margin: stretch::geometry::Rect {
3850                            start: stretch::style::Dimension::Auto,
3851                            ..Default::default()
3852                        },
3853                        ..Default::default()
3854                    },
3855                    stretch::style::Node {
3856                        size: stretch::geometry::Size {
3857                            width: stretch::style::Dimension::Points(50.0000),
3858                            height: stretch::style::Dimension::Points(50.0000),
3859                            ..Default::default()
3860                        },
3861                        ..Default::default()
3862                    },
3863                ],
3864                ..Default::default()
3865            },
3866            stretch::geometry::Size::undefined(),
3867        );
3868
3869        assert_eq!(layout.size.width, 200.0000);
3870        assert_eq!(layout.size.height, 200.0000);
3871        assert_eq!(layout.location.x, 0.0000);
3872        assert_eq!(layout.location.y, 0.0000);
3873
3874        assert_eq!(layout.children[0].size.width, 150.0000);
3875        assert_eq!(layout.children[0].size.height, 0.0000);
3876        assert_eq!(layout.children[0].location.x, 0.0000);
3877        assert_eq!(layout.children[0].location.y, 100.0000);
3878
3879        assert_eq!(layout.children[1].size.width, 50.0000);
3880        assert_eq!(layout.children[1].size.height, 50.0000);
3881        assert_eq!(layout.children[1].location.x, 150.0000);
3882        assert_eq!(layout.children[1].location.y, 75.0000);
3883    }
3884
3885    #[test]
3886    fn flex_basis_smaller_then_content_with_flex_grow_small_size() {
3887        let layout = stretch::compute(
3888            &stretch::style::Node {
3889                size: stretch::geometry::Size {
3890                    width: stretch::style::Dimension::Points(10.0000),
3891                    ..Default::default()
3892                },
3893                children: vec![
3894                    stretch::style::Node {
3895                        flex_direction: stretch::style::FlexDirection::Column,
3896                        flex_grow: 1.0000,
3897                        flex_basis: stretch::style::Dimension::Points(0.0000),
3898                        children: vec![stretch::style::Node {
3899                            size: stretch::geometry::Size {
3900                                width: stretch::style::Dimension::Points(70.0000),
3901                                height: stretch::style::Dimension::Points(100.0000),
3902                                ..Default::default()
3903                            },
3904                            ..Default::default()
3905                        }],
3906                        ..Default::default()
3907                    },
3908                    stretch::style::Node {
3909                        flex_direction: stretch::style::FlexDirection::Column,
3910                        flex_grow: 1.0000,
3911                        flex_basis: stretch::style::Dimension::Points(0.0000),
3912                        children: vec![stretch::style::Node {
3913                            size: stretch::geometry::Size {
3914                                width: stretch::style::Dimension::Points(20.0000),
3915                                height: stretch::style::Dimension::Points(100.0000),
3916                                ..Default::default()
3917                            },
3918                            ..Default::default()
3919                        }],
3920                        ..Default::default()
3921                    },
3922                ],
3923                ..Default::default()
3924            },
3925            stretch::geometry::Size::undefined(),
3926        );
3927
3928        assert_eq!(layout.size.width, 10.0000);
3929        assert_eq!(layout.size.height, 100.0000);
3930        assert_eq!(layout.location.x, 0.0000);
3931        assert_eq!(layout.location.y, 0.0000);
3932
3933        assert_eq!(layout.children[0].size.width, 70.0000);
3934        assert_eq!(layout.children[0].size.height, 100.0000);
3935        assert_eq!(layout.children[0].location.x, 0.0000);
3936        assert_eq!(layout.children[0].location.y, 0.0000);
3937
3938        assert_eq!(layout.children[0].children[0].size.width, 70.0000);
3939        assert_eq!(layout.children[0].children[0].size.height, 100.0000);
3940        assert_eq!(layout.children[0].children[0].location.x, 0.0000);
3941        assert_eq!(layout.children[0].children[0].location.y, 0.0000);
3942
3943        assert_eq!(layout.children[1].size.width, 20.0000);
3944        assert_eq!(layout.children[1].size.height, 100.0000);
3945        assert_eq!(layout.children[1].location.x, 70.0000);
3946        assert_eq!(layout.children[1].location.y, 0.0000);
3947
3948        assert_eq!(layout.children[1].children[0].size.width, 20.0000);
3949        assert_eq!(layout.children[1].children[0].size.height, 100.0000);
3950        assert_eq!(layout.children[1].children[0].location.x, 0.0000);
3951        assert_eq!(layout.children[1].children[0].location.y, 0.0000);
3952    }
3953
3954    #[test]
3955    fn percentage_flex_basis_cross_max_width() {
3956        let layout = stretch::compute(
3957            &stretch::style::Node {
3958                flex_direction: stretch::style::FlexDirection::Column,
3959                size: stretch::geometry::Size {
3960                    width: stretch::style::Dimension::Points(200.0000),
3961                    height: stretch::style::Dimension::Points(400.0000),
3962                    ..Default::default()
3963                },
3964                children: vec![
3965                    stretch::style::Node {
3966                        flex_grow: 1.0000,
3967                        flex_basis: stretch::style::Dimension::Percent(0.1000),
3968                        max_size: stretch::geometry::Size {
3969                            width: stretch::style::Dimension::Percent(0.6000),
3970                            ..Default::default()
3971                        },
3972                        ..Default::default()
3973                    },
3974                    stretch::style::Node {
3975                        flex_grow: 4.0000,
3976                        flex_basis: stretch::style::Dimension::Percent(0.1500),
3977                        max_size: stretch::geometry::Size {
3978                            width: stretch::style::Dimension::Percent(0.2000),
3979                            ..Default::default()
3980                        },
3981                        ..Default::default()
3982                    },
3983                ],
3984                ..Default::default()
3985            },
3986            stretch::geometry::Size::undefined(),
3987        );
3988
3989        assert_eq!(layout.size.width, 200.0000);
3990        assert_eq!(layout.size.height, 400.0000);
3991        assert_eq!(layout.location.x, 0.0000);
3992        assert_eq!(layout.location.y, 0.0000);
3993
3994        assert_eq!(layout.children[0].size.width, 120.0000);
3995        assert_eq!(layout.children[0].size.height, 100.0000);
3996        assert_eq!(layout.children[0].location.x, 0.0000);
3997        assert_eq!(layout.children[0].location.y, 0.0000);
3998
3999        assert_eq!(layout.children[1].size.width, 40.0000);
4000        assert_eq!(layout.children[1].size.height, 300.0000);
4001        assert_eq!(layout.children[1].location.x, 0.0000);
4002        assert_eq!(layout.children[1].location.y, 100.0000);
4003    }
4004
4005    #[test]
4006    fn align_items_flex_end_child_without_margin_bigger_than_parent() {
4007        let layout = stretch::compute(
4008            &stretch::style::Node {
4009                align_items: stretch::style::AlignItems::Center,
4010                justify_content: stretch::style::JustifyContent::Center,
4011                size: stretch::geometry::Size {
4012                    width: stretch::style::Dimension::Points(50.0000),
4013                    height: stretch::style::Dimension::Points(50.0000),
4014                    ..Default::default()
4015                },
4016                children: vec![stretch::style::Node {
4017                    align_items: stretch::style::AlignItems::FlexEnd,
4018                    children: vec![stretch::style::Node {
4019                        size: stretch::geometry::Size {
4020                            width: stretch::style::Dimension::Points(70.0000),
4021                            height: stretch::style::Dimension::Points(70.0000),
4022                            ..Default::default()
4023                        },
4024                        ..Default::default()
4025                    }],
4026                    ..Default::default()
4027                }],
4028                ..Default::default()
4029            },
4030            stretch::geometry::Size::undefined(),
4031        );
4032
4033        assert_eq!(layout.size.width, 50.0000);
4034        assert_eq!(layout.size.height, 50.0000);
4035        assert_eq!(layout.location.x, 0.0000);
4036        assert_eq!(layout.location.y, 0.0000);
4037
4038        assert_eq!(layout.children[0].size.width, 70.0000);
4039        assert_eq!(layout.children[0].size.height, 70.0000);
4040        assert_eq!(layout.children[0].location.x, -10.0000);
4041        assert_eq!(layout.children[0].location.y, -10.0000);
4042
4043        assert_eq!(layout.children[0].children[0].size.width, 70.0000);
4044        assert_eq!(layout.children[0].children[0].size.height, 70.0000);
4045        assert_eq!(layout.children[0].children[0].location.x, 0.0000);
4046        assert_eq!(layout.children[0].children[0].location.y, 0.0000);
4047    }
4048
4049    #[test]
4050    fn width_smaller_then_content_with_flex_grow_very_large_size() {
4051        let layout = stretch::compute(
4052            &stretch::style::Node {
4053                size: stretch::geometry::Size {
4054                    width: stretch::style::Dimension::Points(200.0000),
4055                    ..Default::default()
4056                },
4057                children: vec![
4058                    stretch::style::Node {
4059                        flex_direction: stretch::style::FlexDirection::Column,
4060                        flex_grow: 1.0000,
4061                        size: stretch::geometry::Size {
4062                            width: stretch::style::Dimension::Points(0.0000),
4063                            ..Default::default()
4064                        },
4065                        children: vec![stretch::style::Node {
4066                            size: stretch::geometry::Size {
4067                                width: stretch::style::Dimension::Points(70.0000),
4068                                height: stretch::style::Dimension::Points(100.0000),
4069                                ..Default::default()
4070                            },
4071                            ..Default::default()
4072                        }],
4073                        ..Default::default()
4074                    },
4075                    stretch::style::Node {
4076                        flex_direction: stretch::style::FlexDirection::Column,
4077                        flex_grow: 1.0000,
4078                        size: stretch::geometry::Size {
4079                            width: stretch::style::Dimension::Points(0.0000),
4080                            ..Default::default()
4081                        },
4082                        children: vec![stretch::style::Node {
4083                            size: stretch::geometry::Size {
4084                                width: stretch::style::Dimension::Points(20.0000),
4085                                height: stretch::style::Dimension::Points(100.0000),
4086                                ..Default::default()
4087                            },
4088                            ..Default::default()
4089                        }],
4090                        ..Default::default()
4091                    },
4092                ],
4093                ..Default::default()
4094            },
4095            stretch::geometry::Size::undefined(),
4096        );
4097
4098        assert_eq!(layout.size.width, 200.0000);
4099        assert_eq!(layout.size.height, 100.0000);
4100        assert_eq!(layout.location.x, 0.0000);
4101        assert_eq!(layout.location.y, 0.0000);
4102
4103        assert_eq!(layout.children[0].size.width, 100.0000);
4104        assert_eq!(layout.children[0].size.height, 100.0000);
4105        assert_eq!(layout.children[0].location.x, 0.0000);
4106        assert_eq!(layout.children[0].location.y, 0.0000);
4107
4108        assert_eq!(layout.children[0].children[0].size.width, 70.0000);
4109        assert_eq!(layout.children[0].children[0].size.height, 100.0000);
4110        assert_eq!(layout.children[0].children[0].location.x, 0.0000);
4111        assert_eq!(layout.children[0].children[0].location.y, 0.0000);
4112
4113        assert_eq!(layout.children[1].size.width, 100.0000);
4114        assert_eq!(layout.children[1].size.height, 100.0000);
4115        assert_eq!(layout.children[1].location.x, 100.0000);
4116        assert_eq!(layout.children[1].location.y, 0.0000);
4117
4118        assert_eq!(layout.children[1].children[0].size.width, 20.0000);
4119        assert_eq!(layout.children[1].children[0].size.height, 100.0000);
4120        assert_eq!(layout.children[1].children[0].location.x, 0.0000);
4121        assert_eq!(layout.children[1].children[0].location.y, 0.0000);
4122    }
4123
4124    #[test]
4125    fn size_defined_by_child_with_padding() {
4126        let layout = stretch::compute(
4127            &stretch::style::Node {
4128                padding: stretch::geometry::Rect {
4129                    start: stretch::style::Dimension::Points(10.0000),
4130                    end: stretch::style::Dimension::Points(10.0000),
4131                    top: stretch::style::Dimension::Points(10.0000),
4132                    bottom: stretch::style::Dimension::Points(10.0000),
4133                    ..Default::default()
4134                },
4135                children: vec![stretch::style::Node {
4136                    size: stretch::geometry::Size {
4137                        width: stretch::style::Dimension::Points(10.0000),
4138                        height: stretch::style::Dimension::Points(10.0000),
4139                        ..Default::default()
4140                    },
4141                    ..Default::default()
4142                }],
4143                ..Default::default()
4144            },
4145            stretch::geometry::Size::undefined(),
4146        );
4147
4148        assert_eq!(layout.size.width, 30.0000);
4149        assert_eq!(layout.size.height, 30.0000);
4150        assert_eq!(layout.location.x, 0.0000);
4151        assert_eq!(layout.location.y, 0.0000);
4152
4153        assert_eq!(layout.children[0].size.width, 10.0000);
4154        assert_eq!(layout.children[0].size.height, 10.0000);
4155        assert_eq!(layout.children[0].location.x, 10.0000);
4156        assert_eq!(layout.children[0].location.y, 10.0000);
4157    }
4158
4159    #[test]
4160    fn absolute_layout_within_border() {
4161        let layout = stretch::compute(
4162            &stretch::style::Node {
4163                size: stretch::geometry::Size {
4164                    width: stretch::style::Dimension::Points(100.0000),
4165                    height: stretch::style::Dimension::Points(100.0000),
4166                    ..Default::default()
4167                },
4168                padding: stretch::geometry::Rect {
4169                    start: stretch::style::Dimension::Points(10.0000),
4170                    end: stretch::style::Dimension::Points(10.0000),
4171                    top: stretch::style::Dimension::Points(10.0000),
4172                    bottom: stretch::style::Dimension::Points(10.0000),
4173                    ..Default::default()
4174                },
4175                border: stretch::geometry::Rect {
4176                    start: stretch::style::Dimension::Points(10.0000),
4177                    end: stretch::style::Dimension::Points(10.0000),
4178                    top: stretch::style::Dimension::Points(10.0000),
4179                    bottom: stretch::style::Dimension::Points(10.0000),
4180                    ..Default::default()
4181                },
4182                children: vec![
4183                    stretch::style::Node {
4184                        position_type: stretch::style::PositionType::Absolute,
4185                        size: stretch::geometry::Size {
4186                            width: stretch::style::Dimension::Points(50.0000),
4187                            height: stretch::style::Dimension::Points(50.0000),
4188                            ..Default::default()
4189                        },
4190                        position: stretch::geometry::Rect {
4191                            start: stretch::style::Dimension::Points(0.0000),
4192                            top: stretch::style::Dimension::Points(0.0000),
4193                            ..Default::default()
4194                        },
4195                        ..Default::default()
4196                    },
4197                    stretch::style::Node {
4198                        position_type: stretch::style::PositionType::Absolute,
4199                        size: stretch::geometry::Size {
4200                            width: stretch::style::Dimension::Points(50.0000),
4201                            height: stretch::style::Dimension::Points(50.0000),
4202                            ..Default::default()
4203                        },
4204                        position: stretch::geometry::Rect {
4205                            end: stretch::style::Dimension::Points(0.0000),
4206                            bottom: stretch::style::Dimension::Points(0.0000),
4207                            ..Default::default()
4208                        },
4209                        ..Default::default()
4210                    },
4211                    stretch::style::Node {
4212                        position_type: stretch::style::PositionType::Absolute,
4213                        size: stretch::geometry::Size {
4214                            width: stretch::style::Dimension::Points(50.0000),
4215                            height: stretch::style::Dimension::Points(50.0000),
4216                            ..Default::default()
4217                        },
4218                        margin: stretch::geometry::Rect {
4219                            start: stretch::style::Dimension::Points(10.0000),
4220                            end: stretch::style::Dimension::Points(10.0000),
4221                            top: stretch::style::Dimension::Points(10.0000),
4222                            bottom: stretch::style::Dimension::Points(10.0000),
4223                            ..Default::default()
4224                        },
4225                        position: stretch::geometry::Rect {
4226                            start: stretch::style::Dimension::Points(0.0000),
4227                            top: stretch::style::Dimension::Points(0.0000),
4228                            ..Default::default()
4229                        },
4230                        ..Default::default()
4231                    },
4232                    stretch::style::Node {
4233                        position_type: stretch::style::PositionType::Absolute,
4234                        size: stretch::geometry::Size {
4235                            width: stretch::style::Dimension::Points(50.0000),
4236                            height: stretch::style::Dimension::Points(50.0000),
4237                            ..Default::default()
4238                        },
4239                        margin: stretch::geometry::Rect {
4240                            start: stretch::style::Dimension::Points(10.0000),
4241                            end: stretch::style::Dimension::Points(10.0000),
4242                            top: stretch::style::Dimension::Points(10.0000),
4243                            bottom: stretch::style::Dimension::Points(10.0000),
4244                            ..Default::default()
4245                        },
4246                        position: stretch::geometry::Rect {
4247                            end: stretch::style::Dimension::Points(0.0000),
4248                            bottom: stretch::style::Dimension::Points(0.0000),
4249                            ..Default::default()
4250                        },
4251                        ..Default::default()
4252                    },
4253                ],
4254                ..Default::default()
4255            },
4256            stretch::geometry::Size::undefined(),
4257        );
4258
4259        assert_eq!(layout.size.width, 100.0000);
4260        assert_eq!(layout.size.height, 100.0000);
4261        assert_eq!(layout.location.x, 0.0000);
4262        assert_eq!(layout.location.y, 0.0000);
4263
4264        assert_eq!(layout.children[0].size.width, 50.0000);
4265        assert_eq!(layout.children[0].size.height, 50.0000);
4266        assert_eq!(layout.children[0].location.x, 10.0000);
4267        assert_eq!(layout.children[0].location.y, 10.0000);
4268
4269        assert_eq!(layout.children[1].size.width, 50.0000);
4270        assert_eq!(layout.children[1].size.height, 50.0000);
4271        assert_eq!(layout.children[1].location.x, 40.0000);
4272        assert_eq!(layout.children[1].location.y, 40.0000);
4273
4274        assert_eq!(layout.children[2].size.width, 50.0000);
4275        assert_eq!(layout.children[2].size.height, 50.0000);
4276        assert_eq!(layout.children[2].location.x, 20.0000);
4277        assert_eq!(layout.children[2].location.y, 20.0000);
4278
4279        assert_eq!(layout.children[3].size.width, 50.0000);
4280        assert_eq!(layout.children[3].size.height, 50.0000);
4281        assert_eq!(layout.children[3].location.x, 30.0000);
4282        assert_eq!(layout.children[3].location.y, 30.0000);
4283    }
4284
4285    #[test]
4286    fn margin_auto_left_fix_right_child_bigger_than_parent() {
4287        let layout = stretch::compute(
4288            &stretch::style::Node {
4289                justify_content: stretch::style::JustifyContent::Center,
4290                size: stretch::geometry::Size {
4291                    width: stretch::style::Dimension::Points(52.0000),
4292                    height: stretch::style::Dimension::Points(52.0000),
4293                    ..Default::default()
4294                },
4295                children: vec![stretch::style::Node {
4296                    size: stretch::geometry::Size {
4297                        width: stretch::style::Dimension::Points(72.0000),
4298                        height: stretch::style::Dimension::Points(72.0000),
4299                        ..Default::default()
4300                    },
4301                    margin: stretch::geometry::Rect {
4302                        start: stretch::style::Dimension::Auto,
4303                        end: stretch::style::Dimension::Points(10.0000),
4304                        ..Default::default()
4305                    },
4306                    ..Default::default()
4307                }],
4308                ..Default::default()
4309            },
4310            stretch::geometry::Size::undefined(),
4311        );
4312
4313        assert_eq!(layout.size.width, 52.0000);
4314        assert_eq!(layout.size.height, 52.0000);
4315        assert_eq!(layout.location.x, 0.0000);
4316        assert_eq!(layout.location.y, 0.0000);
4317
4318        assert_eq!(layout.children[0].size.width, 42.0000);
4319        assert_eq!(layout.children[0].size.height, 72.0000);
4320        assert_eq!(layout.children[0].location.x, 0.0000);
4321        assert_eq!(layout.children[0].location.y, 0.0000);
4322    }
4323
4324    #[test]
4325    fn justify_content_row_flex_end() {
4326        let layout = stretch::compute(
4327            &stretch::style::Node {
4328                justify_content: stretch::style::JustifyContent::FlexEnd,
4329                size: stretch::geometry::Size {
4330                    width: stretch::style::Dimension::Points(100.0000),
4331                    height: stretch::style::Dimension::Points(100.0000),
4332                    ..Default::default()
4333                },
4334                children: vec![
4335                    stretch::style::Node {
4336                        size: stretch::geometry::Size {
4337                            width: stretch::style::Dimension::Points(10.0000),
4338                            ..Default::default()
4339                        },
4340                        ..Default::default()
4341                    },
4342                    stretch::style::Node {
4343                        size: stretch::geometry::Size {
4344                            width: stretch::style::Dimension::Points(10.0000),
4345                            ..Default::default()
4346                        },
4347                        ..Default::default()
4348                    },
4349                    stretch::style::Node {
4350                        size: stretch::geometry::Size {
4351                            width: stretch::style::Dimension::Points(10.0000),
4352                            ..Default::default()
4353                        },
4354                        ..Default::default()
4355                    },
4356                ],
4357                ..Default::default()
4358            },
4359            stretch::geometry::Size::undefined(),
4360        );
4361
4362        assert_eq!(layout.size.width, 100.0000);
4363        assert_eq!(layout.size.height, 100.0000);
4364        assert_eq!(layout.location.x, 0.0000);
4365        assert_eq!(layout.location.y, 0.0000);
4366
4367        assert_eq!(layout.children[0].size.width, 10.0000);
4368        assert_eq!(layout.children[0].size.height, 100.0000);
4369        assert_eq!(layout.children[0].location.x, 70.0000);
4370        assert_eq!(layout.children[0].location.y, 0.0000);
4371
4372        assert_eq!(layout.children[1].size.width, 10.0000);
4373        assert_eq!(layout.children[1].size.height, 100.0000);
4374        assert_eq!(layout.children[1].location.x, 80.0000);
4375        assert_eq!(layout.children[1].location.y, 0.0000);
4376
4377        assert_eq!(layout.children[2].size.width, 10.0000);
4378        assert_eq!(layout.children[2].size.height, 100.0000);
4379        assert_eq!(layout.children[2].location.x, 90.0000);
4380        assert_eq!(layout.children[2].location.y, 0.0000);
4381    }
4382
4383    #[test]
4384    fn margin_bottom() {
4385        let layout = stretch::compute(
4386            &stretch::style::Node {
4387                flex_direction: stretch::style::FlexDirection::Column,
4388                justify_content: stretch::style::JustifyContent::FlexEnd,
4389                size: stretch::geometry::Size {
4390                    width: stretch::style::Dimension::Points(100.0000),
4391                    height: stretch::style::Dimension::Points(100.0000),
4392                    ..Default::default()
4393                },
4394                children: vec![stretch::style::Node {
4395                    size: stretch::geometry::Size {
4396                        height: stretch::style::Dimension::Points(10.0000),
4397                        ..Default::default()
4398                    },
4399                    margin: stretch::geometry::Rect {
4400                        bottom: stretch::style::Dimension::Points(10.0000),
4401                        ..Default::default()
4402                    },
4403                    ..Default::default()
4404                }],
4405                ..Default::default()
4406            },
4407            stretch::geometry::Size::undefined(),
4408        );
4409
4410        assert_eq!(layout.size.width, 100.0000);
4411        assert_eq!(layout.size.height, 100.0000);
4412        assert_eq!(layout.location.x, 0.0000);
4413        assert_eq!(layout.location.y, 0.0000);
4414
4415        assert_eq!(layout.children[0].size.width, 100.0000);
4416        assert_eq!(layout.children[0].size.height, 10.0000);
4417        assert_eq!(layout.children[0].location.x, 0.0000);
4418        assert_eq!(layout.children[0].location.y, 80.0000);
4419    }
4420
4421    #[test]
4422    fn margin_should_not_be_part_of_max_height() {
4423        let layout = stretch::compute(
4424            &stretch::style::Node {
4425                size: stretch::geometry::Size {
4426                    width: stretch::style::Dimension::Points(250.0000),
4427                    height: stretch::style::Dimension::Points(250.0000),
4428                    ..Default::default()
4429                },
4430                children: vec![stretch::style::Node {
4431                    size: stretch::geometry::Size {
4432                        width: stretch::style::Dimension::Points(100.0000),
4433                        height: stretch::style::Dimension::Points(100.0000),
4434                        ..Default::default()
4435                    },
4436                    max_size: stretch::geometry::Size {
4437                        height: stretch::style::Dimension::Points(100.0000),
4438                        ..Default::default()
4439                    },
4440                    margin: stretch::geometry::Rect {
4441                        top: stretch::style::Dimension::Points(20.0000),
4442                        ..Default::default()
4443                    },
4444                    ..Default::default()
4445                }],
4446                ..Default::default()
4447            },
4448            stretch::geometry::Size::undefined(),
4449        );
4450
4451        assert_eq!(layout.size.width, 250.0000);
4452        assert_eq!(layout.size.height, 250.0000);
4453        assert_eq!(layout.location.x, 0.0000);
4454        assert_eq!(layout.location.y, 0.0000);
4455
4456        assert_eq!(layout.children[0].size.width, 100.0000);
4457        assert_eq!(layout.children[0].size.height, 100.0000);
4458        assert_eq!(layout.children[0].location.x, 0.0000);
4459        assert_eq!(layout.children[0].location.y, 20.0000);
4460    }
4461
4462    #[test]
4463    fn flex_basis_smaller_than_main_dimen_row() {
4464        let layout = stretch::compute(
4465            &stretch::style::Node {
4466                size: stretch::geometry::Size {
4467                    width: stretch::style::Dimension::Points(100.0000),
4468                    ..Default::default()
4469                },
4470                children: vec![stretch::style::Node {
4471                    flex_basis: stretch::style::Dimension::Points(10.0000),
4472                    size: stretch::geometry::Size {
4473                        width: stretch::style::Dimension::Points(50.0000),
4474                        height: stretch::style::Dimension::Points(50.0000),
4475                        ..Default::default()
4476                    },
4477                    ..Default::default()
4478                }],
4479                ..Default::default()
4480            },
4481            stretch::geometry::Size::undefined(),
4482        );
4483
4484        assert_eq!(layout.size.width, 100.0000);
4485        assert_eq!(layout.size.height, 50.0000);
4486        assert_eq!(layout.location.x, 0.0000);
4487        assert_eq!(layout.location.y, 0.0000);
4488
4489        assert_eq!(layout.children[0].size.width, 10.0000);
4490        assert_eq!(layout.children[0].size.height, 50.0000);
4491        assert_eq!(layout.children[0].location.x, 0.0000);
4492        assert_eq!(layout.children[0].location.y, 0.0000);
4493    }
4494
4495    #[test]
4496    fn percentage_flex_basis_cross_min_height() {
4497        let layout = stretch::compute(
4498            &stretch::style::Node {
4499                flex_direction: stretch::style::FlexDirection::Column,
4500                size: stretch::geometry::Size {
4501                    width: stretch::style::Dimension::Points(200.0000),
4502                    height: stretch::style::Dimension::Points(400.0000),
4503                    ..Default::default()
4504                },
4505                children: vec![
4506                    stretch::style::Node {
4507                        flex_grow: 1.0000,
4508                        min_size: stretch::geometry::Size {
4509                            height: stretch::style::Dimension::Percent(0.6000),
4510                            ..Default::default()
4511                        },
4512                        ..Default::default()
4513                    },
4514                    stretch::style::Node {
4515                        flex_grow: 2.0000,
4516                        min_size: stretch::geometry::Size {
4517                            height: stretch::style::Dimension::Percent(0.1000),
4518                            ..Default::default()
4519                        },
4520                        ..Default::default()
4521                    },
4522                ],
4523                ..Default::default()
4524            },
4525            stretch::geometry::Size::undefined(),
4526        );
4527
4528        assert_eq!(layout.size.width, 200.0000);
4529        assert_eq!(layout.size.height, 400.0000);
4530        assert_eq!(layout.location.x, 0.0000);
4531        assert_eq!(layout.location.y, 0.0000);
4532
4533        assert_eq!(layout.children[0].size.width, 200.0000);
4534        assert_eq!(layout.children[0].size.height, 280.0000);
4535        assert_eq!(layout.children[0].location.x, 0.0000);
4536        assert_eq!(layout.children[0].location.y, 0.0000);
4537
4538        assert_eq!(layout.children[1].size.width, 200.0000);
4539        assert_eq!(layout.children[1].size.height, 120.0000);
4540        assert_eq!(layout.children[1].location.x, 0.0000);
4541        assert_eq!(layout.children[1].location.y, 280.0000);
4542    }
4543
4544    #[test]
4545    fn nested_overflowing_child_in_constraint_parent() {
4546        let layout = stretch::compute(
4547            &stretch::style::Node {
4548                size: stretch::geometry::Size {
4549                    width: stretch::style::Dimension::Points(100.0000),
4550                    height: stretch::style::Dimension::Points(100.0000),
4551                    ..Default::default()
4552                },
4553                children: vec![stretch::style::Node {
4554                    size: stretch::geometry::Size {
4555                        width: stretch::style::Dimension::Points(100.0000),
4556                        height: stretch::style::Dimension::Points(100.0000),
4557                        ..Default::default()
4558                    },
4559                    children: vec![stretch::style::Node {
4560                        size: stretch::geometry::Size {
4561                            width: stretch::style::Dimension::Points(200.0000),
4562                            height: stretch::style::Dimension::Points(200.0000),
4563                            ..Default::default()
4564                        },
4565                        ..Default::default()
4566                    }],
4567                    ..Default::default()
4568                }],
4569                ..Default::default()
4570            },
4571            stretch::geometry::Size::undefined(),
4572        );
4573
4574        assert_eq!(layout.size.width, 100.0000);
4575        assert_eq!(layout.size.height, 100.0000);
4576        assert_eq!(layout.location.x, 0.0000);
4577        assert_eq!(layout.location.y, 0.0000);
4578
4579        assert_eq!(layout.children[0].size.width, 100.0000);
4580        assert_eq!(layout.children[0].size.height, 100.0000);
4581        assert_eq!(layout.children[0].location.x, 0.0000);
4582        assert_eq!(layout.children[0].location.y, 0.0000);
4583
4584        assert_eq!(layout.children[0].children[0].size.width, 100.0000);
4585        assert_eq!(layout.children[0].children[0].size.height, 200.0000);
4586        assert_eq!(layout.children[0].children[0].location.x, 0.0000);
4587        assert_eq!(layout.children[0].children[0].location.y, 0.0000);
4588    }
4589
4590    #[test]
4591    fn wrapped_row_within_align_items_center() {
4592        let layout = stretch::compute(
4593            &stretch::style::Node {
4594                flex_direction: stretch::style::FlexDirection::Column,
4595                align_items: stretch::style::AlignItems::Center,
4596                size: stretch::geometry::Size {
4597                    width: stretch::style::Dimension::Points(200.0000),
4598                    height: stretch::style::Dimension::Points(200.0000),
4599                    ..Default::default()
4600                },
4601                children: vec![stretch::style::Node {
4602                    flex_wrap: stretch::style::FlexWrap::Wrap,
4603                    children: vec![
4604                        stretch::style::Node {
4605                            size: stretch::geometry::Size {
4606                                width: stretch::style::Dimension::Points(150.0000),
4607                                height: stretch::style::Dimension::Points(80.0000),
4608                                ..Default::default()
4609                            },
4610                            ..Default::default()
4611                        },
4612                        stretch::style::Node {
4613                            size: stretch::geometry::Size {
4614                                width: stretch::style::Dimension::Points(80.0000),
4615                                height: stretch::style::Dimension::Points(80.0000),
4616                                ..Default::default()
4617                            },
4618                            ..Default::default()
4619                        },
4620                    ],
4621                    ..Default::default()
4622                }],
4623                ..Default::default()
4624            },
4625            stretch::geometry::Size::undefined(),
4626        );
4627
4628        assert_eq!(layout.size.width, 200.0000);
4629        assert_eq!(layout.size.height, 200.0000);
4630        assert_eq!(layout.location.x, 0.0000);
4631        assert_eq!(layout.location.y, 0.0000);
4632
4633        assert_eq!(layout.children[0].size.width, 200.0000);
4634        assert_eq!(layout.children[0].size.height, 160.0000);
4635        assert_eq!(layout.children[0].location.x, 0.0000);
4636        assert_eq!(layout.children[0].location.y, 0.0000);
4637
4638        assert_eq!(layout.children[0].children[0].size.width, 150.0000);
4639        assert_eq!(layout.children[0].children[0].size.height, 80.0000);
4640        assert_eq!(layout.children[0].children[0].location.x, 0.0000);
4641        assert_eq!(layout.children[0].children[0].location.y, 0.0000);
4642
4643        assert_eq!(layout.children[0].children[1].size.width, 80.0000);
4644        assert_eq!(layout.children[0].children[1].size.height, 80.0000);
4645        assert_eq!(layout.children[0].children[1].location.x, 0.0000);
4646        assert_eq!(layout.children[0].children[1].location.y, 80.0000);
4647    }
4648
4649    #[test]
4650    fn justify_content_column_center() {
4651        let layout = stretch::compute(
4652            &stretch::style::Node {
4653                flex_direction: stretch::style::FlexDirection::Column,
4654                justify_content: stretch::style::JustifyContent::Center,
4655                size: stretch::geometry::Size {
4656                    width: stretch::style::Dimension::Points(100.0000),
4657                    height: stretch::style::Dimension::Points(100.0000),
4658                    ..Default::default()
4659                },
4660                children: vec![
4661                    stretch::style::Node {
4662                        size: stretch::geometry::Size {
4663                            height: stretch::style::Dimension::Points(10.0000),
4664                            ..Default::default()
4665                        },
4666                        ..Default::default()
4667                    },
4668                    stretch::style::Node {
4669                        size: stretch::geometry::Size {
4670                            height: stretch::style::Dimension::Points(10.0000),
4671                            ..Default::default()
4672                        },
4673                        ..Default::default()
4674                    },
4675                    stretch::style::Node {
4676                        size: stretch::geometry::Size {
4677                            height: stretch::style::Dimension::Points(10.0000),
4678                            ..Default::default()
4679                        },
4680                        ..Default::default()
4681                    },
4682                ],
4683                ..Default::default()
4684            },
4685            stretch::geometry::Size::undefined(),
4686        );
4687
4688        assert_eq!(layout.size.width, 100.0000);
4689        assert_eq!(layout.size.height, 100.0000);
4690        assert_eq!(layout.location.x, 0.0000);
4691        assert_eq!(layout.location.y, 0.0000);
4692
4693        assert_eq!(layout.children[0].size.width, 100.0000);
4694        assert_eq!(layout.children[0].size.height, 10.0000);
4695        assert_eq!(layout.children[0].location.x, 0.0000);
4696        assert_eq!(layout.children[0].location.y, 35.0000);
4697
4698        assert_eq!(layout.children[1].size.width, 100.0000);
4699        assert_eq!(layout.children[1].size.height, 10.0000);
4700        assert_eq!(layout.children[1].location.x, 0.0000);
4701        assert_eq!(layout.children[1].location.y, 45.0000);
4702
4703        assert_eq!(layout.children[2].size.width, 100.0000);
4704        assert_eq!(layout.children[2].size.height, 10.0000);
4705        assert_eq!(layout.children[2].location.x, 0.0000);
4706        assert_eq!(layout.children[2].location.y, 55.0000);
4707    }
4708
4709    #[test]
4710    fn align_items_center_child_with_margin_bigger_than_parent() {
4711        let layout = stretch::compute(
4712            &stretch::style::Node {
4713                align_items: stretch::style::AlignItems::Center,
4714                justify_content: stretch::style::JustifyContent::Center,
4715                size: stretch::geometry::Size {
4716                    width: stretch::style::Dimension::Points(50.0000),
4717                    height: stretch::style::Dimension::Points(50.0000),
4718                    ..Default::default()
4719                },
4720                children: vec![stretch::style::Node {
4721                    align_items: stretch::style::AlignItems::Center,
4722                    children: vec![stretch::style::Node {
4723                        size: stretch::geometry::Size {
4724                            width: stretch::style::Dimension::Points(50.0000),
4725                            height: stretch::style::Dimension::Points(50.0000),
4726                            ..Default::default()
4727                        },
4728                        margin: stretch::geometry::Rect {
4729                            start: stretch::style::Dimension::Points(10.0000),
4730                            end: stretch::style::Dimension::Points(10.0000),
4731                            ..Default::default()
4732                        },
4733                        ..Default::default()
4734                    }],
4735                    ..Default::default()
4736                }],
4737                ..Default::default()
4738            },
4739            stretch::geometry::Size::undefined(),
4740        );
4741
4742        assert_eq!(layout.size.width, 50.0000);
4743        assert_eq!(layout.size.height, 50.0000);
4744        assert_eq!(layout.location.x, 0.0000);
4745        assert_eq!(layout.location.y, 0.0000);
4746
4747        assert_eq!(layout.children[0].size.width, 70.0000);
4748        assert_eq!(layout.children[0].size.height, 50.0000);
4749        assert_eq!(layout.children[0].location.x, -10.0000);
4750        assert_eq!(layout.children[0].location.y, 0.0000);
4751
4752        assert_eq!(layout.children[0].children[0].size.width, 50.0000);
4753        assert_eq!(layout.children[0].children[0].size.height, 50.0000);
4754        assert_eq!(layout.children[0].children[0].location.x, 10.0000);
4755        assert_eq!(layout.children[0].children[0].location.y, 0.0000);
4756    }
4757
4758    #[test]
4759    fn percentage_width_height() {
4760        let layout = stretch::compute(
4761            &stretch::style::Node {
4762                size: stretch::geometry::Size {
4763                    width: stretch::style::Dimension::Points(200.0000),
4764                    height: stretch::style::Dimension::Points(400.0000),
4765                    ..Default::default()
4766                },
4767                children: vec![stretch::style::Node {
4768                    size: stretch::geometry::Size {
4769                        width: stretch::style::Dimension::Percent(0.3000),
4770                        height: stretch::style::Dimension::Percent(0.3000),
4771                        ..Default::default()
4772                    },
4773                    ..Default::default()
4774                }],
4775                ..Default::default()
4776            },
4777            stretch::geometry::Size::undefined(),
4778        );
4779
4780        assert_eq!(layout.size.width, 200.0000);
4781        assert_eq!(layout.size.height, 400.0000);
4782        assert_eq!(layout.location.x, 0.0000);
4783        assert_eq!(layout.location.y, 0.0000);
4784
4785        assert_eq!(layout.children[0].size.width, 60.0000);
4786        assert_eq!(layout.children[0].size.height, 120.0000);
4787        assert_eq!(layout.children[0].location.x, 0.0000);
4788        assert_eq!(layout.children[0].location.y, 0.0000);
4789    }
4790
4791    #[test]
4792    fn margin_auto_mutiple_children_column() {
4793        let layout = stretch::compute(
4794            &stretch::style::Node {
4795                flex_direction: stretch::style::FlexDirection::Column,
4796                align_items: stretch::style::AlignItems::Center,
4797                size: stretch::geometry::Size {
4798                    width: stretch::style::Dimension::Points(200.0000),
4799                    height: stretch::style::Dimension::Points(200.0000),
4800                    ..Default::default()
4801                },
4802                children: vec![
4803                    stretch::style::Node {
4804                        size: stretch::geometry::Size {
4805                            width: stretch::style::Dimension::Points(50.0000),
4806                            height: stretch::style::Dimension::Points(50.0000),
4807                            ..Default::default()
4808                        },
4809                        margin: stretch::geometry::Rect { top: stretch::style::Dimension::Auto, ..Default::default() },
4810                        ..Default::default()
4811                    },
4812                    stretch::style::Node {
4813                        size: stretch::geometry::Size {
4814                            width: stretch::style::Dimension::Points(50.0000),
4815                            height: stretch::style::Dimension::Points(50.0000),
4816                            ..Default::default()
4817                        },
4818                        margin: stretch::geometry::Rect { top: stretch::style::Dimension::Auto, ..Default::default() },
4819                        ..Default::default()
4820                    },
4821                    stretch::style::Node {
4822                        size: stretch::geometry::Size {
4823                            width: stretch::style::Dimension::Points(50.0000),
4824                            height: stretch::style::Dimension::Points(50.0000),
4825                            ..Default::default()
4826                        },
4827                        ..Default::default()
4828                    },
4829                ],
4830                ..Default::default()
4831            },
4832            stretch::geometry::Size::undefined(),
4833        );
4834
4835        assert_eq!(layout.size.width, 200.0000);
4836        assert_eq!(layout.size.height, 200.0000);
4837        assert_eq!(layout.location.x, 0.0000);
4838        assert_eq!(layout.location.y, 0.0000);
4839
4840        assert_eq!(layout.children[0].size.width, 50.0000);
4841        assert_eq!(layout.children[0].size.height, 50.0000);
4842        assert_eq!(layout.children[0].location.x, 75.0000);
4843        assert_eq!(layout.children[0].location.y, 25.0000);
4844
4845        assert_eq!(layout.children[1].size.width, 50.0000);
4846        assert_eq!(layout.children[1].size.height, 50.0000);
4847        assert_eq!(layout.children[1].location.x, 75.0000);
4848        assert_eq!(layout.children[1].location.y, 100.0000);
4849
4850        assert_eq!(layout.children[2].size.width, 50.0000);
4851        assert_eq!(layout.children[2].size.height, 50.0000);
4852        assert_eq!(layout.children[2].location.x, 75.0000);
4853        assert_eq!(layout.children[2].location.y, 150.0000);
4854    }
4855
4856    #[test]
4857    fn min_width_overrides_width_on_root() {
4858        let layout = stretch::compute(
4859            &stretch::style::Node {
4860                size: stretch::geometry::Size {
4861                    width: stretch::style::Dimension::Points(50.0000),
4862                    ..Default::default()
4863                },
4864                min_size: stretch::geometry::Size {
4865                    width: stretch::style::Dimension::Points(100.0000),
4866                    ..Default::default()
4867                },
4868                ..Default::default()
4869            },
4870            stretch::geometry::Size::undefined(),
4871        );
4872
4873        assert_eq!(layout.size.width, 100.0000);
4874        assert_eq!(layout.size.height, 0.0000);
4875        assert_eq!(layout.location.x, 0.0000);
4876        assert_eq!(layout.location.y, 0.0000);
4877    }
4878
4879    #[test]
4880    fn flex_wrap_wrap_to_child_height() {
4881        let layout = stretch::compute(
4882            &stretch::style::Node {
4883                flex_direction: stretch::style::FlexDirection::Column,
4884                children: vec![
4885                    stretch::style::Node {
4886                        flex_wrap: stretch::style::FlexWrap::Wrap,
4887                        align_items: stretch::style::AlignItems::FlexStart,
4888                        children: vec![stretch::style::Node {
4889                            flex_direction: stretch::style::FlexDirection::Column,
4890                            size: stretch::geometry::Size {
4891                                width: stretch::style::Dimension::Points(100.0000),
4892                                ..Default::default()
4893                            },
4894                            children: vec![stretch::style::Node {
4895                                size: stretch::geometry::Size {
4896                                    width: stretch::style::Dimension::Points(100.0000),
4897                                    height: stretch::style::Dimension::Points(100.0000),
4898                                    ..Default::default()
4899                                },
4900                                ..Default::default()
4901                            }],
4902                            ..Default::default()
4903                        }],
4904                        ..Default::default()
4905                    },
4906                    stretch::style::Node {
4907                        size: stretch::geometry::Size {
4908                            width: stretch::style::Dimension::Points(100.0000),
4909                            height: stretch::style::Dimension::Points(100.0000),
4910                            ..Default::default()
4911                        },
4912                        ..Default::default()
4913                    },
4914                ],
4915                ..Default::default()
4916            },
4917            stretch::geometry::Size::undefined(),
4918        );
4919
4920        assert_eq!(layout.size.width, 100.0000);
4921        assert_eq!(layout.size.height, 200.0000);
4922        assert_eq!(layout.location.x, 0.0000);
4923        assert_eq!(layout.location.y, 0.0000);
4924
4925        assert_eq!(layout.children[0].size.width, 100.0000);
4926        assert_eq!(layout.children[0].size.height, 100.0000);
4927        assert_eq!(layout.children[0].location.x, 0.0000);
4928        assert_eq!(layout.children[0].location.y, 0.0000);
4929
4930        assert_eq!(layout.children[0].children[0].size.width, 100.0000);
4931        assert_eq!(layout.children[0].children[0].size.height, 100.0000);
4932        assert_eq!(layout.children[0].children[0].location.x, 0.0000);
4933        assert_eq!(layout.children[0].children[0].location.y, 0.0000);
4934
4935        assert_eq!(layout.children[0].children[0].children[0].size.width, 100.0000);
4936        assert_eq!(layout.children[0].children[0].children[0].size.height, 100.0000);
4937        assert_eq!(layout.children[0].children[0].children[0].location.x, 0.0000);
4938        assert_eq!(layout.children[0].children[0].children[0].location.y, 0.0000);
4939
4940        assert_eq!(layout.children[1].size.width, 100.0000);
4941        assert_eq!(layout.children[1].size.height, 100.0000);
4942        assert_eq!(layout.children[1].location.x, 0.0000);
4943        assert_eq!(layout.children[1].location.y, 100.0000);
4944    }
4945
4946    #[test]
4947    fn wrap_nodes_with_content_sizing_margin_cross() {
4948        let layout = stretch::compute(
4949            &stretch::style::Node {
4950                flex_direction: stretch::style::FlexDirection::Column,
4951                size: stretch::geometry::Size {
4952                    width: stretch::style::Dimension::Points(500.0000),
4953                    height: stretch::style::Dimension::Points(500.0000),
4954                    ..Default::default()
4955                },
4956                children: vec![stretch::style::Node {
4957                    flex_wrap: stretch::style::FlexWrap::Wrap,
4958                    size: stretch::geometry::Size {
4959                        width: stretch::style::Dimension::Points(70.0000),
4960                        ..Default::default()
4961                    },
4962                    children: vec![
4963                        stretch::style::Node {
4964                            flex_direction: stretch::style::FlexDirection::Column,
4965                            children: vec![stretch::style::Node {
4966                                size: stretch::geometry::Size {
4967                                    width: stretch::style::Dimension::Points(40.0000),
4968                                    height: stretch::style::Dimension::Points(40.0000),
4969                                    ..Default::default()
4970                                },
4971                                ..Default::default()
4972                            }],
4973                            ..Default::default()
4974                        },
4975                        stretch::style::Node {
4976                            flex_direction: stretch::style::FlexDirection::Column,
4977                            margin: stretch::geometry::Rect {
4978                                top: stretch::style::Dimension::Points(10.0000),
4979                                ..Default::default()
4980                            },
4981                            children: vec![stretch::style::Node {
4982                                size: stretch::geometry::Size {
4983                                    width: stretch::style::Dimension::Points(40.0000),
4984                                    height: stretch::style::Dimension::Points(40.0000),
4985                                    ..Default::default()
4986                                },
4987                                ..Default::default()
4988                            }],
4989                            ..Default::default()
4990                        },
4991                    ],
4992                    ..Default::default()
4993                }],
4994                ..Default::default()
4995            },
4996            stretch::geometry::Size::undefined(),
4997        );
4998
4999        assert_eq!(layout.size.width, 500.0000);
5000        assert_eq!(layout.size.height, 500.0000);
5001        assert_eq!(layout.location.x, 0.0000);
5002        assert_eq!(layout.location.y, 0.0000);
5003
5004        assert_eq!(layout.children[0].size.width, 70.0000);
5005        assert_eq!(layout.children[0].size.height, 90.0000);
5006        assert_eq!(layout.children[0].location.x, 0.0000);
5007        assert_eq!(layout.children[0].location.y, 0.0000);
5008
5009        assert_eq!(layout.children[0].children[0].size.width, 40.0000);
5010        assert_eq!(layout.children[0].children[0].size.height, 40.0000);
5011        assert_eq!(layout.children[0].children[0].location.x, 0.0000);
5012        assert_eq!(layout.children[0].children[0].location.y, 0.0000);
5013
5014        assert_eq!(layout.children[0].children[0].children[0].size.width, 40.0000);
5015        assert_eq!(layout.children[0].children[0].children[0].size.height, 40.0000);
5016        assert_eq!(layout.children[0].children[0].children[0].location.x, 0.0000);
5017        assert_eq!(layout.children[0].children[0].children[0].location.y, 0.0000);
5018
5019        assert_eq!(layout.children[0].children[1].size.width, 40.0000);
5020        assert_eq!(layout.children[0].children[1].size.height, 40.0000);
5021        assert_eq!(layout.children[0].children[1].location.x, 0.0000);
5022        assert_eq!(layout.children[0].children[1].location.y, 50.0000);
5023
5024        assert_eq!(layout.children[0].children[1].children[0].size.width, 40.0000);
5025        assert_eq!(layout.children[0].children[1].children[0].size.height, 40.0000);
5026        assert_eq!(layout.children[0].children[1].children[0].location.x, 0.0000);
5027        assert_eq!(layout.children[0].children[1].children[0].location.y, 0.0000);
5028    }
5029
5030    #[test]
5031    fn align_baseline() {
5032        let layout = stretch::compute(
5033            &stretch::style::Node {
5034                align_items: stretch::style::AlignItems::Baseline,
5035                size: stretch::geometry::Size {
5036                    width: stretch::style::Dimension::Points(100.0000),
5037                    height: stretch::style::Dimension::Points(100.0000),
5038                    ..Default::default()
5039                },
5040                children: vec![
5041                    stretch::style::Node {
5042                        size: stretch::geometry::Size {
5043                            width: stretch::style::Dimension::Points(50.0000),
5044                            height: stretch::style::Dimension::Points(50.0000),
5045                            ..Default::default()
5046                        },
5047                        ..Default::default()
5048                    },
5049                    stretch::style::Node {
5050                        size: stretch::geometry::Size {
5051                            width: stretch::style::Dimension::Points(50.0000),
5052                            height: stretch::style::Dimension::Points(20.0000),
5053                            ..Default::default()
5054                        },
5055                        ..Default::default()
5056                    },
5057                ],
5058                ..Default::default()
5059            },
5060            stretch::geometry::Size::undefined(),
5061        );
5062
5063        assert_eq!(layout.size.width, 100.0000);
5064        assert_eq!(layout.size.height, 100.0000);
5065        assert_eq!(layout.location.x, 0.0000);
5066        assert_eq!(layout.location.y, 0.0000);
5067
5068        assert_eq!(layout.children[0].size.width, 50.0000);
5069        assert_eq!(layout.children[0].size.height, 50.0000);
5070        assert_eq!(layout.children[0].location.x, 0.0000);
5071        assert_eq!(layout.children[0].location.y, 0.0000);
5072
5073        assert_eq!(layout.children[1].size.width, 50.0000);
5074        assert_eq!(layout.children[1].size.height, 20.0000);
5075        assert_eq!(layout.children[1].location.x, 50.0000);
5076        assert_eq!(layout.children[1].location.y, 30.0000);
5077    }
5078
5079    #[test]
5080    fn margin_with_sibling_row() {
5081        let layout = stretch::compute(
5082            &stretch::style::Node {
5083                size: stretch::geometry::Size {
5084                    width: stretch::style::Dimension::Points(100.0000),
5085                    height: stretch::style::Dimension::Points(100.0000),
5086                    ..Default::default()
5087                },
5088                children: vec![
5089                    stretch::style::Node {
5090                        flex_grow: 1.0000,
5091                        margin: stretch::geometry::Rect {
5092                            end: stretch::style::Dimension::Points(10.0000),
5093                            ..Default::default()
5094                        },
5095                        ..Default::default()
5096                    },
5097                    stretch::style::Node { flex_grow: 1.0000, ..Default::default() },
5098                ],
5099                ..Default::default()
5100            },
5101            stretch::geometry::Size::undefined(),
5102        );
5103
5104        assert_eq!(layout.size.width, 100.0000);
5105        assert_eq!(layout.size.height, 100.0000);
5106        assert_eq!(layout.location.x, 0.0000);
5107        assert_eq!(layout.location.y, 0.0000);
5108
5109        assert_eq!(layout.children[0].size.width, 45.0000);
5110        assert_eq!(layout.children[0].size.height, 100.0000);
5111        assert_eq!(layout.children[0].location.x, 0.0000);
5112        assert_eq!(layout.children[0].location.y, 0.0000);
5113
5114        assert_eq!(layout.children[1].size.width, 45.0000);
5115        assert_eq!(layout.children[1].size.height, 100.0000);
5116        assert_eq!(layout.children[1].location.x, 55.0000);
5117        assert_eq!(layout.children[1].location.y, 0.0000);
5118    }
5119
5120    #[test]
5121    fn wrap_reverse_row_align_content_space_around() {
5122        let layout = stretch::compute(
5123            &stretch::style::Node {
5124                flex_wrap: stretch::style::FlexWrap::WrapReverse,
5125                align_content: stretch::style::AlignContent::SpaceAround,
5126                size: stretch::geometry::Size {
5127                    width: stretch::style::Dimension::Points(100.0000),
5128                    ..Default::default()
5129                },
5130                children: vec![
5131                    stretch::style::Node {
5132                        size: stretch::geometry::Size {
5133                            width: stretch::style::Dimension::Points(30.0000),
5134                            height: stretch::style::Dimension::Points(10.0000),
5135                            ..Default::default()
5136                        },
5137                        ..Default::default()
5138                    },
5139                    stretch::style::Node {
5140                        size: stretch::geometry::Size {
5141                            width: stretch::style::Dimension::Points(30.0000),
5142                            height: stretch::style::Dimension::Points(20.0000),
5143                            ..Default::default()
5144                        },
5145                        ..Default::default()
5146                    },
5147                    stretch::style::Node {
5148                        size: stretch::geometry::Size {
5149                            width: stretch::style::Dimension::Points(30.0000),
5150                            height: stretch::style::Dimension::Points(30.0000),
5151                            ..Default::default()
5152                        },
5153                        ..Default::default()
5154                    },
5155                    stretch::style::Node {
5156                        size: stretch::geometry::Size {
5157                            width: stretch::style::Dimension::Points(30.0000),
5158                            height: stretch::style::Dimension::Points(40.0000),
5159                            ..Default::default()
5160                        },
5161                        ..Default::default()
5162                    },
5163                    stretch::style::Node {
5164                        size: stretch::geometry::Size {
5165                            width: stretch::style::Dimension::Points(30.0000),
5166                            height: stretch::style::Dimension::Points(50.0000),
5167                            ..Default::default()
5168                        },
5169                        ..Default::default()
5170                    },
5171                ],
5172                ..Default::default()
5173            },
5174            stretch::geometry::Size::undefined(),
5175        );
5176
5177        assert_eq!(layout.size.width, 100.0000);
5178        assert_eq!(layout.size.height, 80.0000);
5179        assert_eq!(layout.location.x, 0.0000);
5180        assert_eq!(layout.location.y, 0.0000);
5181
5182        assert_eq!(layout.children[0].size.width, 30.0000);
5183        assert_eq!(layout.children[0].size.height, 10.0000);
5184        assert_eq!(layout.children[0].location.x, 0.0000);
5185        assert_eq!(layout.children[0].location.y, 70.0000);
5186
5187        assert_eq!(layout.children[1].size.width, 30.0000);
5188        assert_eq!(layout.children[1].size.height, 20.0000);
5189        assert_eq!(layout.children[1].location.x, 30.0000);
5190        assert_eq!(layout.children[1].location.y, 60.0000);
5191
5192        assert_eq!(layout.children[2].size.width, 30.0000);
5193        assert_eq!(layout.children[2].size.height, 30.0000);
5194        assert_eq!(layout.children[2].location.x, 60.0000);
5195        assert_eq!(layout.children[2].location.y, 50.0000);
5196
5197        assert_eq!(layout.children[3].size.width, 30.0000);
5198        assert_eq!(layout.children[3].size.height, 40.0000);
5199        assert_eq!(layout.children[3].location.x, 0.0000);
5200        assert_eq!(layout.children[3].location.y, 10.0000);
5201
5202        assert_eq!(layout.children[4].size.width, 30.0000);
5203        assert_eq!(layout.children[4].size.height, 50.0000);
5204        assert_eq!(layout.children[4].location.x, 30.0000);
5205        assert_eq!(layout.children[4].location.y, 0.0000);
5206    }
5207
5208    #[test]
5209    fn wrap_reverse_column() {
5210        let layout = stretch::compute(
5211            &stretch::style::Node {
5212                flex_direction: stretch::style::FlexDirection::Column,
5213                flex_wrap: stretch::style::FlexWrap::WrapReverse,
5214                size: stretch::geometry::Size {
5215                    width: stretch::style::Dimension::Points(100.0000),
5216                    height: stretch::style::Dimension::Points(100.0000),
5217                    ..Default::default()
5218                },
5219                children: vec![
5220                    stretch::style::Node {
5221                        size: stretch::geometry::Size {
5222                            width: stretch::style::Dimension::Points(30.0000),
5223                            height: stretch::style::Dimension::Points(31.0000),
5224                            ..Default::default()
5225                        },
5226                        ..Default::default()
5227                    },
5228                    stretch::style::Node {
5229                        size: stretch::geometry::Size {
5230                            width: stretch::style::Dimension::Points(30.0000),
5231                            height: stretch::style::Dimension::Points(32.0000),
5232                            ..Default::default()
5233                        },
5234                        ..Default::default()
5235                    },
5236                    stretch::style::Node {
5237                        size: stretch::geometry::Size {
5238                            width: stretch::style::Dimension::Points(30.0000),
5239                            height: stretch::style::Dimension::Points(33.0000),
5240                            ..Default::default()
5241                        },
5242                        ..Default::default()
5243                    },
5244                    stretch::style::Node {
5245                        size: stretch::geometry::Size {
5246                            width: stretch::style::Dimension::Points(30.0000),
5247                            height: stretch::style::Dimension::Points(34.0000),
5248                            ..Default::default()
5249                        },
5250                        ..Default::default()
5251                    },
5252                ],
5253                ..Default::default()
5254            },
5255            stretch::geometry::Size::undefined(),
5256        );
5257
5258        assert_eq!(layout.size.width, 100.0000);
5259        assert_eq!(layout.size.height, 100.0000);
5260        assert_eq!(layout.location.x, 0.0000);
5261        assert_eq!(layout.location.y, 0.0000);
5262
5263        assert_eq!(layout.children[0].size.width, 30.0000);
5264        assert_eq!(layout.children[0].size.height, 31.0000);
5265        assert_eq!(layout.children[0].location.x, 70.0000);
5266        assert_eq!(layout.children[0].location.y, 0.0000);
5267
5268        assert_eq!(layout.children[1].size.width, 30.0000);
5269        assert_eq!(layout.children[1].size.height, 32.0000);
5270        assert_eq!(layout.children[1].location.x, 70.0000);
5271        assert_eq!(layout.children[1].location.y, 31.0000);
5272
5273        assert_eq!(layout.children[2].size.width, 30.0000);
5274        assert_eq!(layout.children[2].size.height, 33.0000);
5275        assert_eq!(layout.children[2].location.x, 70.0000);
5276        assert_eq!(layout.children[2].location.y, 63.0000);
5277
5278        assert_eq!(layout.children[3].size.width, 30.0000);
5279        assert_eq!(layout.children[3].size.height, 34.0000);
5280        assert_eq!(layout.children[3].location.x, 20.0000);
5281        assert_eq!(layout.children[3].location.y, 0.0000);
5282    }
5283
5284    #[test]
5285    fn align_items_center_with_child_margin() {
5286        let layout = stretch::compute(
5287            &stretch::style::Node {
5288                align_items: stretch::style::AlignItems::Center,
5289                size: stretch::geometry::Size {
5290                    width: stretch::style::Dimension::Points(100.0000),
5291                    height: stretch::style::Dimension::Points(100.0000),
5292                    ..Default::default()
5293                },
5294                children: vec![stretch::style::Node {
5295                    size: stretch::geometry::Size {
5296                        width: stretch::style::Dimension::Points(10.0000),
5297                        height: stretch::style::Dimension::Points(10.0000),
5298                        ..Default::default()
5299                    },
5300                    margin: stretch::geometry::Rect {
5301                        top: stretch::style::Dimension::Points(10.0000),
5302                        ..Default::default()
5303                    },
5304                    ..Default::default()
5305                }],
5306                ..Default::default()
5307            },
5308            stretch::geometry::Size::undefined(),
5309        );
5310
5311        assert_eq!(layout.size.width, 100.0000);
5312        assert_eq!(layout.size.height, 100.0000);
5313        assert_eq!(layout.location.x, 0.0000);
5314        assert_eq!(layout.location.y, 0.0000);
5315
5316        assert_eq!(layout.children[0].size.width, 10.0000);
5317        assert_eq!(layout.children[0].size.height, 10.0000);
5318        assert_eq!(layout.children[0].location.x, 0.0000);
5319        assert_eq!(layout.children[0].location.y, 50.0000);
5320    }
5321
5322    #[test]
5323    fn flex_direction_column_reverse() {
5324        let layout = stretch::compute(
5325            &stretch::style::Node {
5326                flex_direction: stretch::style::FlexDirection::ColumnReverse,
5327                size: stretch::geometry::Size {
5328                    width: stretch::style::Dimension::Points(100.0000),
5329                    height: stretch::style::Dimension::Points(100.0000),
5330                    ..Default::default()
5331                },
5332                children: vec![
5333                    stretch::style::Node {
5334                        size: stretch::geometry::Size {
5335                            height: stretch::style::Dimension::Points(10.0000),
5336                            ..Default::default()
5337                        },
5338                        ..Default::default()
5339                    },
5340                    stretch::style::Node {
5341                        size: stretch::geometry::Size {
5342                            height: stretch::style::Dimension::Points(10.0000),
5343                            ..Default::default()
5344                        },
5345                        ..Default::default()
5346                    },
5347                    stretch::style::Node {
5348                        size: stretch::geometry::Size {
5349                            height: stretch::style::Dimension::Points(10.0000),
5350                            ..Default::default()
5351                        },
5352                        ..Default::default()
5353                    },
5354                ],
5355                ..Default::default()
5356            },
5357            stretch::geometry::Size::undefined(),
5358        );
5359
5360        assert_eq!(layout.size.width, 100.0000);
5361        assert_eq!(layout.size.height, 100.0000);
5362        assert_eq!(layout.location.x, 0.0000);
5363        assert_eq!(layout.location.y, 0.0000);
5364
5365        assert_eq!(layout.children[0].size.width, 100.0000);
5366        assert_eq!(layout.children[0].size.height, 10.0000);
5367        assert_eq!(layout.children[0].location.x, 0.0000);
5368        assert_eq!(layout.children[0].location.y, 90.0000);
5369
5370        assert_eq!(layout.children[1].size.width, 100.0000);
5371        assert_eq!(layout.children[1].size.height, 10.0000);
5372        assert_eq!(layout.children[1].location.x, 0.0000);
5373        assert_eq!(layout.children[1].location.y, 80.0000);
5374
5375        assert_eq!(layout.children[2].size.width, 100.0000);
5376        assert_eq!(layout.children[2].size.height, 10.0000);
5377        assert_eq!(layout.children[2].location.x, 0.0000);
5378        assert_eq!(layout.children[2].location.y, 70.0000);
5379    }
5380
5381    #[test]
5382    fn flex_direction_column() {
5383        let layout = stretch::compute(
5384            &stretch::style::Node {
5385                flex_direction: stretch::style::FlexDirection::Column,
5386                size: stretch::geometry::Size {
5387                    width: stretch::style::Dimension::Points(100.0000),
5388                    height: stretch::style::Dimension::Points(100.0000),
5389                    ..Default::default()
5390                },
5391                children: vec![
5392                    stretch::style::Node {
5393                        size: stretch::geometry::Size {
5394                            height: stretch::style::Dimension::Points(10.0000),
5395                            ..Default::default()
5396                        },
5397                        ..Default::default()
5398                    },
5399                    stretch::style::Node {
5400                        size: stretch::geometry::Size {
5401                            height: stretch::style::Dimension::Points(10.0000),
5402                            ..Default::default()
5403                        },
5404                        ..Default::default()
5405                    },
5406                    stretch::style::Node {
5407                        size: stretch::geometry::Size {
5408                            height: stretch::style::Dimension::Points(10.0000),
5409                            ..Default::default()
5410                        },
5411                        ..Default::default()
5412                    },
5413                ],
5414                ..Default::default()
5415            },
5416            stretch::geometry::Size::undefined(),
5417        );
5418
5419        assert_eq!(layout.size.width, 100.0000);
5420        assert_eq!(layout.size.height, 100.0000);
5421        assert_eq!(layout.location.x, 0.0000);
5422        assert_eq!(layout.location.y, 0.0000);
5423
5424        assert_eq!(layout.children[0].size.width, 100.0000);
5425        assert_eq!(layout.children[0].size.height, 10.0000);
5426        assert_eq!(layout.children[0].location.x, 0.0000);
5427        assert_eq!(layout.children[0].location.y, 0.0000);
5428
5429        assert_eq!(layout.children[1].size.width, 100.0000);
5430        assert_eq!(layout.children[1].size.height, 10.0000);
5431        assert_eq!(layout.children[1].location.x, 0.0000);
5432        assert_eq!(layout.children[1].location.y, 10.0000);
5433
5434        assert_eq!(layout.children[2].size.width, 100.0000);
5435        assert_eq!(layout.children[2].size.height, 10.0000);
5436        assert_eq!(layout.children[2].location.x, 0.0000);
5437        assert_eq!(layout.children[2].location.y, 20.0000);
5438    }
5439
5440    #[test]
5441    fn align_items_center_child_without_margin_bigger_than_parent() {
5442        let layout = stretch::compute(
5443            &stretch::style::Node {
5444                align_items: stretch::style::AlignItems::Center,
5445                justify_content: stretch::style::JustifyContent::Center,
5446                size: stretch::geometry::Size {
5447                    width: stretch::style::Dimension::Points(50.0000),
5448                    height: stretch::style::Dimension::Points(50.0000),
5449                    ..Default::default()
5450                },
5451                children: vec![stretch::style::Node {
5452                    align_items: stretch::style::AlignItems::Center,
5453                    children: vec![stretch::style::Node {
5454                        size: stretch::geometry::Size {
5455                            width: stretch::style::Dimension::Points(70.0000),
5456                            height: stretch::style::Dimension::Points(70.0000),
5457                            ..Default::default()
5458                        },
5459                        ..Default::default()
5460                    }],
5461                    ..Default::default()
5462                }],
5463                ..Default::default()
5464            },
5465            stretch::geometry::Size::undefined(),
5466        );
5467
5468        assert_eq!(layout.size.width, 50.0000);
5469        assert_eq!(layout.size.height, 50.0000);
5470        assert_eq!(layout.location.x, 0.0000);
5471        assert_eq!(layout.location.y, 0.0000);
5472
5473        assert_eq!(layout.children[0].size.width, 70.0000);
5474        assert_eq!(layout.children[0].size.height, 70.0000);
5475        assert_eq!(layout.children[0].location.x, -10.0000);
5476        assert_eq!(layout.children[0].location.y, -10.0000);
5477
5478        assert_eq!(layout.children[0].children[0].size.width, 70.0000);
5479        assert_eq!(layout.children[0].children[0].size.height, 70.0000);
5480        assert_eq!(layout.children[0].children[0].location.x, 0.0000);
5481        assert_eq!(layout.children[0].children[0].location.y, 0.0000);
5482    }
5483
5484    #[test]
5485    fn align_self_flex_end_override_flex_start() {
5486        let layout = stretch::compute(
5487            &stretch::style::Node {
5488                align_items: stretch::style::AlignItems::FlexStart,
5489                size: stretch::geometry::Size {
5490                    width: stretch::style::Dimension::Points(100.0000),
5491                    height: stretch::style::Dimension::Points(100.0000),
5492                    ..Default::default()
5493                },
5494                children: vec![stretch::style::Node {
5495                    align_self: stretch::style::AlignSelf::FlexEnd,
5496                    size: stretch::geometry::Size {
5497                        width: stretch::style::Dimension::Points(10.0000),
5498                        height: stretch::style::Dimension::Points(10.0000),
5499                        ..Default::default()
5500                    },
5501                    ..Default::default()
5502                }],
5503                ..Default::default()
5504            },
5505            stretch::geometry::Size::undefined(),
5506        );
5507
5508        assert_eq!(layout.size.width, 100.0000);
5509        assert_eq!(layout.size.height, 100.0000);
5510        assert_eq!(layout.location.x, 0.0000);
5511        assert_eq!(layout.location.y, 0.0000);
5512
5513        assert_eq!(layout.children[0].size.width, 10.0000);
5514        assert_eq!(layout.children[0].size.height, 10.0000);
5515        assert_eq!(layout.children[0].location.x, 0.0000);
5516        assert_eq!(layout.children[0].location.y, 90.0000);
5517    }
5518
5519    #[test]
5520    fn rounding_total_fractial() {
5521        let layout = stretch::compute(
5522            &stretch::style::Node {
5523                flex_direction: stretch::style::FlexDirection::Column,
5524                size: stretch::geometry::Size {
5525                    width: stretch::style::Dimension::Points(87.4000),
5526                    height: stretch::style::Dimension::Points(113.4000),
5527                    ..Default::default()
5528                },
5529                children: vec![
5530                    stretch::style::Node {
5531                        flex_grow: 0.7000,
5532                        flex_basis: stretch::style::Dimension::Points(50.3000),
5533                        size: stretch::geometry::Size {
5534                            height: stretch::style::Dimension::Points(20.3000),
5535                            ..Default::default()
5536                        },
5537                        ..Default::default()
5538                    },
5539                    stretch::style::Node {
5540                        flex_grow: 1.6000,
5541                        size: stretch::geometry::Size {
5542                            height: stretch::style::Dimension::Points(10.0000),
5543                            ..Default::default()
5544                        },
5545                        ..Default::default()
5546                    },
5547                    stretch::style::Node {
5548                        flex_grow: 1.1000,
5549                        size: stretch::geometry::Size {
5550                            height: stretch::style::Dimension::Points(10.7000),
5551                            ..Default::default()
5552                        },
5553                        ..Default::default()
5554                    },
5555                ],
5556                ..Default::default()
5557            },
5558            stretch::geometry::Size::undefined(),
5559        );
5560
5561        assert_eq!(layout.size.width, 87.0000);
5562        assert_eq!(layout.size.height, 113.0000);
5563        assert_eq!(layout.location.x, 0.0000);
5564        assert_eq!(layout.location.y, 0.0000);
5565
5566        assert_eq!(layout.children[0].size.width, 87.0000);
5567        assert_eq!(layout.children[0].size.height, 59.0000);
5568        assert_eq!(layout.children[0].location.x, 0.0000);
5569        assert_eq!(layout.children[0].location.y, 0.0000);
5570
5571        assert_eq!(layout.children[1].size.width, 87.0000);
5572        assert_eq!(layout.children[1].size.height, 30.0000);
5573        assert_eq!(layout.children[1].location.x, 0.0000);
5574        assert_eq!(layout.children[1].location.y, 59.0000);
5575
5576        assert_eq!(layout.children[2].size.width, 87.0000);
5577        assert_eq!(layout.children[2].size.height, 24.0000);
5578        assert_eq!(layout.children[2].location.x, 0.0000);
5579        assert_eq!(layout.children[2].location.y, 89.0000);
5580    }
5581
5582    #[test]
5583    fn align_baseline_child_multiline() {
5584        let layout = stretch::compute(
5585            &stretch::style::Node {
5586                align_items: stretch::style::AlignItems::Baseline,
5587                size: stretch::geometry::Size {
5588                    width: stretch::style::Dimension::Points(100.0000),
5589                    ..Default::default()
5590                },
5591                children: vec![
5592                    stretch::style::Node {
5593                        size: stretch::geometry::Size {
5594                            width: stretch::style::Dimension::Points(50.0000),
5595                            height: stretch::style::Dimension::Points(60.0000),
5596                            ..Default::default()
5597                        },
5598                        ..Default::default()
5599                    },
5600                    stretch::style::Node {
5601                        flex_wrap: stretch::style::FlexWrap::Wrap,
5602                        size: stretch::geometry::Size {
5603                            width: stretch::style::Dimension::Points(50.0000),
5604                            ..Default::default()
5605                        },
5606                        children: vec![
5607                            stretch::style::Node {
5608                                size: stretch::geometry::Size {
5609                                    width: stretch::style::Dimension::Points(25.0000),
5610                                    height: stretch::style::Dimension::Points(20.0000),
5611                                    ..Default::default()
5612                                },
5613                                ..Default::default()
5614                            },
5615                            stretch::style::Node {
5616                                size: stretch::geometry::Size {
5617                                    width: stretch::style::Dimension::Points(25.0000),
5618                                    height: stretch::style::Dimension::Points(10.0000),
5619                                    ..Default::default()
5620                                },
5621                                ..Default::default()
5622                            },
5623                            stretch::style::Node {
5624                                size: stretch::geometry::Size {
5625                                    width: stretch::style::Dimension::Points(25.0000),
5626                                    height: stretch::style::Dimension::Points(20.0000),
5627                                    ..Default::default()
5628                                },
5629                                ..Default::default()
5630                            },
5631                            stretch::style::Node {
5632                                size: stretch::geometry::Size {
5633                                    width: stretch::style::Dimension::Points(25.0000),
5634                                    height: stretch::style::Dimension::Points(10.0000),
5635                                    ..Default::default()
5636                                },
5637                                ..Default::default()
5638                            },
5639                        ],
5640                        ..Default::default()
5641                    },
5642                ],
5643                ..Default::default()
5644            },
5645            stretch::geometry::Size::undefined(),
5646        );
5647
5648        assert_eq!(layout.size.width, 100.0000);
5649        assert_eq!(layout.size.height, 80.0000);
5650        assert_eq!(layout.location.x, 0.0000);
5651        assert_eq!(layout.location.y, 0.0000);
5652
5653        assert_eq!(layout.children[0].size.width, 50.0000);
5654        assert_eq!(layout.children[0].size.height, 60.0000);
5655        assert_eq!(layout.children[0].location.x, 0.0000);
5656        assert_eq!(layout.children[0].location.y, 0.0000);
5657
5658        assert_eq!(layout.children[1].size.width, 50.0000);
5659        assert_eq!(layout.children[1].size.height, 40.0000);
5660        assert_eq!(layout.children[1].location.x, 50.0000);
5661        assert_eq!(layout.children[1].location.y, 40.0000);
5662
5663        assert_eq!(layout.children[1].children[0].size.width, 25.0000);
5664        assert_eq!(layout.children[1].children[0].size.height, 20.0000);
5665        assert_eq!(layout.children[1].children[0].location.x, 0.0000);
5666        assert_eq!(layout.children[1].children[0].location.y, 0.0000);
5667
5668        assert_eq!(layout.children[1].children[1].size.width, 25.0000);
5669        assert_eq!(layout.children[1].children[1].size.height, 10.0000);
5670        assert_eq!(layout.children[1].children[1].location.x, 25.0000);
5671        assert_eq!(layout.children[1].children[1].location.y, 0.0000);
5672
5673        assert_eq!(layout.children[1].children[2].size.width, 25.0000);
5674        assert_eq!(layout.children[1].children[2].size.height, 20.0000);
5675        assert_eq!(layout.children[1].children[2].location.x, 0.0000);
5676        assert_eq!(layout.children[1].children[2].location.y, 20.0000);
5677
5678        assert_eq!(layout.children[1].children[3].size.width, 25.0000);
5679        assert_eq!(layout.children[1].children[3].size.height, 10.0000);
5680        assert_eq!(layout.children[1].children[3].location.x, 25.0000);
5681        assert_eq!(layout.children[1].children[3].location.y, 20.0000);
5682    }
5683
5684    #[test]
5685    fn absolute_layout_align_items_center_on_child_only() {
5686        let layout = stretch::compute(
5687            &stretch::style::Node {
5688                size: stretch::geometry::Size {
5689                    width: stretch::style::Dimension::Points(110.0000),
5690                    height: stretch::style::Dimension::Points(100.0000),
5691                    ..Default::default()
5692                },
5693                children: vec![stretch::style::Node {
5694                    position_type: stretch::style::PositionType::Absolute,
5695                    align_self: stretch::style::AlignSelf::Center,
5696                    size: stretch::geometry::Size {
5697                        width: stretch::style::Dimension::Points(60.0000),
5698                        height: stretch::style::Dimension::Points(40.0000),
5699                        ..Default::default()
5700                    },
5701                    ..Default::default()
5702                }],
5703                ..Default::default()
5704            },
5705            stretch::geometry::Size::undefined(),
5706        );
5707
5708        assert_eq!(layout.size.width, 110.0000);
5709        assert_eq!(layout.size.height, 100.0000);
5710        assert_eq!(layout.location.x, 0.0000);
5711        assert_eq!(layout.location.y, 0.0000);
5712
5713        assert_eq!(layout.children[0].size.width, 60.0000);
5714        assert_eq!(layout.children[0].size.height, 40.0000);
5715        assert_eq!(layout.children[0].location.x, 0.0000);
5716        assert_eq!(layout.children[0].location.y, 30.0000);
5717    }
5718
5719    #[test]
5720    fn wrap_reverse_row_single_line_different_size() {
5721        let layout = stretch::compute(
5722            &stretch::style::Node {
5723                flex_wrap: stretch::style::FlexWrap::WrapReverse,
5724                align_content: stretch::style::AlignContent::FlexStart,
5725                size: stretch::geometry::Size {
5726                    width: stretch::style::Dimension::Points(300.0000),
5727                    ..Default::default()
5728                },
5729                children: vec![
5730                    stretch::style::Node {
5731                        size: stretch::geometry::Size {
5732                            width: stretch::style::Dimension::Points(30.0000),
5733                            height: stretch::style::Dimension::Points(10.0000),
5734                            ..Default::default()
5735                        },
5736                        ..Default::default()
5737                    },
5738                    stretch::style::Node {
5739                        size: stretch::geometry::Size {
5740                            width: stretch::style::Dimension::Points(30.0000),
5741                            height: stretch::style::Dimension::Points(20.0000),
5742                            ..Default::default()
5743                        },
5744                        ..Default::default()
5745                    },
5746                    stretch::style::Node {
5747                        size: stretch::geometry::Size {
5748                            width: stretch::style::Dimension::Points(30.0000),
5749                            height: stretch::style::Dimension::Points(30.0000),
5750                            ..Default::default()
5751                        },
5752                        ..Default::default()
5753                    },
5754                    stretch::style::Node {
5755                        size: stretch::geometry::Size {
5756                            width: stretch::style::Dimension::Points(30.0000),
5757                            height: stretch::style::Dimension::Points(40.0000),
5758                            ..Default::default()
5759                        },
5760                        ..Default::default()
5761                    },
5762                    stretch::style::Node {
5763                        size: stretch::geometry::Size {
5764                            width: stretch::style::Dimension::Points(30.0000),
5765                            height: stretch::style::Dimension::Points(50.0000),
5766                            ..Default::default()
5767                        },
5768                        ..Default::default()
5769                    },
5770                ],
5771                ..Default::default()
5772            },
5773            stretch::geometry::Size::undefined(),
5774        );
5775
5776        assert_eq!(layout.size.width, 300.0000);
5777        assert_eq!(layout.size.height, 50.0000);
5778        assert_eq!(layout.location.x, 0.0000);
5779        assert_eq!(layout.location.y, 0.0000);
5780
5781        assert_eq!(layout.children[0].size.width, 30.0000);
5782        assert_eq!(layout.children[0].size.height, 10.0000);
5783        assert_eq!(layout.children[0].location.x, 0.0000);
5784        assert_eq!(layout.children[0].location.y, 40.0000);
5785
5786        assert_eq!(layout.children[1].size.width, 30.0000);
5787        assert_eq!(layout.children[1].size.height, 20.0000);
5788        assert_eq!(layout.children[1].location.x, 30.0000);
5789        assert_eq!(layout.children[1].location.y, 30.0000);
5790
5791        assert_eq!(layout.children[2].size.width, 30.0000);
5792        assert_eq!(layout.children[2].size.height, 30.0000);
5793        assert_eq!(layout.children[2].location.x, 60.0000);
5794        assert_eq!(layout.children[2].location.y, 20.0000);
5795
5796        assert_eq!(layout.children[3].size.width, 30.0000);
5797        assert_eq!(layout.children[3].size.height, 40.0000);
5798        assert_eq!(layout.children[3].location.x, 90.0000);
5799        assert_eq!(layout.children[3].location.y, 10.0000);
5800
5801        assert_eq!(layout.children[4].size.width, 30.0000);
5802        assert_eq!(layout.children[4].size.height, 50.0000);
5803        assert_eq!(layout.children[4].location.x, 120.0000);
5804        assert_eq!(layout.children[4].location.y, 0.0000);
5805    }
5806
5807    #[test]
5808    fn rounding_fractial_input_4() {
5809        let layout = stretch::compute(
5810            &stretch::style::Node {
5811                flex_direction: stretch::style::FlexDirection::Column,
5812                size: stretch::geometry::Size {
5813                    width: stretch::style::Dimension::Points(100.0000),
5814                    height: stretch::style::Dimension::Points(113.4000),
5815                    ..Default::default()
5816                },
5817                children: vec![
5818                    stretch::style::Node {
5819                        flex_grow: 1.0000,
5820                        flex_basis: stretch::style::Dimension::Points(50.0000),
5821                        size: stretch::geometry::Size {
5822                            height: stretch::style::Dimension::Points(20.0000),
5823                            ..Default::default()
5824                        },
5825                        ..Default::default()
5826                    },
5827                    stretch::style::Node {
5828                        flex_grow: 1.0000,
5829                        size: stretch::geometry::Size {
5830                            height: stretch::style::Dimension::Points(10.0000),
5831                            ..Default::default()
5832                        },
5833                        ..Default::default()
5834                    },
5835                    stretch::style::Node {
5836                        flex_grow: 1.0000,
5837                        size: stretch::geometry::Size {
5838                            height: stretch::style::Dimension::Points(10.0000),
5839                            ..Default::default()
5840                        },
5841                        ..Default::default()
5842                    },
5843                ],
5844                ..Default::default()
5845            },
5846            stretch::geometry::Size::undefined(),
5847        );
5848
5849        assert_eq!(layout.size.width, 100.0000);
5850        assert_eq!(layout.size.height, 113.0000);
5851        assert_eq!(layout.location.x, 0.0000);
5852        assert_eq!(layout.location.y, 0.0000);
5853
5854        assert_eq!(layout.children[0].size.width, 100.0000);
5855        assert_eq!(layout.children[0].size.height, 64.0000);
5856        assert_eq!(layout.children[0].location.x, 0.0000);
5857        assert_eq!(layout.children[0].location.y, 0.0000);
5858
5859        assert_eq!(layout.children[1].size.width, 100.0000);
5860        assert_eq!(layout.children[1].size.height, 25.0000);
5861        assert_eq!(layout.children[1].location.x, 0.0000);
5862        assert_eq!(layout.children[1].location.y, 64.0000);
5863
5864        assert_eq!(layout.children[2].size.width, 100.0000);
5865        assert_eq!(layout.children[2].size.height, 24.0000);
5866        assert_eq!(layout.children[2].location.x, 0.0000);
5867        assert_eq!(layout.children[2].location.y, 89.0000);
5868    }
5869
5870    #[test]
5871    fn width_smaller_then_content_with_flex_grow_unconstraint_size() {
5872        let layout = stretch::compute(
5873            &stretch::style::Node {
5874                children: vec![
5875                    stretch::style::Node {
5876                        flex_direction: stretch::style::FlexDirection::Column,
5877                        flex_grow: 1.0000,
5878                        size: stretch::geometry::Size {
5879                            width: stretch::style::Dimension::Points(0.0000),
5880                            ..Default::default()
5881                        },
5882                        children: vec![stretch::style::Node {
5883                            size: stretch::geometry::Size {
5884                                width: stretch::style::Dimension::Points(70.0000),
5885                                height: stretch::style::Dimension::Points(100.0000),
5886                                ..Default::default()
5887                            },
5888                            ..Default::default()
5889                        }],
5890                        ..Default::default()
5891                    },
5892                    stretch::style::Node {
5893                        flex_direction: stretch::style::FlexDirection::Column,
5894                        flex_grow: 1.0000,
5895                        size: stretch::geometry::Size {
5896                            width: stretch::style::Dimension::Points(0.0000),
5897                            ..Default::default()
5898                        },
5899                        children: vec![stretch::style::Node {
5900                            size: stretch::geometry::Size {
5901                                width: stretch::style::Dimension::Points(20.0000),
5902                                height: stretch::style::Dimension::Points(100.0000),
5903                                ..Default::default()
5904                            },
5905                            ..Default::default()
5906                        }],
5907                        ..Default::default()
5908                    },
5909                ],
5910                ..Default::default()
5911            },
5912            stretch::geometry::Size::undefined(),
5913        );
5914
5915        assert_eq!(layout.size.width, 0.0000);
5916        assert_eq!(layout.size.height, 100.0000);
5917        assert_eq!(layout.location.x, 0.0000);
5918        assert_eq!(layout.location.y, 0.0000);
5919
5920        assert_eq!(layout.children[0].size.width, 0.0000);
5921        assert_eq!(layout.children[0].size.height, 100.0000);
5922        assert_eq!(layout.children[0].location.x, 0.0000);
5923        assert_eq!(layout.children[0].location.y, 0.0000);
5924
5925        assert_eq!(layout.children[0].children[0].size.width, 70.0000);
5926        assert_eq!(layout.children[0].children[0].size.height, 100.0000);
5927        assert_eq!(layout.children[0].children[0].location.x, 0.0000);
5928        assert_eq!(layout.children[0].children[0].location.y, 0.0000);
5929
5930        assert_eq!(layout.children[1].size.width, 0.0000);
5931        assert_eq!(layout.children[1].size.height, 100.0000);
5932        assert_eq!(layout.children[1].location.x, 0.0000);
5933        assert_eq!(layout.children[1].location.y, 0.0000);
5934
5935        assert_eq!(layout.children[1].children[0].size.width, 20.0000);
5936        assert_eq!(layout.children[1].children[0].size.height, 100.0000);
5937        assert_eq!(layout.children[1].children[0].location.x, 0.0000);
5938        assert_eq!(layout.children[1].children[0].location.y, 0.0000);
5939    }
5940
5941    #[test]
5942    fn padding_flex_child() {
5943        let layout = stretch::compute(
5944            &stretch::style::Node {
5945                size: stretch::geometry::Size {
5946                    width: stretch::style::Dimension::Points(100.0000),
5947                    height: stretch::style::Dimension::Points(100.0000),
5948                    ..Default::default()
5949                },
5950                padding: stretch::geometry::Rect {
5951                    start: stretch::style::Dimension::Points(10.0000),
5952                    end: stretch::style::Dimension::Points(10.0000),
5953                    top: stretch::style::Dimension::Points(10.0000),
5954                    bottom: stretch::style::Dimension::Points(10.0000),
5955                    ..Default::default()
5956                },
5957                children: vec![stretch::style::Node {
5958                    flex_grow: 1.0000,
5959                    size: stretch::geometry::Size {
5960                        width: stretch::style::Dimension::Points(10.0000),
5961                        ..Default::default()
5962                    },
5963                    ..Default::default()
5964                }],
5965                ..Default::default()
5966            },
5967            stretch::geometry::Size::undefined(),
5968        );
5969
5970        assert_eq!(layout.size.width, 100.0000);
5971        assert_eq!(layout.size.height, 100.0000);
5972        assert_eq!(layout.location.x, 0.0000);
5973        assert_eq!(layout.location.y, 0.0000);
5974
5975        assert_eq!(layout.children[0].size.width, 80.0000);
5976        assert_eq!(layout.children[0].size.height, 80.0000);
5977        assert_eq!(layout.children[0].location.x, 10.0000);
5978        assert_eq!(layout.children[0].location.y, 10.0000);
5979    }
5980
5981    #[test]
5982    fn flex_direction_row_reverse() {
5983        let layout = stretch::compute(
5984            &stretch::style::Node {
5985                flex_direction: stretch::style::FlexDirection::RowReverse,
5986                size: stretch::geometry::Size {
5987                    width: stretch::style::Dimension::Points(100.0000),
5988                    height: stretch::style::Dimension::Points(100.0000),
5989                    ..Default::default()
5990                },
5991                children: vec![
5992                    stretch::style::Node {
5993                        size: stretch::geometry::Size {
5994                            width: stretch::style::Dimension::Points(10.0000),
5995                            ..Default::default()
5996                        },
5997                        ..Default::default()
5998                    },
5999                    stretch::style::Node {
6000                        size: stretch::geometry::Size {
6001                            width: stretch::style::Dimension::Points(10.0000),
6002                            ..Default::default()
6003                        },
6004                        ..Default::default()
6005                    },
6006                    stretch::style::Node {
6007                        size: stretch::geometry::Size {
6008                            width: stretch::style::Dimension::Points(10.0000),
6009                            ..Default::default()
6010                        },
6011                        ..Default::default()
6012                    },
6013                ],
6014                ..Default::default()
6015            },
6016            stretch::geometry::Size::undefined(),
6017        );
6018
6019        assert_eq!(layout.size.width, 100.0000);
6020        assert_eq!(layout.size.height, 100.0000);
6021        assert_eq!(layout.location.x, 0.0000);
6022        assert_eq!(layout.location.y, 0.0000);
6023
6024        assert_eq!(layout.children[0].size.width, 10.0000);
6025        assert_eq!(layout.children[0].size.height, 100.0000);
6026        assert_eq!(layout.children[0].location.x, 90.0000);
6027        assert_eq!(layout.children[0].location.y, 0.0000);
6028
6029        assert_eq!(layout.children[1].size.width, 10.0000);
6030        assert_eq!(layout.children[1].size.height, 100.0000);
6031        assert_eq!(layout.children[1].location.x, 80.0000);
6032        assert_eq!(layout.children[1].location.y, 0.0000);
6033
6034        assert_eq!(layout.children[2].size.width, 10.0000);
6035        assert_eq!(layout.children[2].size.height, 100.0000);
6036        assert_eq!(layout.children[2].location.x, 70.0000);
6037        assert_eq!(layout.children[2].location.y, 0.0000);
6038    }
6039
6040    #[test]
6041    fn percentage_size_based_on_parent_inner_size() {
6042        let layout = stretch::compute(
6043            &stretch::style::Node {
6044                flex_direction: stretch::style::FlexDirection::Column,
6045                size: stretch::geometry::Size {
6046                    width: stretch::style::Dimension::Points(200.0000),
6047                    height: stretch::style::Dimension::Points(400.0000),
6048                    ..Default::default()
6049                },
6050                padding: stretch::geometry::Rect {
6051                    start: stretch::style::Dimension::Points(20.0000),
6052                    end: stretch::style::Dimension::Points(20.0000),
6053                    top: stretch::style::Dimension::Points(20.0000),
6054                    bottom: stretch::style::Dimension::Points(20.0000),
6055                    ..Default::default()
6056                },
6057                children: vec![stretch::style::Node {
6058                    size: stretch::geometry::Size {
6059                        width: stretch::style::Dimension::Percent(0.5000),
6060                        height: stretch::style::Dimension::Percent(0.5000),
6061                        ..Default::default()
6062                    },
6063                    ..Default::default()
6064                }],
6065                ..Default::default()
6066            },
6067            stretch::geometry::Size::undefined(),
6068        );
6069
6070        assert_eq!(layout.size.width, 200.0000);
6071        assert_eq!(layout.size.height, 400.0000);
6072        assert_eq!(layout.location.x, 0.0000);
6073        assert_eq!(layout.location.y, 0.0000);
6074
6075        assert_eq!(layout.children[0].size.width, 80.0000);
6076        assert_eq!(layout.children[0].size.height, 180.0000);
6077        assert_eq!(layout.children[0].location.x, 20.0000);
6078        assert_eq!(layout.children[0].location.y, 20.0000);
6079    }
6080
6081    #[test]
6082    fn wrap_reverse_row_align_content_stretch() {
6083        let layout = stretch::compute(
6084            &stretch::style::Node {
6085                flex_wrap: stretch::style::FlexWrap::WrapReverse,
6086                size: stretch::geometry::Size {
6087                    width: stretch::style::Dimension::Points(100.0000),
6088                    ..Default::default()
6089                },
6090                children: vec![
6091                    stretch::style::Node {
6092                        size: stretch::geometry::Size {
6093                            width: stretch::style::Dimension::Points(30.0000),
6094                            height: stretch::style::Dimension::Points(10.0000),
6095                            ..Default::default()
6096                        },
6097                        ..Default::default()
6098                    },
6099                    stretch::style::Node {
6100                        size: stretch::geometry::Size {
6101                            width: stretch::style::Dimension::Points(30.0000),
6102                            height: stretch::style::Dimension::Points(20.0000),
6103                            ..Default::default()
6104                        },
6105                        ..Default::default()
6106                    },
6107                    stretch::style::Node {
6108                        size: stretch::geometry::Size {
6109                            width: stretch::style::Dimension::Points(30.0000),
6110                            height: stretch::style::Dimension::Points(30.0000),
6111                            ..Default::default()
6112                        },
6113                        ..Default::default()
6114                    },
6115                    stretch::style::Node {
6116                        size: stretch::geometry::Size {
6117                            width: stretch::style::Dimension::Points(30.0000),
6118                            height: stretch::style::Dimension::Points(40.0000),
6119                            ..Default::default()
6120                        },
6121                        ..Default::default()
6122                    },
6123                    stretch::style::Node {
6124                        size: stretch::geometry::Size {
6125                            width: stretch::style::Dimension::Points(30.0000),
6126                            height: stretch::style::Dimension::Points(50.0000),
6127                            ..Default::default()
6128                        },
6129                        ..Default::default()
6130                    },
6131                ],
6132                ..Default::default()
6133            },
6134            stretch::geometry::Size::undefined(),
6135        );
6136
6137        assert_eq!(layout.size.width, 100.0000);
6138        assert_eq!(layout.size.height, 80.0000);
6139        assert_eq!(layout.location.x, 0.0000);
6140        assert_eq!(layout.location.y, 0.0000);
6141
6142        assert_eq!(layout.children[0].size.width, 30.0000);
6143        assert_eq!(layout.children[0].size.height, 10.0000);
6144        assert_eq!(layout.children[0].location.x, 0.0000);
6145        assert_eq!(layout.children[0].location.y, 70.0000);
6146
6147        assert_eq!(layout.children[1].size.width, 30.0000);
6148        assert_eq!(layout.children[1].size.height, 20.0000);
6149        assert_eq!(layout.children[1].location.x, 30.0000);
6150        assert_eq!(layout.children[1].location.y, 60.0000);
6151
6152        assert_eq!(layout.children[2].size.width, 30.0000);
6153        assert_eq!(layout.children[2].size.height, 30.0000);
6154        assert_eq!(layout.children[2].location.x, 60.0000);
6155        assert_eq!(layout.children[2].location.y, 50.0000);
6156
6157        assert_eq!(layout.children[3].size.width, 30.0000);
6158        assert_eq!(layout.children[3].size.height, 40.0000);
6159        assert_eq!(layout.children[3].location.x, 0.0000);
6160        assert_eq!(layout.children[3].location.y, 10.0000);
6161
6162        assert_eq!(layout.children[4].size.width, 30.0000);
6163        assert_eq!(layout.children[4].size.height, 50.0000);
6164        assert_eq!(layout.children[4].location.x, 30.0000);
6165        assert_eq!(layout.children[4].location.y, 0.0000);
6166    }
6167
6168    #[test]
6169    fn margin_auto_top() {
6170        let layout = stretch::compute(
6171            &stretch::style::Node {
6172                align_items: stretch::style::AlignItems::Center,
6173                size: stretch::geometry::Size {
6174                    width: stretch::style::Dimension::Points(200.0000),
6175                    height: stretch::style::Dimension::Points(200.0000),
6176                    ..Default::default()
6177                },
6178                children: vec![
6179                    stretch::style::Node {
6180                        size: stretch::geometry::Size {
6181                            width: stretch::style::Dimension::Points(50.0000),
6182                            height: stretch::style::Dimension::Points(50.0000),
6183                            ..Default::default()
6184                        },
6185                        margin: stretch::geometry::Rect { top: stretch::style::Dimension::Auto, ..Default::default() },
6186                        ..Default::default()
6187                    },
6188                    stretch::style::Node {
6189                        size: stretch::geometry::Size {
6190                            width: stretch::style::Dimension::Points(50.0000),
6191                            height: stretch::style::Dimension::Points(50.0000),
6192                            ..Default::default()
6193                        },
6194                        ..Default::default()
6195                    },
6196                ],
6197                ..Default::default()
6198            },
6199            stretch::geometry::Size::undefined(),
6200        );
6201
6202        assert_eq!(layout.size.width, 200.0000);
6203        assert_eq!(layout.size.height, 200.0000);
6204        assert_eq!(layout.location.x, 0.0000);
6205        assert_eq!(layout.location.y, 0.0000);
6206
6207        assert_eq!(layout.children[0].size.width, 50.0000);
6208        assert_eq!(layout.children[0].size.height, 50.0000);
6209        assert_eq!(layout.children[0].location.x, 0.0000);
6210        assert_eq!(layout.children[0].location.y, 150.0000);
6211
6212        assert_eq!(layout.children[1].size.width, 50.0000);
6213        assert_eq!(layout.children[1].size.height, 50.0000);
6214        assert_eq!(layout.children[1].location.x, 50.0000);
6215        assert_eq!(layout.children[1].location.y, 75.0000);
6216    }
6217
6218    #[test]
6219    fn flex_grow_within_constrained_max_row() {
6220        let layout = stretch::compute(
6221            &stretch::style::Node {
6222                flex_direction: stretch::style::FlexDirection::Column,
6223                size: stretch::geometry::Size {
6224                    width: stretch::style::Dimension::Points(200.0000),
6225                    ..Default::default()
6226                },
6227                children: vec![stretch::style::Node {
6228                    size: stretch::geometry::Size {
6229                        height: stretch::style::Dimension::Points(100.0000),
6230                        ..Default::default()
6231                    },
6232                    max_size: stretch::geometry::Size {
6233                        width: stretch::style::Dimension::Points(100.0000),
6234                        ..Default::default()
6235                    },
6236                    children: vec![
6237                        stretch::style::Node {
6238                            flex_shrink: 1.0000,
6239                            flex_basis: stretch::style::Dimension::Points(100.0000),
6240                            ..Default::default()
6241                        },
6242                        stretch::style::Node {
6243                            size: stretch::geometry::Size {
6244                                width: stretch::style::Dimension::Points(50.0000),
6245                                ..Default::default()
6246                            },
6247                            ..Default::default()
6248                        },
6249                    ],
6250                    ..Default::default()
6251                }],
6252                ..Default::default()
6253            },
6254            stretch::geometry::Size::undefined(),
6255        );
6256
6257        assert_eq!(layout.size.width, 200.0000);
6258        assert_eq!(layout.size.height, 100.0000);
6259        assert_eq!(layout.location.x, 0.0000);
6260        assert_eq!(layout.location.y, 0.0000);
6261
6262        assert_eq!(layout.children[0].size.width, 100.0000);
6263        assert_eq!(layout.children[0].size.height, 100.0000);
6264        assert_eq!(layout.children[0].location.x, 0.0000);
6265        assert_eq!(layout.children[0].location.y, 0.0000);
6266
6267        assert_eq!(layout.children[0].children[0].size.width, 67.0000);
6268        assert_eq!(layout.children[0].children[0].size.height, 100.0000);
6269        assert_eq!(layout.children[0].children[0].location.x, 0.0000);
6270        assert_eq!(layout.children[0].children[0].location.y, 0.0000);
6271
6272        assert_eq!(layout.children[0].children[1].size.width, 33.0000);
6273        assert_eq!(layout.children[0].children[1].size.height, 100.0000);
6274        assert_eq!(layout.children[0].children[1].location.x, 67.0000);
6275        assert_eq!(layout.children[0].children[1].location.y, 0.0000);
6276    }
6277
6278    #[test]
6279    fn absolute_layout_align_items_and_justify_content_center() {
6280        let layout = stretch::compute(
6281            &stretch::style::Node {
6282                align_items: stretch::style::AlignItems::Center,
6283                justify_content: stretch::style::JustifyContent::Center,
6284                size: stretch::geometry::Size {
6285                    width: stretch::style::Dimension::Points(110.0000),
6286                    height: stretch::style::Dimension::Points(100.0000),
6287                    ..Default::default()
6288                },
6289                children: vec![stretch::style::Node {
6290                    position_type: stretch::style::PositionType::Absolute,
6291                    size: stretch::geometry::Size {
6292                        width: stretch::style::Dimension::Points(60.0000),
6293                        height: stretch::style::Dimension::Points(40.0000),
6294                        ..Default::default()
6295                    },
6296                    ..Default::default()
6297                }],
6298                ..Default::default()
6299            },
6300            stretch::geometry::Size::undefined(),
6301        );
6302
6303        assert_eq!(layout.size.width, 110.0000);
6304        assert_eq!(layout.size.height, 100.0000);
6305        assert_eq!(layout.location.x, 0.0000);
6306        assert_eq!(layout.location.y, 0.0000);
6307
6308        assert_eq!(layout.children[0].size.width, 60.0000);
6309        assert_eq!(layout.children[0].size.height, 40.0000);
6310        assert_eq!(layout.children[0].location.x, 25.0000);
6311        assert_eq!(layout.children[0].location.y, 30.0000);
6312    }
6313
6314    #[test]
6315    fn align_self_flex_end() {
6316        let layout = stretch::compute(
6317            &stretch::style::Node {
6318                size: stretch::geometry::Size {
6319                    width: stretch::style::Dimension::Points(100.0000),
6320                    height: stretch::style::Dimension::Points(100.0000),
6321                    ..Default::default()
6322                },
6323                children: vec![stretch::style::Node {
6324                    align_self: stretch::style::AlignSelf::FlexEnd,
6325                    size: stretch::geometry::Size {
6326                        width: stretch::style::Dimension::Points(10.0000),
6327                        height: stretch::style::Dimension::Points(10.0000),
6328                        ..Default::default()
6329                    },
6330                    ..Default::default()
6331                }],
6332                ..Default::default()
6333            },
6334            stretch::geometry::Size::undefined(),
6335        );
6336
6337        assert_eq!(layout.size.width, 100.0000);
6338        assert_eq!(layout.size.height, 100.0000);
6339        assert_eq!(layout.location.x, 0.0000);
6340        assert_eq!(layout.location.y, 0.0000);
6341
6342        assert_eq!(layout.children[0].size.width, 10.0000);
6343        assert_eq!(layout.children[0].size.height, 10.0000);
6344        assert_eq!(layout.children[0].location.x, 0.0000);
6345        assert_eq!(layout.children[0].location.y, 90.0000);
6346    }
6347
6348    #[test]
6349    fn margin_auto_left_child_bigger_than_parent() {
6350        let layout = stretch::compute(
6351            &stretch::style::Node {
6352                justify_content: stretch::style::JustifyContent::Center,
6353                size: stretch::geometry::Size {
6354                    width: stretch::style::Dimension::Points(52.0000),
6355                    height: stretch::style::Dimension::Points(52.0000),
6356                    ..Default::default()
6357                },
6358                children: vec![stretch::style::Node {
6359                    size: stretch::geometry::Size {
6360                        width: stretch::style::Dimension::Points(72.0000),
6361                        height: stretch::style::Dimension::Points(72.0000),
6362                        ..Default::default()
6363                    },
6364                    margin: stretch::geometry::Rect { start: stretch::style::Dimension::Auto, ..Default::default() },
6365                    ..Default::default()
6366                }],
6367                ..Default::default()
6368            },
6369            stretch::geometry::Size::undefined(),
6370        );
6371
6372        assert_eq!(layout.size.width, 52.0000);
6373        assert_eq!(layout.size.height, 52.0000);
6374        assert_eq!(layout.location.x, 0.0000);
6375        assert_eq!(layout.location.y, 0.0000);
6376
6377        assert_eq!(layout.children[0].size.width, 52.0000);
6378        assert_eq!(layout.children[0].size.height, 72.0000);
6379        assert_eq!(layout.children[0].location.x, 0.0000);
6380        assert_eq!(layout.children[0].location.y, 0.0000);
6381    }
6382
6383    #[test]
6384    fn wrapped_row_within_align_items_flex_end() {
6385        let layout = stretch::compute(
6386            &stretch::style::Node {
6387                flex_direction: stretch::style::FlexDirection::Column,
6388                align_items: stretch::style::AlignItems::FlexEnd,
6389                size: stretch::geometry::Size {
6390                    width: stretch::style::Dimension::Points(200.0000),
6391                    height: stretch::style::Dimension::Points(200.0000),
6392                    ..Default::default()
6393                },
6394                children: vec![stretch::style::Node {
6395                    flex_wrap: stretch::style::FlexWrap::Wrap,
6396                    children: vec![
6397                        stretch::style::Node {
6398                            size: stretch::geometry::Size {
6399                                width: stretch::style::Dimension::Points(150.0000),
6400                                height: stretch::style::Dimension::Points(80.0000),
6401                                ..Default::default()
6402                            },
6403                            ..Default::default()
6404                        },
6405                        stretch::style::Node {
6406                            size: stretch::geometry::Size {
6407                                width: stretch::style::Dimension::Points(80.0000),
6408                                height: stretch::style::Dimension::Points(80.0000),
6409                                ..Default::default()
6410                            },
6411                            ..Default::default()
6412                        },
6413                    ],
6414                    ..Default::default()
6415                }],
6416                ..Default::default()
6417            },
6418            stretch::geometry::Size::undefined(),
6419        );
6420
6421        assert_eq!(layout.size.width, 200.0000);
6422        assert_eq!(layout.size.height, 200.0000);
6423        assert_eq!(layout.location.x, 0.0000);
6424        assert_eq!(layout.location.y, 0.0000);
6425
6426        assert_eq!(layout.children[0].size.width, 200.0000);
6427        assert_eq!(layout.children[0].size.height, 160.0000);
6428        assert_eq!(layout.children[0].location.x, 0.0000);
6429        assert_eq!(layout.children[0].location.y, 0.0000);
6430
6431        assert_eq!(layout.children[0].children[0].size.width, 150.0000);
6432        assert_eq!(layout.children[0].children[0].size.height, 80.0000);
6433        assert_eq!(layout.children[0].children[0].location.x, 0.0000);
6434        assert_eq!(layout.children[0].children[0].location.y, 0.0000);
6435
6436        assert_eq!(layout.children[0].children[1].size.width, 80.0000);
6437        assert_eq!(layout.children[0].children[1].size.height, 80.0000);
6438        assert_eq!(layout.children[0].children[1].location.x, 0.0000);
6439        assert_eq!(layout.children[0].children[1].location.y, 80.0000);
6440    }
6441
6442    #[test]
6443    fn min_height_overrides_height() {
6444        let layout = stretch::compute(
6445            &stretch::style::Node {
6446                children: vec![stretch::style::Node {
6447                    size: stretch::geometry::Size {
6448                        height: stretch::style::Dimension::Points(50.0000),
6449                        ..Default::default()
6450                    },
6451                    min_size: stretch::geometry::Size {
6452                        height: stretch::style::Dimension::Points(100.0000),
6453                        ..Default::default()
6454                    },
6455                    ..Default::default()
6456                }],
6457                ..Default::default()
6458            },
6459            stretch::geometry::Size::undefined(),
6460        );
6461
6462        assert_eq!(layout.size.width, 0.0000);
6463        assert_eq!(layout.size.height, 100.0000);
6464        assert_eq!(layout.location.x, 0.0000);
6465        assert_eq!(layout.location.y, 0.0000);
6466
6467        assert_eq!(layout.children[0].size.width, 0.0000);
6468        assert_eq!(layout.children[0].size.height, 100.0000);
6469        assert_eq!(layout.children[0].location.x, 0.0000);
6470        assert_eq!(layout.children[0].location.y, 0.0000);
6471    }
6472
6473    #[test]
6474    fn align_strech_should_size_based_on_parent() {
6475        let layout = stretch::compute(
6476            &stretch::style::Node {
6477                size: stretch::geometry::Size {
6478                    width: stretch::style::Dimension::Points(100.0000),
6479                    height: stretch::style::Dimension::Points(100.0000),
6480                    ..Default::default()
6481                },
6482                children: vec![stretch::style::Node {
6483                    justify_content: stretch::style::JustifyContent::Center,
6484                    flex_grow: 0.0000,
6485                    flex_shrink: 1.0000,
6486                    children: vec![stretch::style::Node {
6487                        flex_grow: 1.0000,
6488                        flex_shrink: 1.0000,
6489                        children: vec![stretch::style::Node {
6490                            size: stretch::geometry::Size {
6491                                width: stretch::style::Dimension::Points(20.0000),
6492                                height: stretch::style::Dimension::Points(20.0000),
6493                                ..Default::default()
6494                            },
6495                            ..Default::default()
6496                        }],
6497                        ..Default::default()
6498                    }],
6499                    ..Default::default()
6500                }],
6501                ..Default::default()
6502            },
6503            stretch::geometry::Size::undefined(),
6504        );
6505
6506        assert_eq!(layout.size.width, 100.0000);
6507        assert_eq!(layout.size.height, 100.0000);
6508        assert_eq!(layout.location.x, 0.0000);
6509        assert_eq!(layout.location.y, 0.0000);
6510
6511        assert_eq!(layout.children[0].size.width, 20.0000);
6512        assert_eq!(layout.children[0].size.height, 100.0000);
6513        assert_eq!(layout.children[0].location.x, 0.0000);
6514        assert_eq!(layout.children[0].location.y, 0.0000);
6515
6516        assert_eq!(layout.children[0].children[0].size.width, 20.0000);
6517        assert_eq!(layout.children[0].children[0].size.height, 100.0000);
6518        assert_eq!(layout.children[0].children[0].location.x, 0.0000);
6519        assert_eq!(layout.children[0].children[0].location.y, 0.0000);
6520
6521        assert_eq!(layout.children[0].children[0].children[0].size.width, 20.0000);
6522        assert_eq!(layout.children[0].children[0].children[0].size.height, 20.0000);
6523        assert_eq!(layout.children[0].children[0].children[0].location.x, 0.0000);
6524        assert_eq!(layout.children[0].children[0].children[0].location.y, 0.0000);
6525    }
6526
6527    #[test]
6528    fn wrap_row_align_items_flex_end() {
6529        let layout = stretch::compute(
6530            &stretch::style::Node {
6531                flex_wrap: stretch::style::FlexWrap::Wrap,
6532                align_items: stretch::style::AlignItems::FlexEnd,
6533                size: stretch::geometry::Size {
6534                    width: stretch::style::Dimension::Points(100.0000),
6535                    ..Default::default()
6536                },
6537                children: vec![
6538                    stretch::style::Node {
6539                        size: stretch::geometry::Size {
6540                            width: stretch::style::Dimension::Points(30.0000),
6541                            height: stretch::style::Dimension::Points(10.0000),
6542                            ..Default::default()
6543                        },
6544                        ..Default::default()
6545                    },
6546                    stretch::style::Node {
6547                        size: stretch::geometry::Size {
6548                            width: stretch::style::Dimension::Points(30.0000),
6549                            height: stretch::style::Dimension::Points(20.0000),
6550                            ..Default::default()
6551                        },
6552                        ..Default::default()
6553                    },
6554                    stretch::style::Node {
6555                        size: stretch::geometry::Size {
6556                            width: stretch::style::Dimension::Points(30.0000),
6557                            height: stretch::style::Dimension::Points(30.0000),
6558                            ..Default::default()
6559                        },
6560                        ..Default::default()
6561                    },
6562                    stretch::style::Node {
6563                        size: stretch::geometry::Size {
6564                            width: stretch::style::Dimension::Points(30.0000),
6565                            height: stretch::style::Dimension::Points(30.0000),
6566                            ..Default::default()
6567                        },
6568                        ..Default::default()
6569                    },
6570                ],
6571                ..Default::default()
6572            },
6573            stretch::geometry::Size::undefined(),
6574        );
6575
6576        assert_eq!(layout.size.width, 100.0000);
6577        assert_eq!(layout.size.height, 60.0000);
6578        assert_eq!(layout.location.x, 0.0000);
6579        assert_eq!(layout.location.y, 0.0000);
6580
6581        assert_eq!(layout.children[0].size.width, 30.0000);
6582        assert_eq!(layout.children[0].size.height, 10.0000);
6583        assert_eq!(layout.children[0].location.x, 0.0000);
6584        assert_eq!(layout.children[0].location.y, 20.0000);
6585
6586        assert_eq!(layout.children[1].size.width, 30.0000);
6587        assert_eq!(layout.children[1].size.height, 20.0000);
6588        assert_eq!(layout.children[1].location.x, 30.0000);
6589        assert_eq!(layout.children[1].location.y, 10.0000);
6590
6591        assert_eq!(layout.children[2].size.width, 30.0000);
6592        assert_eq!(layout.children[2].size.height, 30.0000);
6593        assert_eq!(layout.children[2].location.x, 60.0000);
6594        assert_eq!(layout.children[2].location.y, 0.0000);
6595
6596        assert_eq!(layout.children[3].size.width, 30.0000);
6597        assert_eq!(layout.children[3].size.height, 30.0000);
6598        assert_eq!(layout.children[3].location.x, 0.0000);
6599        assert_eq!(layout.children[3].location.y, 30.0000);
6600    }
6601
6602    #[test]
6603    fn size_defined_by_child_with_border() {
6604        let layout = stretch::compute(
6605            &stretch::style::Node {
6606                border: stretch::geometry::Rect {
6607                    start: stretch::style::Dimension::Points(10.0000),
6608                    end: stretch::style::Dimension::Points(10.0000),
6609                    top: stretch::style::Dimension::Points(10.0000),
6610                    bottom: stretch::style::Dimension::Points(10.0000),
6611                    ..Default::default()
6612                },
6613                children: vec![stretch::style::Node {
6614                    size: stretch::geometry::Size {
6615                        width: stretch::style::Dimension::Points(10.0000),
6616                        height: stretch::style::Dimension::Points(10.0000),
6617                        ..Default::default()
6618                    },
6619                    ..Default::default()
6620                }],
6621                ..Default::default()
6622            },
6623            stretch::geometry::Size::undefined(),
6624        );
6625
6626        assert_eq!(layout.size.width, 30.0000);
6627        assert_eq!(layout.size.height, 30.0000);
6628        assert_eq!(layout.location.x, 0.0000);
6629        assert_eq!(layout.location.y, 0.0000);
6630
6631        assert_eq!(layout.children[0].size.width, 10.0000);
6632        assert_eq!(layout.children[0].size.height, 10.0000);
6633        assert_eq!(layout.children[0].location.x, 10.0000);
6634        assert_eq!(layout.children[0].location.y, 10.0000);
6635    }
6636
6637    #[test]
6638    fn margin_auto_bottom_and_top_justify_center() {
6639        let layout = stretch::compute(
6640            &stretch::style::Node {
6641                justify_content: stretch::style::JustifyContent::Center,
6642                size: stretch::geometry::Size {
6643                    width: stretch::style::Dimension::Points(200.0000),
6644                    height: stretch::style::Dimension::Points(200.0000),
6645                    ..Default::default()
6646                },
6647                children: vec![
6648                    stretch::style::Node {
6649                        size: stretch::geometry::Size {
6650                            width: stretch::style::Dimension::Points(50.0000),
6651                            height: stretch::style::Dimension::Points(50.0000),
6652                            ..Default::default()
6653                        },
6654                        margin: stretch::geometry::Rect {
6655                            top: stretch::style::Dimension::Auto,
6656                            bottom: stretch::style::Dimension::Auto,
6657                            ..Default::default()
6658                        },
6659                        ..Default::default()
6660                    },
6661                    stretch::style::Node {
6662                        size: stretch::geometry::Size {
6663                            width: stretch::style::Dimension::Points(50.0000),
6664                            height: stretch::style::Dimension::Points(50.0000),
6665                            ..Default::default()
6666                        },
6667                        ..Default::default()
6668                    },
6669                ],
6670                ..Default::default()
6671            },
6672            stretch::geometry::Size::undefined(),
6673        );
6674
6675        assert_eq!(layout.size.width, 200.0000);
6676        assert_eq!(layout.size.height, 200.0000);
6677        assert_eq!(layout.location.x, 0.0000);
6678        assert_eq!(layout.location.y, 0.0000);
6679
6680        assert_eq!(layout.children[0].size.width, 50.0000);
6681        assert_eq!(layout.children[0].size.height, 50.0000);
6682        assert_eq!(layout.children[0].location.x, 50.0000);
6683        assert_eq!(layout.children[0].location.y, 75.0000);
6684
6685        assert_eq!(layout.children[1].size.width, 50.0000);
6686        assert_eq!(layout.children[1].size.height, 50.0000);
6687        assert_eq!(layout.children[1].location.x, 100.0000);
6688        assert_eq!(layout.children[1].location.y, 0.0000);
6689    }
6690
6691    #[test]
6692    fn flex_basis_overrides_main_size() {
6693        let layout = stretch::compute(
6694            &stretch::style::Node {
6695                size: stretch::geometry::Size {
6696                    width: stretch::style::Dimension::Points(100.0000),
6697                    height: stretch::style::Dimension::Points(100.0000),
6698                    ..Default::default()
6699                },
6700                children: vec![
6701                    stretch::style::Node {
6702                        flex_grow: 1.0000,
6703                        flex_basis: stretch::style::Dimension::Points(50.0000),
6704                        size: stretch::geometry::Size {
6705                            width: stretch::style::Dimension::Points(20.0000),
6706                            ..Default::default()
6707                        },
6708                        ..Default::default()
6709                    },
6710                    stretch::style::Node {
6711                        flex_grow: 1.0000,
6712                        size: stretch::geometry::Size {
6713                            width: stretch::style::Dimension::Points(10.0000),
6714                            ..Default::default()
6715                        },
6716                        ..Default::default()
6717                    },
6718                    stretch::style::Node {
6719                        flex_grow: 1.0000,
6720                        size: stretch::geometry::Size {
6721                            width: stretch::style::Dimension::Points(10.0000),
6722                            ..Default::default()
6723                        },
6724                        ..Default::default()
6725                    },
6726                ],
6727                ..Default::default()
6728            },
6729            stretch::geometry::Size::undefined(),
6730        );
6731
6732        assert_eq!(layout.size.width, 100.0000);
6733        assert_eq!(layout.size.height, 100.0000);
6734        assert_eq!(layout.location.x, 0.0000);
6735        assert_eq!(layout.location.y, 0.0000);
6736
6737        assert_eq!(layout.children[0].size.width, 60.0000);
6738        assert_eq!(layout.children[0].size.height, 100.0000);
6739        assert_eq!(layout.children[0].location.x, 0.0000);
6740        assert_eq!(layout.children[0].location.y, 0.0000);
6741
6742        assert_eq!(layout.children[1].size.width, 20.0000);
6743        assert_eq!(layout.children[1].size.height, 100.0000);
6744        assert_eq!(layout.children[1].location.x, 60.0000);
6745        assert_eq!(layout.children[1].location.y, 0.0000);
6746
6747        assert_eq!(layout.children[2].size.width, 20.0000);
6748        assert_eq!(layout.children[2].size.height, 100.0000);
6749        assert_eq!(layout.children[2].location.x, 80.0000);
6750        assert_eq!(layout.children[2].location.y, 0.0000);
6751    }
6752
6753    #[test]
6754    fn wrapped_row_within_align_items_flex_start() {
6755        let layout = stretch::compute(
6756            &stretch::style::Node {
6757                flex_direction: stretch::style::FlexDirection::Column,
6758                align_items: stretch::style::AlignItems::FlexStart,
6759                size: stretch::geometry::Size {
6760                    width: stretch::style::Dimension::Points(200.0000),
6761                    height: stretch::style::Dimension::Points(200.0000),
6762                    ..Default::default()
6763                },
6764                children: vec![stretch::style::Node {
6765                    flex_wrap: stretch::style::FlexWrap::Wrap,
6766                    children: vec![
6767                        stretch::style::Node {
6768                            size: stretch::geometry::Size {
6769                                width: stretch::style::Dimension::Points(150.0000),
6770                                height: stretch::style::Dimension::Points(80.0000),
6771                                ..Default::default()
6772                            },
6773                            ..Default::default()
6774                        },
6775                        stretch::style::Node {
6776                            size: stretch::geometry::Size {
6777                                width: stretch::style::Dimension::Points(80.0000),
6778                                height: stretch::style::Dimension::Points(80.0000),
6779                                ..Default::default()
6780                            },
6781                            ..Default::default()
6782                        },
6783                    ],
6784                    ..Default::default()
6785                }],
6786                ..Default::default()
6787            },
6788            stretch::geometry::Size::undefined(),
6789        );
6790
6791        assert_eq!(layout.size.width, 200.0000);
6792        assert_eq!(layout.size.height, 200.0000);
6793        assert_eq!(layout.location.x, 0.0000);
6794        assert_eq!(layout.location.y, 0.0000);
6795
6796        assert_eq!(layout.children[0].size.width, 200.0000);
6797        assert_eq!(layout.children[0].size.height, 160.0000);
6798        assert_eq!(layout.children[0].location.x, 0.0000);
6799        assert_eq!(layout.children[0].location.y, 0.0000);
6800
6801        assert_eq!(layout.children[0].children[0].size.width, 150.0000);
6802        assert_eq!(layout.children[0].children[0].size.height, 80.0000);
6803        assert_eq!(layout.children[0].children[0].location.x, 0.0000);
6804        assert_eq!(layout.children[0].children[0].location.y, 0.0000);
6805
6806        assert_eq!(layout.children[0].children[1].size.width, 80.0000);
6807        assert_eq!(layout.children[0].children[1].size.height, 80.0000);
6808        assert_eq!(layout.children[0].children[1].location.x, 0.0000);
6809        assert_eq!(layout.children[0].children[1].location.y, 80.0000);
6810    }
6811
6812    #[test]
6813    fn align_center_should_size_based_on_content() {
6814        let layout = stretch::compute(
6815            &stretch::style::Node {
6816                align_items: stretch::style::AlignItems::Center,
6817                size: stretch::geometry::Size {
6818                    width: stretch::style::Dimension::Points(100.0000),
6819                    height: stretch::style::Dimension::Points(100.0000),
6820                    ..Default::default()
6821                },
6822                children: vec![stretch::style::Node {
6823                    justify_content: stretch::style::JustifyContent::Center,
6824                    flex_grow: 0.0000,
6825                    flex_shrink: 1.0000,
6826                    children: vec![stretch::style::Node {
6827                        flex_grow: 1.0000,
6828                        flex_shrink: 1.0000,
6829                        children: vec![stretch::style::Node {
6830                            size: stretch::geometry::Size {
6831                                width: stretch::style::Dimension::Points(20.0000),
6832                                height: stretch::style::Dimension::Points(20.0000),
6833                                ..Default::default()
6834                            },
6835                            ..Default::default()
6836                        }],
6837                        ..Default::default()
6838                    }],
6839                    ..Default::default()
6840                }],
6841                ..Default::default()
6842            },
6843            stretch::geometry::Size::undefined(),
6844        );
6845
6846        assert_eq!(layout.size.width, 100.0000);
6847        assert_eq!(layout.size.height, 100.0000);
6848        assert_eq!(layout.location.x, 0.0000);
6849        assert_eq!(layout.location.y, 0.0000);
6850
6851        assert_eq!(layout.children[0].size.width, 20.0000);
6852        assert_eq!(layout.children[0].size.height, 20.0000);
6853        assert_eq!(layout.children[0].location.x, 0.0000);
6854        assert_eq!(layout.children[0].location.y, 40.0000);
6855
6856        assert_eq!(layout.children[0].children[0].size.width, 20.0000);
6857        assert_eq!(layout.children[0].children[0].size.height, 20.0000);
6858        assert_eq!(layout.children[0].children[0].location.x, 0.0000);
6859        assert_eq!(layout.children[0].children[0].location.y, 0.0000);
6860
6861        assert_eq!(layout.children[0].children[0].children[0].size.width, 20.0000);
6862        assert_eq!(layout.children[0].children[0].children[0].size.height, 20.0000);
6863        assert_eq!(layout.children[0].children[0].children[0].location.x, 0.0000);
6864        assert_eq!(layout.children[0].children[0].children[0].location.y, 0.0000);
6865    }
6866
6867    #[test]
6868    fn margin_auto_right() {
6869        let layout = stretch::compute(
6870            &stretch::style::Node {
6871                align_items: stretch::style::AlignItems::Center,
6872                size: stretch::geometry::Size {
6873                    width: stretch::style::Dimension::Points(200.0000),
6874                    height: stretch::style::Dimension::Points(200.0000),
6875                    ..Default::default()
6876                },
6877                children: vec![
6878                    stretch::style::Node {
6879                        size: stretch::geometry::Size {
6880                            width: stretch::style::Dimension::Points(50.0000),
6881                            height: stretch::style::Dimension::Points(50.0000),
6882                            ..Default::default()
6883                        },
6884                        margin: stretch::geometry::Rect { end: stretch::style::Dimension::Auto, ..Default::default() },
6885                        ..Default::default()
6886                    },
6887                    stretch::style::Node {
6888                        size: stretch::geometry::Size {
6889                            width: stretch::style::Dimension::Points(50.0000),
6890                            height: stretch::style::Dimension::Points(50.0000),
6891                            ..Default::default()
6892                        },
6893                        ..Default::default()
6894                    },
6895                ],
6896                ..Default::default()
6897            },
6898            stretch::geometry::Size::undefined(),
6899        );
6900
6901        assert_eq!(layout.size.width, 200.0000);
6902        assert_eq!(layout.size.height, 200.0000);
6903        assert_eq!(layout.location.x, 0.0000);
6904        assert_eq!(layout.location.y, 0.0000);
6905
6906        assert_eq!(layout.children[0].size.width, 50.0000);
6907        assert_eq!(layout.children[0].size.height, 50.0000);
6908        assert_eq!(layout.children[0].location.x, 0.0000);
6909        assert_eq!(layout.children[0].location.y, 75.0000);
6910
6911        assert_eq!(layout.children[1].size.width, 50.0000);
6912        assert_eq!(layout.children[1].size.height, 50.0000);
6913        assert_eq!(layout.children[1].location.x, 150.0000);
6914        assert_eq!(layout.children[1].location.y, 75.0000);
6915    }
6916
6917    #[test]
6918    fn wrap_reverse_row_align_content_center() {
6919        let layout = stretch::compute(
6920            &stretch::style::Node {
6921                flex_wrap: stretch::style::FlexWrap::WrapReverse,
6922                align_content: stretch::style::AlignContent::Center,
6923                size: stretch::geometry::Size {
6924                    width: stretch::style::Dimension::Points(100.0000),
6925                    ..Default::default()
6926                },
6927                children: vec![
6928                    stretch::style::Node {
6929                        size: stretch::geometry::Size {
6930                            width: stretch::style::Dimension::Points(30.0000),
6931                            height: stretch::style::Dimension::Points(10.0000),
6932                            ..Default::default()
6933                        },
6934                        ..Default::default()
6935                    },
6936                    stretch::style::Node {
6937                        size: stretch::geometry::Size {
6938                            width: stretch::style::Dimension::Points(30.0000),
6939                            height: stretch::style::Dimension::Points(20.0000),
6940                            ..Default::default()
6941                        },
6942                        ..Default::default()
6943                    },
6944                    stretch::style::Node {
6945                        size: stretch::geometry::Size {
6946                            width: stretch::style::Dimension::Points(30.0000),
6947                            height: stretch::style::Dimension::Points(30.0000),
6948                            ..Default::default()
6949                        },
6950                        ..Default::default()
6951                    },
6952                    stretch::style::Node {
6953                        size: stretch::geometry::Size {
6954                            width: stretch::style::Dimension::Points(30.0000),
6955                            height: stretch::style::Dimension::Points(40.0000),
6956                            ..Default::default()
6957                        },
6958                        ..Default::default()
6959                    },
6960                    stretch::style::Node {
6961                        size: stretch::geometry::Size {
6962                            width: stretch::style::Dimension::Points(30.0000),
6963                            height: stretch::style::Dimension::Points(50.0000),
6964                            ..Default::default()
6965                        },
6966                        ..Default::default()
6967                    },
6968                ],
6969                ..Default::default()
6970            },
6971            stretch::geometry::Size::undefined(),
6972        );
6973
6974        assert_eq!(layout.size.width, 100.0000);
6975        assert_eq!(layout.size.height, 80.0000);
6976        assert_eq!(layout.location.x, 0.0000);
6977        assert_eq!(layout.location.y, 0.0000);
6978
6979        assert_eq!(layout.children[0].size.width, 30.0000);
6980        assert_eq!(layout.children[0].size.height, 10.0000);
6981        assert_eq!(layout.children[0].location.x, 0.0000);
6982        assert_eq!(layout.children[0].location.y, 70.0000);
6983
6984        assert_eq!(layout.children[1].size.width, 30.0000);
6985        assert_eq!(layout.children[1].size.height, 20.0000);
6986        assert_eq!(layout.children[1].location.x, 30.0000);
6987        assert_eq!(layout.children[1].location.y, 60.0000);
6988
6989        assert_eq!(layout.children[2].size.width, 30.0000);
6990        assert_eq!(layout.children[2].size.height, 30.0000);
6991        assert_eq!(layout.children[2].location.x, 60.0000);
6992        assert_eq!(layout.children[2].location.y, 50.0000);
6993
6994        assert_eq!(layout.children[3].size.width, 30.0000);
6995        assert_eq!(layout.children[3].size.height, 40.0000);
6996        assert_eq!(layout.children[3].location.x, 0.0000);
6997        assert_eq!(layout.children[3].location.y, 10.0000);
6998
6999        assert_eq!(layout.children[4].size.width, 30.0000);
7000        assert_eq!(layout.children[4].size.height, 50.0000);
7001        assert_eq!(layout.children[4].location.x, 30.0000);
7002        assert_eq!(layout.children[4].location.y, 0.0000);
7003    }
7004
7005    #[test]
7006    fn padding_no_child() {
7007        let layout = stretch::compute(
7008            &stretch::style::Node {
7009                padding: stretch::geometry::Rect {
7010                    start: stretch::style::Dimension::Points(10.0000),
7011                    end: stretch::style::Dimension::Points(10.0000),
7012                    top: stretch::style::Dimension::Points(10.0000),
7013                    bottom: stretch::style::Dimension::Points(10.0000),
7014                    ..Default::default()
7015                },
7016                ..Default::default()
7017            },
7018            stretch::geometry::Size::undefined(),
7019        );
7020
7021        assert_eq!(layout.size.width, 20.0000);
7022        assert_eq!(layout.size.height, 20.0000);
7023        assert_eq!(layout.location.x, 0.0000);
7024        assert_eq!(layout.location.y, 0.0000);
7025    }
7026
7027    #[test]
7028    fn margin_with_sibling_column() {
7029        let layout = stretch::compute(
7030            &stretch::style::Node {
7031                flex_direction: stretch::style::FlexDirection::Column,
7032                size: stretch::geometry::Size {
7033                    width: stretch::style::Dimension::Points(100.0000),
7034                    height: stretch::style::Dimension::Points(100.0000),
7035                    ..Default::default()
7036                },
7037                children: vec![
7038                    stretch::style::Node {
7039                        flex_grow: 1.0000,
7040                        margin: stretch::geometry::Rect {
7041                            bottom: stretch::style::Dimension::Points(10.0000),
7042                            ..Default::default()
7043                        },
7044                        ..Default::default()
7045                    },
7046                    stretch::style::Node { flex_grow: 1.0000, ..Default::default() },
7047                ],
7048                ..Default::default()
7049            },
7050            stretch::geometry::Size::undefined(),
7051        );
7052
7053        assert_eq!(layout.size.width, 100.0000);
7054        assert_eq!(layout.size.height, 100.0000);
7055        assert_eq!(layout.location.x, 0.0000);
7056        assert_eq!(layout.location.y, 0.0000);
7057
7058        assert_eq!(layout.children[0].size.width, 100.0000);
7059        assert_eq!(layout.children[0].size.height, 45.0000);
7060        assert_eq!(layout.children[0].location.x, 0.0000);
7061        assert_eq!(layout.children[0].location.y, 0.0000);
7062
7063        assert_eq!(layout.children[1].size.width, 100.0000);
7064        assert_eq!(layout.children[1].size.height, 45.0000);
7065        assert_eq!(layout.children[1].location.x, 0.0000);
7066        assert_eq!(layout.children[1].location.y, 55.0000);
7067    }
7068
7069    #[test]
7070    fn flex_direction_row_no_width() {
7071        let layout = stretch::compute(
7072            &stretch::style::Node {
7073                size: stretch::geometry::Size {
7074                    height: stretch::style::Dimension::Points(100.0000),
7075                    ..Default::default()
7076                },
7077                children: vec![
7078                    stretch::style::Node {
7079                        size: stretch::geometry::Size {
7080                            width: stretch::style::Dimension::Points(10.0000),
7081                            ..Default::default()
7082                        },
7083                        ..Default::default()
7084                    },
7085                    stretch::style::Node {
7086                        size: stretch::geometry::Size {
7087                            width: stretch::style::Dimension::Points(10.0000),
7088                            ..Default::default()
7089                        },
7090                        ..Default::default()
7091                    },
7092                    stretch::style::Node {
7093                        size: stretch::geometry::Size {
7094                            width: stretch::style::Dimension::Points(10.0000),
7095                            ..Default::default()
7096                        },
7097                        ..Default::default()
7098                    },
7099                ],
7100                ..Default::default()
7101            },
7102            stretch::geometry::Size::undefined(),
7103        );
7104
7105        assert_eq!(layout.size.width, 30.0000);
7106        assert_eq!(layout.size.height, 100.0000);
7107        assert_eq!(layout.location.x, 0.0000);
7108        assert_eq!(layout.location.y, 0.0000);
7109
7110        assert_eq!(layout.children[0].size.width, 10.0000);
7111        assert_eq!(layout.children[0].size.height, 100.0000);
7112        assert_eq!(layout.children[0].location.x, 0.0000);
7113        assert_eq!(layout.children[0].location.y, 0.0000);
7114
7115        assert_eq!(layout.children[1].size.width, 10.0000);
7116        assert_eq!(layout.children[1].size.height, 100.0000);
7117        assert_eq!(layout.children[1].location.x, 10.0000);
7118        assert_eq!(layout.children[1].location.y, 0.0000);
7119
7120        assert_eq!(layout.children[2].size.width, 10.0000);
7121        assert_eq!(layout.children[2].size.height, 100.0000);
7122        assert_eq!(layout.children[2].location.x, 20.0000);
7123        assert_eq!(layout.children[2].location.y, 0.0000);
7124    }
7125
7126    #[test]
7127    fn max_width_overrides_width_on_root() {
7128        let layout = stretch::compute(
7129            &stretch::style::Node {
7130                size: stretch::geometry::Size {
7131                    width: stretch::style::Dimension::Points(200.0000),
7132                    ..Default::default()
7133                },
7134                max_size: stretch::geometry::Size {
7135                    width: stretch::style::Dimension::Points(100.0000),
7136                    ..Default::default()
7137                },
7138                ..Default::default()
7139            },
7140            stretch::geometry::Size::undefined(),
7141        );
7142
7143        assert_eq!(layout.size.width, 100.0000);
7144        assert_eq!(layout.size.height, 0.0000);
7145        assert_eq!(layout.location.x, 0.0000);
7146        assert_eq!(layout.location.y, 0.0000);
7147    }
7148
7149    #[test]
7150    fn margin_auto_left_and_right() {
7151        let layout = stretch::compute(
7152            &stretch::style::Node {
7153                size: stretch::geometry::Size {
7154                    width: stretch::style::Dimension::Points(200.0000),
7155                    height: stretch::style::Dimension::Points(200.0000),
7156                    ..Default::default()
7157                },
7158                children: vec![
7159                    stretch::style::Node {
7160                        size: stretch::geometry::Size {
7161                            width: stretch::style::Dimension::Points(50.0000),
7162                            height: stretch::style::Dimension::Points(50.0000),
7163                            ..Default::default()
7164                        },
7165                        margin: stretch::geometry::Rect {
7166                            start: stretch::style::Dimension::Auto,
7167                            end: stretch::style::Dimension::Auto,
7168                            ..Default::default()
7169                        },
7170                        ..Default::default()
7171                    },
7172                    stretch::style::Node {
7173                        size: stretch::geometry::Size {
7174                            width: stretch::style::Dimension::Points(50.0000),
7175                            height: stretch::style::Dimension::Points(50.0000),
7176                            ..Default::default()
7177                        },
7178                        ..Default::default()
7179                    },
7180                ],
7181                ..Default::default()
7182            },
7183            stretch::geometry::Size::undefined(),
7184        );
7185
7186        assert_eq!(layout.size.width, 200.0000);
7187        assert_eq!(layout.size.height, 200.0000);
7188        assert_eq!(layout.location.x, 0.0000);
7189        assert_eq!(layout.location.y, 0.0000);
7190
7191        assert_eq!(layout.children[0].size.width, 50.0000);
7192        assert_eq!(layout.children[0].size.height, 50.0000);
7193        assert_eq!(layout.children[0].location.x, 50.0000);
7194        assert_eq!(layout.children[0].location.y, 0.0000);
7195
7196        assert_eq!(layout.children[1].size.width, 50.0000);
7197        assert_eq!(layout.children[1].size.height, 50.0000);
7198        assert_eq!(layout.children[1].location.x, 150.0000);
7199        assert_eq!(layout.children[1].location.y, 0.0000);
7200    }
7201
7202    #[test]
7203    fn flex_direction_column_no_height() {
7204        let layout = stretch::compute(
7205            &stretch::style::Node {
7206                flex_direction: stretch::style::FlexDirection::Column,
7207                size: stretch::geometry::Size {
7208                    width: stretch::style::Dimension::Points(100.0000),
7209                    ..Default::default()
7210                },
7211                children: vec![
7212                    stretch::style::Node {
7213                        size: stretch::geometry::Size {
7214                            height: stretch::style::Dimension::Points(10.0000),
7215                            ..Default::default()
7216                        },
7217                        ..Default::default()
7218                    },
7219                    stretch::style::Node {
7220                        size: stretch::geometry::Size {
7221                            height: stretch::style::Dimension::Points(10.0000),
7222                            ..Default::default()
7223                        },
7224                        ..Default::default()
7225                    },
7226                    stretch::style::Node {
7227                        size: stretch::geometry::Size {
7228                            height: stretch::style::Dimension::Points(10.0000),
7229                            ..Default::default()
7230                        },
7231                        ..Default::default()
7232                    },
7233                ],
7234                ..Default::default()
7235            },
7236            stretch::geometry::Size::undefined(),
7237        );
7238
7239        assert_eq!(layout.size.width, 100.0000);
7240        assert_eq!(layout.size.height, 30.0000);
7241        assert_eq!(layout.location.x, 0.0000);
7242        assert_eq!(layout.location.y, 0.0000);
7243
7244        assert_eq!(layout.children[0].size.width, 100.0000);
7245        assert_eq!(layout.children[0].size.height, 10.0000);
7246        assert_eq!(layout.children[0].location.x, 0.0000);
7247        assert_eq!(layout.children[0].location.y, 0.0000);
7248
7249        assert_eq!(layout.children[1].size.width, 100.0000);
7250        assert_eq!(layout.children[1].size.height, 10.0000);
7251        assert_eq!(layout.children[1].location.x, 0.0000);
7252        assert_eq!(layout.children[1].location.y, 10.0000);
7253
7254        assert_eq!(layout.children[2].size.width, 100.0000);
7255        assert_eq!(layout.children[2].size.height, 10.0000);
7256        assert_eq!(layout.children[2].location.x, 0.0000);
7257        assert_eq!(layout.children[2].location.y, 20.0000);
7258    }
7259
7260    #[test]
7261    fn flex_basis_unconstraint_column() {
7262        let layout = stretch::compute(
7263            &stretch::style::Node {
7264                flex_direction: stretch::style::FlexDirection::Column,
7265                children: vec![stretch::style::Node {
7266                    flex_basis: stretch::style::Dimension::Points(50.0000),
7267                    size: stretch::geometry::Size {
7268                        width: stretch::style::Dimension::Points(100.0000),
7269                        ..Default::default()
7270                    },
7271                    ..Default::default()
7272                }],
7273                ..Default::default()
7274            },
7275            stretch::geometry::Size::undefined(),
7276        );
7277
7278        assert_eq!(layout.size.width, 100.0000);
7279        assert_eq!(layout.size.height, 50.0000);
7280        assert_eq!(layout.location.x, 0.0000);
7281        assert_eq!(layout.location.y, 0.0000);
7282
7283        assert_eq!(layout.children[0].size.width, 100.0000);
7284        assert_eq!(layout.children[0].size.height, 50.0000);
7285        assert_eq!(layout.children[0].location.x, 0.0000);
7286        assert_eq!(layout.children[0].location.y, 0.0000);
7287    }
7288
7289    #[test]
7290    fn width_smaller_then_content_with_flex_grow_small_size() {
7291        let layout = stretch::compute(
7292            &stretch::style::Node {
7293                size: stretch::geometry::Size {
7294                    width: stretch::style::Dimension::Points(10.0000),
7295                    ..Default::default()
7296                },
7297                children: vec![
7298                    stretch::style::Node {
7299                        flex_direction: stretch::style::FlexDirection::Column,
7300                        flex_grow: 1.0000,
7301                        size: stretch::geometry::Size {
7302                            width: stretch::style::Dimension::Points(0.0000),
7303                            ..Default::default()
7304                        },
7305                        children: vec![stretch::style::Node {
7306                            size: stretch::geometry::Size {
7307                                width: stretch::style::Dimension::Points(70.0000),
7308                                height: stretch::style::Dimension::Points(100.0000),
7309                                ..Default::default()
7310                            },
7311                            ..Default::default()
7312                        }],
7313                        ..Default::default()
7314                    },
7315                    stretch::style::Node {
7316                        flex_direction: stretch::style::FlexDirection::Column,
7317                        flex_grow: 1.0000,
7318                        size: stretch::geometry::Size {
7319                            width: stretch::style::Dimension::Points(0.0000),
7320                            ..Default::default()
7321                        },
7322                        children: vec![stretch::style::Node {
7323                            size: stretch::geometry::Size {
7324                                width: stretch::style::Dimension::Points(20.0000),
7325                                height: stretch::style::Dimension::Points(100.0000),
7326                                ..Default::default()
7327                            },
7328                            ..Default::default()
7329                        }],
7330                        ..Default::default()
7331                    },
7332                ],
7333                ..Default::default()
7334            },
7335            stretch::geometry::Size::undefined(),
7336        );
7337
7338        assert_eq!(layout.size.width, 10.0000);
7339        assert_eq!(layout.size.height, 100.0000);
7340        assert_eq!(layout.location.x, 0.0000);
7341        assert_eq!(layout.location.y, 0.0000);
7342
7343        assert_eq!(layout.children[0].size.width, 5.0000);
7344        assert_eq!(layout.children[0].size.height, 100.0000);
7345        assert_eq!(layout.children[0].location.x, 0.0000);
7346        assert_eq!(layout.children[0].location.y, 0.0000);
7347
7348        assert_eq!(layout.children[0].children[0].size.width, 70.0000);
7349        assert_eq!(layout.children[0].children[0].size.height, 100.0000);
7350        assert_eq!(layout.children[0].children[0].location.x, 0.0000);
7351        assert_eq!(layout.children[0].children[0].location.y, 0.0000);
7352
7353        assert_eq!(layout.children[1].size.width, 5.0000);
7354        assert_eq!(layout.children[1].size.height, 100.0000);
7355        assert_eq!(layout.children[1].location.x, 5.0000);
7356        assert_eq!(layout.children[1].location.y, 0.0000);
7357
7358        assert_eq!(layout.children[1].children[0].size.width, 20.0000);
7359        assert_eq!(layout.children[1].children[0].size.height, 100.0000);
7360        assert_eq!(layout.children[1].children[0].location.x, 0.0000);
7361        assert_eq!(layout.children[1].children[0].location.y, 0.0000);
7362    }
7363
7364    #[test]
7365    fn absolute_layout_in_wrap_reverse_row_container() {
7366        let layout = stretch::compute(
7367            &stretch::style::Node {
7368                flex_wrap: stretch::style::FlexWrap::WrapReverse,
7369                size: stretch::geometry::Size {
7370                    width: stretch::style::Dimension::Points(100.0000),
7371                    height: stretch::style::Dimension::Points(100.0000),
7372                    ..Default::default()
7373                },
7374                children: vec![stretch::style::Node {
7375                    position_type: stretch::style::PositionType::Absolute,
7376                    size: stretch::geometry::Size {
7377                        width: stretch::style::Dimension::Points(20.0000),
7378                        height: stretch::style::Dimension::Points(20.0000),
7379                        ..Default::default()
7380                    },
7381                    ..Default::default()
7382                }],
7383                ..Default::default()
7384            },
7385            stretch::geometry::Size::undefined(),
7386        );
7387
7388        assert_eq!(layout.size.width, 100.0000);
7389        assert_eq!(layout.size.height, 100.0000);
7390        assert_eq!(layout.location.x, 0.0000);
7391        assert_eq!(layout.location.y, 0.0000);
7392
7393        assert_eq!(layout.children[0].size.width, 20.0000);
7394        assert_eq!(layout.children[0].size.height, 20.0000);
7395        assert_eq!(layout.children[0].location.x, 0.0000);
7396        assert_eq!(layout.children[0].location.y, 80.0000);
7397    }
7398
7399    #[test]
7400    fn flex_basis_and_main_dimen_set_when_flexing() {
7401        let layout = stretch::compute(
7402            &stretch::style::Node {
7403                size: stretch::geometry::Size {
7404                    width: stretch::style::Dimension::Points(100.0000),
7405                    ..Default::default()
7406                },
7407                children: vec![
7408                    stretch::style::Node {
7409                        flex_grow: 1.0000,
7410                        flex_basis: stretch::style::Dimension::Points(10.0000),
7411                        size: stretch::geometry::Size {
7412                            width: stretch::style::Dimension::Points(50.0000),
7413                            height: stretch::style::Dimension::Points(50.0000),
7414                            ..Default::default()
7415                        },
7416                        ..Default::default()
7417                    },
7418                    stretch::style::Node {
7419                        flex_grow: 1.0000,
7420                        flex_basis: stretch::style::Dimension::Points(10.0000),
7421                        size: stretch::geometry::Size {
7422                            width: stretch::style::Dimension::Points(0.0000),
7423                            height: stretch::style::Dimension::Points(50.0000),
7424                            ..Default::default()
7425                        },
7426                        ..Default::default()
7427                    },
7428                ],
7429                ..Default::default()
7430            },
7431            stretch::geometry::Size::undefined(),
7432        );
7433
7434        assert_eq!(layout.size.width, 100.0000);
7435        assert_eq!(layout.size.height, 50.0000);
7436        assert_eq!(layout.location.x, 0.0000);
7437        assert_eq!(layout.location.y, 0.0000);
7438
7439        assert_eq!(layout.children[0].size.width, 50.0000);
7440        assert_eq!(layout.children[0].size.height, 50.0000);
7441        assert_eq!(layout.children[0].location.x, 0.0000);
7442        assert_eq!(layout.children[0].location.y, 0.0000);
7443
7444        assert_eq!(layout.children[1].size.width, 50.0000);
7445        assert_eq!(layout.children[1].size.height, 50.0000);
7446        assert_eq!(layout.children[1].location.x, 50.0000);
7447        assert_eq!(layout.children[1].location.y, 0.0000);
7448    }
7449
7450    #[test]
7451    fn flex_basis_smaller_than_main_dimen_column() {
7452        let layout = stretch::compute(
7453            &stretch::style::Node {
7454                flex_direction: stretch::style::FlexDirection::Column,
7455                size: stretch::geometry::Size {
7456                    height: stretch::style::Dimension::Points(100.0000),
7457                    ..Default::default()
7458                },
7459                children: vec![stretch::style::Node {
7460                    flex_basis: stretch::style::Dimension::Points(10.0000),
7461                    size: stretch::geometry::Size {
7462                        width: stretch::style::Dimension::Points(50.0000),
7463                        height: stretch::style::Dimension::Points(50.0000),
7464                        ..Default::default()
7465                    },
7466                    ..Default::default()
7467                }],
7468                ..Default::default()
7469            },
7470            stretch::geometry::Size::undefined(),
7471        );
7472
7473        assert_eq!(layout.size.width, 50.0000);
7474        assert_eq!(layout.size.height, 100.0000);
7475        assert_eq!(layout.location.x, 0.0000);
7476        assert_eq!(layout.location.y, 0.0000);
7477
7478        assert_eq!(layout.children[0].size.width, 50.0000);
7479        assert_eq!(layout.children[0].size.height, 10.0000);
7480        assert_eq!(layout.children[0].location.x, 0.0000);
7481        assert_eq!(layout.children[0].location.y, 0.0000);
7482    }
7483
7484    #[test]
7485    fn percentage_margin_should_calculate_based_only_on_width() {
7486        let layout = stretch::compute(
7487            &stretch::style::Node {
7488                flex_direction: stretch::style::FlexDirection::Column,
7489                size: stretch::geometry::Size {
7490                    width: stretch::style::Dimension::Points(200.0000),
7491                    height: stretch::style::Dimension::Points(100.0000),
7492                    ..Default::default()
7493                },
7494                children: vec![stretch::style::Node {
7495                    flex_direction: stretch::style::FlexDirection::Column,
7496                    flex_grow: 1.0000,
7497                    margin: stretch::geometry::Rect {
7498                        start: stretch::style::Dimension::Percent(0.1000),
7499                        end: stretch::style::Dimension::Percent(0.1000),
7500                        top: stretch::style::Dimension::Percent(0.1000),
7501                        bottom: stretch::style::Dimension::Percent(0.1000),
7502                        ..Default::default()
7503                    },
7504                    children: vec![stretch::style::Node {
7505                        size: stretch::geometry::Size {
7506                            width: stretch::style::Dimension::Points(10.0000),
7507                            height: stretch::style::Dimension::Points(10.0000),
7508                            ..Default::default()
7509                        },
7510                        ..Default::default()
7511                    }],
7512                    ..Default::default()
7513                }],
7514                ..Default::default()
7515            },
7516            stretch::geometry::Size::undefined(),
7517        );
7518
7519        assert_eq!(layout.size.width, 200.0000);
7520        assert_eq!(layout.size.height, 100.0000);
7521        assert_eq!(layout.location.x, 0.0000);
7522        assert_eq!(layout.location.y, 0.0000);
7523
7524        assert_eq!(layout.children[0].size.width, 160.0000);
7525        assert_eq!(layout.children[0].size.height, 60.0000);
7526        assert_eq!(layout.children[0].location.x, 20.0000);
7527        assert_eq!(layout.children[0].location.y, 20.0000);
7528
7529        assert_eq!(layout.children[0].children[0].size.width, 10.0000);
7530        assert_eq!(layout.children[0].children[0].size.height, 10.0000);
7531        assert_eq!(layout.children[0].children[0].location.x, 0.0000);
7532        assert_eq!(layout.children[0].children[0].location.y, 0.0000);
7533    }
7534
7535    #[test]
7536    fn absolute_layout_start_top_end_bottom() {
7537        let layout = stretch::compute(
7538            &stretch::style::Node {
7539                size: stretch::geometry::Size {
7540                    width: stretch::style::Dimension::Points(100.0000),
7541                    height: stretch::style::Dimension::Points(100.0000),
7542                    ..Default::default()
7543                },
7544                children: vec![stretch::style::Node {
7545                    position_type: stretch::style::PositionType::Absolute,
7546                    position: stretch::geometry::Rect {
7547                        start: stretch::style::Dimension::Points(10.0000),
7548                        end: stretch::style::Dimension::Points(10.0000),
7549                        top: stretch::style::Dimension::Points(10.0000),
7550                        bottom: stretch::style::Dimension::Points(10.0000),
7551                        ..Default::default()
7552                    },
7553                    ..Default::default()
7554                }],
7555                ..Default::default()
7556            },
7557            stretch::geometry::Size::undefined(),
7558        );
7559
7560        assert_eq!(layout.size.width, 100.0000);
7561        assert_eq!(layout.size.height, 100.0000);
7562        assert_eq!(layout.location.x, 0.0000);
7563        assert_eq!(layout.location.y, 0.0000);
7564
7565        assert_eq!(layout.children[0].size.width, 80.0000);
7566        assert_eq!(layout.children[0].size.height, 80.0000);
7567        assert_eq!(layout.children[0].location.x, 10.0000);
7568        assert_eq!(layout.children[0].location.y, 10.0000);
7569    }
7570
7571    #[test]
7572    fn min_width() {
7573        let layout = stretch::compute(
7574            &stretch::style::Node {
7575                size: stretch::geometry::Size {
7576                    width: stretch::style::Dimension::Points(100.0000),
7577                    height: stretch::style::Dimension::Points(100.0000),
7578                    ..Default::default()
7579                },
7580                children: vec![
7581                    stretch::style::Node {
7582                        flex_grow: 1.0000,
7583                        min_size: stretch::geometry::Size {
7584                            width: stretch::style::Dimension::Points(60.0000),
7585                            ..Default::default()
7586                        },
7587                        ..Default::default()
7588                    },
7589                    stretch::style::Node { flex_grow: 1.0000, ..Default::default() },
7590                ],
7591                ..Default::default()
7592            },
7593            stretch::geometry::Size::undefined(),
7594        );
7595
7596        assert_eq!(layout.size.width, 100.0000);
7597        assert_eq!(layout.size.height, 100.0000);
7598        assert_eq!(layout.location.x, 0.0000);
7599        assert_eq!(layout.location.y, 0.0000);
7600
7601        assert_eq!(layout.children[0].size.width, 80.0000);
7602        assert_eq!(layout.children[0].size.height, 100.0000);
7603        assert_eq!(layout.children[0].location.x, 0.0000);
7604        assert_eq!(layout.children[0].location.y, 0.0000);
7605
7606        assert_eq!(layout.children[1].size.width, 20.0000);
7607        assert_eq!(layout.children[1].size.height, 100.0000);
7608        assert_eq!(layout.children[1].location.x, 80.0000);
7609        assert_eq!(layout.children[1].location.y, 0.0000);
7610    }
7611
7612    #[test]
7613    fn min_height_overrides_height_on_root() {
7614        let layout = stretch::compute(
7615            &stretch::style::Node {
7616                size: stretch::geometry::Size {
7617                    height: stretch::style::Dimension::Points(50.0000),
7618                    ..Default::default()
7619                },
7620                min_size: stretch::geometry::Size {
7621                    height: stretch::style::Dimension::Points(100.0000),
7622                    ..Default::default()
7623                },
7624                ..Default::default()
7625            },
7626            stretch::geometry::Size::undefined(),
7627        );
7628
7629        assert_eq!(layout.size.width, 0.0000);
7630        assert_eq!(layout.size.height, 100.0000);
7631        assert_eq!(layout.location.x, 0.0000);
7632        assert_eq!(layout.location.y, 0.0000);
7633    }
7634
7635    #[test]
7636    fn absolute_layout_width_height_end_bottom() {
7637        let layout = stretch::compute(
7638            &stretch::style::Node {
7639                size: stretch::geometry::Size {
7640                    width: stretch::style::Dimension::Points(100.0000),
7641                    height: stretch::style::Dimension::Points(100.0000),
7642                    ..Default::default()
7643                },
7644                children: vec![stretch::style::Node {
7645                    position_type: stretch::style::PositionType::Absolute,
7646                    size: stretch::geometry::Size {
7647                        width: stretch::style::Dimension::Points(10.0000),
7648                        height: stretch::style::Dimension::Points(10.0000),
7649                        ..Default::default()
7650                    },
7651                    position: stretch::geometry::Rect {
7652                        end: stretch::style::Dimension::Points(10.0000),
7653                        bottom: stretch::style::Dimension::Points(10.0000),
7654                        ..Default::default()
7655                    },
7656                    ..Default::default()
7657                }],
7658                ..Default::default()
7659            },
7660            stretch::geometry::Size::undefined(),
7661        );
7662
7663        assert_eq!(layout.size.width, 100.0000);
7664        assert_eq!(layout.size.height, 100.0000);
7665        assert_eq!(layout.location.x, 0.0000);
7666        assert_eq!(layout.location.y, 0.0000);
7667
7668        assert_eq!(layout.children[0].size.width, 10.0000);
7669        assert_eq!(layout.children[0].size.height, 10.0000);
7670        assert_eq!(layout.children[0].location.x, 80.0000);
7671        assert_eq!(layout.children[0].location.y, 80.0000);
7672    }
7673
7674    #[test]
7675    fn align_self_center() {
7676        let layout = stretch::compute(
7677            &stretch::style::Node {
7678                size: stretch::geometry::Size {
7679                    width: stretch::style::Dimension::Points(100.0000),
7680                    height: stretch::style::Dimension::Points(100.0000),
7681                    ..Default::default()
7682                },
7683                children: vec![stretch::style::Node {
7684                    align_self: stretch::style::AlignSelf::Center,
7685                    size: stretch::geometry::Size {
7686                        width: stretch::style::Dimension::Points(10.0000),
7687                        height: stretch::style::Dimension::Points(10.0000),
7688                        ..Default::default()
7689                    },
7690                    ..Default::default()
7691                }],
7692                ..Default::default()
7693            },
7694            stretch::geometry::Size::undefined(),
7695        );
7696
7697        assert_eq!(layout.size.width, 100.0000);
7698        assert_eq!(layout.size.height, 100.0000);
7699        assert_eq!(layout.location.x, 0.0000);
7700        assert_eq!(layout.location.y, 0.0000);
7701
7702        assert_eq!(layout.children[0].size.width, 10.0000);
7703        assert_eq!(layout.children[0].size.height, 10.0000);
7704        assert_eq!(layout.children[0].location.x, 0.0000);
7705        assert_eq!(layout.children[0].location.y, 45.0000);
7706    }
7707
7708    #[test]
7709    fn wrapped_column_max_height() {
7710        let layout = stretch::compute(
7711            &stretch::style::Node {
7712                flex_direction: stretch::style::FlexDirection::Column,
7713                flex_wrap: stretch::style::FlexWrap::Wrap,
7714                align_items: stretch::style::AlignItems::Center,
7715                align_content: stretch::style::AlignContent::Center,
7716                justify_content: stretch::style::JustifyContent::Center,
7717                size: stretch::geometry::Size {
7718                    width: stretch::style::Dimension::Points(700.0000),
7719                    height: stretch::style::Dimension::Points(500.0000),
7720                    ..Default::default()
7721                },
7722                children: vec![
7723                    stretch::style::Node {
7724                        size: stretch::geometry::Size {
7725                            width: stretch::style::Dimension::Points(100.0000),
7726                            height: stretch::style::Dimension::Points(500.0000),
7727                            ..Default::default()
7728                        },
7729                        max_size: stretch::geometry::Size {
7730                            height: stretch::style::Dimension::Points(200.0000),
7731                            ..Default::default()
7732                        },
7733                        ..Default::default()
7734                    },
7735                    stretch::style::Node {
7736                        size: stretch::geometry::Size {
7737                            width: stretch::style::Dimension::Points(200.0000),
7738                            height: stretch::style::Dimension::Points(200.0000),
7739                            ..Default::default()
7740                        },
7741                        margin: stretch::geometry::Rect {
7742                            start: stretch::style::Dimension::Points(20.0000),
7743                            end: stretch::style::Dimension::Points(20.0000),
7744                            top: stretch::style::Dimension::Points(20.0000),
7745                            bottom: stretch::style::Dimension::Points(20.0000),
7746                            ..Default::default()
7747                        },
7748                        ..Default::default()
7749                    },
7750                    stretch::style::Node {
7751                        size: stretch::geometry::Size {
7752                            width: stretch::style::Dimension::Points(100.0000),
7753                            height: stretch::style::Dimension::Points(100.0000),
7754                            ..Default::default()
7755                        },
7756                        ..Default::default()
7757                    },
7758                ],
7759                ..Default::default()
7760            },
7761            stretch::geometry::Size::undefined(),
7762        );
7763
7764        assert_eq!(layout.size.width, 700.0000);
7765        assert_eq!(layout.size.height, 500.0000);
7766        assert_eq!(layout.location.x, 0.0000);
7767        assert_eq!(layout.location.y, 0.0000);
7768
7769        assert_eq!(layout.children[0].size.width, 100.0000);
7770        assert_eq!(layout.children[0].size.height, 200.0000);
7771        assert_eq!(layout.children[0].location.x, 250.0000);
7772        assert_eq!(layout.children[0].location.y, 30.0000);
7773
7774        assert_eq!(layout.children[1].size.width, 200.0000);
7775        assert_eq!(layout.children[1].size.height, 200.0000);
7776        assert_eq!(layout.children[1].location.x, 200.0000);
7777        assert_eq!(layout.children[1].location.y, 250.0000);
7778
7779        assert_eq!(layout.children[2].size.width, 100.0000);
7780        assert_eq!(layout.children[2].size.height, 100.0000);
7781        assert_eq!(layout.children[2].location.x, 420.0000);
7782        assert_eq!(layout.children[2].location.y, 200.0000);
7783    }
7784
7785    #[test]
7786    fn wrap_row() {
7787        let layout = stretch::compute(
7788            &stretch::style::Node {
7789                flex_wrap: stretch::style::FlexWrap::Wrap,
7790                size: stretch::geometry::Size {
7791                    width: stretch::style::Dimension::Points(100.0000),
7792                    ..Default::default()
7793                },
7794                children: vec![
7795                    stretch::style::Node {
7796                        size: stretch::geometry::Size {
7797                            width: stretch::style::Dimension::Points(31.0000),
7798                            height: stretch::style::Dimension::Points(30.0000),
7799                            ..Default::default()
7800                        },
7801                        ..Default::default()
7802                    },
7803                    stretch::style::Node {
7804                        size: stretch::geometry::Size {
7805                            width: stretch::style::Dimension::Points(32.0000),
7806                            height: stretch::style::Dimension::Points(30.0000),
7807                            ..Default::default()
7808                        },
7809                        ..Default::default()
7810                    },
7811                    stretch::style::Node {
7812                        size: stretch::geometry::Size {
7813                            width: stretch::style::Dimension::Points(33.0000),
7814                            height: stretch::style::Dimension::Points(30.0000),
7815                            ..Default::default()
7816                        },
7817                        ..Default::default()
7818                    },
7819                    stretch::style::Node {
7820                        size: stretch::geometry::Size {
7821                            width: stretch::style::Dimension::Points(34.0000),
7822                            height: stretch::style::Dimension::Points(30.0000),
7823                            ..Default::default()
7824                        },
7825                        ..Default::default()
7826                    },
7827                ],
7828                ..Default::default()
7829            },
7830            stretch::geometry::Size::undefined(),
7831        );
7832
7833        assert_eq!(layout.size.width, 100.0000);
7834        assert_eq!(layout.size.height, 60.0000);
7835        assert_eq!(layout.location.x, 0.0000);
7836        assert_eq!(layout.location.y, 0.0000);
7837
7838        assert_eq!(layout.children[0].size.width, 31.0000);
7839        assert_eq!(layout.children[0].size.height, 30.0000);
7840        assert_eq!(layout.children[0].location.x, 0.0000);
7841        assert_eq!(layout.children[0].location.y, 0.0000);
7842
7843        assert_eq!(layout.children[1].size.width, 32.0000);
7844        assert_eq!(layout.children[1].size.height, 30.0000);
7845        assert_eq!(layout.children[1].location.x, 31.0000);
7846        assert_eq!(layout.children[1].location.y, 0.0000);
7847
7848        assert_eq!(layout.children[2].size.width, 33.0000);
7849        assert_eq!(layout.children[2].size.height, 30.0000);
7850        assert_eq!(layout.children[2].location.x, 63.0000);
7851        assert_eq!(layout.children[2].location.y, 0.0000);
7852
7853        assert_eq!(layout.children[3].size.width, 34.0000);
7854        assert_eq!(layout.children[3].size.height, 30.0000);
7855        assert_eq!(layout.children[3].location.x, 0.0000);
7856        assert_eq!(layout.children[3].location.y, 30.0000);
7857    }
7858
7859    #[test]
7860    fn max_height() {
7861        let layout = stretch::compute(
7862            &stretch::style::Node {
7863                size: stretch::geometry::Size {
7864                    width: stretch::style::Dimension::Points(100.0000),
7865                    height: stretch::style::Dimension::Points(100.0000),
7866                    ..Default::default()
7867                },
7868                children: vec![stretch::style::Node {
7869                    size: stretch::geometry::Size {
7870                        width: stretch::style::Dimension::Points(10.0000),
7871                        ..Default::default()
7872                    },
7873                    max_size: stretch::geometry::Size {
7874                        height: stretch::style::Dimension::Points(50.0000),
7875                        ..Default::default()
7876                    },
7877                    ..Default::default()
7878                }],
7879                ..Default::default()
7880            },
7881            stretch::geometry::Size::undefined(),
7882        );
7883
7884        assert_eq!(layout.size.width, 100.0000);
7885        assert_eq!(layout.size.height, 100.0000);
7886        assert_eq!(layout.location.x, 0.0000);
7887        assert_eq!(layout.location.y, 0.0000);
7888
7889        assert_eq!(layout.children[0].size.width, 10.0000);
7890        assert_eq!(layout.children[0].size.height, 50.0000);
7891        assert_eq!(layout.children[0].location.x, 0.0000);
7892        assert_eq!(layout.children[0].location.y, 0.0000);
7893    }
7894
7895    #[test]
7896    fn flex_grow_child() {
7897        let layout = stretch::compute(
7898            &stretch::style::Node {
7899                children: vec![stretch::style::Node {
7900                    flex_grow: 1.0000,
7901                    flex_basis: stretch::style::Dimension::Points(0.0000),
7902                    size: stretch::geometry::Size {
7903                        height: stretch::style::Dimension::Points(100.0000),
7904                        ..Default::default()
7905                    },
7906                    ..Default::default()
7907                }],
7908                ..Default::default()
7909            },
7910            stretch::geometry::Size::undefined(),
7911        );
7912
7913        assert_eq!(layout.size.width, 0.0000);
7914        assert_eq!(layout.size.height, 100.0000);
7915        assert_eq!(layout.location.x, 0.0000);
7916        assert_eq!(layout.location.y, 0.0000);
7917
7918        assert_eq!(layout.children[0].size.width, 0.0000);
7919        assert_eq!(layout.children[0].size.height, 100.0000);
7920        assert_eq!(layout.children[0].location.x, 0.0000);
7921        assert_eq!(layout.children[0].location.y, 0.0000);
7922    }
7923
7924    #[test]
7925    fn percentage_size_of_flex_basis() {
7926        let layout = stretch::compute(
7927            &stretch::style::Node {
7928                size: stretch::geometry::Size {
7929                    width: stretch::style::Dimension::Points(100.0000),
7930                    ..Default::default()
7931                },
7932                children: vec![stretch::style::Node {
7933                    flex_basis: stretch::style::Dimension::Points(50.0000),
7934                    children: vec![stretch::style::Node {
7935                        size: stretch::geometry::Size {
7936                            width: stretch::style::Dimension::Percent(1.0000),
7937                            height: stretch::style::Dimension::Points(100.0000),
7938                            ..Default::default()
7939                        },
7940                        ..Default::default()
7941                    }],
7942                    ..Default::default()
7943                }],
7944                ..Default::default()
7945            },
7946            stretch::geometry::Size::undefined(),
7947        );
7948
7949        assert_eq!(layout.size.width, 100.0000);
7950        assert_eq!(layout.size.height, 100.0000);
7951        assert_eq!(layout.location.x, 0.0000);
7952        assert_eq!(layout.location.y, 0.0000);
7953
7954        assert_eq!(layout.children[0].size.width, 50.0000);
7955        assert_eq!(layout.children[0].size.height, 100.0000);
7956        assert_eq!(layout.children[0].location.x, 0.0000);
7957        assert_eq!(layout.children[0].location.y, 0.0000);
7958
7959        assert_eq!(layout.children[0].children[0].size.width, 50.0000);
7960        assert_eq!(layout.children[0].children[0].size.height, 100.0000);
7961        assert_eq!(layout.children[0].children[0].location.x, 0.0000);
7962        assert_eq!(layout.children[0].children[0].location.y, 0.0000);
7963    }
7964
7965    #[test]
7966    fn align_items_flex_end_child_with_margin_bigger_than_parent() {
7967        let layout = stretch::compute(
7968            &stretch::style::Node {
7969                align_items: stretch::style::AlignItems::Center,
7970                justify_content: stretch::style::JustifyContent::Center,
7971                size: stretch::geometry::Size {
7972                    width: stretch::style::Dimension::Points(50.0000),
7973                    height: stretch::style::Dimension::Points(50.0000),
7974                    ..Default::default()
7975                },
7976                children: vec![stretch::style::Node {
7977                    align_items: stretch::style::AlignItems::FlexEnd,
7978                    children: vec![stretch::style::Node {
7979                        size: stretch::geometry::Size {
7980                            width: stretch::style::Dimension::Points(50.0000),
7981                            height: stretch::style::Dimension::Points(50.0000),
7982                            ..Default::default()
7983                        },
7984                        margin: stretch::geometry::Rect {
7985                            start: stretch::style::Dimension::Points(10.0000),
7986                            end: stretch::style::Dimension::Points(10.0000),
7987                            ..Default::default()
7988                        },
7989                        ..Default::default()
7990                    }],
7991                    ..Default::default()
7992                }],
7993                ..Default::default()
7994            },
7995            stretch::geometry::Size::undefined(),
7996        );
7997
7998        assert_eq!(layout.size.width, 50.0000);
7999        assert_eq!(layout.size.height, 50.0000);
8000        assert_eq!(layout.location.x, 0.0000);
8001        assert_eq!(layout.location.y, 0.0000);
8002
8003        assert_eq!(layout.children[0].size.width, 70.0000);
8004        assert_eq!(layout.children[0].size.height, 50.0000);
8005        assert_eq!(layout.children[0].location.x, -10.0000);
8006        assert_eq!(layout.children[0].location.y, 0.0000);
8007
8008        assert_eq!(layout.children[0].children[0].size.width, 50.0000);
8009        assert_eq!(layout.children[0].children[0].size.height, 50.0000);
8010        assert_eq!(layout.children[0].children[0].location.x, 10.0000);
8011        assert_eq!(layout.children[0].children[0].location.y, 0.0000);
8012    }
8013
8014    #[test]
8015    fn justify_content_row_max_width_and_margin() {
8016        let layout = stretch::compute(
8017            &stretch::style::Node {
8018                justify_content: stretch::style::JustifyContent::Center,
8019                size: stretch::geometry::Size {
8020                    width: stretch::style::Dimension::Points(100.0000),
8021                    ..Default::default()
8022                },
8023                max_size: stretch::geometry::Size {
8024                    width: stretch::style::Dimension::Points(80.0000),
8025                    ..Default::default()
8026                },
8027                children: vec![stretch::style::Node {
8028                    size: stretch::geometry::Size {
8029                        width: stretch::style::Dimension::Points(20.0000),
8030                        height: stretch::style::Dimension::Points(20.0000),
8031                        ..Default::default()
8032                    },
8033                    margin: stretch::geometry::Rect {
8034                        start: stretch::style::Dimension::Points(100.0000),
8035                        ..Default::default()
8036                    },
8037                    ..Default::default()
8038                }],
8039                ..Default::default()
8040            },
8041            stretch::geometry::Size::undefined(),
8042        );
8043
8044        assert_eq!(layout.size.width, 80.0000);
8045        assert_eq!(layout.size.height, 20.0000);
8046        assert_eq!(layout.location.x, 0.0000);
8047        assert_eq!(layout.location.y, 0.0000);
8048
8049        assert_eq!(layout.children[0].size.width, 0.0000);
8050        assert_eq!(layout.children[0].size.height, 20.0000);
8051        assert_eq!(layout.children[0].location.x, 90.0000);
8052        assert_eq!(layout.children[0].location.y, 0.0000);
8053    }
8054
8055    #[test]
8056    fn margin_left() {
8057        let layout = stretch::compute(
8058            &stretch::style::Node {
8059                size: stretch::geometry::Size {
8060                    width: stretch::style::Dimension::Points(100.0000),
8061                    height: stretch::style::Dimension::Points(100.0000),
8062                    ..Default::default()
8063                },
8064                children: vec![stretch::style::Node {
8065                    size: stretch::geometry::Size {
8066                        width: stretch::style::Dimension::Points(10.0000),
8067                        ..Default::default()
8068                    },
8069                    margin: stretch::geometry::Rect {
8070                        start: stretch::style::Dimension::Points(10.0000),
8071                        ..Default::default()
8072                    },
8073                    ..Default::default()
8074                }],
8075                ..Default::default()
8076            },
8077            stretch::geometry::Size::undefined(),
8078        );
8079
8080        assert_eq!(layout.size.width, 100.0000);
8081        assert_eq!(layout.size.height, 100.0000);
8082        assert_eq!(layout.location.x, 0.0000);
8083        assert_eq!(layout.location.y, 0.0000);
8084
8085        assert_eq!(layout.children[0].size.width, 10.0000);
8086        assert_eq!(layout.children[0].size.height, 100.0000);
8087        assert_eq!(layout.children[0].location.x, 10.0000);
8088        assert_eq!(layout.children[0].location.y, 0.0000);
8089    }
8090
8091    #[test]
8092    fn size_defined_by_child() {
8093        let layout = stretch::compute(
8094            &stretch::style::Node {
8095                children: vec![stretch::style::Node {
8096                    size: stretch::geometry::Size {
8097                        width: stretch::style::Dimension::Points(100.0000),
8098                        height: stretch::style::Dimension::Points(100.0000),
8099                        ..Default::default()
8100                    },
8101                    ..Default::default()
8102                }],
8103                ..Default::default()
8104            },
8105            stretch::geometry::Size::undefined(),
8106        );
8107
8108        assert_eq!(layout.size.width, 100.0000);
8109        assert_eq!(layout.size.height, 100.0000);
8110        assert_eq!(layout.location.x, 0.0000);
8111        assert_eq!(layout.location.y, 0.0000);
8112
8113        assert_eq!(layout.children[0].size.width, 100.0000);
8114        assert_eq!(layout.children[0].size.height, 100.0000);
8115        assert_eq!(layout.children[0].location.x, 0.0000);
8116        assert_eq!(layout.children[0].location.y, 0.0000);
8117    }
8118
8119    #[test]
8120    fn rounding_total_fractial_nested() {
8121        let layout = stretch::compute(
8122            &stretch::style::Node {
8123                flex_direction: stretch::style::FlexDirection::Column,
8124                size: stretch::geometry::Size {
8125                    width: stretch::style::Dimension::Points(87.4000),
8126                    height: stretch::style::Dimension::Points(113.4000),
8127                    ..Default::default()
8128                },
8129                children: vec![
8130                    stretch::style::Node {
8131                        flex_direction: stretch::style::FlexDirection::Column,
8132                        flex_grow: 0.7000,
8133                        flex_basis: stretch::style::Dimension::Points(50.3000),
8134                        size: stretch::geometry::Size {
8135                            height: stretch::style::Dimension::Points(20.3000),
8136                            ..Default::default()
8137                        },
8138                        children: vec![
8139                            stretch::style::Node {
8140                                flex_grow: 1.0000,
8141                                flex_basis: stretch::style::Dimension::Points(0.3000),
8142                                size: stretch::geometry::Size {
8143                                    height: stretch::style::Dimension::Points(9.9000),
8144                                    ..Default::default()
8145                                },
8146                                position: stretch::geometry::Rect {
8147                                    bottom: stretch::style::Dimension::Points(13.3000),
8148                                    ..Default::default()
8149                                },
8150                                ..Default::default()
8151                            },
8152                            stretch::style::Node {
8153                                flex_grow: 4.0000,
8154                                flex_basis: stretch::style::Dimension::Points(0.3000),
8155                                size: stretch::geometry::Size {
8156                                    height: stretch::style::Dimension::Points(1.1000),
8157                                    ..Default::default()
8158                                },
8159                                position: stretch::geometry::Rect {
8160                                    top: stretch::style::Dimension::Points(13.3000),
8161                                    ..Default::default()
8162                                },
8163                                ..Default::default()
8164                            },
8165                        ],
8166                        ..Default::default()
8167                    },
8168                    stretch::style::Node {
8169                        flex_grow: 1.6000,
8170                        size: stretch::geometry::Size {
8171                            height: stretch::style::Dimension::Points(10.0000),
8172                            ..Default::default()
8173                        },
8174                        ..Default::default()
8175                    },
8176                    stretch::style::Node {
8177                        flex_grow: 1.1000,
8178                        size: stretch::geometry::Size {
8179                            height: stretch::style::Dimension::Points(10.7000),
8180                            ..Default::default()
8181                        },
8182                        ..Default::default()
8183                    },
8184                ],
8185                ..Default::default()
8186            },
8187            stretch::geometry::Size::undefined(),
8188        );
8189
8190        assert_eq!(layout.size.width, 87.0000);
8191        assert_eq!(layout.size.height, 113.0000);
8192        assert_eq!(layout.location.x, 0.0000);
8193        assert_eq!(layout.location.y, 0.0000);
8194
8195        assert_eq!(layout.children[0].size.width, 87.0000);
8196        assert_eq!(layout.children[0].size.height, 59.0000);
8197        assert_eq!(layout.children[0].location.x, 0.0000);
8198        assert_eq!(layout.children[0].location.y, 0.0000);
8199
8200        assert_eq!(layout.children[0].children[0].size.width, 87.0000);
8201        assert_eq!(layout.children[0].children[0].size.height, 12.0000);
8202        assert_eq!(layout.children[0].children[0].location.x, 0.0000);
8203        assert_eq!(layout.children[0].children[0].location.y, -13.0000);
8204
8205        assert_eq!(layout.children[0].children[1].size.width, 87.0000);
8206        assert_eq!(layout.children[0].children[1].size.height, 47.0000);
8207        assert_eq!(layout.children[0].children[1].location.x, 0.0000);
8208        assert_eq!(layout.children[0].children[1].location.y, 25.0000);
8209
8210        assert_eq!(layout.children[1].size.width, 87.0000);
8211        assert_eq!(layout.children[1].size.height, 30.0000);
8212        assert_eq!(layout.children[1].location.x, 0.0000);
8213        assert_eq!(layout.children[1].location.y, 59.0000);
8214
8215        assert_eq!(layout.children[2].size.width, 87.0000);
8216        assert_eq!(layout.children[2].size.height, 24.0000);
8217        assert_eq!(layout.children[2].location.x, 0.0000);
8218        assert_eq!(layout.children[2].location.y, 89.0000);
8219    }
8220
8221    #[test]
8222    fn min_max_percent_no_width_height() {
8223        let layout = stretch::compute(
8224            &stretch::style::Node {
8225                flex_direction: stretch::style::FlexDirection::Column,
8226                align_items: stretch::style::AlignItems::FlexStart,
8227                size: stretch::geometry::Size {
8228                    width: stretch::style::Dimension::Points(100.0000),
8229                    height: stretch::style::Dimension::Points(100.0000),
8230                    ..Default::default()
8231                },
8232                children: vec![stretch::style::Node {
8233                    min_size: stretch::geometry::Size {
8234                        width: stretch::style::Dimension::Percent(0.1000),
8235                        height: stretch::style::Dimension::Percent(0.1000),
8236                        ..Default::default()
8237                    },
8238                    max_size: stretch::geometry::Size {
8239                        width: stretch::style::Dimension::Percent(0.1000),
8240                        height: stretch::style::Dimension::Percent(0.1000),
8241                        ..Default::default()
8242                    },
8243                    ..Default::default()
8244                }],
8245                ..Default::default()
8246            },
8247            stretch::geometry::Size::undefined(),
8248        );
8249
8250        assert_eq!(layout.size.width, 100.0000);
8251        assert_eq!(layout.size.height, 100.0000);
8252        assert_eq!(layout.location.x, 0.0000);
8253        assert_eq!(layout.location.y, 0.0000);
8254
8255        assert_eq!(layout.children[0].size.width, 10.0000);
8256        assert_eq!(layout.children[0].size.height, 10.0000);
8257        assert_eq!(layout.children[0].location.x, 0.0000);
8258        assert_eq!(layout.children[0].location.y, 0.0000);
8259    }
8260
8261    #[test]
8262    fn flex_basis_smaller_then_content_with_flex_grow_very_large_size() {
8263        let layout = stretch::compute(
8264            &stretch::style::Node {
8265                size: stretch::geometry::Size {
8266                    width: stretch::style::Dimension::Points(200.0000),
8267                    ..Default::default()
8268                },
8269                children: vec![
8270                    stretch::style::Node {
8271                        flex_direction: stretch::style::FlexDirection::Column,
8272                        flex_grow: 1.0000,
8273                        flex_basis: stretch::style::Dimension::Points(0.0000),
8274                        children: vec![stretch::style::Node {
8275                            size: stretch::geometry::Size {
8276                                width: stretch::style::Dimension::Points(70.0000),
8277                                height: stretch::style::Dimension::Points(100.0000),
8278                                ..Default::default()
8279                            },
8280                            ..Default::default()
8281                        }],
8282                        ..Default::default()
8283                    },
8284                    stretch::style::Node {
8285                        flex_direction: stretch::style::FlexDirection::Column,
8286                        flex_grow: 1.0000,
8287                        flex_basis: stretch::style::Dimension::Points(0.0000),
8288                        children: vec![stretch::style::Node {
8289                            size: stretch::geometry::Size {
8290                                width: stretch::style::Dimension::Points(20.0000),
8291                                height: stretch::style::Dimension::Points(100.0000),
8292                                ..Default::default()
8293                            },
8294                            ..Default::default()
8295                        }],
8296                        ..Default::default()
8297                    },
8298                ],
8299                ..Default::default()
8300            },
8301            stretch::geometry::Size::undefined(),
8302        );
8303
8304        assert_eq!(layout.size.width, 200.0000);
8305        assert_eq!(layout.size.height, 100.0000);
8306        assert_eq!(layout.location.x, 0.0000);
8307        assert_eq!(layout.location.y, 0.0000);
8308
8309        assert_eq!(layout.children[0].size.width, 100.0000);
8310        assert_eq!(layout.children[0].size.height, 100.0000);
8311        assert_eq!(layout.children[0].location.x, 0.0000);
8312        assert_eq!(layout.children[0].location.y, 0.0000);
8313
8314        assert_eq!(layout.children[0].children[0].size.width, 70.0000);
8315        assert_eq!(layout.children[0].children[0].size.height, 100.0000);
8316        assert_eq!(layout.children[0].children[0].location.x, 0.0000);
8317        assert_eq!(layout.children[0].children[0].location.y, 0.0000);
8318
8319        assert_eq!(layout.children[1].size.width, 100.0000);
8320        assert_eq!(layout.children[1].size.height, 100.0000);
8321        assert_eq!(layout.children[1].location.x, 100.0000);
8322        assert_eq!(layout.children[1].location.y, 0.0000);
8323
8324        assert_eq!(layout.children[1].children[0].size.width, 20.0000);
8325        assert_eq!(layout.children[1].children[0].size.height, 100.0000);
8326        assert_eq!(layout.children[1].children[0].location.x, 0.0000);
8327        assert_eq!(layout.children[1].children[0].location.y, 0.0000);
8328    }
8329
8330    #[test]
8331    fn percent_within_flex_grow() {
8332        let layout = stretch::compute(
8333            &stretch::style::Node {
8334                size: stretch::geometry::Size {
8335                    width: stretch::style::Dimension::Points(350.0000),
8336                    height: stretch::style::Dimension::Points(100.0000),
8337                    ..Default::default()
8338                },
8339                children: vec![
8340                    stretch::style::Node {
8341                        size: stretch::geometry::Size {
8342                            width: stretch::style::Dimension::Points(100.0000),
8343                            ..Default::default()
8344                        },
8345                        ..Default::default()
8346                    },
8347                    stretch::style::Node {
8348                        flex_direction: stretch::style::FlexDirection::Column,
8349                        flex_grow: 1.0000,
8350                        children: vec![stretch::style::Node {
8351                            size: stretch::geometry::Size {
8352                                width: stretch::style::Dimension::Percent(1.0000),
8353                                ..Default::default()
8354                            },
8355                            ..Default::default()
8356                        }],
8357                        ..Default::default()
8358                    },
8359                    stretch::style::Node {
8360                        size: stretch::geometry::Size {
8361                            width: stretch::style::Dimension::Points(100.0000),
8362                            ..Default::default()
8363                        },
8364                        ..Default::default()
8365                    },
8366                ],
8367                ..Default::default()
8368            },
8369            stretch::geometry::Size::undefined(),
8370        );
8371
8372        assert_eq!(layout.size.width, 350.0000);
8373        assert_eq!(layout.size.height, 100.0000);
8374        assert_eq!(layout.location.x, 0.0000);
8375        assert_eq!(layout.location.y, 0.0000);
8376
8377        assert_eq!(layout.children[0].size.width, 100.0000);
8378        assert_eq!(layout.children[0].size.height, 100.0000);
8379        assert_eq!(layout.children[0].location.x, 0.0000);
8380        assert_eq!(layout.children[0].location.y, 0.0000);
8381
8382        assert_eq!(layout.children[1].size.width, 150.0000);
8383        assert_eq!(layout.children[1].size.height, 100.0000);
8384        assert_eq!(layout.children[1].location.x, 100.0000);
8385        assert_eq!(layout.children[1].location.y, 0.0000);
8386
8387        assert_eq!(layout.children[1].children[0].size.width, 150.0000);
8388        assert_eq!(layout.children[1].children[0].size.height, 0.0000);
8389        assert_eq!(layout.children[1].children[0].location.x, 0.0000);
8390        assert_eq!(layout.children[1].children[0].location.y, 0.0000);
8391
8392        assert_eq!(layout.children[2].size.width, 100.0000);
8393        assert_eq!(layout.children[2].size.height, 100.0000);
8394        assert_eq!(layout.children[2].location.x, 250.0000);
8395        assert_eq!(layout.children[2].location.y, 0.0000);
8396    }
8397
8398    #[test]
8399    fn margin_and_stretch_row() {
8400        let layout = stretch::compute(
8401            &stretch::style::Node {
8402                size: stretch::geometry::Size {
8403                    width: stretch::style::Dimension::Points(100.0000),
8404                    height: stretch::style::Dimension::Points(100.0000),
8405                    ..Default::default()
8406                },
8407                children: vec![stretch::style::Node {
8408                    flex_grow: 1.0000,
8409                    margin: stretch::geometry::Rect {
8410                        top: stretch::style::Dimension::Points(10.0000),
8411                        bottom: stretch::style::Dimension::Points(10.0000),
8412                        ..Default::default()
8413                    },
8414                    ..Default::default()
8415                }],
8416                ..Default::default()
8417            },
8418            stretch::geometry::Size::undefined(),
8419        );
8420
8421        assert_eq!(layout.size.width, 100.0000);
8422        assert_eq!(layout.size.height, 100.0000);
8423        assert_eq!(layout.location.x, 0.0000);
8424        assert_eq!(layout.location.y, 0.0000);
8425
8426        assert_eq!(layout.children[0].size.width, 100.0000);
8427        assert_eq!(layout.children[0].size.height, 80.0000);
8428        assert_eq!(layout.children[0].location.x, 0.0000);
8429        assert_eq!(layout.children[0].location.y, 10.0000);
8430    }
8431
8432    #[test]
8433    fn margin_top() {
8434        let layout = stretch::compute(
8435            &stretch::style::Node {
8436                flex_direction: stretch::style::FlexDirection::Column,
8437                size: stretch::geometry::Size {
8438                    width: stretch::style::Dimension::Points(100.0000),
8439                    height: stretch::style::Dimension::Points(100.0000),
8440                    ..Default::default()
8441                },
8442                children: vec![stretch::style::Node {
8443                    size: stretch::geometry::Size {
8444                        height: stretch::style::Dimension::Points(10.0000),
8445                        ..Default::default()
8446                    },
8447                    margin: stretch::geometry::Rect {
8448                        top: stretch::style::Dimension::Points(10.0000),
8449                        ..Default::default()
8450                    },
8451                    ..Default::default()
8452                }],
8453                ..Default::default()
8454            },
8455            stretch::geometry::Size::undefined(),
8456        );
8457
8458        assert_eq!(layout.size.width, 100.0000);
8459        assert_eq!(layout.size.height, 100.0000);
8460        assert_eq!(layout.location.x, 0.0000);
8461        assert_eq!(layout.location.y, 0.0000);
8462
8463        assert_eq!(layout.children[0].size.width, 100.0000);
8464        assert_eq!(layout.children[0].size.height, 10.0000);
8465        assert_eq!(layout.children[0].location.x, 0.0000);
8466        assert_eq!(layout.children[0].location.y, 10.0000);
8467    }
8468
8469    #[test]
8470    fn percentage_flex_basis_main_max_height() {
8471        let layout = stretch::compute(
8472            &stretch::style::Node {
8473                size: stretch::geometry::Size {
8474                    width: stretch::style::Dimension::Points(200.0000),
8475                    height: stretch::style::Dimension::Points(400.0000),
8476                    ..Default::default()
8477                },
8478                children: vec![
8479                    stretch::style::Node {
8480                        flex_grow: 1.0000,
8481                        flex_basis: stretch::style::Dimension::Percent(0.1000),
8482                        max_size: stretch::geometry::Size {
8483                            height: stretch::style::Dimension::Percent(0.6000),
8484                            ..Default::default()
8485                        },
8486                        ..Default::default()
8487                    },
8488                    stretch::style::Node {
8489                        flex_grow: 4.0000,
8490                        flex_basis: stretch::style::Dimension::Percent(0.1000),
8491                        max_size: stretch::geometry::Size {
8492                            height: stretch::style::Dimension::Percent(0.2000),
8493                            ..Default::default()
8494                        },
8495                        ..Default::default()
8496                    },
8497                ],
8498                ..Default::default()
8499            },
8500            stretch::geometry::Size::undefined(),
8501        );
8502
8503        assert_eq!(layout.size.width, 200.0000);
8504        assert_eq!(layout.size.height, 400.0000);
8505        assert_eq!(layout.location.x, 0.0000);
8506        assert_eq!(layout.location.y, 0.0000);
8507
8508        assert_eq!(layout.children[0].size.width, 52.0000);
8509        assert_eq!(layout.children[0].size.height, 240.0000);
8510        assert_eq!(layout.children[0].location.x, 0.0000);
8511        assert_eq!(layout.children[0].location.y, 0.0000);
8512
8513        assert_eq!(layout.children[1].size.width, 148.0000);
8514        assert_eq!(layout.children[1].size.height, 80.0000);
8515        assert_eq!(layout.children[1].location.x, 52.0000);
8516        assert_eq!(layout.children[1].location.y, 0.0000);
8517    }
8518
8519    #[test]
8520    fn margin_auto_left_and_right_column() {
8521        let layout = stretch::compute(
8522            &stretch::style::Node {
8523                align_items: stretch::style::AlignItems::Center,
8524                size: stretch::geometry::Size {
8525                    width: stretch::style::Dimension::Points(200.0000),
8526                    height: stretch::style::Dimension::Points(200.0000),
8527                    ..Default::default()
8528                },
8529                children: vec![
8530                    stretch::style::Node {
8531                        size: stretch::geometry::Size {
8532                            width: stretch::style::Dimension::Points(50.0000),
8533                            height: stretch::style::Dimension::Points(50.0000),
8534                            ..Default::default()
8535                        },
8536                        margin: stretch::geometry::Rect {
8537                            start: stretch::style::Dimension::Auto,
8538                            end: stretch::style::Dimension::Auto,
8539                            ..Default::default()
8540                        },
8541                        ..Default::default()
8542                    },
8543                    stretch::style::Node {
8544                        size: stretch::geometry::Size {
8545                            width: stretch::style::Dimension::Points(50.0000),
8546                            height: stretch::style::Dimension::Points(50.0000),
8547                            ..Default::default()
8548                        },
8549                        ..Default::default()
8550                    },
8551                ],
8552                ..Default::default()
8553            },
8554            stretch::geometry::Size::undefined(),
8555        );
8556
8557        assert_eq!(layout.size.width, 200.0000);
8558        assert_eq!(layout.size.height, 200.0000);
8559        assert_eq!(layout.location.x, 0.0000);
8560        assert_eq!(layout.location.y, 0.0000);
8561
8562        assert_eq!(layout.children[0].size.width, 50.0000);
8563        assert_eq!(layout.children[0].size.height, 50.0000);
8564        assert_eq!(layout.children[0].location.x, 50.0000);
8565        assert_eq!(layout.children[0].location.y, 75.0000);
8566
8567        assert_eq!(layout.children[1].size.width, 50.0000);
8568        assert_eq!(layout.children[1].size.height, 50.0000);
8569        assert_eq!(layout.children[1].location.x, 150.0000);
8570        assert_eq!(layout.children[1].location.y, 75.0000);
8571    }
8572
8573    #[test]
8574    fn margin_and_flex_row() {
8575        let layout = stretch::compute(
8576            &stretch::style::Node {
8577                size: stretch::geometry::Size {
8578                    width: stretch::style::Dimension::Points(100.0000),
8579                    height: stretch::style::Dimension::Points(100.0000),
8580                    ..Default::default()
8581                },
8582                children: vec![stretch::style::Node {
8583                    flex_grow: 1.0000,
8584                    margin: stretch::geometry::Rect {
8585                        start: stretch::style::Dimension::Points(10.0000),
8586                        end: stretch::style::Dimension::Points(10.0000),
8587                        ..Default::default()
8588                    },
8589                    ..Default::default()
8590                }],
8591                ..Default::default()
8592            },
8593            stretch::geometry::Size::undefined(),
8594        );
8595
8596        assert_eq!(layout.size.width, 100.0000);
8597        assert_eq!(layout.size.height, 100.0000);
8598        assert_eq!(layout.location.x, 0.0000);
8599        assert_eq!(layout.location.y, 0.0000);
8600
8601        assert_eq!(layout.children[0].size.width, 80.0000);
8602        assert_eq!(layout.children[0].size.height, 100.0000);
8603        assert_eq!(layout.children[0].location.x, 10.0000);
8604        assert_eq!(layout.children[0].location.y, 0.0000);
8605    }
8606
8607    #[test]
8608    fn flex_wrap_children_with_min_main_overriding_flex_basis() {
8609        let layout = stretch::compute(
8610            &stretch::style::Node {
8611                flex_wrap: stretch::style::FlexWrap::Wrap,
8612                size: stretch::geometry::Size {
8613                    width: stretch::style::Dimension::Points(100.0000),
8614                    ..Default::default()
8615                },
8616                children: vec![
8617                    stretch::style::Node {
8618                        flex_basis: stretch::style::Dimension::Points(50.0000),
8619                        size: stretch::geometry::Size {
8620                            height: stretch::style::Dimension::Points(50.0000),
8621                            ..Default::default()
8622                        },
8623                        min_size: stretch::geometry::Size {
8624                            width: stretch::style::Dimension::Points(55.0000),
8625                            ..Default::default()
8626                        },
8627                        ..Default::default()
8628                    },
8629                    stretch::style::Node {
8630                        flex_basis: stretch::style::Dimension::Points(50.0000),
8631                        size: stretch::geometry::Size {
8632                            height: stretch::style::Dimension::Points(50.0000),
8633                            ..Default::default()
8634                        },
8635                        min_size: stretch::geometry::Size {
8636                            width: stretch::style::Dimension::Points(55.0000),
8637                            ..Default::default()
8638                        },
8639                        ..Default::default()
8640                    },
8641                ],
8642                ..Default::default()
8643            },
8644            stretch::geometry::Size::undefined(),
8645        );
8646
8647        assert_eq!(layout.size.width, 100.0000);
8648        assert_eq!(layout.size.height, 100.0000);
8649        assert_eq!(layout.location.x, 0.0000);
8650        assert_eq!(layout.location.y, 0.0000);
8651
8652        assert_eq!(layout.children[0].size.width, 55.0000);
8653        assert_eq!(layout.children[0].size.height, 50.0000);
8654        assert_eq!(layout.children[0].location.x, 0.0000);
8655        assert_eq!(layout.children[0].location.y, 0.0000);
8656
8657        assert_eq!(layout.children[1].size.width, 55.0000);
8658        assert_eq!(layout.children[1].size.height, 50.0000);
8659        assert_eq!(layout.children[1].location.x, 0.0000);
8660        assert_eq!(layout.children[1].location.y, 50.0000);
8661    }
8662
8663    #[test]
8664    fn wrap_row_align_items_center() {
8665        let layout = stretch::compute(
8666            &stretch::style::Node {
8667                flex_wrap: stretch::style::FlexWrap::Wrap,
8668                align_items: stretch::style::AlignItems::Center,
8669                size: stretch::geometry::Size {
8670                    width: stretch::style::Dimension::Points(100.0000),
8671                    ..Default::default()
8672                },
8673                children: vec![
8674                    stretch::style::Node {
8675                        size: stretch::geometry::Size {
8676                            width: stretch::style::Dimension::Points(30.0000),
8677                            height: stretch::style::Dimension::Points(10.0000),
8678                            ..Default::default()
8679                        },
8680                        ..Default::default()
8681                    },
8682                    stretch::style::Node {
8683                        size: stretch::geometry::Size {
8684                            width: stretch::style::Dimension::Points(30.0000),
8685                            height: stretch::style::Dimension::Points(20.0000),
8686                            ..Default::default()
8687                        },
8688                        ..Default::default()
8689                    },
8690                    stretch::style::Node {
8691                        size: stretch::geometry::Size {
8692                            width: stretch::style::Dimension::Points(30.0000),
8693                            height: stretch::style::Dimension::Points(30.0000),
8694                            ..Default::default()
8695                        },
8696                        ..Default::default()
8697                    },
8698                    stretch::style::Node {
8699                        size: stretch::geometry::Size {
8700                            width: stretch::style::Dimension::Points(30.0000),
8701                            height: stretch::style::Dimension::Points(30.0000),
8702                            ..Default::default()
8703                        },
8704                        ..Default::default()
8705                    },
8706                ],
8707                ..Default::default()
8708            },
8709            stretch::geometry::Size::undefined(),
8710        );
8711
8712        assert_eq!(layout.size.width, 100.0000);
8713        assert_eq!(layout.size.height, 60.0000);
8714        assert_eq!(layout.location.x, 0.0000);
8715        assert_eq!(layout.location.y, 0.0000);
8716
8717        assert_eq!(layout.children[0].size.width, 30.0000);
8718        assert_eq!(layout.children[0].size.height, 10.0000);
8719        assert_eq!(layout.children[0].location.x, 0.0000);
8720        assert_eq!(layout.children[0].location.y, 10.0000);
8721
8722        assert_eq!(layout.children[1].size.width, 30.0000);
8723        assert_eq!(layout.children[1].size.height, 20.0000);
8724        assert_eq!(layout.children[1].location.x, 30.0000);
8725        assert_eq!(layout.children[1].location.y, 5.0000);
8726
8727        assert_eq!(layout.children[2].size.width, 30.0000);
8728        assert_eq!(layout.children[2].size.height, 30.0000);
8729        assert_eq!(layout.children[2].location.x, 60.0000);
8730        assert_eq!(layout.children[2].location.y, 0.0000);
8731
8732        assert_eq!(layout.children[3].size.width, 30.0000);
8733        assert_eq!(layout.children[3].size.height, 30.0000);
8734        assert_eq!(layout.children[3].location.x, 0.0000);
8735        assert_eq!(layout.children[3].location.y, 30.0000);
8736    }
8737
8738    #[test]
8739    fn display_none_with_margin() {
8740        let layout = stretch::compute(
8741            &stretch::style::Node {
8742                size: stretch::geometry::Size {
8743                    width: stretch::style::Dimension::Points(100.0000),
8744                    height: stretch::style::Dimension::Points(100.0000),
8745                    ..Default::default()
8746                },
8747                children: vec![
8748                    stretch::style::Node {
8749                        display: stretch::style::Display::None,
8750                        size: stretch::geometry::Size {
8751                            width: stretch::style::Dimension::Points(20.0000),
8752                            height: stretch::style::Dimension::Points(20.0000),
8753                            ..Default::default()
8754                        },
8755                        margin: stretch::geometry::Rect {
8756                            start: stretch::style::Dimension::Points(10.0000),
8757                            end: stretch::style::Dimension::Points(10.0000),
8758                            top: stretch::style::Dimension::Points(10.0000),
8759                            bottom: stretch::style::Dimension::Points(10.0000),
8760                            ..Default::default()
8761                        },
8762                        ..Default::default()
8763                    },
8764                    stretch::style::Node { flex_grow: 1.0000, ..Default::default() },
8765                ],
8766                ..Default::default()
8767            },
8768            stretch::geometry::Size::undefined(),
8769        );
8770
8771        assert_eq!(layout.size.width, 100.0000);
8772        assert_eq!(layout.size.height, 100.0000);
8773        assert_eq!(layout.location.x, 0.0000);
8774        assert_eq!(layout.location.y, 0.0000);
8775
8776        assert_eq!(layout.children[0].size.width, 0.0000);
8777        assert_eq!(layout.children[0].size.height, 0.0000);
8778        assert_eq!(layout.children[0].location.x, 0.0000);
8779        assert_eq!(layout.children[0].location.y, 0.0000);
8780
8781        assert_eq!(layout.children[1].size.width, 100.0000);
8782        assert_eq!(layout.children[1].size.height, 100.0000);
8783        assert_eq!(layout.children[1].location.x, 0.0000);
8784        assert_eq!(layout.children[1].location.y, 0.0000);
8785    }
8786
8787    #[test]
8788    fn flex_basis_flex_grow_column() {
8789        let layout = stretch::compute(
8790            &stretch::style::Node {
8791                flex_direction: stretch::style::FlexDirection::Column,
8792                size: stretch::geometry::Size {
8793                    width: stretch::style::Dimension::Points(100.0000),
8794                    height: stretch::style::Dimension::Points(100.0000),
8795                    ..Default::default()
8796                },
8797                children: vec![
8798                    stretch::style::Node {
8799                        flex_grow: 1.0000,
8800                        flex_basis: stretch::style::Dimension::Points(50.0000),
8801                        ..Default::default()
8802                    },
8803                    stretch::style::Node { flex_grow: 1.0000, ..Default::default() },
8804                ],
8805                ..Default::default()
8806            },
8807            stretch::geometry::Size::undefined(),
8808        );
8809
8810        assert_eq!(layout.size.width, 100.0000);
8811        assert_eq!(layout.size.height, 100.0000);
8812        assert_eq!(layout.location.x, 0.0000);
8813        assert_eq!(layout.location.y, 0.0000);
8814
8815        assert_eq!(layout.children[0].size.width, 100.0000);
8816        assert_eq!(layout.children[0].size.height, 75.0000);
8817        assert_eq!(layout.children[0].location.x, 0.0000);
8818        assert_eq!(layout.children[0].location.y, 0.0000);
8819
8820        assert_eq!(layout.children[1].size.width, 100.0000);
8821        assert_eq!(layout.children[1].size.height, 25.0000);
8822        assert_eq!(layout.children[1].location.x, 0.0000);
8823        assert_eq!(layout.children[1].location.y, 75.0000);
8824    }
8825
8826    #[test]
8827    fn absolute_layout_align_items_and_justify_content_center_and_right_position() {
8828        let layout = stretch::compute(
8829            &stretch::style::Node {
8830                align_items: stretch::style::AlignItems::Center,
8831                justify_content: stretch::style::JustifyContent::Center,
8832                size: stretch::geometry::Size {
8833                    width: stretch::style::Dimension::Points(110.0000),
8834                    height: stretch::style::Dimension::Points(100.0000),
8835                    ..Default::default()
8836                },
8837                children: vec![stretch::style::Node {
8838                    position_type: stretch::style::PositionType::Absolute,
8839                    size: stretch::geometry::Size {
8840                        width: stretch::style::Dimension::Points(60.0000),
8841                        height: stretch::style::Dimension::Points(40.0000),
8842                        ..Default::default()
8843                    },
8844                    position: stretch::geometry::Rect {
8845                        end: stretch::style::Dimension::Points(5.0000),
8846                        ..Default::default()
8847                    },
8848                    ..Default::default()
8849                }],
8850                ..Default::default()
8851            },
8852            stretch::geometry::Size::undefined(),
8853        );
8854
8855        assert_eq!(layout.size.width, 110.0000);
8856        assert_eq!(layout.size.height, 100.0000);
8857        assert_eq!(layout.location.x, 0.0000);
8858        assert_eq!(layout.location.y, 0.0000);
8859
8860        assert_eq!(layout.children[0].size.width, 60.0000);
8861        assert_eq!(layout.children[0].size.height, 40.0000);
8862        assert_eq!(layout.children[0].location.x, 45.0000);
8863        assert_eq!(layout.children[0].location.y, 30.0000);
8864    }
8865
8866    #[test]
8867    fn overflow_cross_axis() {
8868        let layout = stretch::compute(
8869            &stretch::style::Node {
8870                size: stretch::geometry::Size {
8871                    width: stretch::style::Dimension::Points(100.0000),
8872                    height: stretch::style::Dimension::Points(100.0000),
8873                    ..Default::default()
8874                },
8875                children: vec![stretch::style::Node {
8876                    size: stretch::geometry::Size {
8877                        width: stretch::style::Dimension::Points(100.0000),
8878                        height: stretch::style::Dimension::Points(200.0000),
8879                        ..Default::default()
8880                    },
8881                    ..Default::default()
8882                }],
8883                ..Default::default()
8884            },
8885            stretch::geometry::Size::undefined(),
8886        );
8887
8888        assert_eq!(layout.size.width, 100.0000);
8889        assert_eq!(layout.size.height, 100.0000);
8890        assert_eq!(layout.location.x, 0.0000);
8891        assert_eq!(layout.location.y, 0.0000);
8892
8893        assert_eq!(layout.children[0].size.width, 100.0000);
8894        assert_eq!(layout.children[0].size.height, 200.0000);
8895        assert_eq!(layout.children[0].location.x, 0.0000);
8896        assert_eq!(layout.children[0].location.y, 0.0000);
8897    }
8898
8899    #[test]
8900    fn display_none_with_position() {
8901        let layout = stretch::compute(
8902            &stretch::style::Node {
8903                size: stretch::geometry::Size {
8904                    width: stretch::style::Dimension::Points(100.0000),
8905                    height: stretch::style::Dimension::Points(100.0000),
8906                    ..Default::default()
8907                },
8908                children: vec![
8909                    stretch::style::Node { flex_grow: 1.0000, ..Default::default() },
8910                    stretch::style::Node {
8911                        display: stretch::style::Display::None,
8912                        flex_grow: 1.0000,
8913                        position: stretch::geometry::Rect {
8914                            top: stretch::style::Dimension::Points(10.0000),
8915                            ..Default::default()
8916                        },
8917                        ..Default::default()
8918                    },
8919                ],
8920                ..Default::default()
8921            },
8922            stretch::geometry::Size::undefined(),
8923        );
8924
8925        assert_eq!(layout.size.width, 100.0000);
8926        assert_eq!(layout.size.height, 100.0000);
8927        assert_eq!(layout.location.x, 0.0000);
8928        assert_eq!(layout.location.y, 0.0000);
8929
8930        assert_eq!(layout.children[0].size.width, 100.0000);
8931        assert_eq!(layout.children[0].size.height, 100.0000);
8932        assert_eq!(layout.children[0].location.x, 0.0000);
8933        assert_eq!(layout.children[0].location.y, 0.0000);
8934
8935        assert_eq!(layout.children[1].size.width, 0.0000);
8936        assert_eq!(layout.children[1].size.height, 0.0000);
8937        assert_eq!(layout.children[1].location.x, 0.0000);
8938        assert_eq!(layout.children[1].location.y, 0.0000);
8939    }
8940
8941    #[test]
8942    fn wrap_column() {
8943        let layout = stretch::compute(
8944            &stretch::style::Node {
8945                flex_direction: stretch::style::FlexDirection::Column,
8946                flex_wrap: stretch::style::FlexWrap::Wrap,
8947                size: stretch::geometry::Size {
8948                    width: stretch::style::Dimension::Points(100.0000),
8949                    height: stretch::style::Dimension::Points(100.0000),
8950                    ..Default::default()
8951                },
8952                children: vec![
8953                    stretch::style::Node {
8954                        size: stretch::geometry::Size {
8955                            width: stretch::style::Dimension::Points(30.0000),
8956                            height: stretch::style::Dimension::Points(31.0000),
8957                            ..Default::default()
8958                        },
8959                        ..Default::default()
8960                    },
8961                    stretch::style::Node {
8962                        size: stretch::geometry::Size {
8963                            width: stretch::style::Dimension::Points(30.0000),
8964                            height: stretch::style::Dimension::Points(32.0000),
8965                            ..Default::default()
8966                        },
8967                        ..Default::default()
8968                    },
8969                    stretch::style::Node {
8970                        size: stretch::geometry::Size {
8971                            width: stretch::style::Dimension::Points(30.0000),
8972                            height: stretch::style::Dimension::Points(33.0000),
8973                            ..Default::default()
8974                        },
8975                        ..Default::default()
8976                    },
8977                    stretch::style::Node {
8978                        size: stretch::geometry::Size {
8979                            width: stretch::style::Dimension::Points(30.0000),
8980                            height: stretch::style::Dimension::Points(34.0000),
8981                            ..Default::default()
8982                        },
8983                        ..Default::default()
8984                    },
8985                ],
8986                ..Default::default()
8987            },
8988            stretch::geometry::Size::undefined(),
8989        );
8990
8991        assert_eq!(layout.size.width, 100.0000);
8992        assert_eq!(layout.size.height, 100.0000);
8993        assert_eq!(layout.location.x, 0.0000);
8994        assert_eq!(layout.location.y, 0.0000);
8995
8996        assert_eq!(layout.children[0].size.width, 30.0000);
8997        assert_eq!(layout.children[0].size.height, 31.0000);
8998        assert_eq!(layout.children[0].location.x, 0.0000);
8999        assert_eq!(layout.children[0].location.y, 0.0000);
9000
9001        assert_eq!(layout.children[1].size.width, 30.0000);
9002        assert_eq!(layout.children[1].size.height, 32.0000);
9003        assert_eq!(layout.children[1].location.x, 0.0000);
9004        assert_eq!(layout.children[1].location.y, 31.0000);
9005
9006        assert_eq!(layout.children[2].size.width, 30.0000);
9007        assert_eq!(layout.children[2].size.height, 33.0000);
9008        assert_eq!(layout.children[2].location.x, 0.0000);
9009        assert_eq!(layout.children[2].location.y, 63.0000);
9010
9011        assert_eq!(layout.children[3].size.width, 30.0000);
9012        assert_eq!(layout.children[3].size.height, 34.0000);
9013        assert_eq!(layout.children[3].location.x, 50.0000);
9014        assert_eq!(layout.children[3].location.y, 0.0000);
9015    }
9016
9017    #[test]
9018    fn justify_content_column_space_evenly() {
9019        let layout = stretch::compute(
9020            &stretch::style::Node {
9021                flex_direction: stretch::style::FlexDirection::Column,
9022                justify_content: stretch::style::JustifyContent::SpaceEvenly,
9023                size: stretch::geometry::Size {
9024                    width: stretch::style::Dimension::Points(100.0000),
9025                    height: stretch::style::Dimension::Points(100.0000),
9026                    ..Default::default()
9027                },
9028                children: vec![
9029                    stretch::style::Node {
9030                        size: stretch::geometry::Size {
9031                            height: stretch::style::Dimension::Points(10.0000),
9032                            ..Default::default()
9033                        },
9034                        ..Default::default()
9035                    },
9036                    stretch::style::Node {
9037                        size: stretch::geometry::Size {
9038                            height: stretch::style::Dimension::Points(10.0000),
9039                            ..Default::default()
9040                        },
9041                        ..Default::default()
9042                    },
9043                    stretch::style::Node {
9044                        size: stretch::geometry::Size {
9045                            height: stretch::style::Dimension::Points(10.0000),
9046                            ..Default::default()
9047                        },
9048                        ..Default::default()
9049                    },
9050                ],
9051                ..Default::default()
9052            },
9053            stretch::geometry::Size::undefined(),
9054        );
9055
9056        assert_eq!(layout.size.width, 100.0000);
9057        assert_eq!(layout.size.height, 100.0000);
9058        assert_eq!(layout.location.x, 0.0000);
9059        assert_eq!(layout.location.y, 0.0000);
9060
9061        assert_eq!(layout.children[0].size.width, 100.0000);
9062        assert_eq!(layout.children[0].size.height, 10.0000);
9063        assert_eq!(layout.children[0].location.x, 0.0000);
9064        assert_eq!(layout.children[0].location.y, 18.0000);
9065
9066        assert_eq!(layout.children[1].size.width, 100.0000);
9067        assert_eq!(layout.children[1].size.height, 10.0000);
9068        assert_eq!(layout.children[1].location.x, 0.0000);
9069        assert_eq!(layout.children[1].location.y, 45.0000);
9070
9071        assert_eq!(layout.children[2].size.width, 100.0000);
9072        assert_eq!(layout.children[2].size.height, 10.0000);
9073        assert_eq!(layout.children[2].location.x, 0.0000);
9074        assert_eq!(layout.children[2].location.y, 73.0000);
9075    }
9076
9077    #[test]
9078    fn flex_grow_within_constrained_max_column() {
9079        let layout = stretch::compute(
9080            &stretch::style::Node {
9081                flex_direction: stretch::style::FlexDirection::Column,
9082                size: stretch::geometry::Size {
9083                    width: stretch::style::Dimension::Points(100.0000),
9084                    ..Default::default()
9085                },
9086                max_size: stretch::geometry::Size {
9087                    height: stretch::style::Dimension::Points(100.0000),
9088                    ..Default::default()
9089                },
9090                children: vec![
9091                    stretch::style::Node {
9092                        flex_shrink: 1.0000,
9093                        flex_basis: stretch::style::Dimension::Points(100.0000),
9094                        ..Default::default()
9095                    },
9096                    stretch::style::Node {
9097                        size: stretch::geometry::Size {
9098                            height: stretch::style::Dimension::Points(50.0000),
9099                            ..Default::default()
9100                        },
9101                        ..Default::default()
9102                    },
9103                ],
9104                ..Default::default()
9105            },
9106            stretch::geometry::Size::undefined(),
9107        );
9108
9109        assert_eq!(layout.size.width, 100.0000);
9110        assert_eq!(layout.size.height, 100.0000);
9111        assert_eq!(layout.location.x, 0.0000);
9112        assert_eq!(layout.location.y, 0.0000);
9113
9114        assert_eq!(layout.children[0].size.width, 100.0000);
9115        assert_eq!(layout.children[0].size.height, 67.0000);
9116        assert_eq!(layout.children[0].location.x, 0.0000);
9117        assert_eq!(layout.children[0].location.y, 0.0000);
9118
9119        assert_eq!(layout.children[1].size.width, 100.0000);
9120        assert_eq!(layout.children[1].size.height, 33.0000);
9121        assert_eq!(layout.children[1].location.x, 0.0000);
9122        assert_eq!(layout.children[1].location.y, 67.0000);
9123    }
9124
9125    #[test]
9126    fn justify_content_column_space_around() {
9127        let layout = stretch::compute(
9128            &stretch::style::Node {
9129                flex_direction: stretch::style::FlexDirection::Column,
9130                justify_content: stretch::style::JustifyContent::SpaceAround,
9131                size: stretch::geometry::Size {
9132                    width: stretch::style::Dimension::Points(100.0000),
9133                    height: stretch::style::Dimension::Points(100.0000),
9134                    ..Default::default()
9135                },
9136                children: vec![
9137                    stretch::style::Node {
9138                        size: stretch::geometry::Size {
9139                            height: stretch::style::Dimension::Points(10.0000),
9140                            ..Default::default()
9141                        },
9142                        ..Default::default()
9143                    },
9144                    stretch::style::Node {
9145                        size: stretch::geometry::Size {
9146                            height: stretch::style::Dimension::Points(10.0000),
9147                            ..Default::default()
9148                        },
9149                        ..Default::default()
9150                    },
9151                    stretch::style::Node {
9152                        size: stretch::geometry::Size {
9153                            height: stretch::style::Dimension::Points(10.0000),
9154                            ..Default::default()
9155                        },
9156                        ..Default::default()
9157                    },
9158                ],
9159                ..Default::default()
9160            },
9161            stretch::geometry::Size::undefined(),
9162        );
9163
9164        assert_eq!(layout.size.width, 100.0000);
9165        assert_eq!(layout.size.height, 100.0000);
9166        assert_eq!(layout.location.x, 0.0000);
9167        assert_eq!(layout.location.y, 0.0000);
9168
9169        assert_eq!(layout.children[0].size.width, 100.0000);
9170        assert_eq!(layout.children[0].size.height, 10.0000);
9171        assert_eq!(layout.children[0].location.x, 0.0000);
9172        assert_eq!(layout.children[0].location.y, 12.0000);
9173
9174        assert_eq!(layout.children[1].size.width, 100.0000);
9175        assert_eq!(layout.children[1].size.height, 10.0000);
9176        assert_eq!(layout.children[1].location.x, 0.0000);
9177        assert_eq!(layout.children[1].location.y, 45.0000);
9178
9179        assert_eq!(layout.children[2].size.width, 100.0000);
9180        assert_eq!(layout.children[2].size.height, 10.0000);
9181        assert_eq!(layout.children[2].location.x, 0.0000);
9182        assert_eq!(layout.children[2].location.y, 78.0000);
9183    }
9184
9185    #[test]
9186    fn flex_basis_larger_than_content_row() {
9187        let layout = stretch::compute(
9188            &stretch::style::Node {
9189                size: stretch::geometry::Size {
9190                    width: stretch::style::Dimension::Points(100.0000),
9191                    ..Default::default()
9192                },
9193                children: vec![stretch::style::Node {
9194                    flex_direction: stretch::style::FlexDirection::Column,
9195                    flex_basis: stretch::style::Dimension::Points(50.0000),
9196                    children: vec![stretch::style::Node {
9197                        size: stretch::geometry::Size {
9198                            width: stretch::style::Dimension::Points(10.0000),
9199                            height: stretch::style::Dimension::Points(100.0000),
9200                            ..Default::default()
9201                        },
9202                        ..Default::default()
9203                    }],
9204                    ..Default::default()
9205                }],
9206                ..Default::default()
9207            },
9208            stretch::geometry::Size::undefined(),
9209        );
9210
9211        assert_eq!(layout.size.width, 100.0000);
9212        assert_eq!(layout.size.height, 100.0000);
9213        assert_eq!(layout.location.x, 0.0000);
9214        assert_eq!(layout.location.y, 0.0000);
9215
9216        assert_eq!(layout.children[0].size.width, 50.0000);
9217        assert_eq!(layout.children[0].size.height, 100.0000);
9218        assert_eq!(layout.children[0].location.x, 0.0000);
9219        assert_eq!(layout.children[0].location.y, 0.0000);
9220
9221        assert_eq!(layout.children[0].children[0].size.width, 10.0000);
9222        assert_eq!(layout.children[0].children[0].size.height, 100.0000);
9223        assert_eq!(layout.children[0].children[0].location.x, 0.0000);
9224        assert_eq!(layout.children[0].children[0].location.y, 0.0000);
9225    }
9226
9227    #[test]
9228    fn absolute_layout_align_items_and_justify_content_center_and_left_position() {
9229        let layout = stretch::compute(
9230            &stretch::style::Node {
9231                align_items: stretch::style::AlignItems::Center,
9232                justify_content: stretch::style::JustifyContent::Center,
9233                size: stretch::geometry::Size {
9234                    width: stretch::style::Dimension::Points(110.0000),
9235                    height: stretch::style::Dimension::Points(100.0000),
9236                    ..Default::default()
9237                },
9238                children: vec![stretch::style::Node {
9239                    position_type: stretch::style::PositionType::Absolute,
9240                    size: stretch::geometry::Size {
9241                        width: stretch::style::Dimension::Points(60.0000),
9242                        height: stretch::style::Dimension::Points(40.0000),
9243                        ..Default::default()
9244                    },
9245                    position: stretch::geometry::Rect {
9246                        start: stretch::style::Dimension::Points(5.0000),
9247                        ..Default::default()
9248                    },
9249                    ..Default::default()
9250                }],
9251                ..Default::default()
9252            },
9253            stretch::geometry::Size::undefined(),
9254        );
9255
9256        assert_eq!(layout.size.width, 110.0000);
9257        assert_eq!(layout.size.height, 100.0000);
9258        assert_eq!(layout.location.x, 0.0000);
9259        assert_eq!(layout.location.y, 0.0000);
9260
9261        assert_eq!(layout.children[0].size.width, 60.0000);
9262        assert_eq!(layout.children[0].size.height, 40.0000);
9263        assert_eq!(layout.children[0].location.x, 5.0000);
9264        assert_eq!(layout.children[0].location.y, 30.0000);
9265    }
9266
9267    #[test]
9268    fn percentage_flex_basis_main_min_width() {
9269        let layout = stretch::compute(
9270            &stretch::style::Node {
9271                size: stretch::geometry::Size {
9272                    width: stretch::style::Dimension::Points(200.0000),
9273                    height: stretch::style::Dimension::Points(400.0000),
9274                    ..Default::default()
9275                },
9276                children: vec![
9277                    stretch::style::Node {
9278                        flex_grow: 1.0000,
9279                        flex_basis: stretch::style::Dimension::Percent(0.1500),
9280                        min_size: stretch::geometry::Size {
9281                            width: stretch::style::Dimension::Percent(0.6000),
9282                            ..Default::default()
9283                        },
9284                        ..Default::default()
9285                    },
9286                    stretch::style::Node {
9287                        flex_grow: 4.0000,
9288                        flex_basis: stretch::style::Dimension::Percent(0.1000),
9289                        min_size: stretch::geometry::Size {
9290                            width: stretch::style::Dimension::Percent(0.2000),
9291                            ..Default::default()
9292                        },
9293                        ..Default::default()
9294                    },
9295                ],
9296                ..Default::default()
9297            },
9298            stretch::geometry::Size::undefined(),
9299        );
9300
9301        assert_eq!(layout.size.width, 200.0000);
9302        assert_eq!(layout.size.height, 400.0000);
9303        assert_eq!(layout.location.x, 0.0000);
9304        assert_eq!(layout.location.y, 0.0000);
9305
9306        assert_eq!(layout.children[0].size.width, 120.0000);
9307        assert_eq!(layout.children[0].size.height, 400.0000);
9308        assert_eq!(layout.children[0].location.x, 0.0000);
9309        assert_eq!(layout.children[0].location.y, 0.0000);
9310
9311        assert_eq!(layout.children[1].size.width, 80.0000);
9312        assert_eq!(layout.children[1].size.height, 400.0000);
9313        assert_eq!(layout.children[1].location.x, 120.0000);
9314        assert_eq!(layout.children[1].location.y, 0.0000);
9315    }
9316
9317    #[test]
9318    fn margin_auto_bottom() {
9319        let layout = stretch::compute(
9320            &stretch::style::Node {
9321                align_items: stretch::style::AlignItems::Center,
9322                size: stretch::geometry::Size {
9323                    width: stretch::style::Dimension::Points(200.0000),
9324                    height: stretch::style::Dimension::Points(200.0000),
9325                    ..Default::default()
9326                },
9327                children: vec![
9328                    stretch::style::Node {
9329                        size: stretch::geometry::Size {
9330                            width: stretch::style::Dimension::Points(50.0000),
9331                            height: stretch::style::Dimension::Points(50.0000),
9332                            ..Default::default()
9333                        },
9334                        margin: stretch::geometry::Rect {
9335                            bottom: stretch::style::Dimension::Auto,
9336                            ..Default::default()
9337                        },
9338                        ..Default::default()
9339                    },
9340                    stretch::style::Node {
9341                        size: stretch::geometry::Size {
9342                            width: stretch::style::Dimension::Points(50.0000),
9343                            height: stretch::style::Dimension::Points(50.0000),
9344                            ..Default::default()
9345                        },
9346                        ..Default::default()
9347                    },
9348                ],
9349                ..Default::default()
9350            },
9351            stretch::geometry::Size::undefined(),
9352        );
9353
9354        assert_eq!(layout.size.width, 200.0000);
9355        assert_eq!(layout.size.height, 200.0000);
9356        assert_eq!(layout.location.x, 0.0000);
9357        assert_eq!(layout.location.y, 0.0000);
9358
9359        assert_eq!(layout.children[0].size.width, 50.0000);
9360        assert_eq!(layout.children[0].size.height, 50.0000);
9361        assert_eq!(layout.children[0].location.x, 0.0000);
9362        assert_eq!(layout.children[0].location.y, 0.0000);
9363
9364        assert_eq!(layout.children[1].size.width, 50.0000);
9365        assert_eq!(layout.children[1].size.height, 50.0000);
9366        assert_eq!(layout.children[1].location.x, 50.0000);
9367        assert_eq!(layout.children[1].location.y, 75.0000);
9368    }
9369
9370    #[test]
9371    fn flex_grow_shrink_at_most() {
9372        let layout = stretch::compute(
9373            &stretch::style::Node {
9374                size: stretch::geometry::Size {
9375                    width: stretch::style::Dimension::Points(100.0000),
9376                    height: stretch::style::Dimension::Points(100.0000),
9377                    ..Default::default()
9378                },
9379                children: vec![stretch::style::Node {
9380                    children: vec![stretch::style::Node {
9381                        flex_grow: 1.0000,
9382                        flex_shrink: 1.0000,
9383                        ..Default::default()
9384                    }],
9385                    ..Default::default()
9386                }],
9387                ..Default::default()
9388            },
9389            stretch::geometry::Size::undefined(),
9390        );
9391
9392        assert_eq!(layout.size.width, 100.0000);
9393        assert_eq!(layout.size.height, 100.0000);
9394        assert_eq!(layout.location.x, 0.0000);
9395        assert_eq!(layout.location.y, 0.0000);
9396
9397        assert_eq!(layout.children[0].size.width, 0.0000);
9398        assert_eq!(layout.children[0].size.height, 100.0000);
9399        assert_eq!(layout.children[0].location.x, 0.0000);
9400        assert_eq!(layout.children[0].location.y, 0.0000);
9401
9402        assert_eq!(layout.children[0].children[0].size.width, 0.0000);
9403        assert_eq!(layout.children[0].children[0].size.height, 100.0000);
9404        assert_eq!(layout.children[0].children[0].location.x, 0.0000);
9405        assert_eq!(layout.children[0].children[0].location.y, 0.0000);
9406    }
9407
9408    #[test]
9409    fn percentage_padding_should_calculate_based_only_on_width() {
9410        let layout = stretch::compute(
9411            &stretch::style::Node {
9412                flex_direction: stretch::style::FlexDirection::Column,
9413                size: stretch::geometry::Size {
9414                    width: stretch::style::Dimension::Points(200.0000),
9415                    height: stretch::style::Dimension::Points(100.0000),
9416                    ..Default::default()
9417                },
9418                children: vec![stretch::style::Node {
9419                    flex_direction: stretch::style::FlexDirection::Column,
9420                    flex_grow: 1.0000,
9421                    padding: stretch::geometry::Rect {
9422                        start: stretch::style::Dimension::Percent(0.1000),
9423                        end: stretch::style::Dimension::Percent(0.1000),
9424                        top: stretch::style::Dimension::Percent(0.1000),
9425                        bottom: stretch::style::Dimension::Percent(0.1000),
9426                        ..Default::default()
9427                    },
9428                    children: vec![stretch::style::Node {
9429                        size: stretch::geometry::Size {
9430                            width: stretch::style::Dimension::Points(10.0000),
9431                            height: stretch::style::Dimension::Points(10.0000),
9432                            ..Default::default()
9433                        },
9434                        ..Default::default()
9435                    }],
9436                    ..Default::default()
9437                }],
9438                ..Default::default()
9439            },
9440            stretch::geometry::Size::undefined(),
9441        );
9442
9443        assert_eq!(layout.size.width, 200.0000);
9444        assert_eq!(layout.size.height, 100.0000);
9445        assert_eq!(layout.location.x, 0.0000);
9446        assert_eq!(layout.location.y, 0.0000);
9447
9448        assert_eq!(layout.children[0].size.width, 200.0000);
9449        assert_eq!(layout.children[0].size.height, 100.0000);
9450        assert_eq!(layout.children[0].location.x, 0.0000);
9451        assert_eq!(layout.children[0].location.y, 0.0000);
9452
9453        assert_eq!(layout.children[0].children[0].size.width, 10.0000);
9454        assert_eq!(layout.children[0].children[0].size.height, 10.0000);
9455        assert_eq!(layout.children[0].children[0].location.x, 20.0000);
9456        assert_eq!(layout.children[0].children[0].location.y, 20.0000);
9457    }
9458
9459    #[test]
9460    fn flex_shrink_to_zero() {
9461        let layout = stretch::compute(
9462            &stretch::style::Node {
9463                size: stretch::geometry::Size {
9464                    width: stretch::style::Dimension::Points(75.0000),
9465                    ..Default::default()
9466                },
9467                children: vec![
9468                    stretch::style::Node {
9469                        flex_shrink: 0.0000,
9470                        size: stretch::geometry::Size {
9471                            width: stretch::style::Dimension::Points(50.0000),
9472                            height: stretch::style::Dimension::Points(50.0000),
9473                            ..Default::default()
9474                        },
9475                        ..Default::default()
9476                    },
9477                    stretch::style::Node {
9478                        flex_shrink: 1.0000,
9479                        size: stretch::geometry::Size {
9480                            width: stretch::style::Dimension::Points(50.0000),
9481                            height: stretch::style::Dimension::Points(50.0000),
9482                            ..Default::default()
9483                        },
9484                        ..Default::default()
9485                    },
9486                    stretch::style::Node {
9487                        flex_shrink: 0.0000,
9488                        size: stretch::geometry::Size {
9489                            width: stretch::style::Dimension::Points(50.0000),
9490                            height: stretch::style::Dimension::Points(50.0000),
9491                            ..Default::default()
9492                        },
9493                        ..Default::default()
9494                    },
9495                ],
9496                ..Default::default()
9497            },
9498            stretch::geometry::Size::undefined(),
9499        );
9500
9501        assert_eq!(layout.size.width, 75.0000);
9502        assert_eq!(layout.size.height, 50.0000);
9503        assert_eq!(layout.location.x, 0.0000);
9504        assert_eq!(layout.location.y, 0.0000);
9505
9506        assert_eq!(layout.children[0].size.width, 50.0000);
9507        assert_eq!(layout.children[0].size.height, 50.0000);
9508        assert_eq!(layout.children[0].location.x, 0.0000);
9509        assert_eq!(layout.children[0].location.y, 0.0000);
9510
9511        assert_eq!(layout.children[1].size.width, 0.0000);
9512        assert_eq!(layout.children[1].size.height, 50.0000);
9513        assert_eq!(layout.children[1].location.x, 50.0000);
9514        assert_eq!(layout.children[1].location.y, 0.0000);
9515
9516        assert_eq!(layout.children[2].size.width, 50.0000);
9517        assert_eq!(layout.children[2].size.height, 50.0000);
9518        assert_eq!(layout.children[2].location.x, 50.0000);
9519        assert_eq!(layout.children[2].location.y, 0.0000);
9520    }
9521
9522    #[test]
9523    fn margin_auto_mutiple_children_row() {
9524        let layout = stretch::compute(
9525            &stretch::style::Node {
9526                align_items: stretch::style::AlignItems::Center,
9527                size: stretch::geometry::Size {
9528                    width: stretch::style::Dimension::Points(200.0000),
9529                    height: stretch::style::Dimension::Points(200.0000),
9530                    ..Default::default()
9531                },
9532                children: vec![
9533                    stretch::style::Node {
9534                        size: stretch::geometry::Size {
9535                            width: stretch::style::Dimension::Points(50.0000),
9536                            height: stretch::style::Dimension::Points(50.0000),
9537                            ..Default::default()
9538                        },
9539                        margin: stretch::geometry::Rect { end: stretch::style::Dimension::Auto, ..Default::default() },
9540                        ..Default::default()
9541                    },
9542                    stretch::style::Node {
9543                        size: stretch::geometry::Size {
9544                            width: stretch::style::Dimension::Points(50.0000),
9545                            height: stretch::style::Dimension::Points(50.0000),
9546                            ..Default::default()
9547                        },
9548                        margin: stretch::geometry::Rect { end: stretch::style::Dimension::Auto, ..Default::default() },
9549                        ..Default::default()
9550                    },
9551                    stretch::style::Node {
9552                        size: stretch::geometry::Size {
9553                            width: stretch::style::Dimension::Points(50.0000),
9554                            height: stretch::style::Dimension::Points(50.0000),
9555                            ..Default::default()
9556                        },
9557                        ..Default::default()
9558                    },
9559                ],
9560                ..Default::default()
9561            },
9562            stretch::geometry::Size::undefined(),
9563        );
9564
9565        assert_eq!(layout.size.width, 200.0000);
9566        assert_eq!(layout.size.height, 200.0000);
9567        assert_eq!(layout.location.x, 0.0000);
9568        assert_eq!(layout.location.y, 0.0000);
9569
9570        assert_eq!(layout.children[0].size.width, 50.0000);
9571        assert_eq!(layout.children[0].size.height, 50.0000);
9572        assert_eq!(layout.children[0].location.x, 0.0000);
9573        assert_eq!(layout.children[0].location.y, 75.0000);
9574
9575        assert_eq!(layout.children[1].size.width, 50.0000);
9576        assert_eq!(layout.children[1].size.height, 50.0000);
9577        assert_eq!(layout.children[1].location.x, 75.0000);
9578        assert_eq!(layout.children[1].location.y, 75.0000);
9579
9580        assert_eq!(layout.children[2].size.width, 50.0000);
9581        assert_eq!(layout.children[2].size.height, 50.0000);
9582        assert_eq!(layout.children[2].location.x, 150.0000);
9583        assert_eq!(layout.children[2].location.y, 75.0000);
9584    }
9585
9586    #[test]
9587    fn justify_content_min_width_with_padding_child_width_lower_than_parent() {
9588        let layout = stretch::compute(
9589            &stretch::style::Node {
9590                flex_direction: stretch::style::FlexDirection::Column,
9591                size: stretch::geometry::Size {
9592                    width: stretch::style::Dimension::Points(1080.0000),
9593                    height: stretch::style::Dimension::Points(1584.0000),
9594                    ..Default::default()
9595                },
9596                children: vec![stretch::style::Node {
9597                    children: vec![stretch::style::Node {
9598                        justify_content: stretch::style::JustifyContent::Center,
9599                        min_size: stretch::geometry::Size {
9600                            width: stretch::style::Dimension::Points(400.0000),
9601                            ..Default::default()
9602                        },
9603                        padding: stretch::geometry::Rect {
9604                            start: stretch::style::Dimension::Points(100.0000),
9605                            end: stretch::style::Dimension::Points(100.0000),
9606                            ..Default::default()
9607                        },
9608                        children: vec![stretch::style::Node {
9609                            size: stretch::geometry::Size {
9610                                width: stretch::style::Dimension::Points(199.0000),
9611                                height: stretch::style::Dimension::Points(100.0000),
9612                                ..Default::default()
9613                            },
9614                            ..Default::default()
9615                        }],
9616                        ..Default::default()
9617                    }],
9618                    ..Default::default()
9619                }],
9620                ..Default::default()
9621            },
9622            stretch::geometry::Size::undefined(),
9623        );
9624
9625        assert_eq!(layout.size.width, 1080.0000);
9626        assert_eq!(layout.size.height, 1584.0000);
9627        assert_eq!(layout.location.x, 0.0000);
9628        assert_eq!(layout.location.y, 0.0000);
9629
9630        assert_eq!(layout.children[0].size.width, 1080.0000);
9631        assert_eq!(layout.children[0].size.height, 100.0000);
9632        assert_eq!(layout.children[0].location.x, 0.0000);
9633        assert_eq!(layout.children[0].location.y, 0.0000);
9634
9635        assert_eq!(layout.children[0].children[0].size.width, 400.0000);
9636        assert_eq!(layout.children[0].children[0].size.height, 100.0000);
9637        assert_eq!(layout.children[0].children[0].location.x, 0.0000);
9638        assert_eq!(layout.children[0].children[0].location.y, 0.0000);
9639
9640        assert_eq!(layout.children[0].children[0].children[0].size.width, 199.0000);
9641        assert_eq!(layout.children[0].children[0].children[0].size.height, 100.0000);
9642        assert_eq!(layout.children[0].children[0].children[0].location.x, 101.0000);
9643        assert_eq!(layout.children[0].children[0].children[0].location.y, 0.0000);
9644    }
9645
9646    #[test]
9647    fn size_defined_by_grand_child() {
9648        let layout = stretch::compute(
9649            &stretch::style::Node {
9650                children: vec![stretch::style::Node {
9651                    children: vec![stretch::style::Node {
9652                        size: stretch::geometry::Size {
9653                            width: stretch::style::Dimension::Points(100.0000),
9654                            height: stretch::style::Dimension::Points(100.0000),
9655                            ..Default::default()
9656                        },
9657                        ..Default::default()
9658                    }],
9659                    ..Default::default()
9660                }],
9661                ..Default::default()
9662            },
9663            stretch::geometry::Size::undefined(),
9664        );
9665
9666        assert_eq!(layout.size.width, 100.0000);
9667        assert_eq!(layout.size.height, 100.0000);
9668        assert_eq!(layout.location.x, 0.0000);
9669        assert_eq!(layout.location.y, 0.0000);
9670
9671        assert_eq!(layout.children[0].size.width, 100.0000);
9672        assert_eq!(layout.children[0].size.height, 100.0000);
9673        assert_eq!(layout.children[0].location.x, 0.0000);
9674        assert_eq!(layout.children[0].location.y, 0.0000);
9675
9676        assert_eq!(layout.children[0].children[0].size.width, 100.0000);
9677        assert_eq!(layout.children[0].children[0].size.height, 100.0000);
9678        assert_eq!(layout.children[0].children[0].location.x, 0.0000);
9679        assert_eq!(layout.children[0].children[0].location.y, 0.0000);
9680    }
9681
9682    #[test]
9683    fn absolute_layout_align_items_and_justify_content_center_and_bottom_position() {
9684        let layout = stretch::compute(
9685            &stretch::style::Node {
9686                align_items: stretch::style::AlignItems::Center,
9687                justify_content: stretch::style::JustifyContent::Center,
9688                size: stretch::geometry::Size {
9689                    width: stretch::style::Dimension::Points(110.0000),
9690                    height: stretch::style::Dimension::Points(100.0000),
9691                    ..Default::default()
9692                },
9693                children: vec![stretch::style::Node {
9694                    position_type: stretch::style::PositionType::Absolute,
9695                    size: stretch::geometry::Size {
9696                        width: stretch::style::Dimension::Points(60.0000),
9697                        height: stretch::style::Dimension::Points(40.0000),
9698                        ..Default::default()
9699                    },
9700                    position: stretch::geometry::Rect {
9701                        bottom: stretch::style::Dimension::Points(10.0000),
9702                        ..Default::default()
9703                    },
9704                    ..Default::default()
9705                }],
9706                ..Default::default()
9707            },
9708            stretch::geometry::Size::undefined(),
9709        );
9710
9711        assert_eq!(layout.size.width, 110.0000);
9712        assert_eq!(layout.size.height, 100.0000);
9713        assert_eq!(layout.location.x, 0.0000);
9714        assert_eq!(layout.location.y, 0.0000);
9715
9716        assert_eq!(layout.children[0].size.width, 60.0000);
9717        assert_eq!(layout.children[0].size.height, 40.0000);
9718        assert_eq!(layout.children[0].location.x, 25.0000);
9719        assert_eq!(layout.children[0].location.y, 50.0000);
9720    }
9721
9722    #[test]
9723    fn justify_content_min_max() {
9724        let layout = stretch::compute(
9725            &stretch::style::Node {
9726                flex_direction: stretch::style::FlexDirection::Column,
9727                justify_content: stretch::style::JustifyContent::Center,
9728                size: stretch::geometry::Size {
9729                    width: stretch::style::Dimension::Points(100.0000),
9730                    ..Default::default()
9731                },
9732                min_size: stretch::geometry::Size {
9733                    height: stretch::style::Dimension::Points(100.0000),
9734                    ..Default::default()
9735                },
9736                max_size: stretch::geometry::Size {
9737                    height: stretch::style::Dimension::Points(200.0000),
9738                    ..Default::default()
9739                },
9740                children: vec![stretch::style::Node {
9741                    size: stretch::geometry::Size {
9742                        width: stretch::style::Dimension::Points(60.0000),
9743                        height: stretch::style::Dimension::Points(60.0000),
9744                        ..Default::default()
9745                    },
9746                    ..Default::default()
9747                }],
9748                ..Default::default()
9749            },
9750            stretch::geometry::Size::undefined(),
9751        );
9752
9753        assert_eq!(layout.size.width, 100.0000);
9754        assert_eq!(layout.size.height, 100.0000);
9755        assert_eq!(layout.location.x, 0.0000);
9756        assert_eq!(layout.location.y, 0.0000);
9757
9758        assert_eq!(layout.children[0].size.width, 60.0000);
9759        assert_eq!(layout.children[0].size.height, 60.0000);
9760        assert_eq!(layout.children[0].location.x, 0.0000);
9761        assert_eq!(layout.children[0].location.y, 20.0000);
9762    }
9763
9764    #[test]
9765    fn padding_align_end_child() {
9766        let layout = stretch::compute(
9767            &stretch::style::Node {
9768                align_items: stretch::style::AlignItems::FlexEnd,
9769                justify_content: stretch::style::JustifyContent::FlexEnd,
9770                size: stretch::geometry::Size {
9771                    width: stretch::style::Dimension::Points(200.0000),
9772                    height: stretch::style::Dimension::Points(200.0000),
9773                    ..Default::default()
9774                },
9775                children: vec![stretch::style::Node {
9776                    size: stretch::geometry::Size {
9777                        width: stretch::style::Dimension::Points(100.0000),
9778                        height: stretch::style::Dimension::Points(100.0000),
9779                        ..Default::default()
9780                    },
9781                    padding: stretch::geometry::Rect {
9782                        start: stretch::style::Dimension::Points(20.0000),
9783                        end: stretch::style::Dimension::Points(20.0000),
9784                        top: stretch::style::Dimension::Points(20.0000),
9785                        bottom: stretch::style::Dimension::Points(20.0000),
9786                        ..Default::default()
9787                    },
9788                    ..Default::default()
9789                }],
9790                ..Default::default()
9791            },
9792            stretch::geometry::Size::undefined(),
9793        );
9794
9795        assert_eq!(layout.size.width, 200.0000);
9796        assert_eq!(layout.size.height, 200.0000);
9797        assert_eq!(layout.location.x, 0.0000);
9798        assert_eq!(layout.location.y, 0.0000);
9799
9800        assert_eq!(layout.children[0].size.width, 100.0000);
9801        assert_eq!(layout.children[0].size.height, 100.0000);
9802        assert_eq!(layout.children[0].location.x, 100.0000);
9803        assert_eq!(layout.children[0].location.y, 100.0000);
9804    }
9805
9806    #[test]
9807    fn justify_content_row_space_between() {
9808        let layout = stretch::compute(
9809            &stretch::style::Node {
9810                justify_content: stretch::style::JustifyContent::SpaceBetween,
9811                size: stretch::geometry::Size {
9812                    width: stretch::style::Dimension::Points(100.0000),
9813                    height: stretch::style::Dimension::Points(100.0000),
9814                    ..Default::default()
9815                },
9816                children: vec![
9817                    stretch::style::Node {
9818                        size: stretch::geometry::Size {
9819                            width: stretch::style::Dimension::Points(10.0000),
9820                            ..Default::default()
9821                        },
9822                        ..Default::default()
9823                    },
9824                    stretch::style::Node {
9825                        size: stretch::geometry::Size {
9826                            width: stretch::style::Dimension::Points(10.0000),
9827                            ..Default::default()
9828                        },
9829                        ..Default::default()
9830                    },
9831                    stretch::style::Node {
9832                        size: stretch::geometry::Size {
9833                            width: stretch::style::Dimension::Points(10.0000),
9834                            ..Default::default()
9835                        },
9836                        ..Default::default()
9837                    },
9838                ],
9839                ..Default::default()
9840            },
9841            stretch::geometry::Size::undefined(),
9842        );
9843
9844        assert_eq!(layout.size.width, 100.0000);
9845        assert_eq!(layout.size.height, 100.0000);
9846        assert_eq!(layout.location.x, 0.0000);
9847        assert_eq!(layout.location.y, 0.0000);
9848
9849        assert_eq!(layout.children[0].size.width, 10.0000);
9850        assert_eq!(layout.children[0].size.height, 100.0000);
9851        assert_eq!(layout.children[0].location.x, 0.0000);
9852        assert_eq!(layout.children[0].location.y, 0.0000);
9853
9854        assert_eq!(layout.children[1].size.width, 10.0000);
9855        assert_eq!(layout.children[1].size.height, 100.0000);
9856        assert_eq!(layout.children[1].location.x, 45.0000);
9857        assert_eq!(layout.children[1].location.y, 0.0000);
9858
9859        assert_eq!(layout.children[2].size.width, 10.0000);
9860        assert_eq!(layout.children[2].size.height, 100.0000);
9861        assert_eq!(layout.children[2].location.x, 90.0000);
9862        assert_eq!(layout.children[2].location.y, 0.0000);
9863    }
9864
9865    #[test]
9866    fn align_self_baseline() {
9867        let layout = stretch::compute(
9868            &stretch::style::Node {
9869                size: stretch::geometry::Size {
9870                    width: stretch::style::Dimension::Points(100.0000),
9871                    height: stretch::style::Dimension::Points(100.0000),
9872                    ..Default::default()
9873                },
9874                children: vec![
9875                    stretch::style::Node {
9876                        align_self: stretch::style::AlignSelf::Baseline,
9877                        size: stretch::geometry::Size {
9878                            width: stretch::style::Dimension::Points(50.0000),
9879                            height: stretch::style::Dimension::Points(50.0000),
9880                            ..Default::default()
9881                        },
9882                        ..Default::default()
9883                    },
9884                    stretch::style::Node {
9885                        align_self: stretch::style::AlignSelf::Baseline,
9886                        size: stretch::geometry::Size {
9887                            width: stretch::style::Dimension::Points(50.0000),
9888                            height: stretch::style::Dimension::Points(20.0000),
9889                            ..Default::default()
9890                        },
9891                        children: vec![stretch::style::Node {
9892                            size: stretch::geometry::Size {
9893                                width: stretch::style::Dimension::Points(50.0000),
9894                                height: stretch::style::Dimension::Points(10.0000),
9895                                ..Default::default()
9896                            },
9897                            ..Default::default()
9898                        }],
9899                        ..Default::default()
9900                    },
9901                ],
9902                ..Default::default()
9903            },
9904            stretch::geometry::Size::undefined(),
9905        );
9906
9907        assert_eq!(layout.size.width, 100.0000);
9908        assert_eq!(layout.size.height, 100.0000);
9909        assert_eq!(layout.location.x, 0.0000);
9910        assert_eq!(layout.location.y, 0.0000);
9911
9912        assert_eq!(layout.children[0].size.width, 50.0000);
9913        assert_eq!(layout.children[0].size.height, 50.0000);
9914        assert_eq!(layout.children[0].location.x, 0.0000);
9915        assert_eq!(layout.children[0].location.y, 0.0000);
9916
9917        assert_eq!(layout.children[1].size.width, 50.0000);
9918        assert_eq!(layout.children[1].size.height, 20.0000);
9919        assert_eq!(layout.children[1].location.x, 50.0000);
9920        assert_eq!(layout.children[1].location.y, 40.0000);
9921
9922        assert_eq!(layout.children[1].children[0].size.width, 50.0000);
9923        assert_eq!(layout.children[1].children[0].size.height, 10.0000);
9924        assert_eq!(layout.children[1].children[0].location.x, 0.0000);
9925        assert_eq!(layout.children[1].children[0].location.y, 0.0000);
9926    }
9927
9928    #[test]
9929    fn rounding_fractial_input_1() {
9930        let layout = stretch::compute(
9931            &stretch::style::Node {
9932                flex_direction: stretch::style::FlexDirection::Column,
9933                size: stretch::geometry::Size {
9934                    width: stretch::style::Dimension::Points(100.0000),
9935                    height: stretch::style::Dimension::Points(113.4000),
9936                    ..Default::default()
9937                },
9938                children: vec![
9939                    stretch::style::Node {
9940                        flex_grow: 1.0000,
9941                        flex_basis: stretch::style::Dimension::Points(50.0000),
9942                        size: stretch::geometry::Size {
9943                            height: stretch::style::Dimension::Points(20.0000),
9944                            ..Default::default()
9945                        },
9946                        ..Default::default()
9947                    },
9948                    stretch::style::Node {
9949                        flex_grow: 1.0000,
9950                        size: stretch::geometry::Size {
9951                            height: stretch::style::Dimension::Points(10.0000),
9952                            ..Default::default()
9953                        },
9954                        ..Default::default()
9955                    },
9956                    stretch::style::Node {
9957                        flex_grow: 1.0000,
9958                        size: stretch::geometry::Size {
9959                            height: stretch::style::Dimension::Points(10.0000),
9960                            ..Default::default()
9961                        },
9962                        ..Default::default()
9963                    },
9964                ],
9965                ..Default::default()
9966            },
9967            stretch::geometry::Size::undefined(),
9968        );
9969
9970        assert_eq!(layout.size.width, 100.0000);
9971        assert_eq!(layout.size.height, 113.0000);
9972        assert_eq!(layout.location.x, 0.0000);
9973        assert_eq!(layout.location.y, 0.0000);
9974
9975        assert_eq!(layout.children[0].size.width, 100.0000);
9976        assert_eq!(layout.children[0].size.height, 64.0000);
9977        assert_eq!(layout.children[0].location.x, 0.0000);
9978        assert_eq!(layout.children[0].location.y, 0.0000);
9979
9980        assert_eq!(layout.children[1].size.width, 100.0000);
9981        assert_eq!(layout.children[1].size.height, 25.0000);
9982        assert_eq!(layout.children[1].location.x, 0.0000);
9983        assert_eq!(layout.children[1].location.y, 64.0000);
9984
9985        assert_eq!(layout.children[2].size.width, 100.0000);
9986        assert_eq!(layout.children[2].size.height, 24.0000);
9987        assert_eq!(layout.children[2].location.x, 0.0000);
9988        assert_eq!(layout.children[2].location.y, 89.0000);
9989    }
9990
9991    #[test]
9992    fn absolute_layout_align_items_center() {
9993        let layout = stretch::compute(
9994            &stretch::style::Node {
9995                align_items: stretch::style::AlignItems::Center,
9996                size: stretch::geometry::Size {
9997                    width: stretch::style::Dimension::Points(110.0000),
9998                    height: stretch::style::Dimension::Points(100.0000),
9999                    ..Default::default()
10000                },
10001                children: vec![stretch::style::Node {
10002                    position_type: stretch::style::PositionType::Absolute,
10003                    size: stretch::geometry::Size {
10004                        width: stretch::style::Dimension::Points(60.0000),
10005                        height: stretch::style::Dimension::Points(40.0000),
10006                        ..Default::default()
10007                    },
10008                    ..Default::default()
10009                }],
10010                ..Default::default()
10011            },
10012            stretch::geometry::Size::undefined(),
10013        );
10014
10015        assert_eq!(layout.size.width, 110.0000);
10016        assert_eq!(layout.size.height, 100.0000);
10017        assert_eq!(layout.location.x, 0.0000);
10018        assert_eq!(layout.location.y, 0.0000);
10019
10020        assert_eq!(layout.children[0].size.width, 60.0000);
10021        assert_eq!(layout.children[0].size.height, 40.0000);
10022        assert_eq!(layout.children[0].location.x, 0.0000);
10023        assert_eq!(layout.children[0].location.y, 30.0000);
10024    }
10025
10026    #[test]
10027    fn flex_basis_slightly_smaller_then_content_with_flex_grow_large_size() {
10028        let layout = stretch::compute(
10029            &stretch::style::Node {
10030                size: stretch::geometry::Size {
10031                    width: stretch::style::Dimension::Points(100.0000),
10032                    ..Default::default()
10033                },
10034                children: vec![
10035                    stretch::style::Node {
10036                        flex_direction: stretch::style::FlexDirection::Column,
10037                        flex_grow: 1.0000,
10038                        flex_basis: stretch::style::Dimension::Points(60.0000),
10039                        children: vec![stretch::style::Node {
10040                            size: stretch::geometry::Size {
10041                                width: stretch::style::Dimension::Points(70.0000),
10042                                height: stretch::style::Dimension::Points(100.0000),
10043                                ..Default::default()
10044                            },
10045                            ..Default::default()
10046                        }],
10047                        ..Default::default()
10048                    },
10049                    stretch::style::Node {
10050                        flex_direction: stretch::style::FlexDirection::Column,
10051                        flex_grow: 1.0000,
10052                        flex_basis: stretch::style::Dimension::Points(0.0000),
10053                        children: vec![stretch::style::Node {
10054                            size: stretch::geometry::Size {
10055                                width: stretch::style::Dimension::Points(20.0000),
10056                                height: stretch::style::Dimension::Points(100.0000),
10057                                ..Default::default()
10058                            },
10059                            ..Default::default()
10060                        }],
10061                        ..Default::default()
10062                    },
10063                ],
10064                ..Default::default()
10065            },
10066            stretch::geometry::Size::undefined(),
10067        );
10068
10069        assert_eq!(layout.size.width, 100.0000);
10070        assert_eq!(layout.size.height, 100.0000);
10071        assert_eq!(layout.location.x, 0.0000);
10072        assert_eq!(layout.location.y, 0.0000);
10073
10074        assert_eq!(layout.children[0].size.width, 80.0000);
10075        assert_eq!(layout.children[0].size.height, 100.0000);
10076        assert_eq!(layout.children[0].location.x, 0.0000);
10077        assert_eq!(layout.children[0].location.y, 0.0000);
10078
10079        assert_eq!(layout.children[0].children[0].size.width, 70.0000);
10080        assert_eq!(layout.children[0].children[0].size.height, 100.0000);
10081        assert_eq!(layout.children[0].children[0].location.x, 0.0000);
10082        assert_eq!(layout.children[0].children[0].location.y, 0.0000);
10083
10084        assert_eq!(layout.children[1].size.width, 20.0000);
10085        assert_eq!(layout.children[1].size.height, 100.0000);
10086        assert_eq!(layout.children[1].location.x, 80.0000);
10087        assert_eq!(layout.children[1].location.y, 0.0000);
10088
10089        assert_eq!(layout.children[1].children[0].size.width, 20.0000);
10090        assert_eq!(layout.children[1].children[0].size.height, 100.0000);
10091        assert_eq!(layout.children[1].children[0].location.x, 0.0000);
10092        assert_eq!(layout.children[1].children[0].location.y, 0.0000);
10093    }
10094
10095    #[test]
10096    fn percentage_flex_basis_cross_min_width() {
10097        let layout = stretch::compute(
10098            &stretch::style::Node {
10099                flex_direction: stretch::style::FlexDirection::Column,
10100                size: stretch::geometry::Size {
10101                    width: stretch::style::Dimension::Points(200.0000),
10102                    height: stretch::style::Dimension::Points(400.0000),
10103                    ..Default::default()
10104                },
10105                children: vec![
10106                    stretch::style::Node {
10107                        flex_grow: 1.0000,
10108                        flex_basis: stretch::style::Dimension::Percent(0.1000),
10109                        min_size: stretch::geometry::Size {
10110                            width: stretch::style::Dimension::Percent(0.6000),
10111                            ..Default::default()
10112                        },
10113                        ..Default::default()
10114                    },
10115                    stretch::style::Node {
10116                        flex_grow: 4.0000,
10117                        flex_basis: stretch::style::Dimension::Percent(0.1500),
10118                        min_size: stretch::geometry::Size {
10119                            width: stretch::style::Dimension::Percent(0.2000),
10120                            ..Default::default()
10121                        },
10122                        ..Default::default()
10123                    },
10124                ],
10125                ..Default::default()
10126            },
10127            stretch::geometry::Size::undefined(),
10128        );
10129
10130        assert_eq!(layout.size.width, 200.0000);
10131        assert_eq!(layout.size.height, 400.0000);
10132        assert_eq!(layout.location.x, 0.0000);
10133        assert_eq!(layout.location.y, 0.0000);
10134
10135        assert_eq!(layout.children[0].size.width, 200.0000);
10136        assert_eq!(layout.children[0].size.height, 100.0000);
10137        assert_eq!(layout.children[0].location.x, 0.0000);
10138        assert_eq!(layout.children[0].location.y, 0.0000);
10139
10140        assert_eq!(layout.children[1].size.width, 200.0000);
10141        assert_eq!(layout.children[1].size.height, 300.0000);
10142        assert_eq!(layout.children[1].location.x, 0.0000);
10143        assert_eq!(layout.children[1].location.y, 100.0000);
10144    }
10145
10146    #[test]
10147    fn margin_auto_left_and_right_column_and_center() {
10148        let layout = stretch::compute(
10149            &stretch::style::Node {
10150                align_items: stretch::style::AlignItems::Center,
10151                size: stretch::geometry::Size {
10152                    width: stretch::style::Dimension::Points(200.0000),
10153                    height: stretch::style::Dimension::Points(200.0000),
10154                    ..Default::default()
10155                },
10156                children: vec![
10157                    stretch::style::Node {
10158                        size: stretch::geometry::Size {
10159                            width: stretch::style::Dimension::Points(50.0000),
10160                            height: stretch::style::Dimension::Points(50.0000),
10161                            ..Default::default()
10162                        },
10163                        margin: stretch::geometry::Rect {
10164                            start: stretch::style::Dimension::Auto,
10165                            end: stretch::style::Dimension::Auto,
10166                            ..Default::default()
10167                        },
10168                        ..Default::default()
10169                    },
10170                    stretch::style::Node {
10171                        size: stretch::geometry::Size {
10172                            width: stretch::style::Dimension::Points(50.0000),
10173                            height: stretch::style::Dimension::Points(50.0000),
10174                            ..Default::default()
10175                        },
10176                        ..Default::default()
10177                    },
10178                ],
10179                ..Default::default()
10180            },
10181            stretch::geometry::Size::undefined(),
10182        );
10183
10184        assert_eq!(layout.size.width, 200.0000);
10185        assert_eq!(layout.size.height, 200.0000);
10186        assert_eq!(layout.location.x, 0.0000);
10187        assert_eq!(layout.location.y, 0.0000);
10188
10189        assert_eq!(layout.children[0].size.width, 50.0000);
10190        assert_eq!(layout.children[0].size.height, 50.0000);
10191        assert_eq!(layout.children[0].location.x, 50.0000);
10192        assert_eq!(layout.children[0].location.y, 75.0000);
10193
10194        assert_eq!(layout.children[1].size.width, 50.0000);
10195        assert_eq!(layout.children[1].size.height, 50.0000);
10196        assert_eq!(layout.children[1].location.x, 150.0000);
10197        assert_eq!(layout.children[1].location.y, 75.0000);
10198    }
10199
10200    #[test]
10201    fn flex_grow_less_than_factor_one() {
10202        let layout = stretch::compute(
10203            &stretch::style::Node {
10204                size: stretch::geometry::Size {
10205                    width: stretch::style::Dimension::Points(500.0000),
10206                    height: stretch::style::Dimension::Points(200.0000),
10207                    ..Default::default()
10208                },
10209                children: vec![
10210                    stretch::style::Node {
10211                        flex_grow: 0.2000,
10212                        flex_shrink: 0.0000,
10213                        flex_basis: stretch::style::Dimension::Points(40.0000),
10214                        ..Default::default()
10215                    },
10216                    stretch::style::Node { flex_grow: 0.2000, flex_shrink: 0.0000, ..Default::default() },
10217                    stretch::style::Node { flex_grow: 0.4000, flex_shrink: 0.0000, ..Default::default() },
10218                ],
10219                ..Default::default()
10220            },
10221            stretch::geometry::Size::undefined(),
10222        );
10223
10224        assert_eq!(layout.size.width, 500.0000);
10225        assert_eq!(layout.size.height, 200.0000);
10226        assert_eq!(layout.location.x, 0.0000);
10227        assert_eq!(layout.location.y, 0.0000);
10228
10229        assert_eq!(layout.children[0].size.width, 132.0000);
10230        assert_eq!(layout.children[0].size.height, 200.0000);
10231        assert_eq!(layout.children[0].location.x, 0.0000);
10232        assert_eq!(layout.children[0].location.y, 0.0000);
10233
10234        assert_eq!(layout.children[1].size.width, 92.0000);
10235        assert_eq!(layout.children[1].size.height, 200.0000);
10236        assert_eq!(layout.children[1].location.x, 132.0000);
10237        assert_eq!(layout.children[1].location.y, 0.0000);
10238
10239        assert_eq!(layout.children[2].size.width, 184.0000);
10240        assert_eq!(layout.children[2].size.height, 200.0000);
10241        assert_eq!(layout.children[2].location.x, 224.0000);
10242        assert_eq!(layout.children[2].location.y, 0.0000);
10243    }
10244
10245    #[test]
10246    fn flex_grow_within_constrained_min_max_column() {
10247        let layout = stretch::compute(
10248            &stretch::style::Node {
10249                min_size: stretch::geometry::Size {
10250                    height: stretch::style::Dimension::Points(100.0000),
10251                    ..Default::default()
10252                },
10253                children: vec![
10254                    stretch::style::Node { flex_grow: 1.0000, ..Default::default() },
10255                    stretch::style::Node {
10256                        size: stretch::geometry::Size {
10257                            height: stretch::style::Dimension::Points(50.0000),
10258                            ..Default::default()
10259                        },
10260                        ..Default::default()
10261                    },
10262                ],
10263                ..Default::default()
10264            },
10265            stretch::geometry::Size::undefined(),
10266        );
10267
10268        assert_eq!(layout.size.width, 0.0000);
10269        assert_eq!(layout.size.height, 100.0000);
10270        assert_eq!(layout.location.x, 0.0000);
10271        assert_eq!(layout.location.y, 0.0000);
10272
10273        assert_eq!(layout.children[0].size.width, 0.0000);
10274        assert_eq!(layout.children[0].size.height, 100.0000);
10275        assert_eq!(layout.children[0].location.x, 0.0000);
10276        assert_eq!(layout.children[0].location.y, 0.0000);
10277
10278        assert_eq!(layout.children[1].size.width, 0.0000);
10279        assert_eq!(layout.children[1].size.height, 50.0000);
10280        assert_eq!(layout.children[1].location.x, 0.0000);
10281        assert_eq!(layout.children[1].location.y, 0.0000);
10282    }
10283
10284    #[test]
10285    fn percentage_flex_basis_cross_max_height() {
10286        let layout = stretch::compute(
10287            &stretch::style::Node {
10288                flex_direction: stretch::style::FlexDirection::Column,
10289                size: stretch::geometry::Size {
10290                    width: stretch::style::Dimension::Points(200.0000),
10291                    height: stretch::style::Dimension::Points(400.0000),
10292                    ..Default::default()
10293                },
10294                children: vec![
10295                    stretch::style::Node {
10296                        flex_grow: 1.0000,
10297                        flex_basis: stretch::style::Dimension::Percent(0.1000),
10298                        max_size: stretch::geometry::Size {
10299                            height: stretch::style::Dimension::Percent(0.6000),
10300                            ..Default::default()
10301                        },
10302                        ..Default::default()
10303                    },
10304                    stretch::style::Node {
10305                        flex_grow: 4.0000,
10306                        flex_basis: stretch::style::Dimension::Percent(0.1000),
10307                        max_size: stretch::geometry::Size {
10308                            height: stretch::style::Dimension::Percent(0.2000),
10309                            ..Default::default()
10310                        },
10311                        ..Default::default()
10312                    },
10313                ],
10314                ..Default::default()
10315            },
10316            stretch::geometry::Size::undefined(),
10317        );
10318
10319        assert_eq!(layout.size.width, 200.0000);
10320        assert_eq!(layout.size.height, 400.0000);
10321        assert_eq!(layout.location.x, 0.0000);
10322        assert_eq!(layout.location.y, 0.0000);
10323
10324        assert_eq!(layout.children[0].size.width, 200.0000);
10325        assert_eq!(layout.children[0].size.height, 240.0000);
10326        assert_eq!(layout.children[0].location.x, 0.0000);
10327        assert_eq!(layout.children[0].location.y, 0.0000);
10328
10329        assert_eq!(layout.children[1].size.width, 200.0000);
10330        assert_eq!(layout.children[1].size.height, 80.0000);
10331        assert_eq!(layout.children[1].location.x, 0.0000);
10332        assert_eq!(layout.children[1].location.y, 240.0000);
10333    }
10334
10335    #[test]
10336    fn justify_content_column_flex_end() {
10337        let layout = stretch::compute(
10338            &stretch::style::Node {
10339                flex_direction: stretch::style::FlexDirection::Column,
10340                justify_content: stretch::style::JustifyContent::FlexEnd,
10341                size: stretch::geometry::Size {
10342                    width: stretch::style::Dimension::Points(100.0000),
10343                    height: stretch::style::Dimension::Points(100.0000),
10344                    ..Default::default()
10345                },
10346                children: vec![
10347                    stretch::style::Node {
10348                        size: stretch::geometry::Size {
10349                            height: stretch::style::Dimension::Points(10.0000),
10350                            ..Default::default()
10351                        },
10352                        ..Default::default()
10353                    },
10354                    stretch::style::Node {
10355                        size: stretch::geometry::Size {
10356                            height: stretch::style::Dimension::Points(10.0000),
10357                            ..Default::default()
10358                        },
10359                        ..Default::default()
10360                    },
10361                    stretch::style::Node {
10362                        size: stretch::geometry::Size {
10363                            height: stretch::style::Dimension::Points(10.0000),
10364                            ..Default::default()
10365                        },
10366                        ..Default::default()
10367                    },
10368                ],
10369                ..Default::default()
10370            },
10371            stretch::geometry::Size::undefined(),
10372        );
10373
10374        assert_eq!(layout.size.width, 100.0000);
10375        assert_eq!(layout.size.height, 100.0000);
10376        assert_eq!(layout.location.x, 0.0000);
10377        assert_eq!(layout.location.y, 0.0000);
10378
10379        assert_eq!(layout.children[0].size.width, 100.0000);
10380        assert_eq!(layout.children[0].size.height, 10.0000);
10381        assert_eq!(layout.children[0].location.x, 0.0000);
10382        assert_eq!(layout.children[0].location.y, 70.0000);
10383
10384        assert_eq!(layout.children[1].size.width, 100.0000);
10385        assert_eq!(layout.children[1].size.height, 10.0000);
10386        assert_eq!(layout.children[1].location.x, 0.0000);
10387        assert_eq!(layout.children[1].location.y, 80.0000);
10388
10389        assert_eq!(layout.children[2].size.width, 100.0000);
10390        assert_eq!(layout.children[2].size.height, 10.0000);
10391        assert_eq!(layout.children[2].location.x, 0.0000);
10392        assert_eq!(layout.children[2].location.y, 90.0000);
10393    }
10394
10395    #[test]
10396    fn rounding_flex_basis_flex_grow_row_width_of_100() {
10397        let layout = stretch::compute(
10398            &stretch::style::Node {
10399                size: stretch::geometry::Size {
10400                    width: stretch::style::Dimension::Points(100.0000),
10401                    height: stretch::style::Dimension::Points(100.0000),
10402                    ..Default::default()
10403                },
10404                children: vec![
10405                    stretch::style::Node { flex_grow: 1.0000, ..Default::default() },
10406                    stretch::style::Node { flex_grow: 1.0000, ..Default::default() },
10407                    stretch::style::Node { flex_grow: 1.0000, ..Default::default() },
10408                ],
10409                ..Default::default()
10410            },
10411            stretch::geometry::Size::undefined(),
10412        );
10413
10414        assert_eq!(layout.size.width, 100.0000);
10415        assert_eq!(layout.size.height, 100.0000);
10416        assert_eq!(layout.location.x, 0.0000);
10417        assert_eq!(layout.location.y, 0.0000);
10418
10419        assert_eq!(layout.children[0].size.width, 33.0000);
10420        assert_eq!(layout.children[0].size.height, 100.0000);
10421        assert_eq!(layout.children[0].location.x, 0.0000);
10422        assert_eq!(layout.children[0].location.y, 0.0000);
10423
10424        assert_eq!(layout.children[1].size.width, 34.0000);
10425        assert_eq!(layout.children[1].size.height, 100.0000);
10426        assert_eq!(layout.children[1].location.x, 33.0000);
10427        assert_eq!(layout.children[1].location.y, 0.0000);
10428
10429        assert_eq!(layout.children[2].size.width, 33.0000);
10430        assert_eq!(layout.children[2].size.height, 100.0000);
10431        assert_eq!(layout.children[2].location.x, 67.0000);
10432        assert_eq!(layout.children[2].location.y, 0.0000);
10433    }
10434
10435    #[test]
10436    fn display_none_fixed_size() {
10437        let layout = stretch::compute(
10438            &stretch::style::Node {
10439                size: stretch::geometry::Size {
10440                    width: stretch::style::Dimension::Points(100.0000),
10441                    height: stretch::style::Dimension::Points(100.0000),
10442                    ..Default::default()
10443                },
10444                children: vec![
10445                    stretch::style::Node { flex_grow: 1.0000, ..Default::default() },
10446                    stretch::style::Node {
10447                        display: stretch::style::Display::None,
10448                        size: stretch::geometry::Size {
10449                            width: stretch::style::Dimension::Points(20.0000),
10450                            height: stretch::style::Dimension::Points(20.0000),
10451                            ..Default::default()
10452                        },
10453                        ..Default::default()
10454                    },
10455                ],
10456                ..Default::default()
10457            },
10458            stretch::geometry::Size::undefined(),
10459        );
10460
10461        assert_eq!(layout.size.width, 100.0000);
10462        assert_eq!(layout.size.height, 100.0000);
10463        assert_eq!(layout.location.x, 0.0000);
10464        assert_eq!(layout.location.y, 0.0000);
10465
10466        assert_eq!(layout.children[0].size.width, 100.0000);
10467        assert_eq!(layout.children[0].size.height, 100.0000);
10468        assert_eq!(layout.children[0].location.x, 0.0000);
10469        assert_eq!(layout.children[0].location.y, 0.0000);
10470
10471        assert_eq!(layout.children[1].size.width, 0.0000);
10472        assert_eq!(layout.children[1].size.height, 0.0000);
10473        assert_eq!(layout.children[1].location.x, 0.0000);
10474        assert_eq!(layout.children[1].location.y, 0.0000);
10475    }
10476
10477    #[test]
10478    fn wrap_reverse_row_align_content_flex_start() {
10479        let layout = stretch::compute(
10480            &stretch::style::Node {
10481                flex_wrap: stretch::style::FlexWrap::WrapReverse,
10482                align_content: stretch::style::AlignContent::FlexStart,
10483                size: stretch::geometry::Size {
10484                    width: stretch::style::Dimension::Points(100.0000),
10485                    ..Default::default()
10486                },
10487                children: vec![
10488                    stretch::style::Node {
10489                        size: stretch::geometry::Size {
10490                            width: stretch::style::Dimension::Points(30.0000),
10491                            height: stretch::style::Dimension::Points(10.0000),
10492                            ..Default::default()
10493                        },
10494                        ..Default::default()
10495                    },
10496                    stretch::style::Node {
10497                        size: stretch::geometry::Size {
10498                            width: stretch::style::Dimension::Points(30.0000),
10499                            height: stretch::style::Dimension::Points(20.0000),
10500                            ..Default::default()
10501                        },
10502                        ..Default::default()
10503                    },
10504                    stretch::style::Node {
10505                        size: stretch::geometry::Size {
10506                            width: stretch::style::Dimension::Points(30.0000),
10507                            height: stretch::style::Dimension::Points(30.0000),
10508                            ..Default::default()
10509                        },
10510                        ..Default::default()
10511                    },
10512                    stretch::style::Node {
10513                        size: stretch::geometry::Size {
10514                            width: stretch::style::Dimension::Points(30.0000),
10515                            height: stretch::style::Dimension::Points(40.0000),
10516                            ..Default::default()
10517                        },
10518                        ..Default::default()
10519                    },
10520                    stretch::style::Node {
10521                        size: stretch::geometry::Size {
10522                            width: stretch::style::Dimension::Points(30.0000),
10523                            height: stretch::style::Dimension::Points(50.0000),
10524                            ..Default::default()
10525                        },
10526                        ..Default::default()
10527                    },
10528                ],
10529                ..Default::default()
10530            },
10531            stretch::geometry::Size::undefined(),
10532        );
10533
10534        assert_eq!(layout.size.width, 100.0000);
10535        assert_eq!(layout.size.height, 80.0000);
10536        assert_eq!(layout.location.x, 0.0000);
10537        assert_eq!(layout.location.y, 0.0000);
10538
10539        assert_eq!(layout.children[0].size.width, 30.0000);
10540        assert_eq!(layout.children[0].size.height, 10.0000);
10541        assert_eq!(layout.children[0].location.x, 0.0000);
10542        assert_eq!(layout.children[0].location.y, 70.0000);
10543
10544        assert_eq!(layout.children[1].size.width, 30.0000);
10545        assert_eq!(layout.children[1].size.height, 20.0000);
10546        assert_eq!(layout.children[1].location.x, 30.0000);
10547        assert_eq!(layout.children[1].location.y, 60.0000);
10548
10549        assert_eq!(layout.children[2].size.width, 30.0000);
10550        assert_eq!(layout.children[2].size.height, 30.0000);
10551        assert_eq!(layout.children[2].location.x, 60.0000);
10552        assert_eq!(layout.children[2].location.y, 50.0000);
10553
10554        assert_eq!(layout.children[3].size.width, 30.0000);
10555        assert_eq!(layout.children[3].size.height, 40.0000);
10556        assert_eq!(layout.children[3].location.x, 0.0000);
10557        assert_eq!(layout.children[3].location.y, 10.0000);
10558
10559        assert_eq!(layout.children[4].size.width, 30.0000);
10560        assert_eq!(layout.children[4].size.height, 50.0000);
10561        assert_eq!(layout.children[4].location.x, 30.0000);
10562        assert_eq!(layout.children[4].location.y, 0.0000);
10563    }
10564
10565    #[test]
10566    fn flex_shrink_flex_grow_child_flex_shrink_other_child() {
10567        let layout = stretch::compute(
10568            &stretch::style::Node {
10569                size: stretch::geometry::Size {
10570                    width: stretch::style::Dimension::Points(500.0000),
10571                    height: stretch::style::Dimension::Points(500.0000),
10572                    ..Default::default()
10573                },
10574                children: vec![
10575                    stretch::style::Node {
10576                        flex_grow: 0.0000,
10577                        flex_shrink: 1.0000,
10578                        size: stretch::geometry::Size {
10579                            width: stretch::style::Dimension::Points(500.0000),
10580                            height: stretch::style::Dimension::Points(100.0000),
10581                            ..Default::default()
10582                        },
10583                        ..Default::default()
10584                    },
10585                    stretch::style::Node {
10586                        flex_grow: 1.0000,
10587                        flex_shrink: 1.0000,
10588                        size: stretch::geometry::Size {
10589                            width: stretch::style::Dimension::Points(500.0000),
10590                            height: stretch::style::Dimension::Points(100.0000),
10591                            ..Default::default()
10592                        },
10593                        ..Default::default()
10594                    },
10595                ],
10596                ..Default::default()
10597            },
10598            stretch::geometry::Size::undefined(),
10599        );
10600
10601        assert_eq!(layout.size.width, 500.0000);
10602        assert_eq!(layout.size.height, 500.0000);
10603        assert_eq!(layout.location.x, 0.0000);
10604        assert_eq!(layout.location.y, 0.0000);
10605
10606        assert_eq!(layout.children[0].size.width, 250.0000);
10607        assert_eq!(layout.children[0].size.height, 100.0000);
10608        assert_eq!(layout.children[0].location.x, 0.0000);
10609        assert_eq!(layout.children[0].location.y, 0.0000);
10610
10611        assert_eq!(layout.children[1].size.width, 250.0000);
10612        assert_eq!(layout.children[1].size.height, 100.0000);
10613        assert_eq!(layout.children[1].location.x, 250.0000);
10614        assert_eq!(layout.children[1].location.y, 0.0000);
10615    }
10616
10617    #[test]
10618    fn flex_basis_unconstraint_row() {
10619        let layout = stretch::compute(
10620            &stretch::style::Node {
10621                children: vec![stretch::style::Node {
10622                    flex_basis: stretch::style::Dimension::Points(50.0000),
10623                    size: stretch::geometry::Size {
10624                        height: stretch::style::Dimension::Points(100.0000),
10625                        ..Default::default()
10626                    },
10627                    ..Default::default()
10628                }],
10629                ..Default::default()
10630            },
10631            stretch::geometry::Size::undefined(),
10632        );
10633
10634        assert_eq!(layout.size.width, 0.0000);
10635        assert_eq!(layout.size.height, 100.0000);
10636        assert_eq!(layout.location.x, 0.0000);
10637        assert_eq!(layout.location.y, 0.0000);
10638
10639        assert_eq!(layout.children[0].size.width, 0.0000);
10640        assert_eq!(layout.children[0].size.height, 100.0000);
10641        assert_eq!(layout.children[0].location.x, 0.0000);
10642        assert_eq!(layout.children[0].location.y, 0.0000);
10643    }
10644
10645    #[test]
10646    fn align_items_flex_end() {
10647        let layout = stretch::compute(
10648            &stretch::style::Node {
10649                align_items: stretch::style::AlignItems::FlexEnd,
10650                size: stretch::geometry::Size {
10651                    width: stretch::style::Dimension::Points(100.0000),
10652                    height: stretch::style::Dimension::Points(100.0000),
10653                    ..Default::default()
10654                },
10655                children: vec![stretch::style::Node {
10656                    size: stretch::geometry::Size {
10657                        width: stretch::style::Dimension::Points(10.0000),
10658                        height: stretch::style::Dimension::Points(10.0000),
10659                        ..Default::default()
10660                    },
10661                    ..Default::default()
10662                }],
10663                ..Default::default()
10664            },
10665            stretch::geometry::Size::undefined(),
10666        );
10667
10668        assert_eq!(layout.size.width, 100.0000);
10669        assert_eq!(layout.size.height, 100.0000);
10670        assert_eq!(layout.location.x, 0.0000);
10671        assert_eq!(layout.location.y, 0.0000);
10672
10673        assert_eq!(layout.children[0].size.width, 10.0000);
10674        assert_eq!(layout.children[0].size.height, 10.0000);
10675        assert_eq!(layout.children[0].location.x, 0.0000);
10676        assert_eq!(layout.children[0].location.y, 90.0000);
10677    }
10678
10679    #[test]
10680    fn absolute_layout_width_height_start_top() {
10681        let layout = stretch::compute(
10682            &stretch::style::Node {
10683                size: stretch::geometry::Size {
10684                    width: stretch::style::Dimension::Points(100.0000),
10685                    height: stretch::style::Dimension::Points(100.0000),
10686                    ..Default::default()
10687                },
10688                children: vec![stretch::style::Node {
10689                    position_type: stretch::style::PositionType::Absolute,
10690                    size: stretch::geometry::Size {
10691                        width: stretch::style::Dimension::Points(10.0000),
10692                        height: stretch::style::Dimension::Points(10.0000),
10693                        ..Default::default()
10694                    },
10695                    position: stretch::geometry::Rect {
10696                        start: stretch::style::Dimension::Points(10.0000),
10697                        top: stretch::style::Dimension::Points(10.0000),
10698                        ..Default::default()
10699                    },
10700                    ..Default::default()
10701                }],
10702                ..Default::default()
10703            },
10704            stretch::geometry::Size::undefined(),
10705        );
10706
10707        assert_eq!(layout.size.width, 100.0000);
10708        assert_eq!(layout.size.height, 100.0000);
10709        assert_eq!(layout.location.x, 0.0000);
10710        assert_eq!(layout.location.y, 0.0000);
10711
10712        assert_eq!(layout.children[0].size.width, 10.0000);
10713        assert_eq!(layout.children[0].size.height, 10.0000);
10714        assert_eq!(layout.children[0].location.x, 10.0000);
10715        assert_eq!(layout.children[0].location.y, 10.0000);
10716    }
10717
10718    #[test]
10719    fn rounding_flex_basis_flex_shrink_row() {
10720        let layout = stretch::compute(
10721            &stretch::style::Node {
10722                size: stretch::geometry::Size {
10723                    width: stretch::style::Dimension::Points(101.0000),
10724                    height: stretch::style::Dimension::Points(100.0000),
10725                    ..Default::default()
10726                },
10727                children: vec![
10728                    stretch::style::Node {
10729                        flex_shrink: 1.0000,
10730                        flex_basis: stretch::style::Dimension::Points(100.0000),
10731                        ..Default::default()
10732                    },
10733                    stretch::style::Node {
10734                        flex_basis: stretch::style::Dimension::Points(25.0000),
10735                        ..Default::default()
10736                    },
10737                    stretch::style::Node {
10738                        flex_basis: stretch::style::Dimension::Points(25.0000),
10739                        ..Default::default()
10740                    },
10741                ],
10742                ..Default::default()
10743            },
10744            stretch::geometry::Size::undefined(),
10745        );
10746
10747        assert_eq!(layout.size.width, 101.0000);
10748        assert_eq!(layout.size.height, 100.0000);
10749        assert_eq!(layout.location.x, 0.0000);
10750        assert_eq!(layout.location.y, 0.0000);
10751
10752        assert_eq!(layout.children[0].size.width, 67.0000);
10753        assert_eq!(layout.children[0].size.height, 100.0000);
10754        assert_eq!(layout.children[0].location.x, 0.0000);
10755        assert_eq!(layout.children[0].location.y, 0.0000);
10756
10757        assert_eq!(layout.children[1].size.width, 17.0000);
10758        assert_eq!(layout.children[1].size.height, 100.0000);
10759        assert_eq!(layout.children[1].location.x, 67.0000);
10760        assert_eq!(layout.children[1].location.y, 0.0000);
10761
10762        assert_eq!(layout.children[2].size.width, 17.0000);
10763        assert_eq!(layout.children[2].size.height, 100.0000);
10764        assert_eq!(layout.children[2].location.x, 84.0000);
10765        assert_eq!(layout.children[2].location.y, 0.0000);
10766    }
10767
10768    #[test]
10769    fn border_center_child() {
10770        let layout = stretch::compute(
10771            &stretch::style::Node {
10772                align_items: stretch::style::AlignItems::Center,
10773                justify_content: stretch::style::JustifyContent::Center,
10774                size: stretch::geometry::Size {
10775                    width: stretch::style::Dimension::Points(100.0000),
10776                    height: stretch::style::Dimension::Points(100.0000),
10777                    ..Default::default()
10778                },
10779                border: stretch::geometry::Rect {
10780                    top: stretch::style::Dimension::Points(10.0000),
10781                    bottom: stretch::style::Dimension::Points(20.0000),
10782                    ..Default::default()
10783                },
10784                children: vec![stretch::style::Node {
10785                    size: stretch::geometry::Size {
10786                        width: stretch::style::Dimension::Points(10.0000),
10787                        height: stretch::style::Dimension::Points(10.0000),
10788                        ..Default::default()
10789                    },
10790                    ..Default::default()
10791                }],
10792                ..Default::default()
10793            },
10794            stretch::geometry::Size::undefined(),
10795        );
10796
10797        assert_eq!(layout.size.width, 100.0000);
10798        assert_eq!(layout.size.height, 100.0000);
10799        assert_eq!(layout.location.x, 0.0000);
10800        assert_eq!(layout.location.y, 0.0000);
10801
10802        assert_eq!(layout.children[0].size.width, 10.0000);
10803        assert_eq!(layout.children[0].size.height, 10.0000);
10804        assert_eq!(layout.children[0].location.x, 45.0000);
10805        assert_eq!(layout.children[0].location.y, 40.0000);
10806    }
10807
10808    #[test]
10809    fn align_items_flex_start() {
10810        let layout = stretch::compute(
10811            &stretch::style::Node {
10812                align_items: stretch::style::AlignItems::FlexStart,
10813                size: stretch::geometry::Size {
10814                    width: stretch::style::Dimension::Points(100.0000),
10815                    height: stretch::style::Dimension::Points(100.0000),
10816                    ..Default::default()
10817                },
10818                children: vec![stretch::style::Node {
10819                    size: stretch::geometry::Size {
10820                        width: stretch::style::Dimension::Points(10.0000),
10821                        height: stretch::style::Dimension::Points(10.0000),
10822                        ..Default::default()
10823                    },
10824                    ..Default::default()
10825                }],
10826                ..Default::default()
10827            },
10828            stretch::geometry::Size::undefined(),
10829        );
10830
10831        assert_eq!(layout.size.width, 100.0000);
10832        assert_eq!(layout.size.height, 100.0000);
10833        assert_eq!(layout.location.x, 0.0000);
10834        assert_eq!(layout.location.y, 0.0000);
10835
10836        assert_eq!(layout.children[0].size.width, 10.0000);
10837        assert_eq!(layout.children[0].size.height, 10.0000);
10838        assert_eq!(layout.children[0].location.x, 0.0000);
10839        assert_eq!(layout.children[0].location.y, 0.0000);
10840    }
10841
10842    #[test]
10843    fn border_no_child() {
10844        let layout = stretch::compute(
10845            &stretch::style::Node {
10846                border: stretch::geometry::Rect {
10847                    start: stretch::style::Dimension::Points(10.0000),
10848                    end: stretch::style::Dimension::Points(10.0000),
10849                    top: stretch::style::Dimension::Points(10.0000),
10850                    bottom: stretch::style::Dimension::Points(10.0000),
10851                    ..Default::default()
10852                },
10853                ..Default::default()
10854            },
10855            stretch::geometry::Size::undefined(),
10856        );
10857
10858        assert_eq!(layout.size.width, 20.0000);
10859        assert_eq!(layout.size.height, 20.0000);
10860        assert_eq!(layout.location.x, 0.0000);
10861        assert_eq!(layout.location.y, 0.0000);
10862    }
10863
10864    #[test]
10865    fn rounding_flex_basis_flex_grow_row_prime_number_width() {
10866        let layout = stretch::compute(
10867            &stretch::style::Node {
10868                size: stretch::geometry::Size {
10869                    width: stretch::style::Dimension::Points(113.0000),
10870                    height: stretch::style::Dimension::Points(100.0000),
10871                    ..Default::default()
10872                },
10873                children: vec![
10874                    stretch::style::Node { flex_grow: 1.0000, ..Default::default() },
10875                    stretch::style::Node { flex_grow: 1.0000, ..Default::default() },
10876                    stretch::style::Node { flex_grow: 1.0000, ..Default::default() },
10877                    stretch::style::Node { flex_grow: 1.0000, ..Default::default() },
10878                    stretch::style::Node { flex_grow: 1.0000, ..Default::default() },
10879                ],
10880                ..Default::default()
10881            },
10882            stretch::geometry::Size::undefined(),
10883        );
10884
10885        assert_eq!(layout.size.width, 113.0000);
10886        assert_eq!(layout.size.height, 100.0000);
10887        assert_eq!(layout.location.x, 0.0000);
10888        assert_eq!(layout.location.y, 0.0000);
10889
10890        assert_eq!(layout.children[0].size.width, 23.0000);
10891        assert_eq!(layout.children[0].size.height, 100.0000);
10892        assert_eq!(layout.children[0].location.x, 0.0000);
10893        assert_eq!(layout.children[0].location.y, 0.0000);
10894
10895        assert_eq!(layout.children[1].size.width, 22.0000);
10896        assert_eq!(layout.children[1].size.height, 100.0000);
10897        assert_eq!(layout.children[1].location.x, 23.0000);
10898        assert_eq!(layout.children[1].location.y, 0.0000);
10899
10900        assert_eq!(layout.children[2].size.width, 23.0000);
10901        assert_eq!(layout.children[2].size.height, 100.0000);
10902        assert_eq!(layout.children[2].location.x, 45.0000);
10903        assert_eq!(layout.children[2].location.y, 0.0000);
10904
10905        assert_eq!(layout.children[3].size.width, 22.0000);
10906        assert_eq!(layout.children[3].size.height, 100.0000);
10907        assert_eq!(layout.children[3].location.x, 68.0000);
10908        assert_eq!(layout.children[3].location.y, 0.0000);
10909
10910        assert_eq!(layout.children[4].size.width, 23.0000);
10911        assert_eq!(layout.children[4].size.height, 100.0000);
10912        assert_eq!(layout.children[4].location.x, 90.0000);
10913        assert_eq!(layout.children[4].location.y, 0.0000);
10914    }
10915
10916    #[test]
10917    fn align_items_center_with_child_top() {
10918        let layout = stretch::compute(
10919            &stretch::style::Node {
10920                align_items: stretch::style::AlignItems::Center,
10921                size: stretch::geometry::Size {
10922                    width: stretch::style::Dimension::Points(100.0000),
10923                    height: stretch::style::Dimension::Points(100.0000),
10924                    ..Default::default()
10925                },
10926                children: vec![stretch::style::Node {
10927                    size: stretch::geometry::Size {
10928                        width: stretch::style::Dimension::Points(10.0000),
10929                        height: stretch::style::Dimension::Points(10.0000),
10930                        ..Default::default()
10931                    },
10932                    position: stretch::geometry::Rect {
10933                        top: stretch::style::Dimension::Points(10.0000),
10934                        ..Default::default()
10935                    },
10936                    ..Default::default()
10937                }],
10938                ..Default::default()
10939            },
10940            stretch::geometry::Size::undefined(),
10941        );
10942
10943        assert_eq!(layout.size.width, 100.0000);
10944        assert_eq!(layout.size.height, 100.0000);
10945        assert_eq!(layout.location.x, 0.0000);
10946        assert_eq!(layout.location.y, 0.0000);
10947
10948        assert_eq!(layout.children[0].size.width, 10.0000);
10949        assert_eq!(layout.children[0].size.height, 10.0000);
10950        assert_eq!(layout.children[0].location.x, 0.0000);
10951        assert_eq!(layout.children[0].location.y, 55.0000);
10952    }
10953
10954    #[test]
10955    fn width_smaller_then_content_with_flex_grow_large_size() {
10956        let layout = stretch::compute(
10957            &stretch::style::Node {
10958                size: stretch::geometry::Size {
10959                    width: stretch::style::Dimension::Points(100.0000),
10960                    ..Default::default()
10961                },
10962                children: vec![
10963                    stretch::style::Node {
10964                        flex_direction: stretch::style::FlexDirection::Column,
10965                        flex_grow: 1.0000,
10966                        size: stretch::geometry::Size {
10967                            width: stretch::style::Dimension::Points(0.0000),
10968                            ..Default::default()
10969                        },
10970                        children: vec![stretch::style::Node {
10971                            size: stretch::geometry::Size {
10972                                width: stretch::style::Dimension::Points(70.0000),
10973                                height: stretch::style::Dimension::Points(100.0000),
10974                                ..Default::default()
10975                            },
10976                            ..Default::default()
10977                        }],
10978                        ..Default::default()
10979                    },
10980                    stretch::style::Node {
10981                        flex_direction: stretch::style::FlexDirection::Column,
10982                        flex_grow: 1.0000,
10983                        size: stretch::geometry::Size {
10984                            width: stretch::style::Dimension::Points(0.0000),
10985                            ..Default::default()
10986                        },
10987                        children: vec![stretch::style::Node {
10988                            size: stretch::geometry::Size {
10989                                width: stretch::style::Dimension::Points(20.0000),
10990                                height: stretch::style::Dimension::Points(100.0000),
10991                                ..Default::default()
10992                            },
10993                            ..Default::default()
10994                        }],
10995                        ..Default::default()
10996                    },
10997                ],
10998                ..Default::default()
10999            },
11000            stretch::geometry::Size::undefined(),
11001        );
11002
11003        assert_eq!(layout.size.width, 100.0000);
11004        assert_eq!(layout.size.height, 100.0000);
11005        assert_eq!(layout.location.x, 0.0000);
11006        assert_eq!(layout.location.y, 0.0000);
11007
11008        assert_eq!(layout.children[0].size.width, 50.0000);
11009        assert_eq!(layout.children[0].size.height, 100.0000);
11010        assert_eq!(layout.children[0].location.x, 0.0000);
11011        assert_eq!(layout.children[0].location.y, 0.0000);
11012
11013        assert_eq!(layout.children[0].children[0].size.width, 70.0000);
11014        assert_eq!(layout.children[0].children[0].size.height, 100.0000);
11015        assert_eq!(layout.children[0].children[0].location.x, 0.0000);
11016        assert_eq!(layout.children[0].children[0].location.y, 0.0000);
11017
11018        assert_eq!(layout.children[1].size.width, 50.0000);
11019        assert_eq!(layout.children[1].size.height, 100.0000);
11020        assert_eq!(layout.children[1].location.x, 50.0000);
11021        assert_eq!(layout.children[1].location.y, 0.0000);
11022
11023        assert_eq!(layout.children[1].children[0].size.width, 20.0000);
11024        assert_eq!(layout.children[1].children[0].size.height, 100.0000);
11025        assert_eq!(layout.children[1].children[0].location.x, 0.0000);
11026        assert_eq!(layout.children[1].children[0].location.y, 0.0000);
11027    }
11028
11029    #[test]
11030    fn display_none() {
11031        let layout = stretch::compute(
11032            &stretch::style::Node {
11033                size: stretch::geometry::Size {
11034                    width: stretch::style::Dimension::Points(100.0000),
11035                    height: stretch::style::Dimension::Points(100.0000),
11036                    ..Default::default()
11037                },
11038                children: vec![
11039                    stretch::style::Node { flex_grow: 1.0000, ..Default::default() },
11040                    stretch::style::Node {
11041                        display: stretch::style::Display::None,
11042                        flex_grow: 1.0000,
11043                        ..Default::default()
11044                    },
11045                ],
11046                ..Default::default()
11047            },
11048            stretch::geometry::Size::undefined(),
11049        );
11050
11051        assert_eq!(layout.size.width, 100.0000);
11052        assert_eq!(layout.size.height, 100.0000);
11053        assert_eq!(layout.location.x, 0.0000);
11054        assert_eq!(layout.location.y, 0.0000);
11055
11056        assert_eq!(layout.children[0].size.width, 100.0000);
11057        assert_eq!(layout.children[0].size.height, 100.0000);
11058        assert_eq!(layout.children[0].location.x, 0.0000);
11059        assert_eq!(layout.children[0].location.y, 0.0000);
11060
11061        assert_eq!(layout.children[1].size.width, 0.0000);
11062        assert_eq!(layout.children[1].size.height, 0.0000);
11063        assert_eq!(layout.children[1].location.x, 0.0000);
11064        assert_eq!(layout.children[1].location.y, 0.0000);
11065    }
11066
11067    #[test]
11068    fn flex_basis_smaller_than_content_column() {
11069        let layout = stretch::compute(
11070            &stretch::style::Node {
11071                flex_direction: stretch::style::FlexDirection::Column,
11072                size: stretch::geometry::Size {
11073                    height: stretch::style::Dimension::Points(100.0000),
11074                    ..Default::default()
11075                },
11076                children: vec![stretch::style::Node {
11077                    flex_direction: stretch::style::FlexDirection::Column,
11078                    flex_basis: stretch::style::Dimension::Points(50.0000),
11079                    children: vec![stretch::style::Node {
11080                        size: stretch::geometry::Size {
11081                            width: stretch::style::Dimension::Points(100.0000),
11082                            height: stretch::style::Dimension::Points(100.0000),
11083                            ..Default::default()
11084                        },
11085                        ..Default::default()
11086                    }],
11087                    ..Default::default()
11088                }],
11089                ..Default::default()
11090            },
11091            stretch::geometry::Size::undefined(),
11092        );
11093
11094        assert_eq!(layout.size.width, 100.0000);
11095        assert_eq!(layout.size.height, 100.0000);
11096        assert_eq!(layout.location.x, 0.0000);
11097        assert_eq!(layout.location.y, 0.0000);
11098
11099        assert_eq!(layout.children[0].size.width, 100.0000);
11100        assert_eq!(layout.children[0].size.height, 50.0000);
11101        assert_eq!(layout.children[0].location.x, 0.0000);
11102        assert_eq!(layout.children[0].location.y, 0.0000);
11103
11104        assert_eq!(layout.children[0].children[0].size.width, 100.0000);
11105        assert_eq!(layout.children[0].children[0].size.height, 50.0000);
11106        assert_eq!(layout.children[0].children[0].location.x, 0.0000);
11107        assert_eq!(layout.children[0].children[0].location.y, 0.0000);
11108    }
11109
11110    #[test]
11111    fn percentage_width_height_undefined_parent_size() {
11112        let layout = stretch::compute(
11113            &stretch::style::Node {
11114                flex_direction: stretch::style::FlexDirection::Column,
11115                children: vec![stretch::style::Node {
11116                    size: stretch::geometry::Size {
11117                        width: stretch::style::Dimension::Percent(0.5000),
11118                        height: stretch::style::Dimension::Percent(0.5000),
11119                        ..Default::default()
11120                    },
11121                    ..Default::default()
11122                }],
11123                ..Default::default()
11124            },
11125            stretch::geometry::Size::undefined(),
11126        );
11127
11128        assert_eq!(layout.size.width, 0.0000);
11129        assert_eq!(layout.size.height, 0.0000);
11130        assert_eq!(layout.location.x, 0.0000);
11131        assert_eq!(layout.location.y, 0.0000);
11132
11133        assert_eq!(layout.children[0].size.width, 0.0000);
11134        assert_eq!(layout.children[0].size.height, 0.0000);
11135        assert_eq!(layout.children[0].location.x, 0.0000);
11136        assert_eq!(layout.children[0].location.y, 0.0000);
11137    }
11138
11139    #[test]
11140    fn flex_grow_within_max_width() {
11141        let layout = stretch::compute(
11142            &stretch::style::Node {
11143                flex_direction: stretch::style::FlexDirection::Column,
11144                size: stretch::geometry::Size {
11145                    width: stretch::style::Dimension::Points(200.0000),
11146                    height: stretch::style::Dimension::Points(100.0000),
11147                    ..Default::default()
11148                },
11149                children: vec![stretch::style::Node {
11150                    max_size: stretch::geometry::Size {
11151                        width: stretch::style::Dimension::Points(100.0000),
11152                        ..Default::default()
11153                    },
11154                    children: vec![stretch::style::Node {
11155                        flex_grow: 1.0000,
11156                        size: stretch::geometry::Size {
11157                            height: stretch::style::Dimension::Points(20.0000),
11158                            ..Default::default()
11159                        },
11160                        ..Default::default()
11161                    }],
11162                    ..Default::default()
11163                }],
11164                ..Default::default()
11165            },
11166            stretch::geometry::Size::undefined(),
11167        );
11168
11169        assert_eq!(layout.size.width, 200.0000);
11170        assert_eq!(layout.size.height, 100.0000);
11171        assert_eq!(layout.location.x, 0.0000);
11172        assert_eq!(layout.location.y, 0.0000);
11173
11174        assert_eq!(layout.children[0].size.width, 100.0000);
11175        assert_eq!(layout.children[0].size.height, 20.0000);
11176        assert_eq!(layout.children[0].location.x, 0.0000);
11177        assert_eq!(layout.children[0].location.y, 0.0000);
11178
11179        assert_eq!(layout.children[0].children[0].size.width, 100.0000);
11180        assert_eq!(layout.children[0].children[0].size.height, 20.0000);
11181        assert_eq!(layout.children[0].children[0].location.x, 0.0000);
11182        assert_eq!(layout.children[0].children[0].location.y, 0.0000);
11183    }
11184
11185    #[test]
11186    fn flex_grow_height_maximized() {
11187        let layout = stretch::compute(
11188            &stretch::style::Node {
11189                flex_direction: stretch::style::FlexDirection::Column,
11190                size: stretch::geometry::Size {
11191                    width: stretch::style::Dimension::Points(100.0000),
11192                    height: stretch::style::Dimension::Points(500.0000),
11193                    ..Default::default()
11194                },
11195                children: vec![stretch::style::Node {
11196                    flex_direction: stretch::style::FlexDirection::Column,
11197                    flex_grow: 1.0000,
11198                    min_size: stretch::geometry::Size {
11199                        height: stretch::style::Dimension::Points(100.0000),
11200                        ..Default::default()
11201                    },
11202                    max_size: stretch::geometry::Size {
11203                        height: stretch::style::Dimension::Points(500.0000),
11204                        ..Default::default()
11205                    },
11206                    children: vec![
11207                        stretch::style::Node {
11208                            flex_grow: 1.0000,
11209                            flex_basis: stretch::style::Dimension::Points(200.0000),
11210                            ..Default::default()
11211                        },
11212                        stretch::style::Node {
11213                            size: stretch::geometry::Size {
11214                                height: stretch::style::Dimension::Points(100.0000),
11215                                ..Default::default()
11216                            },
11217                            ..Default::default()
11218                        },
11219                    ],
11220                    ..Default::default()
11221                }],
11222                ..Default::default()
11223            },
11224            stretch::geometry::Size::undefined(),
11225        );
11226
11227        assert_eq!(layout.size.width, 100.0000);
11228        assert_eq!(layout.size.height, 500.0000);
11229        assert_eq!(layout.location.x, 0.0000);
11230        assert_eq!(layout.location.y, 0.0000);
11231
11232        assert_eq!(layout.children[0].size.width, 100.0000);
11233        assert_eq!(layout.children[0].size.height, 500.0000);
11234        assert_eq!(layout.children[0].location.x, 0.0000);
11235        assert_eq!(layout.children[0].location.y, 0.0000);
11236
11237        assert_eq!(layout.children[0].children[0].size.width, 100.0000);
11238        assert_eq!(layout.children[0].children[0].size.height, 400.0000);
11239        assert_eq!(layout.children[0].children[0].location.x, 0.0000);
11240        assert_eq!(layout.children[0].children[0].location.y, 0.0000);
11241
11242        assert_eq!(layout.children[0].children[1].size.width, 100.0000);
11243        assert_eq!(layout.children[0].children[1].size.height, 100.0000);
11244        assert_eq!(layout.children[0].children[1].location.x, 0.0000);
11245        assert_eq!(layout.children[0].children[1].location.y, 400.0000);
11246    }
11247
11248    #[test]
11249    fn max_height_overrides_height() {
11250        let layout = stretch::compute(
11251            &stretch::style::Node {
11252                children: vec![stretch::style::Node {
11253                    size: stretch::geometry::Size {
11254                        height: stretch::style::Dimension::Points(200.0000),
11255                        ..Default::default()
11256                    },
11257                    max_size: stretch::geometry::Size {
11258                        height: stretch::style::Dimension::Points(100.0000),
11259                        ..Default::default()
11260                    },
11261                    ..Default::default()
11262                }],
11263                ..Default::default()
11264            },
11265            stretch::geometry::Size::undefined(),
11266        );
11267
11268        assert_eq!(layout.size.width, 0.0000);
11269        assert_eq!(layout.size.height, 100.0000);
11270        assert_eq!(layout.location.x, 0.0000);
11271        assert_eq!(layout.location.y, 0.0000);
11272
11273        assert_eq!(layout.children[0].size.width, 0.0000);
11274        assert_eq!(layout.children[0].size.height, 100.0000);
11275        assert_eq!(layout.children[0].location.x, 0.0000);
11276        assert_eq!(layout.children[0].location.y, 0.0000);
11277    }
11278
11279    #[test]
11280    fn relative_position_should_not_nudge_siblings() {
11281        let layout = stretch::compute(
11282            &stretch::style::Node {
11283                flex_direction: stretch::style::FlexDirection::Column,
11284                size: stretch::geometry::Size {
11285                    width: stretch::style::Dimension::Points(100.0000),
11286                    height: stretch::style::Dimension::Points(100.0000),
11287                    ..Default::default()
11288                },
11289                children: vec![
11290                    stretch::style::Node {
11291                        size: stretch::geometry::Size {
11292                            height: stretch::style::Dimension::Points(10.0000),
11293                            ..Default::default()
11294                        },
11295                        position: stretch::geometry::Rect {
11296                            top: stretch::style::Dimension::Points(15.0000),
11297                            ..Default::default()
11298                        },
11299                        ..Default::default()
11300                    },
11301                    stretch::style::Node {
11302                        size: stretch::geometry::Size {
11303                            height: stretch::style::Dimension::Points(10.0000),
11304                            ..Default::default()
11305                        },
11306                        position: stretch::geometry::Rect {
11307                            top: stretch::style::Dimension::Points(15.0000),
11308                            ..Default::default()
11309                        },
11310                        ..Default::default()
11311                    },
11312                ],
11313                ..Default::default()
11314            },
11315            stretch::geometry::Size::undefined(),
11316        );
11317
11318        assert_eq!(layout.size.width, 100.0000);
11319        assert_eq!(layout.size.height, 100.0000);
11320        assert_eq!(layout.location.x, 0.0000);
11321        assert_eq!(layout.location.y, 0.0000);
11322
11323        assert_eq!(layout.children[0].size.width, 100.0000);
11324        assert_eq!(layout.children[0].size.height, 10.0000);
11325        assert_eq!(layout.children[0].location.x, 0.0000);
11326        assert_eq!(layout.children[0].location.y, 15.0000);
11327
11328        assert_eq!(layout.children[1].size.width, 100.0000);
11329        assert_eq!(layout.children[1].size.height, 10.0000);
11330        assert_eq!(layout.children[1].location.x, 0.0000);
11331        assert_eq!(layout.children[1].location.y, 25.0000);
11332    }
11333
11334    #[test]
11335    fn justify_content_min_width_with_padding_child_width_greater_than_parent() {
11336        let layout = stretch::compute(
11337            &stretch::style::Node {
11338                flex_direction: stretch::style::FlexDirection::Column,
11339                size: stretch::geometry::Size {
11340                    width: stretch::style::Dimension::Points(1000.0000),
11341                    height: stretch::style::Dimension::Points(1584.0000),
11342                    ..Default::default()
11343                },
11344                children: vec![stretch::style::Node {
11345                    children: vec![stretch::style::Node {
11346                        justify_content: stretch::style::JustifyContent::Center,
11347                        min_size: stretch::geometry::Size {
11348                            width: stretch::style::Dimension::Points(400.0000),
11349                            ..Default::default()
11350                        },
11351                        padding: stretch::geometry::Rect {
11352                            start: stretch::style::Dimension::Points(100.0000),
11353                            end: stretch::style::Dimension::Points(100.0000),
11354                            ..Default::default()
11355                        },
11356                        children: vec![stretch::style::Node {
11357                            size: stretch::geometry::Size {
11358                                width: stretch::style::Dimension::Points(300.0000),
11359                                height: stretch::style::Dimension::Points(100.0000),
11360                                ..Default::default()
11361                            },
11362                            ..Default::default()
11363                        }],
11364                        ..Default::default()
11365                    }],
11366                    ..Default::default()
11367                }],
11368                ..Default::default()
11369            },
11370            stretch::geometry::Size::undefined(),
11371        );
11372
11373        assert_eq!(layout.size.width, 1000.0000);
11374        assert_eq!(layout.size.height, 1584.0000);
11375        assert_eq!(layout.location.x, 0.0000);
11376        assert_eq!(layout.location.y, 0.0000);
11377
11378        assert_eq!(layout.children[0].size.width, 1000.0000);
11379        assert_eq!(layout.children[0].size.height, 100.0000);
11380        assert_eq!(layout.children[0].location.x, 0.0000);
11381        assert_eq!(layout.children[0].location.y, 0.0000);
11382
11383        assert_eq!(layout.children[0].children[0].size.width, 500.0000);
11384        assert_eq!(layout.children[0].children[0].size.height, 100.0000);
11385        assert_eq!(layout.children[0].children[0].location.x, 0.0000);
11386        assert_eq!(layout.children[0].children[0].location.y, 0.0000);
11387
11388        assert_eq!(layout.children[0].children[0].children[0].size.width, 300.0000);
11389        assert_eq!(layout.children[0].children[0].children[0].size.height, 100.0000);
11390        assert_eq!(layout.children[0].children[0].children[0].location.x, 100.0000);
11391        assert_eq!(layout.children[0].children[0].children[0].location.y, 0.0000);
11392    }
11393
11394    #[test]
11395    fn flex_grow_flex_basis_percent_min_max() {
11396        let layout = stretch::compute(
11397            &stretch::style::Node {
11398                size: stretch::geometry::Size {
11399                    width: stretch::style::Dimension::Points(120.0000),
11400                    ..Default::default()
11401                },
11402                children: vec![
11403                    stretch::style::Node {
11404                        flex_grow: 1.0000,
11405                        flex_shrink: 0.0000,
11406                        flex_basis: stretch::style::Dimension::Points(0.0000),
11407                        size: stretch::geometry::Size {
11408                            height: stretch::style::Dimension::Points(20.0000),
11409                            ..Default::default()
11410                        },
11411                        min_size: stretch::geometry::Size {
11412                            width: stretch::style::Dimension::Points(60.0000),
11413                            ..Default::default()
11414                        },
11415                        ..Default::default()
11416                    },
11417                    stretch::style::Node {
11418                        flex_grow: 1.0000,
11419                        flex_shrink: 0.0000,
11420                        flex_basis: stretch::style::Dimension::Percent(0.5000),
11421                        size: stretch::geometry::Size {
11422                            width: stretch::style::Dimension::Points(20.0000),
11423                            height: stretch::style::Dimension::Points(20.0000),
11424                            ..Default::default()
11425                        },
11426                        max_size: stretch::geometry::Size {
11427                            width: stretch::style::Dimension::Points(20.0000),
11428                            ..Default::default()
11429                        },
11430                        ..Default::default()
11431                    },
11432                ],
11433                ..Default::default()
11434            },
11435            stretch::geometry::Size::undefined(),
11436        );
11437
11438        assert_eq!(layout.size.width, 120.0000);
11439        assert_eq!(layout.size.height, 20.0000);
11440        assert_eq!(layout.location.x, 0.0000);
11441        assert_eq!(layout.location.y, 0.0000);
11442
11443        assert_eq!(layout.children[0].size.width, 100.0000);
11444        assert_eq!(layout.children[0].size.height, 20.0000);
11445        assert_eq!(layout.children[0].location.x, 0.0000);
11446        assert_eq!(layout.children[0].location.y, 0.0000);
11447
11448        assert_eq!(layout.children[1].size.width, 20.0000);
11449        assert_eq!(layout.children[1].size.height, 20.0000);
11450        assert_eq!(layout.children[1].location.x, 100.0000);
11451        assert_eq!(layout.children[1].location.y, 0.0000);
11452    }
11453
11454    #[test]
11455    fn percent_absolute_position() {
11456        let layout = stretch::compute(
11457            &stretch::style::Node {
11458                flex_direction: stretch::style::FlexDirection::Column,
11459                size: stretch::geometry::Size {
11460                    width: stretch::style::Dimension::Points(60.0000),
11461                    height: stretch::style::Dimension::Points(50.0000),
11462                    ..Default::default()
11463                },
11464                children: vec![stretch::style::Node {
11465                    position_type: stretch::style::PositionType::Absolute,
11466                    size: stretch::geometry::Size {
11467                        width: stretch::style::Dimension::Percent(1.0000),
11468                        height: stretch::style::Dimension::Points(50.0000),
11469                        ..Default::default()
11470                    },
11471                    position: stretch::geometry::Rect {
11472                        start: stretch::style::Dimension::Percent(0.5000),
11473                        ..Default::default()
11474                    },
11475                    children: vec![
11476                        stretch::style::Node {
11477                            size: stretch::geometry::Size {
11478                                width: stretch::style::Dimension::Percent(1.0000),
11479                                ..Default::default()
11480                            },
11481                            ..Default::default()
11482                        },
11483                        stretch::style::Node {
11484                            size: stretch::geometry::Size {
11485                                width: stretch::style::Dimension::Percent(1.0000),
11486                                ..Default::default()
11487                            },
11488                            ..Default::default()
11489                        },
11490                    ],
11491                    ..Default::default()
11492                }],
11493                ..Default::default()
11494            },
11495            stretch::geometry::Size::undefined(),
11496        );
11497
11498        assert_eq!(layout.size.width, 60.0000);
11499        assert_eq!(layout.size.height, 50.0000);
11500        assert_eq!(layout.location.x, 0.0000);
11501        assert_eq!(layout.location.y, 0.0000);
11502
11503        assert_eq!(layout.children[0].size.width, 60.0000);
11504        assert_eq!(layout.children[0].size.height, 50.0000);
11505        assert_eq!(layout.children[0].location.x, 30.0000);
11506        assert_eq!(layout.children[0].location.y, 0.0000);
11507
11508        assert_eq!(layout.children[0].children[0].size.width, 30.0000);
11509        assert_eq!(layout.children[0].children[0].size.height, 50.0000);
11510        assert_eq!(layout.children[0].children[0].location.x, 0.0000);
11511        assert_eq!(layout.children[0].children[0].location.y, 0.0000);
11512
11513        assert_eq!(layout.children[0].children[1].size.width, 30.0000);
11514        assert_eq!(layout.children[0].children[1].size.height, 50.0000);
11515        assert_eq!(layout.children[0].children[1].location.x, 30.0000);
11516        assert_eq!(layout.children[0].children[1].location.y, 0.0000);
11517    }
11518
11519    #[test]
11520    fn flex_root_ignored() {
11521        let layout = stretch::compute(
11522            &stretch::style::Node {
11523                flex_direction: stretch::style::FlexDirection::Column,
11524                size: stretch::geometry::Size {
11525                    width: stretch::style::Dimension::Points(100.0000),
11526                    ..Default::default()
11527                },
11528                min_size: stretch::geometry::Size {
11529                    height: stretch::style::Dimension::Points(100.0000),
11530                    ..Default::default()
11531                },
11532                max_size: stretch::geometry::Size {
11533                    height: stretch::style::Dimension::Points(500.0000),
11534                    ..Default::default()
11535                },
11536                children: vec![
11537                    stretch::style::Node {
11538                        flex_grow: 1.0000,
11539                        flex_basis: stretch::style::Dimension::Points(200.0000),
11540                        ..Default::default()
11541                    },
11542                    stretch::style::Node {
11543                        size: stretch::geometry::Size {
11544                            height: stretch::style::Dimension::Points(100.0000),
11545                            ..Default::default()
11546                        },
11547                        ..Default::default()
11548                    },
11549                ],
11550                ..Default::default()
11551            },
11552            stretch::geometry::Size::undefined(),
11553        );
11554
11555        assert_eq!(layout.size.width, 100.0000);
11556        assert_eq!(layout.size.height, 300.0000);
11557        assert_eq!(layout.location.x, 0.0000);
11558        assert_eq!(layout.location.y, 0.0000);
11559
11560        assert_eq!(layout.children[0].size.width, 100.0000);
11561        assert_eq!(layout.children[0].size.height, 200.0000);
11562        assert_eq!(layout.children[0].location.x, 0.0000);
11563        assert_eq!(layout.children[0].location.y, 0.0000);
11564
11565        assert_eq!(layout.children[1].size.width, 100.0000);
11566        assert_eq!(layout.children[1].size.height, 100.0000);
11567        assert_eq!(layout.children[1].location.x, 0.0000);
11568        assert_eq!(layout.children[1].location.y, 200.0000);
11569    }
11570
11571    #[test]
11572    fn justify_content_column_space_between() {
11573        let layout = stretch::compute(
11574            &stretch::style::Node {
11575                flex_direction: stretch::style::FlexDirection::Column,
11576                justify_content: stretch::style::JustifyContent::SpaceBetween,
11577                size: stretch::geometry::Size {
11578                    width: stretch::style::Dimension::Points(100.0000),
11579                    height: stretch::style::Dimension::Points(100.0000),
11580                    ..Default::default()
11581                },
11582                children: vec![
11583                    stretch::style::Node {
11584                        size: stretch::geometry::Size {
11585                            height: stretch::style::Dimension::Points(10.0000),
11586                            ..Default::default()
11587                        },
11588                        ..Default::default()
11589                    },
11590                    stretch::style::Node {
11591                        size: stretch::geometry::Size {
11592                            height: stretch::style::Dimension::Points(10.0000),
11593                            ..Default::default()
11594                        },
11595                        ..Default::default()
11596                    },
11597                    stretch::style::Node {
11598                        size: stretch::geometry::Size {
11599                            height: stretch::style::Dimension::Points(10.0000),
11600                            ..Default::default()
11601                        },
11602                        ..Default::default()
11603                    },
11604                ],
11605                ..Default::default()
11606            },
11607            stretch::geometry::Size::undefined(),
11608        );
11609
11610        assert_eq!(layout.size.width, 100.0000);
11611        assert_eq!(layout.size.height, 100.0000);
11612        assert_eq!(layout.location.x, 0.0000);
11613        assert_eq!(layout.location.y, 0.0000);
11614
11615        assert_eq!(layout.children[0].size.width, 100.0000);
11616        assert_eq!(layout.children[0].size.height, 10.0000);
11617        assert_eq!(layout.children[0].location.x, 0.0000);
11618        assert_eq!(layout.children[0].location.y, 0.0000);
11619
11620        assert_eq!(layout.children[1].size.width, 100.0000);
11621        assert_eq!(layout.children[1].size.height, 10.0000);
11622        assert_eq!(layout.children[1].location.x, 0.0000);
11623        assert_eq!(layout.children[1].location.y, 45.0000);
11624
11625        assert_eq!(layout.children[2].size.width, 100.0000);
11626        assert_eq!(layout.children[2].size.height, 10.0000);
11627        assert_eq!(layout.children[2].location.x, 0.0000);
11628        assert_eq!(layout.children[2].location.y, 90.0000);
11629    }
11630
11631    #[test]
11632    fn flex_grow_within_constrained_max_width() {
11633        let layout = stretch::compute(
11634            &stretch::style::Node {
11635                flex_direction: stretch::style::FlexDirection::Column,
11636                size: stretch::geometry::Size {
11637                    width: stretch::style::Dimension::Points(200.0000),
11638                    height: stretch::style::Dimension::Points(100.0000),
11639                    ..Default::default()
11640                },
11641                children: vec![stretch::style::Node {
11642                    max_size: stretch::geometry::Size {
11643                        width: stretch::style::Dimension::Points(300.0000),
11644                        ..Default::default()
11645                    },
11646                    children: vec![stretch::style::Node {
11647                        flex_grow: 1.0000,
11648                        size: stretch::geometry::Size {
11649                            height: stretch::style::Dimension::Points(20.0000),
11650                            ..Default::default()
11651                        },
11652                        ..Default::default()
11653                    }],
11654                    ..Default::default()
11655                }],
11656                ..Default::default()
11657            },
11658            stretch::geometry::Size::undefined(),
11659        );
11660
11661        assert_eq!(layout.size.width, 200.0000);
11662        assert_eq!(layout.size.height, 100.0000);
11663        assert_eq!(layout.location.x, 0.0000);
11664        assert_eq!(layout.location.y, 0.0000);
11665
11666        assert_eq!(layout.children[0].size.width, 200.0000);
11667        assert_eq!(layout.children[0].size.height, 20.0000);
11668        assert_eq!(layout.children[0].location.x, 0.0000);
11669        assert_eq!(layout.children[0].location.y, 0.0000);
11670
11671        assert_eq!(layout.children[0].children[0].size.width, 200.0000);
11672        assert_eq!(layout.children[0].children[0].size.height, 20.0000);
11673        assert_eq!(layout.children[0].children[0].location.x, 0.0000);
11674        assert_eq!(layout.children[0].children[0].location.y, 0.0000);
11675    }
11676
11677    #[test]
11678    fn flex_basis_smaller_than_content_row() {
11679        let layout = stretch::compute(
11680            &stretch::style::Node {
11681                size: stretch::geometry::Size {
11682                    width: stretch::style::Dimension::Points(100.0000),
11683                    ..Default::default()
11684                },
11685                children: vec![stretch::style::Node {
11686                    flex_direction: stretch::style::FlexDirection::Column,
11687                    flex_basis: stretch::style::Dimension::Points(50.0000),
11688                    children: vec![stretch::style::Node {
11689                        size: stretch::geometry::Size {
11690                            width: stretch::style::Dimension::Points(100.0000),
11691                            height: stretch::style::Dimension::Points(100.0000),
11692                            ..Default::default()
11693                        },
11694                        ..Default::default()
11695                    }],
11696                    ..Default::default()
11697                }],
11698                ..Default::default()
11699            },
11700            stretch::geometry::Size::undefined(),
11701        );
11702
11703        assert_eq!(layout.size.width, 100.0000);
11704        assert_eq!(layout.size.height, 100.0000);
11705        assert_eq!(layout.location.x, 0.0000);
11706        assert_eq!(layout.location.y, 0.0000);
11707
11708        assert_eq!(layout.children[0].size.width, 100.0000);
11709        assert_eq!(layout.children[0].size.height, 100.0000);
11710        assert_eq!(layout.children[0].location.x, 0.0000);
11711        assert_eq!(layout.children[0].location.y, 0.0000);
11712
11713        assert_eq!(layout.children[0].children[0].size.width, 100.0000);
11714        assert_eq!(layout.children[0].children[0].size.height, 100.0000);
11715        assert_eq!(layout.children[0].children[0].location.x, 0.0000);
11716        assert_eq!(layout.children[0].children[0].location.y, 0.0000);
11717    }
11718
11719    #[test]
11720    fn max_width_overrides_width() {
11721        let layout = stretch::compute(
11722            &stretch::style::Node {
11723                children: vec![stretch::style::Node {
11724                    size: stretch::geometry::Size {
11725                        width: stretch::style::Dimension::Points(200.0000),
11726                        ..Default::default()
11727                    },
11728                    max_size: stretch::geometry::Size {
11729                        width: stretch::style::Dimension::Points(100.0000),
11730                        ..Default::default()
11731                    },
11732                    ..Default::default()
11733                }],
11734                ..Default::default()
11735            },
11736            stretch::geometry::Size::undefined(),
11737        );
11738
11739        assert_eq!(layout.size.width, 100.0000);
11740        assert_eq!(layout.size.height, 0.0000);
11741        assert_eq!(layout.location.x, 0.0000);
11742        assert_eq!(layout.location.y, 0.0000);
11743
11744        assert_eq!(layout.children[0].size.width, 100.0000);
11745        assert_eq!(layout.children[0].size.height, 0.0000);
11746        assert_eq!(layout.children[0].location.x, 0.0000);
11747        assert_eq!(layout.children[0].location.y, 0.0000);
11748    }
11749
11750    #[test]
11751    fn percentage_position_bottom_right() {
11752        let layout = stretch::compute(
11753            &stretch::style::Node {
11754                size: stretch::geometry::Size {
11755                    width: stretch::style::Dimension::Points(500.0000),
11756                    height: stretch::style::Dimension::Points(500.0000),
11757                    ..Default::default()
11758                },
11759                children: vec![stretch::style::Node {
11760                    size: stretch::geometry::Size {
11761                        width: stretch::style::Dimension::Percent(0.5500),
11762                        height: stretch::style::Dimension::Percent(0.1500),
11763                        ..Default::default()
11764                    },
11765                    position: stretch::geometry::Rect {
11766                        end: stretch::style::Dimension::Percent(0.2000),
11767                        bottom: stretch::style::Dimension::Percent(0.1000),
11768                        ..Default::default()
11769                    },
11770                    ..Default::default()
11771                }],
11772                ..Default::default()
11773            },
11774            stretch::geometry::Size::undefined(),
11775        );
11776
11777        assert_eq!(layout.size.width, 500.0000);
11778        assert_eq!(layout.size.height, 500.0000);
11779        assert_eq!(layout.location.x, 0.0000);
11780        assert_eq!(layout.location.y, 0.0000);
11781
11782        assert_eq!(layout.children[0].size.width, 275.0000);
11783        assert_eq!(layout.children[0].size.height, 75.0000);
11784        assert_eq!(layout.children[0].location.x, -100.0000);
11785        assert_eq!(layout.children[0].location.y, -50.0000);
11786    }
11787
11788    #[test]
11789    fn margin_auto_top_stretching_child() {
11790        let layout = stretch::compute(
11791            &stretch::style::Node {
11792                align_items: stretch::style::AlignItems::Center,
11793                size: stretch::geometry::Size {
11794                    width: stretch::style::Dimension::Points(200.0000),
11795                    height: stretch::style::Dimension::Points(200.0000),
11796                    ..Default::default()
11797                },
11798                children: vec![
11799                    stretch::style::Node {
11800                        flex_grow: 1.0000,
11801                        flex_shrink: 1.0000,
11802                        flex_basis: stretch::style::Dimension::Percent(0.0000),
11803                        margin: stretch::geometry::Rect { top: stretch::style::Dimension::Auto, ..Default::default() },
11804                        ..Default::default()
11805                    },
11806                    stretch::style::Node {
11807                        size: stretch::geometry::Size {
11808                            width: stretch::style::Dimension::Points(50.0000),
11809                            height: stretch::style::Dimension::Points(50.0000),
11810                            ..Default::default()
11811                        },
11812                        ..Default::default()
11813                    },
11814                ],
11815                ..Default::default()
11816            },
11817            stretch::geometry::Size::undefined(),
11818        );
11819
11820        assert_eq!(layout.size.width, 200.0000);
11821        assert_eq!(layout.size.height, 200.0000);
11822        assert_eq!(layout.location.x, 0.0000);
11823        assert_eq!(layout.location.y, 0.0000);
11824
11825        assert_eq!(layout.children[0].size.width, 150.0000);
11826        assert_eq!(layout.children[0].size.height, 0.0000);
11827        assert_eq!(layout.children[0].location.x, 0.0000);
11828        assert_eq!(layout.children[0].location.y, 200.0000);
11829
11830        assert_eq!(layout.children[1].size.width, 50.0000);
11831        assert_eq!(layout.children[1].size.height, 50.0000);
11832        assert_eq!(layout.children[1].location.x, 150.0000);
11833        assert_eq!(layout.children[1].location.y, 75.0000);
11834    }
11835
11836    #[test]
11837    fn align_flex_start_with_shrinking_children() {
11838        let layout = stretch::compute(
11839            &stretch::style::Node {
11840                size: stretch::geometry::Size {
11841                    width: stretch::style::Dimension::Points(500.0000),
11842                    height: stretch::style::Dimension::Points(500.0000),
11843                    ..Default::default()
11844                },
11845                children: vec![stretch::style::Node {
11846                    align_items: stretch::style::AlignItems::FlexStart,
11847                    children: vec![stretch::style::Node {
11848                        flex_grow: 1.0000,
11849                        flex_shrink: 1.0000,
11850                        children: vec![stretch::style::Node {
11851                            flex_grow: 1.0000,
11852                            flex_shrink: 1.0000,
11853                            ..Default::default()
11854                        }],
11855                        ..Default::default()
11856                    }],
11857                    ..Default::default()
11858                }],
11859                ..Default::default()
11860            },
11861            stretch::geometry::Size::undefined(),
11862        );
11863
11864        assert_eq!(layout.size.width, 500.0000);
11865        assert_eq!(layout.size.height, 500.0000);
11866        assert_eq!(layout.location.x, 0.0000);
11867        assert_eq!(layout.location.y, 0.0000);
11868
11869        assert_eq!(layout.children[0].size.width, 0.0000);
11870        assert_eq!(layout.children[0].size.height, 500.0000);
11871        assert_eq!(layout.children[0].location.x, 0.0000);
11872        assert_eq!(layout.children[0].location.y, 0.0000);
11873
11874        assert_eq!(layout.children[0].children[0].size.width, 0.0000);
11875        assert_eq!(layout.children[0].children[0].size.height, 0.0000);
11876        assert_eq!(layout.children[0].children[0].location.x, 0.0000);
11877        assert_eq!(layout.children[0].children[0].location.y, 0.0000);
11878
11879        assert_eq!(layout.children[0].children[0].children[0].size.width, 0.0000);
11880        assert_eq!(layout.children[0].children[0].children[0].size.height, 0.0000);
11881        assert_eq!(layout.children[0].children[0].children[0].location.x, 0.0000);
11882        assert_eq!(layout.children[0].children[0].children[0].location.y, 0.0000);
11883    }
11884
11885    #[test]
11886    fn justify_content_column_min_height_and_margin_bottom() {
11887        let layout = stretch::compute(
11888            &stretch::style::Node {
11889                flex_direction: stretch::style::FlexDirection::Column,
11890                justify_content: stretch::style::JustifyContent::Center,
11891                min_size: stretch::geometry::Size {
11892                    height: stretch::style::Dimension::Points(50.0000),
11893                    ..Default::default()
11894                },
11895                children: vec![stretch::style::Node {
11896                    size: stretch::geometry::Size {
11897                        width: stretch::style::Dimension::Points(20.0000),
11898                        height: stretch::style::Dimension::Points(20.0000),
11899                        ..Default::default()
11900                    },
11901                    margin: stretch::geometry::Rect {
11902                        bottom: stretch::style::Dimension::Points(10.0000),
11903                        ..Default::default()
11904                    },
11905                    ..Default::default()
11906                }],
11907                ..Default::default()
11908            },
11909            stretch::geometry::Size::undefined(),
11910        );
11911
11912        assert_eq!(layout.size.width, 20.0000);
11913        assert_eq!(layout.size.height, 50.0000);
11914        assert_eq!(layout.location.x, 0.0000);
11915        assert_eq!(layout.location.y, 0.0000);
11916
11917        assert_eq!(layout.children[0].size.width, 20.0000);
11918        assert_eq!(layout.children[0].size.height, 20.0000);
11919        assert_eq!(layout.children[0].location.x, 0.0000);
11920        assert_eq!(layout.children[0].location.y, 10.0000);
11921    }
11922
11923}