Chromium Code Reviews| Index: ui/gfx/canvas_unittest.cc |
| diff --git a/ui/gfx/canvas_unittest.cc b/ui/gfx/canvas_unittest.cc |
| index 806e8f0e7a5c5c2f470eae038e0b1f246cbdeb6c..25d3ff9584ce94e293ccdac36658f2495d577b09 100644 |
| --- a/ui/gfx/canvas_unittest.cc |
| +++ b/ui/gfx/canvas_unittest.cc |
| @@ -9,6 +9,9 @@ |
| #include "base/strings/utf_string_conversions.h" |
| #include "testing/gtest/include/gtest/gtest.h" |
| #include "ui/gfx/font_list.h" |
| +#include "ui/gfx/geometry/rect.h" |
| +#include "ui/gfx/geometry/rect_f.h" |
| +#include "ui/gfx/skia_util.h" |
| namespace gfx { |
| @@ -46,6 +49,17 @@ TEST_F(CanvasTest, StringSizeEmptyString) { |
| EXPECT_GT(size.height(), 0); |
| } |
| +// Verifies GetClipBounds() returns the correct value. |
| +TEST_F(CanvasTest, ClipRectWithScaling) { |
| + Canvas canvas(gfx::Size(200, 100), 2.25, true); |
| + canvas.sk_canvas()->clipRect(RectFToSkRect(gfx::RectF(100, 0, 20, 1.7f))); |
|
danakj
2014/09/10 18:27:16
nit: 1.2 to show it's not just rounding?
sky
2014/09/10 18:29:51
Actually, the 1.2 isn't the interesting part here.
danakj
2014/09/10 18:32:13
Ooh didn't see the scaling, ok cool :)
|
| + gfx::Rect clip_rect; |
| + ASSERT_TRUE(canvas.GetClipBounds(&clip_rect)); |
| + // Use Contains() rather than Equals() as skia may extend the rect in certain |
| + // directions. None-the-less the clip must contain the region we damaged. |
| + EXPECT_TRUE(clip_rect.Contains(gfx::Rect(100, 0, 20, 2))); |
| +} |
| + |
| // Line height is only supported on Skia. |
| #if defined(OS_MACOSX) || defined(OS_ANDROID) |
| #define MAYBE_StringSizeWithLineHeight DISABLED_StringSizeWithLineHeight |