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

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: Rebased upto r183571 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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 77
78 TestCase printTestCases[] = { 78 TestCase printTestCases[] = {
79 {"print and (min-resolution: 1dppx)", 1}, 79 {"print and (min-resolution: 1dppx)", 1},
80 {"print and (min-resolution: 118dpcm)", 1}, 80 {"print and (min-resolution: 118dpcm)", 1},
81 {"print and (min-resolution: 119dpcm)", 0}, 81 {"print and (min-resolution: 119dpcm)", 0},
82 {0, 0} // Do not remove the terminator line. 82 {0, 0} // Do not remove the terminator line.
83 }; 83 };
84 84
85 void testMQEvaluator(TestCase* testCases, const MediaQueryEvaluator& mediaQueryE valuator) 85 void testMQEvaluator(TestCase* testCases, const MediaQueryEvaluator& mediaQueryE valuator)
86 { 86 {
87 RefPtrWillBePersistent<MediaQuerySet> querySet = nullptr;
87 for (unsigned i = 0; testCases[i].input; ++i) { 88 for (unsigned i = 0; testCases[i].input; ++i) {
88 RefPtrWillBeRawPtr<MediaQuerySet> querySet = MediaQuerySet::create(testC ases[i].input); 89 querySet = MediaQuerySet::create(testCases[i].input);
89 ASSERT_EQ(testCases[i].output, mediaQueryEvaluator.eval(querySet.get())) ; 90 ASSERT_EQ(testCases[i].output, mediaQueryEvaluator.eval(querySet.get())) ;
90 } 91 }
91 } 92 }
92 93
93 TEST(MediaQueryEvaluatorTest, Cached) 94 TEST(MediaQueryEvaluatorTest, Cached)
94 { 95 {
95 MediaValuesCached::MediaValuesCachedData data; 96 MediaValuesCached::MediaValuesCachedData data;
96 data.viewportWidth = 500; 97 data.viewportWidth = 500;
97 data.viewportHeight = 500; 98 data.viewportHeight = 500;
98 data.deviceWidth = 500; 99 data.deviceWidth = 500;
(...skipping 26 matching lines...) Expand all
125 126
126 MediaQueryEvaluator mediaQueryEvaluator(&pageHolder->frame()); 127 MediaQueryEvaluator mediaQueryEvaluator(&pageHolder->frame());
127 testMQEvaluator(viewportTestCases, mediaQueryEvaluator); 128 testMQEvaluator(viewportTestCases, mediaQueryEvaluator);
128 pageHolder->frameView().setMediaType(MediaTypeNames::print); 129 pageHolder->frameView().setMediaType(MediaTypeNames::print);
129 testMQEvaluator(printTestCases, mediaQueryEvaluator); 130 testMQEvaluator(printTestCases, mediaQueryEvaluator);
130 } 131 }
131 132
132 TEST(MediaQueryEvaluatorTest, DynamicNoView) 133 TEST(MediaQueryEvaluatorTest, DynamicNoView)
133 { 134 {
134 OwnPtr<DummyPageHolder> pageHolder = DummyPageHolder::create(IntSize(500, 50 0)); 135 OwnPtr<DummyPageHolder> pageHolder = DummyPageHolder::create(IntSize(500, 50 0));
135 RefPtr<FrameView> view = pageHolder->frame().view(); 136 RefPtrWillBePersistent<FrameView> view = pageHolder->frame().view();
136 pageHolder->frame().setView(nullptr); 137 pageHolder->frame().setView(nullptr);
137 MediaQueryEvaluator mediaQueryEvaluator(&pageHolder->frame()); 138 MediaQueryEvaluator mediaQueryEvaluator(&pageHolder->frame());
138 RefPtrWillBeRawPtr<MediaQuerySet> querySet = MediaQuerySet::create("foobar") ; 139 RefPtrWillBePersistent<MediaQuerySet> querySet = MediaQuerySet::create("foob ar");
139 bool output = false; 140 bool output = false;
140 ASSERT_EQ(output, mediaQueryEvaluator.eval(querySet.get())); 141 ASSERT_EQ(output, mediaQueryEvaluator.eval(querySet.get()));
141 pageHolder->frame().setView(view); 142 pageHolder->frame().setView(view);
142 } 143 }
143 144
144 } // namespace 145 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698