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

Side by Side Diff: third_party/WebKit/Source/core/layout/ImageQualityControllerTest.cpp

Issue 1482953002: Drop dependency on LayoutObject in fetch/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Compile fix 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "config.h" 5 #include "config.h"
6 #include "core/layout/ImageQualityController.h" 6 #include "core/layout/ImageQualityController.h"
7 7
8 #include "core/layout/LayoutImage.h" 8 #include "core/layout/LayoutImage.h"
9 #include "core/layout/LayoutTestHelper.h" 9 #include "core/layout/LayoutTestHelper.h"
10 #include "platform/graphics/GraphicsContext.h" 10 #include "platform/graphics/GraphicsContext.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 LayoutObject* obj = document().body()->firstChild()->layoutObject(); 43 LayoutObject* obj = document().body()->firstChild()->layoutObject();
44 44
45 EXPECT_EQ(InterpolationNone, controller()->chooseInterpolationQuality(nullpt r, obj, nullptr, nullptr, LayoutSize())); 45 EXPECT_EQ(InterpolationNone, controller()->chooseInterpolationQuality(nullpt r, obj, nullptr, nullptr, LayoutSize()));
46 } 46 }
47 47
48 #if !USE(LOW_QUALITY_IMAGE_INTERPOLATION) 48 #if !USE(LOW_QUALITY_IMAGE_INTERPOLATION)
49 49
50 class TestImageAnimated : public Image { 50 class TestImageAnimated : public Image {
51 public: 51 public:
52 bool maybeAnimated() override { return true; } 52 bool maybeAnimated() override { return true; }
53 bool currentFrameKnownToBeOpaque() override { return false; } 53 bool currentFrameKnownToBeOpaque(MetadataMode = UseCurrentMetadata) override { return false; }
54 IntSize size() const override { return IntSize(); } 54 IntSize size() const override { return IntSize(); }
55 void destroyDecodedData(bool) override { } 55 void destroyDecodedData(bool) override { }
56 void draw(SkCanvas*, const SkPaint&, const FloatRect& dstRect, const FloatRe ct& srcRect, RespectImageOrientationEnum, ImageClampingMode) override { } 56 void draw(SkCanvas*, const SkPaint&, const FloatRect& dstRect, const FloatRe ct& srcRect, RespectImageOrientationEnum, ImageClampingMode) override { }
57 PassRefPtr<SkImage> imageForCurrentFrame() override { return nullptr; } 57 PassRefPtr<SkImage> imageForCurrentFrame() override { return nullptr; }
58 }; 58 };
59 59
60 TEST_F(ImageQualityControllerTest, ImageMaybeAnimated) 60 TEST_F(ImageQualityControllerTest, ImageMaybeAnimated)
61 { 61 {
62 setBodyInnerHTML("<img src='myimage'></img>"); 62 setBodyInnerHTML("<img src='myimage'></img>");
63 LayoutImage* img = toLayoutImage(document().body()->firstChild()->layoutObje ct()); 63 LayoutImage* img = toLayoutImage(document().body()->firstChild()->layoutObje ct());
64 64
65 RefPtr<TestImageAnimated> testImage = adoptRef(new TestImageAnimated); 65 RefPtr<TestImageAnimated> testImage = adoptRef(new TestImageAnimated);
66 EXPECT_EQ(InterpolationMedium, controller()->chooseInterpolationQuality(null ptr, img, testImage.get(), nullptr, LayoutSize())); 66 EXPECT_EQ(InterpolationMedium, controller()->chooseInterpolationQuality(null ptr, img, testImage.get(), nullptr, LayoutSize()));
67 } 67 }
68 68
69 class TestImageWithContrast : public Image { 69 class TestImageWithContrast : public Image {
70 public: 70 public:
71 bool maybeAnimated() override { return true; } 71 bool maybeAnimated() override { return true; }
72 bool currentFrameKnownToBeOpaque() override { return false; } 72 bool currentFrameKnownToBeOpaque(MetadataMode = UseCurrentMetadata) override { return false; }
73 IntSize size() const override { return IntSize(); } 73 IntSize size() const override { return IntSize(); }
74 void destroyDecodedData(bool) override { } 74 void destroyDecodedData(bool) override { }
75 void draw(SkCanvas*, const SkPaint&, const FloatRect& dstRect, const FloatRe ct& srcRect, RespectImageOrientationEnum, ImageClampingMode) override { } 75 void draw(SkCanvas*, const SkPaint&, const FloatRect& dstRect, const FloatRe ct& srcRect, RespectImageOrientationEnum, ImageClampingMode) override { }
76 76
77 bool isBitmapImage() const override { return true; } 77 bool isBitmapImage() const override { return true; }
78 PassRefPtr<SkImage> imageForCurrentFrame() override { return nullptr; } 78 PassRefPtr<SkImage> imageForCurrentFrame() override { return nullptr; }
79 }; 79 };
80 80
81 TEST_F(ImageQualityControllerTest, LowQualityFilterForContrast) 81 TEST_F(ImageQualityControllerTest, LowQualityFilterForContrast)
82 { 82 {
83 setBodyInnerHTML("<img src='myimage' style='image-rendering: -webkit-optimiz e-contrast'></img>"); 83 setBodyInnerHTML("<img src='myimage' style='image-rendering: -webkit-optimiz e-contrast'></img>");
84 LayoutImage* img = toLayoutImage(document().body()->firstChild()->layoutObje ct()); 84 LayoutImage* img = toLayoutImage(document().body()->firstChild()->layoutObje ct());
85 85
86 RefPtr<TestImageWithContrast> testImage = adoptRef(new TestImageWithContrast ); 86 RefPtr<TestImageWithContrast> testImage = adoptRef(new TestImageWithContrast );
87 EXPECT_EQ(InterpolationLow, controller()->chooseInterpolationQuality(nullptr , img, testImage.get(), testImage.get(), LayoutSize())); 87 EXPECT_EQ(InterpolationLow, controller()->chooseInterpolationQuality(nullptr , img, testImage.get(), testImage.get(), LayoutSize()));
88 } 88 }
89 89
90 class TestImageLowQuality : public Image { 90 class TestImageLowQuality : public Image {
91 public: 91 public:
92 bool maybeAnimated() override { return true; } 92 bool maybeAnimated() override { return true; }
93 bool currentFrameKnownToBeOpaque() override { return false; } 93 bool currentFrameKnownToBeOpaque(MetadataMode = UseCurrentMetadata) override { return false; }
94 IntSize size() const override { return IntSize(1, 1); } 94 IntSize size() const override { return IntSize(1, 1); }
95 void destroyDecodedData(bool) override { } 95 void destroyDecodedData(bool) override { }
96 void draw(SkCanvas*, const SkPaint&, const FloatRect& dstRect, const FloatRe ct& srcRect, RespectImageOrientationEnum, ImageClampingMode) override { } 96 void draw(SkCanvas*, const SkPaint&, const FloatRect& dstRect, const FloatRe ct& srcRect, RespectImageOrientationEnum, ImageClampingMode) override { }
97 97
98 bool isBitmapImage() const override { return true; } 98 bool isBitmapImage() const override { return true; }
99 PassRefPtr<SkImage> imageForCurrentFrame() override { return nullptr; } 99 PassRefPtr<SkImage> imageForCurrentFrame() override { return nullptr; }
100 }; 100 };
101 101
102 TEST_F(ImageQualityControllerTest, MediumQualityFilterForUnscaledImage) 102 TEST_F(ImageQualityControllerTest, MediumQualityFilterForUnscaledImage)
103 { 103 {
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 EXPECT_FALSE(mockTimer->isActive()); 206 EXPECT_FALSE(mockTimer->isActive());
207 // Painted at the same size, so even though timer is still executing, don't go to low quality. 207 // Painted at the same size, so even though timer is still executing, don't go to low quality.
208 EXPECT_EQ(InterpolationLow, controller()->chooseInterpolationQuality(&contex t, img, testImage.get(), testImage.get(), LayoutSize(4, 4))); 208 EXPECT_EQ(InterpolationLow, controller()->chooseInterpolationQuality(&contex t, img, testImage.get(), testImage.get(), LayoutSize(4, 4)));
209 // Check that the timer was not kicked. It should not have been, since the i mage was painted at the same size as last time. 209 // Check that the timer was not kicked. It should not have been, since the i mage was painted at the same size as last time.
210 EXPECT_FALSE(mockTimer->isActive()); 210 EXPECT_FALSE(mockTimer->isActive());
211 } 211 }
212 212
213 #endif 213 #endif
214 214
215 } // namespace blink 215 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/fetch/ImageResource.cpp ('k') | third_party/WebKit/Source/core/layout/LayoutImage.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698