Chromium Code Reviews| 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 class HTMLImageElementTest : public testing::Test { | |
| 16 protected: | |
| 17 HTMLImageElementTest() | |
| 18 : m_dummyPageHolder(DummyPageHolder::create(IntSize(500, 600))) | |
| 19 { | |
| 20 } | |
| 21 | |
| 22 OwnPtr<DummyPageHolder> m_dummyPageHolder; | |
| 23 }; | |
| 24 | |
| 25 TEST_F(HTMLImageElementTest, width) | |
| 26 { | |
| 27 RefPtrWillBeRawPtr<HTMLImageElement> image = HTMLImageElement::create(m_dumm yPageHolder->document(), nullptr, /* createdByParser */ false); | |
| 28 image->setAttribute(HTMLNames::widthAttr, "400"); | |
| 29 EXPECT_EQ(400, image->resourceWidth().width); | |
| 30 image->setAttribute(HTMLNames::sizesAttr, "100vw"); | |
| 31 EXPECT_EQ(500, image->resourceWidth().width); | |
|
Mike West
2015/06/18 14:44:49
Maybe make this a const along with the page's widt
| |
| 32 } | |
| 33 | |
| 34 TEST_F(HTMLImageElementTest, sourceSize) | |
| 35 { | |
| 36 RefPtrWillBeRawPtr<HTMLImageElement> image = HTMLImageElement::create(m_dumm yPageHolder->document(), nullptr, /* createdByParser */ false); | |
| 37 image->setAttribute(HTMLNames::widthAttr, "400"); | |
| 38 EXPECT_EQ(500, image->sourceSize(*image)); | |
| 39 image->setAttribute(HTMLNames::sizesAttr, "50vw"); | |
| 40 EXPECT_EQ(250, image->sourceSize(*image)); | |
| 41 } | |
| 42 | |
| 43 } // namespace blink | |
| OLD | NEW |