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

Unified Diff: content/browser/plugin_loader_posix_unittest.cc

Issue 128773002: Restart plugin loading only if the plugin list has actually become stale. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix test Created 6 years, 11 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/plugin_loader_posix.cc ('k') | content/browser/plugin_service_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/plugin_loader_posix_unittest.cc
diff --git a/content/browser/plugin_loader_posix_unittest.cc b/content/browser/plugin_loader_posix_unittest.cc
index 4690768435c2ab93f85dae3fcd40d3c6de410b58..542b2c6cbb458f25c0ebad588cea36a0fe24b070 100644
--- a/content/browser/plugin_loader_posix_unittest.cc
+++ b/content/browser/plugin_loader_posix_unittest.cc
@@ -11,6 +11,7 @@
#include "base/message_loop/message_loop.h"
#include "base/strings/utf_string_conversions.h"
#include "content/browser/browser_thread_impl.h"
+#include "content/common/plugin_list.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -96,7 +97,8 @@ class PluginLoaderPosixTest : public testing::Test {
WebPluginInfo plugin3_;
private:
- base::ShadowingAtExitManager at_exit_manager_; // Destroys PluginService.
+ // Destroys PluginService and PluginList.
+ base::ShadowingAtExitManager at_exit_manager_;
base::MessageLoopForIO message_loop_;
BrowserThreadImpl file_thread_;
@@ -110,25 +112,48 @@ TEST_F(PluginLoaderPosixTest, QueueRequests) {
PluginService::GetPluginsCallback callback =
base::Bind(&VerifyCallback, base::Unretained(&did_callback));
- EXPECT_EQ(0u, plugin_loader()->number_of_pending_callbacks());
- plugin_loader()->LoadPlugins(message_loop()->message_loop_proxy(), callback);
- EXPECT_EQ(1u, plugin_loader()->number_of_pending_callbacks());
+ plugin_loader()->GetPlugins(callback);
+ plugin_loader()->GetPlugins(callback);
- plugin_loader()->LoadPlugins(message_loop()->message_loop_proxy(), callback);
- EXPECT_EQ(2u, plugin_loader()->number_of_pending_callbacks());
+ EXPECT_CALL(*plugin_loader(), LoadPluginsInternal()).Times(1);
+ message_loop()->RunUntilIdle();
- EXPECT_CALL(*plugin_loader(), LoadPluginsInternal()).Times(2);
+ EXPECT_EQ(0, did_callback);
+
+ plugin_loader()->canonical_list()->clear();
+ plugin_loader()->canonical_list()->push_back(plugin1_.path);
+ plugin_loader()->TestOnPluginLoaded(0, plugin1_);
+ message_loop()->RunUntilIdle();
+
+ EXPECT_EQ(2, did_callback);
+}
+
+TEST_F(PluginLoaderPosixTest, QueueRequestsAndInvalidate) {
+ int did_callback = 0;
+ PluginService::GetPluginsCallback callback =
+ base::Bind(&VerifyCallback, base::Unretained(&did_callback));
+
+ plugin_loader()->GetPlugins(callback);
+
+ EXPECT_CALL(*plugin_loader(), LoadPluginsInternal()).Times(1);
message_loop()->RunUntilIdle();
EXPECT_EQ(0, did_callback);
+ ::testing::Mock::VerifyAndClearExpectations(plugin_loader());
+
+ // Invalidate the plugin list, then queue up another request.
+ PluginList::Singleton()->RefreshPlugins();
+ plugin_loader()->GetPlugins(callback);
+
+ EXPECT_CALL(*plugin_loader(), LoadPluginsInternal()).Times(1);
plugin_loader()->canonical_list()->clear();
plugin_loader()->canonical_list()->push_back(plugin1_.path);
plugin_loader()->TestOnPluginLoaded(0, plugin1_);
message_loop()->RunUntilIdle();
+ // Only the first request should have been fulfilled.
EXPECT_EQ(1, did_callback);
- EXPECT_EQ(1u, plugin_loader()->number_of_pending_callbacks());
plugin_loader()->canonical_list()->clear();
plugin_loader()->canonical_list()->push_back(plugin1_.path);
@@ -136,7 +161,6 @@ TEST_F(PluginLoaderPosixTest, QueueRequests) {
message_loop()->RunUntilIdle();
EXPECT_EQ(2, did_callback);
- EXPECT_EQ(0u, plugin_loader()->number_of_pending_callbacks());
}
TEST_F(PluginLoaderPosixTest, ThreeSuccessfulLoads) {
@@ -144,7 +168,7 @@ TEST_F(PluginLoaderPosixTest, ThreeSuccessfulLoads) {
PluginService::GetPluginsCallback callback =
base::Bind(&VerifyCallback, base::Unretained(&did_callback));
- plugin_loader()->LoadPlugins(message_loop()->message_loop_proxy(), callback);
+ plugin_loader()->GetPlugins(callback);
EXPECT_CALL(*plugin_loader(), LoadPluginsInternal()).Times(1);
message_loop()->RunUntilIdle();
@@ -184,7 +208,7 @@ TEST_F(PluginLoaderPosixTest, ThreeSuccessfulLoadsThenCrash) {
PluginService::GetPluginsCallback callback =
base::Bind(&VerifyCallback, base::Unretained(&did_callback));
- plugin_loader()->LoadPlugins(message_loop()->message_loop_proxy(), callback);
+ plugin_loader()->GetPlugins(callback);
EXPECT_CALL(*plugin_loader(), LoadPluginsInternal()).Times(2);
message_loop()->RunUntilIdle();
@@ -226,7 +250,7 @@ TEST_F(PluginLoaderPosixTest, TwoFailures) {
PluginService::GetPluginsCallback callback =
base::Bind(&VerifyCallback, base::Unretained(&did_callback));
- plugin_loader()->LoadPlugins(message_loop()->message_loop_proxy(), callback);
+ plugin_loader()->GetPlugins(callback);
EXPECT_CALL(*plugin_loader(), LoadPluginsInternal()).Times(1);
message_loop()->RunUntilIdle();
@@ -264,7 +288,7 @@ TEST_F(PluginLoaderPosixTest, CrashedProcess) {
PluginService::GetPluginsCallback callback =
base::Bind(&VerifyCallback, base::Unretained(&did_callback));
- plugin_loader()->LoadPlugins(message_loop()->message_loop_proxy(), callback);
+ plugin_loader()->GetPlugins(callback);
EXPECT_CALL(*plugin_loader(), LoadPluginsInternal()).Times(1);
message_loop()->RunUntilIdle();
@@ -296,7 +320,7 @@ TEST_F(PluginLoaderPosixTest, InternalPlugin) {
PluginService::GetPluginsCallback callback =
base::Bind(&VerifyCallback, base::Unretained(&did_callback));
- plugin_loader()->LoadPlugins(message_loop()->message_loop_proxy(), callback);
+ plugin_loader()->GetPlugins(callback);
EXPECT_CALL(*plugin_loader(), LoadPluginsInternal()).Times(1);
message_loop()->RunUntilIdle();
@@ -344,7 +368,7 @@ TEST_F(PluginLoaderPosixTest, AllCrashed) {
PluginService::GetPluginsCallback callback =
base::Bind(&VerifyCallback, base::Unretained(&did_callback));
- plugin_loader()->LoadPlugins(message_loop()->message_loop_proxy(), callback);
+ plugin_loader()->GetPlugins(callback);
// Spin the loop so that the canonical list of plugins can be set.
EXPECT_CALL(*plugin_loader(), LoadPluginsInternal()).Times(1);
« no previous file with comments | « content/browser/plugin_loader_posix.cc ('k') | content/browser/plugin_service_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698