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

Side by Side Diff: Source/web/tests/FrameTestHelpers.cpp

Issue 78963008: Moved remaining legacy viewport tests to unit tests. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 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 /* 1 /*
2 * Copyright (C) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 14 matching lines...) Expand all
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #include "config.h" 31 #include "config.h"
32 #include "FrameTestHelpers.h" 32 #include "FrameTestHelpers.h"
33 33
34 #include "URLTestHelpers.h" 34 #include "URLTestHelpers.h"
35 #include "wtf/StdLibExtras.h" 35 #include "UserAgentStyleSheets.h"
36 #include "WebFrameClient.h" 36 #include "WebFrameClient.h"
37 #include "WebFrameImpl.h" 37 #include "WebFrameImpl.h"
38 #include "WebSettings.h" 38 #include "WebSettings.h"
39 #include "WebViewClient.h" 39 #include "WebViewClient.h"
40 #include "core/css/CSSDefaultStyleSheets.h"
41 #include "core/css/RuleSet.h"
42 #include "core/css/StyleSheetContents.h"
43 #include "core/css/ViewportStyle.h"
44 #include "core/page/Settings.h"
45 #include "core/platform/ScrollbarTheme.h"
abarth-chromium 2013/11/27 18:43:50 It's sad to have all these detailed dependencies.
40 #include "public/platform/Platform.h" 46 #include "public/platform/Platform.h"
41 #include "public/platform/WebString.h" 47 #include "public/platform/WebString.h"
42 #include "public/platform/WebThread.h" 48 #include "public/platform/WebThread.h"
43 #include "public/platform/WebURLRequest.h" 49 #include "public/platform/WebURLRequest.h"
44 #include "public/platform/WebURLResponse.h" 50 #include "public/platform/WebURLResponse.h"
45 #include "public/platform/WebUnitTestSupport.h" 51 #include "public/platform/WebUnitTestSupport.h"
52 #include "wtf/StdLibExtras.h"
53 #include <gtest/gtest.h>
46 54
47 namespace blink { 55 namespace blink {
48 namespace FrameTestHelpers { 56 namespace FrameTestHelpers {
49 57
50 namespace { 58 namespace {
51 59
52 class QuitTask : public WebThread::Task { 60 class QuitTask : public WebThread::Task {
53 public: 61 public:
54 void PostThis(WebCore::Timer<QuitTask>*) 62 void PostThis(WebCore::Timer<QuitTask>*)
55 { 63 {
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 } 97 }
90 98
91 void runPendingTasks() 99 void runPendingTasks()
92 { 100 {
93 // Pending tasks include Timers that have been scheduled. 101 // Pending tasks include Timers that have been scheduled.
94 WebCore::Timer<QuitTask> quitOnTimeout(new QuitTask, &QuitTask::PostThis); 102 WebCore::Timer<QuitTask> quitOnTimeout(new QuitTask, &QuitTask::PostThis);
95 quitOnTimeout.startOneShot(0); 103 quitOnTimeout.startOneShot(0);
96 Platform::current()->currentThread()->enterRunLoop(); 104 Platform::current()->currentThread()->enterRunLoop();
97 } 105 }
98 106
107 void setViewportSettings(WebSettings* settings)
108 {
109 settings->setViewportMetaEnabled(true);
110 settings->setViewportEnabled(true);
111 settings->setMainFrameResizesAreOrientationChanges(true);
112 }
113
99 WebViewHelper::WebViewHelper() 114 WebViewHelper::WebViewHelper()
100 : m_mainFrame(0) 115 : m_mainFrame(0)
101 , m_webView(0) 116 , m_webView(0)
102 { 117 {
103 } 118 }
104 119
105 WebViewHelper::~WebViewHelper() 120 WebViewHelper::~WebViewHelper()
106 { 121 {
107 reset(); 122 reset();
108 } 123 }
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 if (m_webView) { 160 if (m_webView) {
146 m_webView->close(); 161 m_webView->close();
147 m_webView = 0; 162 m_webView = 0;
148 } 163 }
149 if (m_mainFrame) { 164 if (m_mainFrame) {
150 m_mainFrame->close(); 165 m_mainFrame->close();
151 m_mainFrame = 0; 166 m_mainFrame = 0;
152 } 167 }
153 } 168 }
154 169
170 UseMockScrollbarSettings::UseMockScrollbarSettings()
171 {
172 WebCore::Settings::setMockScrollbarsEnabled(true);
173 WebCore::RuntimeEnabledFeatures::setOverlayScrollbarsEnabled(true);
174 EXPECT_TRUE(WebCore::ScrollbarTheme::theme()->usesOverlayScrollbars());
175 }
176
177 UseMockScrollbarSettings::~UseMockScrollbarSettings()
178 {
179 WebCore::Settings::setMockScrollbarsEnabled(false);
180 WebCore::RuntimeEnabledFeatures::setOverlayScrollbarsEnabled(false);
181 }
abarth-chromium 2013/11/27 18:43:50 These seem fine because they're poking at well-def
182
183 // Since UA stylesheets get loaded statically at first use, we need this to
184 // reset the UA stylesheets so that we can have per-test UA stylesheets and
185 // have Blink pick up a newly injected viewport stylesheet.
186 static void resetCSSDefaultStyleSheets()
187 {
188 if (WebCore::CSSDefaultStyleSheets::defaultPrintStyle
189 == WebCore::CSSDefaultStyleSheets::defaultStyle)
190 WebCore::CSSDefaultStyleSheets::defaultPrintStyle = 0;
191
192 #define RESET(x) \
193 if (WebCore::CSSDefaultStyleSheets::x) { \
194 delete WebCore::CSSDefaultStyleSheets::x; \
195 WebCore::CSSDefaultStyleSheets::x = 0; \
196 }
197
198 RESET(defaultStyle)
199 RESET(defaultQuirksStyle)
200 RESET(defaultPrintStyle)
201 RESET(defaultViewSourceStyle)
202 RESET(defaultXHTMLMobileProfileStyle)
203
204 #undef RESET
205 #define RESET(x) \
206 if (WebCore::CSSDefaultStyleSheets::x) { \
207 WebCore::CSSDefaultStyleSheets::x->deref(); \
208 WebCore::CSSDefaultStyleSheets::x = 0; \
209 }
210
211 RESET(defaultStyleSheet)
212 RESET(quirksStyleSheet)
213 RESET(svgStyleSheet)
214 RESET(mediaControlsStyleSheet)
215 RESET(fullscreenStyleSheet)
216
217 #undef RESET
218 }
abarth-chromium 2013/11/27 18:43:50 These seem a bit more questionable....
bokan 2013/11/27 19:20:10 Yah, this feels wrong but there seems to be no way
219
220 ReplaceViewportUAStylesheet::ReplaceViewportUAStylesheet(WTF::String uaStyleshee t)
221 {
222 resetCSSDefaultStyleSheets();
223 WebCore::ViewportStyle::styleOverrideString() = String(uaStylesheet);
224 }
225
226 ReplaceViewportUAStylesheet::~ReplaceViewportUAStylesheet()
227 {
228 WebCore::ViewportStyle::styleOverrideString() = WTF::String();
229 resetCSSDefaultStyleSheets();
230 }
231
232 UseAndroidViewportUAStylesheet::UseAndroidViewportUAStylesheet()
233 : ReplaceViewportUAStylesheet(String(
234 WebCore::viewportAndroidUserAgentStyleSheet,
235 sizeof(WebCore::viewportAndroidUserAgentStyleSheet)))
236 {
237 }
238
155 } // namespace FrameTestHelpers 239 } // namespace FrameTestHelpers
156 } // namespace blink 240 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698