Add test case for Flexbox layout algorithm
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit-third-party / facebook-flexbox / layout-test-utils.c
1 /**
2  * Copyright (c) 2014, Facebook, Inc.
3  * All rights reserved.
4  *
5  * This source code is licensed under the BSD-style license found in the
6  * LICENSE file in the root directory of this source tree. An additional grant
7  * of patent rights can be found in the PATENTS file in the same directory.
8  */
9
10 #include "layout-test-utils.h"
11 #include <stdlib.h>
12
13 #ifdef _MSC_VER
14 #include <float.h>
15 #define isnan _isnan
16
17 /* define fmaxf & fminf if < VC12 */
18 #if _MSC_VER < 1800
19 inline float fmaxf(const float a, const float b) {
20   return (a > b) ? a : b;
21 }
22 inline float fminf(const float a, const float b) {
23   return (a < b) ? a : b;
24 }
25 #endif
26 #endif
27
28   /** START_GENERATED **/
29 #define SMALL_WIDTH 35
30 #define SMALL_HEIGHT 18
31 #define BIG_WIDTH 172
32 #define BIG_HEIGHT 36
33 #define BIG_MIN_WIDTH 100
34 #define SMALL_TEXT "small"
35 #define LONG_TEXT "loooooooooong with space"
36 #define MEASURE_WITH_RATIO_2 "measureWithRatio2"
37 #define MEASURE_WITH_MATCH_PARENT "measureWithMatchParent"
38   /** END_GENERATED **/
39
40 typedef struct failed_test_t {
41   struct failed_test_t *next;
42   const char *name;
43   css_node_t *style;
44   css_node_t *expected;
45 } failed_test_t;
46
47 static failed_test_t *failed_test_head = NULL;
48 static failed_test_t *failed_test_tail = NULL;
49 static void add_failed_test(const char *name, css_node_t *style, css_node_t *expected) {
50   failed_test_t *failed_test = (failed_test_t *)malloc(sizeof(failed_test_t));
51   failed_test->next = NULL;
52   failed_test->name = name;
53   failed_test->style = style;
54   failed_test->expected = expected;
55
56   if (!failed_test_head) {
57     failed_test_head = failed_test;
58     failed_test_tail = failed_test;
59   } else {
60     failed_test_tail->next = failed_test;
61     failed_test_tail = failed_test;
62   }
63 }
64
65 static bool eq(float a, float b) {
66   return fabs(a - b) < 0.0001;
67 }
68
69 static bool are_layout_equal(css_node_t *a, css_node_t *b) {
70   if (!eq(a->layout.dimensions[CSS_WIDTH], b->layout.dimensions[CSS_WIDTH]) ||
71       !eq(a->layout.dimensions[CSS_HEIGHT], b->layout.dimensions[CSS_HEIGHT]) ||
72       !eq(a->layout.position[CSS_TOP], b->layout.position[CSS_TOP]) ||
73       !eq(a->layout.position[CSS_LEFT], b->layout.position[CSS_LEFT]) ||
74       !eq(a->children_count, b->children_count)) {
75     return false;
76   }
77   int i;
78   for (i = 0; i < a->children_count; ++i) {
79     if (!are_layout_equal(a->get_child(a->context, i), b->get_child(b->context, i))) {
80       return false;
81     }
82   }
83   return true;
84 }
85
86 css_dim_t measure(void *context, float width, css_measure_mode_t widthMode, float height, css_measure_mode_t heightMode) {
87   const char *text = (const char *)context;
88   css_dim_t dim;
89   if (strcmp(text, SMALL_TEXT) == 0) {
90     if (widthMode == CSS_MEASURE_MODE_UNDEFINED) {
91       width = 1000000;
92     }
93     dim.dimensions[CSS_WIDTH] = fminf(SMALL_WIDTH, width);
94     dim.dimensions[CSS_HEIGHT] = SMALL_HEIGHT;
95     return dim;
96   }
97   if (strcmp(text, LONG_TEXT) == 0) {
98     if (widthMode == CSS_MEASURE_MODE_UNDEFINED) {
99       width = 1000000;
100     }
101     dim.dimensions[CSS_WIDTH] = width >= BIG_WIDTH ? BIG_WIDTH : fmaxf(BIG_MIN_WIDTH, width);
102     dim.dimensions[CSS_HEIGHT] = width >= BIG_WIDTH ? SMALL_HEIGHT : BIG_HEIGHT;
103     return dim;
104   }
105
106   if (strcmp(text, MEASURE_WITH_RATIO_2) == 0) {
107     if (widthMode != CSS_MEASURE_MODE_UNDEFINED) {
108       dim.dimensions[CSS_WIDTH] = width;
109       dim.dimensions[CSS_HEIGHT] = width * 2;
110     } else if (heightMode != CSS_MEASURE_MODE_UNDEFINED) {
111       dim.dimensions[CSS_WIDTH] = height * 2;
112       dim.dimensions[CSS_HEIGHT] = height;
113     } else {
114       dim.dimensions[CSS_WIDTH] = 99999;
115       dim.dimensions[CSS_HEIGHT] = 99999;
116     }
117     return dim;
118   }
119
120   if (strcmp(text, MEASURE_WITH_MATCH_PARENT) == 0) {
121     if (widthMode == CSS_MEASURE_MODE_UNDEFINED) {
122       width = 99999;
123     }
124     if (heightMode == CSS_MEASURE_MODE_UNDEFINED) {
125       height = 99999;
126     }
127     dim.dimensions[CSS_WIDTH] = width;
128     dim.dimensions[CSS_HEIGHT] = height;
129     return dim;
130   }
131
132   // Should not go here
133   dim.dimensions[CSS_WIDTH] = CSS_UNDEFINED;
134   dim.dimensions[CSS_HEIGHT] = CSS_UNDEFINED;
135   return dim;
136 }
137
138 static int test_ran_count = 0;
139 void test(const char *name, css_node_t *style, css_node_t *expected_layout) {
140   ++test_ran_count;
141   layoutNode(style, CSS_UNDEFINED, CSS_UNDEFINED, (css_direction_t)-1);
142
143   if (!are_layout_equal(style, expected_layout)) {
144     printf("%sF%s", "\x1B[31m", "\x1B[0m");
145     add_failed_test(name, style, expected_layout);
146   } else {
147     printf("%s.%s", "\x1B[32m", "\x1B[0m");
148     free_css_node(style);
149     free_css_node(expected_layout);
150   }
151 }
152
153 bool tests_finished() {
154   failed_test_t *failed_test = failed_test_head;
155   printf("\n");
156
157   int tests_failed = 0;
158   while (failed_test) {
159     printf("%sFAIL%s %s\n", "\x1B[31m", "\x1B[0m", failed_test->name);
160
161     printf("Input:    ");
162     print_css_node(failed_test->style, (css_print_options_t)(CSS_PRINT_STYLE | CSS_PRINT_CHILDREN));
163     printf("Output:   ");
164     print_css_node(failed_test->style, (css_print_options_t)(CSS_PRINT_LAYOUT | CSS_PRINT_CHILDREN));
165
166     printf("Expected: ");
167     print_css_node(failed_test->expected, (css_print_options_t)(CSS_PRINT_LAYOUT | CSS_PRINT_CHILDREN));
168
169     free_css_node(failed_test->style);
170     free_css_node(failed_test->expected);
171
172     failed_test_t *next_failed_test = failed_test->next;
173     free(failed_test);
174     failed_test = next_failed_test;
175
176     tests_failed++;
177   }
178   printf("\n\n");
179
180   if (tests_failed > 0) {
181     printf("TESTS FAILED: %d\n", tests_failed);
182     return false;
183   } else {
184     printf("ALL TESTS PASSED: %d tests ran.\n", test_ran_count);
185     return true;
186   }
187 }
188
189 static css_node_t* get_child(void *context, int i) {
190   css_node_t* children = (css_node_t*)context;
191   return &children[i];
192 }
193
194 static bool is_dirty(void *context) {
195   (void)context; // remove unused warning
196   return true;
197 }
198
199 static void init_test_css_node(css_node_t *node) {
200   node->get_child = get_child;
201   node->is_dirty = is_dirty;
202 }
203
204 css_node_t *new_test_css_node(void) {
205   css_node_t *node = new_css_node();
206   init_test_css_node(node);
207   return node;
208 }
209
210 void init_css_node_children(css_node_t *node, int children_count) {
211   node->context = calloc((size_t)children_count, sizeof(css_node_t));
212   int i;
213   for (i = 0; i < children_count; ++i) {
214     init_css_node(node->get_child(node->context, i));
215     init_test_css_node(node->get_child(node->context, i));
216   }
217   node->children_count = children_count;
218 }
219
220 // @generated by transpile.html
221
222 bool perform_layout_test()
223 {
224   /** START_GENERATED **/
225   {
226     css_node_t *root_node = new_test_css_node();
227     {
228       css_node_t *node_0 = root_node;
229       node_0->style.dimensions[CSS_WIDTH] = 100;
230       node_0->style.dimensions[CSS_HEIGHT] = 200;
231     }
232
233     css_node_t *root_layout = new_test_css_node();
234     {
235       css_node_t *node_0 = root_layout;
236       node_0->layout.position[CSS_TOP] = 0;
237       node_0->layout.position[CSS_LEFT] = 0;
238       node_0->layout.dimensions[CSS_WIDTH] = 100;
239       node_0->layout.dimensions[CSS_HEIGHT] = 200;
240     }
241
242     test("should layout a single node with width and height", root_node, root_layout);
243   }
244
245   {
246     css_node_t *root_node = new_test_css_node();
247     {
248       css_node_t *node_0 = root_node;
249       node_0->style.dimensions[CSS_WIDTH] = 1000;
250       node_0->style.dimensions[CSS_HEIGHT] = 1000;
251       init_css_node_children(node_0, 3);
252       {
253         css_node_t *node_1;
254         node_1 = node_0->get_child(node_0->context, 0);
255         node_1->style.dimensions[CSS_WIDTH] = 500;
256         node_1->style.dimensions[CSS_HEIGHT] = 500;
257         node_1 = node_0->get_child(node_0->context, 1);
258         node_1->style.dimensions[CSS_WIDTH] = 250;
259         node_1->style.dimensions[CSS_HEIGHT] = 250;
260         node_1 = node_0->get_child(node_0->context, 2);
261         node_1->style.dimensions[CSS_WIDTH] = 125;
262         node_1->style.dimensions[CSS_HEIGHT] = 125;
263       }
264     }
265
266     css_node_t *root_layout = new_test_css_node();
267     {
268       css_node_t *node_0 = root_layout;
269       node_0->layout.position[CSS_TOP] = 0;
270       node_0->layout.position[CSS_LEFT] = 0;
271       node_0->layout.dimensions[CSS_WIDTH] = 1000;
272       node_0->layout.dimensions[CSS_HEIGHT] = 1000;
273       init_css_node_children(node_0, 3);
274       {
275         css_node_t *node_1;
276         node_1 = node_0->get_child(node_0->context, 0);
277         node_1->layout.position[CSS_TOP] = 0;
278         node_1->layout.position[CSS_LEFT] = 0;
279         node_1->layout.dimensions[CSS_WIDTH] = 500;
280         node_1->layout.dimensions[CSS_HEIGHT] = 500;
281         node_1 = node_0->get_child(node_0->context, 1);
282         node_1->layout.position[CSS_TOP] = 500;
283         node_1->layout.position[CSS_LEFT] = 0;
284         node_1->layout.dimensions[CSS_WIDTH] = 250;
285         node_1->layout.dimensions[CSS_HEIGHT] = 250;
286         node_1 = node_0->get_child(node_0->context, 2);
287         node_1->layout.position[CSS_TOP] = 750;
288         node_1->layout.position[CSS_LEFT] = 0;
289         node_1->layout.dimensions[CSS_WIDTH] = 125;
290         node_1->layout.dimensions[CSS_HEIGHT] = 125;
291       }
292     }
293
294     test("should layout node with children", root_node, root_layout);
295   }
296
297   {
298     css_node_t *root_node = new_test_css_node();
299     {
300       css_node_t *node_0 = root_node;
301       node_0->style.flex_direction = CSS_FLEX_DIRECTION_COLUMN_REVERSE;
302       node_0->style.dimensions[CSS_WIDTH] = 1000;
303       node_0->style.dimensions[CSS_HEIGHT] = 1000;
304       init_css_node_children(node_0, 3);
305       {
306         css_node_t *node_1;
307         node_1 = node_0->get_child(node_0->context, 0);
308         node_1->style.dimensions[CSS_WIDTH] = 500;
309         node_1->style.dimensions[CSS_HEIGHT] = 500;
310         node_1 = node_0->get_child(node_0->context, 1);
311         node_1->style.dimensions[CSS_WIDTH] = 250;
312         node_1->style.dimensions[CSS_HEIGHT] = 250;
313         node_1 = node_0->get_child(node_0->context, 2);
314         node_1->style.dimensions[CSS_WIDTH] = 125;
315         node_1->style.dimensions[CSS_HEIGHT] = 125;
316       }
317     }
318
319     css_node_t *root_layout = new_test_css_node();
320     {
321       css_node_t *node_0 = root_layout;
322       node_0->layout.position[CSS_TOP] = 0;
323       node_0->layout.position[CSS_LEFT] = 0;
324       node_0->layout.dimensions[CSS_WIDTH] = 1000;
325       node_0->layout.dimensions[CSS_HEIGHT] = 1000;
326       init_css_node_children(node_0, 3);
327       {
328         css_node_t *node_1;
329         node_1 = node_0->get_child(node_0->context, 0);
330         node_1->layout.position[CSS_TOP] = 500;
331         node_1->layout.position[CSS_LEFT] = 0;
332         node_1->layout.dimensions[CSS_WIDTH] = 500;
333         node_1->layout.dimensions[CSS_HEIGHT] = 500;
334         node_1 = node_0->get_child(node_0->context, 1);
335         node_1->layout.position[CSS_TOP] = 250;
336         node_1->layout.position[CSS_LEFT] = 0;
337         node_1->layout.dimensions[CSS_WIDTH] = 250;
338         node_1->layout.dimensions[CSS_HEIGHT] = 250;
339         node_1 = node_0->get_child(node_0->context, 2);
340         node_1->layout.position[CSS_TOP] = 125;
341         node_1->layout.position[CSS_LEFT] = 0;
342         node_1->layout.dimensions[CSS_WIDTH] = 125;
343         node_1->layout.dimensions[CSS_HEIGHT] = 125;
344       }
345     }
346
347     test("should layout node with children in reverse", root_node, root_layout);
348   }
349
350   {
351     css_node_t *root_node = new_test_css_node();
352     {
353       css_node_t *node_0 = root_node;
354       node_0->style.dimensions[CSS_WIDTH] = 1000;
355       node_0->style.dimensions[CSS_HEIGHT] = 1000;
356       init_css_node_children(node_0, 2);
357       {
358         css_node_t *node_1;
359         node_1 = node_0->get_child(node_0->context, 0);
360         node_1->style.dimensions[CSS_WIDTH] = 500;
361         node_1->style.dimensions[CSS_HEIGHT] = 500;
362         node_1 = node_0->get_child(node_0->context, 1);
363         node_1->style.dimensions[CSS_WIDTH] = 500;
364         node_1->style.dimensions[CSS_HEIGHT] = 500;
365         init_css_node_children(node_1, 2);
366         {
367           css_node_t *node_2;
368           node_2 = node_1->get_child(node_1->context, 0);
369           node_2->style.dimensions[CSS_WIDTH] = 250;
370           node_2->style.dimensions[CSS_HEIGHT] = 250;
371           node_2 = node_1->get_child(node_1->context, 1);
372           node_2->style.dimensions[CSS_WIDTH] = 250;
373           node_2->style.dimensions[CSS_HEIGHT] = 250;
374         }
375       }
376     }
377
378     css_node_t *root_layout = new_test_css_node();
379     {
380       css_node_t *node_0 = root_layout;
381       node_0->layout.position[CSS_TOP] = 0;
382       node_0->layout.position[CSS_LEFT] = 0;
383       node_0->layout.dimensions[CSS_WIDTH] = 1000;
384       node_0->layout.dimensions[CSS_HEIGHT] = 1000;
385       init_css_node_children(node_0, 2);
386       {
387         css_node_t *node_1;
388         node_1 = node_0->get_child(node_0->context, 0);
389         node_1->layout.position[CSS_TOP] = 0;
390         node_1->layout.position[CSS_LEFT] = 0;
391         node_1->layout.dimensions[CSS_WIDTH] = 500;
392         node_1->layout.dimensions[CSS_HEIGHT] = 500;
393         node_1 = node_0->get_child(node_0->context, 1);
394         node_1->layout.position[CSS_TOP] = 500;
395         node_1->layout.position[CSS_LEFT] = 0;
396         node_1->layout.dimensions[CSS_WIDTH] = 500;
397         node_1->layout.dimensions[CSS_HEIGHT] = 500;
398         init_css_node_children(node_1, 2);
399         {
400           css_node_t *node_2;
401           node_2 = node_1->get_child(node_1->context, 0);
402           node_2->layout.position[CSS_TOP] = 0;
403           node_2->layout.position[CSS_LEFT] = 0;
404           node_2->layout.dimensions[CSS_WIDTH] = 250;
405           node_2->layout.dimensions[CSS_HEIGHT] = 250;
406           node_2 = node_1->get_child(node_1->context, 1);
407           node_2->layout.position[CSS_TOP] = 250;
408           node_2->layout.position[CSS_LEFT] = 0;
409           node_2->layout.dimensions[CSS_WIDTH] = 250;
410           node_2->layout.dimensions[CSS_HEIGHT] = 250;
411         }
412       }
413     }
414
415     test("should layout node with nested children", root_node, root_layout);
416   }
417
418   {
419     css_node_t *root_node = new_test_css_node();
420     {
421       css_node_t *node_0 = root_node;
422       node_0->style.flex_direction = CSS_FLEX_DIRECTION_COLUMN_REVERSE;
423       node_0->style.dimensions[CSS_WIDTH] = 1000;
424       node_0->style.dimensions[CSS_HEIGHT] = 1000;
425       init_css_node_children(node_0, 2);
426       {
427         css_node_t *node_1;
428         node_1 = node_0->get_child(node_0->context, 0);
429         node_1->style.dimensions[CSS_WIDTH] = 500;
430         node_1->style.dimensions[CSS_HEIGHT] = 500;
431         node_1 = node_0->get_child(node_0->context, 1);
432         node_1->style.flex_direction = CSS_FLEX_DIRECTION_COLUMN_REVERSE;
433         node_1->style.dimensions[CSS_WIDTH] = 500;
434         node_1->style.dimensions[CSS_HEIGHT] = 500;
435         init_css_node_children(node_1, 2);
436         {
437           css_node_t *node_2;
438           node_2 = node_1->get_child(node_1->context, 0);
439           node_2->style.dimensions[CSS_WIDTH] = 250;
440           node_2->style.dimensions[CSS_HEIGHT] = 250;
441           node_2 = node_1->get_child(node_1->context, 1);
442           node_2->style.dimensions[CSS_WIDTH] = 250;
443           node_2->style.dimensions[CSS_HEIGHT] = 250;
444         }
445       }
446     }
447
448     css_node_t *root_layout = new_test_css_node();
449     {
450       css_node_t *node_0 = root_layout;
451       node_0->layout.position[CSS_TOP] = 0;
452       node_0->layout.position[CSS_LEFT] = 0;
453       node_0->layout.dimensions[CSS_WIDTH] = 1000;
454       node_0->layout.dimensions[CSS_HEIGHT] = 1000;
455       init_css_node_children(node_0, 2);
456       {
457         css_node_t *node_1;
458         node_1 = node_0->get_child(node_0->context, 0);
459         node_1->layout.position[CSS_TOP] = 500;
460         node_1->layout.position[CSS_LEFT] = 0;
461         node_1->layout.dimensions[CSS_WIDTH] = 500;
462         node_1->layout.dimensions[CSS_HEIGHT] = 500;
463         node_1 = node_0->get_child(node_0->context, 1);
464         node_1->layout.position[CSS_TOP] = 0;
465         node_1->layout.position[CSS_LEFT] = 0;
466         node_1->layout.dimensions[CSS_WIDTH] = 500;
467         node_1->layout.dimensions[CSS_HEIGHT] = 500;
468         init_css_node_children(node_1, 2);
469         {
470           css_node_t *node_2;
471           node_2 = node_1->get_child(node_1->context, 0);
472           node_2->layout.position[CSS_TOP] = 250;
473           node_2->layout.position[CSS_LEFT] = 0;
474           node_2->layout.dimensions[CSS_WIDTH] = 250;
475           node_2->layout.dimensions[CSS_HEIGHT] = 250;
476           node_2 = node_1->get_child(node_1->context, 1);
477           node_2->layout.position[CSS_TOP] = 0;
478           node_2->layout.position[CSS_LEFT] = 0;
479           node_2->layout.dimensions[CSS_WIDTH] = 250;
480           node_2->layout.dimensions[CSS_HEIGHT] = 250;
481         }
482       }
483     }
484
485     test("should layout node with nested children in reverse", root_node, root_layout);
486   }
487
488   {
489     css_node_t *root_node = new_test_css_node();
490     {
491       css_node_t *node_0 = root_node;
492       node_0->style.dimensions[CSS_WIDTH] = 100;
493       node_0->style.dimensions[CSS_HEIGHT] = 200;
494       node_0->style.margin[CSS_LEFT] = 10;
495       node_0->style.margin[CSS_TOP] = 10;
496       node_0->style.margin[CSS_RIGHT] = 10;
497       node_0->style.margin[CSS_BOTTOM] = 10;
498       node_0->style.margin[CSS_START] = 10;
499       node_0->style.margin[CSS_END] = 10;
500     }
501
502     css_node_t *root_layout = new_test_css_node();
503     {
504       css_node_t *node_0 = root_layout;
505       node_0->layout.position[CSS_TOP] = 10;
506       node_0->layout.position[CSS_LEFT] = 10;
507       node_0->layout.dimensions[CSS_WIDTH] = 100;
508       node_0->layout.dimensions[CSS_HEIGHT] = 200;
509     }
510
511     test("should layout node with margin", root_node, root_layout);
512   }
513
514   {
515     css_node_t *root_node = new_test_css_node();
516     {
517       css_node_t *node_0 = root_node;
518       node_0->style.dimensions[CSS_WIDTH] = 1000;
519       node_0->style.dimensions[CSS_HEIGHT] = 1000;
520       node_0->style.margin[CSS_LEFT] = 10;
521       node_0->style.margin[CSS_TOP] = 10;
522       node_0->style.margin[CSS_RIGHT] = 10;
523       node_0->style.margin[CSS_BOTTOM] = 10;
524       node_0->style.margin[CSS_START] = 10;
525       node_0->style.margin[CSS_END] = 10;
526       init_css_node_children(node_0, 3);
527       {
528         css_node_t *node_1;
529         node_1 = node_0->get_child(node_0->context, 0);
530         node_1->style.dimensions[CSS_WIDTH] = 100;
531         node_1->style.dimensions[CSS_HEIGHT] = 100;
532         node_1->style.margin[CSS_LEFT] = 50;
533         node_1->style.margin[CSS_TOP] = 50;
534         node_1->style.margin[CSS_RIGHT] = 50;
535         node_1->style.margin[CSS_BOTTOM] = 50;
536         node_1->style.margin[CSS_START] = 50;
537         node_1->style.margin[CSS_END] = 50;
538         node_1 = node_0->get_child(node_0->context, 1);
539         node_1->style.dimensions[CSS_WIDTH] = 100;
540         node_1->style.dimensions[CSS_HEIGHT] = 100;
541         node_1->style.margin[CSS_LEFT] = 25;
542         node_1->style.margin[CSS_TOP] = 25;
543         node_1->style.margin[CSS_RIGHT] = 25;
544         node_1->style.margin[CSS_BOTTOM] = 25;
545         node_1->style.margin[CSS_START] = 25;
546         node_1->style.margin[CSS_END] = 25;
547         node_1 = node_0->get_child(node_0->context, 2);
548         node_1->style.dimensions[CSS_WIDTH] = 100;
549         node_1->style.dimensions[CSS_HEIGHT] = 100;
550         node_1->style.margin[CSS_LEFT] = 10;
551         node_1->style.margin[CSS_TOP] = 10;
552         node_1->style.margin[CSS_RIGHT] = 10;
553         node_1->style.margin[CSS_BOTTOM] = 10;
554         node_1->style.margin[CSS_START] = 10;
555         node_1->style.margin[CSS_END] = 10;
556       }
557     }
558
559     css_node_t *root_layout = new_test_css_node();
560     {
561       css_node_t *node_0 = root_layout;
562       node_0->layout.position[CSS_TOP] = 10;
563       node_0->layout.position[CSS_LEFT] = 10;
564       node_0->layout.dimensions[CSS_WIDTH] = 1000;
565       node_0->layout.dimensions[CSS_HEIGHT] = 1000;
566       init_css_node_children(node_0, 3);
567       {
568         css_node_t *node_1;
569         node_1 = node_0->get_child(node_0->context, 0);
570         node_1->layout.position[CSS_TOP] = 50;
571         node_1->layout.position[CSS_LEFT] = 50;
572         node_1->layout.dimensions[CSS_WIDTH] = 100;
573         node_1->layout.dimensions[CSS_HEIGHT] = 100;
574         node_1 = node_0->get_child(node_0->context, 1);
575         node_1->layout.position[CSS_TOP] = 225;
576         node_1->layout.position[CSS_LEFT] = 25;
577         node_1->layout.dimensions[CSS_WIDTH] = 100;
578         node_1->layout.dimensions[CSS_HEIGHT] = 100;
579         node_1 = node_0->get_child(node_0->context, 2);
580         node_1->layout.position[CSS_TOP] = 360;
581         node_1->layout.position[CSS_LEFT] = 10;
582         node_1->layout.dimensions[CSS_WIDTH] = 100;
583         node_1->layout.dimensions[CSS_HEIGHT] = 100;
584       }
585     }
586
587     test("should layout node with several children", root_node, root_layout);
588   }
589
590   {
591     css_node_t *root_node = new_test_css_node();
592     {
593       css_node_t *node_0 = root_node;
594       node_0->style.flex_direction = CSS_FLEX_DIRECTION_COLUMN_REVERSE;
595       node_0->style.dimensions[CSS_WIDTH] = 1000;
596       node_0->style.dimensions[CSS_HEIGHT] = 1000;
597       node_0->style.margin[CSS_LEFT] = 10;
598       node_0->style.margin[CSS_TOP] = 10;
599       node_0->style.margin[CSS_RIGHT] = 10;
600       node_0->style.margin[CSS_BOTTOM] = 10;
601       node_0->style.margin[CSS_START] = 10;
602       node_0->style.margin[CSS_END] = 10;
603       init_css_node_children(node_0, 3);
604       {
605         css_node_t *node_1;
606         node_1 = node_0->get_child(node_0->context, 0);
607         node_1->style.dimensions[CSS_WIDTH] = 100;
608         node_1->style.dimensions[CSS_HEIGHT] = 100;
609         node_1->style.margin[CSS_LEFT] = 50;
610         node_1->style.margin[CSS_TOP] = 50;
611         node_1->style.margin[CSS_RIGHT] = 50;
612         node_1->style.margin[CSS_BOTTOM] = 50;
613         node_1->style.margin[CSS_START] = 50;
614         node_1->style.margin[CSS_END] = 50;
615         node_1 = node_0->get_child(node_0->context, 1);
616         node_1->style.dimensions[CSS_WIDTH] = 100;
617         node_1->style.dimensions[CSS_HEIGHT] = 100;
618         node_1->style.margin[CSS_LEFT] = 25;
619         node_1->style.margin[CSS_TOP] = 25;
620         node_1->style.margin[CSS_RIGHT] = 25;
621         node_1->style.margin[CSS_BOTTOM] = 25;
622         node_1->style.margin[CSS_START] = 25;
623         node_1->style.margin[CSS_END] = 25;
624         node_1 = node_0->get_child(node_0->context, 2);
625         node_1->style.dimensions[CSS_WIDTH] = 100;
626         node_1->style.dimensions[CSS_HEIGHT] = 100;
627         node_1->style.margin[CSS_LEFT] = 10;
628         node_1->style.margin[CSS_TOP] = 10;
629         node_1->style.margin[CSS_RIGHT] = 10;
630         node_1->style.margin[CSS_BOTTOM] = 10;
631         node_1->style.margin[CSS_START] = 10;
632         node_1->style.margin[CSS_END] = 10;
633       }
634     }
635
636     css_node_t *root_layout = new_test_css_node();
637     {
638       css_node_t *node_0 = root_layout;
639       node_0->layout.position[CSS_TOP] = 10;
640       node_0->layout.position[CSS_LEFT] = 10;
641       node_0->layout.dimensions[CSS_WIDTH] = 1000;
642       node_0->layout.dimensions[CSS_HEIGHT] = 1000;
643       init_css_node_children(node_0, 3);
644       {
645         css_node_t *node_1;
646         node_1 = node_0->get_child(node_0->context, 0);
647         node_1->layout.position[CSS_TOP] = 850;
648         node_1->layout.position[CSS_LEFT] = 50;
649         node_1->layout.dimensions[CSS_WIDTH] = 100;
650         node_1->layout.dimensions[CSS_HEIGHT] = 100;
651         node_1 = node_0->get_child(node_0->context, 1);
652         node_1->layout.position[CSS_TOP] = 675;
653         node_1->layout.position[CSS_LEFT] = 25;
654         node_1->layout.dimensions[CSS_WIDTH] = 100;
655         node_1->layout.dimensions[CSS_HEIGHT] = 100;
656         node_1 = node_0->get_child(node_0->context, 2);
657         node_1->layout.position[CSS_TOP] = 540;
658         node_1->layout.position[CSS_LEFT] = 10;
659         node_1->layout.dimensions[CSS_WIDTH] = 100;
660         node_1->layout.dimensions[CSS_HEIGHT] = 100;
661       }
662     }
663
664     test("should layout node with several children in reverse", root_node, root_layout);
665   }
666
667   {
668     css_node_t *root_node = new_test_css_node();
669     {
670       css_node_t *node_0 = root_node;
671       node_0->style.direction = CSS_DIRECTION_RTL;
672       node_0->style.flex_direction = CSS_FLEX_DIRECTION_ROW_REVERSE;
673       node_0->style.dimensions[CSS_WIDTH] = 1000;
674       node_0->style.dimensions[CSS_HEIGHT] = 1000;
675       init_css_node_children(node_0, 2);
676       {
677         css_node_t *node_1;
678         node_1 = node_0->get_child(node_0->context, 0);
679         node_1->style.dimensions[CSS_WIDTH] = 100;
680         node_1->style.dimensions[CSS_HEIGHT] = 200;
681         node_1 = node_0->get_child(node_0->context, 1);
682         node_1->style.dimensions[CSS_WIDTH] = 300;
683         node_1->style.dimensions[CSS_HEIGHT] = 150;
684       }
685     }
686
687     css_node_t *root_layout = new_test_css_node();
688     {
689       css_node_t *node_0 = root_layout;
690       node_0->layout.position[CSS_TOP] = 0;
691       node_0->layout.position[CSS_LEFT] = 0;
692       node_0->layout.dimensions[CSS_WIDTH] = 1000;
693       node_0->layout.dimensions[CSS_HEIGHT] = 1000;
694       init_css_node_children(node_0, 2);
695       {
696         css_node_t *node_1;
697         node_1 = node_0->get_child(node_0->context, 0);
698         node_1->layout.position[CSS_TOP] = 0;
699         node_1->layout.position[CSS_LEFT] = 0;
700         node_1->layout.dimensions[CSS_WIDTH] = 100;
701         node_1->layout.dimensions[CSS_HEIGHT] = 200;
702         node_1 = node_0->get_child(node_0->context, 1);
703         node_1->layout.position[CSS_TOP] = 0;
704         node_1->layout.position[CSS_LEFT] = 100;
705         node_1->layout.dimensions[CSS_WIDTH] = 300;
706         node_1->layout.dimensions[CSS_HEIGHT] = 150;
707       }
708     }
709
710     test("should layout rtl with reverse correctly", root_node, root_layout);
711   }
712
713   {
714     css_node_t *root_node = new_test_css_node();
715     {
716       css_node_t *node_0 = root_node;
717       node_0->style.flex_direction = CSS_FLEX_DIRECTION_ROW;
718       node_0->style.dimensions[CSS_WIDTH] = 1000;
719       node_0->style.dimensions[CSS_HEIGHT] = 1000;
720       init_css_node_children(node_0, 2);
721       {
722         css_node_t *node_1;
723         node_1 = node_0->get_child(node_0->context, 0);
724         node_1->style.dimensions[CSS_WIDTH] = 100;
725         node_1->style.dimensions[CSS_HEIGHT] = 200;
726         node_1 = node_0->get_child(node_0->context, 1);
727         node_1->style.dimensions[CSS_WIDTH] = 300;
728         node_1->style.dimensions[CSS_HEIGHT] = 150;
729       }
730     }
731
732     css_node_t *root_layout = new_test_css_node();
733     {
734       css_node_t *node_0 = root_layout;
735       node_0->layout.position[CSS_TOP] = 0;
736       node_0->layout.position[CSS_LEFT] = 0;
737       node_0->layout.dimensions[CSS_WIDTH] = 1000;
738       node_0->layout.dimensions[CSS_HEIGHT] = 1000;
739       init_css_node_children(node_0, 2);
740       {
741         css_node_t *node_1;
742         node_1 = node_0->get_child(node_0->context, 0);
743         node_1->layout.position[CSS_TOP] = 0;
744         node_1->layout.position[CSS_LEFT] = 0;
745         node_1->layout.dimensions[CSS_WIDTH] = 100;
746         node_1->layout.dimensions[CSS_HEIGHT] = 200;
747         node_1 = node_0->get_child(node_0->context, 1);
748         node_1->layout.position[CSS_TOP] = 0;
749         node_1->layout.position[CSS_LEFT] = 100;
750         node_1->layout.dimensions[CSS_WIDTH] = 300;
751         node_1->layout.dimensions[CSS_HEIGHT] = 150;
752       }
753     }
754
755     test("should layout node with row flex direction", root_node, root_layout);
756   }
757
758   {
759     css_node_t *root_node = new_test_css_node();
760     {
761       css_node_t *node_0 = root_node;
762       node_0->style.direction = CSS_DIRECTION_RTL;
763       node_0->style.flex_direction = CSS_FLEX_DIRECTION_ROW;
764       node_0->style.dimensions[CSS_WIDTH] = 1000;
765       node_0->style.dimensions[CSS_HEIGHT] = 1000;
766       init_css_node_children(node_0, 2);
767       {
768         css_node_t *node_1;
769         node_1 = node_0->get_child(node_0->context, 0);
770         node_1->style.dimensions[CSS_WIDTH] = 100;
771         node_1->style.dimensions[CSS_HEIGHT] = 200;
772         node_1 = node_0->get_child(node_0->context, 1);
773         node_1->style.dimensions[CSS_WIDTH] = 300;
774         node_1->style.dimensions[CSS_HEIGHT] = 150;
775       }
776     }
777
778     css_node_t *root_layout = new_test_css_node();
779     {
780       css_node_t *node_0 = root_layout;
781       node_0->layout.position[CSS_TOP] = 0;
782       node_0->layout.position[CSS_LEFT] = 0;
783       node_0->layout.dimensions[CSS_WIDTH] = 1000;
784       node_0->layout.dimensions[CSS_HEIGHT] = 1000;
785       init_css_node_children(node_0, 2);
786       {
787         css_node_t *node_1;
788         node_1 = node_0->get_child(node_0->context, 0);
789         node_1->layout.position[CSS_TOP] = 0;
790         node_1->layout.position[CSS_LEFT] = 900;
791         node_1->layout.dimensions[CSS_WIDTH] = 100;
792         node_1->layout.dimensions[CSS_HEIGHT] = 200;
793         node_1 = node_0->get_child(node_0->context, 1);
794         node_1->layout.position[CSS_TOP] = 0;
795         node_1->layout.position[CSS_LEFT] = 600;
796         node_1->layout.dimensions[CSS_WIDTH] = 300;
797         node_1->layout.dimensions[CSS_HEIGHT] = 150;
798       }
799     }
800
801     test("should layout node with row flex direction in rtl", root_node, root_layout);
802   }
803
804   {
805     css_node_t *root_node = new_test_css_node();
806     {
807       css_node_t *node_0 = root_node;
808       node_0->style.dimensions[CSS_WIDTH] = 300;
809       init_css_node_children(node_0, 2);
810       {
811         css_node_t *node_1;
812         node_1 = node_0->get_child(node_0->context, 0);
813         node_1->style.dimensions[CSS_WIDTH] = 100;
814         node_1->style.dimensions[CSS_HEIGHT] = 200;
815         node_1 = node_0->get_child(node_0->context, 1);
816         node_1->style.dimensions[CSS_WIDTH] = 300;
817         node_1->style.dimensions[CSS_HEIGHT] = 150;
818       }
819     }
820
821     css_node_t *root_layout = new_test_css_node();
822     {
823       css_node_t *node_0 = root_layout;
824       node_0->layout.position[CSS_TOP] = 0;
825       node_0->layout.position[CSS_LEFT] = 0;
826       node_0->layout.dimensions[CSS_WIDTH] = 300;
827       node_0->layout.dimensions[CSS_HEIGHT] = 350;
828       init_css_node_children(node_0, 2);
829       {
830         css_node_t *node_1;
831         node_1 = node_0->get_child(node_0->context, 0);
832         node_1->layout.position[CSS_TOP] = 0;
833         node_1->layout.position[CSS_LEFT] = 0;
834         node_1->layout.dimensions[CSS_WIDTH] = 100;
835         node_1->layout.dimensions[CSS_HEIGHT] = 200;
836         node_1 = node_0->get_child(node_0->context, 1);
837         node_1->layout.position[CSS_TOP] = 200;
838         node_1->layout.position[CSS_LEFT] = 0;
839         node_1->layout.dimensions[CSS_WIDTH] = 300;
840         node_1->layout.dimensions[CSS_HEIGHT] = 150;
841       }
842     }
843
844     test("should layout node based on children main dimensions", root_node, root_layout);
845   }
846
847   {
848     css_node_t *root_node = new_test_css_node();
849     {
850       css_node_t *node_0 = root_node;
851       node_0->style.flex_direction = CSS_FLEX_DIRECTION_COLUMN_REVERSE;
852       node_0->style.dimensions[CSS_WIDTH] = 300;
853       init_css_node_children(node_0, 2);
854       {
855         css_node_t *node_1;
856         node_1 = node_0->get_child(node_0->context, 0);
857         node_1->style.dimensions[CSS_WIDTH] = 100;
858         node_1->style.dimensions[CSS_HEIGHT] = 200;
859         node_1 = node_0->get_child(node_0->context, 1);
860         node_1->style.dimensions[CSS_WIDTH] = 300;
861         node_1->style.dimensions[CSS_HEIGHT] = 150;
862       }
863     }
864
865     css_node_t *root_layout = new_test_css_node();
866     {
867       css_node_t *node_0 = root_layout;
868       node_0->layout.position[CSS_TOP] = 0;
869       node_0->layout.position[CSS_LEFT] = 0;
870       node_0->layout.dimensions[CSS_WIDTH] = 300;
871       node_0->layout.dimensions[CSS_HEIGHT] = 350;
872       init_css_node_children(node_0, 2);
873       {
874         css_node_t *node_1;
875         node_1 = node_0->get_child(node_0->context, 0);
876         node_1->layout.position[CSS_TOP] = 150;
877         node_1->layout.position[CSS_LEFT] = 0;
878         node_1->layout.dimensions[CSS_WIDTH] = 100;
879         node_1->layout.dimensions[CSS_HEIGHT] = 200;
880         node_1 = node_0->get_child(node_0->context, 1);
881         node_1->layout.position[CSS_TOP] = 0;
882         node_1->layout.position[CSS_LEFT] = 0;
883         node_1->layout.dimensions[CSS_WIDTH] = 300;
884         node_1->layout.dimensions[CSS_HEIGHT] = 150;
885       }
886     }
887
888     test("should layout node based on children main dimensions in reverse", root_node, root_layout);
889   }
890
891   {
892     css_node_t *root_node = new_test_css_node();
893     {
894       css_node_t *node_0 = root_node;
895       node_0->style.dimensions[CSS_WIDTH] = 1000;
896       node_0->style.dimensions[CSS_HEIGHT] = 1000;
897       init_css_node_children(node_0, 2);
898       {
899         css_node_t *node_1;
900         node_1 = node_0->get_child(node_0->context, 0);
901         node_1->style.dimensions[CSS_WIDTH] = 100;
902         node_1->style.dimensions[CSS_HEIGHT] = 200;
903         node_1 = node_0->get_child(node_0->context, 1);
904         node_1->style.flex = 1;
905         node_1->style.dimensions[CSS_WIDTH] = 100;
906       }
907     }
908
909     css_node_t *root_layout = new_test_css_node();
910     {
911       css_node_t *node_0 = root_layout;
912       node_0->layout.position[CSS_TOP] = 0;
913       node_0->layout.position[CSS_LEFT] = 0;
914       node_0->layout.dimensions[CSS_WIDTH] = 1000;
915       node_0->layout.dimensions[CSS_HEIGHT] = 1000;
916       init_css_node_children(node_0, 2);
917       {
918         css_node_t *node_1;
919         node_1 = node_0->get_child(node_0->context, 0);
920         node_1->layout.position[CSS_TOP] = 0;
921         node_1->layout.position[CSS_LEFT] = 0;
922         node_1->layout.dimensions[CSS_WIDTH] = 100;
923         node_1->layout.dimensions[CSS_HEIGHT] = 200;
924         node_1 = node_0->get_child(node_0->context, 1);
925         node_1->layout.position[CSS_TOP] = 200;
926         node_1->layout.position[CSS_LEFT] = 0;
927         node_1->layout.dimensions[CSS_WIDTH] = 100;
928         node_1->layout.dimensions[CSS_HEIGHT] = 800;
929       }
930     }
931
932     test("should layout node with just flex", root_node, root_layout);
933   }
934
935   {
936     css_node_t *root_node = new_test_css_node();
937     {
938       css_node_t *node_0 = root_node;
939       node_0->style.flex_direction = CSS_FLEX_DIRECTION_COLUMN_REVERSE;
940       node_0->style.dimensions[CSS_WIDTH] = 1000;
941       node_0->style.dimensions[CSS_HEIGHT] = 1000;
942       init_css_node_children(node_0, 2);
943       {
944         css_node_t *node_1;
945         node_1 = node_0->get_child(node_0->context, 0);
946         node_1->style.dimensions[CSS_WIDTH] = 100;
947         node_1->style.dimensions[CSS_HEIGHT] = 200;
948         node_1 = node_0->get_child(node_0->context, 1);
949         node_1->style.flex = 1;
950         node_1->style.dimensions[CSS_WIDTH] = 100;
951       }
952     }
953
954     css_node_t *root_layout = new_test_css_node();
955     {
956       css_node_t *node_0 = root_layout;
957       node_0->layout.position[CSS_TOP] = 0;
958       node_0->layout.position[CSS_LEFT] = 0;
959       node_0->layout.dimensions[CSS_WIDTH] = 1000;
960       node_0->layout.dimensions[CSS_HEIGHT] = 1000;
961       init_css_node_children(node_0, 2);
962       {
963         css_node_t *node_1;
964         node_1 = node_0->get_child(node_0->context, 0);
965         node_1->layout.position[CSS_TOP] = 800;
966         node_1->layout.position[CSS_LEFT] = 0;
967         node_1->layout.dimensions[CSS_WIDTH] = 100;
968         node_1->layout.dimensions[CSS_HEIGHT] = 200;
969         node_1 = node_0->get_child(node_0->context, 1);
970         node_1->layout.position[CSS_TOP] = 0;
971         node_1->layout.position[CSS_LEFT] = 0;
972         node_1->layout.dimensions[CSS_WIDTH] = 100;
973         node_1->layout.dimensions[CSS_HEIGHT] = 800;
974       }
975     }
976
977     test("should layout node with just flex in reverse", root_node, root_layout);
978   }
979
980   {
981     css_node_t *root_node = new_test_css_node();
982     {
983       css_node_t *node_0 = root_node;
984       node_0->style.dimensions[CSS_WIDTH] = 1000;
985       node_0->style.dimensions[CSS_HEIGHT] = 1000;
986       init_css_node_children(node_0, 1);
987       {
988         css_node_t *node_1;
989         node_1 = node_0->get_child(node_0->context, 0);
990         node_1->style.flex = 1;
991         node_1->style.dimensions[CSS_WIDTH] = 1000;
992         init_css_node_children(node_1, 1);
993         {
994           css_node_t *node_2;
995           node_2 = node_1->get_child(node_1->context, 0);
996           node_2->style.flex = 1;
997           node_2->style.dimensions[CSS_WIDTH] = 1000;
998           init_css_node_children(node_2, 1);
999           {
1000             css_node_t *node_3;
1001             node_3 = node_2->get_child(node_2->context, 0);
1002             node_3->style.flex = 1;
1003             node_3->style.dimensions[CSS_WIDTH] = 1000;
1004           }
1005         }
1006       }
1007     }
1008
1009     css_node_t *root_layout = new_test_css_node();
1010     {
1011       css_node_t *node_0 = root_layout;
1012       node_0->layout.position[CSS_TOP] = 0;
1013       node_0->layout.position[CSS_LEFT] = 0;
1014       node_0->layout.dimensions[CSS_WIDTH] = 1000;
1015       node_0->layout.dimensions[CSS_HEIGHT] = 1000;
1016       init_css_node_children(node_0, 1);
1017       {
1018         css_node_t *node_1;
1019         node_1 = node_0->get_child(node_0->context, 0);
1020         node_1->layout.position[CSS_TOP] = 0;
1021         node_1->layout.position[CSS_LEFT] = 0;
1022         node_1->layout.dimensions[CSS_WIDTH] = 1000;
1023         node_1->layout.dimensions[CSS_HEIGHT] = 1000;
1024         init_css_node_children(node_1, 1);
1025         {
1026           css_node_t *node_2;
1027           node_2 = node_1->get_child(node_1->context, 0);
1028           node_2->layout.position[CSS_TOP] = 0;
1029           node_2->layout.position[CSS_LEFT] = 0;
1030           node_2->layout.dimensions[CSS_WIDTH] = 1000;
1031           node_2->layout.dimensions[CSS_HEIGHT] = 1000;
1032           init_css_node_children(node_2, 1);
1033           {
1034             css_node_t *node_3;
1035             node_3 = node_2->get_child(node_2->context, 0);
1036             node_3->layout.position[CSS_TOP] = 0;
1037             node_3->layout.position[CSS_LEFT] = 0;
1038             node_3->layout.dimensions[CSS_WIDTH] = 1000;
1039             node_3->layout.dimensions[CSS_HEIGHT] = 1000;
1040           }
1041         }
1042       }
1043     }
1044
1045     test("should layout node with flex recursively", root_node, root_layout);
1046   }
1047
1048   {
1049     css_node_t *root_node = new_test_css_node();
1050     {
1051       css_node_t *node_0 = root_node;
1052       node_0->style.flex_direction = CSS_FLEX_DIRECTION_COLUMN_REVERSE;
1053       node_0->style.dimensions[CSS_WIDTH] = 1000;
1054       node_0->style.dimensions[CSS_HEIGHT] = 1000;
1055       init_css_node_children(node_0, 1);
1056       {
1057         css_node_t *node_1;
1058         node_1 = node_0->get_child(node_0->context, 0);
1059         node_1->style.flex_direction = CSS_FLEX_DIRECTION_COLUMN_REVERSE;
1060         node_1->style.flex = 1;
1061         node_1->style.dimensions[CSS_WIDTH] = 1000;
1062         init_css_node_children(node_1, 1);
1063         {
1064           css_node_t *node_2;
1065           node_2 = node_1->get_child(node_1->context, 0);
1066           node_2->style.flex_direction = CSS_FLEX_DIRECTION_COLUMN_REVERSE;
1067           node_2->style.flex = 1;
1068           node_2->style.dimensions[CSS_WIDTH] = 1000;
1069           init_css_node_children(node_2, 1);
1070           {
1071             css_node_t *node_3;
1072             node_3 = node_2->get_child(node_2->context, 0);
1073             node_3->style.flex_direction = CSS_FLEX_DIRECTION_COLUMN_REVERSE;
1074             node_3->style.flex = 1;
1075             node_3->style.dimensions[CSS_WIDTH] = 1000;
1076           }
1077         }
1078       }
1079     }
1080
1081     css_node_t *root_layout = new_test_css_node();
1082     {
1083       css_node_t *node_0 = root_layout;
1084       node_0->layout.position[CSS_TOP] = 0;
1085       node_0->layout.position[CSS_LEFT] = 0;
1086       node_0->layout.dimensions[CSS_WIDTH] = 1000;
1087       node_0->layout.dimensions[CSS_HEIGHT] = 1000;
1088       init_css_node_children(node_0, 1);
1089       {
1090         css_node_t *node_1;
1091         node_1 = node_0->get_child(node_0->context, 0);
1092         node_1->layout.position[CSS_TOP] = 0;
1093         node_1->layout.position[CSS_LEFT] = 0;
1094         node_1->layout.dimensions[CSS_WIDTH] = 1000;
1095         node_1->layout.dimensions[CSS_HEIGHT] = 1000;
1096         init_css_node_children(node_1, 1);
1097         {
1098           css_node_t *node_2;
1099           node_2 = node_1->get_child(node_1->context, 0);
1100           node_2->layout.position[CSS_TOP] = 0;
1101           node_2->layout.position[CSS_LEFT] = 0;
1102           node_2->layout.dimensions[CSS_WIDTH] = 1000;
1103           node_2->layout.dimensions[CSS_HEIGHT] = 1000;
1104           init_css_node_children(node_2, 1);
1105           {
1106             css_node_t *node_3;
1107             node_3 = node_2->get_child(node_2->context, 0);
1108             node_3->layout.position[CSS_TOP] = 0;
1109             node_3->layout.position[CSS_LEFT] = 0;
1110             node_3->layout.dimensions[CSS_WIDTH] = 1000;
1111             node_3->layout.dimensions[CSS_HEIGHT] = 1000;
1112           }
1113         }
1114       }
1115     }
1116
1117     test("should layout node with flex recursively in reverse", root_node, root_layout);
1118   }
1119
1120   {
1121     css_node_t *root_node = new_test_css_node();
1122     {
1123       css_node_t *node_0 = root_node;
1124       node_0->style.dimensions[CSS_WIDTH] = 1000;
1125       node_0->style.dimensions[CSS_HEIGHT] = 1000;
1126       node_0->style.margin[CSS_LEFT] = 5;
1127       node_0->style.margin[CSS_TOP] = 10;
1128       init_css_node_children(node_0, 2);
1129       {
1130         css_node_t *node_1;
1131         node_1 = node_0->get_child(node_0->context, 0);
1132         node_1->style.dimensions[CSS_WIDTH] = 100;
1133         node_1->style.dimensions[CSS_HEIGHT] = 100;
1134         node_1->style.margin[CSS_LEFT] = 15;
1135         node_1->style.margin[CSS_TOP] = 50;
1136         node_1->style.margin[CSS_BOTTOM] = 20;
1137         node_1 = node_0->get_child(node_0->context, 1);
1138         node_1->style.dimensions[CSS_WIDTH] = 100;
1139         node_1->style.dimensions[CSS_HEIGHT] = 100;
1140         node_1->style.margin[CSS_LEFT] = 30;
1141       }
1142     }
1143
1144     css_node_t *root_layout = new_test_css_node();
1145     {
1146       css_node_t *node_0 = root_layout;
1147       node_0->layout.position[CSS_TOP] = 10;
1148       node_0->layout.position[CSS_LEFT] = 5;
1149       node_0->layout.dimensions[CSS_WIDTH] = 1000;
1150       node_0->layout.dimensions[CSS_HEIGHT] = 1000;
1151       init_css_node_children(node_0, 2);
1152       {
1153         css_node_t *node_1;
1154         node_1 = node_0->get_child(node_0->context, 0);
1155         node_1->layout.position[CSS_TOP] = 50;
1156         node_1->layout.position[CSS_LEFT] = 15;
1157         node_1->layout.dimensions[CSS_WIDTH] = 100;
1158         node_1->layout.dimensions[CSS_HEIGHT] = 100;
1159         node_1 = node_0->get_child(node_0->context, 1);
1160         node_1->layout.position[CSS_TOP] = 170;
1161         node_1->layout.position[CSS_LEFT] = 30;
1162         node_1->layout.dimensions[CSS_WIDTH] = 100;
1163         node_1->layout.dimensions[CSS_HEIGHT] = 100;
1164       }
1165     }
1166
1167     test("should layout node with targeted margin", root_node, root_layout);
1168   }
1169
1170   {
1171     css_node_t *root_node = new_test_css_node();
1172     {
1173       css_node_t *node_0 = root_node;
1174       node_0->style.flex_direction = CSS_FLEX_DIRECTION_COLUMN_REVERSE;
1175       node_0->style.dimensions[CSS_WIDTH] = 1000;
1176       node_0->style.dimensions[CSS_HEIGHT] = 1000;
1177       node_0->style.margin[CSS_LEFT] = 5;
1178       node_0->style.margin[CSS_TOP] = 10;
1179       init_css_node_children(node_0, 2);
1180       {
1181         css_node_t *node_1;
1182         node_1 = node_0->get_child(node_0->context, 0);
1183         node_1->style.dimensions[CSS_WIDTH] = 100;
1184         node_1->style.dimensions[CSS_HEIGHT] = 100;
1185         node_1->style.margin[CSS_LEFT] = 15;
1186         node_1->style.margin[CSS_TOP] = 50;
1187         node_1->style.margin[CSS_BOTTOM] = 20;
1188         node_1 = node_0->get_child(node_0->context, 1);
1189         node_1->style.dimensions[CSS_WIDTH] = 100;
1190         node_1->style.dimensions[CSS_HEIGHT] = 100;
1191         node_1->style.margin[CSS_LEFT] = 30;
1192       }
1193     }
1194
1195     css_node_t *root_layout = new_test_css_node();
1196     {
1197       css_node_t *node_0 = root_layout;
1198       node_0->layout.position[CSS_TOP] = 10;
1199       node_0->layout.position[CSS_LEFT] = 5;
1200       node_0->layout.dimensions[CSS_WIDTH] = 1000;
1201       node_0->layout.dimensions[CSS_HEIGHT] = 1000;
1202       init_css_node_children(node_0, 2);
1203       {
1204         css_node_t *node_1;
1205         node_1 = node_0->get_child(node_0->context, 0);
1206         node_1->layout.position[CSS_TOP] = 880;
1207         node_1->layout.position[CSS_LEFT] = 15;
1208         node_1->layout.dimensions[CSS_WIDTH] = 100;
1209         node_1->layout.dimensions[CSS_HEIGHT] = 100;
1210         node_1 = node_0->get_child(node_0->context, 1);
1211         node_1->layout.position[CSS_TOP] = 730;
1212         node_1->layout.position[CSS_LEFT] = 30;
1213         node_1->layout.dimensions[CSS_WIDTH] = 100;
1214         node_1->layout.dimensions[CSS_HEIGHT] = 100;
1215       }
1216     }
1217
1218     test("should layout node with targeted margin in reverse", root_node, root_layout);
1219   }
1220
1221   {
1222     css_node_t *root_node = new_test_css_node();
1223     {
1224       css_node_t *node_0 = root_node;
1225       node_0->style.justify_content = CSS_JUSTIFY_FLEX_START;
1226       node_0->style.dimensions[CSS_WIDTH] = 1000;
1227       node_0->style.dimensions[CSS_HEIGHT] = 1000;
1228       init_css_node_children(node_0, 2);
1229       {
1230         css_node_t *node_1;
1231         node_1 = node_0->get_child(node_0->context, 0);
1232         node_1->style.dimensions[CSS_WIDTH] = 100;
1233         node_1->style.dimensions[CSS_HEIGHT] = 100;
1234         node_1 = node_0->get_child(node_0->context, 1);
1235         node_1->style.dimensions[CSS_WIDTH] = 100;
1236         node_1->style.dimensions[CSS_HEIGHT] = 100;
1237       }
1238     }
1239
1240     css_node_t *root_layout = new_test_css_node();
1241     {
1242       css_node_t *node_0 = root_layout;
1243       node_0->layout.position[CSS_TOP] = 0;
1244       node_0->layout.position[CSS_LEFT] = 0;
1245       node_0->layout.dimensions[CSS_WIDTH] = 1000;
1246       node_0->layout.dimensions[CSS_HEIGHT] = 1000;
1247       init_css_node_children(node_0, 2);
1248       {
1249         css_node_t *node_1;
1250         node_1 = node_0->get_child(node_0->context, 0);
1251         node_1->layout.position[CSS_TOP] = 0;
1252         node_1->layout.position[CSS_LEFT] = 0;
1253         node_1->layout.dimensions[CSS_WIDTH] = 100;
1254         node_1->layout.dimensions[CSS_HEIGHT] = 100;
1255         node_1 = node_0->get_child(node_0->context, 1);
1256         node_1->layout.position[CSS_TOP] = 100;
1257         node_1->layout.position[CSS_LEFT] = 0;
1258         node_1->layout.dimensions[CSS_WIDTH] = 100;
1259         node_1->layout.dimensions[CSS_HEIGHT] = 100;
1260       }
1261     }
1262
1263     test("should layout node with justifyContent: flex-start", root_node, root_layout);
1264   }
1265
1266   {
1267     css_node_t *root_node = new_test_css_node();
1268     {
1269       css_node_t *node_0 = root_node;
1270       node_0->style.flex_direction = CSS_FLEX_DIRECTION_COLUMN_REVERSE;
1271       node_0->style.justify_content = CSS_JUSTIFY_FLEX_START;
1272       node_0->style.dimensions[CSS_WIDTH] = 1000;
1273       node_0->style.dimensions[CSS_HEIGHT] = 1000;
1274       init_css_node_children(node_0, 2);
1275       {
1276         css_node_t *node_1;
1277         node_1 = node_0->get_child(node_0->context, 0);
1278         node_1->style.dimensions[CSS_WIDTH] = 100;
1279         node_1->style.dimensions[CSS_HEIGHT] = 100;
1280         node_1 = node_0->get_child(node_0->context, 1);
1281         node_1->style.dimensions[CSS_WIDTH] = 100;
1282         node_1->style.dimensions[CSS_HEIGHT] = 100;
1283       }
1284     }
1285
1286     css_node_t *root_layout = new_test_css_node();
1287     {
1288       css_node_t *node_0 = root_layout;
1289       node_0->layout.position[CSS_TOP] = 0;
1290       node_0->layout.position[CSS_LEFT] = 0;
1291       node_0->layout.dimensions[CSS_WIDTH] = 1000;
1292       node_0->layout.dimensions[CSS_HEIGHT] = 1000;
1293       init_css_node_children(node_0, 2);
1294       {
1295         css_node_t *node_1;
1296         node_1 = node_0->get_child(node_0->context, 0);
1297         node_1->layout.position[CSS_TOP] = 900;
1298         node_1->layout.position[CSS_LEFT] = 0;
1299         node_1->layout.dimensions[CSS_WIDTH] = 100;
1300         node_1->layout.dimensions[CSS_HEIGHT] = 100;
1301         node_1 = node_0->get_child(node_0->context, 1);
1302         node_1->layout.position[CSS_TOP] = 800;
1303         node_1->layout.position[CSS_LEFT] = 0;
1304         node_1->layout.dimensions[CSS_WIDTH] = 100;
1305         node_1->layout.dimensions[CSS_HEIGHT] = 100;
1306       }
1307     }
1308
1309     test("should layout node with justifyContent: flex-start in reverse", root_node, root_layout);
1310   }
1311
1312   {
1313     css_node_t *root_node = new_test_css_node();
1314     {
1315       css_node_t *node_0 = root_node;
1316       node_0->style.justify_content = CSS_JUSTIFY_FLEX_END;
1317       node_0->style.dimensions[CSS_WIDTH] = 1000;
1318       node_0->style.dimensions[CSS_HEIGHT] = 1000;
1319       init_css_node_children(node_0, 2);
1320       {
1321         css_node_t *node_1;
1322         node_1 = node_0->get_child(node_0->context, 0);
1323         node_1->style.dimensions[CSS_WIDTH] = 100;
1324         node_1->style.dimensions[CSS_HEIGHT] = 100;
1325         node_1 = node_0->get_child(node_0->context, 1);
1326         node_1->style.dimensions[CSS_WIDTH] = 100;
1327         node_1->style.dimensions[CSS_HEIGHT] = 100;
1328       }
1329     }
1330
1331     css_node_t *root_layout = new_test_css_node();
1332     {
1333       css_node_t *node_0 = root_layout;
1334       node_0->layout.position[CSS_TOP] = 0;
1335       node_0->layout.position[CSS_LEFT] = 0;
1336       node_0->layout.dimensions[CSS_WIDTH] = 1000;
1337       node_0->layout.dimensions[CSS_HEIGHT] = 1000;
1338       init_css_node_children(node_0, 2);
1339       {
1340         css_node_t *node_1;
1341         node_1 = node_0->get_child(node_0->context, 0);
1342         node_1->layout.position[CSS_TOP] = 800;
1343         node_1->layout.position[CSS_LEFT] = 0;
1344         node_1->layout.dimensions[CSS_WIDTH] = 100;
1345         node_1->layout.dimensions[CSS_HEIGHT] = 100;
1346         node_1 = node_0->get_child(node_0->context, 1);
1347         node_1->layout.position[CSS_TOP] = 900;
1348         node_1->layout.position[CSS_LEFT] = 0;
1349         node_1->layout.dimensions[CSS_WIDTH] = 100;
1350         node_1->layout.dimensions[CSS_HEIGHT] = 100;
1351       }
1352     }
1353
1354     test("should layout node with justifyContent: flex-end", root_node, root_layout);
1355   }
1356
1357   {
1358     css_node_t *root_node = new_test_css_node();
1359     {
1360       css_node_t *node_0 = root_node;
1361       node_0->style.flex_direction = CSS_FLEX_DIRECTION_COLUMN_REVERSE;
1362       node_0->style.justify_content = CSS_JUSTIFY_FLEX_END;
1363       node_0->style.dimensions[CSS_WIDTH] = 1000;
1364       node_0->style.dimensions[CSS_HEIGHT] = 1000;
1365       init_css_node_children(node_0, 2);
1366       {
1367         css_node_t *node_1;
1368         node_1 = node_0->get_child(node_0->context, 0);
1369         node_1->style.dimensions[CSS_WIDTH] = 100;
1370         node_1->style.dimensions[CSS_HEIGHT] = 100;
1371         node_1 = node_0->get_child(node_0->context, 1);
1372         node_1->style.dimensions[CSS_WIDTH] = 100;
1373         node_1->style.dimensions[CSS_HEIGHT] = 100;
1374       }
1375     }
1376
1377     css_node_t *root_layout = new_test_css_node();
1378     {
1379       css_node_t *node_0 = root_layout;
1380       node_0->layout.position[CSS_TOP] = 0;
1381       node_0->layout.position[CSS_LEFT] = 0;
1382       node_0->layout.dimensions[CSS_WIDTH] = 1000;
1383       node_0->layout.dimensions[CSS_HEIGHT] = 1000;
1384       init_css_node_children(node_0, 2);
1385       {
1386         css_node_t *node_1;
1387         node_1 = node_0->get_child(node_0->context, 0);
1388         node_1->layout.position[CSS_TOP] = 100;
1389         node_1->layout.position[CSS_LEFT] = 0;
1390         node_1->layout.dimensions[CSS_WIDTH] = 100;
1391         node_1->layout.dimensions[CSS_HEIGHT] = 100;
1392         node_1 = node_0->get_child(node_0->context, 1);
1393         node_1->layout.position[CSS_TOP] = 0;
1394         node_1->layout.position[CSS_LEFT] = 0;
1395         node_1->layout.dimensions[CSS_WIDTH] = 100;
1396         node_1->layout.dimensions[CSS_HEIGHT] = 100;
1397       }
1398     }
1399
1400     test("should layout node with justifyContent: flex-end in reverse", root_node, root_layout);
1401   }
1402
1403   {
1404     css_node_t *root_node = new_test_css_node();
1405     {
1406       css_node_t *node_0 = root_node;
1407       node_0->style.justify_content = CSS_JUSTIFY_SPACE_BETWEEN;
1408       node_0->style.dimensions[CSS_WIDTH] = 1000;
1409       node_0->style.dimensions[CSS_HEIGHT] = 1000;
1410       init_css_node_children(node_0, 2);
1411       {
1412         css_node_t *node_1;
1413         node_1 = node_0->get_child(node_0->context, 0);
1414         node_1->style.dimensions[CSS_WIDTH] = 100;
1415         node_1->style.dimensions[CSS_HEIGHT] = 100;
1416         node_1 = node_0->get_child(node_0->context, 1);
1417         node_1->style.dimensions[CSS_WIDTH] = 100;
1418         node_1->style.dimensions[CSS_HEIGHT] = 100;
1419       }
1420     }
1421
1422     css_node_t *root_layout = new_test_css_node();
1423     {
1424       css_node_t *node_0 = root_layout;
1425       node_0->layout.position[CSS_TOP] = 0;
1426       node_0->layout.position[CSS_LEFT] = 0;
1427       node_0->layout.dimensions[CSS_WIDTH] = 1000;
1428       node_0->layout.dimensions[CSS_HEIGHT] = 1000;
1429       init_css_node_children(node_0, 2);
1430       {
1431         css_node_t *node_1;
1432         node_1 = node_0->get_child(node_0->context, 0);
1433         node_1->layout.position[CSS_TOP] = 0;
1434         node_1->layout.position[CSS_LEFT] = 0;
1435         node_1->layout.dimensions[CSS_WIDTH] = 100;
1436         node_1->layout.dimensions[CSS_HEIGHT] = 100;
1437         node_1 = node_0->get_child(node_0->context, 1);
1438         node_1->layout.position[CSS_TOP] = 900;
1439         node_1->layout.position[CSS_LEFT] = 0;
1440         node_1->layout.dimensions[CSS_WIDTH] = 100;
1441         node_1->layout.dimensions[CSS_HEIGHT] = 100;
1442       }
1443     }
1444
1445     test("should layout node with justifyContent: space-between", root_node, root_layout);
1446   }
1447
1448   {
1449     css_node_t *root_node = new_test_css_node();
1450     {
1451       css_node_t *node_0 = root_node;
1452       node_0->style.flex_direction = CSS_FLEX_DIRECTION_COLUMN_REVERSE;
1453       node_0->style.justify_content = CSS_JUSTIFY_SPACE_BETWEEN;
1454       node_0->style.dimensions[CSS_WIDTH] = 1000;
1455       node_0->style.dimensions[CSS_HEIGHT] = 1000;
1456       init_css_node_children(node_0, 2);
1457       {
1458         css_node_t *node_1;
1459         node_1 = node_0->get_child(node_0->context, 0);
1460         node_1->style.dimensions[CSS_WIDTH] = 100;
1461         node_1->style.dimensions[CSS_HEIGHT] = 100;
1462         node_1 = node_0->get_child(node_0->context, 1);
1463         node_1->style.dimensions[CSS_WIDTH] = 100;
1464         node_1->style.dimensions[CSS_HEIGHT] = 100;
1465       }
1466     }
1467
1468     css_node_t *root_layout = new_test_css_node();
1469     {
1470       css_node_t *node_0 = root_layout;
1471       node_0->layout.position[CSS_TOP] = 0;
1472       node_0->layout.position[CSS_LEFT] = 0;
1473       node_0->layout.dimensions[CSS_WIDTH] = 1000;
1474       node_0->layout.dimensions[CSS_HEIGHT] = 1000;
1475       init_css_node_children(node_0, 2);
1476       {
1477         css_node_t *node_1;
1478         node_1 = node_0->get_child(node_0->context, 0);
1479         node_1->layout.position[CSS_TOP] = 900;
1480         node_1->layout.position[CSS_LEFT] = 0;
1481         node_1->layout.dimensions[CSS_WIDTH] = 100;
1482         node_1->layout.dimensions[CSS_HEIGHT] = 100;
1483         node_1 = node_0->get_child(node_0->context, 1);
1484         node_1->layout.position[CSS_TOP] = 0;
1485         node_1->layout.position[CSS_LEFT] = 0;
1486         node_1->layout.dimensions[CSS_WIDTH] = 100;
1487         node_1->layout.dimensions[CSS_HEIGHT] = 100;
1488       }
1489     }
1490
1491     test("should layout node with justifyContent: space-between in reverse", root_node, root_layout);
1492   }
1493
1494   {
1495     css_node_t *root_node = new_test_css_node();
1496     {
1497       css_node_t *node_0 = root_node;
1498       node_0->style.justify_content = CSS_JUSTIFY_SPACE_AROUND;
1499       node_0->style.dimensions[CSS_WIDTH] = 1000;
1500       node_0->style.dimensions[CSS_HEIGHT] = 1000;
1501       init_css_node_children(node_0, 2);
1502       {
1503         css_node_t *node_1;
1504         node_1 = node_0->get_child(node_0->context, 0);
1505         node_1->style.dimensions[CSS_WIDTH] = 100;
1506         node_1->style.dimensions[CSS_HEIGHT] = 100;
1507         node_1 = node_0->get_child(node_0->context, 1);
1508         node_1->style.dimensions[CSS_WIDTH] = 100;
1509         node_1->style.dimensions[CSS_HEIGHT] = 100;
1510       }
1511     }
1512
1513     css_node_t *root_layout = new_test_css_node();
1514     {
1515       css_node_t *node_0 = root_layout;
1516       node_0->layout.position[CSS_TOP] = 0;
1517       node_0->layout.position[CSS_LEFT] = 0;
1518       node_0->layout.dimensions[CSS_WIDTH] = 1000;
1519       node_0->layout.dimensions[CSS_HEIGHT] = 1000;
1520       init_css_node_children(node_0, 2);
1521       {
1522         css_node_t *node_1;
1523         node_1 = node_0->get_child(node_0->context, 0);
1524         node_1->layout.position[CSS_TOP] = 200;
1525         node_1->layout.position[CSS_LEFT] = 0;
1526         node_1->layout.dimensions[CSS_WIDTH] = 100;
1527         node_1->layout.dimensions[CSS_HEIGHT] = 100;
1528         node_1 = node_0->get_child(node_0->context, 1);
1529         node_1->layout.position[CSS_TOP] = 700;
1530         node_1->layout.position[CSS_LEFT] = 0;
1531         node_1->layout.dimensions[CSS_WIDTH] = 100;
1532         node_1->layout.dimensions[CSS_HEIGHT] = 100;
1533       }
1534     }
1535
1536     test("should layout node with justifyContent: space-around", root_node, root_layout);
1537   }
1538
1539   {
1540     css_node_t *root_node = new_test_css_node();
1541     {
1542       css_node_t *node_0 = root_node;
1543       node_0->style.flex_direction = CSS_FLEX_DIRECTION_COLUMN_REVERSE;
1544       node_0->style.justify_content = CSS_JUSTIFY_SPACE_AROUND;
1545       node_0->style.dimensions[CSS_WIDTH] = 1000;
1546       node_0->style.dimensions[CSS_HEIGHT] = 1000;
1547       init_css_node_children(node_0, 2);
1548       {
1549         css_node_t *node_1;
1550         node_1 = node_0->get_child(node_0->context, 0);
1551         node_1->style.dimensions[CSS_WIDTH] = 100;
1552         node_1->style.dimensions[CSS_HEIGHT] = 100;
1553         node_1 = node_0->get_child(node_0->context, 1);
1554         node_1->style.dimensions[CSS_WIDTH] = 100;
1555         node_1->style.dimensions[CSS_HEIGHT] = 100;
1556       }
1557     }
1558
1559     css_node_t *root_layout = new_test_css_node();
1560     {
1561       css_node_t *node_0 = root_layout;
1562       node_0->layout.position[CSS_TOP] = 0;
1563       node_0->layout.position[CSS_LEFT] = 0;
1564       node_0->layout.dimensions[CSS_WIDTH] = 1000;
1565       node_0->layout.dimensions[CSS_HEIGHT] = 1000;
1566       init_css_node_children(node_0, 2);
1567       {
1568         css_node_t *node_1;
1569         node_1 = node_0->get_child(node_0->context, 0);
1570         node_1->layout.position[CSS_TOP] = 700;
1571         node_1->layout.position[CSS_LEFT] = 0;
1572         node_1->layout.dimensions[CSS_WIDTH] = 100;
1573         node_1->layout.dimensions[CSS_HEIGHT] = 100;
1574         node_1 = node_0->get_child(node_0->context, 1);
1575         node_1->layout.position[CSS_TOP] = 200;
1576         node_1->layout.position[CSS_LEFT] = 0;
1577         node_1->layout.dimensions[CSS_WIDTH] = 100;
1578         node_1->layout.dimensions[CSS_HEIGHT] = 100;
1579       }
1580     }
1581
1582     test("should layout node with justifyContent: space-around in reverse", root_node, root_layout);
1583   }
1584
1585   {
1586     css_node_t *root_node = new_test_css_node();
1587     {
1588       css_node_t *node_0 = root_node;
1589       node_0->style.justify_content = CSS_JUSTIFY_CENTER;
1590       node_0->style.dimensions[CSS_WIDTH] = 1000;
1591       node_0->style.dimensions[CSS_HEIGHT] = 1000;
1592       init_css_node_children(node_0, 2);
1593       {
1594         css_node_t *node_1;
1595         node_1 = node_0->get_child(node_0->context, 0);
1596         node_1->style.dimensions[CSS_WIDTH] = 100;
1597         node_1->style.dimensions[CSS_HEIGHT] = 100;
1598         node_1 = node_0->get_child(node_0->context, 1);
1599         node_1->style.dimensions[CSS_WIDTH] = 100;
1600         node_1->style.dimensions[CSS_HEIGHT] = 100;
1601       }
1602     }
1603
1604     css_node_t *root_layout = new_test_css_node();
1605     {
1606       css_node_t *node_0 = root_layout;
1607       node_0->layout.position[CSS_TOP] = 0;
1608       node_0->layout.position[CSS_LEFT] = 0;
1609       node_0->layout.dimensions[CSS_WIDTH] = 1000;
1610       node_0->layout.dimensions[CSS_HEIGHT] = 1000;
1611       init_css_node_children(node_0, 2);
1612       {
1613         css_node_t *node_1;
1614         node_1 = node_0->get_child(node_0->context, 0);
1615         node_1->layout.position[CSS_TOP] = 400;
1616         node_1->layout.position[CSS_LEFT] = 0;
1617         node_1->layout.dimensions[CSS_WIDTH] = 100;
1618         node_1->layout.dimensions[CSS_HEIGHT] = 100;
1619         node_1 = node_0->get_child(node_0->context, 1);
1620         node_1->layout.position[CSS_TOP] = 500;
1621         node_1->layout.position[CSS_LEFT] = 0;
1622         node_1->layout.dimensions[CSS_WIDTH] = 100;
1623         node_1->layout.dimensions[CSS_HEIGHT] = 100;
1624       }
1625     }
1626
1627     test("should layout node with justifyContent: center", root_node, root_layout);
1628   }
1629
1630   {
1631     css_node_t *root_node = new_test_css_node();
1632     {
1633       css_node_t *node_0 = root_node;
1634       node_0->style.flex_direction = CSS_FLEX_DIRECTION_COLUMN_REVERSE;
1635       node_0->style.justify_content = CSS_JUSTIFY_CENTER;
1636       node_0->style.dimensions[CSS_WIDTH] = 1000;
1637       node_0->style.dimensions[CSS_HEIGHT] = 1000;
1638       init_css_node_children(node_0, 2);
1639       {
1640         css_node_t *node_1;
1641         node_1 = node_0->get_child(node_0->context, 0);
1642         node_1->style.dimensions[CSS_WIDTH] = 100;
1643         node_1->style.dimensions[CSS_HEIGHT] = 100;
1644         node_1 = node_0->get_child(node_0->context, 1);
1645         node_1->style.dimensions[CSS_WIDTH] = 100;
1646         node_1->style.dimensions[CSS_HEIGHT] = 100;
1647       }
1648     }
1649
1650     css_node_t *root_layout = new_test_css_node();
1651     {
1652       css_node_t *node_0 = root_layout;
1653       node_0->layout.position[CSS_TOP] = 0;
1654       node_0->layout.position[CSS_LEFT] = 0;
1655       node_0->layout.dimensions[CSS_WIDTH] = 1000;
1656       node_0->layout.dimensions[CSS_HEIGHT] = 1000;
1657       init_css_node_children(node_0, 2);
1658       {
1659         css_node_t *node_1;
1660         node_1 = node_0->get_child(node_0->context, 0);
1661         node_1->layout.position[CSS_TOP] = 500;
1662         node_1->layout.position[CSS_LEFT] = 0;
1663         node_1->layout.dimensions[CSS_WIDTH] = 100;
1664         node_1->layout.dimensions[CSS_HEIGHT] = 100;
1665         node_1 = node_0->get_child(node_0->context, 1);
1666         node_1->layout.position[CSS_TOP] = 400;
1667         node_1->layout.position[CSS_LEFT] = 0;
1668         node_1->layout.dimensions[CSS_WIDTH] = 100;
1669         node_1->layout.dimensions[CSS_HEIGHT] = 100;
1670       }
1671     }
1672
1673     test("should layout node with justifyContent: center in reverse", root_node, root_layout);
1674   }
1675
1676   {
1677     css_node_t *root_node = new_test_css_node();
1678     {
1679       css_node_t *node_0 = root_node;
1680       node_0->style.dimensions[CSS_WIDTH] = 1000;
1681       node_0->style.dimensions[CSS_HEIGHT] = 1000;
1682       init_css_node_children(node_0, 1);
1683       {
1684         css_node_t *node_1;
1685         node_1 = node_0->get_child(node_0->context, 0);
1686         node_1->style.flex = 1;
1687         node_1->style.dimensions[CSS_WIDTH] = 100;
1688         node_1->style.dimensions[CSS_HEIGHT] = 100;
1689       }
1690     }
1691
1692     css_node_t *root_layout = new_test_css_node();
1693     {
1694       css_node_t *node_0 = root_layout;
1695       node_0->layout.position[CSS_TOP] = 0;
1696       node_0->layout.position[CSS_LEFT] = 0;
1697       node_0->layout.dimensions[CSS_WIDTH] = 1000;
1698       node_0->layout.dimensions[CSS_HEIGHT] = 1000;
1699       init_css_node_children(node_0, 1);
1700       {
1701         css_node_t *node_1;
1702         node_1 = node_0->get_child(node_0->context, 0);
1703         node_1->layout.position[CSS_TOP] = 0;
1704         node_1->layout.position[CSS_LEFT] = 0;
1705         node_1->layout.dimensions[CSS_WIDTH] = 100;
1706         node_1->layout.dimensions[CSS_HEIGHT] = 1000;
1707       }
1708     }
1709
1710     test("should layout node with flex override height", root_node, root_layout);
1711   }
1712
1713   {
1714     css_node_t *root_node = new_test_css_node();
1715     {
1716       css_node_t *node_0 = root_node;
1717       node_0->style.align_items = CSS_ALIGN_FLEX_START;
1718       node_0->style.dimensions[CSS_WIDTH] = 1000;
1719       node_0->style.dimensions[CSS_HEIGHT] = 1000;
1720       init_css_node_children(node_0, 2);
1721       {
1722         css_node_t *node_1;
1723         node_1 = node_0->get_child(node_0->context, 0);
1724         node_1->style.dimensions[CSS_WIDTH] = 200;
1725         node_1->style.dimensions[CSS_HEIGHT] = 100;
1726         node_1 = node_0->get_child(node_0->context, 1);
1727         node_1->style.dimensions[CSS_WIDTH] = 100;
1728         node_1->style.dimensions[CSS_HEIGHT] = 100;
1729       }
1730     }
1731
1732     css_node_t *root_layout = new_test_css_node();
1733     {
1734       css_node_t *node_0 = root_layout;
1735       node_0->layout.position[CSS_TOP] = 0;
1736       node_0->layout.position[CSS_LEFT] = 0;
1737       node_0->layout.dimensions[CSS_WIDTH] = 1000;
1738       node_0->layout.dimensions[CSS_HEIGHT] = 1000;
1739       init_css_node_children(node_0, 2);
1740       {
1741         css_node_t *node_1;
1742         node_1 = node_0->get_child(node_0->context, 0);
1743         node_1->layout.position[CSS_TOP] = 0;
1744         node_1->layout.position[CSS_LEFT] = 0;
1745         node_1->layout.dimensions[CSS_WIDTH] = 200;
1746         node_1->layout.dimensions[CSS_HEIGHT] = 100;
1747         node_1 = node_0->get_child(node_0->context, 1);
1748         node_1->layout.position[CSS_TOP] = 100;
1749         node_1->layout.position[CSS_LEFT] = 0;
1750         node_1->layout.dimensions[CSS_WIDTH] = 100;
1751         node_1->layout.dimensions[CSS_HEIGHT] = 100;
1752       }
1753     }
1754
1755     test("should layout node with alignItems: flex-start", root_node, root_layout);
1756   }
1757
1758   {
1759     css_node_t *root_node = new_test_css_node();
1760     {
1761       css_node_t *node_0 = root_node;
1762       node_0->style.flex_direction = CSS_FLEX_DIRECTION_COLUMN_REVERSE;
1763       node_0->style.align_items = CSS_ALIGN_FLEX_START;
1764       node_0->style.dimensions[CSS_WIDTH] = 1000;
1765       node_0->style.dimensions[CSS_HEIGHT] = 1000;
1766       init_css_node_children(node_0, 2);
1767       {
1768         css_node_t *node_1;
1769         node_1 = node_0->get_child(node_0->context, 0);
1770         node_1->style.dimensions[CSS_WIDTH] = 200;
1771         node_1->style.dimensions[CSS_HEIGHT] = 100;
1772         node_1 = node_0->get_child(node_0->context, 1);
1773         node_1->style.dimensions[CSS_WIDTH] = 100;
1774         node_1->style.dimensions[CSS_HEIGHT] = 100;
1775       }
1776     }
1777
1778     css_node_t *root_layout = new_test_css_node();
1779     {
1780       css_node_t *node_0 = root_layout;
1781       node_0->layout.position[CSS_TOP] = 0;
1782       node_0->layout.position[CSS_LEFT] = 0;
1783       node_0->layout.dimensions[CSS_WIDTH] = 1000;
1784       node_0->layout.dimensions[CSS_HEIGHT] = 1000;
1785       init_css_node_children(node_0, 2);
1786       {
1787         css_node_t *node_1;
1788         node_1 = node_0->get_child(node_0->context, 0);
1789         node_1->layout.position[CSS_TOP] = 900;
1790         node_1->layout.position[CSS_LEFT] = 0;
1791         node_1->layout.dimensions[CSS_WIDTH] = 200;
1792         node_1->layout.dimensions[CSS_HEIGHT] = 100;
1793         node_1 = node_0->get_child(node_0->context, 1);
1794         node_1->layout.position[CSS_TOP] = 800;
1795         node_1->layout.position[CSS_LEFT] = 0;
1796         node_1->layout.dimensions[CSS_WIDTH] = 100;
1797         node_1->layout.dimensions[CSS_HEIGHT] = 100;
1798       }
1799     }
1800
1801     test("should layout node with alignItems: flex-start in reverse", root_node, root_layout);
1802   }
1803
1804   {
1805     css_node_t *root_node = new_test_css_node();
1806     {
1807       css_node_t *node_0 = root_node;
1808       node_0->style.align_items = CSS_ALIGN_CENTER;
1809       node_0->style.dimensions[CSS_WIDTH] = 1000;
1810       node_0->style.dimensions[CSS_HEIGHT] = 1000;
1811       init_css_node_children(node_0, 2);
1812       {
1813         css_node_t *node_1;
1814         node_1 = node_0->get_child(node_0->context, 0);
1815         node_1->style.dimensions[CSS_WIDTH] = 200;
1816         node_1->style.dimensions[CSS_HEIGHT] = 100;
1817         node_1 = node_0->get_child(node_0->context, 1);
1818         node_1->style.dimensions[CSS_WIDTH] = 100;
1819         node_1->style.dimensions[CSS_HEIGHT] = 100;
1820       }
1821     }
1822
1823     css_node_t *root_layout = new_test_css_node();
1824     {
1825       css_node_t *node_0 = root_layout;
1826       node_0->layout.position[CSS_TOP] = 0;
1827       node_0->layout.position[CSS_LEFT] = 0;
1828       node_0->layout.dimensions[CSS_WIDTH] = 1000;
1829       node_0->layout.dimensions[CSS_HEIGHT] = 1000;
1830       init_css_node_children(node_0, 2);
1831       {
1832         css_node_t *node_1;
1833         node_1 = node_0->get_child(node_0->context, 0);
1834         node_1->layout.position[CSS_TOP] = 0;
1835         node_1->layout.position[CSS_LEFT] = 400;
1836         node_1->layout.dimensions[CSS_WIDTH] = 200;
1837         node_1->layout.dimensions[CSS_HEIGHT] = 100;
1838         node_1 = node_0->get_child(node_0->context, 1);
1839         node_1->layout.position[CSS_TOP] = 100;
1840         node_1->layout.position[CSS_LEFT] = 450;
1841         node_1->layout.dimensions[CSS_WIDTH] = 100;
1842         node_1->layout.dimensions[CSS_HEIGHT] = 100;
1843       }
1844     }
1845
1846     test("should layout node with alignItems: center", root_node, root_layout);
1847   }
1848
1849   {
1850     css_node_t *root_node = new_test_css_node();
1851     {
1852       css_node_t *node_0 = root_node;
1853       node_0->style.flex_direction = CSS_FLEX_DIRECTION_COLUMN_REVERSE;
1854       node_0->style.align_items = CSS_ALIGN_CENTER;
1855       node_0->style.dimensions[CSS_WIDTH] = 1000;
1856       node_0->style.dimensions[CSS_HEIGHT] = 1000;
1857       init_css_node_children(node_0, 2);
1858       {
1859         css_node_t *node_1;
1860         node_1 = node_0->get_child(node_0->context, 0);
1861         node_1->style.dimensions[CSS_WIDTH] = 200;
1862         node_1->style.dimensions[CSS_HEIGHT] = 100;
1863         node_1 = node_0->get_child(node_0->context, 1);
1864         node_1->style.dimensions[CSS_WIDTH] = 100;
1865         node_1->style.dimensions[CSS_HEIGHT] = 100;
1866       }
1867     }
1868
1869     css_node_t *root_layout = new_test_css_node();
1870     {
1871       css_node_t *node_0 = root_layout;
1872       node_0->layout.position[CSS_TOP] = 0;
1873       node_0->layout.position[CSS_LEFT] = 0;
1874       node_0->layout.dimensions[CSS_WIDTH] = 1000;
1875       node_0->layout.dimensions[CSS_HEIGHT] = 1000;
1876       init_css_node_children(node_0, 2);
1877       {
1878         css_node_t *node_1;
1879         node_1 = node_0->get_child(node_0->context, 0);
1880         node_1->layout.position[CSS_TOP] = 900;
1881         node_1->layout.position[CSS_LEFT] = 400;
1882         node_1->layout.dimensions[CSS_WIDTH] = 200;
1883         node_1->layout.dimensions[CSS_HEIGHT] = 100;
1884         node_1 = node_0->get_child(node_0->context, 1);
1885         node_1->layout.position[CSS_TOP] = 800;
1886         node_1->layout.position[CSS_LEFT] = 450;
1887         node_1->layout.dimensions[CSS_WIDTH] = 100;
1888         node_1->layout.dimensions[CSS_HEIGHT] = 100;
1889       }
1890     }
1891
1892     test("should layout node with alignItems: center in reverse", root_node, root_layout);
1893   }
1894
1895   {
1896     css_node_t *root_node = new_test_css_node();
1897     {
1898       css_node_t *node_0 = root_node;
1899       node_0->style.align_items = CSS_ALIGN_FLEX_END;
1900       node_0->style.dimensions[CSS_WIDTH] = 1000;
1901       node_0->style.dimensions[CSS_HEIGHT] = 1000;
1902       init_css_node_children(node_0, 2);
1903       {
1904         css_node_t *node_1;
1905         node_1 = node_0->get_child(node_0->context, 0);
1906         node_1->style.dimensions[CSS_WIDTH] = 200;
1907         node_1->style.dimensions[CSS_HEIGHT] = 100;
1908         node_1 = node_0->get_child(node_0->context, 1);
1909         node_1->style.dimensions[CSS_WIDTH] = 100;
1910         node_1->style.dimensions[CSS_HEIGHT] = 100;
1911       }
1912     }
1913
1914     css_node_t *root_layout = new_test_css_node();
1915     {
1916       css_node_t *node_0 = root_layout;
1917       node_0->layout.position[CSS_TOP] = 0;
1918       node_0->layout.position[CSS_LEFT] = 0;
1919       node_0->layout.dimensions[CSS_WIDTH] = 1000;
1920       node_0->layout.dimensions[CSS_HEIGHT] = 1000;
1921       init_css_node_children(node_0, 2);
1922       {
1923         css_node_t *node_1;
1924         node_1 = node_0->get_child(node_0->context, 0);
1925         node_1->layout.position[CSS_TOP] = 0;
1926         node_1->layout.position[CSS_LEFT] = 800;
1927         node_1->layout.dimensions[CSS_WIDTH] = 200;
1928         node_1->layout.dimensions[CSS_HEIGHT] = 100;
1929         node_1 = node_0->get_child(node_0->context, 1);
1930         node_1->layout.position[CSS_TOP] = 100;
1931         node_1->layout.position[CSS_LEFT] = 900;
1932         node_1->layout.dimensions[CSS_WIDTH] = 100;
1933         node_1->layout.dimensions[CSS_HEIGHT] = 100;
1934       }
1935     }
1936
1937     test("should layout node with alignItems: flex-end", root_node, root_layout);
1938   }
1939
1940   {
1941     css_node_t *root_node = new_test_css_node();
1942     {
1943       css_node_t *node_0 = root_node;
1944       node_0->style.flex_direction = CSS_FLEX_DIRECTION_COLUMN_REVERSE;
1945       node_0->style.align_items = CSS_ALIGN_FLEX_END;
1946       node_0->style.dimensions[CSS_WIDTH] = 1000;
1947       node_0->style.dimensions[CSS_HEIGHT] = 1000;
1948       init_css_node_children(node_0, 2);
1949       {
1950         css_node_t *node_1;
1951         node_1 = node_0->get_child(node_0->context, 0);
1952         node_1->style.dimensions[CSS_WIDTH] = 200;
1953         node_1->style.dimensions[CSS_HEIGHT] = 100;
1954         node_1 = node_0->get_child(node_0->context, 1);
1955         node_1->style.dimensions[CSS_WIDTH] = 100;
1956         node_1->style.dimensions[CSS_HEIGHT] = 100;
1957       }
1958     }
1959
1960     css_node_t *root_layout = new_test_css_node();
1961     {
1962       css_node_t *node_0 = root_layout;
1963       node_0->layout.position[CSS_TOP] = 0;
1964       node_0->layout.position[CSS_LEFT] = 0;
1965       node_0->layout.dimensions[CSS_WIDTH] = 1000;
1966       node_0->layout.dimensions[CSS_HEIGHT] = 1000;
1967       init_css_node_children(node_0, 2);
1968       {
1969         css_node_t *node_1;
1970         node_1 = node_0->get_child(node_0->context, 0);
1971         node_1->layout.position[CSS_TOP] = 900;
1972         node_1->layout.position[CSS_LEFT] = 800;
1973         node_1->layout.dimensions[CSS_WIDTH] = 200;
1974         node_1->layout.dimensions[CSS_HEIGHT] = 100;
1975         node_1 = node_0->get_child(node_0->context, 1);
1976         node_1->layout.position[CSS_TOP] = 800;
1977         node_1->layout.position[CSS_LEFT] = 900;
1978         node_1->layout.dimensions[CSS_WIDTH] = 100;
1979         node_1->layout.dimensions[CSS_HEIGHT] = 100;
1980       }
1981     }
1982
1983     test("should layout node with alignItems: flex-end in reverse", root_node, root_layout);
1984   }
1985
1986   {
1987     css_node_t *root_node = new_test_css_node();
1988     {
1989       css_node_t *node_0 = root_node;
1990       node_0->style.align_items = CSS_ALIGN_FLEX_END;
1991       node_0->style.dimensions[CSS_WIDTH] = 1000;
1992       node_0->style.dimensions[CSS_HEIGHT] = 1000;
1993       init_css_node_children(node_0, 2);
1994       {
1995         css_node_t *node_1;
1996         node_1 = node_0->get_child(node_0->context, 0);
1997         node_1->style.dimensions[CSS_WIDTH] = 200;
1998         node_1->style.dimensions[CSS_HEIGHT] = 100;
1999         node_1 = node_0->get_child(node_0->context, 1);
2000         node_1->style.align_self = CSS_ALIGN_CENTER;
2001         node_1->style.dimensions[CSS_WIDTH] = 100;
2002         node_1->style.dimensions[CSS_HEIGHT] = 100;
2003       }
2004     }
2005
2006     css_node_t *root_layout = new_test_css_node();
2007     {
2008       css_node_t *node_0 = root_layout;
2009       node_0->layout.position[CSS_TOP] = 0;
2010       node_0->layout.position[CSS_LEFT] = 0;
2011       node_0->layout.dimensions[CSS_WIDTH] = 1000;
2012       node_0->layout.dimensions[CSS_HEIGHT] = 1000;
2013       init_css_node_children(node_0, 2);
2014       {
2015         css_node_t *node_1;
2016         node_1 = node_0->get_child(node_0->context, 0);
2017         node_1->layout.position[CSS_TOP] = 0;
2018         node_1->layout.position[CSS_LEFT] = 800;
2019         node_1->layout.dimensions[CSS_WIDTH] = 200;
2020         node_1->layout.dimensions[CSS_HEIGHT] = 100;
2021         node_1 = node_0->get_child(node_0->context, 1);
2022         node_1->layout.position[CSS_TOP] = 100;
2023         node_1->layout.position[CSS_LEFT] = 450;
2024         node_1->layout.dimensions[CSS_WIDTH] = 100;
2025         node_1->layout.dimensions[CSS_HEIGHT] = 100;
2026       }
2027     }
2028
2029     test("should layout node with alignSelf overrides alignItems", root_node, root_layout);
2030   }
2031
2032   {
2033     css_node_t *root_node = new_test_css_node();
2034     {
2035       css_node_t *node_0 = root_node;
2036       node_0->style.flex_direction = CSS_FLEX_DIRECTION_COLUMN_REVERSE;
2037       node_0->style.align_items = CSS_ALIGN_FLEX_END;
2038       node_0->style.dimensions[CSS_WIDTH] = 1000;
2039       node_0->style.dimensions[CSS_HEIGHT] = 1000;
2040       init_css_node_children(node_0, 2);
2041       {
2042         css_node_t *node_1;
2043         node_1 = node_0->get_child(node_0->context, 0);
2044         node_1->style.dimensions[CSS_WIDTH] = 200;
2045         node_1->style.dimensions[CSS_HEIGHT] = 100;
2046         node_1 = node_0->get_child(node_0->context, 1);
2047         node_1->style.align_self = CSS_ALIGN_CENTER;
2048         node_1->style.dimensions[CSS_WIDTH] = 100;
2049         node_1->style.dimensions[CSS_HEIGHT] = 100;
2050       }
2051     }
2052
2053     css_node_t *root_layout = new_test_css_node();
2054     {
2055       css_node_t *node_0 = root_layout;
2056       node_0->layout.position[CSS_TOP] = 0;
2057       node_0->layout.position[CSS_LEFT] = 0;
2058       node_0->layout.dimensions[CSS_WIDTH] = 1000;
2059       node_0->layout.dimensions[CSS_HEIGHT] = 1000;
2060       init_css_node_children(node_0, 2);
2061       {
2062         css_node_t *node_1;
2063         node_1 = node_0->get_child(node_0->context, 0);
2064         node_1->layout.position[CSS_TOP] = 900;
2065         node_1->layout.position[CSS_LEFT] = 800;
2066         node_1->layout.dimensions[CSS_WIDTH] = 200;
2067         node_1->layout.dimensions[CSS_HEIGHT] = 100;
2068         node_1 = node_0->get_child(node_0->context, 1);
2069         node_1->layout.position[CSS_TOP] = 800;
2070         node_1->layout.position[CSS_LEFT] = 450;
2071         node_1->layout.dimensions[CSS_WIDTH] = 100;
2072         node_1->layout.dimensions[CSS_HEIGHT] = 100;
2073       }
2074     }
2075
2076     test("should layout node with alignSelf overrides alignItems in reverse", root_node, root_layout);
2077   }
2078
2079   {
2080     css_node_t *root_node = new_test_css_node();
2081     {
2082       css_node_t *node_0 = root_node;
2083       node_0->style.align_items = CSS_ALIGN_STRETCH;
2084       node_0->style.dimensions[CSS_WIDTH] = 1000;
2085       node_0->style.dimensions[CSS_HEIGHT] = 1000;
2086       init_css_node_children(node_0, 1);
2087       {
2088         css_node_t *node_1;
2089         node_1 = node_0->get_child(node_0->context, 0);
2090         node_1->style.dimensions[CSS_HEIGHT] = 100;
2091       }
2092     }
2093
2094     css_node_t *root_layout = new_test_css_node();
2095     {
2096       css_node_t *node_0 = root_layout;
2097       node_0->layout.position[CSS_TOP] = 0;
2098       node_0->layout.position[CSS_LEFT] = 0;
2099       node_0->layout.dimensions[CSS_WIDTH] = 1000;
2100       node_0->layout.dimensions[CSS_HEIGHT] = 1000;
2101       init_css_node_children(node_0, 1);
2102       {
2103         css_node_t *node_1;
2104         node_1 = node_0->get_child(node_0->context, 0);
2105         node_1->layout.position[CSS_TOP] = 0;
2106         node_1->layout.position[CSS_LEFT] = 0;
2107         node_1->layout.dimensions[CSS_WIDTH] = 1000;
2108         node_1->layout.dimensions[CSS_HEIGHT] = 100;
2109       }
2110     }
2111
2112     test("should layout node with alignItem: stretch", root_node, root_layout);
2113   }
2114
2115   {
2116     css_node_t *root_node = new_test_css_node();
2117     {
2118       css_node_t *node_0 = root_node;
2119       node_0->style.flex_direction = CSS_FLEX_DIRECTION_COLUMN_REVERSE;
2120       node_0->style.align_items = CSS_ALIGN_STRETCH;
2121       node_0->style.dimensions[CSS_WIDTH] = 1000;
2122       node_0->style.dimensions[CSS_HEIGHT] = 1000;
2123       init_css_node_children(node_0, 1);
2124       {
2125         css_node_t *node_1;
2126         node_1 = node_0->get_child(node_0->context, 0);
2127         node_1->style.dimensions[CSS_HEIGHT] = 100;
2128       }
2129     }
2130
2131     css_node_t *root_layout = new_test_css_node();
2132     {
2133       css_node_t *node_0 = root_layout;
2134       node_0->layout.position[CSS_TOP] = 0;
2135       node_0->layout.position[CSS_LEFT] = 0;
2136       node_0->layout.dimensions[CSS_WIDTH] = 1000;
2137       node_0->layout.dimensions[CSS_HEIGHT] = 1000;
2138       init_css_node_children(node_0, 1);
2139       {
2140         css_node_t *node_1;
2141         node_1 = node_0->get_child(node_0->context, 0);
2142         node_1->layout.position[CSS_TOP] = 900;
2143         node_1->layout.position[CSS_LEFT] = 0;
2144         node_1->layout.dimensions[CSS_WIDTH] = 1000;
2145         node_1->layout.dimensions[CSS_HEIGHT] = 100;
2146       }
2147     }
2148
2149     test("should layout node with alignItem: stretch in reverse", root_node, root_layout);
2150   }
2151
2152   {
2153     css_node_t *root_node = new_test_css_node();
2154     {
2155       css_node_t *node_0 = root_node;
2156       init_css_node_children(node_0, 1);
2157       {
2158         css_node_t *node_1;
2159         node_1 = node_0->get_child(node_0->context, 0);
2160       }
2161     }
2162
2163     css_node_t *root_layout = new_test_css_node();
2164     {
2165       css_node_t *node_0 = root_layout;
2166       node_0->layout.position[CSS_TOP] = 0;
2167       node_0->layout.position[CSS_LEFT] = 0;
2168       node_0->layout.dimensions[CSS_WIDTH] = 0;
2169       node_0->layout.dimensions[CSS_HEIGHT] = 0;
2170       init_css_node_children(node_0, 1);
2171       {
2172         css_node_t *node_1;
2173         node_1 = node_0->get_child(node_0->context, 0);
2174         node_1->layout.position[CSS_TOP] = 0;
2175         node_1->layout.position[CSS_LEFT] = 0;
2176         node_1->layout.dimensions[CSS_WIDTH] = 0;
2177         node_1->layout.dimensions[CSS_HEIGHT] = 0;
2178       }
2179     }
2180
2181     test("should layout empty node", root_node, root_layout);
2182   }
2183
2184   {
2185     css_node_t *root_node = new_test_css_node();
2186     {
2187       css_node_t *node_0 = root_node;
2188       node_0->style.flex_direction = CSS_FLEX_DIRECTION_COLUMN_REVERSE;
2189       init_css_node_children(node_0, 1);
2190       {
2191         css_node_t *node_1;
2192         node_1 = node_0->get_child(node_0->context, 0);
2193       }
2194     }
2195
2196     css_node_t *root_layout = new_test_css_node();
2197     {
2198       css_node_t *node_0 = root_layout;
2199       node_0->layout.position[CSS_TOP] = 0;
2200       node_0->layout.position[CSS_LEFT] = 0;
2201       node_0->layout.dimensions[CSS_WIDTH] = 0;
2202       node_0->layout.dimensions[CSS_HEIGHT] = 0;
2203       init_css_node_children(node_0, 1);
2204       {
2205         css_node_t *node_1;
2206         node_1 = node_0->get_child(node_0->context, 0);
2207         node_1->layout.position[CSS_TOP] = 0;
2208         node_1->layout.position[CSS_LEFT] = 0;
2209         node_1->layout.dimensions[CSS_WIDTH] = 0;
2210         node_1->layout.dimensions[CSS_HEIGHT] = 0;
2211       }
2212     }
2213
2214     test("should layout empty node in reverse", root_node, root_layout);
2215   }
2216
2217   {
2218     css_node_t *root_node = new_test_css_node();
2219     {
2220       css_node_t *node_0 = root_node;
2221       init_css_node_children(node_0, 1);
2222       {
2223         css_node_t *node_1;
2224         node_1 = node_0->get_child(node_0->context, 0);
2225         node_1->style.margin[CSS_LEFT] = 5;
2226         node_1->style.margin[CSS_TOP] = 5;
2227         node_1->style.margin[CSS_RIGHT] = 5;
2228         node_1->style.margin[CSS_BOTTOM] = 5;
2229         node_1->style.margin[CSS_START] = 5;
2230         node_1->style.margin[CSS_END] = 5;
2231       }
2232     }
2233
2234     css_node_t *root_layout = new_test_css_node();
2235     {
2236       css_node_t *node_0 = root_layout;
2237       node_0->layout.position[CSS_TOP] = 0;
2238       node_0->layout.position[CSS_LEFT] = 0;
2239       node_0->layout.dimensions[CSS_WIDTH] = 10;
2240       node_0->layout.dimensions[CSS_HEIGHT] = 10;
2241       init_css_node_children(node_0, 1);
2242       {
2243         css_node_t *node_1;
2244         node_1 = node_0->get_child(node_0->context, 0);
2245         node_1->layout.position[CSS_TOP] = 5;
2246         node_1->layout.position[CSS_LEFT] = 5;
2247         node_1->layout.dimensions[CSS_WIDTH] = 0;
2248         node_1->layout.dimensions[CSS_HEIGHT] = 0;
2249       }
2250     }
2251
2252     test("should layout child with margin", root_node, root_layout);
2253   }
2254
2255   {
2256     css_node_t *root_node = new_test_css_node();
2257     {
2258       css_node_t *node_0 = root_node;
2259       node_0->style.flex_direction = CSS_FLEX_DIRECTION_COLUMN_REVERSE;
2260       init_css_node_children(node_0, 1);
2261       {
2262         css_node_t *node_1;
2263         node_1 = node_0->get_child(node_0->context, 0);
2264         node_1->style.margin[CSS_LEFT] = 5;
2265         node_1->style.margin[CSS_TOP] = 5;
2266         node_1->style.margin[CSS_RIGHT] = 5;
2267         node_1->style.margin[CSS_BOTTOM] = 5;
2268         node_1->style.margin[CSS_START] = 5;
2269         node_1->style.margin[CSS_END] = 5;
2270       }
2271     }
2272
2273     css_node_t *root_layout = new_test_css_node();
2274     {
2275       css_node_t *node_0 = root_layout;
2276       node_0->layout.position[CSS_TOP] = 0;
2277       node_0->layout.position[CSS_LEFT] = 0;
2278       node_0->layout.dimensions[CSS_WIDTH] = 10;
2279       node_0->layout.dimensions[CSS_HEIGHT] = 10;
2280       init_css_node_children(node_0, 1);
2281       {
2282         css_node_t *node_1;
2283         node_1 = node_0->get_child(node_0->context, 0);
2284         node_1->layout.position[CSS_TOP] = 5;
2285         node_1->layout.position[CSS_LEFT] = 5;
2286         node_1->layout.dimensions[CSS_WIDTH] = 0;
2287         node_1->layout.dimensions[CSS_HEIGHT] = 0;
2288       }
2289     }
2290
2291     test("should layout child with margin in reverse", root_node, root_layout);
2292   }
2293
2294   {
2295     css_node_t *root_node = new_test_css_node();
2296     {
2297       css_node_t *node_0 = root_node;
2298       node_0->style.dimensions[CSS_HEIGHT] = 100;
2299       init_css_node_children(node_0, 2);
2300       {
2301         css_node_t *node_1;
2302         node_1 = node_0->get_child(node_0->context, 0);
2303         node_1->style.dimensions[CSS_HEIGHT] = 100;
2304         node_1 = node_0->get_child(node_0->context, 1);
2305         node_1->style.dimensions[CSS_HEIGHT] = 200;
2306       }
2307     }
2308
2309     css_node_t *root_layout = new_test_css_node();
2310     {
2311       css_node_t *node_0 = root_layout;
2312       node_0->layout.position[CSS_TOP] = 0;
2313       node_0->layout.position[CSS_LEFT] = 0;
2314       node_0->layout.dimensions[CSS_WIDTH] = 0;
2315       node_0->layout.dimensions[CSS_HEIGHT] = 100;
2316       init_css_node_children(node_0, 2);
2317       {
2318         css_node_t *node_1;
2319         node_1 = node_0->get_child(node_0->context, 0);
2320         node_1->layout.position[CSS_TOP] = 0;
2321         node_1->layout.position[CSS_LEFT] = 0;
2322         node_1->layout.dimensions[CSS_WIDTH] = 0;
2323         node_1->layout.dimensions[CSS_HEIGHT] = 100;
2324         node_1 = node_0->get_child(node_0->context, 1);
2325         node_1->layout.position[CSS_TOP] = 100;
2326         node_1->layout.position[CSS_LEFT] = 0;
2327         node_1->layout.dimensions[CSS_WIDTH] = 0;
2328         node_1->layout.dimensions[CSS_HEIGHT] = 200;
2329       }
2330     }
2331
2332     test("should not shrink children if not enough space", root_node, root_layout);
2333   }
2334
2335   {
2336     css_node_t *root_node = new_test_css_node();
2337     {
2338       css_node_t *node_0 = root_node;
2339       node_0->style.flex_direction = CSS_FLEX_DIRECTION_COLUMN_REVERSE;
2340       node_0->style.dimensions[CSS_HEIGHT] = 100;
2341       init_css_node_children(node_0, 2);
2342       {
2343         css_node_t *node_1;
2344         node_1 = node_0->get_child(node_0->context, 0);
2345         node_1->style.dimensions[CSS_HEIGHT] = 100;
2346         node_1 = node_0->get_child(node_0->context, 1);
2347         node_1->style.dimensions[CSS_HEIGHT] = 200;
2348       }
2349     }
2350
2351     css_node_t *root_layout = new_test_css_node();
2352     {
2353       css_node_t *node_0 = root_layout;
2354       node_0->layout.position[CSS_TOP] = 0;
2355       node_0->layout.position[CSS_LEFT] = 0;
2356       node_0->layout.dimensions[CSS_WIDTH] = 0;
2357       node_0->layout.dimensions[CSS_HEIGHT] = 100;
2358       init_css_node_children(node_0, 2);
2359       {
2360         css_node_t *node_1;
2361         node_1 = node_0->get_child(node_0->context, 0);
2362         node_1->layout.position[CSS_TOP] = 0;
2363         node_1->layout.position[CSS_LEFT] = 0;
2364         node_1->layout.dimensions[CSS_WIDTH] = 0;
2365         node_1->layout.dimensions[CSS_HEIGHT] = 100;
2366         node_1 = node_0->get_child(node_0->context, 1);
2367         node_1->layout.position[CSS_TOP] = -200;
2368         node_1->layout.position[CSS_LEFT] = 0;
2369         node_1->layout.dimensions[CSS_WIDTH] = 0;
2370         node_1->layout.dimensions[CSS_HEIGHT] = 200;
2371       }
2372     }
2373
2374     test("should not shrink children if not enough space in reverse", root_node, root_layout);
2375   }
2376
2377   {
2378     css_node_t *root_node = new_test_css_node();
2379     {
2380       css_node_t *node_0 = root_node;
2381       node_0->style.justify_content = CSS_JUSTIFY_CENTER;
2382     }
2383
2384     css_node_t *root_layout = new_test_css_node();
2385     {
2386       css_node_t *node_0 = root_layout;
2387       node_0->layout.position[CSS_TOP] = 0;
2388       node_0->layout.position[CSS_LEFT] = 0;
2389       node_0->layout.dimensions[CSS_WIDTH] = 0;
2390       node_0->layout.dimensions[CSS_HEIGHT] = 0;
2391     }
2392
2393     test("should layout for center", root_node, root_layout);
2394   }
2395
2396   {
2397     css_node_t *root_node = new_test_css_node();
2398     {
2399       css_node_t *node_0 = root_node;
2400       node_0->style.justify_content = CSS_JUSTIFY_FLEX_END;
2401       node_0->style.dimensions[CSS_HEIGHT] = 100;
2402       init_css_node_children(node_0, 1);
2403       {
2404         css_node_t *node_1;
2405         node_1 = node_0->get_child(node_0->context, 0);
2406         node_1->style.margin[CSS_TOP] = 10;
2407       }
2408     }
2409
2410     css_node_t *root_layout = new_test_css_node();
2411     {
2412       css_node_t *node_0 = root_layout;
2413       node_0->layout.position[CSS_TOP] = 0;
2414       node_0->layout.position[CSS_LEFT] = 0;
2415       node_0->layout.dimensions[CSS_WIDTH] = 0;
2416       node_0->layout.dimensions[CSS_HEIGHT] = 100;
2417       init_css_node_children(node_0, 1);
2418       {
2419         css_node_t *node_1;
2420         node_1 = node_0->get_child(node_0->context, 0);
2421         node_1->layout.position[CSS_TOP] = 100;
2422         node_1->layout.position[CSS_LEFT] = 0;
2423         node_1->layout.dimensions[CSS_WIDTH] = 0;
2424         node_1->layout.dimensions[CSS_HEIGHT] = 0;
2425       }
2426     }
2427
2428     test("should layout flex-end taking into account margin", root_node, root_layout);
2429   }
2430
2431   {
2432     css_node_t *root_node = new_test_css_node();
2433     {
2434       css_node_t *node_0 = root_node;
2435       node_0->style.flex_direction = CSS_FLEX_DIRECTION_COLUMN_REVERSE;
2436       node_0->style.justify_content = CSS_JUSTIFY_FLEX_END;
2437       node_0->style.dimensions[CSS_HEIGHT] = 100;
2438       init_css_node_children(node_0, 1);
2439       {
2440         css_node_t *node_1;
2441         node_1 = node_0->get_child(node_0->context, 0);
2442         node_1->style.margin[CSS_TOP] = 10;
2443       }
2444     }
2445
2446     css_node_t *root_layout = new_test_css_node();
2447     {
2448       css_node_t *node_0 = root_layout;
2449       node_0->layout.position[CSS_TOP] = 0;
2450       node_0->layout.position[CSS_LEFT] = 0;
2451       node_0->layout.dimensions[CSS_WIDTH] = 0;
2452       node_0->layout.dimensions[CSS_HEIGHT] = 100;
2453       init_css_node_children(node_0, 1);
2454       {
2455         css_node_t *node_1;
2456         node_1 = node_0->get_child(node_0->context, 0);
2457         node_1->layout.position[CSS_TOP] = 10;
2458         node_1->layout.position[CSS_LEFT] = 0;
2459         node_1->layout.dimensions[CSS_WIDTH] = 0;
2460         node_1->layout.dimensions[CSS_HEIGHT] = 0;
2461       }
2462     }
2463
2464     test("should layout flex-end taking into account margin in reverse", root_node, root_layout);
2465   }
2466
2467   {
2468     css_node_t *root_node = new_test_css_node();
2469     {
2470       css_node_t *node_0 = root_node;
2471       init_css_node_children(node_0, 1);
2472       {
2473         css_node_t *node_1;
2474         node_1 = node_0->get_child(node_0->context, 0);
2475         node_1->style.align_items = CSS_ALIGN_FLEX_END;
2476         init_css_node_children(node_1, 2);
2477         {
2478           css_node_t *node_2;
2479           node_2 = node_1->get_child(node_1->context, 0);
2480           node_2->style.margin[CSS_LEFT] = 10;
2481           node_2->style.margin[CSS_TOP] = 10;
2482           node_2->style.margin[CSS_RIGHT] = 10;
2483           node_2->style.margin[CSS_BOTTOM] = 10;
2484           node_2->style.margin[CSS_START] = 10;
2485           node_2->style.margin[CSS_END] = 10;
2486           node_2 = node_1->get_child(node_1->context, 1);
2487           node_2->style.dimensions[CSS_HEIGHT] = 100;
2488         }
2489       }
2490     }
2491
2492     css_node_t *root_layout = new_test_css_node();
2493     {
2494       css_node_t *node_0 = root_layout;
2495       node_0->layout.position[CSS_TOP] = 0;
2496       node_0->layout.position[CSS_LEFT] = 0;
2497       node_0->layout.dimensions[CSS_WIDTH] = 20;
2498       node_0->layout.dimensions[CSS_HEIGHT] = 120;
2499       init_css_node_children(node_0, 1);
2500       {
2501         css_node_t *node_1;
2502         node_1 = node_0->get_child(node_0->context, 0);
2503         node_1->layout.position[CSS_TOP] = 0;
2504         node_1->layout.position[CSS_LEFT] = 0;
2505         node_1->layout.dimensions[CSS_WIDTH] = 20;
2506         node_1->layout.dimensions[CSS_HEIGHT] = 120;
2507         init_css_node_children(node_1, 2);
2508         {
2509           css_node_t *node_2;
2510           node_2 = node_1->get_child(node_1->context, 0);
2511           node_2->layout.position[CSS_TOP] = 10;
2512           node_2->layout.position[CSS_LEFT] = 10;
2513           node_2->layout.dimensions[CSS_WIDTH] = 0;
2514           node_2->layout.dimensions[CSS_HEIGHT] = 0;
2515           node_2 = node_1->get_child(node_1->context, 1);
2516           node_2->layout.position[CSS_TOP] = 20;
2517           node_2->layout.position[CSS_LEFT] = 20;
2518           node_2->layout.dimensions[CSS_WIDTH] = 0;
2519           node_2->layout.dimensions[CSS_HEIGHT] = 100;
2520         }
2521       }
2522     }
2523
2524     test("should layout alignItems with margin", root_node, root_layout);
2525   }
2526
2527   {
2528     css_node_t *root_node = new_test_css_node();
2529     {
2530       css_node_t *node_0 = root_node;
2531       init_css_node_children(node_0, 1);
2532       {
2533         css_node_t *node_1;
2534         node_1 = node_0->get_child(node_0->context, 0);
2535         node_1->style.flex_direction = CSS_FLEX_DIRECTION_COLUMN_REVERSE;
2536         node_1->style.align_items = CSS_ALIGN_FLEX_END;
2537         init_css_node_children(node_1, 2);
2538         {
2539           css_node_t *node_2;
2540           node_2 = node_1->get_child(node_1->context, 0);
2541           node_2->style.margin[CSS_LEFT] = 10;
2542           node_2->style.margin[CSS_TOP] = 10;
2543           node_2->style.margin[CSS_RIGHT] = 10;
2544           node_2->style.margin[CSS_BOTTOM] = 10;
2545           node_2->style.margin[CSS_START] = 10;
2546           node_2->style.margin[CSS_END] = 10;
2547           node_2 = node_1->get_child(node_1->context, 1);
2548           node_2->style.dimensions[CSS_HEIGHT] = 100;
2549         }
2550       }
2551     }
2552
2553     css_node_t *root_layout = new_test_css_node();
2554     {
2555       css_node_t *node_0 = root_layout;
2556       node_0->layout.position[CSS_TOP] = 0;
2557       node_0->layout.position[CSS_LEFT] = 0;
2558       node_0->layout.dimensions[CSS_WIDTH] = 20;
2559       node_0->layout.dimensions[CSS_HEIGHT] = 120;
2560       init_css_node_children(node_0, 1);
2561       {
2562         css_node_t *node_1;
2563         node_1 = node_0->get_child(node_0->context, 0);
2564         node_1->layout.position[CSS_TOP] = 0;
2565         node_1->layout.position[CSS_LEFT] = 0;
2566         node_1->layout.dimensions[CSS_WIDTH] = 20;
2567         node_1->layout.dimensions[CSS_HEIGHT] = 120;
2568         init_css_node_children(node_1, 2);
2569         {
2570           css_node_t *node_2;
2571           node_2 = node_1->get_child(node_1->context, 0);
2572           node_2->layout.position[CSS_TOP] = 110;
2573           node_2->layout.position[CSS_LEFT] = 10;
2574           node_2->layout.dimensions[CSS_WIDTH] = 0;
2575           node_2->layout.dimensions[CSS_HEIGHT] = 0;
2576           node_2 = node_1->get_child(node_1->context, 1);
2577           node_2->layout.position[CSS_TOP] = 0;
2578           node_2->layout.position[CSS_LEFT] = 20;
2579           node_2->layout.dimensions[CSS_WIDTH] = 0;
2580           node_2->layout.dimensions[CSS_HEIGHT] = 100;
2581         }
2582       }
2583     }
2584
2585     test("should layout alignItems with margin in reverse", root_node, root_layout);
2586   }
2587
2588   {
2589     css_node_t *root_node = new_test_css_node();
2590     {
2591       css_node_t *node_0 = root_node;
2592       init_css_node_children(node_0, 1);
2593       {
2594         css_node_t *node_1;
2595         node_1 = node_0->get_child(node_0->context, 0);
2596         node_1->style.flex = 1;
2597       }
2598     }
2599
2600     css_node_t *root_layout = new_test_css_node();
2601     {
2602       css_node_t *node_0 = root_layout;
2603       node_0->layout.position[CSS_TOP] = 0;
2604       node_0->layout.position[CSS_LEFT] = 0;
2605       node_0->layout.dimensions[CSS_WIDTH] = 0;
2606       node_0->layout.dimensions[CSS_HEIGHT] = 0;
2607       init_css_node_children(node_0, 1);
2608       {
2609         css_node_t *node_1;
2610         node_1 = node_0->get_child(node_0->context, 0);
2611         node_1->layout.position[CSS_TOP] = 0;
2612         node_1->layout.position[CSS_LEFT] = 0;
2613         node_1->layout.dimensions[CSS_WIDTH] = 0;
2614         node_1->layout.dimensions[CSS_HEIGHT] = 0;
2615       }
2616     }
2617
2618     test("should layout flex inside of an empty element", root_node, root_layout);
2619   }
2620
2621   {
2622     css_node_t *root_node = new_test_css_node();
2623     {
2624       css_node_t *node_0 = root_node;
2625       node_0->style.align_items = CSS_ALIGN_STRETCH;
2626       init_css_node_children(node_0, 1);
2627       {
2628         css_node_t *node_1;
2629         node_1 = node_0->get_child(node_0->context, 0);
2630         node_1->style.margin[CSS_LEFT] = 10;
2631       }
2632     }
2633
2634     css_node_t *root_layout = new_test_css_node();
2635     {
2636       css_node_t *node_0 = root_layout;
2637       node_0->layout.position[CSS_TOP] = 0;
2638       node_0->layout.position[CSS_LEFT] = 0;
2639       node_0->layout.dimensions[CSS_WIDTH] = 10;
2640       node_0->layout.dimensions[CSS_HEIGHT] = 0;
2641       init_css_node_children(node_0, 1);
2642       {
2643         css_node_t *node_1;
2644         node_1 = node_0->get_child(node_0->context, 0);
2645         node_1->layout.position[CSS_TOP] = 0;
2646         node_1->layout.position[CSS_LEFT] = 10;
2647         node_1->layout.dimensions[CSS_WIDTH] = 0;
2648         node_1->layout.dimensions[CSS_HEIGHT] = 0;
2649       }
2650     }
2651
2652     test("should layout alignItems stretch and margin", root_node, root_layout);
2653   }
2654
2655   {
2656     css_node_t *root_node = new_test_css_node();
2657     {
2658       css_node_t *node_0 = root_node;
2659       node_0->style.flex_direction = CSS_FLEX_DIRECTION_COLUMN_REVERSE;
2660       node_0->style.align_items = CSS_ALIGN_STRETCH;
2661       init_css_node_children(node_0, 1);
2662       {
2663         css_node_t *node_1;
2664         node_1 = node_0->get_child(node_0->context, 0);
2665         node_1->style.margin[CSS_LEFT] = 10;
2666       }
2667     }
2668
2669     css_node_t *root_layout = new_test_css_node();
2670     {
2671       css_node_t *node_0 = root_layout;
2672       node_0->layout.position[CSS_TOP] = 0;
2673       node_0->layout.position[CSS_LEFT] = 0;
2674       node_0->layout.dimensions[CSS_WIDTH] = 10;
2675       node_0->layout.dimensions[CSS_HEIGHT] = 0;
2676       init_css_node_children(node_0, 1);
2677       {
2678         css_node_t *node_1;
2679         node_1 = node_0->get_child(node_0->context, 0);
2680         node_1->layout.position[CSS_TOP] = 0;
2681         node_1->layout.position[CSS_LEFT] = 10;
2682         node_1->layout.dimensions[CSS_WIDTH] = 0;
2683         node_1->layout.dimensions[CSS_HEIGHT] = 0;
2684       }
2685     }
2686
2687     test("should layout alignItems stretch and margin in reverse", root_node, root_layout);
2688   }
2689
2690   {
2691     css_node_t *root_node = new_test_css_node();
2692     {
2693       css_node_t *node_0 = root_node;
2694       node_0->style.padding[CSS_LEFT] = 5;
2695       node_0->style.padding[CSS_TOP] = 5;
2696       node_0->style.padding[CSS_RIGHT] = 5;
2697       node_0->style.padding[CSS_BOTTOM] = 5;
2698       node_0->style.padding[CSS_START] = 5;
2699       node_0->style.padding[CSS_END] = 5;
2700     }
2701
2702     css_node_t *root_layout = new_test_css_node();
2703     {
2704       css_node_t *node_0 = root_layout;
2705       node_0->layout.position[CSS_TOP] = 0;
2706       node_0->layout.position[CSS_LEFT] = 0;
2707       node_0->layout.dimensions[CSS_WIDTH] = 10;
2708       node_0->layout.dimensions[CSS_HEIGHT] = 10;
2709     }
2710
2711     test("should layout node with padding", root_node, root_layout);
2712   }
2713
2714   {
2715     css_node_t *root_node = new_test_css_node();
2716     {
2717       css_node_t *node_0 = root_node;
2718       node_0->style.padding[CSS_LEFT] = 5;
2719       node_0->style.padding[CSS_TOP] = 5;
2720       node_0->style.padding[CSS_RIGHT] = 5;
2721       node_0->style.padding[CSS_BOTTOM] = 5;
2722       node_0->style.padding[CSS_START] = 5;
2723       node_0->style.padding[CSS_END] = 5;
2724       init_css_node_children(node_0, 1);
2725       {
2726         css_node_t *node_1;
2727         node_1 = node_0->get_child(node_0->context, 0);
2728       }
2729     }
2730
2731     css_node_t *root_layout = new_test_css_node();
2732     {
2733       css_node_t *node_0 = root_layout;
2734       node_0->layout.position[CSS_TOP] = 0;
2735       node_0->layout.position[CSS_LEFT] = 0;
2736       node_0->layout.dimensions[CSS_WIDTH] = 10;
2737       node_0->layout.dimensions[CSS_HEIGHT] = 10;
2738       init_css_node_children(node_0, 1);
2739       {
2740         css_node_t *node_1;
2741         node_1 = node_0->get_child(node_0->context, 0);
2742         node_1->layout.position[CSS_TOP] = 5;
2743         node_1->layout.position[CSS_LEFT] = 5;
2744         node_1->layout.dimensions[CSS_WIDTH] = 0;
2745         node_1->layout.dimensions[CSS_HEIGHT] = 0;
2746       }
2747     }
2748
2749     test("should layout node with padding and a child", root_node, root_layout);
2750   }
2751
2752   {
2753     css_node_t *root_node = new_test_css_node();
2754     {
2755       css_node_t *node_0 = root_node;
2756       node_0->style.padding[CSS_LEFT] = 5;
2757       node_0->style.padding[CSS_TOP] = 5;
2758       node_0->style.padding[CSS_RIGHT] = 5;
2759       node_0->style.padding[CSS_BOTTOM] = 5;
2760       node_0->style.padding[CSS_START] = 5;
2761       node_0->style.padding[CSS_END] = 5;
2762       init_css_node_children(node_0, 1);
2763       {
2764         css_node_t *node_1;
2765         node_1 = node_0->get_child(node_0->context, 0);
2766         node_1->style.margin[CSS_LEFT] = 5;
2767         node_1->style.margin[CSS_TOP] = 5;
2768         node_1->style.margin[CSS_RIGHT] = 5;
2769         node_1->style.margin[CSS_BOTTOM] = 5;
2770         node_1->style.margin[CSS_START] = 5;
2771         node_1->style.margin[CSS_END] = 5;
2772       }
2773     }
2774
2775     css_node_t *root_layout = new_test_css_node();
2776     {
2777       css_node_t *node_0 = root_layout;
2778       node_0->layout.position[CSS_TOP] = 0;
2779       node_0->layout.position[CSS_LEFT] = 0;
2780       node_0->layout.dimensions[CSS_WIDTH] = 20;
2781       node_0->layout.dimensions[CSS_HEIGHT] = 20;
2782       init_css_node_children(node_0, 1);
2783       {
2784         css_node_t *node_1;
2785         node_1 = node_0->get_child(node_0->context, 0);
2786         node_1->layout.position[CSS_TOP] = 10;
2787         node_1->layout.position[CSS_LEFT] = 10;
2788         node_1->layout.dimensions[CSS_WIDTH] = 0;
2789         node_1->layout.dimensions[CSS_HEIGHT] = 0;
2790       }
2791     }
2792
2793     test("should layout node with padding and a child with margin", root_node, root_layout);
2794   }
2795
2796   {
2797     css_node_t *root_node = new_test_css_node();
2798     {
2799       css_node_t *node_0 = root_node;
2800       init_css_node_children(node_0, 1);
2801       {
2802         css_node_t *node_1;
2803         node_1 = node_0->get_child(node_0->context, 0);
2804         node_1->style.align_self = CSS_ALIGN_STRETCH;
2805         node_1->style.padding[CSS_LEFT] = 10;
2806         node_1->style.padding[CSS_TOP] = 10;
2807         node_1->style.padding[CSS_RIGHT] = 10;
2808         node_1->style.padding[CSS_BOTTOM] = 10;
2809         node_1->style.padding[CSS_START] = 10;
2810         node_1->style.padding[CSS_END] = 10;
2811       }
2812     }
2813
2814     css_node_t *root_layout = new_test_css_node();
2815     {
2816       css_node_t *node_0 = root_layout;
2817       node_0->layout.position[CSS_TOP] = 0;
2818       node_0->layout.position[CSS_LEFT] = 0;
2819       node_0->layout.dimensions[CSS_WIDTH] = 20;
2820       node_0->layout.dimensions[CSS_HEIGHT] = 20;
2821       init_css_node_children(node_0, 1);
2822       {
2823         css_node_t *node_1;
2824         node_1 = node_0->get_child(node_0->context, 0);
2825         node_1->layout.position[CSS_TOP] = 0;
2826         node_1->layout.position[CSS_LEFT] = 0;
2827         node_1->layout.dimensions[CSS_WIDTH] = 20;
2828         node_1->layout.dimensions[CSS_HEIGHT] = 20;
2829       }
2830     }
2831
2832     test("should layout node with padding and stretch", root_node, root_layout);
2833   }
2834
2835   {
2836     css_node_t *root_node = new_test_css_node();
2837     {
2838       css_node_t *node_0 = root_node;
2839       node_0->style.padding[CSS_LEFT] = 50;
2840       node_0->style.padding[CSS_TOP] = 50;
2841       node_0->style.padding[CSS_RIGHT] = 50;
2842       node_0->style.padding[CSS_BOTTOM] = 50;
2843       node_0->style.padding[CSS_START] = 50;
2844       node_0->style.padding[CSS_END] = 50;
2845       init_css_node_children(node_0, 1);
2846       {
2847         css_node_t *node_1;
2848         node_1 = node_0->get_child(node_0->context, 0);
2849         node_1->style.align_self = CSS_ALIGN_STRETCH;
2850         node_1->style.padding[CSS_LEFT] = 10;
2851         node_1->style.padding[CSS_TOP] = 10;
2852         node_1->style.padding[CSS_RIGHT] = 10;
2853         node_1->style.padding[CSS_BOTTOM] = 10;
2854         node_1->style.padding[CSS_START] = 10;
2855         node_1->style.padding[CSS_END] = 10;
2856       }
2857     }
2858
2859     css_node_t *root_layout = new_test_css_node();
2860     {
2861       css_node_t *node_0 = root_layout;
2862       node_0->layout.position[CSS_TOP] = 0;
2863       node_0->layout.position[CSS_LEFT] = 0;
2864       node_0->layout.dimensions[CSS_WIDTH] = 120;
2865       node_0->layout.dimensions[CSS_HEIGHT] = 120;
2866       init_css_node_children(node_0, 1);
2867       {
2868         css_node_t *node_1;
2869         node_1 = node_0->get_child(node_0->context, 0);
2870         node_1->layout.position[CSS_TOP] = 50;
2871         node_1->layout.position[CSS_LEFT] = 50;
2872         node_1->layout.dimensions[CSS_WIDTH] = 20;
2873         node_1->layout.dimensions[CSS_HEIGHT] = 20;
2874       }
2875     }
2876
2877     test("should layout node with inner & outer padding and stretch", root_node, root_layout);
2878   }
2879
2880   {
2881     css_node_t *root_node = new_test_css_node();
2882     {
2883       css_node_t *node_0 = root_node;
2884       init_css_node_children(node_0, 1);
2885       {
2886         css_node_t *node_1;
2887         node_1 = node_0->get_child(node_0->context, 0);
2888         node_1->style.align_self = CSS_ALIGN_STRETCH;
2889         init_css_node_children(node_1, 1);
2890         {
2891           css_node_t *node_2;
2892           node_2 = node_1->get_child(node_1->context, 0);
2893           node_2->style.margin[CSS_LEFT] = 16;
2894           node_2->style.margin[CSS_TOP] = 16;
2895           node_2->style.margin[CSS_RIGHT] = 16;
2896           node_2->style.margin[CSS_BOTTOM] = 16;
2897           node_2->style.margin[CSS_START] = 16;
2898           node_2->style.margin[CSS_END] = 16;
2899         }
2900       }
2901     }
2902
2903     css_node_t *root_layout = new_test_css_node();
2904     {
2905       css_node_t *node_0 = root_layout;
2906       node_0->layout.position[CSS_TOP] = 0;
2907       node_0->layout.position[CSS_LEFT] = 0;
2908       node_0->layout.dimensions[CSS_WIDTH] = 32;
2909       node_0->layout.dimensions[CSS_HEIGHT] = 32;
2910       init_css_node_children(node_0, 1);
2911       {
2912         css_node_t *node_1;
2913         node_1 = node_0->get_child(node_0->context, 0);
2914         node_1->layout.position[CSS_TOP] = 0;
2915         node_1->layout.position[CSS_LEFT] = 0;
2916         node_1->layout.dimensions[CSS_WIDTH] = 32;
2917         node_1->layout.dimensions[CSS_HEIGHT] = 32;
2918         init_css_node_children(node_1, 1);
2919         {
2920           css_node_t *node_2;
2921           node_2 = node_1->get_child(node_1->context, 0);
2922           node_2->layout.position[CSS_TOP] = 16;
2923           node_2->layout.position[CSS_LEFT] = 16;
2924           node_2->layout.dimensions[CSS_WIDTH] = 0;
2925           node_2->layout.dimensions[CSS_HEIGHT] = 0;
2926         }
2927       }
2928     }
2929
2930     test("should layout node with stretch and child with margin", root_node, root_layout);
2931   }
2932
2933   {
2934     css_node_t *root_node = new_test_css_node();
2935     {
2936       css_node_t *node_0 = root_node;
2937       node_0->style.position[CSS_LEFT] = 5;
2938       node_0->style.position[CSS_TOP] = 5;
2939     }
2940
2941     css_node_t *root_layout = new_test_css_node();
2942     {
2943       css_node_t *node_0 = root_layout;
2944       node_0->layout.position[CSS_TOP] = 5;
2945       node_0->layout.position[CSS_LEFT] = 5;
2946       node_0->layout.dimensions[CSS_WIDTH] = 0;
2947       node_0->layout.dimensions[CSS_HEIGHT] = 0;
2948     }
2949
2950     test("should layout node with top and left", root_node, root_layout);
2951   }
2952
2953   {
2954     css_node_t *root_node = new_test_css_node();
2955     {
2956       css_node_t *node_0 = root_node;
2957       node_0->style.justify_content = CSS_JUSTIFY_SPACE_AROUND;
2958       node_0->style.dimensions[CSS_HEIGHT] = 10;
2959       node_0->style.padding[CSS_TOP] = 5;
2960       init_css_node_children(node_0, 1);
2961       {
2962         css_node_t *node_1;
2963         node_1 = node_0->get_child(node_0->context, 0);
2964       }
2965     }
2966
2967     css_node_t *root_layout = new_test_css_node();
2968     {
2969       css_node_t *node_0 = root_layout;
2970       node_0->layout.position[CSS_TOP] = 0;
2971       node_0->layout.position[CSS_LEFT] = 0;
2972       node_0->layout.dimensions[CSS_WIDTH] = 0;
2973       node_0->layout.dimensions[CSS_HEIGHT] = 10;
2974       init_css_node_children(node_0, 1);
2975       {
2976         css_node_t *node_1;
2977         node_1 = node_0->get_child(node_0->context, 0);
2978         node_1->layout.position[CSS_TOP] = 7.5;
2979         node_1->layout.position[CSS_LEFT] = 0;
2980         node_1->layout.dimensions[CSS_WIDTH] = 0;
2981         node_1->layout.dimensions[CSS_HEIGHT] = 0;
2982       }
2983     }
2984
2985     test("should layout node with height, padding and space-around", root_node, root_layout);
2986   }
2987
2988   {
2989     css_node_t *root_node = new_test_css_node();
2990     {
2991       css_node_t *node_0 = root_node;
2992       node_0->style.position[CSS_BOTTOM] = 5;
2993     }
2994
2995     css_node_t *root_layout = new_test_css_node();
2996     {
2997       css_node_t *node_0 = root_layout;
2998       node_0->layout.position[CSS_TOP] = -5;
2999       node_0->layout.position[CSS_LEFT] = 0;
3000       node_0->layout.dimensions[CSS_WIDTH] = 0;
3001       node_0->layout.dimensions[CSS_HEIGHT] = 0;
3002     }
3003
3004     test("should layout node with bottom", root_node, root_layout);
3005   }
3006
3007   {
3008     css_node_t *root_node = new_test_css_node();
3009     {
3010       css_node_t *node_0 = root_node;
3011       node_0->style.position[CSS_TOP] = 10;
3012       node_0->style.position[CSS_BOTTOM] = 5;
3013     }
3014
3015     css_node_t *root_layout = new_test_css_node();
3016     {
3017       css_node_t *node_0 = root_layout;
3018       node_0->layout.position[CSS_TOP] = 10;
3019       node_0->layout.position[CSS_LEFT] = 0;
3020       node_0->layout.dimensions[CSS_WIDTH] = 0;
3021       node_0->layout.dimensions[CSS_HEIGHT] = 0;
3022     }
3023
3024     test("should layout node with both top and bottom", root_node, root_layout);
3025   }
3026
3027   {
3028     css_node_t *root_node = new_test_css_node();
3029     {
3030       css_node_t *node_0 = root_node;
3031       node_0->style.flex_direction = CSS_FLEX_DIRECTION_ROW;
3032       node_0->style.dimensions[CSS_WIDTH] = 500;
3033       init_css_node_children(node_0, 3);
3034       {
3035         css_node_t *node_1;
3036         node_1 = node_0->get_child(node_0->context, 0);
3037         node_1->style.flex = 1;
3038         node_1 = node_0->get_child(node_0->context, 1);
3039         node_1->style.position_type = CSS_POSITION_ABSOLUTE;
3040         node_1->style.dimensions[CSS_WIDTH] = 50;
3041         node_1 = node_0->get_child(node_0->context, 2);
3042         node_1->style.flex = 1;
3043       }
3044     }
3045
3046     css_node_t *root_layout = new_test_css_node();
3047     {
3048       css_node_t *node_0 = root_layout;
3049       node_0->layout.position[CSS_TOP] = 0;
3050       node_0->layout.position[CSS_LEFT] = 0;
3051       node_0->layout.dimensions[CSS_WIDTH] = 500;
3052       node_0->layout.dimensions[CSS_HEIGHT] = 0;
3053       init_css_node_children(node_0, 3);
3054       {
3055         css_node_t *node_1;
3056         node_1 = node_0->get_child(node_0->context, 0);
3057         node_1->layout.position[CSS_TOP] = 0;
3058         node_1->layout.position[CSS_LEFT] = 0;
3059         node_1->layout.dimensions[CSS_WIDTH] = 250;
3060         node_1->layout.dimensions[CSS_HEIGHT] = 0;
3061         node_1 = node_0->get_child(node_0->context, 1);
3062         node_1->layout.position[CSS_TOP] = 0;
3063         node_1->layout.position[CSS_LEFT] = 250;
3064         node_1->layout.dimensions[CSS_WIDTH] = 50;
3065         node_1->layout.dimensions[CSS_HEIGHT] = 0;
3066         node_1 = node_0->get_child(node_0->context, 2);
3067         node_1->layout.position[CSS_TOP] = 0;
3068         node_1->layout.position[CSS_LEFT] = 250;
3069         node_1->layout.dimensions[CSS_WIDTH] = 250;
3070         node_1->layout.dimensions[CSS_HEIGHT] = 0;
3071       }
3072     }
3073
3074     test("should layout node with position: absolute", root_node, root_layout);
3075   }
3076
3077   {
3078     css_node_t *root_node = new_test_css_node();
3079     {
3080       css_node_t *node_0 = root_node;
3081       init_css_node_children(node_0, 1);
3082       {
3083         css_node_t *node_1;
3084         node_1 = node_0->get_child(node_0->context, 0);
3085         node_1->style.position_type = CSS_POSITION_ABSOLUTE;
3086         node_1->style.margin[CSS_RIGHT] = 15;
3087       }
3088     }
3089
3090     css_node_t *root_layout = new_test_css_node();
3091     {
3092       css_node_t *node_0 = root_layout;
3093       node_0->layout.position[CSS_TOP] = 0;
3094       node_0->layout.position[CSS_LEFT] = 0;
3095       node_0->layout.dimensions[CSS_WIDTH] = 0;
3096       node_0->layout.dimensions[CSS_HEIGHT] = 0;
3097       init_css_node_children(node_0, 1);
3098       {
3099         css_node_t *node_1;
3100         node_1 = node_0->get_child(node_0->context, 0);
3101         node_1->layout.position[CSS_TOP] = 0;
3102         node_1->layout.position[CSS_LEFT] = 0;
3103         node_1->layout.dimensions[CSS_WIDTH] = 0;
3104         node_1->layout.dimensions[CSS_HEIGHT] = 0;
3105       }
3106     }
3107
3108     test("should layout node with child with position: absolute and margin", root_node, root_layout);
3109   }
3110
3111   {
3112     css_node_t *root_node = new_test_css_node();
3113     {
3114       css_node_t *node_0 = root_node;
3115       init_css_node_children(node_0, 1);
3116       {
3117         css_node_t *node_1;
3118         node_1 = node_0->get_child(node_0->context, 0);
3119         node_1->style.align_self = CSS_ALIGN_CENTER;
3120         node_1->style.position_type = CSS_POSITION_ABSOLUTE;
3121         node_1->style.padding[CSS_RIGHT] = 12;
3122       }
3123     }
3124
3125     css_node_t *root_layout = new_test_css_node();
3126     {
3127       css_node_t *node_0 = root_layout;
3128       node_0->layout.position[CSS_TOP] = 0;
3129       node_0->layout.position[CSS_LEFT] = 0;
3130       node_0->layout.dimensions[CSS_WIDTH] = 0;
3131       node_0->layout.dimensions[CSS_HEIGHT] = 0;
3132       init_css_node_children(node_0, 1);
3133       {
3134         css_node_t *node_1;
3135         node_1 = node_0->get_child(node_0->context, 0);
3136         node_1->layout.position[CSS_TOP] = 0;
3137         node_1->layout.position[CSS_LEFT] = 0;
3138         node_1->layout.dimensions[CSS_WIDTH] = 12;
3139         node_1->layout.dimensions[CSS_HEIGHT] = 0;
3140       }
3141     }
3142
3143     test("should layout node with position: absolute, padding and alignSelf: center", root_node, root_layout);
3144   }
3145
3146   {
3147     css_node_t *root_node = new_test_css_node();
3148     {
3149       css_node_t *node_0 = root_node;
3150       node_0->style.dimensions[CSS_HEIGHT] = 5;
3151       node_0->style.padding[CSS_BOTTOM] = 20;
3152     }
3153
3154     css_node_t *root_layout = new_test_css_node();
3155     {
3156       css_node_t *node_0 = root_layout;
3157       node_0->layout.position[CSS_TOP] = 0;
3158       node_0->layout.position[CSS_LEFT] = 0;
3159       node_0->layout.dimensions[CSS_WIDTH] = 0;
3160       node_0->layout.dimensions[CSS_HEIGHT] = 20;
3161     }
3162
3163     test("should work with height smaller than paddingBottom", root_node, root_layout);
3164   }
3165
3166   {
3167     css_node_t *root_node = new_test_css_node();
3168     {
3169       css_node_t *node_0 = root_node;
3170       node_0->style.dimensions[CSS_WIDTH] = 5;
3171       node_0->style.padding[CSS_LEFT] = 20;
3172     }
3173
3174     css_node_t *root_layout = new_test_css_node();
3175     {
3176       css_node_t *node_0 = root_layout;
3177       node_0->layout.position[CSS_TOP] = 0;
3178       node_0->layout.position[CSS_LEFT] = 0;
3179       node_0->layout.dimensions[CSS_WIDTH] = 20;
3180       node_0->layout.dimensions[CSS_HEIGHT] = 0;
3181     }
3182
3183     test("should work with width smaller than paddingLeft", root_node, root_layout);
3184   }
3185
3186   {
3187     css_node_t *root_node = new_test_css_node();
3188     {
3189       css_node_t *node_0 = root_node;
3190       init_css_node_children(node_0, 2);
3191       {
3192         css_node_t *node_1;
3193         node_1 = node_0->get_child(node_0->context, 0);
3194         init_css_node_children(node_1, 1);
3195         {
3196           css_node_t *node_2;
3197           node_2 = node_1->get_child(node_1->context, 0);
3198           node_2->style.dimensions[CSS_WIDTH] = 400;
3199         }
3200         node_1 = node_0->get_child(node_0->context, 1);
3201         node_1->style.align_self = CSS_ALIGN_STRETCH;
3202         node_1->style.dimensions[CSS_WIDTH] = 200;
3203       }
3204     }
3205
3206     css_node_t *root_layout = new_test_css_node();
3207     {
3208       css_node_t *node_0 = root_layout;
3209       node_0->layout.position[CSS_TOP] = 0;
3210       node_0->layout.position[CSS_LEFT] = 0;
3211       node_0->layout.dimensions[CSS_WIDTH] = 400;
3212       node_0->layout.dimensions[CSS_HEIGHT] = 0;
3213       init_css_node_children(node_0, 2);
3214       {
3215         css_node_t *node_1;
3216         node_1 = node_0->get_child(node_0->context, 0);
3217         node_1->layout.position[CSS_TOP] = 0;
3218         node_1->layout.position[CSS_LEFT] = 0;
3219         node_1->layout.dimensions[CSS_WIDTH] = 400;
3220         node_1->layout.dimensions[CSS_HEIGHT] = 0;
3221         init_css_node_children(node_1, 1);
3222         {
3223           css_node_t *node_2;
3224           node_2 = node_1->get_child(node_1->context, 0);
3225           node_2->layout.position[CSS_TOP] = 0;
3226           node_2->layout.position[CSS_LEFT] = 0;
3227           node_2->layout.dimensions[CSS_WIDTH] = 400;
3228           node_2->layout.dimensions[CSS_HEIGHT] = 0;
3229         }
3230         node_1 = node_0->get_child(node_0->context, 1);
3231         node_1->layout.position[CSS_TOP] = 0;
3232         node_1->layout.position[CSS_LEFT] = 0;
3233         node_1->layout.dimensions[CSS_WIDTH] = 200;
3234         node_1->layout.dimensions[CSS_HEIGHT] = 0;
3235       }
3236     }
3237
3238     test("should layout node with specified width and stretch", root_node, root_layout);
3239   }
3240
3241   {
3242     css_node_t *root_node = new_test_css_node();
3243     {
3244       css_node_t *node_0 = root_node;
3245       node_0->style.padding[CSS_LEFT] = 5;
3246       node_0->style.padding[CSS_TOP] = 5;
3247       node_0->style.padding[CSS_RIGHT] = 5;
3248       node_0->style.padding[CSS_BOTTOM] = 5;
3249       node_0->style.padding[CSS_START] = 5;
3250       node_0->style.padding[CSS_END] = 5;
3251       init_css_node_children(node_0, 1);
3252       {
3253         css_node_t *node_1;
3254         node_1 = node_0->get_child(node_0->context, 0);
3255         node_1->style.position_type = CSS_POSITION_ABSOLUTE;
3256       }
3257     }
3258
3259     css_node_t *root_layout = new_test_css_node();
3260     {
3261       css_node_t *node_0 = root_layout;
3262       node_0->layout.position[CSS_TOP] = 0;
3263       node_0->layout.position[CSS_LEFT] = 0;
3264       node_0->layout.dimensions[CSS_WIDTH] = 10;
3265       node_0->layout.dimensions[CSS_HEIGHT] = 10;
3266       init_css_node_children(node_0, 1);
3267       {
3268         css_node_t *node_1;
3269         node_1 = node_0->get_child(node_0->context, 0);
3270         node_1->layout.position[CSS_TOP] = 5;
3271         node_1->layout.position[CSS_LEFT] = 5;
3272         node_1->layout.dimensions[CSS_WIDTH] = 0;
3273         node_1->layout.dimensions[CSS_HEIGHT] = 0;
3274       }
3275     }
3276
3277     test("should layout node with padding and child with position absolute", root_node, root_layout);
3278   }
3279
3280   {
3281     css_node_t *root_node = new_test_css_node();
3282     {
3283       css_node_t *node_0 = root_node;
3284       init_css_node_children(node_0, 2);
3285       {
3286         css_node_t *node_1;
3287         node_1 = node_0->get_child(node_0->context, 0);
3288         node_1->style.dimensions[CSS_HEIGHT] = 100;
3289         node_1 = node_0->get_child(node_0->context, 1);
3290         node_1->style.position_type = CSS_POSITION_ABSOLUTE;
3291         node_1->style.position[CSS_LEFT] = 10;
3292         node_1->style.position[CSS_TOP] = 10;
3293       }
3294     }
3295
3296     css_node_t *root_layout = new_test_css_node();
3297     {
3298       css_node_t *node_0 = root_layout;
3299       node_0->layout.position[CSS_TOP] = 0;
3300       node_0->layout.position[CSS_LEFT] = 0;
3301       node_0->layout.dimensions[CSS_WIDTH] = 0;
3302       node_0->layout.dimensions[CSS_HEIGHT] = 100;
3303       init_css_node_children(node_0, 2);
3304       {
3305         css_node_t *node_1;
3306         node_1 = node_0->get_child(node_0->context, 0);
3307         node_1->layout.position[CSS_TOP] = 0;
3308         node_1->layout.position[CSS_LEFT] = 0;
3309         node_1->layout.dimensions[CSS_WIDTH] = 0;
3310         node_1->layout.dimensions[CSS_HEIGHT] = 100;
3311         node_1 = node_0->get_child(node_0->context, 1);
3312         node_1->layout.position[CSS_TOP] = 10;
3313         node_1->layout.position[CSS_LEFT] = 10;
3314         node_1->layout.dimensions[CSS_WIDTH] = 0;
3315         node_1->layout.dimensions[CSS_HEIGHT] = 0;
3316       }
3317     }
3318
3319     test("should layout node with position absolute, top and left", root_node, root_layout);
3320   }
3321
3322   {
3323     css_node_t *root_node = new_test_css_node();
3324     {
3325       css_node_t *node_0 = root_node;
3326       node_0->style.padding[CSS_LEFT] = 20;
3327       node_0->style.padding[CSS_TOP] = 20;
3328       node_0->style.padding[CSS_RIGHT] = 20;
3329       node_0->style.padding[CSS_BOTTOM] = 20;
3330       node_0->style.padding[CSS_START] = 20;
3331       node_0->style.padding[CSS_END] = 20;
3332       init_css_node_children(node_0, 1);
3333       {
3334         css_node_t *node_1;
3335         node_1 = node_0->get_child(node_0->context, 0);
3336         node_1->style.position_type = CSS_POSITION_ABSOLUTE;
3337         node_1->style.position[CSS_LEFT] = 5;
3338       }
3339     }
3340
3341     css_node_t *root_layout = new_test_css_node();
3342     {
3343       css_node_t *node_0 = root_layout;
3344       node_0->layout.position[CSS_TOP] = 0;
3345       node_0->layout.position[CSS_LEFT] = 0;
3346       node_0->layout.dimensions[CSS_WIDTH] = 40;
3347       node_0->layout.dimensions[CSS_HEIGHT] = 40;
3348       init_css_node_children(node_0, 1);
3349       {
3350         css_node_t *node_1;
3351         node_1 = node_0->get_child(node_0->context, 0);
3352         node_1->layout.position[CSS_TOP] = 20;
3353         node_1->layout.position[CSS_LEFT] = 5;
3354         node_1->layout.dimensions[CSS_WIDTH] = 0;
3355         node_1->layout.dimensions[CSS_HEIGHT] = 0;
3356       }
3357     }
3358
3359     test("should layout node with padding and child position absolute, left", root_node, root_layout);
3360   }
3361
3362   {
3363     css_node_t *root_node = new_test_css_node();
3364     {
3365       css_node_t *node_0 = root_node;
3366       init_css_node_children(node_0, 1);
3367       {
3368         css_node_t *node_1;
3369         node_1 = node_0->get_child(node_0->context, 0);
3370         node_1->style.position_type = CSS_POSITION_ABSOLUTE;
3371         node_1->style.margin[CSS_TOP] = 5;
3372         node_1->style.position[CSS_TOP] = 5;
3373       }
3374     }
3375
3376     css_node_t *root_layout = new_test_css_node();
3377     {
3378       css_node_t *node_0 = root_layout;
3379       node_0->layout.position[CSS_TOP] = 0;
3380       node_0->layout.position[CSS_LEFT] = 0;
3381       node_0->layout.dimensions[CSS_WIDTH] = 0;
3382       node_0->layout.dimensions[CSS_HEIGHT] = 0;
3383       init_css_node_children(node_0, 1);
3384       {
3385         css_node_t *node_1;
3386         node_1 = node_0->get_child(node_0->context, 0);
3387         node_1->layout.position[CSS_TOP] = 10;
3388         node_1->layout.position[CSS_LEFT] = 0;
3389         node_1->layout.dimensions[CSS_WIDTH] = 0;
3390         node_1->layout.dimensions[CSS_HEIGHT] = 0;
3391       }
3392     }
3393
3394     test("should layout node with position: absolute, top and marginTop", root_node, root_layout);
3395   }
3396
3397   {
3398     css_node_t *root_node = new_test_css_node();
3399     {
3400       css_node_t *node_0 = root_node;
3401       init_css_node_children(node_0, 1);
3402       {
3403         css_node_t *node_1;
3404         node_1 = node_0->get_child(node_0->context, 0);
3405         node_1->style.position_type = CSS_POSITION_ABSOLUTE;
3406         node_1->style.margin[CSS_LEFT] = 5;
3407         node_1->style.position[CSS_LEFT] = 5;
3408       }
3409     }
3410
3411     css_node_t *root_layout = new_test_css_node();
3412     {
3413       css_node_t *node_0 = root_layout;
3414       node_0->layout.position[CSS_TOP] = 0;
3415       node_0->layout.position[CSS_LEFT] = 0;
3416       node_0->layout.dimensions[CSS_WIDTH] = 0;
3417       node_0->layout.dimensions[CSS_HEIGHT] = 0;
3418       init_css_node_children(node_0, 1);
3419       {
3420         css_node_t *node_1;
3421         node_1 = node_0->get_child(node_0->context, 0);
3422         node_1->layout.position[CSS_TOP] = 0;
3423         node_1->layout.position[CSS_LEFT] = 10;
3424         node_1->layout.dimensions[CSS_WIDTH] = 0;
3425         node_1->layout.dimensions[CSS_HEIGHT] = 0;
3426       }
3427     }
3428
3429     test("should layout node with position: absolute, left and marginLeft", root_node, root_layout);
3430   }
3431
3432   {
3433     css_node_t *root_node = new_test_css_node();
3434     {
3435       css_node_t *node_0 = root_node;
3436       node_0->style.justify_content = CSS_JUSTIFY_SPACE_AROUND;
3437       node_0->style.dimensions[CSS_HEIGHT] = 200;
3438       init_css_node_children(node_0, 2);
3439       {
3440         css_node_t *node_1;
3441         node_1 = node_0->get_child(node_0->context, 0);
3442         node_1->style.position_type = CSS_POSITION_ABSOLUTE;
3443         node_1 = node_0->get_child(node_0->context, 1);
3444       }
3445     }
3446
3447     css_node_t *root_layout = new_test_css_node();
3448     {
3449       css_node_t *node_0 = root_layout;
3450       node_0->layout.position[CSS_TOP] = 0;
3451       node_0->layout.position[CSS_LEFT] = 0;
3452       node_0->layout.dimensions[CSS_WIDTH] = 0;
3453       node_0->layout.dimensions[CSS_HEIGHT] = 200;
3454       init_css_node_children(node_0, 2);
3455       {
3456         css_node_t *node_1;
3457         node_1 = node_0->get_child(node_0->context, 0);
3458         node_1->layout.position[CSS_TOP] = 100;
3459         node_1->layout.position[CSS_LEFT] = 0;
3460         node_1->layout.dimensions[CSS_WIDTH] = 0;
3461         node_1->layout.dimensions[CSS_HEIGHT] = 0;
3462         node_1 = node_0->get_child(node_0->context, 1);
3463         node_1->layout.position[CSS_TOP] = 100;
3464         node_1->layout.position[CSS_LEFT] = 0;
3465         node_1->layout.dimensions[CSS_WIDTH] = 0;
3466         node_1->layout.dimensions[CSS_HEIGHT] = 0;
3467       }
3468     }
3469
3470     test("should layout node with space-around and child position absolute", root_node, root_layout);
3471   }
3472
3473   {
3474     css_node_t *root_node = new_test_css_node();
3475     {
3476       css_node_t *node_0 = root_node;
3477       node_0->style.flex_direction = CSS_FLEX_DIRECTION_COLUMN_REVERSE;
3478       node_0->style.justify_content = CSS_JUSTIFY_SPACE_AROUND;
3479       node_0->style.dimensions[CSS_HEIGHT] = 200;
3480       init_css_node_children(node_0, 2);
3481       {
3482         css_node_t *node_1;
3483         node_1 = node_0->get_child(node_0->context, 0);
3484         node_1->style.position_type = CSS_POSITION_ABSOLUTE;
3485         node_1 = node_0->get_child(node_0->context, 1);
3486       }
3487     }
3488
3489     css_node_t *root_layout = new_test_css_node();
3490     {
3491       css_node_t *node_0 = root_layout;
3492       node_0->layout.position[CSS_TOP] = 0;
3493       node_0->layout.position[CSS_LEFT] = 0;
3494       node_0->layout.dimensions[CSS_WIDTH] = 0;
3495       node_0->layout.dimensions[CSS_HEIGHT] = 200;
3496       init_css_node_children(node_0, 2);
3497       {
3498         css_node_t *node_1;
3499         node_1 = node_0->get_child(node_0->context, 0);
3500         node_1->layout.position[CSS_TOP] = 100;
3501         node_1->layout.position[CSS_LEFT] = 0;
3502         node_1->layout.dimensions[CSS_WIDTH] = 0;
3503         node_1->layout.dimensions[CSS_HEIGHT] = 0;
3504         node_1 = node_0->get_child(node_0->context, 1);
3505         node_1->layout.position[CSS_TOP] = 100;
3506         node_1->layout.position[CSS_LEFT] = 0;
3507         node_1->layout.dimensions[CSS_WIDTH] = 0;
3508         node_1->layout.dimensions[CSS_HEIGHT] = 0;
3509       }
3510     }
3511
3512     test("should layout node with space-around and child position absolute in reverse", root_node, root_layout);
3513   }
3514
3515   {
3516     css_node_t *root_node = new_test_css_node();
3517     {
3518       css_node_t *node_0 = root_node;
3519       node_0->style.flex_direction = CSS_FLEX_DIRECTION_ROW;
3520       node_0->style.dimensions[CSS_WIDTH] = 700;
3521       init_css_node_children(node_0, 1);
3522       {
3523         css_node_t *node_1;
3524         node_1 = node_0->get_child(node_0->context, 0);
3525         node_1->style.flex = 1;
3526         node_1->style.margin[CSS_LEFT] = 5;
3527       }
3528     }
3529
3530     css_node_t *root_layout = new_test_css_node();
3531     {
3532       css_node_t *node_0 = root_layout;
3533       node_0->layout.position[CSS_TOP] = 0;
3534       node_0->layout.position[CSS_LEFT] = 0;
3535       node_0->layout.dimensions[CSS_WIDTH] = 700;
3536       node_0->layout.dimensions[CSS_HEIGHT] = 0;
3537       init_css_node_children(node_0, 1);
3538       {
3539         css_node_t *node_1;
3540         node_1 = node_0->get_child(node_0->context, 0);
3541         node_1->layout.position[CSS_TOP] = 0;
3542         node_1->layout.position[CSS_LEFT] = 5;
3543         node_1->layout.dimensions[CSS_WIDTH] = 695;
3544         node_1->layout.dimensions[CSS_HEIGHT] = 0;
3545       }
3546     }
3547
3548     test("should layout node with flex and main margin", root_node, root_layout);
3549   }
3550
3551   {
3552     css_node_t *root_node = new_test_css_node();
3553     {
3554       css_node_t *node_0 = root_node;
3555       node_0->style.direction = CSS_DIRECTION_RTL;
3556       node_0->style.flex_direction = CSS_FLEX_DIRECTION_ROW;
3557       node_0->style.dimensions[CSS_WIDTH] = 700;
3558       init_css_node_children(node_0, 1);
3559       {
3560         css_node_t *node_1;
3561         node_1 = node_0->get_child(node_0->context, 0);
3562         node_1->style.flex = 1;
3563         node_1->style.margin[CSS_RIGHT] = 5;
3564       }
3565     }
3566
3567     css_node_t *root_layout = new_test_css_node();
3568     {
3569       css_node_t *node_0 = root_layout;
3570       node_0->layout.position[CSS_TOP] = 0;
3571       node_0->layout.position[CSS_LEFT] = 0;
3572       node_0->layout.dimensions[CSS_WIDTH] = 700;
3573       node_0->layout.dimensions[CSS_HEIGHT] = 0;
3574       init_css_node_children(node_0, 1);
3575       {
3576         css_node_t *node_1;
3577         node_1 = node_0->get_child(node_0->context, 0);
3578         node_1->layout.position[CSS_TOP] = 0;
3579         node_1->layout.position[CSS_LEFT] = 0;
3580         node_1->layout.dimensions[CSS_WIDTH] = 695;
3581         node_1->layout.dimensions[CSS_HEIGHT] = 0;
3582       }
3583     }
3584
3585     test("should layout node with flex and main margin in rtl", root_node, root_layout);
3586   }
3587
3588   {
3589     css_node_t *root_node = new_test_css_node();
3590     {
3591       css_node_t *node_0 = root_node;
3592       node_0->style.flex_direction = CSS_FLEX_DIRECTION_ROW;
3593       node_0->style.dimensions[CSS_WIDTH] = 700;
3594       init_css_node_children(node_0, 2);
3595       {
3596         css_node_t *node_1;
3597         node_1 = node_0->get_child(node_0->context, 0);
3598         node_1->style.flex = 1;
3599         node_1 = node_0->get_child(node_0->context, 1);
3600         node_1->style.flex = 1;
3601         node_1->style.padding[CSS_RIGHT] = 5;
3602       }
3603     }
3604
3605     css_node_t *root_layout = new_test_css_node();
3606     {
3607       css_node_t *node_0 = root_layout;
3608       node_0->layout.position[CSS_TOP] = 0;
3609       node_0->layout.position[CSS_LEFT] = 0;
3610       node_0->layout.dimensions[CSS_WIDTH] = 700;
3611       node_0->layout.dimensions[CSS_HEIGHT] = 0;
3612       init_css_node_children(node_0, 2);
3613       {
3614         css_node_t *node_1;
3615         node_1 = node_0->get_child(node_0->context, 0);
3616         node_1->layout.position[CSS_TOP] = 0;
3617         node_1->layout.position[CSS_LEFT] = 0;
3618         node_1->layout.dimensions[CSS_WIDTH] = 347.5;
3619         node_1->layout.dimensions[CSS_HEIGHT] = 0;
3620         node_1 = node_0->get_child(node_0->context, 1);
3621         node_1->layout.position[CSS_TOP] = 0;
3622         node_1->layout.position[CSS_LEFT] = 347.5;
3623         node_1->layout.dimensions[CSS_WIDTH] = 352.5;
3624         node_1->layout.dimensions[CSS_HEIGHT] = 0;
3625       }
3626     }
3627
3628     test("should layout node with multiple flex and padding", root_node, root_layout);
3629   }
3630
3631   {
3632     css_node_t *root_node = new_test_css_node();
3633     {
3634       css_node_t *node_0 = root_node;
3635       node_0->style.direction = CSS_DIRECTION_RTL;
3636       node_0->style.flex_direction = CSS_FLEX_DIRECTION_ROW;
3637       node_0->style.dimensions[CSS_WIDTH] = 700;
3638       init_css_node_children(node_0, 2);
3639       {
3640         css_node_t *node_1;
3641         node_1 = node_0->get_child(node_0->context, 0);
3642         node_1->style.flex = 1;
3643         node_1 = node_0->get_child(node_0->context, 1);
3644         node_1->style.flex = 1;
3645         node_1->style.padding[CSS_LEFT] = 5;
3646       }
3647     }
3648
3649     css_node_t *root_layout = new_test_css_node();
3650     {
3651       css_node_t *node_0 = root_layout;
3652       node_0->layout.position[CSS_TOP] = 0;
3653       node_0->layout.position[CSS_LEFT] = 0;
3654       node_0->layout.dimensions[CSS_WIDTH] = 700;
3655       node_0->layout.dimensions[CSS_HEIGHT] = 0;
3656       init_css_node_children(node_0, 2);
3657       {
3658         css_node_t *node_1;
3659         node_1 = node_0->get_child(node_0->context, 0);
3660         node_1->layout.position[CSS_TOP] = 0;
3661         node_1->layout.position[CSS_LEFT] = 352.5;
3662         node_1->layout.dimensions[CSS_WIDTH] = 347.5;
3663         node_1->layout.dimensions[CSS_HEIGHT] = 0;
3664         node_1 = node_0->get_child(node_0->context, 1);
3665         node_1->layout.position[CSS_TOP] = 0;
3666         node_1->layout.position[CSS_LEFT] = 0;
3667         node_1->layout.dimensions[CSS_WIDTH] = 352.5;
3668         node_1->layout.dimensions[CSS_HEIGHT] = 0;
3669       }
3670     }
3671
3672     test("should layout node with multiple flex and padding in rtl", root_node, root_layout);
3673   }
3674
3675   {
3676     css_node_t *root_node = new_test_css_node();
3677     {
3678       css_node_t *node_0 = root_node;
3679       node_0->style.flex_direction = CSS_FLEX_DIRECTION_ROW;
3680       node_0->style.dimensions[CSS_WIDTH] = 700;
3681       init_css_node_children(node_0, 2);
3682       {
3683         css_node_t *node_1;
3684         node_1 = node_0->get_child(node_0->context, 0);
3685         node_1->style.flex = 1;
3686         node_1 = node_0->get_child(node_0->context, 1);
3687         node_1->style.flex = 1;
3688         node_1->style.margin[CSS_LEFT] = 5;
3689       }
3690     }
3691
3692     css_node_t *root_layout = new_test_css_node();
3693     {
3694       css_node_t *node_0 = root_layout;
3695       node_0->layout.position[CSS_TOP] = 0;
3696       node_0->layout.position[CSS_LEFT] = 0;
3697       node_0->layout.dimensions[CSS_WIDTH] = 700;
3698       node_0->layout.dimensions[CSS_HEIGHT] = 0;
3699       init_css_node_children(node_0, 2);
3700       {
3701         css_node_t *node_1;
3702         node_1 = node_0->get_child(node_0->context, 0);
3703         node_1->layout.position[CSS_TOP] = 0;
3704         node_1->layout.position[CSS_LEFT] = 0;
3705         node_1->layout.dimensions[CSS_WIDTH] = 347.5;
3706         node_1->layout.dimensions[CSS_HEIGHT] = 0;
3707         node_1 = node_0->get_child(node_0->context, 1);
3708         node_1->layout.position[CSS_TOP] = 0;
3709         node_1->layout.position[CSS_LEFT] = 352.5;
3710         node_1->layout.dimensions[CSS_WIDTH] = 347.5;
3711         node_1->layout.dimensions[CSS_HEIGHT] = 0;
3712       }
3713     }
3714
3715     test("should layout node with multiple flex and margin", root_node, root_layout);
3716   }
3717
3718   {
3719     css_node_t *root_node = new_test_css_node();
3720     {
3721       css_node_t *node_0 = root_node;
3722       node_0->style.direction = CSS_DIRECTION_RTL;
3723       node_0->style.flex_direction = CSS_FLEX_DIRECTION_ROW;
3724       node_0->style.dimensions[CSS_WIDTH] = 700;
3725       init_css_node_children(node_0, 2);
3726       {
3727         css_node_t *node_1;
3728         node_1 = node_0->get_child(node_0->context, 0);
3729         node_1->style.flex = 1;
3730         node_1 = node_0->get_child(node_0->context, 1);
3731         node_1->style.flex = 1;
3732         node_1->style.margin[CSS_RIGHT] = 5;
3733       }
3734     }
3735
3736     css_node_t *root_layout = new_test_css_node();
3737     {
3738       css_node_t *node_0 = root_layout;
3739       node_0->layout.position[CSS_TOP] = 0;
3740       node_0->layout.position[CSS_LEFT] = 0;
3741       node_0->layout.dimensions[CSS_WIDTH] = 700;
3742       node_0->layout.dimensions[CSS_HEIGHT] = 0;
3743       init_css_node_children(node_0, 2);
3744       {
3745         css_node_t *node_1;
3746         node_1 = node_0->get_child(node_0->context, 0);
3747         node_1->layout.position[CSS_TOP] = 0;
3748         node_1->layout.position[CSS_LEFT] = 352.5;
3749         node_1->layout.dimensions[CSS_WIDTH] = 347.5;
3750         node_1->layout.dimensions[CSS_HEIGHT] = 0;
3751         node_1 = node_0->get_child(node_0->context, 1);
3752         node_1->layout.position[CSS_TOP] = 0;
3753         node_1->layout.position[CSS_LEFT] = 0;
3754         node_1->layout.dimensions[CSS_WIDTH] = 347.5;
3755         node_1->layout.dimensions[CSS_HEIGHT] = 0;
3756       }
3757     }
3758
3759     test("should layout node with multiple flex and margin in rtl", root_node, root_layout);
3760   }
3761
3762   {
3763     css_node_t *root_node = new_test_css_node();
3764     {
3765       css_node_t *node_0 = root_node;
3766       node_0->style.dimensions[CSS_HEIGHT] = 300;
3767       init_css_node_children(node_0, 2);
3768       {
3769         css_node_t *node_1;
3770         node_1 = node_0->get_child(node_0->context, 0);
3771         node_1->style.dimensions[CSS_HEIGHT] = 600;
3772         node_1 = node_0->get_child(node_0->context, 1);
3773         node_1->style.flex = 1;
3774       }
3775     }
3776
3777     css_node_t *root_layout = new_test_css_node();
3778     {
3779       css_node_t *node_0 = root_layout;
3780       node_0->layout.position[CSS_TOP] = 0;
3781       node_0->layout.position[CSS_LEFT] = 0;
3782       node_0->layout.dimensions[CSS_WIDTH] = 0;
3783       node_0->layout.dimensions[CSS_HEIGHT] = 300;
3784       init_css_node_children(node_0, 2);
3785       {
3786         css_node_t *node_1;
3787         node_1 = node_0->get_child(node_0->context, 0);
3788         node_1->layout.position[CSS_TOP] = 0;
3789         node_1->layout.position[CSS_LEFT] = 0;
3790         node_1->layout.dimensions[CSS_WIDTH] = 0;
3791         node_1->layout.dimensions[CSS_HEIGHT] = 600;
3792         node_1 = node_0->get_child(node_0->context, 1);
3793         node_1->layout.position[CSS_TOP] = 600;
3794         node_1->layout.position[CSS_LEFT] = 0;
3795         node_1->layout.dimensions[CSS_WIDTH] = 0;
3796         node_1->layout.dimensions[CSS_HEIGHT] = 0;
3797       }
3798     }
3799
3800     test("should layout node with flex and overflow", root_node, root_layout);
3801   }
3802
3803   {
3804     css_node_t *root_node = new_test_css_node();
3805     {
3806       css_node_t *node_0 = root_node;
3807       node_0->style.flex_direction = CSS_FLEX_DIRECTION_ROW;
3808       node_0->style.dimensions[CSS_WIDTH] = 600;
3809       init_css_node_children(node_0, 1);
3810       {
3811         css_node_t *node_1;
3812         node_1 = node_0->get_child(node_0->context, 0);
3813         node_1->style.position_type = CSS_POSITION_ABSOLUTE;
3814         node_1->style.flex = 1;
3815       }
3816     }
3817
3818     css_node_t *root_layout = new_test_css_node();
3819     {
3820       css_node_t *node_0 = root_layout;
3821       node_0->layout.position[CSS_TOP] = 0;
3822       node_0->layout.position[CSS_LEFT] = 0;
3823       node_0->layout.dimensions[CSS_WIDTH] = 600;
3824       node_0->layout.dimensions[CSS_HEIGHT] = 0;
3825       init_css_node_children(node_0, 1);
3826       {
3827         css_node_t *node_1;
3828         node_1 = node_0->get_child(node_0->context, 0);
3829         node_1->layout.position[CSS_TOP] = 0;
3830         node_1->layout.position[CSS_LEFT] = 0;
3831         node_1->layout.dimensions[CSS_WIDTH] = 0;
3832         node_1->layout.dimensions[CSS_HEIGHT] = 0;
3833       }
3834     }
3835
3836     test("should layout node with flex and position absolute", root_node, root_layout);
3837   }
3838
3839   {
3840     css_node_t *root_node = new_test_css_node();
3841     {
3842       css_node_t *node_0 = root_node;
3843       node_0->style.direction = CSS_DIRECTION_RTL;
3844       node_0->style.flex_direction = CSS_FLEX_DIRECTION_ROW;
3845       node_0->style.dimensions[CSS_WIDTH] = 600;
3846       init_css_node_children(node_0, 1);
3847       {
3848         css_node_t *node_1;
3849         node_1 = node_0->get_child(node_0->context, 0);
3850         node_1->style.position_type = CSS_POSITION_ABSOLUTE;
3851         node_1->style.flex = 1;
3852       }
3853     }
3854
3855     css_node_t *root_layout = new_test_css_node();
3856     {
3857       css_node_t *node_0 = root_layout;
3858       node_0->layout.position[CSS_TOP] = 0;
3859       node_0->layout.position[CSS_LEFT] = 0;
3860       node_0->layout.dimensions[CSS_WIDTH] = 600;
3861       node_0->layout.dimensions[CSS_HEIGHT] = 0;
3862       init_css_node_children(node_0, 1);
3863       {
3864         css_node_t *node_1;
3865         node_1 = node_0->get_child(node_0->context, 0);
3866         node_1->layout.position[CSS_TOP] = 0;
3867         node_1->layout.position[CSS_LEFT] = 600;
3868         node_1->layout.dimensions[CSS_WIDTH] = 0;
3869         node_1->layout.dimensions[CSS_HEIGHT] = 0;
3870       }
3871     }
3872
3873     test("should layout node with flex and position absolute in rtl", root_node, root_layout);
3874   }
3875
3876   {
3877     css_node_t *root_node = new_test_css_node();
3878     {
3879       css_node_t *node_0 = root_node;
3880       node_0->style.dimensions[CSS_HEIGHT] = 500;
3881       init_css_node_children(node_0, 2);
3882       {
3883         css_node_t *node_1;
3884         node_1 = node_0->get_child(node_0->context, 0);
3885         node_1->style.flex = 1;
3886         node_1 = node_0->get_child(node_0->context, 1);
3887         node_1->style.position_type = CSS_POSITION_ABSOLUTE;
3888         node_1->style.flex = 1;
3889       }
3890     }
3891
3892     css_node_t *root_layout = new_test_css_node();
3893     {
3894       css_node_t *node_0 = root_layout;
3895       node_0->layout.position[CSS_TOP] = 0;
3896       node_0->layout.position[CSS_LEFT] = 0;
3897       node_0->layout.dimensions[CSS_WIDTH] = 0;
3898       node_0->layout.dimensions[CSS_HEIGHT] = 500;
3899       init_css_node_children(node_0, 2);
3900       {
3901         css_node_t *node_1;
3902         node_1 = node_0->get_child(node_0->context, 0);
3903         node_1->layout.position[CSS_TOP] = 0;
3904         node_1->layout.position[CSS_LEFT] = 0;
3905         node_1->layout.dimensions[CSS_WIDTH] = 0;
3906         node_1->layout.dimensions[CSS_HEIGHT] = 500;
3907         node_1 = node_0->get_child(node_0->context, 1);
3908         node_1->layout.position[CSS_TOP] = 500;
3909         node_1->layout.position[CSS_LEFT] = 0;
3910         node_1->layout.dimensions[CSS_WIDTH] = 0;
3911         node_1->layout.dimensions[CSS_HEIGHT] = 0;
3912       }
3913     }
3914
3915     test("should layout node with double flex and position absolute", root_node, root_layout);
3916   }
3917
3918   {
3919     css_node_t *root_node = new_test_css_node();
3920     {
3921       css_node_t *node_0 = root_node;
3922       node_0->style.border[CSS_LEFT] = 5;
3923       node_0->style.border[CSS_TOP] = 5;
3924       node_0->style.border[CSS_RIGHT] = 5;
3925       node_0->style.border[CSS_BOTTOM] = 5;
3926       node_0->style.border[CSS_START] = 5;
3927       node_0->style.border[CSS_END] = 5;
3928     }
3929
3930     css_node_t *root_layout = new_test_css_node();
3931     {
3932       css_node_t *node_0 = root_layout;
3933       node_0->layout.position[CSS_TOP] = 0;
3934       node_0->layout.position[CSS_LEFT] = 0;
3935       node_0->layout.dimensions[CSS_WIDTH] = 10;
3936       node_0->layout.dimensions[CSS_HEIGHT] = 10;
3937     }
3938
3939     test("should layout node with borderWidth", root_node, root_layout);
3940   }
3941
3942   {
3943     css_node_t *root_node = new_test_css_node();
3944     {
3945       css_node_t *node_0 = root_node;
3946       node_0->style.border[CSS_TOP] = 1;
3947       init_css_node_children(node_0, 1);
3948       {
3949         css_node_t *node_1;
3950         node_1 = node_0->get_child(node_0->context, 0);
3951         node_1->style.position_type = CSS_POSITION_ABSOLUTE;
3952         node_1->style.position[CSS_TOP] = -1;
3953       }
3954     }
3955
3956     css_node_t *root_layout = new_test_css_node();
3957     {
3958       css_node_t *node_0 = root_layout;
3959       node_0->layout.position[CSS_TOP] = 0;
3960       node_0->layout.position[CSS_LEFT] = 0;
3961       node_0->layout.dimensions[CSS_WIDTH] = 0;
3962       node_0->layout.dimensions[CSS_HEIGHT] = 1;
3963       init_css_node_children(node_0, 1);
3964       {
3965         css_node_t *node_1;
3966         node_1 = node_0->get_child(node_0->context, 0);
3967         node_1->layout.position[CSS_TOP] = 0;
3968         node_1->layout.position[CSS_LEFT] = 0;
3969         node_1->layout.dimensions[CSS_WIDTH] = 0;
3970         node_1->layout.dimensions[CSS_HEIGHT] = 0;
3971       }
3972     }
3973
3974     test("should layout node with borderWidth and position: absolute, top", root_node, root_layout);
3975   }
3976
3977   {
3978     css_node_t *root_node = new_test_css_node();
3979     {
3980       css_node_t *node_0 = root_node;
3981       node_0->style.border[CSS_LEFT] = 1;
3982       node_0->style.border[CSS_TOP] = 1;
3983       node_0->style.border[CSS_RIGHT] = 1;
3984       node_0->style.border[CSS_BOTTOM] = 1;
3985       node_0->style.border[CSS_START] = 1;
3986       node_0->style.border[CSS_END] = 1;
3987       init_css_node_children(node_0, 1);
3988       {
3989         css_node_t *node_1;
3990         node_1 = node_0->get_child(node_0->context, 0);
3991         node_1->style.position_type = CSS_POSITION_ABSOLUTE;
3992         node_1->style.position[CSS_LEFT] = 5;
3993       }
3994     }
3995
3996     css_node_t *root_layout = new_test_css_node();
3997     {
3998       css_node_t *node_0 = root_layout;
3999       node_0->layout.position[CSS_TOP] = 0;
4000       node_0->layout.position[CSS_LEFT] = 0;
4001       node_0->layout.dimensions[CSS_WIDTH] = 2;
4002       node_0->layout.dimensions[CSS_HEIGHT] = 2;
4003       init_css_node_children(node_0, 1);
4004       {
4005         css_node_t *node_1;
4006         node_1 = node_0->get_child(node_0->context, 0);
4007         node_1->layout.position[CSS_TOP] = 1;
4008         node_1->layout.position[CSS_LEFT] = 6;
4009         node_1->layout.dimensions[CSS_WIDTH] = 0;
4010         node_1->layout.dimensions[CSS_HEIGHT] = 0;
4011       }
4012     }
4013
4014     test("should layout node with borderWidth and position: absolute, top. cross axis", root_node, root_layout);
4015   }
4016
4017   {
4018     css_node_t *root_node = new_test_css_node();
4019     {
4020       css_node_t *node_0 = root_node;
4021       node_0->style.dimensions[CSS_WIDTH] = 50;
4022       init_css_node_children(node_0, 1);
4023       {
4024         css_node_t *node_1;
4025         node_1 = node_0->get_child(node_0->context, 0);
4026         node_1->style.align_self = CSS_ALIGN_STRETCH;
4027         node_1->style.margin[CSS_LEFT] = 20;
4028         node_1->style.padding[CSS_LEFT] = 20;
4029         node_1->style.padding[CSS_TOP] = 20;
4030         node_1->style.padding[CSS_RIGHT] = 20;
4031         node_1->style.padding[CSS_BOTTOM] = 20;
4032         node_1->style.padding[CSS_START] = 20;
4033         node_1->style.padding[CSS_END] = 20;
4034       }
4035     }
4036
4037     css_node_t *root_layout = new_test_css_node();
4038     {
4039       css_node_t *node_0 = root_layout;
4040       node_0->layout.position[CSS_TOP] = 0;
4041       node_0->layout.position[CSS_LEFT] = 0;
4042       node_0->layout.dimensions[CSS_WIDTH] = 50;
4043       node_0->layout.dimensions[CSS_HEIGHT] = 40;
4044       init_css_node_children(node_0, 1);
4045       {
4046         css_node_t *node_1;
4047         node_1 = node_0->get_child(node_0->context, 0);
4048         node_1->layout.position[CSS_TOP] = 0;
4049         node_1->layout.position[CSS_LEFT] = 20;
4050         node_1->layout.dimensions[CSS_WIDTH] = 40;
4051         node_1->layout.dimensions[CSS_HEIGHT] = 40;
4052       }
4053     }
4054
4055     test("should correctly take into account min padding for stretch", root_node, root_layout);
4056   }
4057
4058   {
4059     css_node_t *root_node = new_test_css_node();
4060     {
4061       css_node_t *node_0 = root_node;
4062       node_0->style.dimensions[CSS_WIDTH] = -31;
4063       init_css_node_children(node_0, 1);
4064       {
4065         css_node_t *node_1;
4066         node_1 = node_0->get_child(node_0->context, 0);
4067         node_1->style.border[CSS_RIGHT] = 5;
4068       }
4069     }
4070
4071     css_node_t *root_layout = new_test_css_node();
4072     {
4073       css_node_t *node_0 = root_layout;
4074       node_0->layout.position[CSS_TOP] = 0;
4075       node_0->layout.position[CSS_LEFT] = 0;
4076       node_0->layout.dimensions[CSS_WIDTH] = 5;
4077       node_0->layout.dimensions[CSS_HEIGHT] = 0;
4078       init_css_node_children(node_0, 1);
4079       {
4080         css_node_t *node_1;
4081         node_1 = node_0->get_child(node_0->context, 0);
4082         node_1->layout.position[CSS_TOP] = 0;
4083         node_1->layout.position[CSS_LEFT] = 0;
4084         node_1->layout.dimensions[CSS_WIDTH] = 5;
4085         node_1->layout.dimensions[CSS_HEIGHT] = 0;
4086       }
4087     }
4088
4089     test("should layout node with negative width", root_node, root_layout);
4090   }
4091
4092   {
4093     css_node_t *root_node = new_test_css_node();
4094     {
4095       css_node_t *node_0 = root_node;
4096       node_0->style.flex_direction = CSS_FLEX_DIRECTION_ROW;
4097       node_0->style.border[CSS_RIGHT] = 1;
4098       init_css_node_children(node_0, 1);
4099       {
4100         css_node_t *node_1;
4101         node_1 = node_0->get_child(node_0->context, 0);
4102         node_1->style.margin[CSS_RIGHT] = -8;
4103       }
4104     }
4105
4106     css_node_t *root_layout = new_test_css_node();
4107     {
4108       css_node_t *node_0 = root_layout;
4109       node_0->layout.position[CSS_TOP] = 0;
4110       node_0->layout.position[CSS_LEFT] = 0;
4111       node_0->layout.dimensions[CSS_WIDTH] = 1;
4112       node_0->layout.dimensions[CSS_HEIGHT] = 0;
4113       init_css_node_children(node_0, 1);
4114       {
4115         css_node_t *node_1;
4116         node_1 = node_0->get_child(node_0->context, 0);
4117         node_1->layout.position[CSS_TOP] = 0;
4118         node_1->layout.position[CSS_LEFT] = 0;
4119         node_1->layout.dimensions[CSS_WIDTH] = 0;
4120         node_1->layout.dimensions[CSS_HEIGHT] = 0;
4121       }
4122     }
4123
4124     test("should handle negative margin and min padding correctly", root_node, root_layout);
4125   }
4126
4127   {
4128     css_node_t *root_node = new_test_css_node();
4129     {
4130       css_node_t *node_0 = root_node;
4131       node_0->style.direction = CSS_DIRECTION_RTL;
4132       node_0->style.flex_direction = CSS_FLEX_DIRECTION_ROW;
4133       node_0->style.border[CSS_LEFT] = 1;
4134       init_css_node_children(node_0, 1);
4135       {
4136         css_node_t *node_1;
4137         node_1 = node_0->get_child(node_0->context, 0);
4138         node_1->style.margin[CSS_LEFT] = -8;
4139       }
4140     }
4141
4142     css_node_t *root_layout = new_test_css_node();
4143     {
4144       css_node_t *node_0 = root_layout;
4145       node_0->layout.position[CSS_TOP] = 0;
4146       node_0->layout.position[CSS_LEFT] = 0;
4147       node_0->layout.dimensions[CSS_WIDTH] = 1;
4148       node_0->layout.dimensions[CSS_HEIGHT] = 0;
4149       init_css_node_children(node_0, 1);
4150       {
4151         css_node_t *node_1;
4152         node_1 = node_0->get_child(node_0->context, 0);
4153         node_1->layout.position[CSS_TOP] = 0;
4154         node_1->layout.position[CSS_LEFT] = 1;
4155         node_1->layout.dimensions[CSS_WIDTH] = 0;
4156         node_1->layout.dimensions[CSS_HEIGHT] = 0;
4157       }
4158     }
4159
4160     test("should handle negative margin and min padding correctly in rtl", root_node, root_layout);
4161   }
4162
4163   {
4164     css_node_t *root_node = new_test_css_node();
4165     {
4166       css_node_t *node_0 = root_node;
4167       node_0->measure = measure;
4168       node_0->context = "small";
4169     }
4170
4171     css_node_t *root_layout = new_test_css_node();
4172     {
4173       css_node_t *node_0 = root_layout;
4174       node_0->layout.position[CSS_TOP] = 0;
4175       node_0->layout.position[CSS_LEFT] = 0;
4176       node_0->layout.dimensions[CSS_WIDTH] = 35;
4177       node_0->layout.dimensions[CSS_HEIGHT] = 18;
4178     }
4179
4180     test("should layout node with just text", root_node, root_layout);
4181   }
4182
4183   {
4184     css_node_t *root_node = new_test_css_node();
4185     {
4186       css_node_t *node_0 = root_node;
4187       node_0->style.dimensions[CSS_WIDTH] = 100;
4188       node_0->measure = measure;
4189       node_0->context = "measureWithRatio2";
4190     }
4191
4192     css_node_t *root_layout = new_test_css_node();
4193     {
4194       css_node_t *node_0 = root_layout;
4195       node_0->layout.position[CSS_TOP] = 0;
4196       node_0->layout.position[CSS_LEFT] = 0;
4197       node_0->layout.dimensions[CSS_WIDTH] = 100;
4198       node_0->layout.dimensions[CSS_HEIGHT] = 200;
4199     }
4200
4201     test("should layout node with fixed width and custom measure function", root_node, root_layout);
4202   }
4203
4204   {
4205     css_node_t *root_node = new_test_css_node();
4206     {
4207       css_node_t *node_0 = root_node;
4208       node_0->style.dimensions[CSS_HEIGHT] = 100;
4209       node_0->measure = measure;
4210       node_0->context = "measureWithRatio2";
4211     }
4212
4213     css_node_t *root_layout = new_test_css_node();
4214     {
4215       css_node_t *node_0 = root_layout;
4216       node_0->layout.position[CSS_TOP] = 0;
4217       node_0->layout.position[CSS_LEFT] = 0;
4218       node_0->layout.dimensions[CSS_WIDTH] = 200;
4219       node_0->layout.dimensions[CSS_HEIGHT] = 100;
4220     }
4221
4222     test("should layout node with fixed height and custom measure function", root_node, root_layout);
4223   }
4224
4225   {
4226     css_node_t *root_node = new_test_css_node();
4227     {
4228       css_node_t *node_0 = root_node;
4229       node_0->style.dimensions[CSS_WIDTH] = 100;
4230       node_0->style.dimensions[CSS_HEIGHT] = 100;
4231       node_0->measure = measure;
4232       node_0->context = "measureWithRatio2";
4233     }
4234
4235     css_node_t *root_layout = new_test_css_node();
4236     {
4237       css_node_t *node_0 = root_layout;
4238       node_0->layout.position[CSS_TOP] = 0;
4239       node_0->layout.position[CSS_LEFT] = 0;
4240       node_0->layout.dimensions[CSS_WIDTH] = 100;
4241       node_0->layout.dimensions[CSS_HEIGHT] = 100;
4242     }
4243
4244     test("should layout node with fixed height and fixed width, ignoring custom measure function", root_node, root_layout);
4245   }
4246
4247   {
4248     css_node_t *root_node = new_test_css_node();
4249     {
4250       css_node_t *node_0 = root_node;
4251       node_0->measure = measure;
4252       node_0->context = "measureWithRatio2";
4253     }
4254
4255     css_node_t *root_layout = new_test_css_node();
4256     {
4257       css_node_t *node_0 = root_layout;
4258       node_0->layout.position[CSS_TOP] = 0;
4259       node_0->layout.position[CSS_LEFT] = 0;
4260       node_0->layout.dimensions[CSS_WIDTH] = 99999;
4261       node_0->layout.dimensions[CSS_HEIGHT] = 99999;
4262     }
4263
4264     test("should layout node with no fixed dimension and custom measure function", root_node, root_layout);
4265   }
4266
4267   {
4268     css_node_t *root_node = new_test_css_node();
4269     {
4270       css_node_t *node_0 = root_node;
4271       node_0->style.flex_direction = CSS_FLEX_DIRECTION_COLUMN;
4272       node_0->style.dimensions[CSS_WIDTH] = 320;
4273       init_css_node_children(node_0, 2);
4274       {
4275         css_node_t *node_1;
4276         node_1 = node_0->get_child(node_0->context, 0);
4277         node_1->measure = measure;
4278         node_1->context = "measureWithRatio2";
4279         node_1 = node_0->get_child(node_0->context, 1);
4280         node_1->style.flex_direction = CSS_FLEX_DIRECTION_ROW;
4281         node_1->style.dimensions[CSS_HEIGHT] = 100;
4282         init_css_node_children(node_1, 2);
4283         {
4284           css_node_t *node_2;
4285           node_2 = node_1->get_child(node_1->context, 0);
4286           node_2->measure = measure;
4287           node_2->context = "measureWithRatio2";
4288           node_2 = node_1->get_child(node_1->context, 1);
4289           node_2->measure = measure;
4290           node_2->context = "measureWithRatio2";
4291         }
4292       }
4293     }
4294
4295     css_node_t *root_layout = new_test_css_node();
4296     {
4297       css_node_t *node_0 = root_layout;
4298       node_0->layout.position[CSS_TOP] = 0;
4299       node_0->layout.position[CSS_LEFT] = 0;
4300       node_0->layout.dimensions[CSS_WIDTH] = 320;
4301       node_0->layout.dimensions[CSS_HEIGHT] = 740;
4302       init_css_node_children(node_0, 2);
4303       {
4304         css_node_t *node_1;
4305         node_1 = node_0->get_child(node_0->context, 0);
4306         node_1->layout.position[CSS_TOP] = 0;
4307         node_1->layout.position[CSS_LEFT] = 0;
4308         node_1->layout.dimensions[CSS_WIDTH] = 320;
4309         node_1->layout.dimensions[CSS_HEIGHT] = 640;
4310         node_1 = node_0->get_child(node_0->context, 1);
4311         node_1->layout.position[CSS_TOP] = 640;
4312         node_1->layout.position[CSS_LEFT] = 0;
4313         node_1->layout.dimensions[CSS_WIDTH] = 320;
4314         node_1->layout.dimensions[CSS_HEIGHT] = 100;
4315         init_css_node_children(node_1, 2);
4316         {
4317           css_node_t *node_2;
4318           node_2 = node_1->get_child(node_1->context, 0);
4319           node_2->layout.position[CSS_TOP] = 0;
4320           node_2->layout.position[CSS_LEFT] = 0;
4321           node_2->layout.dimensions[CSS_WIDTH] = 200;
4322           node_2->layout.dimensions[CSS_HEIGHT] = 100;
4323           node_2 = node_1->get_child(node_1->context, 1);
4324           node_2->layout.position[CSS_TOP] = 0;
4325           node_2->layout.position[CSS_LEFT] = 200;
4326           node_2->layout.dimensions[CSS_WIDTH] = 200;
4327           node_2->layout.dimensions[CSS_HEIGHT] = 100;
4328         }
4329       }
4330     }
4331
4332     test("should layout node with nested stacks and custom measure function", root_node, root_layout);
4333   }
4334
4335   {
4336     css_node_t *root_node = new_test_css_node();
4337     {
4338       css_node_t *node_0 = root_node;
4339       node_0->style.dimensions[CSS_WIDTH] = 10;
4340       node_0->measure = measure;
4341       node_0->context = "small";
4342     }
4343
4344     css_node_t *root_layout = new_test_css_node();
4345     {
4346       css_node_t *node_0 = root_layout;
4347       node_0->layout.position[CSS_TOP] = 0;
4348       node_0->layout.position[CSS_LEFT] = 0;
4349       node_0->layout.dimensions[CSS_WIDTH] = 10;
4350       node_0->layout.dimensions[CSS_HEIGHT] = 18;
4351     }
4352
4353     test("should layout node with text and width", root_node, root_layout);
4354   }
4355
4356   {
4357     css_node_t *root_node = new_test_css_node();
4358     {
4359       css_node_t *node_0 = root_node;
4360       node_0->measure = measure;
4361       node_0->context = "loooooooooong with space";
4362     }
4363
4364     css_node_t *root_layout = new_test_css_node();
4365     {
4366       css_node_t *node_0 = root_layout;
4367       node_0->layout.position[CSS_TOP] = 0;
4368       node_0->layout.position[CSS_LEFT] = 0;
4369       node_0->layout.dimensions[CSS_WIDTH] = 172;
4370       node_0->layout.dimensions[CSS_HEIGHT] = 18;
4371     }
4372
4373     test("should layout node with text, padding and margin", root_node, root_layout);
4374   }
4375
4376   {
4377     css_node_t *root_node = new_test_css_node();
4378     {
4379       css_node_t *node_0 = root_node;
4380       node_0->style.dimensions[CSS_WIDTH] = 300;
4381       init_css_node_children(node_0, 1);
4382       {
4383         css_node_t *node_1;
4384         node_1 = node_0->get_child(node_0->context, 0);
4385         node_1->style.align_self = CSS_ALIGN_STRETCH;
4386         init_css_node_children(node_1, 1);
4387         {
4388           css_node_t *node_2;
4389           node_2 = node_1->get_child(node_1->context, 0);
4390           node_2->style.align_self = CSS_ALIGN_STRETCH;
4391         }
4392       }
4393     }
4394
4395     css_node_t *root_layout = new_test_css_node();
4396     {
4397       css_node_t *node_0 = root_layout;
4398       node_0->layout.position[CSS_TOP] = 0;
4399       node_0->layout.position[CSS_LEFT] = 0;
4400       node_0->layout.dimensions[CSS_WIDTH] = 300;
4401       node_0->layout.dimensions[CSS_HEIGHT] = 0;
4402       init_css_node_children(node_0, 1);
4403       {
4404         css_node_t *node_1;
4405         node_1 = node_0->get_child(node_0->context, 0);
4406         node_1->layout.position[CSS_TOP] = 0;
4407         node_1->layout.position[CSS_LEFT] = 0;
4408         node_1->layout.dimensions[CSS_WIDTH] = 300;
4409         node_1->layout.dimensions[CSS_HEIGHT] = 0;
4410         init_css_node_children(node_1, 1);
4411         {
4412           css_node_t *node_2;
4413           node_2 = node_1->get_child(node_1->context, 0);
4414           node_2->layout.position[CSS_TOP] = 0;
4415           node_2->layout.position[CSS_LEFT] = 0;
4416           node_2->layout.dimensions[CSS_WIDTH] = 300;
4417           node_2->layout.dimensions[CSS_HEIGHT] = 0;
4418         }
4419       }
4420     }
4421
4422     test("should layout node with nested alignSelf: stretch", root_node, root_layout);
4423   }
4424
4425   {
4426     css_node_t *root_node = new_test_css_node();
4427     {
4428       css_node_t *node_0 = root_node;
4429       init_css_node_children(node_0, 1);
4430       {
4431         css_node_t *node_1;
4432         node_1 = node_0->get_child(node_0->context, 0);
4433         node_1->style.flex_direction = CSS_FLEX_DIRECTION_ROW;
4434         node_1->style.dimensions[CSS_WIDTH] = 500;
4435         init_css_node_children(node_1, 1);
4436         {
4437           css_node_t *node_2;
4438           node_2 = node_1->get_child(node_1->context, 0);
4439           node_2->style.flex = 1;
4440           node_2->measure = measure;
4441           node_2->context = "loooooooooong with space";
4442         }
4443       }
4444     }
4445
4446     css_node_t *root_layout = new_test_css_node();
4447     {
4448       css_node_t *node_0 = root_layout;
4449       node_0->layout.position[CSS_TOP] = 0;
4450       node_0->layout.position[CSS_LEFT] = 0;
4451       node_0->layout.dimensions[CSS_WIDTH] = 500;
4452       node_0->layout.dimensions[CSS_HEIGHT] = 18;
4453       init_css_node_children(node_0, 1);
4454       {
4455         css_node_t *node_1;
4456         node_1 = node_0->get_child(node_0->context, 0);
4457         node_1->layout.position[CSS_TOP] = 0;
4458         node_1->layout.position[CSS_LEFT] = 0;
4459         node_1->layout.dimensions[CSS_WIDTH] = 500;
4460         node_1->layout.dimensions[CSS_HEIGHT] = 18;
4461         init_css_node_children(node_1, 1);
4462         {
4463           css_node_t *node_2;
4464           node_2 = node_1->get_child(node_1->context, 0);
4465           node_2->layout.position[CSS_TOP] = 0;
4466           node_2->layout.position[CSS_LEFT] = 0;
4467           node_2->layout.dimensions[CSS_WIDTH] = 500;
4468           node_2->layout.dimensions[CSS_HEIGHT] = 18;
4469         }
4470       }
4471     }
4472
4473     test("should layout node with text and flex", root_node, root_layout);
4474   }
4475
4476   {
4477     css_node_t *root_node = new_test_css_node();
4478     {
4479       css_node_t *node_0 = root_node;
4480       init_css_node_children(node_0, 1);
4481       {
4482         css_node_t *node_1;
4483         node_1 = node_0->get_child(node_0->context, 0);
4484         node_1->style.direction = CSS_DIRECTION_RTL;
4485         node_1->style.flex_direction = CSS_FLEX_DIRECTION_ROW;
4486         node_1->style.dimensions[CSS_WIDTH] = 500;
4487         init_css_node_children(node_1, 1);
4488         {
4489           css_node_t *node_2;
4490           node_2 = node_1->get_child(node_1->context, 0);
4491           node_2->style.flex = 1;
4492           node_2->measure = measure;
4493           node_2->context = "loooooooooong with space";
4494         }
4495       }
4496     }
4497
4498     css_node_t *root_layout = new_test_css_node();
4499     {
4500       css_node_t *node_0 = root_layout;
4501       node_0->layout.position[CSS_TOP] = 0;
4502       node_0->layout.position[CSS_LEFT] = 0;
4503       node_0->layout.dimensions[CSS_WIDTH] = 500;
4504       node_0->layout.dimensions[CSS_HEIGHT] = 18;
4505       init_css_node_children(node_0, 1);
4506       {
4507         css_node_t *node_1;
4508         node_1 = node_0->get_child(node_0->context, 0);
4509         node_1->layout.position[CSS_TOP] = 0;
4510         node_1->layout.position[CSS_LEFT] = 0;
4511         node_1->layout.dimensions[CSS_WIDTH] = 500;
4512         node_1->layout.dimensions[CSS_HEIGHT] = 18;
4513         init_css_node_children(node_1, 1);
4514         {
4515           css_node_t *node_2;
4516           node_2 = node_1->get_child(node_1->context, 0);
4517           node_2->layout.position[CSS_TOP] = 0;
4518           node_2->layout.position[CSS_LEFT] = 0;
4519           node_2->layout.dimensions[CSS_WIDTH] = 500;
4520           node_2->layout.dimensions[CSS_HEIGHT] = 18;
4521         }
4522       }
4523     }
4524
4525     test("should layout node with text and flex in rtl", root_node, root_layout);
4526   }
4527
4528   {
4529     css_node_t *root_node = new_test_css_node();
4530     {
4531       css_node_t *node_0 = root_node;
4532       node_0->style.dimensions[CSS_WIDTH] = 130;
4533       init_css_node_children(node_0, 1);
4534       {
4535         css_node_t *node_1;
4536         node_1 = node_0->get_child(node_0->context, 0);
4537         node_1->style.align_items = CSS_ALIGN_STRETCH;
4538         node_1->style.align_self = CSS_ALIGN_STRETCH;
4539         init_css_node_children(node_1, 1);
4540         {
4541           css_node_t *node_2;
4542           node_2 = node_1->get_child(node_1->context, 0);
4543           node_2->measure = measure;
4544           node_2->context = "loooooooooong with space";
4545         }
4546       }
4547     }
4548
4549     css_node_t *root_layout = new_test_css_node();
4550     {
4551       css_node_t *node_0 = root_layout;
4552       node_0->layout.position[CSS_TOP] = 0;
4553       node_0->layout.position[CSS_LEFT] = 0;
4554       node_0->layout.dimensions[CSS_WIDTH] = 130;
4555       node_0->layout.dimensions[CSS_HEIGHT] = 36;
4556       init_css_node_children(node_0, 1);
4557       {
4558         css_node_t *node_1;
4559         node_1 = node_0->get_child(node_0->context, 0);
4560         node_1->layout.position[CSS_TOP] = 0;
4561         node_1->layout.position[CSS_LEFT] = 0;
4562         node_1->layout.dimensions[CSS_WIDTH] = 130;
4563         node_1->layout.dimensions[CSS_HEIGHT] = 36;
4564         init_css_node_children(node_1, 1);
4565         {
4566           css_node_t *node_2;
4567           node_2 = node_1->get_child(node_1->context, 0);
4568           node_2->layout.position[CSS_TOP] = 0;
4569           node_2->layout.position[CSS_LEFT] = 0;
4570           node_2->layout.dimensions[CSS_WIDTH] = 130;
4571           node_2->layout.dimensions[CSS_HEIGHT] = 36;
4572         }
4573       }
4574     }
4575
4576     test("should layout node with text and stretch", root_node, root_layout);
4577   }
4578
4579   {
4580     css_node_t *root_node = new_test_css_node();
4581     {
4582       css_node_t *node_0 = root_node;
4583       node_0->style.dimensions[CSS_WIDTH] = 200;
4584       init_css_node_children(node_0, 1);
4585       {
4586         css_node_t *node_1;
4587         node_1 = node_0->get_child(node_0->context, 0);
4588         node_1->style.align_items = CSS_ALIGN_STRETCH;
4589         node_1->style.align_self = CSS_ALIGN_STRETCH;
4590         init_css_node_children(node_1, 1);
4591         {
4592           css_node_t *node_2;
4593           node_2 = node_1->get_child(node_1->context, 0);
4594           node_2->style.dimensions[CSS_WIDTH] = 130;
4595           node_2->measure = measure;
4596           node_2->context = "loooooooooong with space";
4597         }
4598       }
4599     }
4600
4601     css_node_t *root_layout = new_test_css_node();
4602     {
4603       css_node_t *node_0 = root_layout;
4604       node_0->layout.position[CSS_TOP] = 0;
4605       node_0->layout.position[CSS_LEFT] = 0;
4606       node_0->layout.dimensions[CSS_WIDTH] = 200;
4607       node_0->layout.dimensions[CSS_HEIGHT] = 36;
4608       init_css_node_children(node_0, 1);
4609       {
4610         css_node_t *node_1;
4611         node_1 = node_0->get_child(node_0->context, 0);
4612         node_1->layout.position[CSS_TOP] = 0;
4613         node_1->layout.position[CSS_LEFT] = 0;
4614         node_1->layout.dimensions[CSS_WIDTH] = 200;
4615         node_1->layout.dimensions[CSS_HEIGHT] = 36;
4616         init_css_node_children(node_1, 1);
4617         {
4618           css_node_t *node_2;
4619           node_2 = node_1->get_child(node_1->context, 0);
4620           node_2->layout.position[CSS_TOP] = 0;
4621           node_2->layout.position[CSS_LEFT] = 0;
4622           node_2->layout.dimensions[CSS_WIDTH] = 130;
4623           node_2->layout.dimensions[CSS_HEIGHT] = 36;
4624         }
4625       }
4626     }
4627
4628     test("should layout node with text stretch and width", root_node, root_layout);
4629   }
4630
4631   {
4632     css_node_t *root_node = new_test_css_node();
4633     {
4634       css_node_t *node_0 = root_node;
4635       node_0->style.align_self = CSS_ALIGN_FLEX_START;
4636       node_0->style.dimensions[CSS_WIDTH] = 100;
4637       init_css_node_children(node_0, 1);
4638       {
4639         css_node_t *node_1;
4640         node_1 = node_0->get_child(node_0->context, 0);
4641         node_1->style.align_self = CSS_ALIGN_FLEX_START;
4642         node_1->measure = measure;
4643         node_1->context = "loooooooooong with space";
4644       }
4645     }
4646
4647     css_node_t *root_layout = new_test_css_node();
4648     {
4649       css_node_t *node_0 = root_layout;
4650       node_0->layout.position[CSS_TOP] = 0;
4651       node_0->layout.position[CSS_LEFT] = 0;
4652       node_0->layout.dimensions[CSS_WIDTH] = 100;
4653       node_0->layout.dimensions[CSS_HEIGHT] = 36;
4654       init_css_node_children(node_0, 1);
4655       {
4656         css_node_t *node_1;
4657         node_1 = node_0->get_child(node_0->context, 0);
4658         node_1->layout.position[CSS_TOP] = 0;
4659         node_1->layout.position[CSS_LEFT] = 0;
4660         node_1->layout.dimensions[CSS_WIDTH] = 100;
4661         node_1->layout.dimensions[CSS_HEIGHT] = 36;
4662       }
4663     }
4664
4665     test("should layout node with text bounded by parent", root_node, root_layout);
4666   }
4667
4668   {
4669     css_node_t *root_node = new_test_css_node();
4670     {
4671       css_node_t *node_0 = root_node;
4672       node_0->style.align_self = CSS_ALIGN_FLEX_START;
4673       node_0->style.dimensions[CSS_WIDTH] = 100;
4674       node_0->style.padding[CSS_LEFT] = 10;
4675       node_0->style.padding[CSS_TOP] = 10;
4676       node_0->style.padding[CSS_RIGHT] = 10;
4677       node_0->style.padding[CSS_BOTTOM] = 10;
4678       node_0->style.padding[CSS_START] = 10;
4679       node_0->style.padding[CSS_END] = 10;
4680       init_css_node_children(node_0, 1);
4681       {
4682         css_node_t *node_1;
4683         node_1 = node_0->get_child(node_0->context, 0);
4684         node_1->style.align_self = CSS_ALIGN_FLEX_START;
4685         node_1->style.margin[CSS_LEFT] = 10;
4686         node_1->style.margin[CSS_TOP] = 10;
4687         node_1->style.margin[CSS_RIGHT] = 10;
4688         node_1->style.margin[CSS_BOTTOM] = 10;
4689         node_1->style.margin[CSS_START] = 10;
4690         node_1->style.margin[CSS_END] = 10;
4691         init_css_node_children(node_1, 1);
4692         {
4693           css_node_t *node_2;
4694           node_2 = node_1->get_child(node_1->context, 0);
4695           node_2->measure = measure;
4696           node_2->context = "loooooooooong with space";
4697         }
4698       }
4699     }
4700
4701     css_node_t *root_layout = new_test_css_node();
4702     {
4703       css_node_t *node_0 = root_layout;
4704       node_0->layout.position[CSS_TOP] = 0;
4705       node_0->layout.position[CSS_LEFT] = 0;
4706       node_0->layout.dimensions[CSS_WIDTH] = 100;
4707       node_0->layout.dimensions[CSS_HEIGHT] = 76;
4708       init_css_node_children(node_0, 1);
4709       {
4710         css_node_t *node_1;
4711         node_1 = node_0->get_child(node_0->context, 0);
4712         node_1->layout.position[CSS_TOP] = 20;
4713         node_1->layout.position[CSS_LEFT] = 20;
4714         node_1->layout.dimensions[CSS_WIDTH] = 100;
4715         node_1->layout.dimensions[CSS_HEIGHT] = 36;
4716         init_css_node_children(node_1, 1);
4717         {
4718           css_node_t *node_2;
4719           node_2 = node_1->get_child(node_1->context, 0);
4720           node_2->layout.position[CSS_TOP] = 0;
4721           node_2->layout.position[CSS_LEFT] = 0;
4722           node_2->layout.dimensions[CSS_WIDTH] = 100;
4723           node_2->layout.dimensions[CSS_HEIGHT] = 36;
4724         }
4725       }
4726     }
4727
4728     test("should layout node with text bounded by grand-parent", root_node, root_layout);
4729   }
4730
4731   {
4732     css_node_t *root_node = new_test_css_node();
4733     {
4734       css_node_t *node_0 = root_node;
4735       node_0->style.justify_content = CSS_JUSTIFY_SPACE_BETWEEN;
4736       node_0->style.dimensions[CSS_HEIGHT] = 100;
4737       init_css_node_children(node_0, 2);
4738       {
4739         css_node_t *node_1;
4740         node_1 = node_0->get_child(node_0->context, 0);
4741         node_1->style.dimensions[CSS_HEIGHT] = 900;
4742         node_1 = node_0->get_child(node_0->context, 1);
4743       }
4744     }
4745
4746     css_node_t *root_layout = new_test_css_node();
4747     {
4748       css_node_t *node_0 = root_layout;
4749       node_0->layout.position[CSS_TOP] = 0;
4750       node_0->layout.position[CSS_LEFT] = 0;
4751       node_0->layout.dimensions[CSS_WIDTH] = 0;
4752       node_0->layout.dimensions[CSS_HEIGHT] = 100;
4753       init_css_node_children(node_0, 2);
4754       {
4755         css_node_t *node_1;
4756         node_1 = node_0->get_child(node_0->context, 0);
4757         node_1->layout.position[CSS_TOP] = 0;
4758         node_1->layout.position[CSS_LEFT] = 0;
4759         node_1->layout.dimensions[CSS_WIDTH] = 0;
4760         node_1->layout.dimensions[CSS_HEIGHT] = 900;
4761         node_1 = node_0->get_child(node_0->context, 1);
4762         node_1->layout.position[CSS_TOP] = 900;
4763         node_1->layout.position[CSS_LEFT] = 0;
4764         node_1->layout.dimensions[CSS_WIDTH] = 0;
4765         node_1->layout.dimensions[CSS_HEIGHT] = 0;
4766       }
4767     }
4768
4769     test("should layout space-between when remaining space is negative", root_node, root_layout);
4770   }
4771
4772   {
4773     css_node_t *root_node = new_test_css_node();
4774     {
4775       css_node_t *node_0 = root_node;
4776       node_0->style.flex_direction = CSS_FLEX_DIRECTION_COLUMN_REVERSE;
4777       node_0->style.justify_content = CSS_JUSTIFY_SPACE_BETWEEN;
4778       node_0->style.dimensions[CSS_HEIGHT] = 100;
4779       init_css_node_children(node_0, 2);
4780       {
4781         css_node_t *node_1;
4782         node_1 = node_0->get_child(node_0->context, 0);
4783         node_1->style.dimensions[CSS_HEIGHT] = 900;
4784         node_1 = node_0->get_child(node_0->context, 1);
4785       }
4786     }
4787
4788     css_node_t *root_layout = new_test_css_node();
4789     {
4790       css_node_t *node_0 = root_layout;
4791       node_0->layout.position[CSS_TOP] = 0;
4792       node_0->layout.position[CSS_LEFT] = 0;
4793       node_0->layout.dimensions[CSS_WIDTH] = 0;
4794       node_0->layout.dimensions[CSS_HEIGHT] = 100;
4795       init_css_node_children(node_0, 2);
4796       {
4797         css_node_t *node_1;
4798         node_1 = node_0->get_child(node_0->context, 0);
4799         node_1->layout.position[CSS_TOP] = -800;
4800         node_1->layout.position[CSS_LEFT] = 0;
4801         node_1->layout.dimensions[CSS_WIDTH] = 0;
4802         node_1->layout.dimensions[CSS_HEIGHT] = 900;
4803         node_1 = node_0->get_child(node_0->context, 1);
4804         node_1->layout.position[CSS_TOP] = -800;
4805         node_1->layout.position[CSS_LEFT] = 0;
4806         node_1->layout.dimensions[CSS_WIDTH] = 0;
4807         node_1->layout.dimensions[CSS_HEIGHT] = 0;
4808       }
4809     }
4810
4811     test("should layout space-between when remaining space is negative in reverse", root_node, root_layout);
4812   }
4813
4814   {
4815     css_node_t *root_node = new_test_css_node();
4816     {
4817       css_node_t *node_0 = root_node;
4818       node_0->style.flex_direction = CSS_FLEX_DIRECTION_ROW;
4819       node_0->style.justify_content = CSS_JUSTIFY_FLEX_END;
4820       node_0->style.dimensions[CSS_WIDTH] = 200;
4821       init_css_node_children(node_0, 1);
4822       {
4823         css_node_t *node_1;
4824         node_1 = node_0->get_child(node_0->context, 0);
4825         node_1->style.dimensions[CSS_WIDTH] = 900;
4826       }
4827     }
4828
4829     css_node_t *root_layout = new_test_css_node();
4830     {
4831       css_node_t *node_0 = root_layout;
4832       node_0->layout.position[CSS_TOP] = 0;
4833       node_0->layout.position[CSS_LEFT] = 0;
4834       node_0->layout.dimensions[CSS_WIDTH] = 200;
4835       node_0->layout.dimensions[CSS_HEIGHT] = 0;
4836       init_css_node_children(node_0, 1);
4837       {
4838         css_node_t *node_1;
4839         node_1 = node_0->get_child(node_0->context, 0);
4840         node_1->layout.position[CSS_TOP] = 0;
4841         node_1->layout.position[CSS_LEFT] = -700;
4842         node_1->layout.dimensions[CSS_WIDTH] = 900;
4843         node_1->layout.dimensions[CSS_HEIGHT] = 0;
4844       }
4845     }
4846
4847     test("should layout flex-end when remaining space is negative", root_node, root_layout);
4848   }
4849
4850   {
4851     css_node_t *root_node = new_test_css_node();
4852     {
4853       css_node_t *node_0 = root_node;
4854       node_0->style.direction = CSS_DIRECTION_RTL;
4855       node_0->style.flex_direction = CSS_FLEX_DIRECTION_ROW;
4856       node_0->style.justify_content = CSS_JUSTIFY_FLEX_END;
4857       node_0->style.dimensions[CSS_WIDTH] = 200;
4858       init_css_node_children(node_0, 1);
4859       {
4860         css_node_t *node_1;
4861         node_1 = node_0->get_child(node_0->context, 0);
4862         node_1->style.dimensions[CSS_WIDTH] = 900;
4863       }
4864     }
4865
4866     css_node_t *root_layout = new_test_css_node();
4867     {
4868       css_node_t *node_0 = root_layout;
4869       node_0->layout.position[CSS_TOP] = 0;
4870       node_0->layout.position[CSS_LEFT] = 0;
4871       node_0->layout.dimensions[CSS_WIDTH] = 200;
4872       node_0->layout.dimensions[CSS_HEIGHT] = 0;
4873       init_css_node_children(node_0, 1);
4874       {
4875         css_node_t *node_1;
4876         node_1 = node_0->get_child(node_0->context, 0);
4877         node_1->layout.position[CSS_TOP] = 0;
4878         node_1->layout.position[CSS_LEFT] = 0;
4879         node_1->layout.dimensions[CSS_WIDTH] = 900;
4880         node_1->layout.dimensions[CSS_HEIGHT] = 0;
4881       }
4882     }
4883
4884     test("should layout flex-end when remaining space is negative in rtl", root_node, root_layout);
4885   }
4886
4887   {
4888     css_node_t *root_node = new_test_css_node();
4889     {
4890       css_node_t *node_0 = root_node;
4891       init_css_node_children(node_0, 1);
4892       {
4893         css_node_t *node_1;
4894         node_1 = node_0->get_child(node_0->context, 0);
4895         node_1->style.flex_direction = CSS_FLEX_DIRECTION_ROW;
4896         node_1->style.dimensions[CSS_WIDTH] = 200;
4897         init_css_node_children(node_1, 1);
4898         {
4899           css_node_t *node_2;
4900           node_2 = node_1->get_child(node_1->context, 0);
4901           node_2->style.margin[CSS_LEFT] = 20;
4902           node_2->style.margin[CSS_TOP] = 20;
4903           node_2->style.margin[CSS_RIGHT] = 20;
4904           node_2->style.margin[CSS_BOTTOM] = 20;
4905           node_2->style.margin[CSS_START] = 20;
4906           node_2->style.margin[CSS_END] = 20;
4907           node_2->measure = measure;
4908           node_2->context = "loooooooooong with space";
4909         }
4910       }
4911     }
4912
4913     css_node_t *root_layout = new_test_css_node();
4914     {
4915       css_node_t *node_0 = root_layout;
4916       node_0->layout.position[CSS_TOP] = 0;
4917       node_0->layout.position[CSS_LEFT] = 0;
4918       node_0->layout.dimensions[CSS_WIDTH] = 200;
4919       node_0->layout.dimensions[CSS_HEIGHT] = 58;
4920       init_css_node_children(node_0, 1);
4921       {
4922         css_node_t *node_1;
4923         node_1 = node_0->get_child(node_0->context, 0);
4924         node_1->layout.position[CSS_TOP] = 0;
4925         node_1->layout.position[CSS_LEFT] = 0;
4926         node_1->layout.dimensions[CSS_WIDTH] = 200;
4927         node_1->layout.dimensions[CSS_HEIGHT] = 58;
4928         init_css_node_children(node_1, 1);
4929         {
4930           css_node_t *node_2;
4931           node_2 = node_1->get_child(node_1->context, 0);
4932           node_2->layout.position[CSS_TOP] = 20;
4933           node_2->layout.position[CSS_LEFT] = 20;
4934           node_2->layout.dimensions[CSS_WIDTH] = 172;
4935           node_2->layout.dimensions[CSS_HEIGHT] = 18;
4936         }
4937       }
4938     }
4939
4940     test("should layout text with flexDirection row", root_node, root_layout);
4941   }
4942
4943   {
4944     css_node_t *root_node = new_test_css_node();
4945     {
4946       css_node_t *node_0 = root_node;
4947       node_0->style.direction = CSS_DIRECTION_RTL;
4948       init_css_node_children(node_0, 1);
4949       {
4950         css_node_t *node_1;
4951         node_1 = node_0->get_child(node_0->context, 0);
4952         node_1->style.flex_direction = CSS_FLEX_DIRECTION_ROW;
4953         node_1->style.dimensions[CSS_WIDTH] = 200;
4954         init_css_node_children(node_1, 1);
4955         {
4956           css_node_t *node_2;
4957           node_2 = node_1->get_child(node_1->context, 0);
4958           node_2->style.margin[CSS_LEFT] = 20;
4959           node_2->style.margin[CSS_TOP] = 20;
4960           node_2->style.margin[CSS_RIGHT] = 20;
4961           node_2->style.margin[CSS_BOTTOM] = 20;
4962           node_2->style.margin[CSS_START] = 20;
4963           node_2->style.margin[CSS_END] = 20;
4964           node_2->measure = measure;
4965           node_2->context = "loooooooooong with space";
4966         }
4967       }
4968     }
4969
4970     css_node_t *root_layout = new_test_css_node();
4971     {
4972       css_node_t *node_0 = root_layout;
4973       node_0->layout.position[CSS_TOP] = 0;
4974       node_0->layout.position[CSS_LEFT] = 0;
4975       node_0->layout.dimensions[CSS_WIDTH] = 200;
4976       node_0->layout.dimensions[CSS_HEIGHT] = 58;
4977       init_css_node_children(node_0, 1);
4978       {
4979         css_node_t *node_1;
4980         node_1 = node_0->get_child(node_0->context, 0);
4981         node_1->layout.position[CSS_TOP] = 0;
4982         node_1->layout.position[CSS_LEFT] = 0;
4983         node_1->layout.dimensions[CSS_WIDTH] = 200;
4984         node_1->layout.dimensions[CSS_HEIGHT] = 58;
4985         init_css_node_children(node_1, 1);
4986         {
4987           css_node_t *node_2;
4988           node_2 = node_1->get_child(node_1->context, 0);
4989           node_2->layout.position[CSS_TOP] = 20;
4990           node_2->layout.position[CSS_LEFT] = 8;
4991           node_2->layout.dimensions[CSS_WIDTH] = 172;
4992           node_2->layout.dimensions[CSS_HEIGHT] = 18;
4993         }
4994       }
4995     }
4996
4997     test("should layout text with flexDirection row in rtl", root_node, root_layout);
4998   }
4999
5000   {
5001     css_node_t *root_node = new_test_css_node();
5002     {
5003       css_node_t *node_0 = root_node;
5004       init_css_node_children(node_0, 1);
5005       {
5006         css_node_t *node_1;
5007         node_1 = node_0->get_child(node_0->context, 0);
5008         node_1->style.dimensions[CSS_WIDTH] = 200;
5009         init_css_node_children(node_1, 1);
5010         {
5011           css_node_t *node_2;
5012           node_2 = node_1->get_child(node_1->context, 0);
5013           node_2->style.margin[CSS_LEFT] = 20;
5014           node_2->style.margin[CSS_TOP] = 20;
5015           node_2->style.margin[CSS_RIGHT] = 20;
5016           node_2->style.margin[CSS_BOTTOM] = 20;
5017           node_2->style.margin[CSS_START] = 20;
5018           node_2->style.margin[CSS_END] = 20;
5019           node_2->measure = measure;
5020           node_2->context = "loooooooooong with space";
5021         }
5022       }
5023     }
5024
5025     css_node_t *root_layout = new_test_css_node();
5026     {
5027       css_node_t *node_0 = root_layout;
5028       node_0->layout.position[CSS_TOP] = 0;
5029       node_0->layout.position[CSS_LEFT] = 0;
5030       node_0->layout.dimensions[CSS_WIDTH] = 200;
5031       node_0->layout.dimensions[CSS_HEIGHT] = 76;
5032       init_css_node_children(node_0, 1);
5033       {
5034         css_node_t *node_1;
5035         node_1 = node_0->get_child(node_0->context, 0);
5036         node_1->layout.position[CSS_TOP] = 0;
5037         node_1->layout.position[CSS_LEFT] = 0;
5038         node_1->layout.dimensions[CSS_WIDTH] = 200;
5039         node_1->layout.dimensions[CSS_HEIGHT] = 76;
5040         init_css_node_children(node_1, 1);
5041         {
5042           css_node_t *node_2;
5043           node_2 = node_1->get_child(node_1->context, 0);
5044           node_2->layout.position[CSS_TOP] = 20;
5045           node_2->layout.position[CSS_LEFT] = 20;
5046           node_2->layout.dimensions[CSS_WIDTH] = 160;
5047           node_2->layout.dimensions[CSS_HEIGHT] = 36;
5048         }
5049       }
5050     }
5051
5052     test("should layout with text and margin", root_node, root_layout);
5053   }
5054
5055   {
5056     css_node_t *root_node = new_test_css_node();
5057     {
5058       css_node_t *node_0 = root_node;
5059       node_0->style.dimensions[CSS_WIDTH] = 100;
5060       node_0->style.dimensions[CSS_HEIGHT] = 100;
5061       init_css_node_children(node_0, 1);
5062       {
5063         css_node_t *node_1;
5064         node_1 = node_0->get_child(node_0->context, 0);
5065         node_1->style.position_type = CSS_POSITION_ABSOLUTE;
5066         node_1->style.position[CSS_LEFT] = 0;
5067         node_1->style.position[CSS_TOP] = 0;
5068         node_1->style.position[CSS_RIGHT] = 0;
5069         node_1->style.position[CSS_BOTTOM] = 0;
5070       }
5071     }
5072
5073     css_node_t *root_layout = new_test_css_node();
5074     {
5075       css_node_t *node_0 = root_layout;
5076       node_0->layout.position[CSS_TOP] = 0;
5077       node_0->layout.position[CSS_LEFT] = 0;
5078       node_0->layout.dimensions[CSS_WIDTH] = 100;
5079       node_0->layout.dimensions[CSS_HEIGHT] = 100;
5080       init_css_node_children(node_0, 1);
5081       {
5082         css_node_t *node_1;
5083         node_1 = node_0->get_child(node_0->context, 0);
5084         node_1->layout.position[CSS_TOP] = 0;
5085         node_1->layout.position[CSS_LEFT] = 0;
5086         node_1->layout.dimensions[CSS_WIDTH] = 100;
5087         node_1->layout.dimensions[CSS_HEIGHT] = 100;
5088       }
5089     }
5090
5091     test("should layout with position absolute, top, left, bottom, right", root_node, root_layout);
5092   }
5093
5094   {
5095     css_node_t *root_node = new_test_css_node();
5096     {
5097       css_node_t *node_0 = root_node;
5098       node_0->style.align_self = CSS_ALIGN_FLEX_START;
5099       node_0->style.dimensions[CSS_WIDTH] = 100;
5100       node_0->style.dimensions[CSS_HEIGHT] = 100;
5101       init_css_node_children(node_0, 2);
5102       {
5103         css_node_t *node_1;
5104         node_1 = node_0->get_child(node_0->context, 0);
5105         node_1->style.align_self = CSS_ALIGN_FLEX_START;
5106         node_1->style.flex = 2.5;
5107         node_1 = node_0->get_child(node_0->context, 1);
5108         node_1->style.align_self = CSS_ALIGN_FLEX_START;
5109         node_1->style.flex = 7.5;
5110       }
5111     }
5112
5113     css_node_t *root_layout = new_test_css_node();
5114     {
5115       css_node_t *node_0 = root_layout;
5116       node_0->layout.position[CSS_TOP] = 0;
5117       node_0->layout.position[CSS_LEFT] = 0;
5118       node_0->layout.dimensions[CSS_WIDTH] = 100;
5119       node_0->layout.dimensions[CSS_HEIGHT] = 100;
5120       init_css_node_children(node_0, 2);
5121       {
5122         css_node_t *node_1;
5123         node_1 = node_0->get_child(node_0->context, 0);
5124         node_1->layout.position[CSS_TOP] = 0;
5125         node_1->layout.position[CSS_LEFT] = 0;
5126         node_1->layout.dimensions[CSS_WIDTH] = 0;
5127         node_1->layout.dimensions[CSS_HEIGHT] = 25;
5128         node_1 = node_0->get_child(node_0->context, 1);
5129         node_1->layout.position[CSS_TOP] = 25;
5130         node_1->layout.position[CSS_LEFT] = 0;
5131         node_1->layout.dimensions[CSS_WIDTH] = 0;
5132         node_1->layout.dimensions[CSS_HEIGHT] = 75;
5133       }
5134     }
5135
5136     test("should layout with arbitrary flex", root_node, root_layout);
5137   }
5138
5139   {
5140     css_node_t *root_node = new_test_css_node();
5141     {
5142       css_node_t *node_0 = root_node;
5143       node_0->style.flex_direction = CSS_FLEX_DIRECTION_COLUMN_REVERSE;
5144       node_0->style.align_self = CSS_ALIGN_FLEX_START;
5145       node_0->style.dimensions[CSS_WIDTH] = 100;
5146       node_0->style.dimensions[CSS_HEIGHT] = 100;
5147       init_css_node_children(node_0, 2);
5148       {
5149         css_node_t *node_1;
5150         node_1 = node_0->get_child(node_0->context, 0);
5151         node_1->style.align_self = CSS_ALIGN_FLEX_START;
5152         node_1->style.flex = 2.5;
5153         node_1 = node_0->get_child(node_0->context, 1);
5154         node_1->style.align_self = CSS_ALIGN_FLEX_START;
5155         node_1->style.flex = 7.5;
5156       }
5157     }
5158
5159     css_node_t *root_layout = new_test_css_node();
5160     {
5161       css_node_t *node_0 = root_layout;
5162       node_0->layout.position[CSS_TOP] = 0;
5163       node_0->layout.position[CSS_LEFT] = 0;
5164       node_0->layout.dimensions[CSS_WIDTH] = 100;
5165       node_0->layout.dimensions[CSS_HEIGHT] = 100;
5166       init_css_node_children(node_0, 2);
5167       {
5168         css_node_t *node_1;
5169         node_1 = node_0->get_child(node_0->context, 0);
5170         node_1->layout.position[CSS_TOP] = 75;
5171         node_1->layout.position[CSS_LEFT] = 0;
5172         node_1->layout.dimensions[CSS_WIDTH] = 0;
5173         node_1->layout.dimensions[CSS_HEIGHT] = 25;
5174         node_1 = node_0->get_child(node_0->context, 1);
5175         node_1->layout.position[CSS_TOP] = 0;
5176         node_1->layout.position[CSS_LEFT] = 0;
5177         node_1->layout.dimensions[CSS_WIDTH] = 0;
5178         node_1->layout.dimensions[CSS_HEIGHT] = 75;
5179       }
5180     }
5181
5182     test("should layout with arbitrary flex in reverse", root_node, root_layout);
5183   }
5184
5185   {
5186     css_node_t *root_node = new_test_css_node();
5187     {
5188       css_node_t *node_0 = root_node;
5189       node_0->style.flex_direction = CSS_FLEX_DIRECTION_COLUMN_REVERSE;
5190       node_0->style.align_self = CSS_ALIGN_FLEX_START;
5191       node_0->style.dimensions[CSS_WIDTH] = 100;
5192       node_0->style.dimensions[CSS_HEIGHT] = 100;
5193       init_css_node_children(node_0, 2);
5194       {
5195         css_node_t *node_1;
5196         node_1 = node_0->get_child(node_0->context, 0);
5197         node_1->style.align_self = CSS_ALIGN_FLEX_START;
5198         node_1->style.flex = -2.5;
5199         node_1 = node_0->get_child(node_0->context, 1);
5200         node_1->style.align_self = CSS_ALIGN_FLEX_START;
5201         node_1->style.flex = 0;
5202       }
5203     }
5204
5205     css_node_t *root_layout = new_test_css_node();
5206     {
5207       css_node_t *node_0 = root_layout;
5208       node_0->layout.position[CSS_TOP] = 0;
5209       node_0->layout.position[CSS_LEFT] = 0;
5210       node_0->layout.dimensions[CSS_WIDTH] = 100;
5211       node_0->layout.dimensions[CSS_HEIGHT] = 100;
5212       init_css_node_children(node_0, 2);
5213       {
5214         css_node_t *node_1;
5215         node_1 = node_0->get_child(node_0->context, 0);
5216         node_1->layout.position[CSS_TOP] = 100;
5217         node_1->layout.position[CSS_LEFT] = 0;
5218         node_1->layout.dimensions[CSS_WIDTH] = 0;
5219         node_1->layout.dimensions[CSS_HEIGHT] = 0;
5220         node_1 = node_0->get_child(node_0->context, 1);
5221         node_1->layout.position[CSS_TOP] = 100;
5222         node_1->layout.position[CSS_LEFT] = 0;
5223         node_1->layout.dimensions[CSS_WIDTH] = 0;
5224         node_1->layout.dimensions[CSS_HEIGHT] = 0;
5225       }
5226     }
5227
5228     test("should layout with negative flex in reverse", root_node, root_layout);
5229   }
5230
5231   {
5232     css_node_t *root_node = new_test_css_node();
5233     {
5234       css_node_t *node_0 = root_node;
5235       init_css_node_children(node_0, 2);
5236       {
5237         css_node_t *node_1;
5238         node_1 = node_0->get_child(node_0->context, 0);
5239         node_1->style.dimensions[CSS_WIDTH] = 50;
5240         node_1->style.dimensions[CSS_HEIGHT] = 100;
5241         node_1 = node_0->get_child(node_0->context, 1);
5242         node_1->style.position_type = CSS_POSITION_ABSOLUTE;
5243         node_1->style.position[CSS_LEFT] = 0;
5244         node_1->style.position[CSS_RIGHT] = 0;
5245       }
5246     }
5247
5248     css_node_t *root_layout = new_test_css_node();
5249     {
5250       css_node_t *node_0 = root_layout;
5251       node_0->layout.position[CSS_TOP] = 0;
5252       node_0->layout.position[CSS_LEFT] = 0;
5253       node_0->layout.dimensions[CSS_WIDTH] = 50;
5254       node_0->layout.dimensions[CSS_HEIGHT] = 100;
5255       init_css_node_children(node_0, 2);
5256       {
5257         css_node_t *node_1;
5258         node_1 = node_0->get_child(node_0->context, 0);
5259         node_1->layout.position[CSS_TOP] = 0;
5260         node_1->layout.position[CSS_LEFT] = 0;
5261         node_1->layout.dimensions[CSS_WIDTH] = 50;
5262         node_1->layout.dimensions[CSS_HEIGHT] = 100;
5263         node_1 = node_0->get_child(node_0->context, 1);
5264         node_1->layout.position[CSS_TOP] = 100;
5265         node_1->layout.position[CSS_LEFT] = 0;
5266         node_1->layout.dimensions[CSS_WIDTH] = 50;
5267         node_1->layout.dimensions[CSS_HEIGHT] = 0;
5268       }
5269     }
5270
5271     test("should layout with position: absolute and another sibling", root_node, root_layout);
5272   }
5273
5274   {
5275     css_node_t *root_node = new_test_css_node();
5276     {
5277       css_node_t *node_0 = root_node;
5278       node_0->style.dimensions[CSS_HEIGHT] = 100;
5279       init_css_node_children(node_0, 1);
5280       {
5281         css_node_t *node_1;
5282         node_1 = node_0->get_child(node_0->context, 0);
5283         node_1->style.position_type = CSS_POSITION_ABSOLUTE;
5284         node_1->style.position[CSS_TOP] = 0;
5285         node_1->style.position[CSS_BOTTOM] = 20;
5286       }
5287     }
5288
5289     css_node_t *root_layout = new_test_css_node();
5290     {
5291       css_node_t *node_0 = root_layout;
5292       node_0->layout.position[CSS_TOP] = 0;
5293       node_0->layout.position[CSS_LEFT] = 0;
5294       node_0->layout.dimensions[CSS_WIDTH] = 0;
5295       node_0->layout.dimensions[CSS_HEIGHT] = 100;
5296       init_css_node_children(node_0, 1);
5297       {
5298         css_node_t *node_1;
5299         node_1 = node_0->get_child(node_0->context, 0);
5300         node_1->layout.position[CSS_TOP] = 0;
5301         node_1->layout.position[CSS_LEFT] = 0;
5302         node_1->layout.dimensions[CSS_WIDTH] = 0;
5303         node_1->layout.dimensions[CSS_HEIGHT] = 80;
5304       }
5305     }
5306
5307     test("should calculate height properly with position: absolute top and bottom", root_node, root_layout);
5308   }
5309
5310   {
5311     css_node_t *root_node = new_test_css_node();
5312     {
5313       css_node_t *node_0 = root_node;
5314       node_0->style.dimensions[CSS_WIDTH] = 200;
5315       node_0->style.dimensions[CSS_HEIGHT] = 200;
5316       init_css_node_children(node_0, 1);
5317       {
5318         css_node_t *node_1;
5319         node_1 = node_0->get_child(node_0->context, 0);
5320         node_1->style.justify_content = CSS_JUSTIFY_CENTER;
5321         node_1->style.position_type = CSS_POSITION_ABSOLUTE;
5322         node_1->style.position[CSS_LEFT] = 0;
5323         node_1->style.position[CSS_TOP] = 0;
5324         node_1->style.position[CSS_RIGHT] = 0;
5325         node_1->style.position[CSS_BOTTOM] = 0;
5326         init_css_node_children(node_1, 1);
5327         {
5328           css_node_t *node_2;
5329           node_2 = node_1->get_child(node_1->context, 0);
5330           node_2->style.dimensions[CSS_WIDTH] = 100;
5331           node_2->style.dimensions[CSS_HEIGHT] = 100;
5332         }
5333       }
5334     }
5335
5336     css_node_t *root_layout = new_test_css_node();
5337     {
5338       css_node_t *node_0 = root_layout;
5339       node_0->layout.position[CSS_TOP] = 0;
5340       node_0->layout.position[CSS_LEFT] = 0;
5341       node_0->layout.dimensions[CSS_WIDTH] = 200;
5342       node_0->layout.dimensions[CSS_HEIGHT] = 200;
5343       init_css_node_children(node_0, 1);
5344       {
5345         css_node_t *node_1;
5346         node_1 = node_0->get_child(node_0->context, 0);
5347         node_1->layout.position[CSS_TOP] = 0;
5348         node_1->layout.position[CSS_LEFT] = 0;
5349         node_1->layout.dimensions[CSS_WIDTH] = 200;
5350         node_1->layout.dimensions[CSS_HEIGHT] = 200;
5351         init_css_node_children(node_1, 1);
5352         {
5353           css_node_t *node_2;
5354           node_2 = node_1->get_child(node_1->context, 0);
5355           node_2->layout.position[CSS_TOP] = 50;
5356           node_2->layout.position[CSS_LEFT] = 0;
5357           node_2->layout.dimensions[CSS_WIDTH] = 100;
5358           node_2->layout.dimensions[CSS_HEIGHT] = 100;
5359         }
5360       }
5361     }
5362
5363     test("should layout with complicated position: absolute and justifyContent: center combo", root_node, root_layout);
5364   }
5365
5366   {
5367     css_node_t *root_node = new_test_css_node();
5368     {
5369       css_node_t *node_0 = root_node;
5370       node_0->style.dimensions[CSS_HEIGHT] = 100;
5371       init_css_node_children(node_0, 1);
5372       {
5373         css_node_t *node_1;
5374         node_1 = node_0->get_child(node_0->context, 0);
5375         node_1->style.position_type = CSS_POSITION_ABSOLUTE;
5376         node_1->style.position[CSS_BOTTOM] = 0;
5377       }
5378     }
5379
5380     css_node_t *root_layout = new_test_css_node();
5381     {
5382       css_node_t *node_0 = root_layout;
5383       node_0->layout.position[CSS_TOP] = 0;
5384       node_0->layout.position[CSS_LEFT] = 0;
5385       node_0->layout.dimensions[CSS_WIDTH] = 0;
5386       node_0->layout.dimensions[CSS_HEIGHT] = 100;
5387       init_css_node_children(node_0, 1);
5388       {
5389         css_node_t *node_1;
5390         node_1 = node_0->get_child(node_0->context, 0);
5391         node_1->layout.position[CSS_TOP] = 100;
5392         node_1->layout.position[CSS_LEFT] = 0;
5393         node_1->layout.dimensions[CSS_WIDTH] = 0;
5394         node_1->layout.dimensions[CSS_HEIGHT] = 0;
5395       }
5396     }
5397
5398     test("should calculate top properly with position: absolute bottom", root_node, root_layout);
5399   }
5400
5401   {
5402     css_node_t *root_node = new_test_css_node();
5403     {
5404       css_node_t *node_0 = root_node;
5405       node_0->style.dimensions[CSS_WIDTH] = 100;
5406       init_css_node_children(node_0, 1);
5407       {
5408         css_node_t *node_1;
5409         node_1 = node_0->get_child(node_0->context, 0);
5410         node_1->style.position_type = CSS_POSITION_ABSOLUTE;
5411         node_1->style.position[CSS_RIGHT] = 0;
5412       }
5413     }
5414
5415     css_node_t *root_layout = new_test_css_node();
5416     {
5417       css_node_t *node_0 = root_layout;
5418       node_0->layout.position[CSS_TOP] = 0;
5419       node_0->layout.position[CSS_LEFT] = 0;
5420       node_0->layout.dimensions[CSS_WIDTH] = 100;
5421       node_0->layout.dimensions[CSS_HEIGHT] = 0;
5422       init_css_node_children(node_0, 1);
5423       {
5424         css_node_t *node_1;
5425         node_1 = node_0->get_child(node_0->context, 0);
5426         node_1->layout.position[CSS_TOP] = 0;
5427         node_1->layout.position[CSS_LEFT] = 100;
5428         node_1->layout.dimensions[CSS_WIDTH] = 0;
5429         node_1->layout.dimensions[CSS_HEIGHT] = 0;
5430       }
5431     }
5432
5433     test("should calculate left properly with position: absolute right", root_node, root_layout);
5434   }
5435
5436   {
5437     css_node_t *root_node = new_test_css_node();
5438     {
5439       css_node_t *node_0 = root_node;
5440       node_0->style.dimensions[CSS_HEIGHT] = 100;
5441       init_css_node_children(node_0, 1);
5442       {
5443         css_node_t *node_1;
5444         node_1 = node_0->get_child(node_0->context, 0);
5445         node_1->style.position_type = CSS_POSITION_ABSOLUTE;
5446         node_1->style.dimensions[CSS_HEIGHT] = 10;
5447         node_1->style.position[CSS_BOTTOM] = 0;
5448       }
5449     }
5450
5451     css_node_t *root_layout = new_test_css_node();
5452     {
5453       css_node_t *node_0 = root_layout;
5454       node_0->layout.position[CSS_TOP] = 0;
5455       node_0->layout.position[CSS_LEFT] = 0;
5456       node_0->layout.dimensions[CSS_WIDTH] = 0;
5457       node_0->layout.dimensions[CSS_HEIGHT] = 100;
5458       init_css_node_children(node_0, 1);
5459       {
5460         css_node_t *node_1;
5461         node_1 = node_0->get_child(node_0->context, 0);
5462         node_1->layout.position[CSS_TOP] = 90;
5463         node_1->layout.position[CSS_LEFT] = 0;
5464         node_1->layout.dimensions[CSS_WIDTH] = 0;
5465         node_1->layout.dimensions[CSS_HEIGHT] = 10;
5466       }
5467     }
5468
5469     test("should calculate top properly with position: absolute bottom and height", root_node, root_layout);
5470   }
5471
5472   {
5473     css_node_t *root_node = new_test_css_node();
5474     {
5475       css_node_t *node_0 = root_node;
5476       node_0->style.dimensions[CSS_WIDTH] = 100;
5477       init_css_node_children(node_0, 1);
5478       {
5479         css_node_t *node_1;
5480         node_1 = node_0->get_child(node_0->context, 0);
5481         node_1->style.position_type = CSS_POSITION_ABSOLUTE;
5482         node_1->style.dimensions[CSS_WIDTH] = 10;
5483         node_1->style.position[CSS_RIGHT] = 0;
5484       }
5485     }
5486
5487     css_node_t *root_layout = new_test_css_node();
5488     {
5489       css_node_t *node_0 = root_layout;
5490       node_0->layout.position[CSS_TOP] = 0;
5491       node_0->layout.position[CSS_LEFT] = 0;
5492       node_0->layout.dimensions[CSS_WIDTH] = 100;
5493       node_0->layout.dimensions[CSS_HEIGHT] = 0;
5494       init_css_node_children(node_0, 1);
5495       {
5496         css_node_t *node_1;
5497         node_1 = node_0->get_child(node_0->context, 0);
5498         node_1->layout.position[CSS_TOP] = 0;
5499         node_1->layout.position[CSS_LEFT] = 90;
5500         node_1->layout.dimensions[CSS_WIDTH] = 10;
5501         node_1->layout.dimensions[CSS_HEIGHT] = 0;
5502       }
5503     }
5504
5505     test("should calculate left properly with position: absolute right and width", root_node, root_layout);
5506   }
5507
5508   {
5509     css_node_t *root_node = new_test_css_node();
5510     {
5511       css_node_t *node_0 = root_node;
5512       init_css_node_children(node_0, 1);
5513       {
5514         css_node_t *node_1;
5515         node_1 = node_0->get_child(node_0->context, 0);
5516         node_1->style.position_type = CSS_POSITION_ABSOLUTE;
5517         node_1->style.dimensions[CSS_HEIGHT] = 10;
5518         node_1->style.position[CSS_BOTTOM] = 0;
5519       }
5520     }
5521
5522     css_node_t *root_layout = new_test_css_node();
5523     {
5524       css_node_t *node_0 = root_layout;
5525       node_0->layout.position[CSS_TOP] = 0;
5526       node_0->layout.position[CSS_LEFT] = 0;
5527       node_0->layout.dimensions[CSS_WIDTH] = 0;
5528       node_0->layout.dimensions[CSS_HEIGHT] = 0;
5529       init_css_node_children(node_0, 1);
5530       {
5531         css_node_t *node_1;
5532         node_1 = node_0->get_child(node_0->context, 0);
5533         node_1->layout.position[CSS_TOP] = -10;
5534         node_1->layout.position[CSS_LEFT] = 0;
5535         node_1->layout.dimensions[CSS_WIDTH] = 0;
5536         node_1->layout.dimensions[CSS_HEIGHT] = 10;
5537       }
5538     }
5539
5540     test("should calculate top properly with position: absolute right, width, and no parent dimensions", root_node, root_layout);
5541   }
5542
5543   {
5544     css_node_t *root_node = new_test_css_node();
5545     {
5546       css_node_t *node_0 = root_node;
5547       init_css_node_children(node_0, 1);
5548       {
5549         css_node_t *node_1;
5550         node_1 = node_0->get_child(node_0->context, 0);
5551         node_1->style.position_type = CSS_POSITION_ABSOLUTE;
5552         node_1->style.dimensions[CSS_WIDTH] = 10;
5553         node_1->style.position[CSS_RIGHT] = 0;
5554       }
5555     }
5556
5557     css_node_t *root_layout = new_test_css_node();
5558     {
5559       css_node_t *node_0 = root_layout;
5560       node_0->layout.position[CSS_TOP] = 0;
5561       node_0->layout.position[CSS_LEFT] = 0;
5562       node_0->layout.dimensions[CSS_WIDTH] = 0;
5563       node_0->layout.dimensions[CSS_HEIGHT] = 0;
5564       init_css_node_children(node_0, 1);
5565       {
5566         css_node_t *node_1;
5567         node_1 = node_0->get_child(node_0->context, 0);
5568         node_1->layout.position[CSS_TOP] = 0;
5569         node_1->layout.position[CSS_LEFT] = -10;
5570         node_1->layout.dimensions[CSS_WIDTH] = 10;
5571         node_1->layout.dimensions[CSS_HEIGHT] = 0;
5572       }
5573     }
5574
5575     test("should calculate left properly with position: absolute right, width, and no parent dimensions", root_node, root_layout);
5576   }
5577
5578   {
5579     css_node_t *root_node = new_test_css_node();
5580     {
5581       css_node_t *node_0 = root_node;
5582       node_0->style.justify_content = CSS_JUSTIFY_SPACE_BETWEEN;
5583       init_css_node_children(node_0, 1);
5584       {
5585         css_node_t *node_1;
5586         node_1 = node_0->get_child(node_0->context, 0);
5587         node_1->style.border[CSS_BOTTOM] = 1;
5588       }
5589     }
5590
5591     css_node_t *root_layout = new_test_css_node();
5592     {
5593       css_node_t *node_0 = root_layout;
5594       node_0->layout.position[CSS_TOP] = 0;
5595       node_0->layout.position[CSS_LEFT] = 0;
5596       node_0->layout.dimensions[CSS_WIDTH] = 0;
5597       node_0->layout.dimensions[CSS_HEIGHT] = 1;
5598       init_css_node_children(node_0, 1);
5599       {
5600         css_node_t *node_1;
5601         node_1 = node_0->get_child(node_0->context, 0);
5602         node_1->layout.position[CSS_TOP] = 0;
5603         node_1->layout.position[CSS_LEFT] = 0;
5604         node_1->layout.dimensions[CSS_WIDTH] = 0;
5605         node_1->layout.dimensions[CSS_HEIGHT] = 1;
5606       }
5607     }
5608
5609     test("should layout border bottom inside of justify content space between container", root_node, root_layout);
5610   }
5611
5612   {
5613     css_node_t *root_node = new_test_css_node();
5614     {
5615       css_node_t *node_0 = root_node;
5616       node_0->style.justify_content = CSS_JUSTIFY_CENTER;
5617       init_css_node_children(node_0, 1);
5618       {
5619         css_node_t *node_1;
5620         node_1 = node_0->get_child(node_0->context, 0);
5621         node_1->style.margin[CSS_TOP] = -6;
5622       }
5623     }
5624
5625     css_node_t *root_layout = new_test_css_node();
5626     {
5627       css_node_t *node_0 = root_layout;
5628       node_0->layout.position[CSS_TOP] = 0;
5629       node_0->layout.position[CSS_LEFT] = 0;
5630       node_0->layout.dimensions[CSS_WIDTH] = 0;
5631       node_0->layout.dimensions[CSS_HEIGHT] = 0;
5632       init_css_node_children(node_0, 1);
5633       {
5634         css_node_t *node_1;
5635         node_1 = node_0->get_child(node_0->context, 0);
5636         node_1->layout.position[CSS_TOP] = -3;
5637         node_1->layout.position[CSS_LEFT] = 0;
5638         node_1->layout.dimensions[CSS_WIDTH] = 0;
5639         node_1->layout.dimensions[CSS_HEIGHT] = 0;
5640       }
5641     }
5642
5643     test("should layout negative margin top inside of justify content center container", root_node, root_layout);
5644   }
5645
5646   {
5647     css_node_t *root_node = new_test_css_node();
5648     {
5649       css_node_t *node_0 = root_node;
5650       node_0->style.justify_content = CSS_JUSTIFY_CENTER;
5651       init_css_node_children(node_0, 1);
5652       {
5653         css_node_t *node_1;
5654         node_1 = node_0->get_child(node_0->context, 0);
5655         node_1->style.margin[CSS_TOP] = 20;
5656       }
5657     }
5658
5659     css_node_t *root_layout = new_test_css_node();
5660     {
5661       css_node_t *node_0 = root_layout;
5662       node_0->layout.position[CSS_TOP] = 0;
5663       node_0->layout.position[CSS_LEFT] = 0;
5664       node_0->layout.dimensions[CSS_WIDTH] = 0;
5665       node_0->layout.dimensions[CSS_HEIGHT] = 20;
5666       init_css_node_children(node_0, 1);
5667       {
5668         css_node_t *node_1;
5669         node_1 = node_0->get_child(node_0->context, 0);
5670         node_1->layout.position[CSS_TOP] = 20;
5671         node_1->layout.position[CSS_LEFT] = 0;
5672         node_1->layout.dimensions[CSS_WIDTH] = 0;
5673         node_1->layout.dimensions[CSS_HEIGHT] = 0;
5674       }
5675     }
5676
5677     test("should layout positive margin top inside of justify content center container", root_node, root_layout);
5678   }
5679
5680   {
5681     css_node_t *root_node = new_test_css_node();
5682     {
5683       css_node_t *node_0 = root_node;
5684       node_0->style.justify_content = CSS_JUSTIFY_FLEX_END;
5685       node_0->style.border[CSS_BOTTOM] = 5;
5686       init_css_node_children(node_0, 1);
5687       {
5688         css_node_t *node_1;
5689         node_1 = node_0->get_child(node_0->context, 0);
5690       }
5691     }
5692
5693     css_node_t *root_layout = new_test_css_node();
5694     {
5695       css_node_t *node_0 = root_layout;
5696       node_0->layout.position[CSS_TOP] = 0;
5697       node_0->layout.position[CSS_LEFT] = 0;
5698       node_0->layout.dimensions[CSS_WIDTH] = 0;
5699       node_0->layout.dimensions[CSS_HEIGHT] = 5;
5700       init_css_node_children(node_0, 1);
5701       {
5702         css_node_t *node_1;
5703         node_1 = node_0->get_child(node_0->context, 0);
5704         node_1->layout.position[CSS_TOP] = 0;
5705         node_1->layout.position[CSS_LEFT] = 0;
5706         node_1->layout.dimensions[CSS_WIDTH] = 0;
5707         node_1->layout.dimensions[CSS_HEIGHT] = 0;
5708       }
5709     }
5710
5711     test("should layout border bottom and flex end with an empty child", root_node, root_layout);
5712   }
5713
5714   {
5715     css_node_t *root_node = new_test_css_node();
5716     {
5717       css_node_t *node_0 = root_node;
5718       node_0->style.dimensions[CSS_WIDTH] = 800;
5719       init_css_node_children(node_0, 1);
5720       {
5721         css_node_t *node_1;
5722         node_1 = node_0->get_child(node_0->context, 0);
5723         node_1->style.position[CSS_LEFT] = 5;
5724         init_css_node_children(node_1, 1);
5725         {
5726           css_node_t *node_2;
5727           node_2 = node_1->get_child(node_1->context, 0);
5728         }
5729       }
5730     }
5731
5732     css_node_t *root_layout = new_test_css_node();
5733     {
5734       css_node_t *node_0 = root_layout;
5735       node_0->layout.position[CSS_TOP] = 0;
5736       node_0->layout.position[CSS_LEFT] = 0;
5737       node_0->layout.dimensions[CSS_WIDTH] = 800;
5738       node_0->layout.dimensions[CSS_HEIGHT] = 0;
5739       init_css_node_children(node_0, 1);
5740       {
5741         css_node_t *node_1;
5742         node_1 = node_0->get_child(node_0->context, 0);
5743         node_1->layout.position[CSS_TOP] = 0;
5744         node_1->layout.position[CSS_LEFT] = 5;
5745         node_1->layout.dimensions[CSS_WIDTH] = 800;
5746         node_1->layout.dimensions[CSS_HEIGHT] = 0;
5747         init_css_node_children(node_1, 1);
5748         {
5749           css_node_t *node_2;
5750           node_2 = node_1->get_child(node_1->context, 0);
5751           node_2->layout.position[CSS_TOP] = 0;
5752           node_2->layout.position[CSS_LEFT] = 0;
5753           node_2->layout.dimensions[CSS_WIDTH] = 800;
5754           node_2->layout.dimensions[CSS_HEIGHT] = 0;
5755         }
5756       }
5757     }
5758
5759     test("should layout with children of a contain with left", root_node, root_layout);
5760   }
5761
5762   {
5763     css_node_t *root_node = new_test_css_node();
5764     {
5765       css_node_t *node_0 = root_node;
5766       node_0->style.flex_direction = CSS_FLEX_DIRECTION_ROW;
5767       node_0->style.flex_wrap = CSS_WRAP;
5768       node_0->style.dimensions[CSS_WIDTH] = 100;
5769       init_css_node_children(node_0, 3);
5770       {
5771         css_node_t *node_1;
5772         node_1 = node_0->get_child(node_0->context, 0);
5773         node_1->style.dimensions[CSS_WIDTH] = 40;
5774         node_1->style.dimensions[CSS_HEIGHT] = 10;
5775         node_1 = node_0->get_child(node_0->context, 1);
5776         node_1->style.dimensions[CSS_WIDTH] = 40;
5777         node_1->style.dimensions[CSS_HEIGHT] = 10;
5778         node_1 = node_0->get_child(node_0->context, 2);
5779         node_1->style.dimensions[CSS_WIDTH] = 40;
5780         node_1->style.dimensions[CSS_HEIGHT] = 10;
5781       }
5782     }
5783
5784     css_node_t *root_layout = new_test_css_node();
5785     {
5786       css_node_t *node_0 = root_layout;
5787       node_0->layout.position[CSS_TOP] = 0;
5788       node_0->layout.position[CSS_LEFT] = 0;
5789       node_0->layout.dimensions[CSS_WIDTH] = 100;
5790       node_0->layout.dimensions[CSS_HEIGHT] = 20;
5791       init_css_node_children(node_0, 3);
5792       {
5793         css_node_t *node_1;
5794         node_1 = node_0->get_child(node_0->context, 0);
5795         node_1->layout.position[CSS_TOP] = 0;
5796         node_1->layout.position[CSS_LEFT] = 0;
5797         node_1->layout.dimensions[CSS_WIDTH] = 40;
5798         node_1->layout.dimensions[CSS_HEIGHT] = 10;
5799         node_1 = node_0->get_child(node_0->context, 1);
5800         node_1->layout.position[CSS_TOP] = 0;
5801         node_1->layout.position[CSS_LEFT] = 40;
5802         node_1->layout.dimensions[CSS_WIDTH] = 40;
5803         node_1->layout.dimensions[CSS_HEIGHT] = 10;
5804         node_1 = node_0->get_child(node_0->context, 2);
5805         node_1->layout.position[CSS_TOP] = 10;
5806         node_1->layout.position[CSS_LEFT] = 0;
5807         node_1->layout.dimensions[CSS_WIDTH] = 40;
5808         node_1->layout.dimensions[CSS_HEIGHT] = 10;
5809       }
5810     }
5811
5812     test("should layout flex-wrap", root_node, root_layout);
5813   }
5814
5815   {
5816     css_node_t *root_node = new_test_css_node();
5817     {
5818       css_node_t *node_0 = root_node;
5819       node_0->style.direction = CSS_DIRECTION_RTL;
5820       node_0->style.flex_direction = CSS_FLEX_DIRECTION_ROW;
5821       node_0->style.flex_wrap = CSS_WRAP;
5822       node_0->style.dimensions[CSS_WIDTH] = 100;
5823       init_css_node_children(node_0, 3);
5824       {
5825         css_node_t *node_1;
5826         node_1 = node_0->get_child(node_0->context, 0);
5827         node_1->style.dimensions[CSS_WIDTH] = 40;
5828         node_1->style.dimensions[CSS_HEIGHT] = 10;
5829         node_1 = node_0->get_child(node_0->context, 1);
5830         node_1->style.dimensions[CSS_WIDTH] = 40;
5831         node_1->style.dimensions[CSS_HEIGHT] = 10;
5832         node_1 = node_0->get_child(node_0->context, 2);
5833         node_1->style.dimensions[CSS_WIDTH] = 40;
5834         node_1->style.dimensions[CSS_HEIGHT] = 10;
5835       }
5836     }
5837
5838     css_node_t *root_layout = new_test_css_node();
5839     {
5840       css_node_t *node_0 = root_layout;
5841       node_0->layout.position[CSS_TOP] = 0;
5842       node_0->layout.position[CSS_LEFT] = 0;
5843       node_0->layout.dimensions[CSS_WIDTH] = 100;
5844       node_0->layout.dimensions[CSS_HEIGHT] = 20;
5845       init_css_node_children(node_0, 3);
5846       {
5847         css_node_t *node_1;
5848         node_1 = node_0->get_child(node_0->context, 0);
5849         node_1->layout.position[CSS_TOP] = 0;
5850         node_1->layout.position[CSS_LEFT] = 60;
5851         node_1->layout.dimensions[CSS_WIDTH] = 40;
5852         node_1->layout.dimensions[CSS_HEIGHT] = 10;
5853         node_1 = node_0->get_child(node_0->context, 1);
5854         node_1->layout.position[CSS_TOP] = 0;
5855         node_1->layout.position[CSS_LEFT] = 20;
5856         node_1->layout.dimensions[CSS_WIDTH] = 40;
5857         node_1->layout.dimensions[CSS_HEIGHT] = 10;
5858         node_1 = node_0->get_child(node_0->context, 2);
5859         node_1->layout.position[CSS_TOP] = 10;
5860         node_1->layout.position[CSS_LEFT] = 60;
5861         node_1->layout.dimensions[CSS_WIDTH] = 40;
5862         node_1->layout.dimensions[CSS_HEIGHT] = 10;
5863       }
5864     }
5865
5866     test("should layout flex-wrap in rtl", root_node, root_layout);
5867   }
5868
5869   {
5870     css_node_t *root_node = new_test_css_node();
5871     {
5872       css_node_t *node_0 = root_node;
5873       node_0->style.flex_wrap = CSS_WRAP;
5874       node_0->style.dimensions[CSS_HEIGHT] = 100;
5875       init_css_node_children(node_0, 2);
5876       {
5877         css_node_t *node_1;
5878         node_1 = node_0->get_child(node_0->context, 0);
5879         node_1->style.dimensions[CSS_HEIGHT] = 100;
5880         node_1 = node_0->get_child(node_0->context, 1);
5881         node_1->style.dimensions[CSS_HEIGHT] = 200;
5882       }
5883     }
5884
5885     css_node_t *root_layout = new_test_css_node();
5886     {
5887       css_node_t *node_0 = root_layout;
5888       node_0->layout.position[CSS_TOP] = 0;
5889       node_0->layout.position[CSS_LEFT] = 0;
5890       node_0->layout.dimensions[CSS_WIDTH] = 0;
5891       node_0->layout.dimensions[CSS_HEIGHT] = 100;
5892       init_css_node_children(node_0, 2);
5893       {
5894         css_node_t *node_1;
5895         node_1 = node_0->get_child(node_0->context, 0);
5896         node_1->layout.position[CSS_TOP] = 0;
5897         node_1->layout.position[CSS_LEFT] = 0;
5898         node_1->layout.dimensions[CSS_WIDTH] = 0;
5899         node_1->layout.dimensions[CSS_HEIGHT] = 100;
5900         node_1 = node_0->get_child(node_0->context, 1);
5901         node_1->layout.position[CSS_TOP] = 0;
5902         node_1->layout.position[CSS_LEFT] = 0;
5903         node_1->layout.dimensions[CSS_WIDTH] = 0;
5904         node_1->layout.dimensions[CSS_HEIGHT] = 200;
5905       }
5906     }
5907
5908     test("should layout flex wrap with a line bigger than container", root_node, root_layout);
5909   }
5910
5911   {
5912     css_node_t *root_node = new_test_css_node();
5913     {
5914       css_node_t *node_0 = root_node;
5915       node_0->style.dimensions[CSS_WIDTH] = 100;
5916       node_0->style.dimensions[CSS_HEIGHT] = 200;
5917       node_0->style.maxDimensions[CSS_WIDTH] = 90;
5918       node_0->style.maxDimensions[CSS_HEIGHT] = 190;
5919     }
5920
5921     css_node_t *root_layout = new_test_css_node();
5922     {
5923       css_node_t *node_0 = root_layout;
5924       node_0->layout.position[CSS_TOP] = 0;
5925       node_0->layout.position[CSS_LEFT] = 0;
5926       node_0->layout.dimensions[CSS_WIDTH] = 90;
5927       node_0->layout.dimensions[CSS_HEIGHT] = 190;
5928     }
5929
5930     test("should use max bounds", root_node, root_layout);
5931   }
5932
5933   {
5934     css_node_t *root_node = new_test_css_node();
5935     {
5936       css_node_t *node_0 = root_node;
5937       node_0->style.dimensions[CSS_WIDTH] = 100;
5938       node_0->style.dimensions[CSS_HEIGHT] = 200;
5939       node_0->style.minDimensions[CSS_WIDTH] = 110;
5940       node_0->style.minDimensions[CSS_HEIGHT] = 210;
5941     }
5942
5943     css_node_t *root_layout = new_test_css_node();
5944     {
5945       css_node_t *node_0 = root_layout;
5946       node_0->layout.position[CSS_TOP] = 0;
5947       node_0->layout.position[CSS_LEFT] = 0;
5948       node_0->layout.dimensions[CSS_WIDTH] = 110;
5949       node_0->layout.dimensions[CSS_HEIGHT] = 210;
5950     }
5951
5952     test("should use min bounds", root_node, root_layout);
5953   }
5954
5955   {
5956     css_node_t *root_node = new_test_css_node();
5957     {
5958       css_node_t *node_0 = root_node;
5959       node_0->style.dimensions[CSS_WIDTH] = 100;
5960       node_0->style.dimensions[CSS_HEIGHT] = 200;
5961       node_0->style.maxDimensions[CSS_WIDTH] = 90;
5962       node_0->style.maxDimensions[CSS_HEIGHT] = 190;
5963       node_0->style.minDimensions[CSS_WIDTH] = 110;
5964       node_0->style.minDimensions[CSS_HEIGHT] = 210;
5965     }
5966
5967     css_node_t *root_layout = new_test_css_node();
5968     {
5969       css_node_t *node_0 = root_layout;
5970       node_0->layout.position[CSS_TOP] = 0;
5971       node_0->layout.position[CSS_LEFT] = 0;
5972       node_0->layout.dimensions[CSS_WIDTH] = 110;
5973       node_0->layout.dimensions[CSS_HEIGHT] = 210;
5974     }
5975
5976     test("should use min bounds over max bounds", root_node, root_layout);
5977   }
5978
5979   {
5980     css_node_t *root_node = new_test_css_node();
5981     {
5982       css_node_t *node_0 = root_node;
5983       node_0->style.dimensions[CSS_WIDTH] = 100;
5984       node_0->style.dimensions[CSS_HEIGHT] = 200;
5985       node_0->style.maxDimensions[CSS_WIDTH] = 80;
5986       node_0->style.maxDimensions[CSS_HEIGHT] = 180;
5987       node_0->style.minDimensions[CSS_WIDTH] = 90;
5988       node_0->style.minDimensions[CSS_HEIGHT] = 190;
5989     }
5990
5991     css_node_t *root_layout = new_test_css_node();
5992     {
5993       css_node_t *node_0 = root_layout;
5994       node_0->layout.position[CSS_TOP] = 0;
5995       node_0->layout.position[CSS_LEFT] = 0;
5996       node_0->layout.dimensions[CSS_WIDTH] = 90;
5997       node_0->layout.dimensions[CSS_HEIGHT] = 190;
5998     }
5999
6000     test("should use min bounds over max bounds and natural width", root_node, root_layout);
6001   }
6002
6003   {
6004     css_node_t *root_node = new_test_css_node();
6005     {
6006       css_node_t *node_0 = root_node;
6007       node_0->style.dimensions[CSS_WIDTH] = 100;
6008       node_0->style.dimensions[CSS_HEIGHT] = 200;
6009       node_0->style.minDimensions[CSS_WIDTH] = -10;
6010       node_0->style.minDimensions[CSS_HEIGHT] = -20;
6011     }
6012
6013     css_node_t *root_layout = new_test_css_node();
6014     {
6015       css_node_t *node_0 = root_layout;
6016       node_0->layout.position[CSS_TOP] = 0;
6017       node_0->layout.position[CSS_LEFT] = 0;
6018       node_0->layout.dimensions[CSS_WIDTH] = 100;
6019       node_0->layout.dimensions[CSS_HEIGHT] = 200;
6020     }
6021
6022     test("should ignore negative min bounds", root_node, root_layout);
6023   }
6024
6025   {
6026     css_node_t *root_node = new_test_css_node();
6027     {
6028       css_node_t *node_0 = root_node;
6029       node_0->style.dimensions[CSS_WIDTH] = 100;
6030       node_0->style.dimensions[CSS_HEIGHT] = 200;
6031       node_0->style.maxDimensions[CSS_WIDTH] = -10;
6032       node_0->style.maxDimensions[CSS_HEIGHT] = -20;
6033     }
6034
6035     css_node_t *root_layout = new_test_css_node();
6036     {
6037       css_node_t *node_0 = root_layout;
6038       node_0->layout.position[CSS_TOP] = 0;
6039       node_0->layout.position[CSS_LEFT] = 0;
6040       node_0->layout.dimensions[CSS_WIDTH] = 100;
6041       node_0->layout.dimensions[CSS_HEIGHT] = 200;
6042     }
6043
6044     test("should ignore negative max bounds", root_node, root_layout);
6045   }
6046
6047   {
6048     css_node_t *root_node = new_test_css_node();
6049     {
6050       css_node_t *node_0 = root_node;
6051       node_0->style.maxDimensions[CSS_WIDTH] = 30;
6052       node_0->style.maxDimensions[CSS_HEIGHT] = 10;
6053       node_0->style.padding[CSS_LEFT] = 20;
6054       node_0->style.padding[CSS_TOP] = 15;
6055       node_0->style.padding[CSS_RIGHT] = 20;
6056       node_0->style.padding[CSS_BOTTOM] = 15;
6057     }
6058
6059     css_node_t *root_layout = new_test_css_node();
6060     {
6061       css_node_t *node_0 = root_layout;
6062       node_0->layout.position[CSS_TOP] = 0;
6063       node_0->layout.position[CSS_LEFT] = 0;
6064       node_0->layout.dimensions[CSS_WIDTH] = 40;
6065       node_0->layout.dimensions[CSS_HEIGHT] = 30;
6066     }
6067
6068     test("should use padded size over max bounds", root_node, root_layout);
6069   }
6070
6071   {
6072     css_node_t *root_node = new_test_css_node();
6073     {
6074       css_node_t *node_0 = root_node;
6075       node_0->style.minDimensions[CSS_WIDTH] = 50;
6076       node_0->style.minDimensions[CSS_HEIGHT] = 40;
6077       node_0->style.padding[CSS_LEFT] = 20;
6078       node_0->style.padding[CSS_TOP] = 15;
6079       node_0->style.padding[CSS_RIGHT] = 20;
6080       node_0->style.padding[CSS_BOTTOM] = 15;
6081     }
6082
6083     css_node_t *root_layout = new_test_css_node();
6084     {
6085       css_node_t *node_0 = root_layout;
6086       node_0->layout.position[CSS_TOP] = 0;
6087       node_0->layout.position[CSS_LEFT] = 0;
6088       node_0->layout.dimensions[CSS_WIDTH] = 50;
6089       node_0->layout.dimensions[CSS_HEIGHT] = 40;
6090     }
6091
6092     test("should use min size over padded size", root_node, root_layout);
6093   }
6094
6095   {
6096     css_node_t *root_node = new_test_css_node();
6097     {
6098       css_node_t *node_0 = root_node;
6099       node_0->style.flex_direction = CSS_FLEX_DIRECTION_ROW;
6100       node_0->style.dimensions[CSS_WIDTH] = 300;
6101       node_0->style.dimensions[CSS_HEIGHT] = 200;
6102       init_css_node_children(node_0, 3);
6103       {
6104         css_node_t *node_1;
6105         node_1 = node_0->get_child(node_0->context, 0);
6106         node_1->style.flex = 1;
6107         node_1 = node_0->get_child(node_0->context, 1);
6108         node_1->style.flex = 1;
6109         node_1->style.minDimensions[CSS_WIDTH] = 200;
6110         node_1 = node_0->get_child(node_0->context, 2);
6111         node_1->style.flex = 1;
6112       }
6113     }
6114
6115     css_node_t *root_layout = new_test_css_node();
6116     {
6117       css_node_t *node_0 = root_layout;
6118       node_0->layout.position[CSS_TOP] = 0;
6119       node_0->layout.position[CSS_LEFT] = 0;
6120       node_0->layout.dimensions[CSS_WIDTH] = 300;
6121       node_0->layout.dimensions[CSS_HEIGHT] = 200;
6122       init_css_node_children(node_0, 3);
6123       {
6124         css_node_t *node_1;
6125         node_1 = node_0->get_child(node_0->context, 0);
6126         node_1->layout.position[CSS_TOP] = 0;
6127         node_1->layout.position[CSS_LEFT] = 0;
6128         node_1->layout.dimensions[CSS_WIDTH] = 50;
6129         node_1->layout.dimensions[CSS_HEIGHT] = 200;
6130         node_1 = node_0->get_child(node_0->context, 1);
6131         node_1->layout.position[CSS_TOP] = 0;
6132         node_1->layout.position[CSS_LEFT] = 50;
6133         node_1->layout.dimensions[CSS_WIDTH] = 200;
6134         node_1->layout.dimensions[CSS_HEIGHT] = 200;
6135         node_1 = node_0->get_child(node_0->context, 2);
6136         node_1->layout.position[CSS_TOP] = 0;
6137         node_1->layout.position[CSS_LEFT] = 250;
6138         node_1->layout.dimensions[CSS_WIDTH] = 50;
6139         node_1->layout.dimensions[CSS_HEIGHT] = 200;
6140       }
6141     }
6142
6143     test("should override flex direction size with min bounds", root_node, root_layout);
6144   }
6145
6146   {
6147     css_node_t *root_node = new_test_css_node();
6148     {
6149       css_node_t *node_0 = root_node;
6150       node_0->style.direction = CSS_DIRECTION_RTL;
6151       node_0->style.flex_direction = CSS_FLEX_DIRECTION_ROW;
6152       node_0->style.dimensions[CSS_WIDTH] = 300;
6153       node_0->style.dimensions[CSS_HEIGHT] = 200;
6154       init_css_node_children(node_0, 3);
6155       {
6156         css_node_t *node_1;
6157         node_1 = node_0->get_child(node_0->context, 0);
6158         node_1->style.flex = 1;
6159         node_1 = node_0->get_child(node_0->context, 1);
6160         node_1->style.flex = 1;
6161         node_1->style.minDimensions[CSS_WIDTH] = 200;
6162         node_1 = node_0->get_child(node_0->context, 2);
6163         node_1->style.flex = 1;
6164       }
6165     }
6166
6167     css_node_t *root_layout = new_test_css_node();
6168     {
6169       css_node_t *node_0 = root_layout;
6170       node_0->layout.position[CSS_TOP] = 0;
6171       node_0->layout.position[CSS_LEFT] = 0;
6172       node_0->layout.dimensions[CSS_WIDTH] = 300;
6173       node_0->layout.dimensions[CSS_HEIGHT] = 200;
6174       init_css_node_children(node_0, 3);
6175       {
6176         css_node_t *node_1;
6177         node_1 = node_0->get_child(node_0->context, 0);
6178         node_1->layout.position[CSS_TOP] = 0;
6179         node_1->layout.position[CSS_LEFT] = 250;
6180         node_1->layout.dimensions[CSS_WIDTH] = 50;
6181         node_1->layout.dimensions[CSS_HEIGHT] = 200;
6182         node_1 = node_0->get_child(node_0->context, 1);
6183         node_1->layout.position[CSS_TOP] = 0;
6184         node_1->layout.position[CSS_LEFT] = 50;
6185         node_1->layout.dimensions[CSS_WIDTH] = 200;
6186         node_1->layout.dimensions[CSS_HEIGHT] = 200;
6187         node_1 = node_0->get_child(node_0->context, 2);
6188         node_1->layout.position[CSS_TOP] = 0;
6189         node_1->layout.position[CSS_LEFT] = 0;
6190         node_1->layout.dimensions[CSS_WIDTH] = 50;
6191         node_1->layout.dimensions[CSS_HEIGHT] = 200;
6192       }
6193     }
6194
6195     test("should override flex direction size with min bounds in rtl", root_node, root_layout);
6196   }
6197
6198   {
6199     css_node_t *root_node = new_test_css_node();
6200     {
6201       css_node_t *node_0 = root_node;
6202       node_0->style.flex_direction = CSS_FLEX_DIRECTION_ROW;
6203       node_0->style.dimensions[CSS_WIDTH] = 300;
6204       node_0->style.dimensions[CSS_HEIGHT] = 200;
6205       init_css_node_children(node_0, 3);
6206       {
6207         css_node_t *node_1;
6208         node_1 = node_0->get_child(node_0->context, 0);
6209         node_1->style.flex = 1;
6210         node_1 = node_0->get_child(node_0->context, 1);
6211         node_1->style.flex = 1;
6212         node_1->style.maxDimensions[CSS_WIDTH] = 110;
6213         node_1->style.minDimensions[CSS_WIDTH] = 90;
6214         node_1 = node_0->get_child(node_0->context, 2);
6215         node_1->style.flex = 1;
6216       }
6217     }
6218
6219     css_node_t *root_layout = new_test_css_node();
6220     {
6221       css_node_t *node_0 = root_layout;
6222       node_0->layout.position[CSS_TOP] = 0;
6223       node_0->layout.position[CSS_LEFT] = 0;
6224       node_0->layout.dimensions[CSS_WIDTH] = 300;
6225       node_0->layout.dimensions[CSS_HEIGHT] = 200;
6226       init_css_node_children(node_0, 3);
6227       {
6228         css_node_t *node_1;
6229         node_1 = node_0->get_child(node_0->context, 0);
6230         node_1->layout.position[CSS_TOP] = 0;
6231         node_1->layout.position[CSS_LEFT] = 0;
6232         node_1->layout.dimensions[CSS_WIDTH] = 100;
6233         node_1->layout.dimensions[CSS_HEIGHT] = 200;
6234         node_1 = node_0->get_child(node_0->context, 1);
6235         node_1->layout.position[CSS_TOP] = 0;
6236         node_1->layout.position[CSS_LEFT] = 100;
6237         node_1->layout.dimensions[CSS_WIDTH] = 100;
6238         node_1->layout.dimensions[CSS_HEIGHT] = 200;
6239         node_1 = node_0->get_child(node_0->context, 2);
6240         node_1->layout.position[CSS_TOP] = 0;
6241         node_1->layout.position[CSS_LEFT] = 200;
6242         node_1->layout.dimensions[CSS_WIDTH] = 100;
6243         node_1->layout.dimensions[CSS_HEIGHT] = 200;
6244       }
6245     }
6246
6247     test("should not override flex direction size within bounds", root_node, root_layout);
6248   }
6249
6250   {
6251     css_node_t *root_node = new_test_css_node();
6252     {
6253       css_node_t *node_0 = root_node;
6254       node_0->style.direction = CSS_DIRECTION_RTL;
6255       node_0->style.flex_direction = CSS_FLEX_DIRECTION_ROW;
6256       node_0->style.dimensions[CSS_WIDTH] = 300;
6257       node_0->style.dimensions[CSS_HEIGHT] = 200;
6258       init_css_node_children(node_0, 3);
6259       {
6260         css_node_t *node_1;
6261         node_1 = node_0->get_child(node_0->context, 0);
6262         node_1->style.flex = 1;
6263         node_1 = node_0->get_child(node_0->context, 1);
6264         node_1->style.flex = 1;
6265         node_1->style.maxDimensions[CSS_WIDTH] = 110;
6266         node_1->style.minDimensions[CSS_WIDTH] = 90;
6267         node_1 = node_0->get_child(node_0->context, 2);
6268         node_1->style.flex = 1;
6269       }
6270     }
6271
6272     css_node_t *root_layout = new_test_css_node();
6273     {
6274       css_node_t *node_0 = root_layout;
6275       node_0->layout.position[CSS_TOP] = 0;
6276       node_0->layout.position[CSS_LEFT] = 0;
6277       node_0->layout.dimensions[CSS_WIDTH] = 300;
6278       node_0->layout.dimensions[CSS_HEIGHT] = 200;
6279       init_css_node_children(node_0, 3);
6280       {
6281         css_node_t *node_1;
6282         node_1 = node_0->get_child(node_0->context, 0);
6283         node_1->layout.position[CSS_TOP] = 0;
6284         node_1->layout.position[CSS_LEFT] = 200;
6285         node_1->layout.dimensions[CSS_WIDTH] = 100;
6286         node_1->layout.dimensions[CSS_HEIGHT] = 200;
6287         node_1 = node_0->get_child(node_0->context, 1);
6288         node_1->layout.position[CSS_TOP] = 0;
6289         node_1->layout.position[CSS_LEFT] = 100;
6290         node_1->layout.dimensions[CSS_WIDTH] = 100;
6291         node_1->layout.dimensions[CSS_HEIGHT] = 200;
6292         node_1 = node_0->get_child(node_0->context, 2);
6293         node_1->layout.position[CSS_TOP] = 0;
6294         node_1->layout.position[CSS_LEFT] = 0;
6295         node_1->layout.dimensions[CSS_WIDTH] = 100;
6296         node_1->layout.dimensions[CSS_HEIGHT] = 200;
6297       }
6298     }
6299
6300     test("should not override flex direction size within bounds in rtl", root_node, root_layout);
6301   }
6302
6303   {
6304     css_node_t *root_node = new_test_css_node();
6305     {
6306       css_node_t *node_0 = root_node;
6307       node_0->style.flex_direction = CSS_FLEX_DIRECTION_ROW;
6308       node_0->style.dimensions[CSS_WIDTH] = 300;
6309       node_0->style.dimensions[CSS_HEIGHT] = 200;
6310       init_css_node_children(node_0, 3);
6311       {
6312         css_node_t *node_1;
6313         node_1 = node_0->get_child(node_0->context, 0);
6314         node_1->style.flex = 1;
6315         node_1 = node_0->get_child(node_0->context, 1);
6316         node_1->style.flex = 1;
6317         node_1->style.maxDimensions[CSS_WIDTH] = 60;
6318         node_1 = node_0->get_child(node_0->context, 2);
6319         node_1->style.flex = 1;
6320       }
6321     }
6322
6323     css_node_t *root_layout = new_test_css_node();
6324     {
6325       css_node_t *node_0 = root_layout;
6326       node_0->layout.position[CSS_TOP] = 0;
6327       node_0->layout.position[CSS_LEFT] = 0;
6328       node_0->layout.dimensions[CSS_WIDTH] = 300;
6329       node_0->layout.dimensions[CSS_HEIGHT] = 200;
6330       init_css_node_children(node_0, 3);
6331       {
6332         css_node_t *node_1;
6333         node_1 = node_0->get_child(node_0->context, 0);
6334         node_1->layout.position[CSS_TOP] = 0;
6335         node_1->layout.position[CSS_LEFT] = 0;
6336         node_1->layout.dimensions[CSS_WIDTH] = 120;
6337         node_1->layout.dimensions[CSS_HEIGHT] = 200;
6338         node_1 = node_0->get_child(node_0->context, 1);
6339         node_1->layout.position[CSS_TOP] = 0;
6340         node_1->layout.position[CSS_LEFT] = 120;
6341         node_1->layout.dimensions[CSS_WIDTH] = 60;
6342         node_1->layout.dimensions[CSS_HEIGHT] = 200;
6343         node_1 = node_0->get_child(node_0->context, 2);
6344         node_1->layout.position[CSS_TOP] = 0;
6345         node_1->layout.position[CSS_LEFT] = 180;
6346         node_1->layout.dimensions[CSS_WIDTH] = 120;
6347         node_1->layout.dimensions[CSS_HEIGHT] = 200;
6348       }
6349     }
6350
6351     test("should override flex direction size with max bounds", root_node, root_layout);
6352   }
6353
6354   {
6355     css_node_t *root_node = new_test_css_node();
6356     {
6357       css_node_t *node_0 = root_node;
6358       node_0->style.direction = CSS_DIRECTION_RTL;
6359       node_0->style.flex_direction = CSS_FLEX_DIRECTION_ROW;
6360       node_0->style.dimensions[CSS_WIDTH] = 300;
6361       node_0->style.dimensions[CSS_HEIGHT] = 200;
6362       init_css_node_children(node_0, 3);
6363       {
6364         css_node_t *node_1;
6365         node_1 = node_0->get_child(node_0->context, 0);
6366         node_1->style.flex = 1;
6367         node_1 = node_0->get_child(node_0->context, 1);
6368         node_1->style.flex = 1;
6369         node_1->style.maxDimensions[CSS_WIDTH] = 60;
6370         node_1 = node_0->get_child(node_0->context, 2);
6371         node_1->style.flex = 1;
6372       }
6373     }
6374
6375     css_node_t *root_layout = new_test_css_node();
6376     {
6377       css_node_t *node_0 = root_layout;
6378       node_0->layout.position[CSS_TOP] = 0;
6379       node_0->layout.position[CSS_LEFT] = 0;
6380       node_0->layout.dimensions[CSS_WIDTH] = 300;
6381       node_0->layout.dimensions[CSS_HEIGHT] = 200;
6382       init_css_node_children(node_0, 3);
6383       {
6384         css_node_t *node_1;
6385         node_1 = node_0->get_child(node_0->context, 0);
6386         node_1->layout.position[CSS_TOP] = 0;
6387         node_1->layout.position[CSS_LEFT] = 180;
6388         node_1->layout.dimensions[CSS_WIDTH] = 120;
6389         node_1->layout.dimensions[CSS_HEIGHT] = 200;
6390         node_1 = node_0->get_child(node_0->context, 1);
6391         node_1->layout.position[CSS_TOP] = 0;
6392         node_1->layout.position[CSS_LEFT] = 120;
6393         node_1->layout.dimensions[CSS_WIDTH] = 60;
6394         node_1->layout.dimensions[CSS_HEIGHT] = 200;
6395         node_1 = node_0->get_child(node_0->context, 2);
6396         node_1->layout.position[CSS_TOP] = 0;
6397         node_1->layout.position[CSS_LEFT] = 0;
6398         node_1->layout.dimensions[CSS_WIDTH] = 120;
6399         node_1->layout.dimensions[CSS_HEIGHT] = 200;
6400       }
6401     }
6402
6403     test("should override flex direction size with max bounds in rtl", root_node, root_layout);
6404   }
6405
6406   {
6407     css_node_t *root_node = new_test_css_node();
6408     {
6409       css_node_t *node_0 = root_node;
6410       node_0->style.flex_direction = CSS_FLEX_DIRECTION_ROW;
6411       node_0->style.dimensions[CSS_WIDTH] = 300;
6412       node_0->style.dimensions[CSS_HEIGHT] = 200;
6413       init_css_node_children(node_0, 3);
6414       {
6415         css_node_t *node_1;
6416         node_1 = node_0->get_child(node_0->context, 0);
6417         node_1->style.flex = 1;
6418         node_1->style.maxDimensions[CSS_WIDTH] = 60;
6419         node_1 = node_0->get_child(node_0->context, 1);
6420         node_1->style.flex = 1;
6421         node_1->style.maxDimensions[CSS_WIDTH] = 60;
6422         node_1 = node_0->get_child(node_0->context, 2);
6423         node_1->style.flex = 1;
6424         node_1->style.maxDimensions[CSS_WIDTH] = 60;
6425       }
6426     }
6427
6428     css_node_t *root_layout = new_test_css_node();
6429     {
6430       css_node_t *node_0 = root_layout;
6431       node_0->layout.position[CSS_TOP] = 0;
6432       node_0->layout.position[CSS_LEFT] = 0;
6433       node_0->layout.dimensions[CSS_WIDTH] = 300;
6434       node_0->layout.dimensions[CSS_HEIGHT] = 200;
6435       init_css_node_children(node_0, 3);
6436       {
6437         css_node_t *node_1;
6438         node_1 = node_0->get_child(node_0->context, 0);
6439         node_1->layout.position[CSS_TOP] = 0;
6440         node_1->layout.position[CSS_LEFT] = 0;
6441         node_1->layout.dimensions[CSS_WIDTH] = 60;
6442         node_1->layout.dimensions[CSS_HEIGHT] = 200;
6443         node_1 = node_0->get_child(node_0->context, 1);
6444         node_1->layout.position[CSS_TOP] = 0;
6445         node_1->layout.position[CSS_LEFT] = 60;
6446         node_1->layout.dimensions[CSS_WIDTH] = 60;
6447         node_1->layout.dimensions[CSS_HEIGHT] = 200;
6448         node_1 = node_0->get_child(node_0->context, 2);
6449         node_1->layout.position[CSS_TOP] = 0;
6450         node_1->layout.position[CSS_LEFT] = 120;
6451         node_1->layout.dimensions[CSS_WIDTH] = 60;
6452         node_1->layout.dimensions[CSS_HEIGHT] = 200;
6453       }
6454     }
6455
6456     test("should ignore flex size if fully max bound", root_node, root_layout);
6457   }
6458
6459   {
6460     css_node_t *root_node = new_test_css_node();
6461     {
6462       css_node_t *node_0 = root_node;
6463       node_0->style.direction = CSS_DIRECTION_RTL;
6464       node_0->style.flex_direction = CSS_FLEX_DIRECTION_ROW;
6465       node_0->style.dimensions[CSS_WIDTH] = 300;
6466       node_0->style.dimensions[CSS_HEIGHT] = 200;
6467       init_css_node_children(node_0, 3);
6468       {
6469         css_node_t *node_1;
6470         node_1 = node_0->get_child(node_0->context, 0);
6471         node_1->style.flex = 1;
6472         node_1->style.maxDimensions[CSS_WIDTH] = 60;
6473         node_1 = node_0->get_child(node_0->context, 1);
6474         node_1->style.flex = 1;
6475         node_1->style.maxDimensions[CSS_WIDTH] = 60;
6476         node_1 = node_0->get_child(node_0->context, 2);
6477         node_1->style.flex = 1;
6478         node_1->style.maxDimensions[CSS_WIDTH] = 60;
6479       }
6480     }
6481
6482     css_node_t *root_layout = new_test_css_node();
6483     {
6484       css_node_t *node_0 = root_layout;
6485       node_0->layout.position[CSS_TOP] = 0;
6486       node_0->layout.position[CSS_LEFT] = 0;
6487       node_0->layout.dimensions[CSS_WIDTH] = 300;
6488       node_0->layout.dimensions[CSS_HEIGHT] = 200;
6489       init_css_node_children(node_0, 3);
6490       {
6491         css_node_t *node_1;
6492         node_1 = node_0->get_child(node_0->context, 0);
6493         node_1->layout.position[CSS_TOP] = 0;
6494         node_1->layout.position[CSS_LEFT] = 240;
6495         node_1->layout.dimensions[CSS_WIDTH] = 60;
6496         node_1->layout.dimensions[CSS_HEIGHT] = 200;
6497         node_1 = node_0->get_child(node_0->context, 1);
6498         node_1->layout.position[CSS_TOP] = 0;
6499         node_1->layout.position[CSS_LEFT] = 180;
6500         node_1->layout.dimensions[CSS_WIDTH] = 60;
6501         node_1->layout.dimensions[CSS_HEIGHT] = 200;
6502         node_1 = node_0->get_child(node_0->context, 2);
6503         node_1->layout.position[CSS_TOP] = 0;
6504         node_1->layout.position[CSS_LEFT] = 120;
6505         node_1->layout.dimensions[CSS_WIDTH] = 60;
6506         node_1->layout.dimensions[CSS_HEIGHT] = 200;
6507       }
6508     }
6509
6510     test("should ignore flex size if fully max bound in rtl", root_node, root_layout);
6511   }
6512
6513   {
6514     css_node_t *root_node = new_test_css_node();
6515     {
6516       css_node_t *node_0 = root_node;
6517       node_0->style.flex_direction = CSS_FLEX_DIRECTION_ROW;
6518       node_0->style.dimensions[CSS_WIDTH] = 300;
6519       node_0->style.dimensions[CSS_HEIGHT] = 200;
6520       init_css_node_children(node_0, 3);
6521       {
6522         css_node_t *node_1;
6523         node_1 = node_0->get_child(node_0->context, 0);
6524         node_1->style.flex = 1;
6525         node_1->style.minDimensions[CSS_WIDTH] = 120;
6526         node_1 = node_0->get_child(node_0->context, 1);
6527         node_1->style.flex = 1;
6528         node_1->style.minDimensions[CSS_WIDTH] = 120;
6529         node_1 = node_0->get_child(node_0->context, 2);
6530         node_1->style.flex = 1;
6531         node_1->style.minDimensions[CSS_WIDTH] = 120;
6532       }
6533     }
6534
6535     css_node_t *root_layout = new_test_css_node();
6536     {
6537       css_node_t *node_0 = root_layout;
6538       node_0->layout.position[CSS_TOP] = 0;
6539       node_0->layout.position[CSS_LEFT] = 0;
6540       node_0->layout.dimensions[CSS_WIDTH] = 300;
6541       node_0->layout.dimensions[CSS_HEIGHT] = 200;
6542       init_css_node_children(node_0, 3);
6543       {
6544         css_node_t *node_1;
6545         node_1 = node_0->get_child(node_0->context, 0);
6546         node_1->layout.position[CSS_TOP] = 0;
6547         node_1->layout.position[CSS_LEFT] = 0;
6548         node_1->layout.dimensions[CSS_WIDTH] = 120;
6549         node_1->layout.dimensions[CSS_HEIGHT] = 200;
6550         node_1 = node_0->get_child(node_0->context, 1);
6551         node_1->layout.position[CSS_TOP] = 0;
6552         node_1->layout.position[CSS_LEFT] = 120;
6553         node_1->layout.dimensions[CSS_WIDTH] = 120;
6554         node_1->layout.dimensions[CSS_HEIGHT] = 200;
6555         node_1 = node_0->get_child(node_0->context, 2);
6556         node_1->layout.position[CSS_TOP] = 0;
6557         node_1->layout.position[CSS_LEFT] = 240;
6558         node_1->layout.dimensions[CSS_WIDTH] = 120;
6559         node_1->layout.dimensions[CSS_HEIGHT] = 200;
6560       }
6561     }
6562
6563     test("should ignore flex size if fully min bound", root_node, root_layout);
6564   }
6565
6566   {
6567     css_node_t *root_node = new_test_css_node();
6568     {
6569       css_node_t *node_0 = root_node;
6570       node_0->style.direction = CSS_DIRECTION_RTL;
6571       node_0->style.flex_direction = CSS_FLEX_DIRECTION_ROW;
6572       node_0->style.dimensions[CSS_WIDTH] = 300;
6573       node_0->style.dimensions[CSS_HEIGHT] = 200;
6574       init_css_node_children(node_0, 3);
6575       {
6576         css_node_t *node_1;
6577         node_1 = node_0->get_child(node_0->context, 0);
6578         node_1->style.flex = 1;
6579         node_1->style.minDimensions[CSS_WIDTH] = 120;
6580         node_1 = node_0->get_child(node_0->context, 1);
6581         node_1->style.flex = 1;
6582         node_1->style.minDimensions[CSS_WIDTH] = 120;
6583         node_1 = node_0->get_child(node_0->context, 2);
6584         node_1->style.flex = 1;
6585         node_1->style.minDimensions[CSS_WIDTH] = 120;
6586       }
6587     }
6588
6589     css_node_t *root_layout = new_test_css_node();
6590     {
6591       css_node_t *node_0 = root_layout;
6592       node_0->layout.position[CSS_TOP] = 0;
6593       node_0->layout.position[CSS_LEFT] = 0;
6594       node_0->layout.dimensions[CSS_WIDTH] = 300;
6595       node_0->layout.dimensions[CSS_HEIGHT] = 200;
6596       init_css_node_children(node_0, 3);
6597       {
6598         css_node_t *node_1;
6599         node_1 = node_0->get_child(node_0->context, 0);
6600         node_1->layout.position[CSS_TOP] = 0;
6601         node_1->layout.position[CSS_LEFT] = 180;
6602         node_1->layout.dimensions[CSS_WIDTH] = 120;
6603         node_1->layout.dimensions[CSS_HEIGHT] = 200;
6604         node_1 = node_0->get_child(node_0->context, 1);
6605         node_1->layout.position[CSS_TOP] = 0;
6606         node_1->layout.position[CSS_LEFT] = 60;
6607         node_1->layout.dimensions[CSS_WIDTH] = 120;
6608         node_1->layout.dimensions[CSS_HEIGHT] = 200;
6609         node_1 = node_0->get_child(node_0->context, 2);
6610         node_1->layout.position[CSS_TOP] = 0;
6611         node_1->layout.position[CSS_LEFT] = -60;
6612         node_1->layout.dimensions[CSS_WIDTH] = 120;
6613         node_1->layout.dimensions[CSS_HEIGHT] = 200;
6614       }
6615     }
6616
6617     test("should ignore flex size if fully min bound in rtl", root_node, root_layout);
6618   }
6619
6620   {
6621     css_node_t *root_node = new_test_css_node();
6622     {
6623       css_node_t *node_0 = root_node;
6624       node_0->style.dimensions[CSS_WIDTH] = 300;
6625       node_0->style.dimensions[CSS_HEIGHT] = 200;
6626       init_css_node_children(node_0, 1);
6627       {
6628         css_node_t *node_1;
6629         node_1 = node_0->get_child(node_0->context, 0);
6630         node_1->style.flex = 1;
6631         node_1->style.maxDimensions[CSS_WIDTH] = 310;
6632         node_1->style.minDimensions[CSS_WIDTH] = 290;
6633       }
6634     }
6635
6636     css_node_t *root_layout = new_test_css_node();
6637     {
6638       css_node_t *node_0 = root_layout;
6639       node_0->layout.position[CSS_TOP] = 0;
6640       node_0->layout.position[CSS_LEFT] = 0;
6641       node_0->layout.dimensions[CSS_WIDTH] = 300;
6642       node_0->layout.dimensions[CSS_HEIGHT] = 200;
6643       init_css_node_children(node_0, 1);
6644       {
6645         css_node_t *node_1;
6646         node_1 = node_0->get_child(node_0->context, 0);
6647         node_1->layout.position[CSS_TOP] = 0;
6648         node_1->layout.position[CSS_LEFT] = 0;
6649         node_1->layout.dimensions[CSS_WIDTH] = 300;
6650         node_1->layout.dimensions[CSS_HEIGHT] = 200;
6651       }
6652     }
6653
6654     test("should pre-fill child size within bounds", root_node, root_layout);
6655   }
6656
6657   {
6658     css_node_t *root_node = new_test_css_node();
6659     {
6660       css_node_t *node_0 = root_node;
6661       node_0->style.dimensions[CSS_WIDTH] = 300;
6662       node_0->style.dimensions[CSS_HEIGHT] = 200;
6663       init_css_node_children(node_0, 1);
6664       {
6665         css_node_t *node_1;
6666         node_1 = node_0->get_child(node_0->context, 0);
6667         node_1->style.flex = 1;
6668         node_1->style.maxDimensions[CSS_WIDTH] = 290;
6669       }
6670     }
6671
6672     css_node_t *root_layout = new_test_css_node();
6673     {
6674       css_node_t *node_0 = root_layout;
6675       node_0->layout.position[CSS_TOP] = 0;
6676       node_0->layout.position[CSS_LEFT] = 0;
6677       node_0->layout.dimensions[CSS_WIDTH] = 300;
6678       node_0->layout.dimensions[CSS_HEIGHT] = 200;
6679       init_css_node_children(node_0, 1);
6680       {
6681         css_node_t *node_1;
6682         node_1 = node_0->get_child(node_0->context, 0);
6683         node_1->layout.position[CSS_TOP] = 0;
6684         node_1->layout.position[CSS_LEFT] = 0;
6685         node_1->layout.dimensions[CSS_WIDTH] = 290;
6686         node_1->layout.dimensions[CSS_HEIGHT] = 200;
6687       }
6688     }
6689
6690     test("should pre-fill child size within max bound", root_node, root_layout);
6691   }
6692
6693   {
6694     css_node_t *root_node = new_test_css_node();
6695     {
6696       css_node_t *node_0 = root_node;
6697       node_0->style.dimensions[CSS_WIDTH] = 300;
6698       node_0->style.dimensions[CSS_HEIGHT] = 200;
6699       init_css_node_children(node_0, 1);
6700       {
6701         css_node_t *node_1;
6702         node_1 = node_0->get_child(node_0->context, 0);
6703         node_1->style.flex = 1;
6704         node_1->style.minDimensions[CSS_WIDTH] = 310;
6705       }
6706     }
6707
6708     css_node_t *root_layout = new_test_css_node();
6709     {
6710       css_node_t *node_0 = root_layout;
6711       node_0->layout.position[CSS_TOP] = 0;
6712       node_0->layout.position[CSS_LEFT] = 0;
6713       node_0->layout.dimensions[CSS_WIDTH] = 300;
6714       node_0->layout.dimensions[CSS_HEIGHT] = 200;
6715       init_css_node_children(node_0, 1);
6716       {
6717         css_node_t *node_1;
6718         node_1 = node_0->get_child(node_0->context, 0);
6719         node_1->layout.position[CSS_TOP] = 0;
6720         node_1->layout.position[CSS_LEFT] = 0;
6721         node_1->layout.dimensions[CSS_WIDTH] = 310;
6722         node_1->layout.dimensions[CSS_HEIGHT] = 200;
6723       }
6724     }
6725
6726     test("should pre-fill child size within min bounds", root_node, root_layout);
6727   }
6728
6729   {
6730     css_node_t *root_node = new_test_css_node();
6731     {
6732       css_node_t *node_0 = root_node;
6733       node_0->style.maxDimensions[CSS_WIDTH] = 300;
6734       node_0->style.maxDimensions[CSS_HEIGHT] = 700;
6735       node_0->style.minDimensions[CSS_WIDTH] = 100;
6736       node_0->style.minDimensions[CSS_HEIGHT] = 500;
6737       init_css_node_children(node_0, 2);
6738       {
6739         css_node_t *node_1;
6740         node_1 = node_0->get_child(node_0->context, 0);
6741         node_1->style.dimensions[CSS_WIDTH] = 200;
6742         node_1->style.dimensions[CSS_HEIGHT] = 300;
6743         node_1 = node_0->get_child(node_0->context, 1);
6744         node_1->style.dimensions[CSS_WIDTH] = 200;
6745         node_1->style.dimensions[CSS_HEIGHT] = 300;
6746       }
6747     }
6748
6749     css_node_t *root_layout = new_test_css_node();
6750     {
6751       css_node_t *node_0 = root_layout;
6752       node_0->layout.position[CSS_TOP] = 0;
6753       node_0->layout.position[CSS_LEFT] = 0;
6754       node_0->layout.dimensions[CSS_WIDTH] = 200;
6755       node_0->layout.dimensions[CSS_HEIGHT] = 600;
6756       init_css_node_children(node_0, 2);
6757       {
6758         css_node_t *node_1;
6759         node_1 = node_0->get_child(node_0->context, 0);
6760         node_1->layout.position[CSS_TOP] = 0;
6761         node_1->layout.position[CSS_LEFT] = 0;
6762         node_1->layout.dimensions[CSS_WIDTH] = 200;
6763         node_1->layout.dimensions[CSS_HEIGHT] = 300;
6764         node_1 = node_0->get_child(node_0->context, 1);
6765         node_1->layout.position[CSS_TOP] = 300;
6766         node_1->layout.position[CSS_LEFT] = 0;
6767         node_1->layout.dimensions[CSS_WIDTH] = 200;
6768         node_1->layout.dimensions[CSS_HEIGHT] = 300;
6769       }
6770     }
6771
6772     test("should set parents size based on bounded children", root_node, root_layout);
6773   }
6774
6775   {
6776     css_node_t *root_node = new_test_css_node();
6777     {
6778       css_node_t *node_0 = root_node;
6779       node_0->style.maxDimensions[CSS_WIDTH] = 100;
6780       node_0->style.maxDimensions[CSS_HEIGHT] = 500;
6781       init_css_node_children(node_0, 2);
6782       {
6783         css_node_t *node_1;
6784         node_1 = node_0->get_child(node_0->context, 0);
6785         node_1->style.dimensions[CSS_WIDTH] = 200;
6786         node_1->style.dimensions[CSS_HEIGHT] = 300;
6787         node_1 = node_0->get_child(node_0->context, 1);
6788         node_1->style.dimensions[CSS_WIDTH] = 200;
6789         node_1->style.dimensions[CSS_HEIGHT] = 300;
6790       }
6791     }
6792
6793     css_node_t *root_layout = new_test_css_node();
6794     {
6795       css_node_t *node_0 = root_layout;
6796       node_0->layout.position[CSS_TOP] = 0;
6797       node_0->layout.position[CSS_LEFT] = 0;
6798       node_0->layout.dimensions[CSS_WIDTH] = 100;
6799       node_0->layout.dimensions[CSS_HEIGHT] = 500;
6800       init_css_node_children(node_0, 2);
6801       {
6802         css_node_t *node_1;
6803         node_1 = node_0->get_child(node_0->context, 0);
6804         node_1->layout.position[CSS_TOP] = 0;
6805         node_1->layout.position[CSS_LEFT] = 0;
6806         node_1->layout.dimensions[CSS_WIDTH] = 200;
6807         node_1->layout.dimensions[CSS_HEIGHT] = 300;
6808         node_1 = node_0->get_child(node_0->context, 1);
6809         node_1->layout.position[CSS_TOP] = 300;
6810         node_1->layout.position[CSS_LEFT] = 0;
6811         node_1->layout.dimensions[CSS_WIDTH] = 200;
6812         node_1->layout.dimensions[CSS_HEIGHT] = 300;
6813       }
6814     }
6815
6816     test("should set parents size based on max bounded children", root_node, root_layout);
6817   }
6818
6819   {
6820     css_node_t *root_node = new_test_css_node();
6821     {
6822       css_node_t *node_0 = root_node;
6823       node_0->style.minDimensions[CSS_WIDTH] = 300;
6824       node_0->style.minDimensions[CSS_HEIGHT] = 700;
6825       init_css_node_children(node_0, 2);
6826       {
6827         css_node_t *node_1;
6828         node_1 = node_0->get_child(node_0->context, 0);
6829         node_1->style.dimensions[CSS_WIDTH] = 200;
6830         node_1->style.dimensions[CSS_HEIGHT] = 300;
6831         node_1 = node_0->get_child(node_0->context, 1);
6832         node_1->style.dimensions[CSS_WIDTH] = 200;
6833         node_1->style.dimensions[CSS_HEIGHT] = 300;
6834       }
6835     }
6836
6837     css_node_t *root_layout = new_test_css_node();
6838     {
6839       css_node_t *node_0 = root_layout;
6840       node_0->layout.position[CSS_TOP] = 0;
6841       node_0->layout.position[CSS_LEFT] = 0;
6842       node_0->layout.dimensions[CSS_WIDTH] = 300;
6843       node_0->layout.dimensions[CSS_HEIGHT] = 700;
6844       init_css_node_children(node_0, 2);
6845       {
6846         css_node_t *node_1;
6847         node_1 = node_0->get_child(node_0->context, 0);
6848         node_1->layout.position[CSS_TOP] = 0;
6849         node_1->layout.position[CSS_LEFT] = 0;
6850         node_1->layout.dimensions[CSS_WIDTH] = 200;
6851         node_1->layout.dimensions[CSS_HEIGHT] = 300;
6852         node_1 = node_0->get_child(node_0->context, 1);
6853         node_1->layout.position[CSS_TOP] = 300;
6854         node_1->layout.position[CSS_LEFT] = 0;
6855         node_1->layout.dimensions[CSS_WIDTH] = 200;
6856         node_1->layout.dimensions[CSS_HEIGHT] = 300;
6857       }
6858     }
6859
6860     test("should set parents size based on min bounded children", root_node, root_layout);
6861   }
6862
6863   {
6864     css_node_t *root_node = new_test_css_node();
6865     {
6866       css_node_t *node_0 = root_node;
6867       node_0->style.align_items = CSS_ALIGN_STRETCH;
6868       node_0->style.dimensions[CSS_WIDTH] = 1000;
6869       init_css_node_children(node_0, 1);
6870       {
6871         css_node_t *node_1;
6872         node_1 = node_0->get_child(node_0->context, 0);
6873         node_1->style.dimensions[CSS_HEIGHT] = 100;
6874         node_1->style.maxDimensions[CSS_WIDTH] = 1100;
6875         node_1->style.maxDimensions[CSS_HEIGHT] = 110;
6876         node_1->style.minDimensions[CSS_WIDTH] = 900;
6877         node_1->style.minDimensions[CSS_HEIGHT] = 90;
6878       }
6879     }
6880
6881     css_node_t *root_layout = new_test_css_node();
6882     {
6883       css_node_t *node_0 = root_layout;
6884       node_0->layout.position[CSS_TOP] = 0;
6885       node_0->layout.position[CSS_LEFT] = 0;
6886       node_0->layout.dimensions[CSS_WIDTH] = 1000;
6887       node_0->layout.dimensions[CSS_HEIGHT] = 100;
6888       init_css_node_children(node_0, 1);
6889       {
6890         css_node_t *node_1;
6891         node_1 = node_0->get_child(node_0->context, 0);
6892         node_1->layout.position[CSS_TOP] = 0;
6893         node_1->layout.position[CSS_LEFT] = 0;
6894         node_1->layout.dimensions[CSS_WIDTH] = 1000;
6895         node_1->layout.dimensions[CSS_HEIGHT] = 100;
6896       }
6897     }
6898
6899     test("should keep stretched size within bounds", root_node, root_layout);
6900   }
6901
6902   {
6903     css_node_t *root_node = new_test_css_node();
6904     {
6905       css_node_t *node_0 = root_node;
6906       node_0->style.align_items = CSS_ALIGN_STRETCH;
6907       node_0->style.dimensions[CSS_WIDTH] = 1000;
6908       init_css_node_children(node_0, 1);
6909       {
6910         css_node_t *node_1;
6911         node_1 = node_0->get_child(node_0->context, 0);
6912         node_1->style.dimensions[CSS_HEIGHT] = 100;
6913         node_1->style.maxDimensions[CSS_WIDTH] = 900;
6914         node_1->style.maxDimensions[CSS_HEIGHT] = 90;
6915       }
6916     }
6917
6918     css_node_t *root_layout = new_test_css_node();
6919     {
6920       css_node_t *node_0 = root_layout;
6921       node_0->layout.position[CSS_TOP] = 0;
6922       node_0->layout.position[CSS_LEFT] = 0;
6923       node_0->layout.dimensions[CSS_WIDTH] = 1000;
6924       node_0->layout.dimensions[CSS_HEIGHT] = 90;
6925       init_css_node_children(node_0, 1);
6926       {
6927         css_node_t *node_1;
6928         node_1 = node_0->get_child(node_0->context, 0);
6929         node_1->layout.position[CSS_TOP] = 0;
6930         node_1->layout.position[CSS_LEFT] = 0;
6931         node_1->layout.dimensions[CSS_WIDTH] = 900;
6932         node_1->layout.dimensions[CSS_HEIGHT] = 90;
6933       }
6934     }
6935
6936     test("should keep stretched size within max bounds", root_node, root_layout);
6937   }
6938
6939   {
6940     css_node_t *root_node = new_test_css_node();
6941     {
6942       css_node_t *node_0 = root_node;
6943       node_0->style.align_items = CSS_ALIGN_STRETCH;
6944       node_0->style.dimensions[CSS_WIDTH] = 1000;
6945       init_css_node_children(node_0, 1);
6946       {
6947         css_node_t *node_1;
6948         node_1 = node_0->get_child(node_0->context, 0);
6949         node_1->style.dimensions[CSS_HEIGHT] = 100;
6950         node_1->style.minDimensions[CSS_WIDTH] = 1100;
6951         node_1->style.minDimensions[CSS_HEIGHT] = 110;
6952       }
6953     }
6954
6955     css_node_t *root_layout = new_test_css_node();
6956     {
6957       css_node_t *node_0 = root_layout;
6958       node_0->layout.position[CSS_TOP] = 0;
6959       node_0->layout.position[CSS_LEFT] = 0;
6960       node_0->layout.dimensions[CSS_WIDTH] = 1000;
6961       node_0->layout.dimensions[CSS_HEIGHT] = 110;
6962       init_css_node_children(node_0, 1);
6963       {
6964         css_node_t *node_1;
6965         node_1 = node_0->get_child(node_0->context, 0);
6966         node_1->layout.position[CSS_TOP] = 0;
6967         node_1->layout.position[CSS_LEFT] = 0;
6968         node_1->layout.dimensions[CSS_WIDTH] = 1100;
6969         node_1->layout.dimensions[CSS_HEIGHT] = 110;
6970       }
6971     }
6972
6973     test("should keep stretched size within min bounds", root_node, root_layout);
6974   }
6975
6976   {
6977     css_node_t *root_node = new_test_css_node();
6978     {
6979       css_node_t *node_0 = root_node;
6980       node_0->style.flex_direction = CSS_FLEX_DIRECTION_ROW;
6981       node_0->style.dimensions[CSS_WIDTH] = 1000;
6982       init_css_node_children(node_0, 1);
6983       {
6984         css_node_t *node_1;
6985         node_1 = node_0->get_child(node_0->context, 0);
6986         node_1->style.dimensions[CSS_HEIGHT] = 100;
6987         node_1->style.minDimensions[CSS_WIDTH] = 100;
6988         node_1->style.minDimensions[CSS_HEIGHT] = 110;
6989       }
6990     }
6991
6992     css_node_t *root_layout = new_test_css_node();
6993     {
6994       css_node_t *node_0 = root_layout;
6995       node_0->layout.position[CSS_TOP] = 0;
6996       node_0->layout.position[CSS_LEFT] = 0;
6997       node_0->layout.dimensions[CSS_WIDTH] = 1000;
6998       node_0->layout.dimensions[CSS_HEIGHT] = 110;
6999       init_css_node_children(node_0, 1);
7000       {
7001         css_node_t *node_1;
7002         node_1 = node_0->get_child(node_0->context, 0);
7003         node_1->layout.position[CSS_TOP] = 0;
7004         node_1->layout.position[CSS_LEFT] = 0;
7005         node_1->layout.dimensions[CSS_WIDTH] = 100;
7006         node_1->layout.dimensions[CSS_HEIGHT] = 110;
7007       }
7008     }
7009
7010     test("should keep cross axis size within min bounds", root_node, root_layout);
7011   }
7012
7013   {
7014     css_node_t *root_node = new_test_css_node();
7015     {
7016       css_node_t *node_0 = root_node;
7017       node_0->style.direction = CSS_DIRECTION_RTL;
7018       node_0->style.flex_direction = CSS_FLEX_DIRECTION_ROW;
7019       node_0->style.dimensions[CSS_WIDTH] = 1000;
7020       init_css_node_children(node_0, 1);
7021       {
7022         css_node_t *node_1;
7023         node_1 = node_0->get_child(node_0->context, 0);
7024         node_1->style.dimensions[CSS_HEIGHT] = 100;
7025         node_1->style.minDimensions[CSS_WIDTH] = 100;
7026         node_1->style.minDimensions[CSS_HEIGHT] = 110;
7027       }
7028     }
7029
7030     css_node_t *root_layout = new_test_css_node();
7031     {
7032       css_node_t *node_0 = root_layout;
7033       node_0->layout.position[CSS_TOP] = 0;
7034       node_0->layout.position[CSS_LEFT] = 0;
7035       node_0->layout.dimensions[CSS_WIDTH] = 1000;
7036       node_0->layout.dimensions[CSS_HEIGHT] = 110;
7037       init_css_node_children(node_0, 1);
7038       {
7039         css_node_t *node_1;
7040         node_1 = node_0->get_child(node_0->context, 0);
7041         node_1->layout.position[CSS_TOP] = 0;
7042         node_1->layout.position[CSS_LEFT] = 900;
7043         node_1->layout.dimensions[CSS_WIDTH] = 100;
7044         node_1->layout.dimensions[CSS_HEIGHT] = 110;
7045       }
7046     }
7047
7048     test("should keep cross axis size within min bounds in rtl", root_node, root_layout);
7049   }
7050
7051   {
7052     css_node_t *root_node = new_test_css_node();
7053     {
7054       css_node_t *node_0 = root_node;
7055       node_0->style.dimensions[CSS_WIDTH] = 1000;
7056       node_0->style.dimensions[CSS_HEIGHT] = 1000;
7057       init_css_node_children(node_0, 1);
7058       {
7059         css_node_t *node_1;
7060         node_1 = node_0->get_child(node_0->context, 0);
7061         node_1->style.position_type = CSS_POSITION_ABSOLUTE;
7062         node_1->style.maxDimensions[CSS_WIDTH] = 500;
7063         node_1->style.maxDimensions[CSS_HEIGHT] = 600;
7064         node_1->style.position[CSS_LEFT] = 100;
7065         node_1->style.position[CSS_TOP] = 100;
7066         node_1->style.position[CSS_RIGHT] = 100;
7067         node_1->style.position[CSS_BOTTOM] = 100;
7068       }
7069     }
7070
7071     css_node_t *root_layout = new_test_css_node();
7072     {
7073       css_node_t *node_0 = root_layout;
7074       node_0->layout.position[CSS_TOP] = 0;
7075       node_0->layout.position[CSS_LEFT] = 0;
7076       node_0->layout.dimensions[CSS_WIDTH] = 1000;
7077       node_0->layout.dimensions[CSS_HEIGHT] = 1000;
7078       init_css_node_children(node_0, 1);
7079       {
7080         css_node_t *node_1;
7081         node_1 = node_0->get_child(node_0->context, 0);
7082         node_1->layout.position[CSS_TOP] = 100;
7083         node_1->layout.position[CSS_LEFT] = 100;
7084         node_1->layout.dimensions[CSS_WIDTH] = 500;
7085         node_1->layout.dimensions[CSS_HEIGHT] = 600;
7086       }
7087     }
7088
7089     test("should layout node with position absolute, top and left and max bounds", root_node, root_layout);
7090   }
7091
7092   {
7093     css_node_t *root_node = new_test_css_node();
7094     {
7095       css_node_t *node_0 = root_node;
7096       node_0->style.dimensions[CSS_WIDTH] = 1000;
7097       node_0->style.dimensions[CSS_HEIGHT] = 1000;
7098       init_css_node_children(node_0, 1);
7099       {
7100         css_node_t *node_1;
7101         node_1 = node_0->get_child(node_0->context, 0);
7102         node_1->style.position_type = CSS_POSITION_ABSOLUTE;
7103         node_1->style.minDimensions[CSS_WIDTH] = 900;
7104         node_1->style.minDimensions[CSS_HEIGHT] = 1000;
7105         node_1->style.position[CSS_LEFT] = 100;
7106         node_1->style.position[CSS_TOP] = 100;
7107         node_1->style.position[CSS_RIGHT] = 100;
7108         node_1->style.position[CSS_BOTTOM] = 100;
7109       }
7110     }
7111
7112     css_node_t *root_layout = new_test_css_node();
7113     {
7114       css_node_t *node_0 = root_layout;
7115       node_0->layout.position[CSS_TOP] = 0;
7116       node_0->layout.position[CSS_LEFT] = 0;
7117       node_0->layout.dimensions[CSS_WIDTH] = 1000;
7118       node_0->layout.dimensions[CSS_HEIGHT] = 1000;
7119       init_css_node_children(node_0, 1);
7120       {
7121         css_node_t *node_1;
7122         node_1 = node_0->get_child(node_0->context, 0);
7123         node_1->layout.position[CSS_TOP] = 100;
7124         node_1->layout.position[CSS_LEFT] = 100;
7125         node_1->layout.dimensions[CSS_WIDTH] = 900;
7126         node_1->layout.dimensions[CSS_HEIGHT] = 1000;
7127       }
7128     }
7129
7130     test("should layout node with position absolute, top and left and min bounds", root_node, root_layout);
7131   }
7132
7133   {
7134     css_node_t *root_node = new_test_css_node();
7135     {
7136       css_node_t *node_0 = root_node;
7137       node_0->style.dimensions[CSS_WIDTH] = 400;
7138       node_0->style.dimensions[CSS_HEIGHT] = 400;
7139       init_css_node_children(node_0, 1);
7140       {
7141         css_node_t *node_1;
7142         node_1 = node_0->get_child(node_0->context, 0);
7143         node_1->style.position_type = CSS_POSITION_ABSOLUTE;
7144         node_1->style.padding[CSS_LEFT] = 10;
7145         node_1->style.padding[CSS_TOP] = 10;
7146         node_1->style.padding[CSS_RIGHT] = 10;
7147         node_1->style.padding[CSS_BOTTOM] = 10;
7148         node_1->style.padding[CSS_START] = 10;
7149         node_1->style.padding[CSS_END] = 10;
7150         node_1->style.position[CSS_LEFT] = 100;
7151         node_1->style.position[CSS_TOP] = 100;
7152         node_1->style.position[CSS_RIGHT] = 100;
7153         node_1->style.position[CSS_BOTTOM] = 100;
7154         init_css_node_children(node_1, 1);
7155         {
7156           css_node_t *node_2;
7157           node_2 = node_1->get_child(node_1->context, 0);
7158           node_2->style.position_type = CSS_POSITION_ABSOLUTE;
7159           node_2->style.position[CSS_LEFT] = 10;
7160           node_2->style.position[CSS_TOP] = 10;
7161           node_2->style.position[CSS_RIGHT] = 10;
7162           node_2->style.position[CSS_BOTTOM] = 10;
7163         }
7164       }
7165     }
7166
7167     css_node_t *root_layout = new_test_css_node();
7168     {
7169       css_node_t *node_0 = root_layout;
7170       node_0->layout.position[CSS_TOP] = 0;
7171       node_0->layout.position[CSS_LEFT] = 0;
7172       node_0->layout.dimensions[CSS_WIDTH] = 400;
7173       node_0->layout.dimensions[CSS_HEIGHT] = 400;
7174       init_css_node_children(node_0, 1);
7175       {
7176         css_node_t *node_1;
7177         node_1 = node_0->get_child(node_0->context, 0);
7178         node_1->layout.position[CSS_TOP] = 100;
7179         node_1->layout.position[CSS_LEFT] = 100;
7180         node_1->layout.dimensions[CSS_WIDTH] = 200;
7181         node_1->layout.dimensions[CSS_HEIGHT] = 200;
7182         init_css_node_children(node_1, 1);
7183         {
7184           css_node_t *node_2;
7185           node_2 = node_1->get_child(node_1->context, 0);
7186           node_2->layout.position[CSS_TOP] = 10;
7187           node_2->layout.position[CSS_LEFT] = 10;
7188           node_2->layout.dimensions[CSS_WIDTH] = 180;
7189           node_2->layout.dimensions[CSS_HEIGHT] = 180;
7190         }
7191       }
7192     }
7193
7194     test("should layout absolutely positioned node with absolutely positioned padded parent", root_node, root_layout);
7195   }
7196
7197   {
7198     css_node_t *root_node = new_test_css_node();
7199     {
7200       css_node_t *node_0 = root_node;
7201       node_0->style.dimensions[CSS_WIDTH] = 400;
7202       node_0->style.dimensions[CSS_HEIGHT] = 400;
7203       init_css_node_children(node_0, 1);
7204       {
7205         css_node_t *node_1;
7206         node_1 = node_0->get_child(node_0->context, 0);
7207         node_1->style.position_type = CSS_POSITION_ABSOLUTE;
7208         node_1->style.padding[CSS_LEFT] = 10;
7209         node_1->style.padding[CSS_TOP] = 10;
7210         node_1->style.padding[CSS_RIGHT] = 10;
7211         node_1->style.padding[CSS_BOTTOM] = 10;
7212         node_1->style.padding[CSS_START] = 10;
7213         node_1->style.padding[CSS_END] = 10;
7214         node_1->style.border[CSS_LEFT] = 1;
7215         node_1->style.border[CSS_TOP] = 1;
7216         node_1->style.border[CSS_RIGHT] = 1;
7217         node_1->style.border[CSS_BOTTOM] = 1;
7218         node_1->style.border[CSS_START] = 1;
7219         node_1->style.border[CSS_END] = 1;
7220         node_1->style.position[CSS_LEFT] = 100;
7221         node_1->style.position[CSS_TOP] = 100;
7222         node_1->style.position[CSS_RIGHT] = 100;
7223         node_1->style.position[CSS_BOTTOM] = 100;
7224         init_css_node_children(node_1, 1);
7225         {
7226           css_node_t *node_2;
7227           node_2 = node_1->get_child(node_1->context, 0);
7228           node_2->style.position_type = CSS_POSITION_ABSOLUTE;
7229           node_2->style.position[CSS_LEFT] = 10;
7230           node_2->style.position[CSS_TOP] = 10;
7231           node_2->style.position[CSS_RIGHT] = 10;
7232           node_2->style.position[CSS_BOTTOM] = 10;
7233         }
7234       }
7235     }
7236
7237     css_node_t *root_layout = new_test_css_node();
7238     {
7239       css_node_t *node_0 = root_layout;
7240       node_0->layout.position[CSS_TOP] = 0;
7241       node_0->layout.position[CSS_LEFT] = 0;
7242       node_0->layout.dimensions[CSS_WIDTH] = 400;
7243       node_0->layout.dimensions[CSS_HEIGHT] = 400;
7244       init_css_node_children(node_0, 1);
7245       {
7246         css_node_t *node_1;
7247         node_1 = node_0->get_child(node_0->context, 0);
7248         node_1->layout.position[CSS_TOP] = 100;
7249         node_1->layout.position[CSS_LEFT] = 100;
7250         node_1->layout.dimensions[CSS_WIDTH] = 200;
7251         node_1->layout.dimensions[CSS_HEIGHT] = 200;
7252         init_css_node_children(node_1, 1);
7253         {
7254           css_node_t *node_2;
7255           node_2 = node_1->get_child(node_1->context, 0);
7256           node_2->layout.position[CSS_TOP] = 11;
7257           node_2->layout.position[CSS_LEFT] = 11;
7258           node_2->layout.dimensions[CSS_WIDTH] = 178;
7259           node_2->layout.dimensions[CSS_HEIGHT] = 178;
7260         }
7261       }
7262     }
7263
7264     test("should layout absolutely positioned node with absolutely positioned padded and bordered parent", root_node, root_layout);
7265   }
7266
7267   {
7268     css_node_t *root_node = new_test_css_node();
7269     {
7270       css_node_t *node_0 = root_node;
7271       node_0->style.dimensions[CSS_WIDTH] = 400;
7272       node_0->style.dimensions[CSS_HEIGHT] = 400;
7273       init_css_node_children(node_0, 1);
7274       {
7275         css_node_t *node_1;
7276         node_1 = node_0->get_child(node_0->context, 0);
7277         node_1->style.flex = 1;
7278         node_1->style.padding[CSS_LEFT] = 10;
7279         node_1->style.padding[CSS_TOP] = 10;
7280         node_1->style.padding[CSS_RIGHT] = 10;
7281         node_1->style.padding[CSS_BOTTOM] = 10;
7282         node_1->style.padding[CSS_START] = 10;
7283         node_1->style.padding[CSS_END] = 10;
7284         init_css_node_children(node_1, 1);
7285         {
7286           css_node_t *node_2;
7287           node_2 = node_1->get_child(node_1->context, 0);
7288           node_2->style.position_type = CSS_POSITION_ABSOLUTE;
7289           node_2->style.position[CSS_LEFT] = 10;
7290           node_2->style.position[CSS_TOP] = 10;
7291           node_2->style.position[CSS_RIGHT] = 10;
7292           node_2->style.position[CSS_BOTTOM] = 10;
7293         }
7294       }
7295     }
7296
7297     css_node_t *root_layout = new_test_css_node();
7298     {
7299       css_node_t *node_0 = root_layout;
7300       node_0->layout.position[CSS_TOP] = 0;
7301       node_0->layout.position[CSS_LEFT] = 0;
7302       node_0->layout.dimensions[CSS_WIDTH] = 400;
7303       node_0->layout.dimensions[CSS_HEIGHT] = 400;
7304       init_css_node_children(node_0, 1);
7305       {
7306         css_node_t *node_1;
7307         node_1 = node_0->get_child(node_0->context, 0);
7308         node_1->layout.position[CSS_TOP] = 0;
7309         node_1->layout.position[CSS_LEFT] = 0;
7310         node_1->layout.dimensions[CSS_WIDTH] = 400;
7311         node_1->layout.dimensions[CSS_HEIGHT] = 400;
7312         init_css_node_children(node_1, 1);
7313         {
7314           css_node_t *node_2;
7315           node_2 = node_1->get_child(node_1->context, 0);
7316           node_2->layout.position[CSS_TOP] = 10;
7317           node_2->layout.position[CSS_LEFT] = 10;
7318           node_2->layout.dimensions[CSS_WIDTH] = 380;
7319           node_2->layout.dimensions[CSS_HEIGHT] = 380;
7320         }
7321       }
7322     }
7323
7324     test("should layout absolutely positioned node with padded flex 1 parent", root_node, root_layout);
7325   }
7326
7327   {
7328     css_node_t *root_node = new_test_css_node();
7329     {
7330       css_node_t *node_0 = root_node;
7331       node_0->style.direction = CSS_DIRECTION_RTL;
7332       node_0->style.dimensions[CSS_WIDTH] = 200;
7333       node_0->style.dimensions[CSS_HEIGHT] = 200;
7334       init_css_node_children(node_0, 2);
7335       {
7336         css_node_t *node_1;
7337         node_1 = node_0->get_child(node_0->context, 0);
7338         node_1->style.flex_direction = CSS_FLEX_DIRECTION_ROW;
7339         init_css_node_children(node_1, 2);
7340         {
7341           css_node_t *node_2;
7342           node_2 = node_1->get_child(node_1->context, 0);
7343           node_2->style.dimensions[CSS_WIDTH] = 50;
7344           node_2->style.dimensions[CSS_HEIGHT] = 50;
7345           node_2 = node_1->get_child(node_1->context, 1);
7346           node_2->style.dimensions[CSS_WIDTH] = 50;
7347           node_2->style.dimensions[CSS_HEIGHT] = 50;
7348         }
7349         node_1 = node_0->get_child(node_0->context, 1);
7350         node_1->style.direction = CSS_DIRECTION_LTR;
7351         node_1->style.flex_direction = CSS_FLEX_DIRECTION_ROW;
7352         init_css_node_children(node_1, 2);
7353         {
7354           css_node_t *node_2;
7355           node_2 = node_1->get_child(node_1->context, 0);
7356           node_2->style.dimensions[CSS_WIDTH] = 50;
7357           node_2->style.dimensions[CSS_HEIGHT] = 50;
7358           node_2 = node_1->get_child(node_1->context, 1);
7359           node_2->style.dimensions[CSS_WIDTH] = 50;
7360           node_2->style.dimensions[CSS_HEIGHT] = 50;
7361         }
7362       }
7363     }
7364
7365     css_node_t *root_layout = new_test_css_node();
7366     {
7367       css_node_t *node_0 = root_layout;
7368       node_0->layout.position[CSS_TOP] = 0;
7369       node_0->layout.position[CSS_LEFT] = 0;
7370       node_0->layout.dimensions[CSS_WIDTH] = 200;
7371       node_0->layout.dimensions[CSS_HEIGHT] = 200;
7372       init_css_node_children(node_0, 2);
7373       {
7374         css_node_t *node_1;
7375         node_1 = node_0->get_child(node_0->context, 0);
7376         node_1->layout.position[CSS_TOP] = 0;
7377         node_1->layout.position[CSS_LEFT] = 0;
7378         node_1->layout.dimensions[CSS_WIDTH] = 200;
7379         node_1->layout.dimensions[CSS_HEIGHT] = 50;
7380         init_css_node_children(node_1, 2);
7381         {
7382           css_node_t *node_2;
7383           node_2 = node_1->get_child(node_1->context, 0);
7384           node_2->layout.position[CSS_TOP] = 0;
7385           node_2->layout.position[CSS_LEFT] = 150;
7386           node_2->layout.dimensions[CSS_WIDTH] = 50;
7387           node_2->layout.dimensions[CSS_HEIGHT] = 50;
7388           node_2 = node_1->get_child(node_1->context, 1);
7389           node_2->layout.position[CSS_TOP] = 0;
7390           node_2->layout.position[CSS_LEFT] = 100;
7391           node_2->layout.dimensions[CSS_WIDTH] = 50;
7392           node_2->layout.dimensions[CSS_HEIGHT] = 50;
7393         }
7394         node_1 = node_0->get_child(node_0->context, 1);
7395         node_1->layout.position[CSS_TOP] = 50;
7396         node_1->layout.position[CSS_LEFT] = 0;
7397         node_1->layout.dimensions[CSS_WIDTH] = 200;
7398         node_1->layout.dimensions[CSS_HEIGHT] = 50;
7399         init_css_node_children(node_1, 2);
7400         {
7401           css_node_t *node_2;
7402           node_2 = node_1->get_child(node_1->context, 0);
7403           node_2->layout.position[CSS_TOP] = 0;
7404           node_2->layout.position[CSS_LEFT] = 0;
7405           node_2->layout.dimensions[CSS_WIDTH] = 50;
7406           node_2->layout.dimensions[CSS_HEIGHT] = 50;
7407           node_2 = node_1->get_child(node_1->context, 1);
7408           node_2->layout.position[CSS_TOP] = 0;
7409           node_2->layout.position[CSS_LEFT] = 50;
7410           node_2->layout.dimensions[CSS_WIDTH] = 50;
7411           node_2->layout.dimensions[CSS_HEIGHT] = 50;
7412         }
7413       }
7414     }
7415
7416     test("should layout nested nodes with mixed directions", root_node, root_layout);
7417   }
7418
7419   {
7420     css_node_t *root_node = new_test_css_node();
7421     {
7422       css_node_t *node_0 = root_node;
7423       node_0->style.flex_direction = CSS_FLEX_DIRECTION_ROW;
7424       node_0->style.justify_content = CSS_JUSTIFY_SPACE_BETWEEN;
7425       node_0->style.flex_wrap = CSS_WRAP;
7426       node_0->style.dimensions[CSS_WIDTH] = 320;
7427       node_0->style.dimensions[CSS_HEIGHT] = 200;
7428       init_css_node_children(node_0, 6);
7429       {
7430         css_node_t *node_1;
7431         node_1 = node_0->get_child(node_0->context, 0);
7432         node_1->style.dimensions[CSS_WIDTH] = 100;
7433         node_1->style.dimensions[CSS_HEIGHT] = 100;
7434         node_1 = node_0->get_child(node_0->context, 1);
7435         node_1->style.dimensions[CSS_WIDTH] = 100;
7436         node_1->style.dimensions[CSS_HEIGHT] = 100;
7437         node_1 = node_0->get_child(node_0->context, 2);
7438         node_1->style.dimensions[CSS_WIDTH] = 100;
7439         node_1->style.dimensions[CSS_HEIGHT] = 100;
7440         node_1 = node_0->get_child(node_0->context, 3);
7441         node_1->style.dimensions[CSS_WIDTH] = 100;
7442         node_1->style.dimensions[CSS_HEIGHT] = 100;
7443         node_1 = node_0->get_child(node_0->context, 4);
7444         node_1->style.dimensions[CSS_WIDTH] = 100;
7445         node_1->style.dimensions[CSS_HEIGHT] = 100;
7446         node_1 = node_0->get_child(node_0->context, 5);
7447         node_1->style.dimensions[CSS_WIDTH] = 100;
7448         node_1->style.dimensions[CSS_HEIGHT] = 100;
7449       }
7450     }
7451
7452     css_node_t *root_layout = new_test_css_node();
7453     {
7454       css_node_t *node_0 = root_layout;
7455       node_0->layout.position[CSS_TOP] = 0;
7456       node_0->layout.position[CSS_LEFT] = 0;
7457       node_0->layout.dimensions[CSS_WIDTH] = 320;
7458       node_0->layout.dimensions[CSS_HEIGHT] = 200;
7459       init_css_node_children(node_0, 6);
7460       {
7461         css_node_t *node_1;
7462         node_1 = node_0->get_child(node_0->context, 0);
7463         node_1->layout.position[CSS_TOP] = 0;
7464         node_1->layout.position[CSS_LEFT] = 0;
7465         node_1->layout.dimensions[CSS_WIDTH] = 100;
7466         node_1->layout.dimensions[CSS_HEIGHT] = 100;
7467         node_1 = node_0->get_child(node_0->context, 1);
7468         node_1->layout.position[CSS_TOP] = 0;
7469         node_1->layout.position[CSS_LEFT] = 110;
7470         node_1->layout.dimensions[CSS_WIDTH] = 100;
7471         node_1->layout.dimensions[CSS_HEIGHT] = 100;
7472         node_1 = node_0->get_child(node_0->context, 2);
7473         node_1->layout.position[CSS_TOP] = 0;
7474         node_1->layout.position[CSS_LEFT] = 220;
7475         node_1->layout.dimensions[CSS_WIDTH] = 100;
7476         node_1->layout.dimensions[CSS_HEIGHT] = 100;
7477         node_1 = node_0->get_child(node_0->context, 3);
7478         node_1->layout.position[CSS_TOP] = 100;
7479         node_1->layout.position[CSS_LEFT] = 0;
7480         node_1->layout.dimensions[CSS_WIDTH] = 100;
7481         node_1->layout.dimensions[CSS_HEIGHT] = 100;
7482         node_1 = node_0->get_child(node_0->context, 4);
7483         node_1->layout.position[CSS_TOP] = 100;
7484         node_1->layout.position[CSS_LEFT] = 110;
7485         node_1->layout.dimensions[CSS_WIDTH] = 100;
7486         node_1->layout.dimensions[CSS_HEIGHT] = 100;
7487         node_1 = node_0->get_child(node_0->context, 5);
7488         node_1->layout.position[CSS_TOP] = 100;
7489         node_1->layout.position[CSS_LEFT] = 220;
7490         node_1->layout.dimensions[CSS_WIDTH] = 100;
7491         node_1->layout.dimensions[CSS_HEIGHT] = 100;
7492       }
7493     }
7494
7495     test("should correctly space wrapped nodes", root_node, root_layout);
7496   }
7497
7498   {
7499     css_node_t *root_node = new_test_css_node();
7500     {
7501       css_node_t *node_0 = root_node;
7502       node_0->style.dimensions[CSS_WIDTH] = 200;
7503       node_0->style.padding[CSS_LEFT] = 5;
7504       node_0->style.padding[CSS_RIGHT] = 5;
7505       node_0->style.padding[CSS_START] = 15;
7506       node_0->style.padding[CSS_END] = 15;
7507       init_css_node_children(node_0, 1);
7508       {
7509         css_node_t *node_1;
7510         node_1 = node_0->get_child(node_0->context, 0);
7511         node_1->style.dimensions[CSS_HEIGHT] = 50;
7512       }
7513     }
7514
7515     css_node_t *root_layout = new_test_css_node();
7516     {
7517       css_node_t *node_0 = root_layout;
7518       node_0->layout.position[CSS_TOP] = 0;
7519       node_0->layout.position[CSS_LEFT] = 0;
7520       node_0->layout.dimensions[CSS_WIDTH] = 200;
7521       node_0->layout.dimensions[CSS_HEIGHT] = 50;
7522       init_css_node_children(node_0, 1);
7523       {
7524         css_node_t *node_1;
7525         node_1 = node_0->get_child(node_0->context, 0);
7526         node_1->layout.position[CSS_TOP] = 0;
7527         node_1->layout.position[CSS_LEFT] = 15;
7528         node_1->layout.dimensions[CSS_WIDTH] = 170;
7529         node_1->layout.dimensions[CSS_HEIGHT] = 50;
7530       }
7531     }
7532
7533     test("should give start/end padding precedence over left/right padding", root_node, root_layout);
7534   }
7535
7536   {
7537     css_node_t *root_node = new_test_css_node();
7538     {
7539       css_node_t *node_0 = root_node;
7540       node_0->style.dimensions[CSS_WIDTH] = 200;
7541       init_css_node_children(node_0, 1);
7542       {
7543         css_node_t *node_1;
7544         node_1 = node_0->get_child(node_0->context, 0);
7545         node_1->style.dimensions[CSS_HEIGHT] = 50;
7546         node_1->style.margin[CSS_LEFT] = 5;
7547         node_1->style.margin[CSS_RIGHT] = 5;
7548         node_1->style.margin[CSS_START] = 15;
7549         node_1->style.margin[CSS_END] = 15;
7550       }
7551     }
7552
7553     css_node_t *root_layout = new_test_css_node();
7554     {
7555       css_node_t *node_0 = root_layout;
7556       node_0->layout.position[CSS_TOP] = 0;
7557       node_0->layout.position[CSS_LEFT] = 0;
7558       node_0->layout.dimensions[CSS_WIDTH] = 200;
7559       node_0->layout.dimensions[CSS_HEIGHT] = 50;
7560       init_css_node_children(node_0, 1);
7561       {
7562         css_node_t *node_1;
7563         node_1 = node_0->get_child(node_0->context, 0);
7564         node_1->layout.position[CSS_TOP] = 0;
7565         node_1->layout.position[CSS_LEFT] = 15;
7566         node_1->layout.dimensions[CSS_WIDTH] = 170;
7567         node_1->layout.dimensions[CSS_HEIGHT] = 50;
7568       }
7569     }
7570
7571     test("should give start/end margin precedence over left/right margin", root_node, root_layout);
7572   }
7573
7574   {
7575     css_node_t *root_node = new_test_css_node();
7576     {
7577       css_node_t *node_0 = root_node;
7578       node_0->style.dimensions[CSS_WIDTH] = 200;
7579       node_0->style.border[CSS_LEFT] = 5;
7580       node_0->style.border[CSS_RIGHT] = 5;
7581       node_0->style.border[CSS_START] = 15;
7582       node_0->style.border[CSS_END] = 15;
7583       init_css_node_children(node_0, 1);
7584       {
7585         css_node_t *node_1;
7586         node_1 = node_0->get_child(node_0->context, 0);
7587         node_1->style.dimensions[CSS_HEIGHT] = 50;
7588       }
7589     }
7590
7591     css_node_t *root_layout = new_test_css_node();
7592     {
7593       css_node_t *node_0 = root_layout;
7594       node_0->layout.position[CSS_TOP] = 0;
7595       node_0->layout.position[CSS_LEFT] = 0;
7596       node_0->layout.dimensions[CSS_WIDTH] = 200;
7597       node_0->layout.dimensions[CSS_HEIGHT] = 50;
7598       init_css_node_children(node_0, 1);
7599       {
7600         css_node_t *node_1;
7601         node_1 = node_0->get_child(node_0->context, 0);
7602         node_1->layout.position[CSS_TOP] = 0;
7603         node_1->layout.position[CSS_LEFT] = 15;
7604         node_1->layout.dimensions[CSS_WIDTH] = 170;
7605         node_1->layout.dimensions[CSS_HEIGHT] = 50;
7606       }
7607     }
7608
7609     test("should give start/end border precedence over left/right border", root_node, root_layout);
7610   }
7611
7612   {
7613     css_node_t *root_node = new_test_css_node();
7614     {
7615       css_node_t *node_0 = root_node;
7616       node_0->style.dimensions[CSS_WIDTH] = 200;
7617       node_0->style.padding[CSS_START] = 15;
7618       node_0->style.padding[CSS_END] = 5;
7619       init_css_node_children(node_0, 1);
7620       {
7621         css_node_t *node_1;
7622         node_1 = node_0->get_child(node_0->context, 0);
7623         node_1->style.dimensions[CSS_HEIGHT] = 50;
7624       }
7625     }
7626
7627     css_node_t *root_layout = new_test_css_node();
7628     {
7629       css_node_t *node_0 = root_layout;
7630       node_0->layout.position[CSS_TOP] = 0;
7631       node_0->layout.position[CSS_LEFT] = 0;
7632       node_0->layout.dimensions[CSS_WIDTH] = 200;
7633       node_0->layout.dimensions[CSS_HEIGHT] = 50;
7634       init_css_node_children(node_0, 1);
7635       {
7636         css_node_t *node_1;
7637         node_1 = node_0->get_child(node_0->context, 0);
7638         node_1->layout.position[CSS_TOP] = 0;
7639         node_1->layout.position[CSS_LEFT] = 15;
7640         node_1->layout.dimensions[CSS_WIDTH] = 180;
7641         node_1->layout.dimensions[CSS_HEIGHT] = 50;
7642       }
7643     }
7644
7645     test("should layout node with correct start/end padding", root_node, root_layout);
7646   }
7647
7648   {
7649     css_node_t *root_node = new_test_css_node();
7650     {
7651       css_node_t *node_0 = root_node;
7652       node_0->style.direction = CSS_DIRECTION_RTL;
7653       node_0->style.dimensions[CSS_WIDTH] = 200;
7654       node_0->style.padding[CSS_START] = 15;
7655       node_0->style.padding[CSS_END] = 5;
7656       init_css_node_children(node_0, 1);
7657       {
7658         css_node_t *node_1;
7659         node_1 = node_0->get_child(node_0->context, 0);
7660         node_1->style.dimensions[CSS_HEIGHT] = 50;
7661       }
7662     }
7663
7664     css_node_t *root_layout = new_test_css_node();
7665     {
7666       css_node_t *node_0 = root_layout;
7667       node_0->layout.position[CSS_TOP] = 0;
7668       node_0->layout.position[CSS_LEFT] = 0;
7669       node_0->layout.dimensions[CSS_WIDTH] = 200;
7670       node_0->layout.dimensions[CSS_HEIGHT] = 50;
7671       init_css_node_children(node_0, 1);
7672       {
7673         css_node_t *node_1;
7674         node_1 = node_0->get_child(node_0->context, 0);
7675         node_1->layout.position[CSS_TOP] = 0;
7676         node_1->layout.position[CSS_LEFT] = 5;
7677         node_1->layout.dimensions[CSS_WIDTH] = 180;
7678         node_1->layout.dimensions[CSS_HEIGHT] = 50;
7679       }
7680     }
7681
7682     test("should layout node with correct start/end padding in rtl", root_node, root_layout);
7683   }
7684
7685   {
7686     css_node_t *root_node = new_test_css_node();
7687     {
7688       css_node_t *node_0 = root_node;
7689       node_0->style.dimensions[CSS_WIDTH] = 200;
7690       init_css_node_children(node_0, 1);
7691       {
7692         css_node_t *node_1;
7693         node_1 = node_0->get_child(node_0->context, 0);
7694         node_1->style.dimensions[CSS_HEIGHT] = 50;
7695         node_1->style.margin[CSS_START] = 15;
7696         node_1->style.margin[CSS_END] = 5;
7697       }
7698     }
7699
7700     css_node_t *root_layout = new_test_css_node();
7701     {
7702       css_node_t *node_0 = root_layout;
7703       node_0->layout.position[CSS_TOP] = 0;
7704       node_0->layout.position[CSS_LEFT] = 0;
7705       node_0->layout.dimensions[CSS_WIDTH] = 200;
7706       node_0->layout.dimensions[CSS_HEIGHT] = 50;
7707       init_css_node_children(node_0, 1);
7708       {
7709         css_node_t *node_1;
7710         node_1 = node_0->get_child(node_0->context, 0);
7711         node_1->layout.position[CSS_TOP] = 0;
7712         node_1->layout.position[CSS_LEFT] = 15;
7713         node_1->layout.dimensions[CSS_WIDTH] = 180;
7714         node_1->layout.dimensions[CSS_HEIGHT] = 50;
7715       }
7716     }
7717
7718     test("should layout node with correct start/end margin", root_node, root_layout);
7719   }
7720
7721   {
7722     css_node_t *root_node = new_test_css_node();
7723     {
7724       css_node_t *node_0 = root_node;
7725       node_0->style.dimensions[CSS_WIDTH] = 200;
7726       init_css_node_children(node_0, 1);
7727       {
7728         css_node_t *node_1;
7729         node_1 = node_0->get_child(node_0->context, 0);
7730         node_1->style.direction = CSS_DIRECTION_RTL;
7731         node_1->style.dimensions[CSS_HEIGHT] = 50;
7732         node_1->style.margin[CSS_START] = 15;
7733         node_1->style.margin[CSS_END] = 5;
7734       }
7735     }
7736
7737     css_node_t *root_layout = new_test_css_node();
7738     {
7739       css_node_t *node_0 = root_layout;
7740       node_0->layout.position[CSS_TOP] = 0;
7741       node_0->layout.position[CSS_LEFT] = 0;
7742       node_0->layout.dimensions[CSS_WIDTH] = 200;
7743       node_0->layout.dimensions[CSS_HEIGHT] = 50;
7744       init_css_node_children(node_0, 1);
7745       {
7746         css_node_t *node_1;
7747         node_1 = node_0->get_child(node_0->context, 0);
7748         node_1->layout.position[CSS_TOP] = 0;
7749         node_1->layout.position[CSS_LEFT] = 5;
7750         node_1->layout.dimensions[CSS_WIDTH] = 180;
7751         node_1->layout.dimensions[CSS_HEIGHT] = 50;
7752       }
7753     }
7754
7755     test("should layout node with correct start/end margin in rtl", root_node, root_layout);
7756   }
7757
7758   {
7759     css_node_t *root_node = new_test_css_node();
7760     {
7761       css_node_t *node_0 = root_node;
7762       node_0->style.dimensions[CSS_WIDTH] = 200;
7763       node_0->style.border[CSS_START] = 15;
7764       node_0->style.border[CSS_END] = 5;
7765       init_css_node_children(node_0, 1);
7766       {
7767         css_node_t *node_1;
7768         node_1 = node_0->get_child(node_0->context, 0);
7769         node_1->style.dimensions[CSS_HEIGHT] = 50;
7770       }
7771     }
7772
7773     css_node_t *root_layout = new_test_css_node();
7774     {
7775       css_node_t *node_0 = root_layout;
7776       node_0->layout.position[CSS_TOP] = 0;
7777       node_0->layout.position[CSS_LEFT] = 0;
7778       node_0->layout.dimensions[CSS_WIDTH] = 200;
7779       node_0->layout.dimensions[CSS_HEIGHT] = 50;
7780       init_css_node_children(node_0, 1);
7781       {
7782         css_node_t *node_1;
7783         node_1 = node_0->get_child(node_0->context, 0);
7784         node_1->layout.position[CSS_TOP] = 0;
7785         node_1->layout.position[CSS_LEFT] = 15;
7786         node_1->layout.dimensions[CSS_WIDTH] = 180;
7787         node_1->layout.dimensions[CSS_HEIGHT] = 50;
7788       }
7789     }
7790
7791     test("should layout node with correct start/end border", root_node, root_layout);
7792   }
7793
7794   {
7795     css_node_t *root_node = new_test_css_node();
7796     {
7797       css_node_t *node_0 = root_node;
7798       node_0->style.direction = CSS_DIRECTION_RTL;
7799       node_0->style.dimensions[CSS_WIDTH] = 200;
7800       node_0->style.border[CSS_START] = 15;
7801       node_0->style.border[CSS_END] = 5;
7802       init_css_node_children(node_0, 1);
7803       {
7804         css_node_t *node_1;
7805         node_1 = node_0->get_child(node_0->context, 0);
7806         node_1->style.dimensions[CSS_HEIGHT] = 50;
7807       }
7808     }
7809
7810     css_node_t *root_layout = new_test_css_node();
7811     {
7812       css_node_t *node_0 = root_layout;
7813       node_0->layout.position[CSS_TOP] = 0;
7814       node_0->layout.position[CSS_LEFT] = 0;
7815       node_0->layout.dimensions[CSS_WIDTH] = 200;
7816       node_0->layout.dimensions[CSS_HEIGHT] = 50;
7817       init_css_node_children(node_0, 1);
7818       {
7819         css_node_t *node_1;
7820         node_1 = node_0->get_child(node_0->context, 0);
7821         node_1->layout.position[CSS_TOP] = 0;
7822         node_1->layout.position[CSS_LEFT] = 5;
7823         node_1->layout.dimensions[CSS_WIDTH] = 180;
7824         node_1->layout.dimensions[CSS_HEIGHT] = 50;
7825       }
7826     }
7827
7828     test("should layout node with correct start/end border in rtl", root_node, root_layout);
7829   }
7830
7831   {
7832     css_node_t *root_node = new_test_css_node();
7833     {
7834       css_node_t *node_0 = root_node;
7835       node_0->style.dimensions[CSS_WIDTH] = 200;
7836       init_css_node_children(node_0, 1);
7837       {
7838         css_node_t *node_1;
7839         node_1 = node_0->get_child(node_0->context, 0);
7840         node_1->style.dimensions[CSS_WIDTH] = 0;
7841       }
7842     }
7843
7844     css_node_t *root_layout = new_test_css_node();
7845     {
7846       css_node_t *node_0 = root_layout;
7847       node_0->layout.position[CSS_TOP] = 0;
7848       node_0->layout.position[CSS_LEFT] = 0;
7849       node_0->layout.dimensions[CSS_WIDTH] = 200;
7850       node_0->layout.dimensions[CSS_HEIGHT] = 0;
7851       init_css_node_children(node_0, 1);
7852       {
7853         css_node_t *node_1;
7854         node_1 = node_0->get_child(node_0->context, 0);
7855         node_1->layout.position[CSS_TOP] = 0;
7856         node_1->layout.position[CSS_LEFT] = 0;
7857         node_1->layout.dimensions[CSS_WIDTH] = 0;
7858         node_1->layout.dimensions[CSS_HEIGHT] = 0;
7859       }
7860     }
7861
7862     test("should layout node with a 0 width", root_node, root_layout);
7863   }
7864
7865   {
7866     css_node_t *root_node = new_test_css_node();
7867     {
7868       css_node_t *node_0 = root_node;
7869       node_0->style.flex_direction = CSS_FLEX_DIRECTION_ROW;
7870       node_0->style.align_items = CSS_ALIGN_FLEX_START;
7871       node_0->style.dimensions[CSS_WIDTH] = 100;
7872       node_0->style.dimensions[CSS_HEIGHT] = 10;
7873       init_css_node_children(node_0, 2);
7874       {
7875         css_node_t *node_1;
7876         node_1 = node_0->get_child(node_0->context, 0);
7877         node_1->style.dimensions[CSS_WIDTH] = 50;
7878         node_1->style.dimensions[CSS_HEIGHT] = 10;
7879         node_1 = node_0->get_child(node_0->context, 1);
7880         node_1->style.flex_direction = CSS_FLEX_DIRECTION_COLUMN;
7881         node_1->style.align_items = CSS_ALIGN_FLEX_START;
7882         node_1->style.flex = 1;
7883         node_1->style.dimensions[CSS_HEIGHT] = 10;
7884         init_css_node_children(node_1, 1);
7885         {
7886           css_node_t *node_2;
7887           node_2 = node_1->get_child(node_1->context, 0);
7888           node_2->style.flex = 1;
7889           node_2->style.dimensions[CSS_HEIGHT] = 10;
7890           node_2->measure = measure;
7891           node_2->context = "measureWithMatchParent";
7892         }
7893       }
7894     }
7895
7896     css_node_t *root_layout = new_test_css_node();
7897     {
7898       css_node_t *node_0 = root_layout;
7899       node_0->layout.position[CSS_TOP] = 0;
7900       node_0->layout.position[CSS_LEFT] = 0;
7901       node_0->layout.dimensions[CSS_WIDTH] = 100;
7902       node_0->layout.dimensions[CSS_HEIGHT] = 10;
7903       init_css_node_children(node_0, 2);
7904       {
7905         css_node_t *node_1;
7906         node_1 = node_0->get_child(node_0->context, 0);
7907         node_1->layout.position[CSS_TOP] = 0;
7908         node_1->layout.position[CSS_LEFT] = 0;
7909         node_1->layout.dimensions[CSS_WIDTH] = 50;
7910         node_1->layout.dimensions[CSS_HEIGHT] = 10;
7911         node_1 = node_0->get_child(node_0->context, 1);
7912         node_1->layout.position[CSS_TOP] = 0;
7913         node_1->layout.position[CSS_LEFT] = 50;
7914         node_1->layout.dimensions[CSS_WIDTH] = 50;
7915         node_1->layout.dimensions[CSS_HEIGHT] = 10;
7916         init_css_node_children(node_1, 1);
7917         {
7918           css_node_t *node_2;
7919           node_2 = node_1->get_child(node_1->context, 0);
7920           node_2->layout.position[CSS_TOP] = 0;
7921           node_2->layout.position[CSS_LEFT] = 0;
7922           node_2->layout.dimensions[CSS_WIDTH] = 50;
7923           node_2->layout.dimensions[CSS_HEIGHT] = 10;
7924         }
7925       }
7926     }
7927
7928     test("should correctly progagate size contraints from flexible parents", root_node, root_layout);
7929   }
7930
7931   {
7932     css_node_t *root_node = new_test_css_node();
7933     {
7934       css_node_t *node_0 = root_node;
7935       node_0->style.flex_direction = CSS_FLEX_DIRECTION_ROW;
7936       node_0->style.align_items = CSS_ALIGN_STRETCH;
7937       node_0->style.dimensions[CSS_WIDTH] = 150;
7938       init_css_node_children(node_0, 2);
7939       {
7940         css_node_t *node_1;
7941         node_1 = node_0->get_child(node_0->context, 0);
7942         node_1->style.flex_direction = CSS_FLEX_DIRECTION_ROW;
7943         node_1->style.margin[CSS_LEFT] = 10;
7944         node_1->style.margin[CSS_TOP] = 10;
7945         init_css_node_children(node_1, 1);
7946         {
7947           css_node_t *node_2;
7948           node_2 = node_1->get_child(node_1->context, 0);
7949           node_2->style.flex_direction = CSS_FLEX_DIRECTION_ROW;
7950           init_css_node_children(node_2, 1);
7951           {
7952             css_node_t *node_3;
7953             node_3 = node_2->get_child(node_2->context, 0);
7954             node_3->style.align_self = CSS_ALIGN_CENTER;
7955           }
7956         }
7957         node_1 = node_0->get_child(node_0->context, 1);
7958         node_1->style.dimensions[CSS_HEIGHT] = 150;
7959       }
7960     }
7961
7962     css_node_t *root_layout = new_test_css_node();
7963     {
7964       css_node_t *node_0 = root_layout;
7965       node_0->layout.position[CSS_TOP] = 0;
7966       node_0->layout.position[CSS_LEFT] = 0;
7967       node_0->layout.dimensions[CSS_WIDTH] = 150;
7968       node_0->layout.dimensions[CSS_HEIGHT] = 150;
7969       init_css_node_children(node_0, 2);
7970       {
7971         css_node_t *node_1;
7972         node_1 = node_0->get_child(node_0->context, 0);
7973         node_1->layout.position[CSS_TOP] = 10;
7974         node_1->layout.position[CSS_LEFT] = 10;
7975         node_1->layout.dimensions[CSS_WIDTH] = 0;
7976         node_1->layout.dimensions[CSS_HEIGHT] = 140;
7977         init_css_node_children(node_1, 1);
7978         {
7979           css_node_t *node_2;
7980           node_2 = node_1->get_child(node_1->context, 0);
7981           node_2->layout.position[CSS_TOP] = 0;
7982           node_2->layout.position[CSS_LEFT] = 0;
7983           node_2->layout.dimensions[CSS_WIDTH] = 0;
7984           node_2->layout.dimensions[CSS_HEIGHT] = 140;
7985           init_css_node_children(node_2, 1);
7986           {
7987             css_node_t *node_3;
7988             node_3 = node_2->get_child(node_2->context, 0);
7989             node_3->layout.position[CSS_TOP] = 70;
7990             node_3->layout.position[CSS_LEFT] = 0;
7991             node_3->layout.dimensions[CSS_WIDTH] = 0;
7992             node_3->layout.dimensions[CSS_HEIGHT] = 0;
7993           }
7994         }
7995         node_1 = node_0->get_child(node_0->context, 1);
7996         node_1->layout.position[CSS_TOP] = 0;
7997         node_1->layout.position[CSS_LEFT] = 10;
7998         node_1->layout.dimensions[CSS_WIDTH] = 0;
7999         node_1->layout.dimensions[CSS_HEIGHT] = 150;
8000       }
8001     }
8002
8003     test("should layout content of an item which is stretched late", root_node, root_layout);
8004   }
8005
8006   {
8007     css_node_t *root_node = new_test_css_node();
8008     {
8009       css_node_t *node_0 = root_node;
8010       init_css_node_children(node_0, 2);
8011       {
8012         css_node_t *node_1;
8013         node_1 = node_0->get_child(node_0->context, 0);
8014         init_css_node_children(node_1, 1);
8015         {
8016           css_node_t *node_2;
8017           node_2 = node_1->get_child(node_1->context, 0);
8018           node_2->style.dimensions[CSS_WIDTH] = 200;
8019           node_2->style.dimensions[CSS_HEIGHT] = 200;
8020         }
8021         node_1 = node_0->get_child(node_0->context, 1);
8022         node_1->style.margin[CSS_LEFT] = 10;
8023         node_1->style.margin[CSS_TOP] = 10;
8024         init_css_node_children(node_1, 1);
8025         {
8026           css_node_t *node_2;
8027           node_2 = node_1->get_child(node_1->context, 0);
8028         }
8029       }
8030     }
8031
8032     css_node_t *root_layout = new_test_css_node();
8033     {
8034       css_node_t *node_0 = root_layout;
8035       node_0->layout.position[CSS_TOP] = 0;
8036       node_0->layout.position[CSS_LEFT] = 0;
8037       node_0->layout.dimensions[CSS_WIDTH] = 200;
8038       node_0->layout.dimensions[CSS_HEIGHT] = 210;
8039       init_css_node_children(node_0, 2);
8040       {
8041         css_node_t *node_1;
8042         node_1 = node_0->get_child(node_0->context, 0);
8043         node_1->layout.position[CSS_TOP] = 0;
8044         node_1->layout.position[CSS_LEFT] = 0;
8045         node_1->layout.dimensions[CSS_WIDTH] = 200;
8046         node_1->layout.dimensions[CSS_HEIGHT] = 200;
8047         init_css_node_children(node_1, 1);
8048         {
8049           css_node_t *node_2;
8050           node_2 = node_1->get_child(node_1->context, 0);
8051           node_2->layout.position[CSS_TOP] = 0;
8052           node_2->layout.position[CSS_LEFT] = 0;
8053           node_2->layout.dimensions[CSS_WIDTH] = 200;
8054           node_2->layout.dimensions[CSS_HEIGHT] = 200;
8055         }
8056         node_1 = node_0->get_child(node_0->context, 1);
8057         node_1->layout.position[CSS_TOP] = 210;
8058         node_1->layout.position[CSS_LEFT] = 10;
8059         node_1->layout.dimensions[CSS_WIDTH] = 190;
8060         node_1->layout.dimensions[CSS_HEIGHT] = 0;
8061         init_css_node_children(node_1, 1);
8062         {
8063           css_node_t *node_2;
8064           node_2 = node_1->get_child(node_1->context, 0);
8065           node_2->layout.position[CSS_TOP] = 0;
8066           node_2->layout.position[CSS_LEFT] = 0;
8067           node_2->layout.dimensions[CSS_WIDTH] = 190;
8068           node_2->layout.dimensions[CSS_HEIGHT] = 0;
8069         }
8070       }
8071     }
8072
8073     test("should layout items whose positioning is determined by sibling tree branches", root_node, root_layout);
8074   }
8075
8076   {
8077     css_node_t *root_node = new_test_css_node();
8078     {
8079       css_node_t *node_0 = root_node;
8080       node_0->style.flex_direction = CSS_FLEX_DIRECTION_ROW;
8081       init_css_node_children(node_0, 3);
8082       {
8083         css_node_t *node_1;
8084         node_1 = node_0->get_child(node_0->context, 0);
8085         node_1->style.align_self = CSS_ALIGN_FLEX_START;
8086         node_1->style.margin[CSS_LEFT] = 10;
8087         node_1->style.margin[CSS_TOP] = 10;
8088         node_1 = node_0->get_child(node_0->context, 1);
8089         node_1->style.align_self = CSS_ALIGN_STRETCH;
8090         node_1->style.dimensions[CSS_WIDTH] = 1;
8091         node_1 = node_0->get_child(node_0->context, 2);
8092         node_1->style.dimensions[CSS_HEIGHT] = 150;
8093       }
8094     }
8095
8096     css_node_t *root_layout = new_test_css_node();
8097     {
8098       css_node_t *node_0 = root_layout;
8099       node_0->layout.position[CSS_TOP] = 0;
8100       node_0->layout.position[CSS_LEFT] = 0;
8101       node_0->layout.dimensions[CSS_WIDTH] = 11;
8102       node_0->layout.dimensions[CSS_HEIGHT] = 150;
8103       init_css_node_children(node_0, 3);
8104       {
8105         css_node_t *node_1;
8106         node_1 = node_0->get_child(node_0->context, 0);
8107         node_1->layout.position[CSS_TOP] = 10;
8108         node_1->layout.position[CSS_LEFT] = 10;
8109         node_1->layout.dimensions[CSS_WIDTH] = 0;
8110         node_1->layout.dimensions[CSS_HEIGHT] = 0;
8111         node_1 = node_0->get_child(node_0->context, 1);
8112         node_1->layout.position[CSS_TOP] = 0;
8113         node_1->layout.position[CSS_LEFT] = 10;
8114         node_1->layout.dimensions[CSS_WIDTH] = 1;
8115         node_1->layout.dimensions[CSS_HEIGHT] = 150;
8116         node_1 = node_0->get_child(node_0->context, 2);
8117         node_1->layout.position[CSS_TOP] = 0;
8118         node_1->layout.position[CSS_LEFT] = 11;
8119         node_1->layout.dimensions[CSS_WIDTH] = 0;
8120         node_1->layout.dimensions[CSS_HEIGHT] = 150;
8121       }
8122     }
8123
8124     test("should layout child whose cross axis is undefined and whose alignSelf is stretch", root_node, root_layout);
8125   }
8126
8127   {
8128     css_node_t *root_node = new_test_css_node();
8129     {
8130       css_node_t *node_0 = root_node;
8131       node_0->style.flex_direction = CSS_FLEX_DIRECTION_ROW;
8132       init_css_node_children(node_0, 2);
8133       {
8134         css_node_t *node_1;
8135         node_1 = node_0->get_child(node_0->context, 0);
8136         init_css_node_children(node_1, 1);
8137         {
8138           css_node_t *node_2;
8139           node_2 = node_1->get_child(node_1->context, 0);
8140           node_2->style.dimensions[CSS_WIDTH] = 100;
8141           node_2->style.dimensions[CSS_HEIGHT] = 100;
8142         }
8143         node_1 = node_0->get_child(node_0->context, 1);
8144         node_1->style.dimensions[CSS_WIDTH] = 100;
8145         init_css_node_children(node_1, 1);
8146         {
8147           css_node_t *node_2;
8148           node_2 = node_1->get_child(node_1->context, 0);
8149           node_2->style.flex_direction = CSS_FLEX_DIRECTION_COLUMN;
8150           node_2->style.align_items = CSS_ALIGN_CENTER;
8151           init_css_node_children(node_2, 1);
8152           {
8153             css_node_t *node_3;
8154             node_3 = node_2->get_child(node_2->context, 0);
8155             node_3->style.dimensions[CSS_WIDTH] = 50;
8156             node_3->style.dimensions[CSS_HEIGHT] = 50;
8157           }
8158         }
8159       }
8160     }
8161
8162     css_node_t *root_layout = new_test_css_node();
8163     {
8164       css_node_t *node_0 = root_layout;
8165       node_0->layout.position[CSS_TOP] = 0;
8166       node_0->layout.position[CSS_LEFT] = 0;
8167       node_0->layout.dimensions[CSS_WIDTH] = 200;
8168       node_0->layout.dimensions[CSS_HEIGHT] = 100;
8169       init_css_node_children(node_0, 2);
8170       {
8171         css_node_t *node_1;
8172         node_1 = node_0->get_child(node_0->context, 0);
8173         node_1->layout.position[CSS_TOP] = 0;
8174         node_1->layout.position[CSS_LEFT] = 0;
8175         node_1->layout.dimensions[CSS_WIDTH] = 100;
8176         node_1->layout.dimensions[CSS_HEIGHT] = 100;
8177         init_css_node_children(node_1, 1);
8178         {
8179           css_node_t *node_2;
8180           node_2 = node_1->get_child(node_1->context, 0);
8181           node_2->layout.position[CSS_TOP] = 0;
8182           node_2->layout.position[CSS_LEFT] = 0;
8183           node_2->layout.dimensions[CSS_WIDTH] = 100;
8184           node_2->layout.dimensions[CSS_HEIGHT] = 100;
8185         }
8186         node_1 = node_0->get_child(node_0->context, 1);
8187         node_1->layout.position[CSS_TOP] = 0;
8188         node_1->layout.position[CSS_LEFT] = 100;
8189         node_1->layout.dimensions[CSS_WIDTH] = 100;
8190         node_1->layout.dimensions[CSS_HEIGHT] = 100;
8191         init_css_node_children(node_1, 1);
8192         {
8193           css_node_t *node_2;
8194           node_2 = node_1->get_child(node_1->context, 0);
8195           node_2->layout.position[CSS_TOP] = 0;
8196           node_2->layout.position[CSS_LEFT] = 0;
8197           node_2->layout.dimensions[CSS_WIDTH] = 100;
8198           node_2->layout.dimensions[CSS_HEIGHT] = 50;
8199           init_css_node_children(node_2, 1);
8200           {
8201             css_node_t *node_3;
8202             node_3 = node_2->get_child(node_2->context, 0);
8203             node_3->layout.position[CSS_TOP] = 0;
8204             node_3->layout.position[CSS_LEFT] = 25;
8205             node_3->layout.dimensions[CSS_WIDTH] = 50;
8206             node_3->layout.dimensions[CSS_HEIGHT] = 50;
8207           }
8208         }
8209       }
8210     }
8211
8212     test("should center items correctly inside a stretched layout", root_node, root_layout);
8213   }
8214
8215   {
8216     css_node_t *root_node = new_test_css_node();
8217     {
8218       css_node_t *node_0 = root_node;
8219       node_0->style.flex_direction = CSS_FLEX_DIRECTION_ROW;
8220       node_0->style.align_content = CSS_ALIGN_STRETCH;
8221       node_0->style.align_items = CSS_ALIGN_FLEX_START;
8222       node_0->style.flex_wrap = CSS_WRAP;
8223       node_0->style.dimensions[CSS_WIDTH] = 300;
8224       node_0->style.dimensions[CSS_HEIGHT] = 380;
8225       init_css_node_children(node_0, 15);
8226       {
8227         css_node_t *node_1;
8228         node_1 = node_0->get_child(node_0->context, 0);
8229         node_1->style.dimensions[CSS_WIDTH] = 50;
8230         node_1->style.dimensions[CSS_HEIGHT] = 50;
8231         node_1->style.margin[CSS_LEFT] = 10;
8232         node_1->style.margin[CSS_TOP] = 10;
8233         node_1->style.margin[CSS_RIGHT] = 10;
8234         node_1->style.margin[CSS_BOTTOM] = 10;
8235         node_1->style.margin[CSS_START] = 10;
8236         node_1->style.margin[CSS_END] = 10;
8237         node_1 = node_0->get_child(node_0->context, 1);
8238         node_1->style.dimensions[CSS_WIDTH] = 50;
8239         node_1->style.dimensions[CSS_HEIGHT] = 50;
8240         node_1->style.margin[CSS_LEFT] = 10;
8241         node_1->style.margin[CSS_TOP] = 10;
8242         node_1->style.margin[CSS_RIGHT] = 10;
8243         node_1->style.margin[CSS_BOTTOM] = 10;
8244         node_1->style.margin[CSS_START] = 10;
8245         node_1->style.margin[CSS_END] = 10;
8246         node_1 = node_0->get_child(node_0->context, 2);
8247         node_1->style.dimensions[CSS_WIDTH] = 50;
8248         node_1->style.dimensions[CSS_HEIGHT] = 50;
8249         node_1->style.margin[CSS_LEFT] = 10;
8250         node_1->style.margin[CSS_TOP] = 10;
8251         node_1->style.margin[CSS_RIGHT] = 10;
8252         node_1->style.margin[CSS_BOTTOM] = 10;
8253         node_1->style.margin[CSS_START] = 10;
8254         node_1->style.margin[CSS_END] = 10;
8255         node_1 = node_0->get_child(node_0->context, 3);
8256         node_1->style.dimensions[CSS_WIDTH] = 50;
8257         node_1->style.dimensions[CSS_HEIGHT] = 50;
8258         node_1->style.margin[CSS_LEFT] = 10;
8259         node_1->style.margin[CSS_TOP] = 10;
8260         node_1->style.margin[CSS_RIGHT] = 10;
8261         node_1->style.margin[CSS_BOTTOM] = 10;
8262         node_1->style.margin[CSS_START] = 10;
8263         node_1->style.margin[CSS_END] = 10;
8264         node_1 = node_0->get_child(node_0->context, 4);
8265         node_1->style.dimensions[CSS_WIDTH] = 50;
8266         node_1->style.dimensions[CSS_HEIGHT] = 100;
8267         node_1->style.margin[CSS_LEFT] = 10;
8268         node_1->style.margin[CSS_TOP] = 10;
8269         node_1->style.margin[CSS_RIGHT] = 10;
8270         node_1->style.margin[CSS_BOTTOM] = 10;
8271         node_1->style.margin[CSS_START] = 10;
8272         node_1->style.margin[CSS_END] = 10;
8273         node_1 = node_0->get_child(node_0->context, 5);
8274         node_1->style.align_self = CSS_ALIGN_FLEX_START;
8275         node_1->style.dimensions[CSS_WIDTH] = 50;
8276         node_1->style.dimensions[CSS_HEIGHT] = 50;
8277         node_1->style.margin[CSS_LEFT] = 10;
8278         node_1->style.margin[CSS_TOP] = 10;
8279         node_1->style.margin[CSS_RIGHT] = 10;
8280         node_1->style.margin[CSS_BOTTOM] = 10;
8281         node_1->style.margin[CSS_START] = 10;
8282         node_1->style.margin[CSS_END] = 10;
8283         node_1 = node_0->get_child(node_0->context, 6);
8284         node_1->style.dimensions[CSS_WIDTH] = 50;
8285         node_1->style.dimensions[CSS_HEIGHT] = 50;
8286         node_1->style.margin[CSS_LEFT] = 10;
8287         node_1->style.margin[CSS_TOP] = 10;
8288         node_1->style.margin[CSS_RIGHT] = 10;
8289         node_1->style.margin[CSS_BOTTOM] = 10;
8290         node_1->style.margin[CSS_START] = 10;
8291         node_1->style.margin[CSS_END] = 10;
8292         node_1 = node_0->get_child(node_0->context, 7);
8293         node_1->style.dimensions[CSS_WIDTH] = 50;
8294         node_1->style.dimensions[CSS_HEIGHT] = 100;
8295         node_1->style.margin[CSS_LEFT] = 10;
8296         node_1->style.margin[CSS_TOP] = 10;
8297         node_1->style.margin[CSS_RIGHT] = 10;
8298         node_1->style.margin[CSS_BOTTOM] = 10;
8299         node_1->style.margin[CSS_START] = 10;
8300         node_1->style.margin[CSS_END] = 10;
8301         node_1 = node_0->get_child(node_0->context, 8);
8302         node_1->style.dimensions[CSS_WIDTH] = 50;
8303         node_1->style.dimensions[CSS_HEIGHT] = 50;
8304         node_1->style.margin[CSS_LEFT] = 10;
8305         node_1->style.margin[CSS_TOP] = 10;
8306         node_1->style.margin[CSS_RIGHT] = 10;
8307         node_1->style.margin[CSS_BOTTOM] = 10;
8308         node_1->style.margin[CSS_START] = 10;
8309         node_1->style.margin[CSS_END] = 10;
8310         node_1 = node_0->get_child(node_0->context, 9);
8311         node_1->style.dimensions[CSS_WIDTH] = 50;
8312         node_1->style.dimensions[CSS_HEIGHT] = 50;
8313         node_1->style.margin[CSS_LEFT] = 10;
8314         node_1->style.margin[CSS_TOP] = 10;
8315         node_1->style.margin[CSS_RIGHT] = 10;
8316         node_1->style.margin[CSS_BOTTOM] = 10;
8317         node_1->style.margin[CSS_START] = 10;
8318         node_1->style.margin[CSS_END] = 10;
8319         node_1 = node_0->get_child(node_0->context, 10);
8320         node_1->style.align_self = CSS_ALIGN_FLEX_START;
8321         node_1->style.dimensions[CSS_WIDTH] = 50;
8322         node_1->style.dimensions[CSS_HEIGHT] = 50;
8323         node_1->style.margin[CSS_LEFT] = 10;
8324         node_1->style.margin[CSS_TOP] = 10;
8325         node_1->style.margin[CSS_RIGHT] = 10;
8326         node_1->style.margin[CSS_BOTTOM] = 10;
8327         node_1->style.margin[CSS_START] = 10;
8328         node_1->style.margin[CSS_END] = 10;
8329         node_1 = node_0->get_child(node_0->context, 11);
8330         node_1->style.dimensions[CSS_WIDTH] = 50;
8331         node_1->style.dimensions[CSS_HEIGHT] = 50;
8332         node_1->style.margin[CSS_LEFT] = 10;
8333         node_1->style.margin[CSS_TOP] = 10;
8334         node_1->style.margin[CSS_RIGHT] = 10;
8335         node_1->style.margin[CSS_BOTTOM] = 10;
8336         node_1->style.margin[CSS_START] = 10;
8337         node_1->style.margin[CSS_END] = 10;
8338         node_1 = node_0->get_child(node_0->context, 12);
8339         node_1->style.dimensions[CSS_WIDTH] = 50;
8340         node_1->style.dimensions[CSS_HEIGHT] = 50;
8341         node_1->style.margin[CSS_LEFT] = 10;
8342         node_1->style.margin[CSS_TOP] = 10;
8343         node_1->style.margin[CSS_RIGHT] = 10;
8344         node_1->style.margin[CSS_BOTTOM] = 10;
8345         node_1->style.margin[CSS_START] = 10;
8346         node_1->style.margin[CSS_END] = 10;
8347         node_1 = node_0->get_child(node_0->context, 13);
8348         node_1->style.align_self = CSS_ALIGN_FLEX_START;
8349         node_1->style.dimensions[CSS_WIDTH] = 50;
8350         node_1->style.dimensions[CSS_HEIGHT] = 50;
8351         node_1->style.margin[CSS_LEFT] = 10;
8352         node_1->style.margin[CSS_TOP] = 10;
8353         node_1->style.margin[CSS_RIGHT] = 10;
8354         node_1->style.margin[CSS_BOTTOM] = 10;
8355         node_1->style.margin[CSS_START] = 10;
8356         node_1->style.margin[CSS_END] = 10;
8357         node_1 = node_0->get_child(node_0->context, 14);
8358         node_1->style.dimensions[CSS_WIDTH] = 50;
8359         node_1->style.dimensions[CSS_HEIGHT] = 50;
8360         node_1->style.margin[CSS_LEFT] = 10;
8361         node_1->style.margin[CSS_TOP] = 10;
8362         node_1->style.margin[CSS_RIGHT] = 10;
8363         node_1->style.margin[CSS_BOTTOM] = 10;
8364         node_1->style.margin[CSS_START] = 10;
8365         node_1->style.margin[CSS_END] = 10;
8366       }
8367     }
8368
8369     css_node_t *root_layout = new_test_css_node();
8370     {
8371       css_node_t *node_0 = root_layout;
8372       node_0->layout.position[CSS_TOP] = 0;
8373       node_0->layout.position[CSS_LEFT] = 0;
8374       node_0->layout.dimensions[CSS_WIDTH] = 300;
8375       node_0->layout.dimensions[CSS_HEIGHT] = 380;
8376       init_css_node_children(node_0, 15);
8377       {
8378         css_node_t *node_1;
8379         node_1 = node_0->get_child(node_0->context, 0);
8380         node_1->layout.position[CSS_TOP] = 10;
8381         node_1->layout.position[CSS_LEFT] = 10;
8382         node_1->layout.dimensions[CSS_WIDTH] = 50;
8383         node_1->layout.dimensions[CSS_HEIGHT] = 50;
8384         node_1 = node_0->get_child(node_0->context, 1);
8385         node_1->layout.position[CSS_TOP] = 10;
8386         node_1->layout.position[CSS_LEFT] = 80;
8387         node_1->layout.dimensions[CSS_WIDTH] = 50;
8388         node_1->layout.dimensions[CSS_HEIGHT] = 50;
8389         node_1 = node_0->get_child(node_0->context, 2);
8390         node_1->layout.position[CSS_TOP] = 10;
8391         node_1->layout.position[CSS_LEFT] = 150;
8392         node_1->layout.dimensions[CSS_WIDTH] = 50;
8393         node_1->layout.dimensions[CSS_HEIGHT] = 50;
8394         node_1 = node_0->get_child(node_0->context, 3);
8395         node_1->layout.position[CSS_TOP] = 10;
8396         node_1->layout.position[CSS_LEFT] = 220;
8397         node_1->layout.dimensions[CSS_WIDTH] = 50;
8398         node_1->layout.dimensions[CSS_HEIGHT] = 50;
8399         node_1 = node_0->get_child(node_0->context, 4);
8400         node_1->layout.position[CSS_TOP] = 92.5;
8401         node_1->layout.position[CSS_LEFT] = 10;
8402         node_1->layout.dimensions[CSS_WIDTH] = 50;
8403         node_1->layout.dimensions[CSS_HEIGHT] = 100;
8404         node_1 = node_0->get_child(node_0->context, 5);
8405         node_1->layout.position[CSS_TOP] = 92.5;
8406         node_1->layout.position[CSS_LEFT] = 80;
8407         node_1->layout.dimensions[CSS_WIDTH] = 50;
8408         node_1->layout.dimensions[CSS_HEIGHT] = 50;
8409         node_1 = node_0->get_child(node_0->context, 6);
8410         node_1->layout.position[CSS_TOP] = 92.5;
8411         node_1->layout.position[CSS_LEFT] = 150;
8412         node_1->layout.dimensions[CSS_WIDTH] = 50;
8413         node_1->layout.dimensions[CSS_HEIGHT] = 50;
8414         node_1 = node_0->get_child(node_0->context, 7);
8415         node_1->layout.position[CSS_TOP] = 92.5;
8416         node_1->layout.position[CSS_LEFT] = 220;
8417         node_1->layout.dimensions[CSS_WIDTH] = 50;
8418         node_1->layout.dimensions[CSS_HEIGHT] = 100;
8419         node_1 = node_0->get_child(node_0->context, 8);
8420         node_1->layout.position[CSS_TOP] = 225;
8421         node_1->layout.position[CSS_LEFT] = 10;
8422         node_1->layout.dimensions[CSS_WIDTH] = 50;
8423         node_1->layout.dimensions[CSS_HEIGHT] = 50;
8424         node_1 = node_0->get_child(node_0->context, 9);
8425         node_1->layout.position[CSS_TOP] = 225;
8426         node_1->layout.position[CSS_LEFT] = 80;
8427         node_1->layout.dimensions[CSS_WIDTH] = 50;
8428         node_1->layout.dimensions[CSS_HEIGHT] = 50;
8429         node_1 = node_0->get_child(node_0->context, 10);
8430         node_1->layout.position[CSS_TOP] = 225;
8431         node_1->layout.position[CSS_LEFT] = 150;
8432         node_1->layout.dimensions[CSS_WIDTH] = 50;
8433         node_1->layout.dimensions[CSS_HEIGHT] = 50;
8434         node_1 = node_0->get_child(node_0->context, 11);
8435         node_1->layout.position[CSS_TOP] = 225;
8436         node_1->layout.position[CSS_LEFT] = 220;
8437         node_1->layout.dimensions[CSS_WIDTH] = 50;
8438         node_1->layout.dimensions[CSS_HEIGHT] = 50;
8439         node_1 = node_0->get_child(node_0->context, 12);
8440         node_1->layout.position[CSS_TOP] = 307.5;
8441         node_1->layout.position[CSS_LEFT] = 10;
8442         node_1->layout.dimensions[CSS_WIDTH] = 50;
8443         node_1->layout.dimensions[CSS_HEIGHT] = 50;
8444         node_1 = node_0->get_child(node_0->context, 13);
8445         node_1->layout.position[CSS_TOP] = 307.5;
8446         node_1->layout.position[CSS_LEFT] = 80;
8447         node_1->layout.dimensions[CSS_WIDTH] = 50;
8448         node_1->layout.dimensions[CSS_HEIGHT] = 50;
8449         node_1 = node_0->get_child(node_0->context, 14);
8450         node_1->layout.position[CSS_TOP] = 307.5;
8451         node_1->layout.position[CSS_LEFT] = 150;
8452         node_1->layout.dimensions[CSS_WIDTH] = 50;
8453         node_1->layout.dimensions[CSS_HEIGHT] = 50;
8454       }
8455     }
8456
8457     test("should layout with alignContent: stretch, and alignItems: flex-start", root_node, root_layout);
8458   }
8459   /** END_GENERATED **/
8460   return tests_finished();
8461 }