OLD | NEW |
---|---|
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "testing/gtest/include/gtest/gtest.h" | 5 #include "testing/gtest/include/gtest/gtest.h" |
6 #include "ui/gfx/geometry/rect.h" | 6 #include "ui/gfx/geometry/rect.h" |
7 #include "ui/gfx/skia_util.h" | 7 #include "ui/gfx/skia_util.h" |
8 | 8 |
9 namespace gfx { | 9 namespace gfx { |
10 | 10 |
(...skipping 15 matching lines...) Expand all Loading... | |
26 // This clamping only makes sense if SkIRect and gfx::Rect have the same size. | 26 // This clamping only makes sense if SkIRect and gfx::Rect have the same size. |
27 // Otherwise, either other overflows can occur that we don't handle, or no | 27 // Otherwise, either other overflows can occur that we don't handle, or no |
28 // overflows can ocur. | 28 // overflows can ocur. |
29 if (sizeof(int) != sizeof(int32_t)) | 29 if (sizeof(int) != sizeof(int32_t)) |
30 return; | 30 return; |
31 using Limits = std::numeric_limits<int>; | 31 using Limits = std::numeric_limits<int>; |
32 | 32 |
33 // right-left and bottom-top would overflow. | 33 // right-left and bottom-top would overflow. |
34 // These should be mapped to max width/height, which is as close as gfx::Rect | 34 // These should be mapped to max width/height, which is as close as gfx::Rect |
35 // can represent. | 35 // can represent. |
36 EXPECT_EQ( | 36 EXPECT_EQ(gfx::Size(Limits::max(), Limits::max()), |
37 gfx::Rect(Limits::min(), Limits::min(), Limits::max(), Limits::max()), | 37 SkIRectToRect(SkIRect::MakeLTRB(Limits::min(), Limits::min(), |
danakj
2017/03/28 20:40:35
This would be more readable (less line-wrappy) if
Peter Mayo
2017/03/29 18:49:26
Done.
| |
38 SkIRectToRect(SkIRect::MakeLTRB(Limits::min(), Limits::min(), | 38 Limits::max(), Limits::max())) |
39 Limits::max(), Limits::max()))); | 39 .size()); |
40 | 40 |
41 // right-left and bottom-top would underflow. | 41 // right-left and bottom-top would underflow. |
42 // These should be mapped to zero, like all negative values. | 42 // These should be mapped to zero, like all negative values. |
43 EXPECT_EQ(gfx::Rect(Limits::max(), Limits::max(), 0, 0), | 43 EXPECT_EQ(gfx::Rect(Limits::max(), Limits::max(), 0, 0), |
44 SkIRectToRect(SkIRect::MakeLTRB(Limits::max(), Limits::max(), | 44 SkIRectToRect(SkIRect::MakeLTRB(Limits::max(), Limits::max(), |
45 Limits::min(), Limits::min()))); | 45 Limits::min(), Limits::min()))); |
46 } | 46 } |
47 | 47 |
48 } // namespace gfx | 48 } // namespace gfx |
OLD | NEW |