| 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 "core/css/MediaQueryEvaluator.h" | 5 #include "core/css/MediaQueryEvaluator.h" |
| 6 | 6 |
| 7 #include "core/MediaTypeNames.h" | 7 #include "core/MediaTypeNames.h" |
| 8 #include "core/css/MediaList.h" | 8 #include "core/css/MediaList.h" |
| 9 #include "core/css/MediaValuesCached.h" | 9 #include "core/css/MediaValuesCached.h" |
| 10 #include "core/frame/FrameView.h" | 10 #include "core/frame/FrameView.h" |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 {"(max-height: 701px)", 1}, | 108 {"(max-height: 701px)", 1}, |
| 109 {"(max-height: 700.125px)", 1}, | 109 {"(max-height: 700.125px)", 1}, |
| 110 {"(max-height: 700px)", 0}, | 110 {"(max-height: 700px)", 0}, |
| 111 {"(height: 700.125px)", 1}, | 111 {"(height: 700.125px)", 1}, |
| 112 {"(height: 700.126px)", 0}, | 112 {"(height: 700.126px)", 0}, |
| 113 {"(height: 700.124px)", 0}, | 113 {"(height: 700.124px)", 0}, |
| 114 {"(height: 701px)", 0}, | 114 {"(height: 701px)", 0}, |
| 115 {0, 0} // Do not remove the terminator line. | 115 {0, 0} // Do not remove the terminator line. |
| 116 }; | 116 }; |
| 117 | 117 |
| 118 TestCase floatNonFriendlyViewportTestCases[] = { |
| 119 {"(min-width: 821px)", 1}, |
| 120 {"(max-width: 821px)", 1}, |
| 121 {"(width: 821px)", 1}, |
| 122 {"(min-height: 821px)", 1}, |
| 123 {"(max-height: 821px)", 1}, |
| 124 {"(height: 821px)", 1}, |
| 125 {"(width: 100vw)", 1}, |
| 126 {"(height: 100vh)", 1}, |
| 127 {0, 0} // Do not remove the terminator line. |
| 128 }; |
| 129 |
| 118 TestCase printTestCases[] = { | 130 TestCase printTestCases[] = { |
| 119 {"print and (min-resolution: 1dppx)", 1}, | 131 {"print and (min-resolution: 1dppx)", 1}, |
| 120 {"print and (min-resolution: 118dpcm)", 1}, | 132 {"print and (min-resolution: 118dpcm)", 1}, |
| 121 {"print and (min-resolution: 119dpcm)", 0}, | 133 {"print and (min-resolution: 119dpcm)", 0}, |
| 122 {0, 0} // Do not remove the terminator line. | 134 {0, 0} // Do not remove the terminator line. |
| 123 }; | 135 }; |
| 124 | 136 |
| 125 void testMQEvaluator(TestCase* testCases, const MediaQueryEvaluator& mediaQueryE
valuator) | 137 void testMQEvaluator(TestCase* testCases, const MediaQueryEvaluator& mediaQueryE
valuator) |
| 126 { | 138 { |
| 127 Persistent<MediaQuerySet> querySet = nullptr; | 139 Persistent<MediaQuerySet> querySet = nullptr; |
| 128 for (unsigned i = 0; testCases[i].input; ++i) { | 140 for (unsigned i = 0; testCases[i].input; ++i) { |
| 129 querySet = MediaQuerySet::create(testCases[i].input); | 141 querySet = MediaQuerySet::create(testCases[i].input); |
| 130 ASSERT_EQ(testCases[i].output, mediaQueryEvaluator.eval(querySet.get()))
; | 142 EXPECT_EQ(testCases[i].output, mediaQueryEvaluator.eval(querySet.get()))
; |
| 131 } | 143 } |
| 132 } | 144 } |
| 133 | 145 |
| 134 TEST(MediaQueryEvaluatorTest, Cached) | 146 TEST(MediaQueryEvaluatorTest, Cached) |
| 135 { | 147 { |
| 136 MediaValuesCached::MediaValuesCachedData data; | 148 MediaValuesCached::MediaValuesCachedData data; |
| 137 data.viewportWidth = 500; | 149 data.viewportWidth = 500; |
| 138 data.viewportHeight = 500; | 150 data.viewportHeight = 500; |
| 139 data.deviceWidth = 500; | 151 data.deviceWidth = 500; |
| 140 data.deviceHeight = 500; | 152 data.deviceHeight = 500; |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 { | 198 { |
| 187 MediaValuesCached::MediaValuesCachedData data; | 199 MediaValuesCached::MediaValuesCachedData data; |
| 188 data.viewportWidth = 600.5; | 200 data.viewportWidth = 600.5; |
| 189 data.viewportHeight = 700.125; | 201 data.viewportHeight = 700.125; |
| 190 MediaValues* mediaValues = MediaValuesCached::create(data); | 202 MediaValues* mediaValues = MediaValuesCached::create(data); |
| 191 | 203 |
| 192 MediaQueryEvaluator mediaQueryEvaluator(*mediaValues); | 204 MediaQueryEvaluator mediaQueryEvaluator(*mediaValues); |
| 193 testMQEvaluator(floatViewportTestCases, mediaQueryEvaluator); | 205 testMQEvaluator(floatViewportTestCases, mediaQueryEvaluator); |
| 194 } | 206 } |
| 195 | 207 |
| 208 TEST(MediaQueryEvaluatorTest, CachedFloatViewportNonFloatFriendly) |
| 209 { |
| 210 MediaValuesCached::MediaValuesCachedData data; |
| 211 data.viewportWidth = 821; |
| 212 data.viewportHeight = 821; |
| 213 MediaValues* mediaValues = MediaValuesCached::create(data); |
| 214 |
| 215 MediaQueryEvaluator mediaQueryEvaluator(*mediaValues); |
| 216 testMQEvaluator(floatNonFriendlyViewportTestCases, mediaQueryEvaluator); |
| 217 } |
| 218 |
| 196 } // namespace blink | 219 } // namespace blink |
| OLD | NEW |