OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "config.h" | 5 #include "config.h" |
6 #include "core/css/parser/CSSTokenizer.h" | 6 #include "core/css/parser/CSSTokenizer.h" |
7 | 7 |
8 #include "core/css/parser/MediaQueryBlockWatcher.h" | 8 #include "core/css/parser/MediaQueryBlockWatcher.h" |
9 #include <gtest/gtest.h> | 9 #include <gtest/gtest.h> |
10 | 10 |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 DEFINE_STATIC_LOCAL(CSSParserToken, whitespace, (WhitespaceToken)); | 104 DEFINE_STATIC_LOCAL(CSSParserToken, whitespace, (WhitespaceToken)); |
105 DEFINE_STATIC_LOCAL(CSSParserToken, colon, (ColonToken)); | 105 DEFINE_STATIC_LOCAL(CSSParserToken, colon, (ColonToken)); |
106 DEFINE_STATIC_LOCAL(CSSParserToken, semicolon, (SemicolonToken)); | 106 DEFINE_STATIC_LOCAL(CSSParserToken, semicolon, (SemicolonToken)); |
107 DEFINE_STATIC_LOCAL(CSSParserToken, comma, (CommaToken)); | 107 DEFINE_STATIC_LOCAL(CSSParserToken, comma, (CommaToken)); |
108 DEFINE_STATIC_LOCAL(CSSParserToken, includeMatch, (IncludeMatchToken)); | 108 DEFINE_STATIC_LOCAL(CSSParserToken, includeMatch, (IncludeMatchToken)); |
109 DEFINE_STATIC_LOCAL(CSSParserToken, dashMatch, (DashMatchToken)); | 109 DEFINE_STATIC_LOCAL(CSSParserToken, dashMatch, (DashMatchToken)); |
110 DEFINE_STATIC_LOCAL(CSSParserToken, prefixMatch, (PrefixMatchToken)); | 110 DEFINE_STATIC_LOCAL(CSSParserToken, prefixMatch, (PrefixMatchToken)); |
111 DEFINE_STATIC_LOCAL(CSSParserToken, suffixMatch, (SuffixMatchToken)); | 111 DEFINE_STATIC_LOCAL(CSSParserToken, suffixMatch, (SuffixMatchToken)); |
112 DEFINE_STATIC_LOCAL(CSSParserToken, substringMatch, (SubstringMatchToken)); | 112 DEFINE_STATIC_LOCAL(CSSParserToken, substringMatch, (SubstringMatchToken)); |
113 DEFINE_STATIC_LOCAL(CSSParserToken, column, (ColumnToken)); | 113 DEFINE_STATIC_LOCAL(CSSParserToken, column, (ColumnToken)); |
| 114 DEFINE_STATIC_LOCAL(CSSParserToken, cdo, (CDOToken)); |
| 115 DEFINE_STATIC_LOCAL(CSSParserToken, cdc, (CDCToken)); |
114 DEFINE_STATIC_LOCAL(CSSParserToken, leftParenthesis, (LeftParenthesisToken)); | 116 DEFINE_STATIC_LOCAL(CSSParserToken, leftParenthesis, (LeftParenthesisToken)); |
115 DEFINE_STATIC_LOCAL(CSSParserToken, rightParenthesis, (RightParenthesisToken)); | 117 DEFINE_STATIC_LOCAL(CSSParserToken, rightParenthesis, (RightParenthesisToken)); |
116 DEFINE_STATIC_LOCAL(CSSParserToken, leftBracket, (LeftBracketToken)); | 118 DEFINE_STATIC_LOCAL(CSSParserToken, leftBracket, (LeftBracketToken)); |
117 DEFINE_STATIC_LOCAL(CSSParserToken, rightBracket, (RightBracketToken)); | 119 DEFINE_STATIC_LOCAL(CSSParserToken, rightBracket, (RightBracketToken)); |
118 DEFINE_STATIC_LOCAL(CSSParserToken, leftBrace, (LeftBraceToken)); | 120 DEFINE_STATIC_LOCAL(CSSParserToken, leftBrace, (LeftBraceToken)); |
119 DEFINE_STATIC_LOCAL(CSSParserToken, rightBrace, (RightBraceToken)); | 121 DEFINE_STATIC_LOCAL(CSSParserToken, rightBrace, (RightBraceToken)); |
120 DEFINE_STATIC_LOCAL(CSSParserToken, badString, (BadStringToken)); | 122 DEFINE_STATIC_LOCAL(CSSParserToken, badString, (BadStringToken)); |
121 DEFINE_STATIC_LOCAL(CSSParserToken, badUrl, (BadUrlToken)); | 123 DEFINE_STATIC_LOCAL(CSSParserToken, badUrl, (BadUrlToken)); |
122 DEFINE_STATIC_LOCAL(CSSParserToken, comment, (CommentToken)); | 124 DEFINE_STATIC_LOCAL(CSSParserToken, comment, (CommentToken)); |
123 | 125 |
(...skipping 21 matching lines...) Expand all Loading... |
145 | 147 |
146 TEST(CSSTokenizerTest, MultipleCharacterTokens) | 148 TEST(CSSTokenizerTest, MultipleCharacterTokens) |
147 { | 149 { |
148 TEST_TOKENS("~=", includeMatch); | 150 TEST_TOKENS("~=", includeMatch); |
149 TEST_TOKENS("|=", dashMatch); | 151 TEST_TOKENS("|=", dashMatch); |
150 TEST_TOKENS("^=", prefixMatch); | 152 TEST_TOKENS("^=", prefixMatch); |
151 TEST_TOKENS("$=", suffixMatch); | 153 TEST_TOKENS("$=", suffixMatch); |
152 TEST_TOKENS("*=", substringMatch); | 154 TEST_TOKENS("*=", substringMatch); |
153 TEST_TOKENS("||", column); | 155 TEST_TOKENS("||", column); |
154 TEST_TOKENS("|||", column, delim('|')); | 156 TEST_TOKENS("|||", column, delim('|')); |
| 157 TEST_TOKENS("<!--", cdo); |
| 158 TEST_TOKENS("<!---", cdo, delim('-')); |
| 159 TEST_TOKENS("-->", cdc); |
155 } | 160 } |
156 | 161 |
157 TEST(CSSTokenizerTest, DelimiterToken) | 162 TEST(CSSTokenizerTest, DelimiterToken) |
158 { | 163 { |
159 TEST_TOKENS("^", delim('^')); | 164 TEST_TOKENS("^", delim('^')); |
160 TEST_TOKENS("*", delim('*')); | 165 TEST_TOKENS("*", delim('*')); |
161 TEST_TOKENS("%", delim('%')); | 166 TEST_TOKENS("%", delim('%')); |
162 TEST_TOKENS("~", delim('~')); | 167 TEST_TOKENS("~", delim('~')); |
163 TEST_TOKENS("&", delim('&')); | 168 TEST_TOKENS("&", delim('&')); |
164 TEST_TOKENS("|", delim('|')); | 169 TEST_TOKENS("|", delim('|')); |
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
459 blockWatcher.handleToken(tokens[j]); | 464 blockWatcher.handleToken(tokens[j]); |
460 level = blockWatcher.blockLevel(); | 465 level = blockWatcher.blockLevel(); |
461 maxLevel = std::max(level, maxLevel); | 466 maxLevel = std::max(level, maxLevel); |
462 } | 467 } |
463 ASSERT_EQ(testCases[i].maxLevel, maxLevel); | 468 ASSERT_EQ(testCases[i].maxLevel, maxLevel); |
464 ASSERT_EQ(testCases[i].finalLevel, level); | 469 ASSERT_EQ(testCases[i].finalLevel, level); |
465 } | 470 } |
466 } | 471 } |
467 | 472 |
468 } // namespace | 473 } // namespace |
OLD | NEW |