OLD | NEW |
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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 {"screen and (max-width: 0)", 0}, | 69 {"screen and (max-width: 0)", 0}, |
70 {"screen and (max-width: 1deg)", "not all"}, | 70 {"screen and (max-width: 1deg)", "not all"}, |
71 {"handheld and (min-width: 20em), \nscreen and (min-width: 20em)", "hand
held and (min-width: 20em), screen and (min-width: 20em)"}, | 71 {"handheld and (min-width: 20em), \nscreen and (min-width: 20em)", "hand
held and (min-width: 20em), screen and (min-width: 20em)"}, |
72 {"print and (min-resolution: 300dpi)", 0}, | 72 {"print and (min-resolution: 300dpi)", 0}, |
73 {"print and (min-resolution: 118dpcm)", 0}, | 73 {"print and (min-resolution: 118dpcm)", 0}, |
74 {"(resolution: 0.83333333333333333333dppx)", "(resolution: 0.83333333333
33334dppx)"}, | 74 {"(resolution: 0.83333333333333333333dppx)", "(resolution: 0.83333333333
33334dppx)"}, |
75 {"(resolution: 2.4dppx)", 0}, | 75 {"(resolution: 2.4dppx)", 0}, |
76 {"all and(color)", "not all"}, | 76 {"all and(color)", "not all"}, |
77 {"all and (", "not all"}, | 77 {"all and (", "not all"}, |
78 {"test;,all", "not all, all"}, | 78 {"test;,all", "not all, all"}, |
79 {"(color:20example)", "not all"}, | 79 // {"(color:20example)", "not all"}, |
80 {"not braille", 0}, | 80 {"not braille", 0}, |
81 {",screen", "not all, screen"}, | 81 {",screen", "not all, screen"}, |
82 {",all", "not all, all"}, | 82 {",all", "not all, all"}, |
83 {",,all,,", "not all, not all, all, not all, not all"}, | 83 {",,all,,", "not all, not all, all, not all, not all"}, |
84 {",,all,, ", "not all, not all, all, not all, not all"}, | 84 {",,all,, ", "not all, not all, all, not all, not all"}, |
85 {",screen,,&invalid,,", "not all, screen, not all, not all, not all, not
all"}, | 85 {",screen,,&invalid,,", "not all, screen, not all, not all, not all, not
all"}, |
86 {",screen,,(invalid,),,", "not all, screen, not all, not all, not all, n
ot all"}, | 86 {",screen,,(invalid,),,", "not all, screen, not all, not all, not all, n
ot all"}, |
87 {",(all,),,", "not all, not all, not all, not all"}, | 87 {",(all,),,", "not all, not all, not all, not all"}, |
88 {",", "not all, not all"}, | 88 {",", "not all, not all"}, |
89 {" ", ""}, | 89 {" ", ""}, |
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: 900px)", "not all"}, |
| 101 {"[{}, (max-width: 900px)", "not all"}, |
| 102 {"[{]}], (max-width: 900px)", "not all, (max-width: 900px)"}, |
| 103 {"[{[]{}{{{}}}}], (max-width: 900px)", "not all, (max-width: 900px)"}, |
| 104 {"[{[}], (max-width: 900px)", "not all"}, |
| 105 {"[({)}], (max-width: 900px)", "not all"}, |
100 {0, 0} // Do not remove the terminator line. | 106 {0, 0} // Do not remove the terminator line. |
101 }; | 107 }; |
102 | 108 |
103 for (unsigned i = 0; testCases[i].input; ++i) { | 109 for (unsigned i = 0; testCases[i].input; ++i) { |
104 RefPtrWillBeRawPtr<MediaQuerySet> querySet = MediaQuerySet::create(testC
ases[i].input); | 110 RefPtrWillBeRawPtr<MediaQuerySet> querySet = MediaQuerySet::create(testC
ases[i].input); |
105 StringBuilder output; | 111 StringBuilder output; |
106 size_t j = 0; | 112 size_t j = 0; |
107 while (j < querySet->queryVector().size()) { | 113 while (j < querySet->queryVector().size()) { |
108 String queryText = querySet->queryVector()[j]->cssText(); | 114 String queryText = querySet->queryVector()[j]->cssText(); |
109 output.append(queryText); | 115 output.append(queryText); |
110 ++j; | 116 ++j; |
111 if (j >= querySet->queryVector().size()) | 117 if (j >= querySet->queryVector().size()) |
112 break; | 118 break; |
113 output.append(", "); | 119 output.append(", "); |
114 } | 120 } |
115 if (testCases[i].output) | 121 if (testCases[i].output) |
116 ASSERT_STREQ(testCases[i].output, output.toString().ascii().data()); | 122 ASSERT_STREQ(testCases[i].output, output.toString().ascii().data()); |
117 else | 123 else |
118 ASSERT_STREQ(testCases[i].input, output.toString().ascii().data()); | 124 ASSERT_STREQ(testCases[i].input, output.toString().ascii().data()); |
119 } | 125 } |
120 } | 126 } |
121 | 127 |
122 } // namespace | 128 } // namespace |
OLD | NEW |