Commit 32e2e9bc authored by rsesek@chromium.org's avatar rsesek@chromium.org

Fix ExtensionServiceTest by moving base::ShadowingAtExitManager into the fixture.

BUG=104443
TEST=unit_tests --gtest_filter=ExtensionServiceTest\* under valgrind

Review URL: http://codereview.chromium.org/8486019

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@110724 0039d316-1c4b-4281-b951-d872f2087c98
parent 5212af31
...@@ -42,6 +42,7 @@ ...@@ -42,6 +42,7 @@
#include "chrome/browser/extensions/pending_extension_info.h" #include "chrome/browser/extensions/pending_extension_info.h"
#include "chrome/browser/extensions/pending_extension_manager.h" #include "chrome/browser/extensions/pending_extension_manager.h"
#include "chrome/browser/extensions/unpacked_installer.h" #include "chrome/browser/extensions/unpacked_installer.h"
#include "chrome/browser/plugin_prefs_factory.h"
#include "chrome/browser/prefs/browser_prefs.h" #include "chrome/browser/prefs/browser_prefs.h"
#include "chrome/browser/prefs/pref_service_mock_builder.h" #include "chrome/browser/prefs/pref_service_mock_builder.h"
#include "chrome/browser/prefs/scoped_user_pref_update.h" #include "chrome/browser/prefs/scoped_user_pref_update.h"
...@@ -379,9 +380,9 @@ class ExtensionTestingProfile : public TestingProfile { ...@@ -379,9 +380,9 @@ class ExtensionTestingProfile : public TestingProfile {
// Our message loop may be used in tests which require it to be an IO loop. // Our message loop may be used in tests which require it to be an IO loop.
ExtensionServiceTestBase::ExtensionServiceTestBase() ExtensionServiceTestBase::ExtensionServiceTestBase()
: service_(NULL), : loop_(MessageLoop::TYPE_IO),
service_(NULL),
total_successes_(0), total_successes_(0),
loop_(MessageLoop::TYPE_IO),
ui_thread_(BrowserThread::UI, &loop_), ui_thread_(BrowserThread::UI, &loop_),
db_thread_(BrowserThread::DB, &loop_), db_thread_(BrowserThread::DB, &loop_),
webkit_thread_(BrowserThread::WEBKIT, &loop_), webkit_thread_(BrowserThread::WEBKIT, &loop_),
...@@ -415,6 +416,8 @@ void ExtensionServiceTestBase::InitializeExtensionService( ...@@ -415,6 +416,8 @@ void ExtensionServiceTestBase::InitializeExtensionService(
browser::RegisterUserPrefs(prefs); browser::RegisterUserPrefs(prefs);
profile->SetPrefService(prefs); profile->SetPrefService(prefs);
PluginPrefsFactory::GetInstance()->ForceRegisterPrefsForTest(prefs);
profile_.reset(profile); profile_.reset(profile);
service_ = profile->CreateExtensionService( service_ = profile->CreateExtensionService(
...@@ -984,7 +987,6 @@ void PackExtensionTestClient::OnPackFailure(const std::string& error_message) { ...@@ -984,7 +987,6 @@ void PackExtensionTestClient::OnPackFailure(const std::string& error_message) {
// Test loading good extensions from the profile directory. // Test loading good extensions from the profile directory.
TEST_F(ExtensionServiceTest, LoadAllExtensionsFromDirectorySuccess) { TEST_F(ExtensionServiceTest, LoadAllExtensionsFromDirectorySuccess) {
base::ShadowingAtExitManager at_exit_manager;
PluginService::GetInstance()->Init(); PluginService::GetInstance()->Init();
// Initialize the test dir with a good Preferences/extensions. // Initialize the test dir with a good Preferences/extensions.
...@@ -1124,7 +1126,6 @@ TEST_F(ExtensionServiceTest, LoadAllExtensionsFromDirectoryFail) { ...@@ -1124,7 +1126,6 @@ TEST_F(ExtensionServiceTest, LoadAllExtensionsFromDirectoryFail) {
// Test that partially deleted extensions are cleaned up during startup // Test that partially deleted extensions are cleaned up during startup
// Test loading bad extensions from the profile directory. // Test loading bad extensions from the profile directory.
TEST_F(ExtensionServiceTest, CleanupOnStartup) { TEST_F(ExtensionServiceTest, CleanupOnStartup) {
base::ShadowingAtExitManager at_exit_manager;
PluginService::GetInstance()->Init(); PluginService::GetInstance()->Init();
FilePath source_install_dir = data_dir_ FilePath source_install_dir = data_dir_
...@@ -1460,7 +1461,6 @@ TEST_F(ExtensionServiceTest, GrantedPermissions) { ...@@ -1460,7 +1461,6 @@ TEST_F(ExtensionServiceTest, GrantedPermissions) {
// an extension contains an NPAPI plugin. Don't run this test on Chrome OS // an extension contains an NPAPI plugin. Don't run this test on Chrome OS
// since they don't support plugins. // since they don't support plugins.
TEST_F(ExtensionServiceTest, GrantedFullAccessPermissions) { TEST_F(ExtensionServiceTest, GrantedFullAccessPermissions) {
base::ShadowingAtExitManager at_exit_manager;
PluginService::GetInstance()->Init(); PluginService::GetInstance()->Init();
InitializeEmptyExtensionService(); InitializeEmptyExtensionService();
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#define CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_UNITTEST_H_ #define CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_UNITTEST_H_
#pragma once #pragma once
#include "base/at_exit.h"
#include "base/file_path.h" #include "base/file_path.h"
#include "base/memory/ref_counted.h" #include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h" #include "base/memory/scoped_ptr.h"
...@@ -48,6 +49,8 @@ class ExtensionServiceTestBase : public testing::Test { ...@@ -48,6 +49,8 @@ class ExtensionServiceTestBase : public testing::Test {
protected: protected:
void InitializeExtensionServiceHelper(bool autoupdate_enabled); void InitializeExtensionServiceHelper(bool autoupdate_enabled);
MessageLoop loop_;
base::ShadowingAtExitManager at_exit_manager_;
ScopedTempDir temp_dir_; ScopedTempDir temp_dir_;
scoped_ptr<TestingProfile> profile_; scoped_ptr<TestingProfile> profile_;
FilePath extensions_install_dir_; FilePath extensions_install_dir_;
...@@ -55,7 +58,6 @@ class ExtensionServiceTestBase : public testing::Test { ...@@ -55,7 +58,6 @@ class ExtensionServiceTestBase : public testing::Test {
// Owned by |profile_|. // Owned by |profile_|.
ExtensionService* service_; ExtensionService* service_;
size_t total_successes_; size_t total_successes_;
MessageLoop loop_;
content::TestBrowserThread ui_thread_; content::TestBrowserThread ui_thread_;
content::TestBrowserThread db_thread_; content::TestBrowserThread db_thread_;
content::TestBrowserThread webkit_thread_; content::TestBrowserThread webkit_thread_;
......
...@@ -6,5 +6,3 @@ RenderViewTest.OnHandleKeyboardEvent ...@@ -6,5 +6,3 @@ RenderViewTest.OnHandleKeyboardEvent
ConnectionTesterTest.DeleteWhileInProgress ConnectionTesterTest.DeleteWhileInProgress
# Fails on CrOS, see http://crbug.com/104030 # Fails on CrOS, see http://crbug.com/104030
GViewRequestInterceptorTest.* GViewRequestInterceptorTest.*
# Multiple Memcheck reports. See http://crbug.com/104443.
ExtensionServiceTest.CleanupOnStartup
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment