OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/browser/plugin_service_impl.h" | 5 #include "content/browser/plugin_service_impl.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 }; | 132 }; |
133 | 133 |
134 // Try to open a channel to the test plugin. Minimal plugin process spawning | 134 // Try to open a channel to the test plugin. Minimal plugin process spawning |
135 // test for the PluginService interface. | 135 // test for the PluginService interface. |
136 IN_PROC_BROWSER_TEST_F(PluginServiceTest, OpenChannelToPlugin) { | 136 IN_PROC_BROWSER_TEST_F(PluginServiceTest, OpenChannelToPlugin) { |
137 MockPluginProcessHostClient mock_client( | 137 MockPluginProcessHostClient mock_client( |
138 browser()->profile()->GetResourceContext()); | 138 browser()->profile()->GetResourceContext()); |
139 BrowserThread::PostTask( | 139 BrowserThread::PostTask( |
140 BrowserThread::IO, FROM_HERE, | 140 BrowserThread::IO, FROM_HERE, |
141 base::Bind(&OpenChannel, &mock_client)); | 141 base::Bind(&OpenChannel, &mock_client)); |
142 ui_test_utils::RunMessageLoop(); | 142 content::RunMessageLoop(); |
143 } | 143 } |
144 | 144 |
145 // A strict mock that fails if any of the methods are called. They shouldn't be | 145 // A strict mock that fails if any of the methods are called. They shouldn't be |
146 // called since the request should get canceled before then. | 146 // called since the request should get canceled before then. |
147 class MockCanceledPluginServiceClient : public PluginProcessHost::Client { | 147 class MockCanceledPluginServiceClient : public PluginProcessHost::Client { |
148 public: | 148 public: |
149 MockCanceledPluginServiceClient(content::ResourceContext* context) | 149 MockCanceledPluginServiceClient(content::ResourceContext* context) |
150 : context_(context), | 150 : context_(context), |
151 get_resource_context_called_(false) { | 151 get_resource_context_called_(false) { |
152 } | 152 } |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 base::Bind(&base::DoNothing), | 195 base::Bind(&base::DoNothing), |
196 base::Bind(&QuitUIMessageLoopFromIOThread)); | 196 base::Bind(&QuitUIMessageLoopFromIOThread)); |
197 } | 197 } |
198 | 198 |
199 // Should not attempt to open a channel, since it should be canceled early on. | 199 // Should not attempt to open a channel, since it should be canceled early on. |
200 IN_PROC_BROWSER_TEST_F(PluginServiceTest, CancelOpenChannelToPluginService) { | 200 IN_PROC_BROWSER_TEST_F(PluginServiceTest, CancelOpenChannelToPluginService) { |
201 ::testing::StrictMock<MockCanceledPluginServiceClient> mock_client( | 201 ::testing::StrictMock<MockCanceledPluginServiceClient> mock_client( |
202 browser()->profile()->GetResourceContext()); | 202 browser()->profile()->GetResourceContext()); |
203 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, | 203 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, |
204 base::Bind(OpenChannelAndThenCancel, &mock_client)); | 204 base::Bind(OpenChannelAndThenCancel, &mock_client)); |
205 ui_test_utils::RunMessageLoop(); | 205 content::RunMessageLoop(); |
206 EXPECT_TRUE(mock_client.get_resource_context_called()); | 206 EXPECT_TRUE(mock_client.get_resource_context_called()); |
207 } | 207 } |
208 | 208 |
209 class MockCanceledBeforeSentPluginProcessHostClient | 209 class MockCanceledBeforeSentPluginProcessHostClient |
210 : public MockCanceledPluginServiceClient { | 210 : public MockCanceledPluginServiceClient { |
211 public: | 211 public: |
212 MockCanceledBeforeSentPluginProcessHostClient( | 212 MockCanceledBeforeSentPluginProcessHostClient( |
213 content::ResourceContext* context) | 213 content::ResourceContext* context) |
214 : MockCanceledPluginServiceClient(context), | 214 : MockCanceledPluginServiceClient(context), |
215 set_plugin_info_called_(false), | 215 set_plugin_info_called_(false), |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
266 DISALLOW_COPY_AND_ASSIGN(MockCanceledBeforeSentPluginProcessHostClient); | 266 DISALLOW_COPY_AND_ASSIGN(MockCanceledBeforeSentPluginProcessHostClient); |
267 }; | 267 }; |
268 | 268 |
269 IN_PROC_BROWSER_TEST_F( | 269 IN_PROC_BROWSER_TEST_F( |
270 PluginServiceTest, CancelBeforeSentOpenChannelToPluginProcessHost) { | 270 PluginServiceTest, CancelBeforeSentOpenChannelToPluginProcessHost) { |
271 ::testing::StrictMock<MockCanceledBeforeSentPluginProcessHostClient> | 271 ::testing::StrictMock<MockCanceledBeforeSentPluginProcessHostClient> |
272 mock_client(browser()->profile()->GetResourceContext()); | 272 mock_client(browser()->profile()->GetResourceContext()); |
273 BrowserThread::PostTask( | 273 BrowserThread::PostTask( |
274 BrowserThread::IO, FROM_HERE, | 274 BrowserThread::IO, FROM_HERE, |
275 base::Bind(&OpenChannel, &mock_client)); | 275 base::Bind(&OpenChannel, &mock_client)); |
276 ui_test_utils::RunMessageLoop(); | 276 content::RunMessageLoop(); |
277 EXPECT_TRUE(mock_client.get_resource_context_called()); | 277 EXPECT_TRUE(mock_client.get_resource_context_called()); |
278 EXPECT_TRUE(mock_client.set_plugin_info_called()); | 278 EXPECT_TRUE(mock_client.set_plugin_info_called()); |
279 EXPECT_TRUE(mock_client.on_found_plugin_process_host_called()); | 279 EXPECT_TRUE(mock_client.on_found_plugin_process_host_called()); |
280 } | 280 } |
281 | 281 |
282 class MockCanceledAfterSentPluginProcessHostClient | 282 class MockCanceledAfterSentPluginProcessHostClient |
283 : public MockCanceledBeforeSentPluginProcessHostClient { | 283 : public MockCanceledBeforeSentPluginProcessHostClient { |
284 public: | 284 public: |
285 MockCanceledAfterSentPluginProcessHostClient( | 285 MockCanceledAfterSentPluginProcessHostClient( |
286 content::ResourceContext* context) | 286 content::ResourceContext* context) |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
318 }; | 318 }; |
319 | 319 |
320 // Should not attempt to open a channel, since it should be canceled early on. | 320 // Should not attempt to open a channel, since it should be canceled early on. |
321 IN_PROC_BROWSER_TEST_F( | 321 IN_PROC_BROWSER_TEST_F( |
322 PluginServiceTest, CancelAfterSentOpenChannelToPluginProcessHost) { | 322 PluginServiceTest, CancelAfterSentOpenChannelToPluginProcessHost) { |
323 ::testing::StrictMock<MockCanceledAfterSentPluginProcessHostClient> | 323 ::testing::StrictMock<MockCanceledAfterSentPluginProcessHostClient> |
324 mock_client(browser()->profile()->GetResourceContext()); | 324 mock_client(browser()->profile()->GetResourceContext()); |
325 BrowserThread::PostTask( | 325 BrowserThread::PostTask( |
326 BrowserThread::IO, FROM_HERE, | 326 BrowserThread::IO, FROM_HERE, |
327 base::Bind(&OpenChannel, &mock_client)); | 327 base::Bind(&OpenChannel, &mock_client)); |
328 ui_test_utils::RunMessageLoop(); | 328 content::RunMessageLoop(); |
329 EXPECT_TRUE(mock_client.get_resource_context_called()); | 329 EXPECT_TRUE(mock_client.get_resource_context_called()); |
330 EXPECT_TRUE(mock_client.set_plugin_info_called()); | 330 EXPECT_TRUE(mock_client.set_plugin_info_called()); |
331 EXPECT_TRUE(mock_client.on_found_plugin_process_host_called()); | 331 EXPECT_TRUE(mock_client.on_found_plugin_process_host_called()); |
332 EXPECT_TRUE(mock_client.on_sent_plugin_channel_request_called()); | 332 EXPECT_TRUE(mock_client.on_sent_plugin_channel_request_called()); |
333 } | 333 } |
334 | 334 |
335 } // namespace | 335 } // namespace |
OLD | NEW |