diff --git a/apps/tests/layouts/wrap-layout-tests.ts b/apps/tests/layouts/wrap-layout-tests.ts index f533cbff3..cac9cf66e 100644 --- a/apps/tests/layouts/wrap-layout-tests.ts +++ b/apps/tests/layouts/wrap-layout-tests.ts @@ -44,12 +44,9 @@ export class WrapLayoutTest extends testModule.UITest 0; + let useItemHeight: boolean = this.itemHeight > 0; + let itemWidth = this.itemWidth; + let itemHeight = this.itemHeight; + for (let i = 0, count = this.getChildrenCount(); i < count; i++) { let child = this.getChildAt(i); if (!child._isVisible) { continue; } - var childSize = View.measureChild(this, child, childWidthMeasureSpec, childHeightMeasureSpec); + var desiredSize = View.measureChild(this, child, childWidthMeasureSpec, childHeightMeasureSpec); + let childMeasuredWidth = useItemWidth ? itemWidth : desiredSize.measuredWidth; + let childMeasuredHeight = useItemHeight ? itemHeight : desiredSize.measuredHeight; + if (isVertical) { - if (childSize.measuredHeight > remainingHeight) { + if (childMeasuredHeight > remainingHeight) { rowOrColumn++; maxLength = Math.max(maxLength, measureHeight); - measureHeight = childSize.measuredHeight; - remainingWidth = height - childSize.measuredHeight; - this._lengths[rowOrColumn] = childSize.measuredWidth; + measureHeight = childMeasuredHeight; + remainingWidth = availableHeight - childMeasuredHeight; + this._lengths[rowOrColumn] = childMeasuredWidth; } else { - remainingHeight -= childSize.measuredHeight; - measureHeight += childSize.measuredHeight; + remainingHeight -= childMeasuredHeight; + measureHeight += childMeasuredHeight; } } else { - if (childSize.measuredWidth > remainingWidth) { + if (childMeasuredWidth > remainingWidth) { rowOrColumn++; maxLength = Math.max(maxLength, measureWidth); - measureWidth = childSize.measuredWidth; - remainingWidth = width - childSize.measuredWidth; - this._lengths[rowOrColumn] = childSize.measuredHeight; + measureWidth = childMeasuredWidth; + remainingWidth = availableWidth - childMeasuredWidth; + this._lengths[rowOrColumn] = childMeasuredHeight; } else { - remainingWidth -= childSize.measuredWidth; - measureWidth += childSize.measuredWidth; + remainingWidth -= childMeasuredWidth; + measureWidth += childMeasuredWidth; } } if (this._lengths.length <= rowOrColumn) { - this._lengths[rowOrColumn] = isVertical ? childSize.measuredWidth: childSize.measuredHeight; + this._lengths[rowOrColumn] = isVertical ? childMeasuredWidth : childMeasuredHeight; } else { - this._lengths[rowOrColumn] = Math.max(this._lengths[rowOrColumn], isVertical ? childSize.measuredWidth : childSize.measuredHeight); + this._lengths[rowOrColumn] = Math.max(this._lengths[rowOrColumn], isVertical ? childMeasuredWidth : childMeasuredHeight); } } @@ -103,14 +115,14 @@ export class WrapLayout extends common.WrapLayout { }); } - measureWidth += (this.paddingLeft + this.paddingRight) * density; - measureHeight += (this.paddingTop + this.paddingBottom) * density; + measureWidth += horizontalPadding; + measureHeight += verticalPadding; measureWidth = Math.max(measureWidth, this.minWidth * density); measureHeight = Math.max(measureHeight, this.minHeight * density); - var widthAndState = View.resolveSizeAndState(measureWidth, width, widthMode, 0); - var heightAndState = View.resolveSizeAndState(measureHeight, height, heightMode, 0); + var widthAndState = View.resolveSizeAndState(measureWidth, utils.layout.getMeasureSpecSize(widthMeasureSpec), widthMode, 0); + var heightAndState = View.resolveSizeAndState(measureHeight, utils.layout.getMeasureSpecSize(heightMeasureSpec), heightMode, 0); this.setMeasuredDimension(widthAndState, heightAndState); } @@ -147,7 +159,7 @@ export class WrapLayout extends common.WrapLayout { let childHeight = child.getMeasuredHeight() + (lp.topMargin + lp.bottomMargin) * density; let length = this._lengths[rowOrColumn]; - if (isVertical) { + if (isVertical) { childWidth = length; childHeight = this.itemHeight > 0 ? this.itemHeight * density : childHeight; if (childTop + childHeight > childrenLength) {