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

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

Issue 2080623002: Revert "Remove OwnPtr from Blink." (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/HTMLImageElement.h" 5 #include "core/html/HTMLImageElement.h"
6 6
7 #include "core/dom/Document.h" 7 #include "core/dom/Document.h"
8 #include "core/frame/FrameView.h" 8 #include "core/frame/FrameView.h"
9 #include "core/testing/DummyPageHolder.h" 9 #include "core/testing/DummyPageHolder.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
11 #include <memory>
12 11
13 namespace blink { 12 namespace blink {
14 13
15 const int viewportWidth = 500; 14 const int viewportWidth = 500;
16 const int viewportHeight = 600; 15 const int viewportHeight = 600;
17 class HTMLImageElementTest : public testing::Test { 16 class HTMLImageElementTest : public testing::Test {
18 protected: 17 protected:
19 HTMLImageElementTest() 18 HTMLImageElementTest()
20 : m_dummyPageHolder(DummyPageHolder::create(IntSize(viewportWidth, viewp ortHeight))) 19 : m_dummyPageHolder(DummyPageHolder::create(IntSize(viewportWidth, viewp ortHeight)))
21 { 20 {
22 } 21 }
23 22
24 std::unique_ptr<DummyPageHolder> m_dummyPageHolder; 23 OwnPtr<DummyPageHolder> m_dummyPageHolder;
25 }; 24 };
26 25
27 TEST_F(HTMLImageElementTest, width) 26 TEST_F(HTMLImageElementTest, width)
28 { 27 {
29 HTMLImageElement* image = HTMLImageElement::create(m_dummyPageHolder->docume nt(), nullptr, /* createdByParser */ false); 28 HTMLImageElement* image = HTMLImageElement::create(m_dummyPageHolder->docume nt(), nullptr, /* createdByParser */ false);
30 image->setAttribute(HTMLNames::widthAttr, "400"); 29 image->setAttribute(HTMLNames::widthAttr, "400");
31 // TODO(yoav): `width` does not impact resourceWidth until we resolve https: //github.com/ResponsiveImagesCG/picture-element/issues/268 30 // TODO(yoav): `width` does not impact resourceWidth until we resolve https: //github.com/ResponsiveImagesCG/picture-element/issues/268
32 EXPECT_EQ(500, image->getResourceWidth().width); 31 EXPECT_EQ(500, image->getResourceWidth().width);
33 image->setAttribute(HTMLNames::sizesAttr, "100vw"); 32 image->setAttribute(HTMLNames::sizesAttr, "100vw");
34 EXPECT_EQ(500, image->getResourceWidth().width); 33 EXPECT_EQ(500, image->getResourceWidth().width);
35 } 34 }
36 35
37 TEST_F(HTMLImageElementTest, sourceSize) 36 TEST_F(HTMLImageElementTest, sourceSize)
38 { 37 {
39 HTMLImageElement* image = HTMLImageElement::create(m_dummyPageHolder->docume nt(), nullptr, /* createdByParser */ false); 38 HTMLImageElement* image = HTMLImageElement::create(m_dummyPageHolder->docume nt(), nullptr, /* createdByParser */ false);
40 image->setAttribute(HTMLNames::widthAttr, "400"); 39 image->setAttribute(HTMLNames::widthAttr, "400");
41 EXPECT_EQ(viewportWidth, image->sourceSize(*image)); 40 EXPECT_EQ(viewportWidth, image->sourceSize(*image));
42 image->setAttribute(HTMLNames::sizesAttr, "50vw"); 41 image->setAttribute(HTMLNames::sizesAttr, "50vw");
43 EXPECT_EQ(250, image->sourceSize(*image)); 42 EXPECT_EQ(250, image->sourceSize(*image));
44 } 43 }
45 44
46 } // namespace blink 45 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/html/HTMLFormElement.h ('k') | third_party/WebKit/Source/core/html/HTMLImageFallbackHelper.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698