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

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

Issue 1186333004: Add support for `width` based Width Client Hint (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Review comments Created 5 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
« no previous file with comments | « Source/core/html/HTMLImageElement.cpp ('k') | Source/core/html/parser/HTMLPreloadScanner.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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
OLDNEW
« no previous file with comments | « Source/core/html/HTMLImageElement.cpp ('k') | Source/core/html/parser/HTMLPreloadScanner.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698