passing height to the measure function

This diff:
* adds height as another parameter passed to the measure function, computed the same way width is
* adds tests for this extension, which has involved adding a new measure function to all of js, c, java and c# tests
This commit is contained in:
Martin Kralik
2015-11-17 18:50:42 +00:00
parent 53769ccbc5
commit f2aa5ba604
29 changed files with 1139 additions and 294 deletions

View File

@@ -10,10 +10,12 @@
var testLayout = layoutTestUtils.testLayout;
var testLayoutAgainstDomOnly = layoutTestUtils.testLayoutAgainstDomOnly;
var testLayoutAgainstExpectedOnly = layoutTestUtils.testLayoutAgainstExpectedOnly;
var testFillNodes = layoutTestUtils.testFillNodes;
var text = layoutTestUtils.text;
var texts = layoutTestUtils.texts;
var textSizes = layoutTestUtils.textSizes;
var measureWithRatio2 = layoutTestUtils.measureWithRatio2();
describe('Javascript Only', function() {
it('should fill root node with layout, style, and children', function() {
@@ -1192,6 +1194,65 @@ describe('Layout', function() {
);
});
it('should layout node with fixed width and custom measure function', function() {
testLayoutAgainstExpectedOnly(
{style: {
measure: measureWithRatio2,
width: 100
}},
{width: 100, height: 200, top: 0, left: 0}
);
});
it('should layout node with fixed height and custom measure function', function() {
testLayoutAgainstExpectedOnly(
{style: {
measure: measureWithRatio2,
height: 100
}},
{width: 200, height: 100, top: 0, left: 0}
);
});
it('should layout node with fixed height and fixed width, ignoring custom measure function', function() {
testLayoutAgainstExpectedOnly(
{style: {
measure: measureWithRatio2,
width: 100,
height: 100
}},
{width: 100, height: 100, top: 0, left: 0}
);
});
it('should layout node with no fixed dimension and custom measure function', function() {
testLayoutAgainstExpectedOnly(
{style: {
measure: measureWithRatio2,
}},
{width: 99999, height: 99999, top: 0, left: 0}
);
});
it('should layout node with nested stacks and custom measure function', function() {
testLayoutAgainstExpectedOnly(
{style: {width: 320, flexDirection: 'column'}, children: [
{style: {measure: measureWithRatio2}},
{style: {height: 100, flexDirection: 'row'}, children: [
{style: {measure: measureWithRatio2}},
{style: {measure: measureWithRatio2}}
]},
]},
{width: 320, height: 740, top: 0, left: 0, children: [
{width: 320, height: 640, top: 0, left: 0},
{width: 320, height: 100, top: 640, left: 0, children: [
{width: 200, height: 100, top: 0, left: 0},
{width: 200, height: 100, top: 0, left: 200}
]},
]}
);
});
it('should layout node with text and width', function() {
testLayout(
{style: {measure: text(texts.small), width: 10}},