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 "platform/testing/UnitTestHelpers.h" | 8 #include "platform/testing/UnitTestHelpers.h" |
9 #include "public/web/WebFrameClient.h" | 9 #include "public/web/WebFrameClient.h" |
10 #include "public/web/WebLocalFrame.h" | 10 #include "public/web/WebLocalFrame.h" |
11 #include "web/tests/FakeWebPlugin.h" | 11 #include "web/tests/FakeWebPlugin.h" |
12 #include "web/tests/FrameTestHelpers.h" | 12 #include "web/tests/FrameTestHelpers.h" |
13 #include <gtest/gtest.h> | 13 #include <gtest/gtest.h> |
14 | 14 |
15 namespace blink { | 15 namespace blink { |
16 | 16 |
17 namespace { | 17 namespace { |
18 | 18 |
19 class FakePlaceholderWebPlugin : public FakeWebPlugin { | 19 class FakePlaceholderWebPlugin : public FakeWebPlugin { |
20 public: | 20 public: |
21 FakePlaceholderWebPlugin(WebFrame* frame, const WebPluginParams& params) | 21 FakePlaceholderWebPlugin(WebFrame* frame, const WebPluginParams& params) |
22 : FakeWebPlugin(frame, params) | 22 : FakeWebPlugin(frame, params) |
23 { | 23 { |
24 } | 24 } |
25 virtual ~FakePlaceholderWebPlugin() { } | 25 ~FakePlaceholderWebPlugin() override {} |
26 | 26 |
27 virtual bool isPlaceholder() override { return true; } | 27 bool isPlaceholder() override { return true; } |
28 }; | 28 }; |
29 | 29 |
30 class WebHelperPluginFrameClient : public FrameTestHelpers::TestWebFrameClient { | 30 class WebHelperPluginFrameClient : public FrameTestHelpers::TestWebFrameClient { |
31 public: | 31 public: |
32 WebHelperPluginFrameClient() : m_createPlaceholder(false) { } | 32 WebHelperPluginFrameClient() : m_createPlaceholder(false) {} |
33 virtual ~WebHelperPluginFrameClient() { } | 33 ~WebHelperPluginFrameClient() override {} |
34 | 34 |
35 virtual WebPlugin* createPlugin(WebLocalFrame* frame, const WebPluginParams&
params) override | 35 WebPlugin* createPlugin(WebLocalFrame* frame, const WebPluginParams& params)
override |
36 { | 36 { |
37 return m_createPlaceholder ? new FakePlaceholderWebPlugin(frame, params)
: new FakeWebPlugin(frame, params); | 37 return m_createPlaceholder ? new FakePlaceholderWebPlugin(frame, params)
: new FakeWebPlugin(frame, params); |
38 } | 38 } |
39 | 39 |
40 void setCreatePlaceholder(bool createPlaceholder) { m_createPlaceholder = cr
eatePlaceholder; } | 40 void setCreatePlaceholder(bool createPlaceholder) { m_createPlaceholder = cr
eatePlaceholder; } |
41 | 41 |
42 private: | 42 private: |
43 bool m_createPlaceholder; | 43 bool m_createPlaceholder; |
44 }; | 44 }; |
45 | 45 |
46 class WebHelperPluginTest : public ::testing::Test { | 46 class WebHelperPluginTest : public ::testing::Test { |
47 protected: | 47 protected: |
48 virtual void SetUp() override | 48 void SetUp() override |
49 { | 49 { |
50 m_helper.initializeAndLoad("about:blank", false, &m_frameClient); | 50 m_helper.initializeAndLoad("about:blank", false, &m_frameClient); |
51 } | 51 } |
52 | 52 |
53 | 53 |
54 void destroyHelperPlugin() | 54 void destroyHelperPlugin() |
55 { | 55 { |
56 m_plugin.clear(); | 56 m_plugin.clear(); |
57 // WebHelperPlugin is destroyed by a task posted to the message loop. | 57 // WebHelperPlugin is destroyed by a task posted to the message loop. |
58 testing::runPendingTasks(); | 58 testing::runPendingTasks(); |
(...skipping 28 matching lines...) Expand all Loading... |
87 { | 87 { |
88 m_frameClient.setCreatePlaceholder(true); | 88 m_frameClient.setCreatePlaceholder(true); |
89 | 89 |
90 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())); |
91 EXPECT_EQ(0, m_plugin.get()); | 91 EXPECT_EQ(0, m_plugin.get()); |
92 } | 92 } |
93 | 93 |
94 } // namespace | 94 } // namespace |
95 | 95 |
96 } // namespace | 96 } // namespace |
OLD | NEW |