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

Unified Diff: ui/gfx/image/image_skia_unittest.cc

Issue 285393002: Fixes use-of-uninitialized-value MSan error in image_skia_unittest (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/image/image_skia_unittest.cc
diff --git a/ui/gfx/image/image_skia_unittest.cc b/ui/gfx/image/image_skia_unittest.cc
index 15337a863a9d34dfffbd05bf44e6999065057a0d..f4f63cf7a5a393ecd8e5b0e15b832ae12c5144e3 100644
--- a/ui/gfx/image/image_skia_unittest.cc
+++ b/ui/gfx/image/image_skia_unittest.cc
@@ -9,9 +9,11 @@
#include "base/threading/simple_thread.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/skia/include/core/SkBitmap.h"
+#include "ui/gfx/canvas.h"
+#include "ui/gfx/geometry/rect.h"
+#include "ui/gfx/geometry/size.h"
#include "ui/gfx/image/image_skia_rep.h"
#include "ui/gfx/image/image_skia_source.h"
-#include "ui/gfx/size.h"
#include "ui/gfx/switches.h"
// Duplicated from base/threading/non_thread_safe.h so that we can be
@@ -54,7 +56,11 @@ class DynamicSource : public ImageSkiaSource {
virtual ImageSkiaRep GetImageForScale(float scale) OVERRIDE {
last_requested_scale_ = scale;
- return gfx::ImageSkiaRep(size_, scale);
oshima 2014/05/15 16:14:13 this constructor is used in other tests (and only
Jun Mukai 2014/05/16 01:57:33 Done.
+ // The returned image can be resized in ImageSkiaStorage, so
+ // empty ImageSkiaRep could cause use-of-uninitialized-value.
+ gfx::Canvas canvas(size_, scale, true);
+ canvas.FillRect(Rect(size_), SK_ColorRED);
+ return canvas.ExtractImageRep();
}
float GetLastRequestedScaleAndReset() {
@@ -504,8 +510,9 @@ TEST_F(ImageSkiaTest, ArbitraryScaleFactorWithMissingResource) {
if (!ImageSkia::IsDSFScalingInImageSkiaEnabled())
return;
- ImageSkia image(new FixedSource(
- ImageSkiaRep(Size(100, 200), 1.0f)), Size(100, 200));
+ Canvas canvas(Size(100, 200), 1.0f, false);
+ canvas.FillRect(Rect(0, 0, 100, 200), SK_ColorRED);
+ ImageSkia image(new FixedSource(canvas.ExtractImageRep()), Size(100, 200));
// Requesting 1.5f -- falls back to 2.0f, but couldn't find. It should
// look up 1.0f and then rescale it.
@@ -525,8 +532,11 @@ TEST_F(ImageSkiaTest, UnscaledImageForArbitraryScaleFactor) {
return;
// 0.0f means unscaled.
+ Canvas canvas(Size(100, 200), 1.0f, false);
+ canvas.FillRect(Rect(0, 0, 100, 200), SK_ColorRED);
+ ImageSkiaRep origin_rep = canvas.ExtractImageRep();
ImageSkia image(new FixedSource(
- ImageSkiaRep(Size(100, 200), 0.0f)), Size(100, 200));
+ ImageSkiaRep(origin_rep.sk_bitmap(), 0.0f)), Size(100, 200));
// Requesting 2.0f, which should return 1.0f unscaled image.
const ImageSkiaRep& rep = image.GetRepresentation(2.0f);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698