Commit e1aaf39f authored by Ian Hickson's avatar Ian Hickson

Fix Block intrinsic functions (#3286)

* Fix Block intrinsic functions

* Update block_test.dart

Fix the test per travis
parent ecf1cce8
......@@ -157,7 +157,7 @@ class RenderBlock extends RenderBox
while (child != null) {
switch (mainAxis) {
case Axis.horizontal:
extent += child.getMinIntrinsicWidth(innerConstraints);
extent += child.getMaxIntrinsicWidth(innerConstraints);
break;
case Axis.vertical:
extent += child.getMinIntrinsicHeight(innerConstraints);
......@@ -206,7 +206,7 @@ class RenderBlock extends RenderBox
case Axis.horizontal:
return _getIntrinsicCrossAxis(
constraints,
(RenderBox child, BoxConstraints innerConstraints) => child.getMinIntrinsicWidth(innerConstraints),
(RenderBox child, BoxConstraints innerConstraints) => child.getMinIntrinsicHeight(innerConstraints),
constraints.constrainHeight
);
case Axis.vertical:
......@@ -221,7 +221,7 @@ class RenderBlock extends RenderBox
case Axis.horizontal:
return _getIntrinsicCrossAxis(
constraints,
(RenderBox child, BoxConstraints innerConstraints) => child.getMaxIntrinsicWidth(innerConstraints),
(RenderBox child, BoxConstraints innerConstraints) => child.getMaxIntrinsicHeight(innerConstraints),
constraints.constrainHeight
);
case Axis.vertical:
......
......@@ -30,11 +30,15 @@ void main() {
expect(paragraph.getMaxIntrinsicHeight(unconstrained), equals(oneLineTextHeight));
expect(paragraph.getMaxIntrinsicHeight(constrained), equals(twoLinesTextHeight));
RenderBox testBlock = new RenderBlock(
// test setup
RenderBlock testBlock = new RenderBlock(
children: <RenderBox>[
paragraph,
]
);
final BoxConstraints empty = new BoxConstraints.tight(Size.zero);
// vertical block
expect(testBlock.getMinIntrinsicWidth(unconstrained), equals(wrappedTextWidth));
expect(testBlock.getMinIntrinsicWidth(constrained), equals(wrappedTextWidth));
expect(testBlock.getMaxIntrinsicWidth(unconstrained), equals(textWidth));
......@@ -43,8 +47,21 @@ void main() {
expect(testBlock.getMinIntrinsicHeight(constrained), equals(twoLinesTextHeight));
expect(testBlock.getMaxIntrinsicHeight(unconstrained), equals(oneLineTextHeight));
expect(testBlock.getMaxIntrinsicHeight(constrained), equals(twoLinesTextHeight));
expect(testBlock.getMinIntrinsicWidth(empty), equals(0.0));
expect(testBlock.getMaxIntrinsicWidth(empty), equals(0.0));
expect(testBlock.getMinIntrinsicHeight(empty), equals(0.0));
expect(testBlock.getMaxIntrinsicHeight(empty), equals(0.0));
final BoxConstraints empty = new BoxConstraints.tight(Size.zero);
// horizontal block
testBlock.mainAxis = Axis.horizontal;
expect(testBlock.getMinIntrinsicWidth(unconstrained), equals(textWidth));
expect(testBlock.getMinIntrinsicWidth(constrained), equals(constrained.maxWidth));
expect(testBlock.getMaxIntrinsicWidth(unconstrained), equals(textWidth));
expect(testBlock.getMaxIntrinsicWidth(constrained), equals(constrained.maxWidth));
expect(testBlock.getMinIntrinsicHeight(unconstrained), equals(oneLineTextHeight));
expect(testBlock.getMinIntrinsicHeight(constrained), equals(oneLineTextHeight));
expect(testBlock.getMaxIntrinsicHeight(unconstrained), equals(oneLineTextHeight));
expect(testBlock.getMaxIntrinsicHeight(constrained), equals(oneLineTextHeight));
expect(testBlock.getMinIntrinsicWidth(empty), equals(0.0));
expect(testBlock.getMaxIntrinsicWidth(empty), equals(0.0));
expect(testBlock.getMinIntrinsicHeight(empty), equals(0.0));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment