OLD | NEW |
(Empty) | |
| 1 // Copyright 2014 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/HTMLLinkElement.h" |
| 7 |
| 8 #include <gtest/gtest.h> |
| 9 |
| 10 using namespace WebCore; |
| 11 |
| 12 namespace { |
| 13 |
| 14 class HTMLLinkElementSizesAttributeTest : public testing::Test { |
| 15 }; |
| 16 |
| 17 TEST(HTMLLinkElementSizesAttributeTest, parseSizes) |
| 18 { |
| 19 AtomicString sizesAttribute = "32x33"; |
| 20 Vector<IntSize> sizes; |
| 21 HTMLLinkElement::parseSizesAttribute(sizesAttribute, sizes); |
| 22 ASSERT_EQ(1U, sizes.size()); |
| 23 EXPECT_EQ(32, sizes[0].width()); |
| 24 EXPECT_EQ(33, sizes[0].height()); |
| 25 |
| 26 UChar attribute[] = {'3', '2', 'x', '3', '3', 0}; |
| 27 sizesAttribute = attribute; |
| 28 sizes.clear(); |
| 29 HTMLLinkElement::parseSizesAttribute(sizesAttribute, sizes); |
| 30 ASSERT_EQ(1U, sizes.size()); |
| 31 EXPECT_EQ(32, sizes[0].width()); |
| 32 EXPECT_EQ(33, sizes[0].height()); |
| 33 |
| 34 |
| 35 sizesAttribute = " 32x33 16X17 128x129 "; |
| 36 sizes.clear(); |
| 37 HTMLLinkElement::parseSizesAttribute(sizesAttribute, sizes); |
| 38 ASSERT_EQ(3U, sizes.size()); |
| 39 EXPECT_EQ(32, sizes[0].width()); |
| 40 EXPECT_EQ(33, sizes[0].height()); |
| 41 EXPECT_EQ(16, sizes[1].width()); |
| 42 EXPECT_EQ(17, sizes[1].height()); |
| 43 EXPECT_EQ(128, sizes[2].width()); |
| 44 EXPECT_EQ(129, sizes[2].height()); |
| 45 |
| 46 sizesAttribute = "any"; |
| 47 sizes.clear(); |
| 48 HTMLLinkElement::parseSizesAttribute(sizesAttribute, sizes); |
| 49 ASSERT_EQ(0U, sizes.size()); |
| 50 |
| 51 sizesAttribute = "32x33 32"; |
| 52 sizes.clear(); |
| 53 HTMLLinkElement::parseSizesAttribute(sizesAttribute, sizes); |
| 54 ASSERT_EQ(0U, sizes.size()); |
| 55 |
| 56 sizesAttribute = "32x33 32x"; |
| 57 sizes.clear(); |
| 58 HTMLLinkElement::parseSizesAttribute(sizesAttribute, sizes); |
| 59 ASSERT_EQ(0U, sizes.size()); |
| 60 |
| 61 sizesAttribute = "32x33 x32"; |
| 62 sizes.clear(); |
| 63 HTMLLinkElement::parseSizesAttribute(sizesAttribute, sizes); |
| 64 ASSERT_EQ(0U, sizes.size()); |
| 65 |
| 66 sizesAttribute = "32x33 any"; |
| 67 sizes.clear(); |
| 68 HTMLLinkElement::parseSizesAttribute(sizesAttribute, sizes); |
| 69 ASSERT_EQ(0U, sizes.size()); |
| 70 |
| 71 sizesAttribute = "32x33, 64x64"; |
| 72 sizes.clear(); |
| 73 HTMLLinkElement::parseSizesAttribute(sizesAttribute, sizes); |
| 74 ASSERT_EQ(0U, sizes.size()); |
| 75 } |
| 76 |
| 77 } // namespace |
OLD | NEW |