Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(403)

Side by Side Diff: ui/gfx/skrect_conversion_unittest.cc

Issue 2744423002: Handle large rects better. (Closed)
Patch Set: Add comment and change constant reference. Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/gfx/skia_util.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 Rect result = SkIRectToRect(SkIRect::MakeLTRB(Limits::min(), Limits::min(),
37 gfx::Rect(Limits::min(), Limits::min(), Limits::max(), Limits::max()), 37 Limits::max(), Limits::max()));
38 SkIRectToRect(SkIRect::MakeLTRB(Limits::min(), Limits::min(), 38 EXPECT_EQ(gfx::Size(Limits::max(), Limits::max()), result.size());
39 Limits::max(), Limits::max())));
40 39
41 // right-left and bottom-top would underflow. 40 // right-left and bottom-top would underflow.
42 // These should be mapped to zero, like all negative values. 41 // These should be mapped to zero, like all negative values.
43 EXPECT_EQ(gfx::Rect(Limits::max(), Limits::max(), 0, 0), 42 result = SkIRectToRect(SkIRect::MakeLTRB(Limits::max(), Limits::max(),
44 SkIRectToRect(SkIRect::MakeLTRB(Limits::max(), Limits::max(), 43 Limits::min(), Limits::min()));
45 Limits::min(), Limits::min()))); 44 EXPECT_EQ(gfx::Rect(Limits::max(), Limits::max(), 0, 0), result);
46 } 45 }
47 46
48 } // namespace gfx 47 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gfx/skia_util.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698