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

Side by Side Diff: third_party/WebKit/Source/core/css/MediaQueryEvaluatorTest.cpp

Issue 1496683002: Avoid rounding down viewport dimensions in Media Queries (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Moved to double Created 5 years 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/MediaQueryEvaluator.h" 6 #include "core/css/MediaQueryEvaluator.h"
7 7
8 #include "core/MediaTypeNames.h" 8 #include "core/MediaTypeNames.h"
9 #include "core/css/MediaList.h" 9 #include "core/css/MediaList.h"
10 #include "core/css/MediaValuesCached.h" 10 #include "core/css/MediaValuesCached.h"
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 {"(height: 500.001px)", 0}, 85 {"(height: 500.001px)", 0},
86 {"(height: 499.999px)", 0}, 86 {"(height: 499.999px)", 0},
87 {"(height: 501px)", 0}, 87 {"(height: 501px)", 0},
88 {"(height)", 1}, 88 {"(height)", 1},
89 {"(width)", 1}, 89 {"(width)", 1},
90 {"(width: whatisthis)", 0}, 90 {"(width: whatisthis)", 0},
91 {"screen and (min-width: 400px) and (max-width: 700px)", 1}, 91 {"screen and (min-width: 400px) and (max-width: 700px)", 1},
92 {0, 0} // Do not remove the terminator line. 92 {0, 0} // Do not remove the terminator line.
93 }; 93 };
94 94
95 TestCase floatViewportTestCases[] = {
96 {"all and (min-width: 600.5px)", 1},
97 {"(min-width: 600px)", 1},
98 {"(min-width: 600.5px)", 1},
99 {"(min-width: 601px)", 0},
100 {"(max-width: 600px)", 0},
101 {"(max-width: 600.5px)", 1},
102 {"(max-width: 601px)", 1},
103 {"(width: 600.5px)", 1},
104 {"(width: 601px)", 0},
105 {"(min-height: 700px)", 1},
106 {"(min-height: 700.125px)", 1},
107 {"(min-height: 701px)", 0},
108 {"(min-height: 700.126px)", 0},
109 {"(max-height: 701px)", 1},
110 {"(max-height: 700.125px)", 1},
111 {"(max-height: 700px)", 0},
112 {"(height: 700.125px)", 1},
113 {"(height: 700.126px)", 0},
114 {"(height: 700.124px)", 0},
115 {"(height: 701px)", 0},
116 {0, 0} // Do not remove the terminator line.
117 };
118
95 TestCase printTestCases[] = { 119 TestCase printTestCases[] = {
96 {"print and (min-resolution: 1dppx)", 1}, 120 {"print and (min-resolution: 1dppx)", 1},
97 {"print and (min-resolution: 118dpcm)", 1}, 121 {"print and (min-resolution: 118dpcm)", 1},
98 {"print and (min-resolution: 119dpcm)", 0}, 122 {"print and (min-resolution: 119dpcm)", 0},
99 {0, 0} // Do not remove the terminator line. 123 {0, 0} // Do not remove the terminator line.
100 }; 124 };
101 125
102 void testMQEvaluator(TestCase* testCases, const MediaQueryEvaluator& mediaQueryE valuator) 126 void testMQEvaluator(TestCase* testCases, const MediaQueryEvaluator& mediaQueryE valuator)
103 { 127 {
104 RefPtrWillBePersistent<MediaQuerySet> querySet = nullptr; 128 RefPtrWillBePersistent<MediaQuerySet> querySet = nullptr;
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 { 176 {
153 OwnPtr<DummyPageHolder> pageHolder = DummyPageHolder::create(IntSize(500, 50 0)); 177 OwnPtr<DummyPageHolder> pageHolder = DummyPageHolder::create(IntSize(500, 50 0));
154 RefPtrWillBeRawPtr<LocalFrame> frame = &pageHolder->frame(); 178 RefPtrWillBeRawPtr<LocalFrame> frame = &pageHolder->frame();
155 pageHolder.clear(); 179 pageHolder.clear();
156 ASSERT_EQ(nullptr, frame->view()); 180 ASSERT_EQ(nullptr, frame->view());
157 MediaQueryEvaluator mediaQueryEvaluator(frame.get()); 181 MediaQueryEvaluator mediaQueryEvaluator(frame.get());
158 RefPtrWillBeRawPtr<MediaQuerySet> querySet = MediaQuerySet::create("foobar") ; 182 RefPtrWillBeRawPtr<MediaQuerySet> querySet = MediaQuerySet::create("foobar") ;
159 EXPECT_FALSE(mediaQueryEvaluator.eval(querySet.get())); 183 EXPECT_FALSE(mediaQueryEvaluator.eval(querySet.get()));
160 } 184 }
161 185
186 TEST(MediaQueryEvaluatorTest, CachedFloatViewport)
187 {
188 MediaValuesCached::MediaValuesCachedData data;
189 data.viewportWidth = 600.5;
190 data.viewportHeight = 700.125;
191 RefPtrWillBeRawPtr<MediaValues> mediaValues = MediaValuesCached::create(data );
192
193 MediaQueryEvaluator mediaQueryEvaluator(*mediaValues);
194 testMQEvaluator(floatViewportTestCases, mediaQueryEvaluator);
195 }
196
162 } // namespace 197 } // namespace
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/css/MediaQueryEvaluator.cpp ('k') | third_party/WebKit/Source/core/css/MediaValues.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698