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

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

Issue 196743002: Parse the link element's size attribute (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Addressed comments Created 6 years, 9 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
OLDNEW
(Empty)
1 /*
2 * Copyright 2014, Google Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above
11 * copyright notice, this list of conditions and the following disclaimer
12 * in the documentation and/or other materials provided with the
13 * distribution.
14 * * Neither the name of Google Inc. nor the names of its
15 * contributors may be used to endorse or promote products derived from
16 * this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31 #include "config.h"
32 #include "core/html/HTMLLinkElement.h"
33
34 #include <gtest/gtest.h>
35
36 using namespace WebCore;
37
38 namespace {
39
40 class HTMLLinkElementSizesAttributeTest : public testing::Test {
41 };
42
43 TEST(HTMLLinkElementSizesAttributeTest, parseSizes)
44 {
45 AtomicString sizesAttribute = "32x33";
46 Vector<IntSize> sizes;
47 HTMLLinkElement::parseSizesAttribute(sizesAttribute, &sizes);
48 ASSERT_EQ(1U, sizes.size());
49 EXPECT_EQ(32, sizes[0].width());
50 EXPECT_EQ(33, sizes[0].height());
51
52 sizesAttribute = " 32x33 16X17 128x129 ";
53 sizes.clear();
54 HTMLLinkElement::parseSizesAttribute(sizesAttribute, &sizes);
55 ASSERT_EQ(3U, sizes.size());
56 EXPECT_EQ(32, sizes[0].width());
57 EXPECT_EQ(33, sizes[0].height());
58 EXPECT_EQ(16, sizes[1].width());
59 EXPECT_EQ(17, sizes[1].height());
60 EXPECT_EQ(128, sizes[2].width());
61 EXPECT_EQ(129, sizes[2].height());
62
63 sizesAttribute = "any";
64 sizes.clear();
65 HTMLLinkElement::parseSizesAttribute(sizesAttribute, &sizes);
66 ASSERT_EQ(0U, sizes.size());
67
68 sizesAttribute = "32x33 32";
69 sizes.clear();
70 HTMLLinkElement::parseSizesAttribute(sizesAttribute, &sizes);
71 ASSERT_EQ(0U, sizes.size());
72
73 sizesAttribute = "32x33 32x";
74 sizes.clear();
75 HTMLLinkElement::parseSizesAttribute(sizesAttribute, &sizes);
76 ASSERT_EQ(0U, sizes.size());
77
78 sizesAttribute = "32x33 x32";
79 sizes.clear();
80 HTMLLinkElement::parseSizesAttribute(sizesAttribute, &sizes);
81 ASSERT_EQ(0U, sizes.size());
82
83 sizesAttribute = "32x33 any";
84 sizes.clear();
85 HTMLLinkElement::parseSizesAttribute(sizesAttribute, &sizes);
86 ASSERT_EQ(0U, sizes.size());
87
88 sizesAttribute = "32x33, 64x64";
89 sizes.clear();
90 HTMLLinkElement::parseSizesAttribute(sizesAttribute, &sizes);
91 ASSERT_EQ(0U, sizes.size());
92 }
93
94 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698