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

Unified Diff: ui/gfx/nine_image_painter_unittest.cc

Issue 1365503007: Make NineImagePainter stay within the bounds rect. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: exclude border if not enough room for it Created 5 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/nine_image_painter.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/nine_image_painter_unittest.cc
diff --git a/ui/gfx/nine_image_painter_unittest.cc b/ui/gfx/nine_image_painter_unittest.cc
index 1bece36212d5fa22a9881ab1e731591e91959bda..6b2f10aee772d39c77f94e9ff103a1468fec6a70 100644
--- a/ui/gfx/nine_image_painter_unittest.cc
+++ b/ui/gfx/nine_image_painter_unittest.cc
@@ -66,4 +66,41 @@ TEST(NineImagePainterTest, PaintScale) {
}
}
+TEST(NineImagePainterTest, PaintStaysInBounds) {
+ // In this test the bounds rect is 1x1 but each image is 2x2.
+ // The NineImagePainter should not paint outside the bounds.
+
+ SkBitmap src;
+ src.allocN32Pixels(6, 6);
+ src.eraseColor(SK_ColorRED);
+
+ gfx::ImageSkia image(gfx::ImageSkiaRep(src, 0.0f));
+ gfx::Insets insets(2, 2, 2, 2);
+ gfx::NineImagePainter painter(image, insets);
+
+ int image_scale = 1;
+ bool is_opaque = true;
+ gfx::Canvas canvas(gfx::Size(3, 3), image_scale, is_opaque);
+ canvas.DrawColor(SK_ColorBLACK);
+
+ gfx::Rect bounds(1, 1, 1, 1);
+ painter.Paint(&canvas, bounds);
+
+ SkBitmap result;
+ const SkISize size = canvas.sk_canvas()->getDeviceSize();
+ result.allocN32Pixels(size.width(), size.height());
+ canvas.sk_canvas()->readPixels(&result, 0, 0);
+
+ EXPECT_EQ(SK_ColorRED, result.getColor(1, 1));
+
+ EXPECT_EQ(SK_ColorBLACK, result.getColor(0, 0));
+ EXPECT_EQ(SK_ColorBLACK, result.getColor(0, 1));
+ EXPECT_EQ(SK_ColorBLACK, result.getColor(0, 2));
+ EXPECT_EQ(SK_ColorBLACK, result.getColor(1, 0));
+ EXPECT_EQ(SK_ColorBLACK, result.getColor(1, 2));
+ EXPECT_EQ(SK_ColorBLACK, result.getColor(2, 0));
+ EXPECT_EQ(SK_ColorBLACK, result.getColor(2, 1));
+ EXPECT_EQ(SK_ColorBLACK, result.getColor(2, 2));
+}
+
} // namespace gfx
« no previous file with comments | « ui/gfx/nine_image_painter.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698