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 "WebHelperPlugin.h" | 6 #include "WebHelperPlugin.h" |
7 | 7 |
8 #include "FakeWebPlugin.h" | 8 #include "FakeWebPlugin.h" |
9 #include "FrameTestHelpers.h" | 9 #include "FrameTestHelpers.h" |
10 #include "WebFrameClient.h" | 10 #include "WebFrameClient.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 virtual ~FakePlaceholderWebPlugin() { } | 23 virtual ~FakePlaceholderWebPlugin() { } |
24 | 24 |
25 virtual bool isPlaceholder() OVERRIDE { return true; } | 25 virtual bool isPlaceholder() OVERRIDE { return true; } |
26 }; | 26 }; |
27 | 27 |
28 class WebHelperPluginFrameClient : public FrameTestHelpers::TestWebFrameClient { | 28 class WebHelperPluginFrameClient : public FrameTestHelpers::TestWebFrameClient { |
29 public: | 29 public: |
30 WebHelperPluginFrameClient() : m_createPlaceholder(false) { } | 30 WebHelperPluginFrameClient() : m_createPlaceholder(false) { } |
31 virtual ~WebHelperPluginFrameClient() { } | 31 virtual ~WebHelperPluginFrameClient() { } |
32 | 32 |
33 virtual WebPlugin* createPlugin(WebFrame* frame, const WebPluginParams& para
ms) OVERRIDE | 33 virtual WebPlugin* createPlugin(WebLocalFrame* frame, const WebPluginParams&
params) OVERRIDE |
34 { | 34 { |
35 return m_createPlaceholder ? new FakePlaceholderWebPlugin(frame, params)
: new FakeWebPlugin(frame, params); | 35 return m_createPlaceholder ? new FakePlaceholderWebPlugin(frame, params)
: new FakeWebPlugin(frame, params); |
36 } | 36 } |
37 | 37 |
38 void setCreatePlaceholder(bool createPlaceholder) { m_createPlaceholder = cr
eatePlaceholder; } | 38 void setCreatePlaceholder(bool createPlaceholder) { m_createPlaceholder = cr
eatePlaceholder; } |
39 | 39 |
40 private: | 40 private: |
41 bool m_createPlaceholder; | 41 bool m_createPlaceholder; |
42 }; | 42 }; |
43 | 43 |
(...skipping 12 matching lines...) Expand all Loading... |
56 FrameTestHelpers::runPendingTasks(); | 56 FrameTestHelpers::runPendingTasks(); |
57 } | 57 } |
58 | 58 |
59 FrameTestHelpers::WebViewHelper m_helper; | 59 FrameTestHelpers::WebViewHelper m_helper; |
60 WebHelperPluginFrameClient m_frameClient; | 60 WebHelperPluginFrameClient m_frameClient; |
61 OwnPtr<WebHelperPlugin> m_plugin; | 61 OwnPtr<WebHelperPlugin> m_plugin; |
62 }; | 62 }; |
63 | 63 |
64 TEST_F(WebHelperPluginTest, CreateAndDestroyAfterWebViewDestruction) | 64 TEST_F(WebHelperPluginTest, CreateAndDestroyAfterWebViewDestruction) |
65 { | 65 { |
66 m_plugin = adoptPtr(WebHelperPlugin::create("hello", m_helper.webView()->mai
nFrame())); | 66 m_plugin = adoptPtr(WebHelperPlugin::create("hello", m_helper.webView()->mai
nFrame()->toWebLocalFrame())); |
67 EXPECT_TRUE(m_plugin); | 67 EXPECT_TRUE(m_plugin); |
68 EXPECT_TRUE(m_plugin->getPlugin()); | 68 EXPECT_TRUE(m_plugin->getPlugin()); |
69 | 69 |
70 m_helper.reset(); | 70 m_helper.reset(); |
71 destroyHelperPlugin(); | 71 destroyHelperPlugin(); |
72 } | 72 } |
73 | 73 |
74 TEST_F(WebHelperPluginTest, CreateAndDestroyBeforeWebViewDestruction) | 74 TEST_F(WebHelperPluginTest, CreateAndDestroyBeforeWebViewDestruction) |
75 { | 75 { |
76 m_plugin = adoptPtr(WebHelperPlugin::create("hello", m_helper.webView()->mai
nFrame())); | 76 m_plugin = adoptPtr(WebHelperPlugin::create("hello", m_helper.webView()->mai
nFrame()->toWebLocalFrame())); |
77 EXPECT_TRUE(m_plugin); | 77 EXPECT_TRUE(m_plugin); |
78 EXPECT_TRUE(m_plugin->getPlugin()); | 78 EXPECT_TRUE(m_plugin->getPlugin()); |
79 | 79 |
80 destroyHelperPlugin(); | 80 destroyHelperPlugin(); |
81 m_helper.reset(); | 81 m_helper.reset(); |
82 } | 82 } |
83 | 83 |
84 TEST_F(WebHelperPluginTest, CreateFailsWithPlaceholder) | 84 TEST_F(WebHelperPluginTest, CreateFailsWithPlaceholder) |
85 { | 85 { |
86 m_frameClient.setCreatePlaceholder(true); | 86 m_frameClient.setCreatePlaceholder(true); |
87 | 87 |
88 m_plugin = adoptPtr(WebHelperPlugin::create("hello", m_helper.webView()->mai
nFrame())); | 88 m_plugin = adoptPtr(WebHelperPlugin::create("hello", m_helper.webView()->mai
nFrame()->toWebLocalFrame())); |
89 EXPECT_EQ(0, m_plugin.get()); | 89 EXPECT_EQ(0, m_plugin.get()); |
90 } | 90 } |
91 | 91 |
92 } // namespace | 92 } // namespace |
93 | 93 |
94 } // namespace | 94 } // namespace |
OLD | NEW |