Fix screenshot tests for React with nodes

Summary:
Fix screenshot tests for React with nodes. It was broken due to
calling clipRect with bounds of [-∞, ∞], which, due to a bug in Canvas that
appeared in screenshot tests, caused the view not to draw. Since this is a
no-op anyway, this patch just doesn't call clipRect when we have infinite
bounds.

Differential Revision: D2975494
This commit is contained in:
Ahmed El-Helw 2016-02-25 17:49:51 -08:00
parent b9e3ef2d5f
commit 7055c52288
1 changed files with 8 additions and 1 deletions

View File

@ -55,6 +55,13 @@ import android.graphics.Canvas;
}
protected final void applyClipping(Canvas canvas) {
canvas.clipRect(mClipLeft, mClipTop, mClipRight, mClipBottom);
// We put this check here to not clip when we have the default [-infinity, infinity] bounds,
// since clipRect in those cases is essentially no-op anyway. This is needed to fix a bug that
// shows up during screenshot testing. Note that checking one side is enough, since if one side
// is infinite, all sides will be infinite, since we only set infinite for all sides at the
// same time - conversely, if one side is finite, all sides will be finite.
if (mClipLeft != Float.NEGATIVE_INFINITY) {
canvas.clipRect(mClipLeft, mClipTop, mClipRight, mClipBottom);
}
}
}