Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 /* | |
| 2 * Copyright 2014, Google Inc. All rights reserved. | |
|
Inactive
2014/03/14 20:36:18
Please use new license HEADER:
http://www.chromium
michaelbai
2014/03/14 20:49:06
Done.
| |
| 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 UChar attribute[] = {'3', '2', 'x', '3', '3', 0}; | |
| 53 sizesAttribute = attribute; | |
| 54 sizes.clear(); | |
| 55 HTMLLinkElement::parseSizesAttribute(sizesAttribute, sizes); | |
| 56 ASSERT_EQ(1U, sizes.size()); | |
| 57 EXPECT_EQ(32, sizes[0].width()); | |
| 58 EXPECT_EQ(33, sizes[0].height()); | |
| 59 | |
| 60 | |
| 61 sizesAttribute = " 32x33 16X17 128x129 "; | |
| 62 sizes.clear(); | |
| 63 HTMLLinkElement::parseSizesAttribute(sizesAttribute, sizes); | |
| 64 ASSERT_EQ(3U, sizes.size()); | |
| 65 EXPECT_EQ(32, sizes[0].width()); | |
| 66 EXPECT_EQ(33, sizes[0].height()); | |
| 67 EXPECT_EQ(16, sizes[1].width()); | |
| 68 EXPECT_EQ(17, sizes[1].height()); | |
| 69 EXPECT_EQ(128, sizes[2].width()); | |
| 70 EXPECT_EQ(129, sizes[2].height()); | |
| 71 | |
| 72 sizesAttribute = "any"; | |
| 73 sizes.clear(); | |
| 74 HTMLLinkElement::parseSizesAttribute(sizesAttribute, sizes); | |
| 75 ASSERT_EQ(0U, sizes.size()); | |
| 76 | |
| 77 sizesAttribute = "32x33 32"; | |
| 78 sizes.clear(); | |
| 79 HTMLLinkElement::parseSizesAttribute(sizesAttribute, sizes); | |
| 80 ASSERT_EQ(0U, sizes.size()); | |
| 81 | |
| 82 sizesAttribute = "32x33 32x"; | |
| 83 sizes.clear(); | |
| 84 HTMLLinkElement::parseSizesAttribute(sizesAttribute, sizes); | |
| 85 ASSERT_EQ(0U, sizes.size()); | |
| 86 | |
| 87 sizesAttribute = "32x33 x32"; | |
| 88 sizes.clear(); | |
| 89 HTMLLinkElement::parseSizesAttribute(sizesAttribute, sizes); | |
| 90 ASSERT_EQ(0U, sizes.size()); | |
| 91 | |
| 92 sizesAttribute = "32x33 any"; | |
| 93 sizes.clear(); | |
| 94 HTMLLinkElement::parseSizesAttribute(sizesAttribute, sizes); | |
| 95 ASSERT_EQ(0U, sizes.size()); | |
| 96 | |
| 97 sizesAttribute = "32x33, 64x64"; | |
| 98 sizes.clear(); | |
| 99 HTMLLinkElement::parseSizesAttribute(sizesAttribute, sizes); | |
| 100 ASSERT_EQ(0U, sizes.size()); | |
| 101 } | |
| 102 | |
| 103 } // namespace | |
| OLD | NEW |