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

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

Issue 718523002: Fix a bug that would cause the plugin_loader to stall. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Comments from avi. Created 6 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') | no next file » | 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) 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_loader_posix.h" 5 #include "content/browser/plugin_loader_posix.h"
6 6
7 #include "base/at_exit.h" 7 #include "base/at_exit.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
(...skipping 29 matching lines...) Expand all
40 } 40 }
41 41
42 std::vector<WebPluginInfo>* internal_plugins() { 42 std::vector<WebPluginInfo>* internal_plugins() {
43 return &internal_plugins_; 43 return &internal_plugins_;
44 } 44 }
45 45
46 void RealLoadPluginsInternal() { 46 void RealLoadPluginsInternal() {
47 PluginLoaderPosix::LoadPluginsInternal(); 47 PluginLoaderPosix::LoadPluginsInternal();
48 } 48 }
49 49
50 bool LaunchUtilityProcess() override {
51 // This method always does nothing and returns false. The actual
52 // implementation of this method launches another process, which is not
53 // very unit_test friendly.
54 return false;
55 }
56
50 void TestOnPluginLoaded(uint32 index, const WebPluginInfo& plugin) { 57 void TestOnPluginLoaded(uint32 index, const WebPluginInfo& plugin) {
51 OnPluginLoaded(index, plugin); 58 OnPluginLoaded(index, plugin);
52 } 59 }
53 60
54 void TestOnPluginLoadFailed(uint32 index, const base::FilePath& path) { 61 void TestOnPluginLoadFailed(uint32 index, const base::FilePath& path) {
55 OnPluginLoadFailed(index, path); 62 OnPluginLoadFailed(index, path);
56 } 63 }
57 64
58 protected: 65 protected:
59 virtual ~MockPluginLoaderPosix() {} 66 virtual ~MockPluginLoaderPosix() {}
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 plugin_loader()->OnProcessCrashed(42); 394 plugin_loader()->OnProcessCrashed(42);
388 plugin_loader()->OnProcessCrashed(42); 395 plugin_loader()->OnProcessCrashed(42);
389 plugin_loader()->OnProcessCrashed(42); 396 plugin_loader()->OnProcessCrashed(42);
390 397
391 message_loop()->RunUntilIdle(); 398 message_loop()->RunUntilIdle();
392 EXPECT_EQ(1, did_callback); 399 EXPECT_EQ(1, did_callback);
393 400
394 EXPECT_EQ(0u, plugin_loader()->loaded_plugins().size()); 401 EXPECT_EQ(0u, plugin_loader()->loaded_plugins().size());
395 } 402 }
396 403
404 TEST_F(PluginLoaderPosixTest, PluginLaunchFailed) {
405 int did_callback = 0;
406 PluginService::GetPluginsCallback callback =
407 base::Bind(&VerifyCallback, base::Unretained(&did_callback));
408
409 EXPECT_CALL(*plugin_loader(), LoadPluginsInternal())
410 .WillOnce(testing::Invoke(
411 plugin_loader(), &MockPluginLoaderPosix::RealLoadPluginsInternal));
412
413 plugin_loader()->GetPlugins(callback);
414 message_loop()->RunUntilIdle();
415 EXPECT_EQ(1, did_callback);
416 EXPECT_EQ(0u, plugin_loader()->loaded_plugins().size());
417
418 // TODO(erikchen): This is a genuine leak that should be fixed.
419 // https://code.google.com/p/chromium/issues/detail?id=431906
420 testing::Mock::AllowLeak(plugin_loader());
421 }
422
397 } // namespace content 423 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/plugin_loader_posix.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698