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

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

Issue 1343843004: [DevTools] Emulate hover and pointer types. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: removed settings getters 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 | « Source/web/WebSettingsImpl.cpp ('k') | Source/web/tests/data/device_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 7745 matching lines...) Expand 10 before | Expand all | Expand 10 after
7756 EXPECT_TRUE(webFrameClient.messages.empty()); 7756 EXPECT_TRUE(webFrameClient.messages.empty());
7757 ASSERT_EQ(2u, popupWebFrameClient.messages.size()); 7757 ASSERT_EQ(2u, popupWebFrameClient.messages.size());
7758 EXPECT_TRUE(std::string::npos != popupWebFrameClient.messages[1].text.utf8() .find("Blocked a frame")); 7758 EXPECT_TRUE(std::string::npos != popupWebFrameClient.messages[1].text.utf8() .find("Blocked a frame"));
7759 7759
7760 // Manually reset to break WebViewHelpers' dependencies on the stack 7760 // Manually reset to break WebViewHelpers' dependencies on the stack
7761 // allocated WebFrameClients. 7761 // allocated WebFrameClients.
7762 webViewHelper.reset(); 7762 webViewHelper.reset();
7763 popupWebViewHelper.reset(); 7763 popupWebViewHelper.reset();
7764 } 7764 }
7765 7765
7766 class ViewportOnResizeTest : public ParameterizedWebFrameTest { 7766 class DeviceEmulationTest : public ParameterizedWebFrameTest {
7767 protected: 7767 protected:
7768 ViewportOnResizeTest() 7768 DeviceEmulationTest()
7769 : m_webViewHelper(this) 7769 : m_webViewHelper(this)
7770 { 7770 {
7771 registerMockedHttpURLLoad("viewport_emulation.html"); 7771 registerMockedHttpURLLoad("device_emulation.html");
7772 m_client.m_screenInfo.deviceScaleFactor = 1; 7772 m_client.m_screenInfo.deviceScaleFactor = 1;
7773 m_webViewHelper.initializeAndLoad(m_baseURL + "viewport_emulation.html", true, 0, &m_client); 7773 m_webViewHelper.initializeAndLoad(m_baseURL + "device_emulation.html", t rue, 0, &m_client);
7774 } 7774 }
7775 7775
7776 void testResize(const WebSize size, const String& expectedSize) 7776 void testResize(const WebSize size, const String& expectedSize)
7777 { 7777 {
7778 m_client.m_screenInfo.rect = WebRect(0, 0, size.width, size.height); 7778 m_client.m_screenInfo.rect = WebRect(0, 0, size.width, size.height);
7779 m_client.m_screenInfo.availableRect = m_client.m_screenInfo.rect; 7779 m_client.m_screenInfo.availableRect = m_client.m_screenInfo.rect;
7780 m_webViewHelper.webView()->resize(size); 7780 m_webViewHelper.webView()->resize(size);
7781 m_webViewHelper.webView()->layout(); 7781 m_webViewHelper.webView()->layout();
7782 EXPECT_EQ(expectedSize, dumpSize("test"));
7783 }
7782 7784
7785 String dumpSize(const String& id)
7786 {
7787 String code = "dumpSize('" + id + "')";
7783 v8::HandleScope scope(v8::Isolate::GetCurrent()); 7788 v8::HandleScope scope(v8::Isolate::GetCurrent());
7784 ScriptExecutionCallbackHelper callbackHelper(m_webViewHelper.webView()-> mainFrame()->mainWorldScriptContext()); 7789 ScriptExecutionCallbackHelper callbackHelper(m_webViewHelper.webView()-> mainFrame()->mainWorldScriptContext());
7785 m_webViewHelper.webView()->mainFrame()->toWebLocalFrame()->requestExecut eScriptAndReturnValue(WebScriptSource(WebString("dumpSize()")), false, &callback Helper); 7790 m_webViewHelper.webView()->mainFrame()->toWebLocalFrame()->requestExecut eScriptAndReturnValue(WebScriptSource(WebString(code)), false, &callbackHelper);
7786 runPendingTasks(); 7791 runPendingTasks();
7787 EXPECT_TRUE(callbackHelper.didComplete()); 7792 EXPECT_TRUE(callbackHelper.didComplete());
7788 EXPECT_EQ(expectedSize, callbackHelper.stringValue()); 7793 return callbackHelper.stringValue();
7789 } 7794 }
7790 7795
7791 FixedLayoutTestWebViewClient m_client; 7796 FixedLayoutTestWebViewClient m_client;
7792 FrameTestHelpers::WebViewHelper m_webViewHelper; 7797 FrameTestHelpers::WebViewHelper m_webViewHelper;
7793 }; 7798 };
7794 7799
7795 INSTANTIATE_TEST_CASE_P(All, ViewportOnResizeTest, ::testing::Values( 7800 INSTANTIATE_TEST_CASE_P(All, DeviceEmulationTest, ::testing::Values(
7796 ParameterizedWebFrameTestConfig::Default, 7801 ParameterizedWebFrameTestConfig::Default,
7797 ParameterizedWebFrameTestConfig::RootLayerScrolls)); 7802 ParameterizedWebFrameTestConfig::RootLayerScrolls));
7798 7803
7799 TEST_P(ViewportOnResizeTest, ViewportInvalidatedOnResizeWithEmulation) 7804 TEST_P(DeviceEmulationTest, DeviceSizeInvalidatedOnResize)
7800 { 7805 {
7801 WebDeviceEmulationParams params; 7806 WebDeviceEmulationParams params;
7802 params.screenPosition = WebDeviceEmulationParams::Mobile; 7807 params.screenPosition = WebDeviceEmulationParams::Mobile;
7803 m_webViewHelper.webView()->enableDeviceEmulation(params); 7808 m_webViewHelper.webView()->enableDeviceEmulation(params);
7804 7809
7805 testResize(WebSize(700, 500), "300x300"); 7810 testResize(WebSize(700, 500), "300x300");
7806 testResize(WebSize(710, 500), "400x300"); 7811 testResize(WebSize(710, 500), "400x300");
7807 testResize(WebSize(690, 500), "200x300"); 7812 testResize(WebSize(690, 500), "200x300");
7808 testResize(WebSize(700, 510), "300x400"); 7813 testResize(WebSize(700, 510), "300x400");
7809 testResize(WebSize(700, 490), "300x200"); 7814 testResize(WebSize(700, 490), "300x200");
7810 testResize(WebSize(710, 510), "400x400"); 7815 testResize(WebSize(710, 510), "400x400");
7811 testResize(WebSize(690, 490), "200x200"); 7816 testResize(WebSize(690, 490), "200x200");
7812 testResize(WebSize(800, 600), "400x400"); 7817 testResize(WebSize(800, 600), "400x400");
7813 7818
7814 m_webViewHelper.webView()->disableDeviceEmulation(); 7819 m_webViewHelper.webView()->disableDeviceEmulation();
7815 } 7820 }
7816 7821
7822 TEST_P(DeviceEmulationTest, PointerAndHoverTypes)
7823 {
7824 WebDeviceEmulationParams params;
7825 params.screenPosition = WebDeviceEmulationParams::Mobile;
7826 m_webViewHelper.webView()->enableDeviceEmulation(params);
7827 EXPECT_EQ("20x20", dumpSize("pointer"));
7828 m_webViewHelper.webView()->disableDeviceEmulation();
7829 }
7830
7817 class WebLocalFrameScope final { 7831 class WebLocalFrameScope final {
7818 public: 7832 public:
7819 WebLocalFrameScope(WebLocalFrame* localFrame) 7833 WebLocalFrameScope(WebLocalFrame* localFrame)
7820 : m_localFrame(localFrame) 7834 : m_localFrame(localFrame)
7821 { 7835 {
7822 } 7836 }
7823 7837
7824 operator WebLocalFrame*() const 7838 operator WebLocalFrame*() const
7825 { 7839 {
7826 return m_localFrame; 7840 return m_localFrame;
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
8202 8216
8203 TEST_F(WebFrameTest, MaxFramesDetach) 8217 TEST_F(WebFrameTest, MaxFramesDetach)
8204 { 8218 {
8205 registerMockedHttpURLLoad("max-frames-detach.html"); 8219 registerMockedHttpURLLoad("max-frames-detach.html");
8206 FrameTestHelpers::WebViewHelper webViewHelper; 8220 FrameTestHelpers::WebViewHelper webViewHelper;
8207 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(m_baseURL + "max- frames-detach.html", true); 8221 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(m_baseURL + "max- frames-detach.html", true);
8208 webViewImpl->mainFrameImpl()->collectGarbage(); 8222 webViewImpl->mainFrameImpl()->collectGarbage();
8209 } 8223 }
8210 8224
8211 } // namespace blink 8225 } // namespace blink
OLDNEW
« no previous file with comments | « Source/web/WebSettingsImpl.cpp ('k') | Source/web/tests/data/device_emulation.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698