Chromium Code Reviews| Index: Source/core/html/HTMLImageElementTest.cpp |
| diff --git a/Source/core/html/HTMLImageElementTest.cpp b/Source/core/html/HTMLImageElementTest.cpp |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..38ca77fd78dc7ee569471663b107029bd243a928 |
| --- /dev/null |
| +++ b/Source/core/html/HTMLImageElementTest.cpp |
| @@ -0,0 +1,43 @@ |
| +// Copyright 2015 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "config.h" |
| +#include "core/html/HTMLImageElement.h" |
| + |
| +#include "core/dom/Document.h" |
| +#include "core/frame/FrameView.h" |
| +#include "core/testing/DummyPageHolder.h" |
| +#include <gtest/gtest.h> |
| + |
| +namespace blink { |
| + |
| +class HTMLImageElementTest : public testing::Test { |
| +protected: |
| + HTMLImageElementTest() |
| + : m_dummyPageHolder(DummyPageHolder::create(IntSize(500, 600))) |
| + { |
| + } |
| + |
| + OwnPtr<DummyPageHolder> m_dummyPageHolder; |
| +}; |
| + |
| +TEST_F(HTMLImageElementTest, width) |
| +{ |
| + RefPtrWillBeRawPtr<HTMLImageElement> image = HTMLImageElement::create(m_dummyPageHolder->document(), nullptr, /* createdByParser */ false); |
| + image->setAttribute(HTMLNames::widthAttr, "400"); |
| + EXPECT_EQ(400, image->resourceWidth().width); |
| + image->setAttribute(HTMLNames::sizesAttr, "100vw"); |
| + 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
|
| +} |
| + |
| +TEST_F(HTMLImageElementTest, sourceSize) |
| +{ |
| + RefPtrWillBeRawPtr<HTMLImageElement> image = HTMLImageElement::create(m_dummyPageHolder->document(), nullptr, /* createdByParser */ false); |
| + image->setAttribute(HTMLNames::widthAttr, "400"); |
| + EXPECT_EQ(500, image->sourceSize(*image)); |
| + image->setAttribute(HTMLNames::sizesAttr, "50vw"); |
| + EXPECT_EQ(250, image->sourceSize(*image)); |
| +} |
| + |
| +} // namespace blink |