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/parser/SizesCalcParser.h" | 6 #include "core/css/parser/SizesCalcParser.h" |
7 | 7 |
| 8 #include "core/MediaTypeNames.h" |
8 #include "core/css/CSSPrimitiveValue.h" | 9 #include "core/css/CSSPrimitiveValue.h" |
9 #include "core/css/MediaValuesCached.h" | 10 #include "core/css/MediaValuesCached.h" |
10 #include "core/css/StylePropertySet.h" | 11 #include "core/css/StylePropertySet.h" |
11 #include "core/css/parser/MediaQueryTokenizer.h" | 12 #include "core/css/parser/MediaQueryTokenizer.h" |
12 | 13 |
13 #include <gtest/gtest.h> | 14 #include <gtest/gtest.h> |
14 | 15 |
15 namespace WebCore { | 16 namespace WebCore { |
16 | 17 |
17 struct TestCase { | 18 struct TestCase { |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 data.viewportWidth = 500; | 104 data.viewportWidth = 500; |
104 data.viewportHeight = 643; | 105 data.viewportHeight = 643; |
105 data.deviceWidth = 500; | 106 data.deviceWidth = 500; |
106 data.deviceHeight = 643; | 107 data.deviceHeight = 643; |
107 data.devicePixelRatio = 2.0; | 108 data.devicePixelRatio = 2.0; |
108 data.colorBitsPerComponent = 24; | 109 data.colorBitsPerComponent = 24; |
109 data.monochromeBitsPerComponent = 0; | 110 data.monochromeBitsPerComponent = 0; |
110 data.pointer = MediaValues::MousePointer; | 111 data.pointer = MediaValues::MousePointer; |
111 data.defaultFontSize = 16; | 112 data.defaultFontSize = 16; |
112 data.threeDEnabled = true; | 113 data.threeDEnabled = true; |
113 data.scanMediaType = false; | 114 data.mediaType = MediaTypeNames::screen; |
114 data.screenMediaType = true; | |
115 data.printMediaType = false; | |
116 data.strictMode = true; | 115 data.strictMode = true; |
117 RefPtr<MediaValues> mediaValues = MediaValuesCached::create(data); | 116 RefPtr<MediaValues> mediaValues = MediaValuesCached::create(data); |
118 | 117 |
119 for (unsigned i = 0; testCases[i].input; ++i) { | 118 for (unsigned i = 0; testCases[i].input; ++i) { |
120 Vector<MediaQueryToken> tokens; | 119 Vector<MediaQueryToken> tokens; |
121 MediaQueryTokenizer::tokenize(testCases[i].input, tokens); | 120 MediaQueryTokenizer::tokenize(testCases[i].input, tokens); |
122 unsigned output; | 121 unsigned output; |
123 bool valid = SizesCalcParser::parse(tokens.begin(), tokens.end(), mediaV
alues, output); | 122 bool valid = SizesCalcParser::parse(tokens.begin(), tokens.end(), mediaV
alues, output); |
124 ASSERT_EQ(testCases[i].valid, valid); | 123 ASSERT_EQ(testCases[i].valid, valid); |
125 if (valid) | 124 if (valid) |
126 ASSERT_EQ(testCases[i].output, output); | 125 ASSERT_EQ(testCases[i].output, output); |
127 } | 126 } |
128 | 127 |
129 for (unsigned i = 0; testCases[i].input; ++i) { | 128 for (unsigned i = 0; testCases[i].input; ++i) { |
130 if (testCases[i].dontRunInCSSCalc) | 129 if (testCases[i].dontRunInCSSCalc) |
131 continue; | 130 continue; |
132 verifyCSSCalc(testCases[i].input, testCases[i].output, testCases[i].vali
d, data.defaultFontSize, data.viewportWidth, data.viewportHeight); | 131 verifyCSSCalc(testCases[i].input, testCases[i].output, testCases[i].vali
d, data.defaultFontSize, data.viewportWidth, data.viewportHeight); |
133 } | 132 } |
134 } | 133 } |
135 | 134 |
136 } // namespace | 135 } // namespace |
OLD | NEW |