| 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 "core/testing/UnitTestHelpers.h" |
| 8 #include "public/web/WebFrameClient.h" | 9 #include "public/web/WebFrameClient.h" |
| 9 #include "public/web/WebLocalFrame.h" | 10 #include "public/web/WebLocalFrame.h" |
| 10 #include "web/tests/FakeWebPlugin.h" | 11 #include "web/tests/FakeWebPlugin.h" |
| 11 #include "web/tests/FrameTestHelpers.h" | 12 #include "web/tests/FrameTestHelpers.h" |
| 12 #include <gtest/gtest.h> | 13 #include <gtest/gtest.h> |
| 13 | 14 |
| 14 namespace blink { | 15 namespace blink { |
| 15 | 16 |
| 16 namespace { | 17 namespace { |
| 17 | 18 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 35 { | 36 { |
| 36 return m_createPlaceholder ? new FakePlaceholderWebPlugin(frame, params)
: new FakeWebPlugin(frame, params); | 37 return m_createPlaceholder ? new FakePlaceholderWebPlugin(frame, params)
: new FakeWebPlugin(frame, params); |
| 37 } | 38 } |
| 38 | 39 |
| 39 void setCreatePlaceholder(bool createPlaceholder) { m_createPlaceholder = cr
eatePlaceholder; } | 40 void setCreatePlaceholder(bool createPlaceholder) { m_createPlaceholder = cr
eatePlaceholder; } |
| 40 | 41 |
| 41 private: | 42 private: |
| 42 bool m_createPlaceholder; | 43 bool m_createPlaceholder; |
| 43 }; | 44 }; |
| 44 | 45 |
| 45 class WebHelperPluginTest : public testing::Test { | 46 class WebHelperPluginTest : public ::testing::Test { |
| 46 protected: | 47 protected: |
| 47 virtual void SetUp() override | 48 virtual void SetUp() override |
| 48 { | 49 { |
| 49 m_helper.initializeAndLoad("about:blank", false, &m_frameClient); | 50 m_helper.initializeAndLoad("about:blank", false, &m_frameClient); |
| 50 } | 51 } |
| 51 | 52 |
| 52 | 53 |
| 53 void destroyHelperPlugin() | 54 void destroyHelperPlugin() |
| 54 { | 55 { |
| 55 m_plugin.clear(); | 56 m_plugin.clear(); |
| 56 // WebHelperPlugin is destroyed by a task posted to the message loop. | 57 // WebHelperPlugin is destroyed by a task posted to the message loop. |
| 57 FrameTestHelpers::runPendingTasks(); | 58 testing::runPendingTasks(); |
| 58 } | 59 } |
| 59 | 60 |
| 60 FrameTestHelpers::WebViewHelper m_helper; | 61 FrameTestHelpers::WebViewHelper m_helper; |
| 61 WebHelperPluginFrameClient m_frameClient; | 62 WebHelperPluginFrameClient m_frameClient; |
| 62 OwnPtr<WebHelperPlugin> m_plugin; | 63 OwnPtr<WebHelperPlugin> m_plugin; |
| 63 }; | 64 }; |
| 64 | 65 |
| 65 TEST_F(WebHelperPluginTest, CreateAndDestroyAfterWebViewDestruction) | 66 TEST_F(WebHelperPluginTest, CreateAndDestroyAfterWebViewDestruction) |
| 66 { | 67 { |
| 67 m_plugin = adoptPtr(WebHelperPlugin::create("hello", m_helper.webView()->mai
nFrame()->toWebLocalFrame())); | 68 m_plugin = adoptPtr(WebHelperPlugin::create("hello", m_helper.webView()->mai
nFrame()->toWebLocalFrame())); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 86 { | 87 { |
| 87 m_frameClient.setCreatePlaceholder(true); | 88 m_frameClient.setCreatePlaceholder(true); |
| 88 | 89 |
| 89 m_plugin = adoptPtr(WebHelperPlugin::create("hello", m_helper.webView()->mai
nFrame()->toWebLocalFrame())); | 90 m_plugin = adoptPtr(WebHelperPlugin::create("hello", m_helper.webView()->mai
nFrame()->toWebLocalFrame())); |
| 90 EXPECT_EQ(0, m_plugin.get()); | 91 EXPECT_EQ(0, m_plugin.get()); |
| 91 } | 92 } |
| 92 | 93 |
| 93 } // namespace | 94 } // namespace |
| 94 | 95 |
| 95 } // namespace | 96 } // namespace |
| OLD | NEW |