| OLD | NEW |
| 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 <memory> | 7 #include <memory> |
| 8 #include "core/dom/Document.h" | 8 #include "core/dom/Document.h" |
| 9 #include "core/frame/LocalFrameView.h" | 9 #include "core/frame/LocalFrameView.h" |
| 10 #include "core/testing/DummyPageHolder.h" | 10 #include "core/testing/DummyPageHolder.h" |
| 11 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
| 12 | 12 |
| 13 namespace blink { | 13 namespace blink { |
| 14 | 14 |
| 15 const int kViewportWidth = 500; | 15 const int kViewportWidth = 500; |
| 16 const int kViewportHeight = 600; | 16 const int kViewportHeight = 600; |
| 17 class HTMLImageElementTest : public testing::Test { | 17 class HTMLImageElementTest : public ::testing::Test { |
| 18 protected: | 18 protected: |
| 19 HTMLImageElementTest() | 19 HTMLImageElementTest() |
| 20 : dummy_page_holder_( | 20 : dummy_page_holder_( |
| 21 DummyPageHolder::Create(IntSize(kViewportWidth, kViewportHeight))) { | 21 DummyPageHolder::Create(IntSize(kViewportWidth, kViewportHeight))) { |
| 22 } | 22 } |
| 23 | 23 |
| 24 std::unique_ptr<DummyPageHolder> dummy_page_holder_; | 24 std::unique_ptr<DummyPageHolder> dummy_page_holder_; |
| 25 }; | 25 }; |
| 26 | 26 |
| 27 TEST_F(HTMLImageElementTest, width) { | 27 TEST_F(HTMLImageElementTest, width) { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 38 TEST_F(HTMLImageElementTest, sourceSize) { | 38 TEST_F(HTMLImageElementTest, sourceSize) { |
| 39 HTMLImageElement* image = HTMLImageElement::Create( | 39 HTMLImageElement* image = HTMLImageElement::Create( |
| 40 dummy_page_holder_->GetDocument(), /* createdByParser */ false); | 40 dummy_page_holder_->GetDocument(), /* createdByParser */ false); |
| 41 image->setAttribute(HTMLNames::widthAttr, "400"); | 41 image->setAttribute(HTMLNames::widthAttr, "400"); |
| 42 EXPECT_EQ(kViewportWidth, image->SourceSize(*image)); | 42 EXPECT_EQ(kViewportWidth, image->SourceSize(*image)); |
| 43 image->setAttribute(HTMLNames::sizesAttr, "50vw"); | 43 image->setAttribute(HTMLNames::sizesAttr, "50vw"); |
| 44 EXPECT_EQ(250, image->SourceSize(*image)); | 44 EXPECT_EQ(250, image->SourceSize(*image)); |
| 45 } | 45 } |
| 46 | 46 |
| 47 } // namespace blink | 47 } // namespace blink |
| OLD | NEW |