Index: third_party/WebKit/Source/core/css/MediaQuerySetTest.cpp |
diff --git a/third_party/WebKit/Source/core/css/MediaQuerySetTest.cpp b/third_party/WebKit/Source/core/css/MediaQuerySetTest.cpp |
index 5cedc1a5510afb98c9cc7c904bf7d68c58cb7d9b..600e20c48f603179b9aaf6957f3a8b9ae4c9fbab 100644 |
--- a/third_party/WebKit/Source/core/css/MediaQuerySetTest.cpp |
+++ b/third_party/WebKit/Source/core/css/MediaQuerySetTest.cpp |
@@ -13,12 +13,9 @@ namespace blink { |
typedef struct { |
const char* input; |
const char* output; |
- bool shouldWorkOnOldParser; |
} TestCase; |
-static void testMediaQuery(TestCase test, |
- MediaQuerySet& querySet, |
- bool oldParser) { |
+static void testMediaQuery(TestCase test, MediaQuerySet& querySet) { |
StringBuilder output; |
size_t j = 0; |
while (j < querySet.queryVector().size()) { |
@@ -29,12 +26,10 @@ static void testMediaQuery(TestCase test, |
break; |
output.append(", "); |
} |
- if (!oldParser || test.shouldWorkOnOldParser) { |
- if (test.output) |
- ASSERT_STREQ(test.output, output.toString().ascii().data()); |
- else |
- ASSERT_STREQ(test.input, output.toString().ascii().data()); |
- } |
+ if (test.output) |
+ ASSERT_STREQ(test.output, output.toString().ascii().data()); |
+ else |
+ ASSERT_STREQ(test.input, output.toString().ascii().data()); |
} |
TEST(MediaQuerySetTest, Basic) { |
@@ -42,162 +37,153 @@ TEST(MediaQuerySetTest, Basic) { |
// The second string represents the output string, if present. |
// Otherwise, the output string is identical to the first string. |
TestCase testCases[] = { |
- {"", 0, true}, |
- {" ", "", true}, |
- {"screen", 0, true}, |
- {"screen and (color)", 0, true}, |
- {"all and (min-width:500px)", "(min-width: 500px)", true}, |
- {"all and (min-width:/*bla*/500px)", "(min-width: 500px)", true}, |
- {"(min-width:500px)", "(min-width: 500px)", true}, |
- {"screen and (color), projection and (color)", 0, true}, |
- {"not screen and (color)", 0, true}, |
- {"only screen and (color)", 0, true}, |
- {"screen and (color), projection and (color)", 0, true}, |
- {"aural and (device-aspect-ratio: 16/9)", 0, true}, |
- {"speech and (min-device-width: 800px)", 0, true}, |
- {"example", 0, true}, |
+ {"", nullptr}, |
+ {" ", ""}, |
+ {"screen", nullptr}, |
+ {"screen and (color)", nullptr}, |
+ {"all and (min-width:500px)", "(min-width: 500px)"}, |
+ {"all and (min-width:/*bla*/500px)", "(min-width: 500px)"}, |
+ {"(min-width:500px)", "(min-width: 500px)"}, |
+ {"screen and (color), projection and (color)", nullptr}, |
+ {"not screen and (color)", nullptr}, |
+ {"only screen and (color)", nullptr}, |
+ {"screen and (color), projection and (color)", nullptr}, |
+ {"aural and (device-aspect-ratio: 16/9)", nullptr}, |
+ {"speech and (min-device-width: 800px)", nullptr}, |
+ {"example", nullptr}, |
{"screen and (max-weight: 3kg) and (color), (monochrome)", |
- "not all, (monochrome)", true}, |
- {"(min-width: -100px)", "not all", true}, |
- {"(example, all,), speech", "not all, speech", true}, |
- {"&test, screen", "not all, screen", true}, |
- {"print and (min-width: 25cm)", 0, true}, |
+ "not all, (monochrome)"}, |
+ {"(min-width: -100px)", "not all"}, |
+ {"(example, all,), speech", "not all, speech"}, |
+ {"&test, screen", "not all, screen"}, |
+ {"print and (min-width: 25cm)", nullptr}, |
{"screen and (min-width: 400px) and (max-width: 700px)", |
- "screen and (max-width: 700px) and (min-width: 400px)", true}, |
- {"screen and (device-width: 800px)", 0, true}, |
- {"screen and (device-height: 60em)", 0, true}, |
- {"screen and (device-height: 60rem)", 0, true}, |
- {"screen and (device-height: 60ch)", 0, true}, |
- {"screen and (device-aspect-ratio: 16/9)", 0, true}, |
- {"(device-aspect-ratio: 16.0/9.0)", "not all", true}, |
- {"(device-aspect-ratio: 16/ 9)", "(device-aspect-ratio: 16/9)", true}, |
- {"(device-aspect-ratio: 16/\r9)", "(device-aspect-ratio: 16/9)", true}, |
- {"all and (color)", "(color)", true}, |
- {"all and (min-color: 1)", "(min-color: 1)", true}, |
- {"all and (min-color: 1.0)", "not all", true}, |
- {"all and (min-color: 2)", "(min-color: 2)", true}, |
- {"all and (color-index)", "(color-index)", true}, |
- {"all and (min-color-index: 1)", "(min-color-index: 1)", true}, |
- {"all and (monochrome)", "(monochrome)", true}, |
- {"all and (min-monochrome: 1)", "(min-monochrome: 1)", true}, |
- {"all and (min-monochrome: 2)", "(min-monochrome: 2)", true}, |
- {"print and (monochrome)", 0, true}, |
- {"handheld and (grid) and (max-width: 15em)", 0, true}, |
- {"handheld and (grid) and (max-device-height: 7em)", 0, true}, |
- {"screen and (max-width: 50%)", "not all", true}, |
- {"screen and (max-WIDTH: 500px)", "screen and (max-width: 500px)", true}, |
- {"screen and (max-width: 24.4em)", 0, true}, |
- {"screen and (max-width: 24.4EM)", "screen and (max-width: 24.4em)", |
- true}, |
- {"screen and (max-width: blabla)", "not all", true}, |
- {"screen and (max-width: 1)", "not all", true}, |
- {"screen and (max-width: 0)", 0, true}, |
- {"screen and (max-width: 1deg)", "not all", true}, |
+ "screen and (max-width: 700px) and (min-width: 400px)"}, |
+ {"screen and (device-width: 800px)", nullptr}, |
+ {"screen and (device-height: 60em)", nullptr}, |
+ {"screen and (device-height: 60rem)", nullptr}, |
+ {"screen and (device-height: 60ch)", nullptr}, |
+ {"screen and (device-aspect-ratio: 16/9)", nullptr}, |
+ {"(device-aspect-ratio: 16.0/9.0)", "not all"}, |
+ {"(device-aspect-ratio: 16/ 9)", "(device-aspect-ratio: 16/9)"}, |
+ {"(device-aspect-ratio: 16/\r9)", "(device-aspect-ratio: 16/9)"}, |
+ {"all and (color)", "(color)"}, |
+ {"all and (min-color: 1)", "(min-color: 1)"}, |
+ {"all and (min-color: 1.0)", "not all"}, |
+ {"all and (min-color: 2)", "(min-color: 2)"}, |
+ {"all and (color-index)", "(color-index)"}, |
+ {"all and (min-color-index: 1)", "(min-color-index: 1)"}, |
+ {"all and (monochrome)", "(monochrome)"}, |
+ {"all and (min-monochrome: 1)", "(min-monochrome: 1)"}, |
+ {"all and (min-monochrome: 2)", "(min-monochrome: 2)"}, |
+ {"print and (monochrome)", nullptr}, |
+ {"handheld and (grid) and (max-width: 15em)", nullptr}, |
+ {"handheld and (grid) and (max-device-height: 7em)", nullptr}, |
+ {"screen and (max-width: 50%)", "not all"}, |
+ {"screen and (max-WIDTH: 500px)", "screen and (max-width: 500px)"}, |
+ {"screen and (max-width: 24.4em)", nullptr}, |
+ {"screen and (max-width: 24.4EM)", "screen and (max-width: 24.4em)"}, |
+ {"screen and (max-width: blabla)", "not all"}, |
+ {"screen and (max-width: 1)", "not all"}, |
+ {"screen and (max-width: 0)", nullptr}, |
+ {"screen and (max-width: 1deg)", "not all"}, |
{"handheld and (min-width: 20em), \nscreen and (min-width: 20em)", |
- "handheld and (min-width: 20em), screen and (min-width: 20em)", true}, |
- {"print and (min-resolution: 300dpi)", 0, true}, |
- {"print and (min-resolution: 118dpcm)", 0, true}, |
+ "handheld and (min-width: 20em), screen and (min-width: 20em)"}, |
+ {"print and (min-resolution: 300dpi)", nullptr}, |
+ {"print and (min-resolution: 118dpcm)", nullptr}, |
{"(resolution: 0.83333333333333333333dppx)", |
- "(resolution: 0.833333333333333dppx)", true}, |
- {"(resolution: 2.4dppx)", 0, true}, |
- {"all and(color)", "not all", true}, |
- {"all and (", "not all", true}, |
- {"test;,all", "not all, all", true}, |
- {"(color:20example)", "not all", false}, |
- {"not braille", 0, true}, |
- {",screen", "not all, screen", true}, |
- {",all", "not all, all", true}, |
- {",,all,,", "not all, not all, all, not all, not all", true}, |
- {",,all,, ", "not all, not all, all, not all, not all", true}, |
+ "(resolution: 0.833333333333333dppx)"}, |
+ {"(resolution: 2.4dppx)", nullptr}, |
+ {"all and(color)", "not all"}, |
+ {"all and (", "not all"}, |
+ {"test;,all", "not all, all"}, |
+ {"(color:20example)", "not all"}, |
+ {"not braille", nullptr}, |
+ {",screen", "not all, screen"}, |
+ {",all", "not all, all"}, |
+ {",,all,,", "not all, not all, all, not all, not all"}, |
+ {",,all,, ", "not all, not all, all, not all, not all"}, |
{",screen,,&invalid,,", |
- "not all, screen, not all, not all, not all, not all", true}, |
+ "not all, screen, not all, not all, not all, not all"}, |
{",screen,,(invalid,),,", |
- "not all, screen, not all, not all, not all, not all", true}, |
- {",(all,),,", "not all, not all, not all, not all", true}, |
- {",", "not all, not all", true}, |
- {" ", "", true}, |
- {"(color", "(color)", true}, |
- {"(min-color: 2", "(min-color: 2)", true}, |
- {"(orientation: portrait)", 0, true}, |
- {"tv and (scan: progressive)", 0, true}, |
- {"(pointer: coarse)", 0, true}, |
- {"(min-orientation:portrait)", "not all", true}, |
- {"all and (orientation:portrait)", "(orientation: portrait)", true}, |
- {"all and (orientation:landscape)", "(orientation: landscape)", true}, |
+ "not all, screen, not all, not all, not all, not all"}, |
+ {",(all,),,", "not all, not all, not all, not all"}, |
+ {",", "not all, not all"}, |
+ {" ", ""}, |
+ {"(color", "(color)"}, |
+ {"(min-color: 2", "(min-color: 2)"}, |
+ {"(orientation: portrait)", nullptr}, |
+ {"tv and (scan: progressive)", nullptr}, |
+ {"(pointer: coarse)", nullptr}, |
+ {"(min-orientation:portrait)", "not all"}, |
+ {"all and (orientation:portrait)", "(orientation: portrait)"}, |
+ {"all and (orientation:landscape)", "(orientation: landscape)"}, |
{"NOT braille, tv AND (max-width: 200px) and (min-WIDTH: 100px) and " |
"(orientation: landscape), (color)", |
"not braille, tv and (max-width: 200px) and (min-width: 100px) and " |
- "(orientation: landscape), (color)", |
- true}, |
- {"(m\\61x-width: 300px)", "(max-width: 300px)", true}, |
- {"(max-width: 400\\70\\78)", "(max-width: 400px)", false}, |
- {"(max-width: 500\\0070\\0078)", "(max-width: 500px)", false}, |
- {"(max-width: 600\\000070\\000078)", "(max-width: 600px)", false}, |
+ "(orientation: landscape), (color)"}, |
+ {"(m\\61x-width: 300px)", "(max-width: 300px)"}, |
+ {"(max-width: 400\\70\\78)", "(max-width: 400px)"}, |
+ {"(max-width: 500\\0070\\0078)", "(max-width: 500px)"}, |
+ {"(max-width: 600\\000070\\000078)", "(max-width: 600px)"}, |
{"(max-width: 700px), (max-width: 700px)", |
- "(max-width: 700px), (max-width: 700px)", true}, |
+ "(max-width: 700px), (max-width: 700px)"}, |
{"(max-width: 800px()), (max-width: 800px)", |
- "not all, (max-width: 800px)", true}, |
- {"(max-width: 900px(()), (max-width: 900px)", "not all", true}, |
+ "not all, (max-width: 800px)"}, |
+ {"(max-width: 900px(()), (max-width: 900px)", "not all"}, |
{"(max-width: 600px(())))), (max-width: 600px)", |
- "not all, (max-width: 600px)", true}, |
- {"(max-width: 500px(((((((((())))), (max-width: 500px)", "not all", true}, |
+ "not all, (max-width: 600px)"}, |
+ {"(max-width: 500px(((((((((())))), (max-width: 500px)", "not all"}, |
{"(max-width: 800px[]), (max-width: 800px)", |
- "not all, (max-width: 800px)", true}, |
- {"(max-width: 900px[[]), (max-width: 900px)", "not all", true}, |
+ "not all, (max-width: 800px)"}, |
+ {"(max-width: 900px[[]), (max-width: 900px)", "not all"}, |
{"(max-width: 600px[[]]]]), (max-width: 600px)", |
- "not all, (max-width: 600px)", true}, |
- {"(max-width: 500px[[[[[[[[[[]]]]), (max-width: 500px)", "not all", true}, |
+ "not all, (max-width: 600px)"}, |
+ {"(max-width: 500px[[[[[[[[[[]]]]), (max-width: 500px)", "not all"}, |
{"(max-width: 800px{}), (max-width: 800px)", |
- "not all, (max-width: 800px)", true}, |
- {"(max-width: 900px{{}), (max-width: 900px)", "not all", true}, |
+ "not all, (max-width: 800px)"}, |
+ {"(max-width: 900px{{}), (max-width: 900px)", "not all"}, |
{"(max-width: 600px{{}}}}), (max-width: 600px)", |
- "not all, (max-width: 600px)", true}, |
- {"(max-width: 500px{{{{{{{{{{}}}}), (max-width: 500px)", "not all", true}, |
- {"[(), (max-width: 400px)", "not all", true}, |
- {"[{}, (max-width: 500px)", "not all", true}, |
- {"[{]}], (max-width: 900px)", "not all, (max-width: 900px)", true}, |
- {"[{[]{}{{{}}}}], (max-width: 900px)", "not all, (max-width: 900px)", |
- true}, |
- {"[{[}], (max-width: 900px)", "not all", true}, |
- {"[({)}], (max-width: 900px)", "not all", true}, |
- {"[]((), (max-width: 900px)", "not all", true}, |
- {"((), (max-width: 900px)", "not all", true}, |
- {"(foo(), (max-width: 900px)", "not all", true}, |
- {"[](()), (max-width: 900px)", "not all, (max-width: 900px)", true}, |
+ "not all, (max-width: 600px)"}, |
+ {"(max-width: 500px{{{{{{{{{{}}}}), (max-width: 500px)", "not all"}, |
+ {"[(), (max-width: 400px)", "not all"}, |
+ {"[{}, (max-width: 500px)", "not all"}, |
+ {"[{]}], (max-width: 900px)", "not all, (max-width: 900px)"}, |
+ {"[{[]{}{{{}}}}], (max-width: 900px)", "not all, (max-width: 900px)"}, |
+ {"[{[}], (max-width: 900px)", "not all"}, |
+ {"[({)}], (max-width: 900px)", "not all"}, |
+ {"[]((), (max-width: 900px)", "not all"}, |
+ {"((), (max-width: 900px)", "not all"}, |
+ {"(foo(), (max-width: 900px)", "not all"}, |
+ {"[](()), (max-width: 900px)", "not all, (max-width: 900px)"}, |
{"all an[isdfs bla())()]icalc(i)(()), (max-width: 400px)", |
- "not all, (max-width: 400px)", true}, |
- {"all an[isdfs bla())(]icalc(i)(()), (max-width: 500px)", "not all", |
- true}, |
- {"all an[isdfs bla())(]icalc(i)(())), (max-width: 600px)", "not all", |
- true}, |
+ "not all, (max-width: 400px)"}, |
+ {"all an[isdfs bla())(]icalc(i)(()), (max-width: 500px)", "not all"}, |
+ {"all an[isdfs bla())(]icalc(i)(())), (max-width: 600px)", "not all"}, |
{"all an[isdfs bla())(]icalc(i)(()))], (max-width: 800px)", |
- "not all, (max-width: 800px)", true}, |
- {"(max-width: '40px')", "not all", true}, |
- {"('max-width': 40px)", "not all", true}, |
- {"'\"'\", (max-width: 900px)", "not all", true}, |
- {"'\"\"\"', (max-width: 900px)", "not all, (max-width: 900px)", true}, |
- {"\"'\"', (max-width: 900px)", "not all", true}, |
- {"\"'''\", (max-width: 900px)", "not all, (max-width: 900px)", true}, |
- {"not not", "not all", true}, |
- {"not and", "not all", true}, |
- {"not only", "not all", true}, |
- {"not or", "not all", true}, |
- {"only not", "not all", true}, |
- {"only and", "not all", true}, |
- {"only only", "not all", true}, |
- {"only or", "not all", true}, |
- {"not (orientation)", "not all", true}, |
- {"only (orientation)", "not all", true}, |
- {0, 0} // Do not remove the terminator line. |
+ "not all, (max-width: 800px)"}, |
+ {"(max-width: '40px')", "not all"}, |
+ {"('max-width': 40px)", "not all"}, |
+ {"'\"'\", (max-width: 900px)", "not all"}, |
+ {"'\"\"\"', (max-width: 900px)", "not all, (max-width: 900px)"}, |
+ {"\"'\"', (max-width: 900px)", "not all"}, |
+ {"\"'''\", (max-width: 900px)", "not all, (max-width: 900px)"}, |
+ {"not not", "not all"}, |
+ {"not and", "not all"}, |
+ {"not only", "not all"}, |
+ {"not or", "not all"}, |
+ {"only not", "not all"}, |
+ {"only and", "not all"}, |
+ {"only only", "not all"}, |
+ {"only or", "not all"}, |
+ {"not (orientation)", "not all"}, |
+ {"only (orientation)", "not all"}, |
+ {nullptr, nullptr} // Do not remove the terminator line. |
}; |
for (unsigned i = 0; testCases[i].input; ++i) { |
- MediaQuerySet* oldParserQuerySet = |
- MediaQuerySet::create(testCases[i].input); |
- MediaQuerySet* threadSafeQuerySet = |
- MediaQuerySet::createOffMainThread(testCases[i].input); |
- testMediaQuery(testCases[i], *oldParserQuerySet, true); |
- testMediaQuery(testCases[i], *threadSafeQuerySet, false); |
+ MediaQuerySet* querySet = MediaQuerySet::create(testCases[i].input); |
+ testMediaQuery(testCases[i], *querySet); |
} |
} |