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

Unified Diff: third_party/WebKit/Source/platform/graphics/BitmapImageTest.cpp

Issue 1610883002: Oilpan: ImageObserver needs to be a GC mixin. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: unit test compile fix Created 4 years, 11 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
Index: third_party/WebKit/Source/platform/graphics/BitmapImageTest.cpp
diff --git a/third_party/WebKit/Source/platform/graphics/BitmapImageTest.cpp b/third_party/WebKit/Source/platform/graphics/BitmapImageTest.cpp
index 77e90017d67b4d99bca048bc73bed48ad3ca5262..169e8725d20bb3a5331a06dd1b696fd6dd3f30c0 100644
--- a/third_party/WebKit/Source/platform/graphics/BitmapImageTest.cpp
+++ b/third_party/WebKit/Source/platform/graphics/BitmapImageTest.cpp
@@ -40,7 +40,8 @@ namespace blink {
class BitmapImageTest : public ::testing::Test {
public:
- class FakeImageObserver : public ImageObserver {
+ class FakeImageObserver : public NoBaseWillBeGarbageCollectedFinalized<FakeImageObserver>, public ImageObserver {
+ WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(FakeImageObserver);
public:
FakeImageObserver() : m_lastDecodedSizeChangedDelta(0) { }
@@ -121,10 +122,11 @@ protected:
void SetUp() override
{
DeferredImageDecoder::setEnabled(m_enableDeferredDecoding);
- m_image = BitmapImage::create(&m_imageObserver);
+ m_imageObserver = adoptPtrWillBeNoop(new FakeImageObserver);
+ m_image = BitmapImage::create(m_imageObserver.get());
}
- FakeImageObserver m_imageObserver;
+ OwnPtrWillBePersistent<FakeImageObserver> m_imageObserver;
RefPtr<BitmapImage> m_image;
private:
@@ -139,8 +141,8 @@ TEST_F(BitmapImageTest, destroyDecodedDataExceptCurrentFrame)
setCurrentFrame(frame);
size_t size = frameDecodedSize(frame);
destroyDecodedData(false);
- EXPECT_LT(m_imageObserver.m_lastDecodedSizeChangedDelta, 0);
- EXPECT_GE(m_imageObserver.m_lastDecodedSizeChangedDelta, -static_cast<int>(totalSize - size));
+ EXPECT_LT(m_imageObserver->m_lastDecodedSizeChangedDelta, 0);
+ EXPECT_GE(m_imageObserver->m_lastDecodedSizeChangedDelta, -static_cast<int>(totalSize - size));
}
TEST_F(BitmapImageTest, destroyAllDecodedData)
@@ -149,7 +151,7 @@ TEST_F(BitmapImageTest, destroyAllDecodedData)
size_t totalSize = decodedSize();
EXPECT_GT(totalSize, 0u);
destroyDecodedData(true);
- EXPECT_EQ(-static_cast<int>(totalSize), m_imageObserver.m_lastDecodedSizeChangedDelta);
+ EXPECT_EQ(-static_cast<int>(totalSize), m_imageObserver->m_lastDecodedSizeChangedDelta);
EXPECT_EQ(0u, decodedSize());
}
@@ -235,14 +237,14 @@ TEST_F(BitmapImageTest, correctDecodedDataSize)
loadImage("/LayoutTests/fast/images/resources/anim_none.gif", false);
frameAtIndex(1);
int frameSize = static_cast<int>(m_image->size().area() * sizeof(ImageFrame::PixelData));
- EXPECT_EQ(frameSize * 2, m_imageObserver.m_lastDecodedSizeChangedDelta);
+ EXPECT_EQ(frameSize * 2, m_imageObserver->m_lastDecodedSizeChangedDelta);
// Trying to destroy all data except an undecoded frame should cause the
// decoder to seek backwards and preserve the most recent previous frame
// necessary to decode that undecoded frame, and destroy all other frames.
setCurrentFrame(2);
destroyDecodedData(false);
- EXPECT_EQ(-frameSize, m_imageObserver.m_lastDecodedSizeChangedDelta);
+ EXPECT_EQ(-frameSize, m_imageObserver->m_lastDecodedSizeChangedDelta);
}
class BitmapImageDeferredDecodingTest : public BitmapImageTest {
@@ -257,14 +259,14 @@ TEST_F(BitmapImageDeferredDecodingTest, correctDecodedDataSize)
loadImage("/LayoutTests/fast/images/resources/anim_none.gif", false);
frameAtIndex(1);
int frameSize = static_cast<int>(m_image->size().area() * sizeof(ImageFrame::PixelData));
- EXPECT_EQ(frameSize, m_imageObserver.m_lastDecodedSizeChangedDelta);
+ EXPECT_EQ(frameSize, m_imageObserver->m_lastDecodedSizeChangedDelta);
frameAtIndex(0);
// Trying to destroy all data except an undecoded frame should go ahead and
// destroy all other frames.
setCurrentFrame(2);
destroyDecodedData(false);
- EXPECT_EQ(-frameSize * 2, m_imageObserver.m_lastDecodedSizeChangedDelta);
+ EXPECT_EQ(-frameSize * 2, m_imageObserver->m_lastDecodedSizeChangedDelta);
}
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698