| 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..3e1568b8559450a42a098c20fe198300727e5779 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,56 @@ 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;
|
| + unsigned level = 0;
|
| + for (size_t j = 0; j < tokens.size(); ++j) {
|
| + if (tokens[j].blockToken() == MediaQueryToken::BlockStart)
|
| + ++level;
|
| + else if (tokens[j].blockToken() == MediaQueryToken::BlockEnd)
|
| + --level;
|
| +
|
| + ASSERT_GE(level, (unsigned)0);
|
| + maxLevel = std::max(level, maxLevel);
|
| + }
|
| + ASSERT_EQ(testCases[i].maxLevel, maxLevel);
|
| + }
|
| +}
|
| +
|
| void testToken(UChar c, MediaQueryTokenType tokenType)
|
| {
|
| Vector<MediaQueryToken> tokens;
|
|
|