Chromium Code Reviews| Index: chrome/browser/media_galleries/media_file_system_registry_unittest.cc |
| diff --git a/chrome/browser/media_galleries/media_file_system_registry_unittest.cc b/chrome/browser/media_galleries/media_file_system_registry_unittest.cc |
| index 10db660818ae92265d2333e66d6aab0e638ea5de..84630a832db46d9adf7c0f8a6096dfc1767af3eb 100644 |
| --- a/chrome/browser/media_galleries/media_file_system_registry_unittest.cc |
| +++ b/chrome/browser/media_galleries/media_file_system_registry_unittest.cc |
| @@ -284,9 +284,6 @@ class ProfileState { |
| class MediaFileSystemRegistryTest : public ChromeRenderViewHostTestHarness { |
| public: |
| - MediaFileSystemRegistryTest(); |
| - virtual ~MediaFileSystemRegistryTest() {} |
| - |
| void CreateProfileState(size_t profile_count); |
| ProfileState* GetProfileState(size_t i); |
| @@ -356,10 +353,10 @@ class MediaFileSystemRegistryTest : public ChromeRenderViewHostTestHarness { |
| private: |
| // This makes sure that at least one default gallery exists on the file |
| // system. |
| - EnsureMediaDirectoriesExists media_directories_; |
| + scoped_ptr<EnsureMediaDirectoriesExists> media_directories_; |
| // Some test gallery directories. |
| - base::ScopedTempDir galleries_dir_; |
| + scoped_ptr<base::ScopedTempDir> galleries_dir_; |
| // An empty directory in |galleries_dir_| |
| base::FilePath empty_dir_; |
| // A directory in |galleries_dir_| with a DCIM directory in it. |
| @@ -369,13 +366,11 @@ class MediaFileSystemRegistryTest : public ChromeRenderViewHostTestHarness { |
| TestMediaFileSystemContext* test_file_system_context_; |
| // Needed for extension service & friends to work. |
| - content::TestBrowserThread ui_thread_; |
| - content::TestBrowserThread file_thread_; |
| #if defined OS_CHROMEOS |
| chromeos::ScopedTestDeviceSettingsService test_device_settings_service_; |
| chromeos::ScopedTestCrosSettings test_cros_settings_; |
| - chromeos::ScopedTestUserManager test_user_manager_; |
| + scoped_ptr<chromeos::ScopedTestUserManager> test_user_manager_; |
| #endif |
| // TODO(gbillock): Eliminate windows-specific code from this test. |
| @@ -385,11 +380,9 @@ class MediaFileSystemRegistryTest : public ChromeRenderViewHostTestHarness { |
| chrome::test::TestStorageMonitor monitor_; |
| #endif |
| - MockProfileSharedRenderProcessHostFactory rph_factory_; |
| + scoped_ptr<MockProfileSharedRenderProcessHostFactory> rph_factory_; |
| ScopedVector<ProfileState> profile_states_; |
| - |
| - DISALLOW_COPY_AND_ASSIGN(MediaFileSystemRegistryTest); |
| }; |
| namespace { |
| @@ -577,14 +570,9 @@ int ProfileState::GetAndClearComparisonCount() { |
| // MediaFileSystemRegistryTest // |
| ///////////////////////////////// |
| -MediaFileSystemRegistryTest::MediaFileSystemRegistryTest() |
| - : ui_thread_(content::BrowserThread::UI, MessageLoop::current()), |
| - file_thread_(content::BrowserThread::FILE, MessageLoop::current()) { |
| -} |
| - |
| void MediaFileSystemRegistryTest::CreateProfileState(size_t profile_count) { |
| for (size_t i = 0; i < profile_count; ++i) { |
| - ProfileState* state = new ProfileState(&rph_factory_); |
| + ProfileState* state = new ProfileState(rph_factory_.get()); |
| profile_states_.push_back(state); |
| } |
| } |
| @@ -720,6 +708,10 @@ MediaFileSystemRegistryTest::GetAutoAddedGalleries( |
| } |
| void MediaFileSystemRegistryTest::SetUp() { |
| + ChromeRenderViewHostTestHarness::CreateThreadBundle(); |
| + media_directories_.reset(new EnsureMediaDirectoriesExists()); |
| + galleries_dir_.reset(new base::ScopedTempDir()); |
| + rph_factory_.reset(new MockProfileSharedRenderProcessHostFactory()); |
| #if defined(OS_WIN) |
| test::TestPortableDeviceWatcherWin* portable_device_watcher = |
| new test::TestPortableDeviceWatcherWin; |
| @@ -737,30 +729,39 @@ void MediaFileSystemRegistryTest::SetUp() { |
| mount_watcher->FlushWorkerPoolForTesting(); |
| base::RunLoop().RunUntilIdle(); |
| #endif |
| - |
| ChromeRenderViewHostTestHarness::SetUp(); |
|
Greg Billock
2013/05/22 00:05:25
You moved this up to line 715 right?
awong
2013/05/22 20:08:36
Good point. Fixed.
|
| + |
| DeleteContents(); |
| - SetRenderProcessHostFactory(&rph_factory_); |
| + SetRenderProcessHostFactory(rph_factory_.get()); |
| test_file_system_context_ = new TestMediaFileSystemContext( |
| g_browser_process->media_file_system_registry()); |
| - ASSERT_TRUE(galleries_dir_.CreateUniqueTempDir()); |
| - empty_dir_ = galleries_dir_.path().AppendASCII("empty"); |
| +#if defined OS_CHROMEOS |
| + test_user_manager_.reset(new chromeos::ScopedTestUserManager()); |
| +#endif |
| + |
| + ASSERT_TRUE(galleries_dir_->CreateUniqueTempDir()); |
| + empty_dir_ = galleries_dir_->path().AppendASCII("empty"); |
| ASSERT_TRUE(file_util::CreateDirectory(empty_dir_)); |
| - dcim_dir_ = galleries_dir_.path().AppendASCII("with_dcim"); |
| + dcim_dir_ = galleries_dir_->path().AppendASCII("with_dcim"); |
| ASSERT_TRUE(file_util::CreateDirectory(dcim_dir_)); |
| ASSERT_TRUE(file_util::CreateDirectory(dcim_dir_.Append(kDCIMDirectoryName))); |
| } |
| void MediaFileSystemRegistryTest::TearDown() { |
| profile_states_.clear(); |
| - ChromeRenderViewHostTestHarness::TearDown(); |
| MediaFileSystemRegistry* registry = |
| g_browser_process->media_file_system_registry(); |
| EXPECT_EQ(0U, registry->GetExtensionGalleriesHostCountForTests()); |
| - BrowserThread::GetBlockingPool()->FlushForTesting(); |
| - MessageLoop::current()->RunUntilIdle(); |
| +#if defined OS_CHROMEOS |
| + test_user_manager_.reset(); |
| +#endif |
| + |
| +#if defined(OS_WIN) |
| + monitor_.reset(); |
| +#endif |
| + ChromeRenderViewHostTestHarness::TearDown(); |
| } |
| /////////// |