| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2011, 2012 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 11 matching lines...) Expand all Loading... |
| 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 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 | |
| 33 #include "web/FrameLoaderClientImpl.h" | 32 #include "web/FrameLoaderClientImpl.h" |
| 34 | 33 |
| 35 #include "core/loader/FrameLoader.h" | 34 #include "core/loader/FrameLoader.h" |
| 36 #include "platform/weborigin/KURL.h" | 35 #include "platform/weborigin/KURL.h" |
| 37 #include "public/web/WebFrameClient.h" | 36 #include "public/web/WebFrameClient.h" |
| 38 #include "public/web/WebPluginParams.h" | 37 #include "public/web/WebPluginParams.h" |
| 39 #include "public/web/WebPluginPlaceholder.h" | 38 #include "public/web/WebPluginPlaceholder.h" |
| 40 #include "public/web/WebSettings.h" | 39 #include "public/web/WebSettings.h" |
| 41 #include "public/web/WebView.h" | 40 #include "public/web/WebView.h" |
| 42 #include "web/PluginPlaceholderImpl.h" | 41 #include "web/PluginPlaceholderImpl.h" |
| 43 #include "web/WebLocalFrameImpl.h" | 42 #include "web/WebLocalFrameImpl.h" |
| 44 #include "web/tests/FrameTestHelpers.h" | 43 #include "web/tests/FrameTestHelpers.h" |
| 45 #include "wtf/text/CString.h" | 44 #include "wtf/text/CString.h" |
| 46 #include "wtf/text/WTFString.h" | 45 #include "wtf/text/WTFString.h" |
| 47 #include <gmock/gmock.h> | 46 #include <gmock/gmock.h> |
| 48 #include <gtest/gtest.h> | 47 #include <gtest/gtest.h> |
| 49 | 48 |
| 50 using testing::_; | 49 using testing::_; |
| 51 using testing::Mock; | 50 using testing::Mock; |
| 52 using testing::Return; | 51 using testing::Return; |
| 53 | 52 |
| 54 namespace blink { | 53 namespace blink { |
| 55 namespace { | 54 namespace { |
| 56 | 55 |
| 57 class MockWebFrameClient : public WebFrameClient { | 56 class MockWebFrameClient : public WebFrameClient { |
| 58 public: | 57 public: |
| 59 virtual ~MockWebFrameClient() { } | 58 ~MockWebFrameClient() override { } |
| 60 | 59 |
| 61 MOCK_METHOD2(userAgentOverride, WebString(WebLocalFrame*, const WebURL&)); | 60 MOCK_METHOD2(userAgentOverride, WebString(WebLocalFrame*, const WebURL&)); |
| 62 MOCK_METHOD2(createPluginPlaceholder, WebPluginPlaceholder*(WebLocalFrame*,
const WebPluginParams&)); | 61 MOCK_METHOD2(createPluginPlaceholder, WebPluginPlaceholder*(WebLocalFrame*,
const WebPluginParams&)); |
| 63 }; | 62 }; |
| 64 | 63 |
| 65 class FrameLoaderClientImplTest : public ::testing::Test { | 64 class FrameLoaderClientImplTest : public ::testing::Test { |
| 66 protected: | 65 protected: |
| 67 virtual void SetUp() override | 66 void SetUp() override |
| 68 { | 67 { |
| 69 ON_CALL(m_webFrameClient, userAgentOverride(_, _)).WillByDefault(Return(
WebString())); | 68 ON_CALL(m_webFrameClient, userAgentOverride(_, _)).WillByDefault(Return(
WebString())); |
| 70 | 69 |
| 71 FrameTestHelpers::TestWebViewClient webViewClient; | 70 FrameTestHelpers::TestWebViewClient webViewClient; |
| 72 m_webView = WebView::create(&webViewClient); | 71 m_webView = WebView::create(&webViewClient); |
| 73 // FIXME: http://crbug.com/363843. This needs to find a better way to | 72 // FIXME: http://crbug.com/363843. This needs to find a better way to |
| 74 // not create graphics layers. | 73 // not create graphics layers. |
| 75 m_webView->settings()->setAcceleratedCompositingEnabled(false); | 74 m_webView->settings()->setAcceleratedCompositingEnabled(false); |
| 76 m_mainFrame = WebLocalFrame::create(WebTreeScopeType::Document, &m_webFr
ameClient); | 75 m_mainFrame = WebLocalFrame::create(WebTreeScopeType::Document, &m_webFr
ameClient); |
| 77 m_webView->setMainFrame(m_mainFrame); | 76 m_webView->setMainFrame(m_mainFrame); |
| 78 m_frameLoaderClientImpl = toFrameLoaderClientImpl(toWebLocalFrameImpl(m_
webView->mainFrame())->frame()->loader().client()); | 77 m_frameLoaderClientImpl = toFrameLoaderClientImpl(toWebLocalFrameImpl(m_
webView->mainFrame())->frame()->loader().client()); |
| 79 } | 78 } |
| 80 | 79 |
| 81 virtual void TearDown() override | 80 void TearDown() override |
| 82 { | 81 { |
| 83 m_webView->close(); | 82 m_webView->close(); |
| 84 m_mainFrame->close(); | 83 m_mainFrame->close(); |
| 85 } | 84 } |
| 86 | 85 |
| 87 WebString userAgent() | 86 WebString userAgent() |
| 88 { | 87 { |
| 89 // The test always returns the same user agent, regardless of the URL pa
ssed in. | 88 // The test always returns the same user agent, regardless of the URL pa
ssed in. |
| 90 KURL dummyURL(ParsedURLString, "about:blank"); | 89 KURL dummyURL(ParsedURLString, "about:blank"); |
| 91 WTF::CString userAgent = m_frameLoaderClientImpl->userAgent(dummyURL).ut
f8(); | 90 WTF::CString userAgent = m_frameLoaderClientImpl->userAgent(dummyURL).ut
f8(); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 EXPECT_CALL(webFrameClient(), createPluginPlaceholder(mainFrame(), _)) | 142 EXPECT_CALL(webFrameClient(), createPluginPlaceholder(mainFrame(), _)) |
| 144 .WillOnce(Return(nullptr)); | 143 .WillOnce(Return(nullptr)); |
| 145 OwnPtrWillBeRawPtr<PluginPlaceholder> pluginPlaceholder = frameLoaderCli
ent().createPluginPlaceholder( | 144 OwnPtrWillBeRawPtr<PluginPlaceholder> pluginPlaceholder = frameLoaderCli
ent().createPluginPlaceholder( |
| 146 document(), url, paramNames, paramValues, mimeType, loadManually); | 145 document(), url, paramNames, paramValues, mimeType, loadManually); |
| 147 ASSERT_FALSE(pluginPlaceholder); | 146 ASSERT_FALSE(pluginPlaceholder); |
| 148 } | 147 } |
| 149 } | 148 } |
| 150 | 149 |
| 151 } // namespace | 150 } // namespace |
| 152 } // namespace blink | 151 } // namespace blink |
| OLD | NEW |