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

Side by Side Diff: third_party/WebKit/Source/core/html/ImageDocumentTest.cpp

Issue 2647633004: [Blink] Don't center images in Android WebViews (Closed)
Patch Set: Created 3 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 unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/core/html/ImageDocument.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "core/html/ImageDocument.h" 5 #include "core/html/ImageDocument.h"
6 6
7 #include "core/dom/Document.h" 7 #include "core/dom/Document.h"
8 #include "core/dom/DocumentParser.h" 8 #include "core/dom/DocumentParser.h"
9 #include "core/frame/Settings.h"
9 #include "core/loader/EmptyClients.h" 10 #include "core/loader/EmptyClients.h"
10 #include "core/testing/DummyPageHolder.h" 11 #include "core/testing/DummyPageHolder.h"
11 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
12 13
13 namespace blink { 14 namespace blink {
14 15
15 namespace { 16 namespace {
16 17
17 // An image of size 50x50. 18 // An image of size 50x50.
18 Vector<unsigned char> jpegImage() { 19 Vector<unsigned char> jpegImage() {
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 } 176 }
176 177
177 TEST_F(ImageDocumentTest, ImageScalesDownWithDsf) { 178 TEST_F(ImageDocumentTest, ImageScalesDownWithDsf) {
178 createDocumentWithoutLoadingImage(20, 30); 179 createDocumentWithoutLoadingImage(20, 30);
179 setWindowToViewportScalingFactor(2.f); 180 setWindowToViewportScalingFactor(2.f);
180 loadImage(); 181 loadImage();
181 EXPECT_EQ(10, imageWidth()); 182 EXPECT_EQ(10, imageWidth());
182 EXPECT_EQ(10, imageHeight()); 183 EXPECT_EQ(10, imageHeight());
183 } 184 }
184 185
186 TEST_F(ImageDocumentTest, ImageNotCenteredWithForceZeroLayoutHeight) {
187 createDocumentWithoutLoadingImage(80, 70);
188 document().page()->settings().setForceZeroLayoutHeight(true);
189 loadImage();
190 EXPECT_FALSE(document().shouldShrinkToFit());
191 EXPECT_EQ(0, document().imageElement()->offsetLeft());
192 EXPECT_EQ(0, document().imageElement()->offsetTop());
193 EXPECT_EQ(50, imageWidth());
194 EXPECT_EQ(50, imageHeight());
195 }
196
197 TEST_F(ImageDocumentTest, ImageCenteredWithoutForceZeroLayoutHeight) {
198 createDocumentWithoutLoadingImage(80, 70);
199 document().page()->settings().setForceZeroLayoutHeight(false);
200 loadImage();
201 EXPECT_TRUE(document().shouldShrinkToFit());
202 EXPECT_EQ(15, document().imageElement()->offsetLeft());
203 EXPECT_EQ(10, document().imageElement()->offsetTop());
204 EXPECT_EQ(50, imageWidth());
205 EXPECT_EQ(50, imageHeight());
206 }
207
185 } // namespace blink 208 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/html/ImageDocument.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698