Adds support for expect-* attributes
This commit is contained in:
@@ -51,7 +51,7 @@
|
||||
<div style="height: 10px; flex-grow:1;"></div>
|
||||
</div>
|
||||
|
||||
<div id="rounding_fractial_input_3" experiments="Rounding" style="top: 0.3px; height: 113.4px; width: 100px;">
|
||||
<div id="rounding_fractial_input_3" experiments="Rounding" style="top: 0.1px; height: 113.1px; width: 100px;">
|
||||
<div style="height: 20px; flex-grow:1; flex-basis:50px;"></div>
|
||||
<div style="height: 10px; flex-grow:1;"></div>
|
||||
<div style="height: 10px; flex-grow:1;"></div>
|
||||
@@ -62,3 +62,15 @@
|
||||
<div style="height: 10px; flex-grow:1;"></div>
|
||||
<div style="height: 10px; flex-grow:1;"></div>
|
||||
</div>
|
||||
|
||||
<div id="rounding_fractial_input_5_x" experiments="Rounding" style="margin-top: .4px; height: 100.4px; width: 100px; flex-direction: row;">
|
||||
<div style="height: 100%; width: 10px;" expect-height="101 instead of 100"></div>
|
||||
<div style="height: 100%; width: 10px;" expect-height="101 instead of 100"></div>
|
||||
<div style="height: 100%; width: 10px;" expect-height="101 instead of 100"></div>
|
||||
</div>
|
||||
|
||||
<div id="rounding_fractial_input_5_y" experiments="Rounding" style="margin-left: .4px; width: 100.4px; height: 100px; flex-direction: column;">
|
||||
<div style="width: 100%; height: 10px;" expect-width="101 instead of 100"></div>
|
||||
<div style="width: 100%; height: 10px;" expect-width="101 instead of 100"></div>
|
||||
<div style="width: 100%; height: 10px;" expect-width="101 instead of 100"></div>
|
||||
</div>
|
||||
|
@@ -420,17 +420,33 @@ function getDefaultStyleValue(style) {
|
||||
return getComputedStyle(node, null).getPropertyValue(style);
|
||||
}
|
||||
|
||||
function getExpectation(child, name, nativeValue) {
|
||||
if (!child.hasAttribute('expect-' + name))
|
||||
return nativeValue;
|
||||
|
||||
var match = child.getAttribute('expect-' + name).match(/^([0-9.]+) instead of ([0-9.]+)/);
|
||||
|
||||
if (!match)
|
||||
throw new Error('Invalid syntax for expect-' + name);
|
||||
|
||||
if (nativeValue !== Number(match[2]))
|
||||
throw new Error('Native value doesn\'t match the expectations for expect-' + name + ' (got ' + nativeValue + ' instead of ' + match[2] + ')');
|
||||
|
||||
return Number(match[1]);
|
||||
}
|
||||
|
||||
function calculateTree(root) {
|
||||
var rootLayout = [];
|
||||
|
||||
for (var i = 0; i < root.children.length; i++) {
|
||||
var child = root.children[i];
|
||||
|
||||
rootLayout.push({
|
||||
name: child.id !== '' ? child.id : 'INSERT_NAME_HERE',
|
||||
left: child.offsetLeft + child.parentNode.clientLeft,
|
||||
top: child.offsetTop + child.parentNode.clientTop,
|
||||
width: child.offsetWidth,
|
||||
height: child.offsetHeight,
|
||||
left: getExpectation(child, `left`, child.offsetLeft + child.parentNode.clientLeft),
|
||||
top: getExpectation(child, `top`, child.offsetTop + child.parentNode.clientTop),
|
||||
width: getExpectation(child, `width`, child.offsetWidth),
|
||||
height: getExpectation(child, `height`, child.offsetHeight),
|
||||
children: calculateTree(child),
|
||||
style: getYogaStyle(child),
|
||||
declaredStyle: child.style,
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env ruby
|
||||
|
||||
require 'watir-webdriver'
|
||||
require 'watir'
|
||||
require 'fileutils'
|
||||
|
||||
caps = Selenium::WebDriver::Remote::Capabilities.chrome(
|
||||
@@ -48,8 +48,6 @@ Dir['fixtures/*.html'].each do |file|
|
||||
f.write eval(logs[2].message.sub(/^[^"]*/, '')).sub('YogaTest', name)
|
||||
f.close
|
||||
|
||||
print logs[4]
|
||||
|
||||
f = File.open("../javascript/tests/Facebook.Yoga/#{name}.js", 'w')
|
||||
f.write eval(logs[3].message.sub(/^[^"]*/, '')).sub('YogaTest', name)
|
||||
f.close
|
||||
|
Reference in New Issue
Block a user