| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2013, Google Inc. All rights reserved. | 2 * Copyright (c) 2013, Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 | 30 |
| 31 #include "config.h" | 31 #include "config.h" |
| 32 | 32 |
| 33 #include <gtest/gtest.h> | 33 #include <gtest/gtest.h> |
| 34 #include "core/html/LinkRelAttribute.h" | 34 #include "core/html/LinkRelAttribute.h" |
| 35 | 35 |
| 36 using namespace WebCore; | 36 using namespace WebCore; |
| 37 | 37 |
| 38 namespace { | 38 namespace { |
| 39 | 39 |
| 40 static inline void testLinkRelAttribute(String value, bool isStyleSheet, IconTyp
e iconType, bool isAlternate, bool isDNSPrefetch, bool isLinkSubresource, bool i
sLinkPrerender) | 40 static inline void testLinkRelAttribute(String value, bool isStyleSheet, IconTyp
e iconType, bool isAlternate, bool isDNSPrefetch, bool isLinkSubresource, bool i
sLinkPrerender, bool isImport = false) |
| 41 { | 41 { |
| 42 LinkRelAttribute linkRelAttribute(value); | 42 LinkRelAttribute linkRelAttribute(value); |
| 43 ASSERT_EQ(isStyleSheet, linkRelAttribute.isStyleSheet()) << value.utf8().dat
a(); | 43 ASSERT_EQ(isStyleSheet, linkRelAttribute.isStyleSheet()) << value.utf8().dat
a(); |
| 44 ASSERT_EQ(iconType, linkRelAttribute.iconType()) << value.utf8().data(); | 44 ASSERT_EQ(iconType, linkRelAttribute.iconType()) << value.utf8().data(); |
| 45 ASSERT_EQ(isAlternate, linkRelAttribute.isAlternate()) << value.utf8().data(
); | 45 ASSERT_EQ(isAlternate, linkRelAttribute.isAlternate()) << value.utf8().data(
); |
| 46 ASSERT_EQ(isDNSPrefetch, linkRelAttribute.isDNSPrefetch()) << value.utf8().d
ata(); | 46 ASSERT_EQ(isDNSPrefetch, linkRelAttribute.isDNSPrefetch()) << value.utf8().d
ata(); |
| 47 ASSERT_EQ(isLinkSubresource, linkRelAttribute.isLinkSubresource()) << value.
utf8().data(); | 47 ASSERT_EQ(isLinkSubresource, linkRelAttribute.isLinkSubresource()) << value.
utf8().data(); |
| 48 ASSERT_EQ(isLinkPrerender, linkRelAttribute.isLinkPrerender()) << value.utf8
().data(); | 48 ASSERT_EQ(isLinkPrerender, linkRelAttribute.isLinkPrerender()) << value.utf8
().data(); |
| 49 ASSERT_EQ(isImport, linkRelAttribute.isImport()) << value.utf8().data(); |
| 49 } | 50 } |
| 50 | 51 |
| 51 TEST(CoreLinkRelAttribute, Constructor) | 52 TEST(CoreLinkRelAttribute, Constructor) |
| 52 { | 53 { |
| 53 testLinkRelAttribute("stylesheet", true, InvalidIcon, false, false, false, f
alse); | 54 testLinkRelAttribute("stylesheet", true, InvalidIcon, false, false, false, f
alse); |
| 54 testLinkRelAttribute("sTyLeShEeT", true, InvalidIcon, false, false, false, f
alse); | 55 testLinkRelAttribute("sTyLeShEeT", true, InvalidIcon, false, false, false, f
alse); |
| 55 | 56 |
| 56 testLinkRelAttribute("icon", false, Favicon, false, false, false, false); | 57 testLinkRelAttribute("icon", false, Favicon, false, false, false, false); |
| 57 testLinkRelAttribute("iCoN", false, Favicon, false, false, false, false); | 58 testLinkRelAttribute("iCoN", false, Favicon, false, false, false, false); |
| 58 testLinkRelAttribute("shortcut icon", false, Favicon, false, false, false, f
alse); | 59 testLinkRelAttribute("shortcut icon", false, Favicon, false, false, false, f
alse); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 70 testLinkRelAttribute("dNs-pReFeTcH", false, InvalidIcon, false, true, false,
false); | 71 testLinkRelAttribute("dNs-pReFeTcH", false, InvalidIcon, false, true, false,
false); |
| 71 | 72 |
| 72 testLinkRelAttribute("alternate stylesheet", true, InvalidIcon, true, false,
false, false); | 73 testLinkRelAttribute("alternate stylesheet", true, InvalidIcon, true, false,
false, false); |
| 73 testLinkRelAttribute("stylesheet alternate", true, InvalidIcon, true, false,
false, false); | 74 testLinkRelAttribute("stylesheet alternate", true, InvalidIcon, true, false,
false, false); |
| 74 testLinkRelAttribute("aLtErNaTe sTyLeShEeT", true, InvalidIcon, true, false,
false, false); | 75 testLinkRelAttribute("aLtErNaTe sTyLeShEeT", true, InvalidIcon, true, false,
false, false); |
| 75 testLinkRelAttribute("sTyLeShEeT aLtErNaTe", true, InvalidIcon, true, false,
false, false); | 76 testLinkRelAttribute("sTyLeShEeT aLtErNaTe", true, InvalidIcon, true, false,
false, false); |
| 76 | 77 |
| 77 testLinkRelAttribute("stylesheet icon prerender aLtErNaTe", true, Favicon, t
rue, false, false, true); | 78 testLinkRelAttribute("stylesheet icon prerender aLtErNaTe", true, Favicon, t
rue, false, false, true); |
| 78 testLinkRelAttribute("alternate subresource", false, InvalidIcon, true, fals
e, true, false); | 79 testLinkRelAttribute("alternate subresource", false, InvalidIcon, true, fals
e, true, false); |
| 79 testLinkRelAttribute("alternate icon stylesheet", true, Favicon, true, false
, false, false); | 80 testLinkRelAttribute("alternate icon stylesheet", true, Favicon, true, false
, false, false); |
| 81 |
| 82 testLinkRelAttribute("import", false, InvalidIcon, false, false, false, fals
e, true); |
| 83 // "import" is mutually exclusive and "stylesheet" wins when they conflict. |
| 84 testLinkRelAttribute("stylesheet import", true, InvalidIcon, false, false, f
alse, false, false); |
| 80 } | 85 } |
| 81 | 86 |
| 82 } // namespace | 87 } // namespace |
| OLD | NEW |