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

Unified 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, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: Source/web/tests/FrameTestHelpers.cpp
diff --git a/Source/web/tests/FrameTestHelpers.cpp b/Source/web/tests/FrameTestHelpers.cpp
index 7f4893f818cf1d823e00092cc80567afae551fcc..1679347c70cf7888639e74257925d76ffd7b8a0f 100644
--- a/Source/web/tests/FrameTestHelpers.cpp
+++ b/Source/web/tests/FrameTestHelpers.cpp
@@ -32,17 +32,25 @@
#include "FrameTestHelpers.h"
#include "URLTestHelpers.h"
-#include "wtf/StdLibExtras.h"
+#include "UserAgentStyleSheets.h"
#include "WebFrameClient.h"
#include "WebFrameImpl.h"
#include "WebSettings.h"
#include "WebViewClient.h"
+#include "core/css/CSSDefaultStyleSheets.h"
+#include "core/css/RuleSet.h"
+#include "core/css/StyleSheetContents.h"
+#include "core/css/ViewportStyle.h"
+#include "core/page/Settings.h"
+#include "core/platform/ScrollbarTheme.h"
abarth-chromium 2013/11/27 18:43:50 It's sad to have all these detailed dependencies.
#include "public/platform/Platform.h"
#include "public/platform/WebString.h"
#include "public/platform/WebThread.h"
#include "public/platform/WebURLRequest.h"
#include "public/platform/WebURLResponse.h"
#include "public/platform/WebUnitTestSupport.h"
+#include "wtf/StdLibExtras.h"
+#include <gtest/gtest.h>
namespace blink {
namespace FrameTestHelpers {
@@ -96,6 +104,13 @@ void runPendingTasks()
Platform::current()->currentThread()->enterRunLoop();
}
+void setViewportSettings(WebSettings* settings)
+{
+ settings->setViewportMetaEnabled(true);
+ settings->setViewportEnabled(true);
+ settings->setMainFrameResizesAreOrientationChanges(true);
+}
+
WebViewHelper::WebViewHelper()
: m_mainFrame(0)
, m_webView(0)
@@ -152,5 +167,74 @@ void WebViewHelper::reset()
}
}
+UseMockScrollbarSettings::UseMockScrollbarSettings()
+{
+ WebCore::Settings::setMockScrollbarsEnabled(true);
+ WebCore::RuntimeEnabledFeatures::setOverlayScrollbarsEnabled(true);
+ EXPECT_TRUE(WebCore::ScrollbarTheme::theme()->usesOverlayScrollbars());
+}
+
+UseMockScrollbarSettings::~UseMockScrollbarSettings()
+{
+ WebCore::Settings::setMockScrollbarsEnabled(false);
+ WebCore::RuntimeEnabledFeatures::setOverlayScrollbarsEnabled(false);
+}
abarth-chromium 2013/11/27 18:43:50 These seem fine because they're poking at well-def
+
+// Since UA stylesheets get loaded statically at first use, we need this to
+// reset the UA stylesheets so that we can have per-test UA stylesheets and
+// have Blink pick up a newly injected viewport stylesheet.
+static void resetCSSDefaultStyleSheets()
+{
+ if (WebCore::CSSDefaultStyleSheets::defaultPrintStyle
+ == WebCore::CSSDefaultStyleSheets::defaultStyle)
+ WebCore::CSSDefaultStyleSheets::defaultPrintStyle = 0;
+
+#define RESET(x) \
+if (WebCore::CSSDefaultStyleSheets::x) { \
+ delete WebCore::CSSDefaultStyleSheets::x; \
+ WebCore::CSSDefaultStyleSheets::x = 0; \
+}
+
+ RESET(defaultStyle)
+ RESET(defaultQuirksStyle)
+ RESET(defaultPrintStyle)
+ RESET(defaultViewSourceStyle)
+ RESET(defaultXHTMLMobileProfileStyle)
+
+#undef RESET
+#define RESET(x) \
+if (WebCore::CSSDefaultStyleSheets::x) { \
+ WebCore::CSSDefaultStyleSheets::x->deref(); \
+ WebCore::CSSDefaultStyleSheets::x = 0; \
+}
+
+ RESET(defaultStyleSheet)
+ RESET(quirksStyleSheet)
+ RESET(svgStyleSheet)
+ RESET(mediaControlsStyleSheet)
+ RESET(fullscreenStyleSheet)
+
+#undef RESET
+}
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
+
+ReplaceViewportUAStylesheet::ReplaceViewportUAStylesheet(WTF::String uaStylesheet)
+{
+ resetCSSDefaultStyleSheets();
+ WebCore::ViewportStyle::styleOverrideString() = String(uaStylesheet);
+}
+
+ReplaceViewportUAStylesheet::~ReplaceViewportUAStylesheet()
+{
+ WebCore::ViewportStyle::styleOverrideString() = WTF::String();
+ resetCSSDefaultStyleSheets();
+}
+
+UseAndroidViewportUAStylesheet::UseAndroidViewportUAStylesheet()
+ : ReplaceViewportUAStylesheet(String(
+ WebCore::viewportAndroidUserAgentStyleSheet,
+ sizeof(WebCore::viewportAndroidUserAgentStyleSheet)))
+{
+}
+
} // namespace FrameTestHelpers
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698