| 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 "core/css/parser/CSSTokenizer.h" | 5 #include "core/css/parser/CSSTokenizer.h" |
| 6 | 6 |
| 7 #include "core/css/parser/CSSParserTokenRange.h" | 7 #include "core/css/parser/CSSParserTokenRange.h" |
| 8 #include "core/css/parser/MediaQueryBlockWatcher.h" | 8 #include "core/css/parser/MediaQueryBlockWatcher.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 #include "wtf/allocator/Partitions.h" | 10 #include "wtf/allocator/Partitions.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 CSSParserTokenRange expected(expectedTokens); | 69 CSSParserTokenRange expected(expectedTokens.begin(), expectedTokens.end()); |
| 70 | 70 |
| 71 CSSTokenizer::Scope actualScope(string); | 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 } |
| (...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 493 blockWatcher.handleToken(range.consume()); | 493 blockWatcher.handleToken(range.consume()); |
| 494 level = blockWatcher.blockLevel(); | 494 level = blockWatcher.blockLevel(); |
| 495 maxLevel = std::max(level, maxLevel); | 495 maxLevel = std::max(level, maxLevel); |
| 496 } | 496 } |
| 497 ASSERT_EQ(testCases[i].maxLevel, maxLevel); | 497 ASSERT_EQ(testCases[i].maxLevel, maxLevel); |
| 498 ASSERT_EQ(testCases[i].finalLevel, level); | 498 ASSERT_EQ(testCases[i].finalLevel, level); |
| 499 } | 499 } |
| 500 } | 500 } |
| 501 | 501 |
| 502 } // namespace blink | 502 } // namespace blink |
| OLD | NEW |