Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(677)

Side by Side Diff: content/browser/plugin_loader_posix_unittest.cc

Issue 8372015: [Linux] Load plugins out-of-process. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: '' Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « content/browser/plugin_loader_posix.cc ('k') | content/browser/plugin_service.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 }
OLDNEW
« no previous file with comments | « content/browser/plugin_loader_posix.cc ('k') | content/browser/plugin_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698