Improve formatting of generated test code input
Summary: Make input html easier to read by indenting it and adding a space between children. The code to do this could very well be improved but it works for the current set of inputs. Reviewed By: lucasr Differential Revision: D3798087 fbshipit-source-id: 0d50ff276000f14ed078cf5ce2e7560ace285a6a
This commit is contained in:
committed by
Facebook Github Bot 5
parent
57725e849a
commit
059384f277
@@ -27,13 +27,27 @@ function printTest(rootNode, layoutTree) {
|
||||
lines.push('/**');
|
||||
lines.push(' * @Generated by gentest/gentest.sh with the following input');
|
||||
lines.push(' *');
|
||||
|
||||
var indentation = 0;
|
||||
lines.push(rootNode.innerHTML.split('\n').map(function(line) {
|
||||
return line.trim();
|
||||
}).filter(function(line) {
|
||||
return line.length > 0 && line !== '<div id="default"></div>';
|
||||
}).map(function(line) {
|
||||
return ' * ' + line;
|
||||
var result;
|
||||
if (line.indexOf('</div') == 0) {
|
||||
result = ' * ' + ' '.repeat(indentation - 1) + line;
|
||||
} else {
|
||||
result = ' * ' + ' '.repeat(indentation) + line;
|
||||
}
|
||||
|
||||
indentation += (line.match(/<div/g) || []).length;
|
||||
indentation -= (line.match(/<\/div/g) || []).length;
|
||||
return result;
|
||||
}).reduce(function(curr, prev) {
|
||||
if (prev.indexOf(' * <div') == 0) {
|
||||
prev = ' * \n' + prev;
|
||||
}
|
||||
return curr + '\n' + prev;
|
||||
}));
|
||||
lines.push(' *');
|
||||
|
@@ -13,15 +13,19 @@
|
||||
* <div id="absolute_layout_width_height_left_top" style="width: 100px; height: 100px;">
|
||||
* <div style="width:10px; height: 10px; position: absolute; left: 10px; top: 10px;"></div>
|
||||
* </div>
|
||||
*
|
||||
* <div id="absolute_layout_width_height_right_bottom" style="width: 100px; height: 100px;">
|
||||
* <div style="width:10px; height: 10px; position: absolute; right: 10px; bottom: 10px;"></div>
|
||||
* </div>
|
||||
*
|
||||
* <div id="absolute_layout_left_top_right_bottom" style="width: 100px; height: 100px;">
|
||||
* <div style="position: absolute; left: 10px; top: 10px; right: 10px; bottom: 10px;"></div>
|
||||
* </div>
|
||||
*
|
||||
* <div id="absolute_layout_width_height_left_top_right_bottom" style="width: 100px; height: 100px;">
|
||||
* <div style="width:10px; height: 10px; position: absolute; left: 10px; top: 10px; right: 10px; bottom: 10px;"></div>
|
||||
* </div>
|
||||
*
|
||||
* <div id="do_not_clamp_height_of_absolute_node_to_height_of_its_overflow_hidden_parent" style="height: 50px; width: 50px; overflow: hidden; flex-direction: row;">
|
||||
* <div style="position: absolute; left: 0; top: 0;">
|
||||
* <div style="width: 100px; height: 100px;"></div>
|
||||
|
@@ -17,6 +17,7 @@
|
||||
* <div style="width: 50px; height: 10px;"></div>
|
||||
* <div style="width: 50px; height: 10px;"></div>
|
||||
* </div>
|
||||
*
|
||||
* <div id="align_content_flex_end" style="width: 100px; height: 100px; flex-wrap: wrap; flex-direction: column; align-content: flex-end;">
|
||||
* <div style="width: 50px; height: 10px;"></div>
|
||||
* <div style="width: 50px; height: 10px;"></div>
|
||||
@@ -24,6 +25,7 @@
|
||||
* <div style="width: 50px; height: 10px;"></div>
|
||||
* <div style="width: 50px; height: 10px;"></div>
|
||||
* </div>
|
||||
*
|
||||
* <div id="align_content_center" style="width: 100px; height: 100px; flex-wrap: wrap; flex-direction: column; align-content: center;">
|
||||
* <div style="width: 50px; height: 10px;"></div>
|
||||
* <div style="width: 50px; height: 10px;"></div>
|
||||
@@ -31,6 +33,7 @@
|
||||
* <div style="width: 50px; height: 10px;"></div>
|
||||
* <div style="width: 50px; height: 10px;"></div>
|
||||
* </div>
|
||||
*
|
||||
* <div id="align_content_stretch" style="width: 100px; height: 100px; flex-wrap: wrap; flex-direction: column; align-content: stretch;">
|
||||
* <div style="width: 50px;"></div>
|
||||
* <div style="width: 50px;"></div>
|
||||
|
@@ -13,12 +13,15 @@
|
||||
* <div id="align_items_stretch" style="width: 100px; height: 100px;">
|
||||
* <div style="height: 10px;"></div>
|
||||
* </div>
|
||||
*
|
||||
* <div id="align_items_center" style="width: 100px; height: 100px; align-items: center;">
|
||||
* <div style="height: 10px; width: 10px;"></div>
|
||||
* </div>
|
||||
*
|
||||
* <div id="align_items_flex_start" style="width: 100px; height: 100px; align-items: flex-start;">
|
||||
* <div style="height: 10px; width: 10px;"></div>
|
||||
* </div>
|
||||
*
|
||||
* <div id="align_items_flex_end" style="width: 100px; height: 100px; align-items: flex-end;">
|
||||
* <div style="height: 10px; width: 10px;"></div>
|
||||
* </div>
|
||||
|
@@ -13,12 +13,15 @@
|
||||
* <div id="align_self_center" style="width:100px; height: 100px;">
|
||||
* <div style="height: 10px; width: 10px; align-self: center;"></div>
|
||||
* </div>
|
||||
*
|
||||
* <div id="align_self_flex_end" style="width:100px; height: 100px;">
|
||||
* <div style="height: 10px; width: 10px; align-self: flex-end;"></div>
|
||||
* </div>
|
||||
*
|
||||
* <div id="align_self_flex_start" style="width:100px; height: 100px;">
|
||||
* <div style="height: 10px; width: 10px; align-self: flex-start;"></div>
|
||||
* </div>
|
||||
*
|
||||
* <div id="align_self_flex_end_override_flex_start" style="width:100px; height: 100px; align-items: flex-start;">
|
||||
* <div style="height: 10px; width: 10px; align-self: flex-end;"></div>
|
||||
* </div>
|
||||
|
@@ -15,26 +15,31 @@
|
||||
* <div style="height: 10px;"></div>
|
||||
* <div style="height: 10px;"></div>
|
||||
* </div>
|
||||
*
|
||||
* <div id="flex_direction_row_no_width" style="height: 100px; flex-direction: row;">
|
||||
* <div style="width: 10px;"></div>
|
||||
* <div style="width: 10px;"></div>
|
||||
* <div style="width: 10px;"></div>
|
||||
* </div>
|
||||
*
|
||||
* <div id="flex_direction_column" style="height: 100px; width: 100px;">
|
||||
* <div style="height: 10px;"></div>
|
||||
* <div style="height: 10px;"></div>
|
||||
* <div style="height: 10px;"></div>
|
||||
* </div>
|
||||
*
|
||||
* <div id="flex_direction_row" style="height: 100px; width: 100px; flex-direction: row;">
|
||||
* <div style="width: 10px;"></div>
|
||||
* <div style="width: 10px;"></div>
|
||||
* <div style="width: 10px;"></div>
|
||||
* </div>
|
||||
*
|
||||
* <div id="flex_direction_column_reverse" style="height: 100px; width: 100px; flex-direction: column-reverse;">
|
||||
* <div style="height: 10px;"></div>
|
||||
* <div style="height: 10px;"></div>
|
||||
* <div style="height: 10px;"></div>
|
||||
* </div>
|
||||
*
|
||||
* <div id="flex_direction_row_reverse" style="height: 100px; width: 100px; flex-direction: row-reverse;">
|
||||
* <div style="width: 10px;"></div>
|
||||
* <div style="width: 10px;"></div>
|
||||
|
@@ -14,18 +14,22 @@
|
||||
* <div style="flex-basis: 50px; flex-grow: 1;"></div>
|
||||
* <div style="flex-grow: 1;"></div>
|
||||
* </div>
|
||||
*
|
||||
* <div id="flex_basis_flex_grow_row" style="width: 100px; height: 100px; flex-direction: row;">
|
||||
* <div style="flex-basis: 50px; flex-grow: 1;"></div>
|
||||
* <div style="flex-grow: 1;"></div>
|
||||
* </div>
|
||||
*
|
||||
* <div id="flex_basis_flex_shrink_column" style="width: 100px; height: 100px;">
|
||||
* <div style="flex-basis: 100px; flex-shrink: 1;"></div>
|
||||
* <div style="flex-basis: 50px;"></div>
|
||||
* </div>
|
||||
*
|
||||
* <div id="flex_basis_flex_shrink_row" style="width: 100px; height: 100px; flex-direction: row;">
|
||||
* <div style="flex-basis: 100px; flex-shrink: 1;"></div>
|
||||
* <div style="flex-basis: 50px;"></div>
|
||||
* </div>
|
||||
*
|
||||
* <div id="flex_basis_flex_grow_undefined_main" style="width: 100px;">
|
||||
* <div style="flex-basis: 100px; flex-grow: 1;"></div>
|
||||
* <div style="flex-basis: 50px;"></div>
|
||||
|
@@ -16,6 +16,7 @@
|
||||
* <div style="height: 30px; width: 30px;"></div>
|
||||
* <div style="height: 30px; width: 30px;"></div>
|
||||
* </div>
|
||||
*
|
||||
* <div id="wrap_row" style="width: 100px; flex-direction: row; flex-wrap: wrap">
|
||||
* <div style="height: 30px; width: 30px;"></div>
|
||||
* <div style="height: 30px; width: 30px;"></div>
|
||||
|
@@ -15,46 +15,55 @@
|
||||
* <div style="width: 10px;"></div>
|
||||
* <div style="width: 10px;"></div>
|
||||
* </div>
|
||||
*
|
||||
* <div id="justify_content_row_flex_end" style="width: 102px; height: 102px; flex-direction: row; justify-content: flex-end;">
|
||||
* <div style="width: 10px;"></div>
|
||||
* <div style="width: 10px;"></div>
|
||||
* <div style="width: 10px;"></div>
|
||||
* </div>
|
||||
*
|
||||
* <div id="justify_content_row_center" style="width: 102px; height: 102px; flex-direction: row; justify-content: center;">
|
||||
* <div style="width: 10px;"></div>
|
||||
* <div style="width: 10px;"></div>
|
||||
* <div style="width: 10px;"></div>
|
||||
* </div>
|
||||
*
|
||||
* <div id="justify_content_row_space_between" style="width: 102px; height: 102px; flex-direction: row; justify-content: space-between;">
|
||||
* <div style="width: 10px;"></div>
|
||||
* <div style="width: 10px;"></div>
|
||||
* <div style="width: 10px;"></div>
|
||||
* </div>
|
||||
*
|
||||
* <div id="justify_content_row_space_around" style="width: 102px; height: 102px; flex-direction: row; justify-content: space-around;">
|
||||
* <div style="width: 10px;"></div>
|
||||
* <div style="width: 10px;"></div>
|
||||
* <div style="width: 10px;"></div>
|
||||
* </div>
|
||||
*
|
||||
* <div id="justify_content_column_flex_start" style="width: 102px; height: 102px; justify-content: flex-start;">
|
||||
* <div style="height: 10px;"></div>
|
||||
* <div style="heigth: 10px;"></div>
|
||||
* <div style="height: 10px;"></div>
|
||||
* </div>
|
||||
*
|
||||
* <div id="justify_content_column_flex_end" style="width: 102px; height: 102px; justify-content: flex-end;">
|
||||
* <div style="height: 10px;"></div>
|
||||
* <div style="height: 10px;"></div>
|
||||
* <div style="height: 10px;"></div>
|
||||
* </div>
|
||||
*
|
||||
* <div id="justify_content_column_center" style="width: 102px; height: 102px; justify-content: center;">
|
||||
* <div style="height: 10px;"></div>
|
||||
* <div style="height: 10px;"></div>
|
||||
* <div style="height: 10px;"></div>
|
||||
* </div>
|
||||
*
|
||||
* <div id="justify_content_column_space_between" style="width: 102px; height: 102px; justify-content: space-between;">
|
||||
* <div style="height: 10px;"></div>
|
||||
* <div style="height: 10px;"></div>
|
||||
* <div style="height: 10px;"></div>
|
||||
* </div>
|
||||
*
|
||||
* <div id="justify_content_column_space_around" style="width: 102px; height: 102px; justify-content: space-around;">
|
||||
* <div style="height: 10px;"></div>
|
||||
* <div style="height: 10px;"></div>
|
||||
|
@@ -13,13 +13,16 @@
|
||||
* <div id="max_width" style="width: 100px; height: 100px;">
|
||||
* <div style="height: 10px; max-width: 50px;"></div>
|
||||
* </div>
|
||||
*
|
||||
* <div id="max_height" style="width: 100px; height: 100px; flex-direction: row;">
|
||||
* <div style="width: 10px; max-height: 50px;"></div>
|
||||
* </div>
|
||||
*
|
||||
* <div id="min_height" style="width: 100px; height: 100px;">
|
||||
* <div style="flex-grow: 1; min-height: 60px;"></div>
|
||||
* <div style="flex-grow: 1;"></div>
|
||||
* </div>
|
||||
*
|
||||
* <div id="min_width" style="width: 100px; height: 100px; flex-direction: row">
|
||||
* <div style="flex-grow: 1; min-width: 60px;"></div>
|
||||
* <div style="flex-grow: 1;"></div>
|
||||
|
Reference in New Issue
Block a user