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/CSSParserTokenRange.h" | 8 #include "core/css/parser/CSSParserTokenRange.h" |
9 #include "core/css/parser/MediaQueryBlockWatcher.h" | 9 #include "core/css/parser/MediaQueryBlockWatcher.h" |
10 #include <gtest/gtest.h> | 10 #include <gtest/gtest.h> |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
59 void testTokens(const String& string, const CSSParserToken& token1, const CSSPar serToken& token2 = CSSParserToken(EOFToken), const CSSParserToken& token3 = CSSP arserToken(EOFToken)) | 59 void testTokens(const String& string, const CSSParserToken& token1, const CSSPar serToken& token2 = CSSParserToken(EOFToken), const CSSParserToken& token3 = CSSP arserToken(EOFToken)) |
60 { | 60 { |
61 Vector<CSSParserToken> expectedTokens; | 61 Vector<CSSParserToken> expectedTokens; |
62 expectedTokens.append(token1); | 62 expectedTokens.append(token1); |
63 if (token2.type() != EOFToken) { | 63 if (token2.type() != EOFToken) { |
64 expectedTokens.append(token2); | 64 expectedTokens.append(token2); |
65 if (token3.type() != EOFToken) | 65 if (token3.type() != EOFToken) |
66 expectedTokens.append(token3); | 66 expectedTokens.append(token3); |
67 } | 67 } |
68 | 68 |
69 CSSTokenizer::Scope actualScope(string); | |
Timothy Loh
2015/07/23 08:11:47
change not needed?
| |
69 CSSParserTokenRange expected(expectedTokens); | 70 CSSParserTokenRange expected(expectedTokens); |
70 | 71 |
71 CSSTokenizer::Scope actualScope(string); | |
72 CSSParserTokenRange actual = actualScope.tokenRange(); | 72 CSSParserTokenRange actual = actualScope.tokenRange(); |
73 | 73 |
74 // Just check that serialization doesn't hit any asserts | 74 // Just check that serialization doesn't hit any asserts |
75 actual.serialize(); | 75 actual.serialize(); |
76 | 76 |
77 while (!expected.atEnd() || !actual.atEnd()) | 77 while (!expected.atEnd() || !actual.atEnd()) |
78 compareTokens(expected.consume(), actual.consume()); | 78 compareTokens(expected.consume(), actual.consume()); |
79 } | 79 } |
80 | 80 |
81 static CSSParserString toParserString(const String& string) | 81 static CSSParserString toParserString(const String& string) |
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
482 blockWatcher.handleToken(range.consume()); | 482 blockWatcher.handleToken(range.consume()); |
483 level = blockWatcher.blockLevel(); | 483 level = blockWatcher.blockLevel(); |
484 maxLevel = std::max(level, maxLevel); | 484 maxLevel = std::max(level, maxLevel); |
485 } | 485 } |
486 ASSERT_EQ(testCases[i].maxLevel, maxLevel); | 486 ASSERT_EQ(testCases[i].maxLevel, maxLevel); |
487 ASSERT_EQ(testCases[i].finalLevel, level); | 487 ASSERT_EQ(testCases[i].finalLevel, level); |
488 } | 488 } |
489 } | 489 } |
490 | 490 |
491 } // namespace | 491 } // namespace |
OLD | NEW |