Replace custom functions with gfx::test::CreateBitmap and others
CreateBitmap, CreateImageSkia and CreateImage APIs are changed with a
new function overload to take a single size parameter. All of them are
also changed by adding an optional color parameter. Then, custom
functions used across the codebase are replaced with these functions.
Bug: 1497199
Change-Id: I5debbb8735215470b0206ef7bdd9c57977cb77d7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4863568
Reviewed-by: Daniel Cheng <[email protected]>
Reviewed-by: Sylvain Defresne <[email protected]>
Reviewed-by: James Cook <[email protected]>
Reviewed-by: Avi Drissman <[email protected]>
Commit-Queue: Henrique Ferreiro <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1232685}
diff --git a/ui/gfx/nine_image_painter_unittest.cc b/ui/gfx/nine_image_painter_unittest.cc
index 0e13d7c..c252fbc3 100644
--- a/ui/gfx/nine_image_painter_unittest.cc
+++ b/ui/gfx/nine_image_painter_unittest.cc
@@ -14,6 +14,7 @@
#include "ui/gfx/geometry/vector2d_conversions.h"
#include "ui/gfx/image/image_skia.h"
#include "ui/gfx/image/image_skia_rep.h"
+#include "ui/gfx/image/image_unittest_util.h"
namespace gfx {
@@ -66,9 +67,7 @@
}
TEST(NineImagePainterTest, PaintHighDPI) {
- SkBitmap src;
- src.allocN32Pixels(100, 100);
- src.eraseColor(SK_ColorRED);
+ SkBitmap src = gfx::test::CreateBitmap(/*size=*/100, SK_ColorRED);
src.eraseArea(SkIRect::MakeXYWH(10, 10, 80, 80), SK_ColorGREEN);
float image_scale = 2.f;
@@ -100,9 +99,7 @@
// The NineImagePainter should not paint outside the bounds.
// The border images should be cropped, but still painted.
- SkBitmap src;
- src.allocN32Pixels(6, 6);
- src.eraseColor(SK_ColorGREEN);
+ SkBitmap src = gfx::test::CreateBitmap(/*size=*/6, SK_ColorGREEN);
src.erase(SK_ColorRED, SkIRect::MakeXYWH(2, 2, 2, 2));
gfx::ImageSkia image = gfx::ImageSkia::CreateFrom1xBitmap(src);
@@ -132,9 +129,7 @@
}
TEST(NineImagePainterTest, PaintWithBoundOffset) {
- SkBitmap src;
- src.allocN32Pixels(10, 10);
- src.eraseColor(SK_ColorRED);
+ SkBitmap src = gfx::test::CreateBitmap(/*size=*/10, SK_ColorRED);
src.eraseArea(SkIRect::MakeXYWH(1, 1, 8, 8), SK_ColorGREEN);
gfx::ImageSkia image = gfx::ImageSkia::CreateFrom1xBitmap(src);
@@ -162,9 +157,7 @@
}
TEST(NineImagePainterTest, PaintWithScale) {
- SkBitmap src;
- src.allocN32Pixels(100, 100);
- src.eraseColor(SK_ColorRED);
+ SkBitmap src = gfx::test::CreateBitmap(/*size=*/100, SK_ColorRED);
src.eraseArea(SkIRect::MakeXYWH(10, 10, 80, 80), SK_ColorGREEN);
float image_scale = 2.f;
@@ -193,9 +186,7 @@
}
TEST(NineImagePainterTest, PaintWithNegativeScale) {
- SkBitmap src;
- src.allocN32Pixels(100, 100);
- src.eraseColor(SK_ColorRED);
+ SkBitmap src = gfx::test::CreateBitmap(/*size=*/100, SK_ColorRED);
src.eraseArea(SkIRect::MakeXYWH(10, 10, 80, 80), SK_ColorGREEN);
float image_scale = 2.f;