| Index: ui/gfx/skrect_conversion_unittest.cc
|
| diff --git a/ui/gfx/skrect_conversion_unittest.cc b/ui/gfx/skrect_conversion_unittest.cc
|
| index 7fe0c835cfe644ed97e8c992d21459d556e91c7e..f9c05c04589fb1506e3d8be70f3253105c73790e 100644
|
| --- a/ui/gfx/skrect_conversion_unittest.cc
|
| +++ b/ui/gfx/skrect_conversion_unittest.cc
|
| @@ -22,4 +22,27 @@ TEST(RectTest, SkiaRectConversions) {
|
| EXPECT_EQ(fsrc.ToString(), SkRectToRectF(skrect).ToString());
|
| }
|
|
|
| +TEST(RectTest, SkIRectToRectClamping) {
|
| + // This clamping only makes sense if SkIRect and gfx::Rect have the same size.
|
| + // Otherwise, either other overflows can occur that we don't handle, or no
|
| + // overflows can ocur.
|
| + if (sizeof(int) != sizeof(int32_t))
|
| + return;
|
| + using Limits = std::numeric_limits<int>;
|
| +
|
| + // right-left and bottom-top would overflow.
|
| + // These should be mapped to max width/height, which is as close as gfx::Rect
|
| + // can represent.
|
| + EXPECT_EQ(
|
| + gfx::Rect(Limits::min(), Limits::min(), Limits::max(), Limits::max()),
|
| + SkIRectToRect(SkIRect::MakeLTRB(Limits::min(), Limits::min(),
|
| + Limits::max(), Limits::max())));
|
| +
|
| + // right-left and bottom-top would underflow.
|
| + // These should be mapped to zero, like all negative values.
|
| + EXPECT_EQ(gfx::Rect(Limits::max(), Limits::max(), 0, 0),
|
| + SkIRectToRect(SkIRect::MakeLTRB(Limits::max(), Limits::max(),
|
| + Limits::min(), Limits::min())));
|
| +}
|
| +
|
| } // namespace gfx
|
|
|