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

Side by Side Diff: Source/core/css/MediaQuerySetTest.cpp

Issue 217423005: Get Media Query parser to handle parens, brackets and braces blocks correctly (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Refactored observeBlocks 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 unified diff | Download patch
OLDNEW
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 "config.h" 5 #include "config.h"
6 #include "core/css/MediaQuery.h" 6 #include "core/css/MediaQuery.h"
7 7
8 #include "core/css/MediaList.h" 8 #include "core/css/MediaList.h"
9 #include "wtf/PassOwnPtr.h" 9 #include "wtf/PassOwnPtr.h"
10 #include "wtf/text/StringBuilder.h" 10 #include "wtf/text/StringBuilder.h"
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 {"(color", "(color)"}, 90 {"(color", "(color)"},
91 {"(min-color: 2", "(min-color: 2)"}, 91 {"(min-color: 2", "(min-color: 2)"},
92 {"(orientation: portrait)", 0}, 92 {"(orientation: portrait)", 0},
93 {"tv and (scan: progressive)", 0}, 93 {"tv and (scan: progressive)", 0},
94 {"(pointer: coarse)", 0}, 94 {"(pointer: coarse)", 0},
95 {"(min-orientation:portrait)", "not all"}, 95 {"(min-orientation:portrait)", "not all"},
96 {"all and (orientation:portrait)", "(orientation: portrait)"}, 96 {"all and (orientation:portrait)", "(orientation: portrait)"},
97 {"all and (orientation:landscape)", "(orientation: landscape)"}, 97 {"all and (orientation:landscape)", "(orientation: landscape)"},
98 {"NOT braille, tv AND (max-width: 200px) and (min-WIDTH: 100px) and (ori entation: landscape), (color)", 98 {"NOT braille, tv AND (max-width: 200px) and (min-WIDTH: 100px) and (ori entation: landscape), (color)",
99 "not braille, tv and (max-width: 200px) and (min-width: 100px) and ( orientation: landscape), (color)"}, 99 "not braille, tv and (max-width: 200px) and (min-width: 100px) and ( orientation: landscape), (color)"},
100 {"(max-width: 700px), (max-width: 700px)", "(max-width: 700px), (max-wid th: 700px)"},
101 {"(max-width: 800px()), (max-width: 800px)", "not all, (max-width: 800px )"},
102 {"(max-width: 900px(()), (max-width: 900px)", "not all"},
103 {"(max-width: 600px(())))), (max-width: 600px)", "not all, (max-width: 6 00px)"},
104 {"(max-width: 500px(((((((((())))), (max-width: 500px)", "not all"},
105 {"(max-width: 800px[]), (max-width: 800px)", "not all, (max-width: 800px )"},
106 {"(max-width: 900px[[]), (max-width: 900px)", "not all"},
107 {"(max-width: 600px[[]]]]), (max-width: 600px)", "not all, (max-width: 6 00px)"},
108 {"(max-width: 500px[[[[[[[[[[]]]]), (max-width: 500px)", "not all"},
109 {"(max-width: 800px{}), (max-width: 800px)", "not all, (max-width: 800px )"},
110 {"(max-width: 900px{{}), (max-width: 900px)", "not all"},
111 {"(max-width: 600px{{}}}}), (max-width: 600px)", "not all, (max-width: 6 00px)"},
112 {"(max-width: 500px{{{{{{{{{{}}}}), (max-width: 500px)", "not all"},
100 {"[(), (max-width: 900px)", "not all"}, 113 {"[(), (max-width: 900px)", "not all"},
101 {"[{}, (max-width: 900px)", "not all"}, 114 {"[{}, (max-width: 900px)", "not all"},
102 {"[{]}], (max-width: 900px)", "not all, (max-width: 900px)"}, 115 {"[{]}], (max-width: 900px)", "not all, (max-width: 900px)"},
103 {"[{[]{}{{{}}}}], (max-width: 900px)", "not all, (max-width: 900px)"}, 116 {"[{[]{}{{{}}}}], (max-width: 900px)", "not all, (max-width: 900px)"},
104 {"[{[}], (max-width: 900px)", "not all"}, 117 {"[{[}], (max-width: 900px)", "not all"},
105 {"[({)}], (max-width: 900px)", "not all"}, 118 {"[({)}], (max-width: 900px)", "not all"},
106 {0, 0} // Do not remove the terminator line. 119 {0, 0} // Do not remove the terminator line.
107 }; 120 };
108 121
109 for (unsigned i = 0; testCases[i].input; ++i) { 122 for (unsigned i = 0; testCases[i].input; ++i) {
110 RefPtrWillBeRawPtr<MediaQuerySet> querySet = MediaQuerySet::create(testC ases[i].input); 123 RefPtrWillBeRawPtr<MediaQuerySet> querySet = MediaQuerySet::create(testC ases[i].input);
111 StringBuilder output; 124 StringBuilder output;
112 size_t j = 0; 125 size_t j = 0;
113 while (j < querySet->queryVector().size()) { 126 while (j < querySet->queryVector().size()) {
114 String queryText = querySet->queryVector()[j]->cssText(); 127 String queryText = querySet->queryVector()[j]->cssText();
115 output.append(queryText); 128 output.append(queryText);
116 ++j; 129 ++j;
117 if (j >= querySet->queryVector().size()) 130 if (j >= querySet->queryVector().size())
118 break; 131 break;
119 output.append(", "); 132 output.append(", ");
120 } 133 }
121 if (testCases[i].output) 134 if (testCases[i].output)
122 ASSERT_STREQ(testCases[i].output, output.toString().ascii().data()); 135 ASSERT_STREQ(testCases[i].output, output.toString().ascii().data());
123 else 136 else
124 ASSERT_STREQ(testCases[i].input, output.toString().ascii().data()); 137 ASSERT_STREQ(testCases[i].input, output.toString().ascii().data());
125 } 138 }
126 } 139 }
127 140
128 } // namespace 141 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698