Index: chrome/browser/chromeos/gview_request_interceptor_unittest.cc |
diff --git a/chrome/browser/chromeos/gview_request_interceptor_unittest.cc b/chrome/browser/chromeos/gview_request_interceptor_unittest.cc |
index ea119a945e64d0a5b4a1f156055c236294c5cb38..050b67c7ca15da08fe3b1b11e2ca4623067b00c8 100644 |
--- a/chrome/browser/chromeos/gview_request_interceptor_unittest.cc |
+++ b/chrome/browser/chromeos/gview_request_interceptor_unittest.cc |
@@ -6,14 +6,13 @@ |
#include <vector> |
#include "base/at_exit.h" |
-#include "base/bind.h" |
#include "base/message_loop.h" |
#include "chrome/browser/chrome_plugin_service_filter.h" |
#include "chrome/browser/chromeos/gview_request_interceptor.h" |
#include "chrome/browser/plugin_prefs.h" |
#include "chrome/browser/plugin_prefs_factory.h" |
#include "chrome/common/chrome_paths.h" |
-#include "chrome/test/base/testing_pref_service.h" |
+#include "chrome/test/base/testing_profile.h" |
#include "content/browser/mock_resource_context.h" |
#include "content/browser/plugin_service.h" |
#include "content/browser/renderer_host/dummy_resource_handler.h" |
@@ -26,6 +25,7 @@ |
#include "net/url_request/url_request_test_job.h" |
#include "net/url_request/url_request_test_util.h" |
#include "testing/gtest/include/gtest/gtest.h" |
+#include "webkit/plugins/npapi/mock_plugin_list.h" |
using content::BrowserThread; |
@@ -84,16 +84,13 @@ class GViewRequestProtocolFactory |
} |
}; |
-void QuitMessageLoop(const std::vector<webkit::WebPluginInfo>&) { |
- MessageLoop::current()->Quit(); |
-} |
- |
class GViewRequestInterceptorTest : public testing::Test { |
public: |
GViewRequestInterceptorTest() |
: ui_thread_(BrowserThread::UI, &message_loop_), |
file_thread_(BrowserThread::FILE, &message_loop_), |
- io_thread_(BrowserThread::IO, &message_loop_) {} |
+ io_thread_(BrowserThread::IO, &message_loop_), |
+ plugin_list_(NULL, 0) {} |
virtual void SetUp() { |
content::ResourceContext* resource_context = |
@@ -104,9 +101,7 @@ class GViewRequestInterceptorTest : public testing::Test { |
job_factory_.SetProtocolHandler("http", new GViewRequestProtocolFactory); |
job_factory_.AddInterceptor(new GViewRequestInterceptor); |
request_context->set_job_factory(&job_factory_); |
- PluginPrefsFactory::GetInstance()->ForceRegisterPrefsForTest(&prefs_); |
- plugin_prefs_ = new PluginPrefs(); |
- plugin_prefs_->SetPrefs(&prefs_); |
+ plugin_prefs_ = PluginPrefs::GetForTestingProfile(&profile_); |
ChromePluginServiceFilter* filter = |
ChromePluginServiceFilter::GetInstance(); |
filter->RegisterResourceContext(plugin_prefs_, resource_context); |
@@ -116,10 +111,8 @@ class GViewRequestInterceptorTest : public testing::Test { |
handler_ = new content::DummyResourceHandler(); |
+ PluginService::GetInstance()->SetPluginListForTesting(&plugin_list_); |
Bernhard Bauer
2011/11/15 23:00:20
What is going to happen when |plugin_list_| is des
Robert Sesek
2011/11/15 23:02:02
ShadowingAtExitManager will delete the PluginServi
Bernhard Bauer
2011/11/15 23:14:15
Ah, I overlooked that one.
|
PluginService::GetInstance()->Init(); |
- PluginService::GetInstance()->RefreshPlugins(); |
- PluginService::GetInstance()->GetPlugins(base::Bind(&QuitMessageLoop)); |
- MessageLoop::current()->RunAllPending(); |
} |
virtual void TearDown() { |
@@ -135,25 +128,14 @@ class GViewRequestInterceptorTest : public testing::Test { |
PluginService::GetInstance()->set_filter(NULL); |
} |
- // GetPluginInfoByPath() will only use stale information. Because plugin |
- // refresh is asynchronous, spin a MessageLoop until the callback is run, |
- // after which, the test will continue. |
void RegisterPDFPlugin() { |
webkit::WebPluginInfo info; |
info.path = pdf_path_; |
- PluginService::GetInstance()->RegisterInternalPlugin(info); |
- |
- PluginService::GetInstance()->RefreshPlugins(); |
- PluginService::GetInstance()->GetPlugins(base::Bind(&QuitMessageLoop)); |
- MessageLoop::current()->RunAllPending(); |
+ plugin_list_.AddPluginToLoad(info); |
} |
void UnregisterPDFPlugin() { |
- PluginService::GetInstance()->UnregisterInternalPlugin(pdf_path_); |
- |
- PluginService::GetInstance()->RefreshPlugins(); |
- PluginService::GetInstance()->GetPlugins(base::Bind(&QuitMessageLoop)); |
- MessageLoop::current()->RunAllPending(); |
+ plugin_list_.ClearPluginsToLoad(); |
} |
void SetPDFPluginLoadedState(bool want_loaded) { |
@@ -207,7 +189,8 @@ class GViewRequestInterceptorTest : public testing::Test { |
content::TestBrowserThread ui_thread_; |
content::TestBrowserThread file_thread_; |
content::TestBrowserThread io_thread_; |
- TestingPrefService prefs_; |
+ webkit::npapi::MockPluginList plugin_list_; |
+ TestingProfile profile_; |
Bernhard Bauer
2011/11/15 23:00:20
Why do we need to set up a TestingProfile now inst
Robert Sesek
2011/11/15 23:02:02
Because the NOTIFICATION_PLUGIN_ENABLE_STATUS_CHAN
Bernhard Bauer
2011/11/15 23:14:15
Hm, maybe we could just ignore a NULL source there
Robert Sesek
2011/11/15 23:15:36
Yeah, I wasn't sure if we wanted to do that. It se
|
scoped_refptr<PluginPrefs> plugin_prefs_; |
net::URLRequestJobFactory job_factory_; |
const net::URLRequestJobFactory* old_factory_; |
@@ -235,7 +218,7 @@ TEST_F(GViewRequestInterceptorTest, DoNotInterceptDownload) { |
EXPECT_EQ(GURL(kPdfUrl), request.url()); |
} |
-TEST_F(GViewRequestInterceptorTest, DISABLED_DoNotInterceptPdfWhenEnabled) { |
+TEST_F(GViewRequestInterceptorTest, DoNotInterceptPdfWhenEnabled) { |
SetPDFPluginLoadedState(true); |
plugin_prefs_->EnablePlugin(true, pdf_path_); |
@@ -247,7 +230,7 @@ TEST_F(GViewRequestInterceptorTest, DISABLED_DoNotInterceptPdfWhenEnabled) { |
EXPECT_EQ(GURL(kPdfUrl), request.url()); |
} |
-TEST_F(GViewRequestInterceptorTest, DISABLED_InterceptPdfWhenDisabled) { |
+TEST_F(GViewRequestInterceptorTest, InterceptPdfWhenDisabled) { |
SetPDFPluginLoadedState(true); |
plugin_prefs_->EnablePlugin(false, pdf_path_); |