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

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

Issue 603193005: Move the Widget hierarchy to the Oilpan heap. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Add ~Scrollbar assert Created 6 years, 2 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/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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 70
71 TestCase printTestCases[] = { 71 TestCase printTestCases[] = {
72 {"print and (min-resolution: 1dppx)", 1}, 72 {"print and (min-resolution: 1dppx)", 1},
73 {"print and (min-resolution: 118dpcm)", 1}, 73 {"print and (min-resolution: 118dpcm)", 1},
74 {"print and (min-resolution: 119dpcm)", 0}, 74 {"print and (min-resolution: 119dpcm)", 0},
75 {0, 0} // Do not remove the terminator line. 75 {0, 0} // Do not remove the terminator line.
76 }; 76 };
77 77
78 void testMQEvaluator(TestCase* testCases, const MediaQueryEvaluator& mediaQueryE valuator) 78 void testMQEvaluator(TestCase* testCases, const MediaQueryEvaluator& mediaQueryE valuator)
79 { 79 {
80 RefPtrWillBePersistent<MediaQuerySet> querySet = nullptr;
80 for (unsigned i = 0; testCases[i].input; ++i) { 81 for (unsigned i = 0; testCases[i].input; ++i) {
81 RefPtrWillBeRawPtr<MediaQuerySet> querySet = MediaQuerySet::create(testC ases[i].input); 82 querySet = MediaQuerySet::create(testCases[i].input);
82 ASSERT_EQ(testCases[i].output, mediaQueryEvaluator.eval(querySet.get())) ; 83 ASSERT_EQ(testCases[i].output, mediaQueryEvaluator.eval(querySet.get())) ;
83 } 84 }
84 } 85 }
85 86
86 TEST(MediaQueryEvaluatorTest, Cached) 87 TEST(MediaQueryEvaluatorTest, Cached)
87 { 88 {
88 MediaValuesCached::MediaValuesCachedData data; 89 MediaValuesCached::MediaValuesCachedData data;
89 data.viewportWidth = 500; 90 data.viewportWidth = 500;
90 data.viewportHeight = 500; 91 data.viewportHeight = 500;
91 data.deviceWidth = 500; 92 data.deviceWidth = 500;
(...skipping 26 matching lines...) Expand all
118 119
119 MediaQueryEvaluator mediaQueryEvaluator(&pageHolder->frame()); 120 MediaQueryEvaluator mediaQueryEvaluator(&pageHolder->frame());
120 testMQEvaluator(viewportTestCases, mediaQueryEvaluator); 121 testMQEvaluator(viewportTestCases, mediaQueryEvaluator);
121 pageHolder->frameView().setMediaType(MediaTypeNames::print); 122 pageHolder->frameView().setMediaType(MediaTypeNames::print);
122 testMQEvaluator(printTestCases, mediaQueryEvaluator); 123 testMQEvaluator(printTestCases, mediaQueryEvaluator);
123 } 124 }
124 125
125 TEST(MediaQueryEvaluatorTest, DynamicNoView) 126 TEST(MediaQueryEvaluatorTest, DynamicNoView)
126 { 127 {
127 OwnPtr<DummyPageHolder> pageHolder = DummyPageHolder::create(IntSize(500, 50 0)); 128 OwnPtr<DummyPageHolder> pageHolder = DummyPageHolder::create(IntSize(500, 50 0));
128 RefPtr<FrameView> view = pageHolder->frame().view(); 129 RefPtrWillBePersistent<FrameView> view = pageHolder->frame().view();
129 pageHolder->frame().setView(nullptr); 130 pageHolder->frame().setView(nullptr);
130 MediaQueryEvaluator mediaQueryEvaluator(&pageHolder->frame()); 131 MediaQueryEvaluator mediaQueryEvaluator(&pageHolder->frame());
131 RefPtrWillBeRawPtr<MediaQuerySet> querySet = MediaQuerySet::create("foobar") ; 132 RefPtrWillBePersistent<MediaQuerySet> querySet = MediaQuerySet::create("foob ar");
132 bool output = false; 133 bool output = false;
133 ASSERT_EQ(output, mediaQueryEvaluator.eval(querySet.get())); 134 ASSERT_EQ(output, mediaQueryEvaluator.eval(querySet.get()));
134 pageHolder->frame().setView(view); 135 pageHolder->frame().setView(view);
135 } 136 }
136 137
137 } // namespace 138 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698