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

Unified Diff: ui/gfx/canvas_unittest.cc

Issue 557953004: Makes GetClipBounds() return the enclosing rect (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/gfx/canvas.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « ui/gfx/canvas.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698