OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_loader_posix.h" | 5 #include "content/browser/plugin_loader_posix.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/file_path.h" | 8 #include "base/file_path.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
(...skipping 20 matching lines...) Expand all Loading... |
31 } | 31 } |
32 | 32 |
33 const std::vector<webkit::WebPluginInfo>& loaded_plugins() { | 33 const std::vector<webkit::WebPluginInfo>& loaded_plugins() { |
34 return loaded_plugins_; | 34 return loaded_plugins_; |
35 } | 35 } |
36 | 36 |
37 std::vector<webkit::WebPluginInfo>* internal_plugins() { | 37 std::vector<webkit::WebPluginInfo>* internal_plugins() { |
38 return &internal_plugins_; | 38 return &internal_plugins_; |
39 } | 39 } |
40 | 40 |
| 41 void RealLoadPluginsInternal() { |
| 42 PluginLoaderPosix::LoadPluginsInternal(); |
| 43 } |
| 44 |
41 void TestOnPluginLoaded(const webkit::WebPluginInfo& plugin) { | 45 void TestOnPluginLoaded(const webkit::WebPluginInfo& plugin) { |
42 OnPluginLoaded(plugin); | 46 OnPluginLoaded(plugin); |
43 } | 47 } |
44 | 48 |
45 void TestOnPluginLoadFailed(const FilePath& path) { | 49 void TestOnPluginLoadFailed(const FilePath& path) { |
46 OnPluginLoadFailed(path); | 50 OnPluginLoadFailed(path); |
47 } | 51 } |
48 }; | 52 }; |
49 | 53 |
50 void VerifyCallback(int* run_count, const std::vector<webkit::WebPluginInfo>&) { | 54 void VerifyCallback(int* run_count, const std::vector<webkit::WebPluginInfo>&) { |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 message_loop()->RunAllPending(); | 273 message_loop()->RunAllPending(); |
270 EXPECT_EQ(0, did_callback); | 274 EXPECT_EQ(0, did_callback); |
271 | 275 |
272 plugin_loader()->TestOnPluginLoaded(plugin3_); | 276 plugin_loader()->TestOnPluginLoaded(plugin3_); |
273 EXPECT_EQ(3u, plugins.size()); | 277 EXPECT_EQ(3u, plugins.size()); |
274 EXPECT_EQ(plugin3_.name, plugins[2].name); | 278 EXPECT_EQ(plugin3_.name, plugins[2].name); |
275 | 279 |
276 message_loop()->RunAllPending(); | 280 message_loop()->RunAllPending(); |
277 EXPECT_EQ(1, did_callback); | 281 EXPECT_EQ(1, did_callback); |
278 } | 282 } |
| 283 |
| 284 TEST_F(PluginLoaderPosixTest, AllCrashed) { |
| 285 int did_callback = 0; |
| 286 PluginService::GetPluginsCallback callback = |
| 287 base::Bind(&VerifyCallback, base::Unretained(&did_callback)); |
| 288 |
| 289 plugin_loader()->LoadPlugins(message_loop()->message_loop_proxy(), callback); |
| 290 |
| 291 // Spin the loop so that the canonical list of plugins can be set. |
| 292 EXPECT_CALL(*plugin_loader(), LoadPluginsInternal()).Times(1); |
| 293 message_loop()->RunAllPending(); |
| 294 AddThreePlugins(); |
| 295 |
| 296 EXPECT_EQ(0u, plugin_loader()->next_load_index()); |
| 297 |
| 298 // Mock the first two calls like normal. |
| 299 testing::Expectation first = |
| 300 EXPECT_CALL(*plugin_loader(), LoadPluginsInternal()).Times(2); |
| 301 // On the last call, go through the default impl. |
| 302 EXPECT_CALL(*plugin_loader(), LoadPluginsInternal()) |
| 303 .After(first) |
| 304 .WillOnce( |
| 305 testing::Invoke(plugin_loader(), |
| 306 &MockPluginLoaderPosix::RealLoadPluginsInternal)); |
| 307 plugin_loader()->OnProcessCrashed(42); |
| 308 plugin_loader()->OnProcessCrashed(42); |
| 309 plugin_loader()->OnProcessCrashed(42); |
| 310 |
| 311 message_loop()->RunAllPending(); |
| 312 EXPECT_EQ(1, did_callback); |
| 313 |
| 314 EXPECT_EQ(0u, plugin_loader()->loaded_plugins().size()); |
| 315 } |
OLD | NEW |