mirror of
https://github.com/status-im/react-native.git
synced 2025-01-28 18:25:06 +00:00
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:
parent
b9e3ef2d5f
commit
7055c52288
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user