diff options
author | anthonyvd <anthonyvd@chromium.org> | 2015-02-27 16:04:23 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-02-28 00:05:16 +0000 |
commit | 404d6107e0215a5c3914b8d3b18f4851e9551a07 (patch) | |
tree | 517b648bbe808d9cb180721a0a74e9de58e6f23b | |
parent | e6eb185c92a58e034bbe31e89bf3ac7205099527 (diff) | |
download | chromium_src-404d6107e0215a5c3914b8d3b18f4851e9551a07.zip chromium_src-404d6107e0215a5c3914b8d3b18f4851e9551a07.tar.gz chromium_src-404d6107e0215a5c3914b8d3b18f4851e9551a07.tar.bz2 |
Fix unit tests on official bots.
Some of the tests weren't properly instantiating a PrefService. It's now being
done in the ExtensionServiceTestBase class and its subclasses were modified
where needed.
BUG=461484
Review URL: https://codereview.chromium.org/965803003
Cr-Commit-Position: refs/heads/master@{#318552}
5 files changed, 7 insertions, 31 deletions
diff --git a/chrome/browser/extensions/extension_garbage_collector_chromeos_unittest.cc b/chrome/browser/extensions/extension_garbage_collector_chromeos_unittest.cc index 622f324..1971067 100644 --- a/chrome/browser/extensions/extension_garbage_collector_chromeos_unittest.cc +++ b/chrome/browser/extensions/extension_garbage_collector_chromeos_unittest.cc @@ -42,13 +42,9 @@ namespace extensions { class ExtensionGarbageCollectorChromeOSUnitTest : public ExtensionServiceTestBase { protected: - PrefService& local_state() { return local_state_; } const base::FilePath& cache_dir() { return cache_dir_.path(); } void SetUp() override { - TestingBrowserProcess::GetGlobal()->SetLocalState(&local_state_); - chrome::RegisterLocalState(local_state_.registry()); - #if defined(ENABLE_PLUGINS) content::PluginService::GetInstance()->Init(); #endif @@ -77,10 +73,6 @@ class ExtensionGarbageCollectorChromeOSUnitTest GetFakeUserManager()->GetActiveUser(), profile_.get()); } - void TearDown() override { - TestingBrowserProcess::GetGlobal()->SetLocalState(NULL); - } - void GarbageCollectExtensions() { ExtensionGarbageCollector::Get(profile_.get()) ->GarbageCollectExtensionsForTest(); @@ -100,7 +92,7 @@ class ExtensionGarbageCollectorChromeOSUnitTest const std::string& version, const std::string& users_string, const base::FilePath& path) { - DictionaryPrefUpdate shared_extensions(&local_state_, + DictionaryPrefUpdate shared_extensions(testing_local_state_.Get(), ExtensionAssetsManagerChromeOS::kSharedExtensions); base::DictionaryValue* extension_info = NULL; @@ -152,7 +144,6 @@ class ExtensionGarbageCollectorChromeOSUnitTest private: scoped_ptr<chromeos::ScopedUserManagerEnabler> user_manager_enabler_; - TestingPrefServiceSimple local_state_; base::ScopedTempDir cache_dir_; }; @@ -195,8 +186,8 @@ TEST_F(ExtensionGarbageCollectorChromeOSUnitTest, SharedExtensions) { EXPECT_TRUE(base::PathExists(path_id2_1)); - const base::DictionaryValue* shared_extensions = local_state().GetDictionary( - ExtensionAssetsManagerChromeOS::kSharedExtensions); + const base::DictionaryValue* shared_extensions = testing_local_state_.Get()-> + GetDictionary(ExtensionAssetsManagerChromeOS::kSharedExtensions); ASSERT_TRUE(shared_extensions); EXPECT_FALSE(shared_extensions->HasKey(kExtensionId1)); diff --git a/chrome/browser/extensions/extension_service_test_base.cc b/chrome/browser/extensions/extension_service_test_base.cc index 9f8ead8..cb0e914 100644 --- a/chrome/browser/extensions/extension_service_test_base.cc +++ b/chrome/browser/extensions/extension_service_test_base.cc @@ -19,6 +19,7 @@ #include "chrome/browser/prefs/pref_service_syncable.h" #include "chrome/common/chrome_constants.h" #include "chrome/common/chrome_paths.h" +#include "chrome/test/base/testing_browser_process.h" #include "chrome/test/base/testing_profile.h" #include "components/pref_registry/pref_registry_syncable.h" #include "content/public/browser/browser_context.h" @@ -73,6 +74,7 @@ ExtensionServiceTestBase::ExtensionServiceInitParams:: ExtensionServiceTestBase::ExtensionServiceTestBase() : service_(NULL), + testing_local_state_(TestingBrowserProcess::GetGlobal()), thread_bundle_(new content::TestBrowserThreadBundle(kThreadOptions)), did_reset_thread_bundle_(false), registry_(NULL) { diff --git a/chrome/browser/extensions/extension_service_test_base.h b/chrome/browser/extensions/extension_service_test_base.h index d64322d..ab48634 100644 --- a/chrome/browser/extensions/extension_service_test_base.h +++ b/chrome/browser/extensions/extension_service_test_base.h @@ -9,6 +9,7 @@ #include "base/files/file_path.h" #include "base/files/scoped_temp_dir.h" #include "base/memory/scoped_ptr.h" +#include "chrome/test/base/scoped_testing_local_state.h" #include "content/public/test/test_browser_thread_bundle.h" #include "content/public/test/test_utils.h" #include "testing/gtest/include/gtest/gtest.h" @@ -112,6 +113,7 @@ class ExtensionServiceTestBase : public testing::Test { // The ExtensionService, whose lifetime is managed by |profile|'s // ExtensionSystem. ExtensionService* service_; + ScopedTestingLocalState testing_local_state_; private: void CreateExtensionService(const ExtensionServiceInitParams& params); diff --git a/chrome/browser/extensions/external_provider_impl_chromeos_unittest.cc b/chrome/browser/extensions/external_provider_impl_chromeos_unittest.cc index edf428d2..8bc00f0 100644 --- a/chrome/browser/extensions/external_provider_impl_chromeos_unittest.cc +++ b/chrome/browser/extensions/external_provider_impl_chromeos_unittest.cc @@ -6,7 +6,6 @@ #include "base/command_line.h" #include "base/memory/scoped_ptr.h" -#include "base/prefs/testing_pref_service.h" #include "base/test/scoped_path_override.h" #include "chrome/browser/chrome_notification_types.h" #include "chrome/browser/chromeos/app_mode/kiosk_app_manager.h" @@ -57,21 +56,15 @@ class ExternalProviderImplChromeOSTest : public ExtensionServiceTestBase { void SetUp() override { ExtensionServiceTestBase::SetUp(); - TestingBrowserProcess::GetGlobal()->SetLocalState(&local_state_); - chromeos::ServicesCustomizationDocument::RegisterPrefs( - local_state_.registry()); - external_externsions_overrides_.reset(new base::ScopedPathOverride( chrome::DIR_EXTERNAL_EXTENSIONS, data_dir().Append("external"))); } void TearDown() override { chromeos::KioskAppManager::Shutdown(); - TestingBrowserProcess::GetGlobal()->SetLocalState(NULL); } private: - TestingPrefServiceSimple local_state_; scoped_ptr<base::ScopedPathOverride> external_externsions_overrides_; chromeos::system::ScopedFakeStatisticsProvider fake_statistics_provider_; user_manager::FakeUserManager* fake_user_manager_; diff --git a/chrome/browser/extensions/external_provider_impl_unittest.cc b/chrome/browser/extensions/external_provider_impl_unittest.cc index 486eac6..43962c9 100644 --- a/chrome/browser/extensions/external_provider_impl_unittest.cc +++ b/chrome/browser/extensions/external_provider_impl_unittest.cc @@ -9,7 +9,6 @@ #include "base/files/file_util.h" #include "base/memory/scoped_ptr.h" #include "base/path_service.h" -#include "base/prefs/testing_pref_service.h" #include "base/strings/stringprintf.h" #include "base/test/scoped_path_override.h" #include "chrome/browser/chrome_notification_types.h" @@ -99,12 +98,6 @@ class ExternalProviderImplTest : public ExtensionServiceTestBase { ExtensionServiceTestBase::SetUp(); test_server_.reset(new EmbeddedTestServer()); -#if defined(OS_CHROMEOS) - TestingBrowserProcess::GetGlobal()->SetLocalState(&local_state_); - chromeos::ServicesCustomizationDocument::RegisterPrefs( - local_state_.registry()); -#endif - ASSERT_TRUE(test_server_->InitializeAndWaitUntilReady()); test_server_->RegisterRequestHandler( base::Bind(&ExternalProviderImplTest::HandleRequest, @@ -117,10 +110,6 @@ class ExternalProviderImplTest : public ExtensionServiceTestBase { test_server_->GetURL(kManifestPath).spec()); } - void TearDown() override { - TestingBrowserProcess::GetGlobal()->SetLocalState(NULL); - } - private: scoped_ptr<HttpResponse> HandleRequest(const HttpRequest& request) { GURL url = test_server_->GetURL(request.relative_url); @@ -163,7 +152,6 @@ class ExternalProviderImplTest : public ExtensionServiceTestBase { // chromeos::ServicesCustomizationExternalLoader is hooked up as an // extensions::ExternalLoader and depends on a functioning StatisticsProvider. chromeos::system::ScopedFakeStatisticsProvider fake_statistics_provider_; - TestingPrefServiceSimple local_state_; #endif DISALLOW_COPY_AND_ASSIGN(ExternalProviderImplTest); |