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

Unified Diff: third_party/WebKit/Source/core/layout/ImageQualityControllerTest.cpp

Issue 1512803004: Use refs for GraphicsContext (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@ScrollbarTheme
Patch Set: Created 5 years 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/core/layout/ImageQualityControllerTest.cpp
diff --git a/third_party/WebKit/Source/core/layout/ImageQualityControllerTest.cpp b/third_party/WebKit/Source/core/layout/ImageQualityControllerTest.cpp
index b53bf73f9175bd617e325284df93b95639111db8..ca9f861aceda423f0944ec8b40ad57ada29279c0 100644
--- a/third_party/WebKit/Source/core/layout/ImageQualityControllerTest.cpp
+++ b/third_party/WebKit/Source/core/layout/ImageQualityControllerTest.cpp
@@ -34,7 +34,7 @@ TEST_F(ImageQualityControllerTest, RegularImage)
setBodyInnerHTML("<img src='myimage'></img>");
LayoutObject* obj = document().body()->firstChild()->layoutObject();
- EXPECT_EQ(InterpolationDefault, controller()->chooseInterpolationQuality(nullptr, obj, nullptr, nullptr, LayoutSize()));
+ EXPECT_EQ(InterpolationDefault, controller()->chooseInterpolationQuality(*obj, nullptr, nullptr, LayoutSize()));
}
TEST_F(ImageQualityControllerTest, ImageRenderingPixelated)
@@ -42,7 +42,7 @@ TEST_F(ImageQualityControllerTest, ImageRenderingPixelated)
setBodyInnerHTML("<img src='myimage' style='image-rendering: pixelated'></img>");
LayoutObject* obj = document().body()->firstChild()->layoutObject();
- EXPECT_EQ(InterpolationNone, controller()->chooseInterpolationQuality(nullptr, obj, nullptr, nullptr, LayoutSize()));
+ EXPECT_EQ(InterpolationNone, controller()->chooseInterpolationQuality(*obj, nullptr, nullptr, LayoutSize()));
}
#if !USE(LOW_QUALITY_IMAGE_INTERPOLATION)
@@ -63,7 +63,7 @@ TEST_F(ImageQualityControllerTest, ImageMaybeAnimated)
LayoutImage* img = toLayoutImage(document().body()->firstChild()->layoutObject());
RefPtr<TestImageAnimated> testImage = adoptRef(new TestImageAnimated);
- EXPECT_EQ(InterpolationMedium, controller()->chooseInterpolationQuality(nullptr, img, testImage.get(), nullptr, LayoutSize()));
+ EXPECT_EQ(InterpolationMedium, controller()->chooseInterpolationQuality(*img, testImage.get(), nullptr, LayoutSize()));
}
class TestImageWithContrast : public Image {
@@ -84,7 +84,7 @@ TEST_F(ImageQualityControllerTest, LowQualityFilterForContrast)
LayoutImage* img = toLayoutImage(document().body()->firstChild()->layoutObject());
RefPtr<TestImageWithContrast> testImage = adoptRef(new TestImageWithContrast);
- EXPECT_EQ(InterpolationLow, controller()->chooseInterpolationQuality(nullptr, img, testImage.get(), testImage.get(), LayoutSize()));
+ EXPECT_EQ(InterpolationLow, controller()->chooseInterpolationQuality(*img, testImage.get(), testImage.get(), LayoutSize()));
}
class TestImageLowQuality : public Image {
@@ -105,9 +105,7 @@ TEST_F(ImageQualityControllerTest, MediumQualityFilterForUnscaledImage)
LayoutImage* img = toLayoutImage(document().body()->firstChild()->layoutObject());
RefPtr<TestImageLowQuality> testImage = adoptRef(new TestImageLowQuality);
- OwnPtr<PaintController> paintController = PaintController::create();
- GraphicsContext context(*paintController);
- EXPECT_EQ(InterpolationMedium, controller()->chooseInterpolationQuality(&context, img, testImage.get(), testImage.get(), LayoutSize(1, 1)));
+ EXPECT_EQ(InterpolationMedium, controller()->chooseInterpolationQuality(*img, testImage.get(), testImage.get(), LayoutSize(1, 1)));
}
class MockTimer : public Timer<ImageQualityController> {
@@ -133,28 +131,26 @@ TEST_F(ImageQualityControllerTest, LowQualityFilterForLiveResize)
LayoutImage* img = toLayoutImage(document().body()->firstChild()->layoutObject());
RefPtr<TestImageLowQuality> testImage = adoptRef(new TestImageLowQuality);
- OwnPtr<PaintController> paintController = PaintController::create();
- GraphicsContext context(*paintController);
// Start a resize
document().frame()->view()->willStartLiveResize();
- EXPECT_EQ(InterpolationLow, controller()->chooseInterpolationQuality(&context, img, testImage.get(), testImage.get(), LayoutSize(2, 2)));
+ EXPECT_EQ(InterpolationLow, controller()->chooseInterpolationQuality(*img, testImage.get(), testImage.get(), LayoutSize(2, 2)));
document().frame()->view()->willEndLiveResize();
// End of live resize, but timer has not fired. Therefore paint at non-low quality.
- EXPECT_EQ(InterpolationMedium, controller()->chooseInterpolationQuality(&context, img, testImage.get(), testImage.get(), LayoutSize(3, 3)));
+ EXPECT_EQ(InterpolationMedium, controller()->chooseInterpolationQuality(*img, testImage.get(), testImage.get(), LayoutSize(3, 3)));
// Start another resize
document().frame()->view()->willStartLiveResize();
- EXPECT_EQ(InterpolationLow, controller()->chooseInterpolationQuality(&context, img, testImage.get(), testImage.get(), LayoutSize(3, 3)));
+ EXPECT_EQ(InterpolationLow, controller()->chooseInterpolationQuality(*img, testImage.get(), testImage.get(), LayoutSize(3, 3)));
// While still in resize, expire the timer.
document().frame()->view()->willEndLiveResize();
mockTimer->fire();
// End of live resize, and timer has fired. Therefore paint at non-low quality, even though the size has changed.
- EXPECT_EQ(InterpolationMedium, controller()->chooseInterpolationQuality(&context, img, testImage.get(), testImage.get(), LayoutSize(4, 4)));
+ EXPECT_EQ(InterpolationMedium, controller()->chooseInterpolationQuality(*img, testImage.get(), testImage.get(), LayoutSize(4, 4)));
}
TEST_F(ImageQualityControllerTest, LowQualityFilterForResizingImage)
@@ -169,17 +165,17 @@ TEST_F(ImageQualityControllerTest, LowQualityFilterForResizingImage)
GraphicsContext context(*paintController);
// Paint once. This will kick off a timer to see if we resize it during that timer's execution.
- EXPECT_EQ(InterpolationMedium, controller()->chooseInterpolationQuality(&context, img, testImage.get(), testImage.get(), LayoutSize(2, 2)));
+ EXPECT_EQ(InterpolationMedium, controller()->chooseInterpolationQuality(*img, testImage.get(), testImage.get(), LayoutSize(2, 2)));
// Go into low-quality mode now that the size changed.
- EXPECT_EQ(InterpolationLow, controller()->chooseInterpolationQuality(&context, img, testImage.get(), testImage.get(), LayoutSize(3, 3)));
+ EXPECT_EQ(InterpolationLow, controller()->chooseInterpolationQuality(*img, testImage.get(), testImage.get(), LayoutSize(3, 3)));
// Stay in low-quality mode since the size changed again.
- EXPECT_EQ(InterpolationLow, controller()->chooseInterpolationQuality(&context, img, testImage.get(), testImage.get(), LayoutSize(4, 4)));
+ EXPECT_EQ(InterpolationLow, controller()->chooseInterpolationQuality(*img, testImage.get(), testImage.get(), LayoutSize(4, 4)));
mockTimer->fire();
// The timer fired before painting at another size, so this doesn't count as animation. Therefore not painting at low quality.
- EXPECT_EQ(InterpolationMedium, controller()->chooseInterpolationQuality(&context, img, testImage.get(), testImage.get(), LayoutSize(4, 4)));
+ EXPECT_EQ(InterpolationMedium, controller()->chooseInterpolationQuality(*img, testImage.get(), testImage.get(), LayoutSize(4, 4)));
}
TEST_F(ImageQualityControllerTest, DontKickTheAnimationTimerWhenPaintingAtTheSameSize)
@@ -190,22 +186,20 @@ TEST_F(ImageQualityControllerTest, DontKickTheAnimationTimerWhenPaintingAtTheSam
LayoutImage* img = toLayoutImage(document().body()->firstChild()->layoutObject());
RefPtr<TestImageLowQuality> testImage = adoptRef(new TestImageLowQuality);
- OwnPtr<PaintController> paintController = PaintController::create();
- GraphicsContext context(*paintController);
// Paint once. This will kick off a timer to see if we resize it during that timer's execution.
- EXPECT_EQ(InterpolationMedium, controller()->chooseInterpolationQuality(&context, img, testImage.get(), testImage.get(), LayoutSize(2, 2)));
+ EXPECT_EQ(InterpolationMedium, controller()->chooseInterpolationQuality(*img, testImage.get(), testImage.get(), LayoutSize(2, 2)));
// Go into low-quality mode now that the size changed.
- EXPECT_EQ(InterpolationLow, controller()->chooseInterpolationQuality(&context, img, testImage.get(), testImage.get(), LayoutSize(3, 3)));
+ EXPECT_EQ(InterpolationLow, controller()->chooseInterpolationQuality(*img, testImage.get(), testImage.get(), LayoutSize(3, 3)));
// Stay in low-quality mode since the size changed again.
- EXPECT_EQ(InterpolationLow, controller()->chooseInterpolationQuality(&context, img, testImage.get(), testImage.get(), LayoutSize(4, 4)));
+ EXPECT_EQ(InterpolationLow, controller()->chooseInterpolationQuality(*img, testImage.get(), testImage.get(), LayoutSize(4, 4)));
mockTimer->stop();
EXPECT_FALSE(mockTimer->isActive());
// Painted at the same size, so even though timer is still executing, don't go to low quality.
- EXPECT_EQ(InterpolationLow, controller()->chooseInterpolationQuality(&context, img, testImage.get(), testImage.get(), LayoutSize(4, 4)));
+ EXPECT_EQ(InterpolationLow, controller()->chooseInterpolationQuality(*img, testImage.get(), testImage.get(), LayoutSize(4, 4)));
// Check that the timer was not kicked. It should not have been, since the image was painted at the same size as last time.
EXPECT_FALSE(mockTimer->isActive());
}

Powered by Google App Engine
This is Rietveld 408576698