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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | Source/web/tests/data/viewport_emulation.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 #include "public/platform/Platform.h" 90 #include "public/platform/Platform.h"
91 #include "public/platform/WebFloatRect.h" 91 #include "public/platform/WebFloatRect.h"
92 #include "public/platform/WebSecurityOrigin.h" 92 #include "public/platform/WebSecurityOrigin.h"
93 #include "public/platform/WebThread.h" 93 #include "public/platform/WebThread.h"
94 #include "public/platform/WebURL.h" 94 #include "public/platform/WebURL.h"
95 #include "public/platform/WebURLResponse.h" 95 #include "public/platform/WebURLResponse.h"
96 #include "public/platform/WebUnitTestSupport.h" 96 #include "public/platform/WebUnitTestSupport.h"
97 #include "public/web/WebCache.h" 97 #include "public/web/WebCache.h"
98 #include "public/web/WebConsoleMessage.h" 98 #include "public/web/WebConsoleMessage.h"
99 #include "public/web/WebDataSource.h" 99 #include "public/web/WebDataSource.h"
100 #include "public/web/WebDeviceEmulationParams.h"
100 #include "public/web/WebDocument.h" 101 #include "public/web/WebDocument.h"
101 #include "public/web/WebFindOptions.h" 102 #include "public/web/WebFindOptions.h"
102 #include "public/web/WebFormElement.h" 103 #include "public/web/WebFormElement.h"
103 #include "public/web/WebFrameClient.h" 104 #include "public/web/WebFrameClient.h"
104 #include "public/web/WebFrameWidget.h" 105 #include "public/web/WebFrameWidget.h"
105 #include "public/web/WebHistoryItem.h" 106 #include "public/web/WebHistoryItem.h"
106 #include "public/web/WebPrintParams.h" 107 #include "public/web/WebPrintParams.h"
107 #include "public/web/WebRange.h" 108 #include "public/web/WebRange.h"
108 #include "public/web/WebRemoteFrame.h" 109 #include "public/web/WebRemoteFrame.h"
109 #include "public/web/WebScriptExecutionCallback.h" 110 #include "public/web/WebScriptExecutionCallback.h"
(...skipping 7615 matching lines...) Expand 10 before | Expand all | Expand 10 after
7725 EXPECT_TRUE(webFrameClient.messages.empty()); 7726 EXPECT_TRUE(webFrameClient.messages.empty());
7726 ASSERT_EQ(2u, popupWebFrameClient.messages.size()); 7727 ASSERT_EQ(2u, popupWebFrameClient.messages.size());
7727 EXPECT_TRUE(std::string::npos != popupWebFrameClient.messages[1].text.utf8() .find("Blocked a frame")); 7728 EXPECT_TRUE(std::string::npos != popupWebFrameClient.messages[1].text.utf8() .find("Blocked a frame"));
7728 7729
7729 // Manually reset to break WebViewHelpers' dependencies on the stack 7730 // Manually reset to break WebViewHelpers' dependencies on the stack
7730 // allocated WebFrameClients. 7731 // allocated WebFrameClients.
7731 webViewHelper.reset(); 7732 webViewHelper.reset();
7732 popupWebViewHelper.reset(); 7733 popupWebViewHelper.reset();
7733 } 7734 }
7734 7735
7736 class ViewportOnResizeTest : public ParameterizedWebFrameTest {
7737 protected:
7738 ViewportOnResizeTest()
7739 : m_webViewHelper(this)
7740 {
7741 registerMockedHttpURLLoad("viewport_emulation.html");
7742 m_client.m_screenInfo.deviceScaleFactor = 1;
7743 m_webViewHelper.initializeAndLoad(m_baseURL + "viewport_emulation.html", true, 0, &m_client);
7744 }
7745
7746 void testResize(const WebSize size, const String& expectedSize)
7747 {
7748 m_client.m_screenInfo.rect = WebRect(0, 0, size.width, size.height);
7749 m_client.m_screenInfo.availableRect = m_client.m_screenInfo.rect;
7750 m_webViewHelper.webView()->resize(size);
7751 m_webViewHelper.webView()->layout();
7752
7753 v8::HandleScope scope(v8::Isolate::GetCurrent());
7754 ScriptExecutionCallbackHelper callbackHelper(m_webViewHelper.webView()-> mainFrame()->mainWorldScriptContext());
7755 m_webViewHelper.webView()->mainFrame()->toWebLocalFrame()->requestExecut eScriptAndReturnValue(WebScriptSource(WebString("dumpSize()")), false, &callback Helper);
7756 runPendingTasks();
7757 EXPECT_TRUE(callbackHelper.didComplete());
7758 EXPECT_EQ(expectedSize, callbackHelper.stringValue());
7759 }
7760
7761 FixedLayoutTestWebViewClient m_client;
7762 FrameTestHelpers::WebViewHelper m_webViewHelper;
7763 };
7764
7765 INSTANTIATE_TEST_CASE_P(All, ViewportOnResizeTest, ::testing::Values(
7766 ParameterizedWebFrameTestConfig::Default,
7767 ParameterizedWebFrameTestConfig::RootLayerScrolls));
7768
7769 TEST_P(ViewportOnResizeTest, ViewportInvalidatedOnResizeWithEmulation)
7770 {
7771 WebDeviceEmulationParams params;
7772 params.screenPosition = WebDeviceEmulationParams::Mobile;
7773 m_webViewHelper.webView()->enableDeviceEmulation(params);
7774
7775 testResize(WebSize(700, 500), "300x300");
7776 testResize(WebSize(710, 500), "400x300");
7777 testResize(WebSize(690, 500), "200x300");
7778 testResize(WebSize(700, 510), "300x400");
7779 testResize(WebSize(700, 490), "300x200");
7780 testResize(WebSize(710, 510), "400x400");
7781 testResize(WebSize(690, 490), "200x200");
7782 testResize(WebSize(800, 600), "400x400");
7783
7784 m_webViewHelper.webView()->disableDeviceEmulation();
7785 }
7786
7735 class WebLocalFrameScope final { 7787 class WebLocalFrameScope final {
7736 public: 7788 public:
7737 WebLocalFrameScope(WebLocalFrame* localFrame) 7789 WebLocalFrameScope(WebLocalFrame* localFrame)
7738 : m_localFrame(localFrame) 7790 : m_localFrame(localFrame)
7739 { 7791 {
7740 } 7792 }
7741 7793
7742 operator WebLocalFrame*() const 7794 operator WebLocalFrame*() const
7743 { 7795 {
7744 return m_localFrame; 7796 return m_localFrame;
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after
8118 8170
8119 TEST_F(WebFrameTest, MaxFramesDetach) 8171 TEST_F(WebFrameTest, MaxFramesDetach)
8120 { 8172 {
8121 registerMockedHttpURLLoad("max-frames-detach.html"); 8173 registerMockedHttpURLLoad("max-frames-detach.html");
8122 FrameTestHelpers::WebViewHelper webViewHelper; 8174 FrameTestHelpers::WebViewHelper webViewHelper;
8123 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(m_baseURL + "max- frames-detach.html", true); 8175 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(m_baseURL + "max- frames-detach.html", true);
8124 webViewImpl->mainFrameImpl()->collectGarbage(); 8176 webViewImpl->mainFrameImpl()->collectGarbage();
8125 } 8177 }
8126 8178
8127 } // namespace blink 8179 } // namespace blink
OLDNEW
« 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