| 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..bce34bebf50d6bb2872cdecd34b32df90a4fbbdd 100644
|
| --- a/Source/core/css/parser/MediaQueryTokenizerTest.cpp
|
| +++ b/Source/core/css/parser/MediaQueryTokenizerTest.cpp
|
| @@ -5,6 +5,7 @@
|
| #include "config.h"
|
| #include "core/css/parser/MediaQueryTokenizer.h"
|
|
|
| +#include "core/css/parser/MediaQueryBlockWatcher.h"
|
| #include "wtf/PassOwnPtr.h"
|
| #include <gtest/gtest.h>
|
|
|
| @@ -15,6 +16,12 @@ typedef struct {
|
| const char* output;
|
| } TestCase;
|
|
|
| +typedef struct {
|
| + const char* input;
|
| + const unsigned maxLevel;
|
| + const unsigned finalLevel;
|
| +} BlockTestCase;
|
| +
|
| TEST(MediaQueryTokenizerTest, Basic)
|
| {
|
| TestCase testCases[] = {
|
| @@ -51,6 +58,54 @@ TEST(MediaQueryTokenizerTest, Basic)
|
| }
|
| }
|
|
|
| +TEST(MediaQueryTokenizerBlockTest, Basic)
|
| +{
|
| + BlockTestCase testCases[] = {
|
| + {"(max-width: 800px()), (max-width: 800px)", 2, 0},
|
| + {"(max-width: 900px(()), (max-width: 900px)", 3, 1},
|
| + {"(max-width: 600px(())))), (max-width: 600px)", 3, 0},
|
| + {"(max-width: 500px(((((((((())))), (max-width: 500px)", 11, 6},
|
| + {"(max-width: 800px[]), (max-width: 800px)", 2, 0},
|
| + {"(max-width: 900px[[]), (max-width: 900px)", 3, 2},
|
| + {"(max-width: 600px[[]]]]), (max-width: 600px)", 3, 0},
|
| + {"(max-width: 500px[[[[[[[[[[]]]]), (max-width: 500px)", 11, 7},
|
| + {"(max-width: 800px{}), (max-width: 800px)", 2, 0},
|
| + {"(max-width: 900px{{}), (max-width: 900px)", 3, 2},
|
| + {"(max-width: 600px{{}}}}), (max-width: 600px)", 3, 0},
|
| + {"(max-width: 500px{{{{{{{{{{}}}}), (max-width: 500px)", 11, 7},
|
| + {"[(), (max-width: 400px)", 2, 1},
|
| + {"[{}, (max-width: 500px)", 2, 1},
|
| + {"[{]}], (max-width: 900px)", 2, 0},
|
| + {"[{[]{}{{{}}}}], (max-width: 900px)", 5, 0},
|
| + {"[{[}], (max-width: 900px)", 3, 2},
|
| + {"[({)}], (max-width: 900px)", 3, 2},
|
| + {"[]((), (max-width: 900px)", 2, 1},
|
| + {"((), (max-width: 900px)", 2, 1},
|
| + {"(foo(), (max-width: 900px)", 2, 1},
|
| + {"[](()), (max-width: 900px)", 2, 0},
|
| + {"all an[isdfs bla())(i())]icalc(i)(()), (max-width: 400px)", 3, 0},
|
| + {"all an[isdfs bla())(]icalc(i)(()), (max-width: 500px)", 4, 2},
|
| + {"all an[isdfs bla())(]icalc(i)(())), (max-width: 600px)", 4, 1},
|
| + {"all an[isdfs bla())(]icalc(i)(()))], (max-width: 800px)", 4, 0},
|
| + {0, 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);
|
| + MediaQueryBlockWatcher blockWatcher;
|
| +
|
| + unsigned maxLevel = 0;
|
| + unsigned level = 0;
|
| + for (size_t j = 0; j < tokens.size(); ++j) {
|
| + blockWatcher.handleToken(tokens[j]);
|
| + level = blockWatcher.blockLevel();
|
| + maxLevel = std::max(level, maxLevel);
|
| + }
|
| + ASSERT_EQ(testCases[i].maxLevel, maxLevel);
|
| + ASSERT_EQ(testCases[i].finalLevel, level);
|
| + }
|
| +}
|
| +
|
| void testToken(UChar c, MediaQueryTokenType tokenType)
|
| {
|
| Vector<MediaQueryToken> tokens;
|
|
|