gentest: allow for different default values

Summary:
@public

We use Chrome for generating test cases, which since v67 (or so) for `min-width` and `min-height` has a default value of either `0px` (CSS 2) or `auto` (CSS 3), depending on style properties.

Our setup only allowed for a single default value, and our test cases produce *both.*
This changes the test gen logic to allow for more than one value.

Reviewed By: SidharthGuglani

Differential Revision: D14682387

fbshipit-source-id: e76361f5cc0b88f9c2d74a5f3248c66abd6907a7
This commit is contained in:
David Aurelio
2019-03-29 06:26:59 -07:00
committed by Facebook Github Bot
parent c235301b52
commit 1fc8472d35
5 changed files with 36 additions and 25 deletions

View File

@@ -137,7 +137,7 @@ function checkDefaultValues() {
{style:'bottom', value:'undefined'},
{style:'display', value:'flex'},
].forEach(function(item) {
assert(item.value === getDefaultStyleValue(item.style),
assert(isDefaultStyleValue(item.style, item.value),
item.style + ' should be ' + item.value);
});
}
@@ -156,9 +156,11 @@ function setupTestTree(e, parent, node, genericNode, nodeName, parentName, index
style == 'width' ||
style == 'height')) {
continue;
}
if (node.style[style] !== getDefaultStyleValue(style)) {
var DEFAULT_STYLES = Object.create }
if (!isDefaultStyleValue(style, node.style[style])) {
switch (style) {
case 'direction':
e.YGNodeStyleSetDirection(nodeName, directionValue(e, node.style[style]));
@@ -399,21 +401,38 @@ function displayValue(e, value){
}
}
function getDefaultStyleValue(style) {
if (style == 'position') {
return 'relative';
var DEFAULT_STYLES = new Map();
function isDefaultStyleValue(style, value) {
let defaultStyle = DEFAULT_STYLES.get(style);
if (defaultStyle == null) {
switch (style) {
case 'position':
defaultStyle = new Set(['relative']);;
break;
case 'left':
case 'top':
case 'right':
case 'bottom':
case 'start':
case 'end':
defaultStyle = new Set(['undefined']);
break;
case 'min-height':
case 'min-width':
defaultStyle = new Set(['0', '0px', 'auto']);
break;
default:
var node = document.getElementById('default');
defaultStyle = new Set([getComputedStyle(node, null)[style]]);
break;
}
DEFAULT_STYLES.set(style, defaultStyle);
}
switch (style) {
case 'left':
case 'top':
case 'right':
case 'bottom':
case 'start':
case 'end':
return 'undefined';
}
var node = document.getElementById('default');
return getComputedStyle(node, null).getPropertyValue(style);
return DEFAULT_STYLES.get(style).has(value);
}
function getRoundedSize(node) {