Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(509)

Unified Diff: Source/core/css/parser/MediaQueryTokenizerTest.cpp

Issue 225293006: Moved MQ parsing block tracking to tokenizer (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fixed review comments Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/core/css/parser/MediaQueryTokenizerTest.cpp
diff --git a/Source/core/css/parser/MediaQueryTokenizerTest.cpp b/Source/core/css/parser/MediaQueryTokenizerTest.cpp
index 0f9a5ee75e96defa7a039d760f0b6bb80b8de376..87774244d474ed54bce22332166d2ec4c443e363 100644
--- a/Source/core/css/parser/MediaQueryTokenizerTest.cpp
+++ b/Source/core/css/parser/MediaQueryTokenizerTest.cpp
@@ -15,6 +15,11 @@ typedef struct {
const char* output;
} TestCase;
+typedef struct {
+ const char* input;
+ const unsigned maxLevel;
+} BlockTestCase;
+
TEST(MediaQueryTokenizerTest, Basic)
{
TestCase testCases[] = {
@@ -51,6 +56,48 @@ TEST(MediaQueryTokenizerTest, Basic)
}
}
+TEST(MediaQueryTokenizerBlockTest, Basic)
+{
+ BlockTestCase testCases[] = {
+ {"(max-width: 800px()), (max-width: 800px)", 2},
+ {"(max-width: 900px(()), (max-width: 900px)", 3},
+ {"(max-width: 600px(())))), (max-width: 600px)", 3},
+ {"(max-width: 500px(((((((((())))), (max-width: 500px)", 11},
+ {"(max-width: 800px[]), (max-width: 800px)", 2},
+ {"(max-width: 900px[[]), (max-width: 900px)", 3},
+ {"(max-width: 600px[[]]]]), (max-width: 600px)", 3},
+ {"(max-width: 500px[[[[[[[[[[]]]]), (max-width: 500px)", 11},
+ {"(max-width: 800px{}), (max-width: 800px)", 2},
+ {"(max-width: 900px{{}), (max-width: 900px)", 3},
+ {"(max-width: 600px{{}}}}), (max-width: 600px)", 3},
+ {"(max-width: 500px{{{{{{{{{{}}}}), (max-width: 500px)", 11},
+ {"[(), (max-width: 400px)", 2},
+ {"[{}, (max-width: 500px)", 2},
+ {"[{]}], (max-width: 900px)", 2},
+ {"[{[]{}{{{}}}}], (max-width: 900px)", 5},
+ {"[{[}], (max-width: 900px)", 3},
+ {"[({)}], (max-width: 900px)", 3},
+ {"[]((), (max-width: 900px)", 2},
+ {"((), (max-width: 900px)", 2},
+ {"(foo(), (max-width: 900px)", 2},
+ {"[](()), (max-width: 900px)", 2},
+ {"all an[isdfs bla())(i())]icalc(i)(()), (max-width: 400px)", 3},
+ {"all an[isdfs bla())(]icalc(i)(()), (max-width: 500px)", 4},
+ {"all an[isdfs bla())(]icalc(i)(())), (max-width: 600px)", 4},
+ {"all an[isdfs bla())(]icalc(i)(()))], (max-width: 800px)", 4},
+ {0, 0} // Do not remove the terminator line.
+ };
+ for (int i = 0; testCases[i].input; ++i) {
+ Vector<MediaQueryToken> tokens;
+ MediaQueryTokenizer::tokenize(testCases[i].input, tokens);
+
+ unsigned maxLevel = 0;
+ for (size_t j = 0; j < tokens.size(); ++j)
+ maxLevel = std::max(tokens[j].blockLevel(), maxLevel);
+ ASSERT_EQ(testCases[i].maxLevel, maxLevel);
+ }
+}
+
void testToken(UChar c, MediaQueryTokenType tokenType)
{
Vector<MediaQueryToken> tokens;

Powered by Google App Engine
This is Rietveld 408576698