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

Unified Diff: Source/web/tests/WebFrameTest.cpp

Issue 1314903010: [DevTools] Add test for viewport invalidation on resize with emulation enabled. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | Source/web/tests/data/viewport_emulation.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/web/tests/WebFrameTest.cpp
diff --git a/Source/web/tests/WebFrameTest.cpp b/Source/web/tests/WebFrameTest.cpp
index ce479e49f729517d372f2f70f8744fa037ccabd4..d08fd605676aab61fcc0be89b0fdcca106bee359 100644
--- a/Source/web/tests/WebFrameTest.cpp
+++ b/Source/web/tests/WebFrameTest.cpp
@@ -97,6 +97,7 @@
#include "public/web/WebCache.h"
#include "public/web/WebConsoleMessage.h"
#include "public/web/WebDataSource.h"
+#include "public/web/WebDeviceEmulationParams.h"
#include "public/web/WebDocument.h"
#include "public/web/WebFindOptions.h"
#include "public/web/WebFormElement.h"
@@ -7732,6 +7733,57 @@ TEST_P(ParameterizedWebFrameTest, CrossDomainAccessErrorsUseCallingWindow)
popupWebViewHelper.reset();
}
+class ViewportOnResizeTest : public ParameterizedWebFrameTest {
+protected:
+ ViewportOnResizeTest()
+ : m_webViewHelper(this)
+ {
+ registerMockedHttpURLLoad("viewport_emulation.html");
+ m_client.m_screenInfo.deviceScaleFactor = 1;
+ m_webViewHelper.initializeAndLoad(m_baseURL + "viewport_emulation.html", true, 0, &m_client);
+ }
+
+ void testResize(const WebSize size, const String& expectedSize)
+ {
+ m_client.m_screenInfo.rect = WebRect(0, 0, size.width, size.height);
+ m_client.m_screenInfo.availableRect = m_client.m_screenInfo.rect;
+ m_webViewHelper.webView()->resize(size);
+ m_webViewHelper.webView()->layout();
+
+ v8::HandleScope scope(v8::Isolate::GetCurrent());
+ ScriptExecutionCallbackHelper callbackHelper(m_webViewHelper.webView()->mainFrame()->mainWorldScriptContext());
+ m_webViewHelper.webView()->mainFrame()->toWebLocalFrame()->requestExecuteScriptAndReturnValue(WebScriptSource(WebString("dumpSize()")), false, &callbackHelper);
+ runPendingTasks();
+ EXPECT_TRUE(callbackHelper.didComplete());
+ EXPECT_EQ(expectedSize, callbackHelper.stringValue());
+ }
+
+ FixedLayoutTestWebViewClient m_client;
+ FrameTestHelpers::WebViewHelper m_webViewHelper;
+};
+
+INSTANTIATE_TEST_CASE_P(All, ViewportOnResizeTest, ::testing::Values(
+ ParameterizedWebFrameTestConfig::Default,
+ ParameterizedWebFrameTestConfig::RootLayerScrolls));
+
+TEST_P(ViewportOnResizeTest, ViewportInvalidatedOnResizeWithEmulation)
+{
+ WebDeviceEmulationParams params;
+ params.screenPosition = WebDeviceEmulationParams::Mobile;
+ m_webViewHelper.webView()->enableDeviceEmulation(params);
+
+ testResize(WebSize(700, 500), "300x300");
+ testResize(WebSize(710, 500), "400x300");
+ testResize(WebSize(690, 500), "200x300");
+ testResize(WebSize(700, 510), "300x400");
+ testResize(WebSize(700, 490), "300x200");
+ testResize(WebSize(710, 510), "400x400");
+ testResize(WebSize(690, 490), "200x200");
+ testResize(WebSize(800, 600), "400x400");
+
+ m_webViewHelper.webView()->disableDeviceEmulation();
+}
+
class WebLocalFrameScope final {
public:
WebLocalFrameScope(WebLocalFrame* localFrame)
« no previous file with comments | « no previous file | Source/web/tests/data/viewport_emulation.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698