| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "config.h" |
| 6 #include "core/html/HTMLImageElement.h" |
| 7 |
| 8 #include "core/dom/Document.h" |
| 9 #include "core/frame/FrameView.h" |
| 10 #include "core/testing/DummyPageHolder.h" |
| 11 #include <gtest/gtest.h> |
| 12 |
| 13 namespace blink { |
| 14 |
| 15 const int viewportWidth = 500; |
| 16 const int viewportHeight = 600; |
| 17 class HTMLImageElementTest : public testing::Test { |
| 18 protected: |
| 19 HTMLImageElementTest() |
| 20 : m_dummyPageHolder(DummyPageHolder::create(IntSize(viewportWidth, viewp
ortHeight))) |
| 21 { |
| 22 } |
| 23 |
| 24 OwnPtr<DummyPageHolder> m_dummyPageHolder; |
| 25 }; |
| 26 |
| 27 TEST_F(HTMLImageElementTest, width) |
| 28 { |
| 29 RefPtrWillBeRawPtr<HTMLImageElement> image = HTMLImageElement::create(m_dumm
yPageHolder->document(), nullptr, /* createdByParser */ false); |
| 30 image->setAttribute(HTMLNames::widthAttr, "400"); |
| 31 EXPECT_EQ(400, image->resourceWidth().width); |
| 32 image->setAttribute(HTMLNames::sizesAttr, "100vw"); |
| 33 EXPECT_EQ(500, image->resourceWidth().width); |
| 34 } |
| 35 |
| 36 TEST_F(HTMLImageElementTest, sourceSize) |
| 37 { |
| 38 RefPtrWillBeRawPtr<HTMLImageElement> image = HTMLImageElement::create(m_dumm
yPageHolder->document(), nullptr, /* createdByParser */ false); |
| 39 image->setAttribute(HTMLNames::widthAttr, "400"); |
| 40 EXPECT_EQ(viewportWidth, image->sourceSize(*image)); |
| 41 image->setAttribute(HTMLNames::sizesAttr, "50vw"); |
| 42 EXPECT_EQ(250, image->sourceSize(*image)); |
| 43 } |
| 44 |
| 45 } // namespace blink |
| OLD | NEW |