| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "config.h" | 5 #include "config.h" |
| 6 #include "public/web/WebHelperPlugin.h" | 6 #include "public/web/WebHelperPlugin.h" |
| 7 | 7 |
| 8 #include "public/web/WebFrameClient.h" | 8 #include "public/web/WebFrameClient.h" |
| 9 #include "public/web/WebLocalFrame.h" | 9 #include "public/web/WebLocalFrame.h" |
| 10 #include "web/tests/FakeWebPlugin.h" | 10 #include "web/tests/FakeWebPlugin.h" |
| 11 #include "web/tests/FrameTestHelpers.h" | 11 #include "web/tests/FrameTestHelpers.h" |
| 12 #include <gtest/gtest.h> | 12 #include <gtest/gtest.h> |
| 13 | 13 |
| 14 namespace blink { | 14 namespace blink { |
| 15 | 15 |
| 16 namespace { | 16 namespace { |
| 17 | 17 |
| 18 class FakePlaceholderWebPlugin : public FakeWebPlugin { | 18 class FakePlaceholderWebPlugin : public FakeWebPlugin { |
| 19 public: | 19 public: |
| 20 FakePlaceholderWebPlugin(WebFrame* frame, const WebPluginParams& params) | 20 FakePlaceholderWebPlugin(WebFrame* frame, const WebPluginParams& params) |
| 21 : FakeWebPlugin(frame, params) | 21 : FakeWebPlugin(frame, params) |
| 22 { | 22 { |
| 23 } | 23 } |
| 24 virtual ~FakePlaceholderWebPlugin() { } | 24 virtual ~FakePlaceholderWebPlugin() { } |
| 25 | 25 |
| 26 virtual bool isPlaceholder() OVERRIDE { return true; } | 26 virtual bool isPlaceholder() override { return true; } |
| 27 }; | 27 }; |
| 28 | 28 |
| 29 class WebHelperPluginFrameClient : public FrameTestHelpers::TestWebFrameClient { | 29 class WebHelperPluginFrameClient : public FrameTestHelpers::TestWebFrameClient { |
| 30 public: | 30 public: |
| 31 WebHelperPluginFrameClient() : m_createPlaceholder(false) { } | 31 WebHelperPluginFrameClient() : m_createPlaceholder(false) { } |
| 32 virtual ~WebHelperPluginFrameClient() { } | 32 virtual ~WebHelperPluginFrameClient() { } |
| 33 | 33 |
| 34 virtual WebPlugin* createPlugin(WebLocalFrame* frame, const WebPluginParams&
params) OVERRIDE | 34 virtual WebPlugin* createPlugin(WebLocalFrame* frame, const WebPluginParams&
params) override |
| 35 { | 35 { |
| 36 return m_createPlaceholder ? new FakePlaceholderWebPlugin(frame, params)
: new FakeWebPlugin(frame, params); | 36 return m_createPlaceholder ? new FakePlaceholderWebPlugin(frame, params)
: new FakeWebPlugin(frame, params); |
| 37 } | 37 } |
| 38 | 38 |
| 39 void setCreatePlaceholder(bool createPlaceholder) { m_createPlaceholder = cr
eatePlaceholder; } | 39 void setCreatePlaceholder(bool createPlaceholder) { m_createPlaceholder = cr
eatePlaceholder; } |
| 40 | 40 |
| 41 private: | 41 private: |
| 42 bool m_createPlaceholder; | 42 bool m_createPlaceholder; |
| 43 }; | 43 }; |
| 44 | 44 |
| 45 class WebHelperPluginTest : public testing::Test { | 45 class WebHelperPluginTest : public testing::Test { |
| 46 protected: | 46 protected: |
| 47 virtual void SetUp() OVERRIDE | 47 virtual void SetUp() override |
| 48 { | 48 { |
| 49 m_helper.initializeAndLoad("about:blank", false, &m_frameClient); | 49 m_helper.initializeAndLoad("about:blank", false, &m_frameClient); |
| 50 } | 50 } |
| 51 | 51 |
| 52 | 52 |
| 53 void destroyHelperPlugin() | 53 void destroyHelperPlugin() |
| 54 { | 54 { |
| 55 m_plugin.clear(); | 55 m_plugin.clear(); |
| 56 // WebHelperPlugin is destroyed by a task posted to the message loop. | 56 // WebHelperPlugin is destroyed by a task posted to the message loop. |
| 57 FrameTestHelpers::runPendingTasks(); | 57 FrameTestHelpers::runPendingTasks(); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 86 { | 86 { |
| 87 m_frameClient.setCreatePlaceholder(true); | 87 m_frameClient.setCreatePlaceholder(true); |
| 88 | 88 |
| 89 m_plugin = adoptPtr(WebHelperPlugin::create("hello", m_helper.webView()->mai
nFrame()->toWebLocalFrame())); | 89 m_plugin = adoptPtr(WebHelperPlugin::create("hello", m_helper.webView()->mai
nFrame()->toWebLocalFrame())); |
| 90 EXPECT_EQ(0, m_plugin.get()); | 90 EXPECT_EQ(0, m_plugin.get()); |
| 91 } | 91 } |
| 92 | 92 |
| 93 } // namespace | 93 } // namespace |
| 94 | 94 |
| 95 } // namespace | 95 } // namespace |
| OLD | NEW |