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..886eff3e3aa9e60499bc47b2f23cb42a72ebb39b 100644 |
| --- a/chrome/browser/media_galleries/media_file_system_registry_unittest.cc |
| +++ b/chrome/browser/media_galleries/media_file_system_registry_unittest.cc |
| @@ -17,6 +17,7 @@ |
| #include "base/run_loop.h" |
| #include "base/stl_util.h" |
| #include "base/stringprintf.h" |
| +#include "base/synchronization/waitable_event.h" |
| #include "base/threading/sequenced_worker_pool.h" |
| #include "base/utf_string_conversions.h" |
| #include "base/values.h" |
| @@ -291,6 +292,8 @@ class MediaFileSystemRegistryTest : public ChromeRenderViewHostTestHarness { |
| ProfileState* GetProfileState(size_t i); |
| + MediaGalleriesPreferences* GetPreferences(Profile* profile); |
| + |
| base::FilePath empty_dir() { |
| return empty_dir_; |
| } |
| @@ -382,7 +385,7 @@ class MediaFileSystemRegistryTest : public ChromeRenderViewHostTestHarness { |
| #if defined(OS_WIN) |
| scoped_ptr<test::TestStorageMonitorWin> monitor_; |
| #else |
| - chrome::test::TestStorageMonitor monitor_; |
| + scoped_ptr<chrome::test::TestStorageMonitor> monitor_; |
| #endif |
| MockProfileSharedRenderProcessHostFactory rph_factory_; |
| @@ -593,6 +596,11 @@ ProfileState* MediaFileSystemRegistryTest::GetProfileState(size_t i) { |
| return profile_states_[i]; |
| } |
| +MediaGalleriesPreferences* MediaFileSystemRegistryTest::GetPreferences( |
| + Profile* profile) { |
| + return GetMediaFileSystemRegistry()->GetPreferences(profile); |
|
vandebo (ex-Chrome)
2013/05/22 21:40:34
Isn't this a recursive call?
Greg Billock
2013/05/23 00:55:59
No, this is in the test. ;-)
|
| +} |
| + |
| std::string MediaFileSystemRegistryTest::AddUserGallery( |
| StorageInfo::Type type, |
| const std::string& unique_id, |
| @@ -720,7 +728,15 @@ MediaFileSystemRegistryTest::GetAutoAddedGalleries( |
| } |
| void MediaFileSystemRegistryTest::SetUp() { |
| -#if defined(OS_WIN) |
| +#if !defined(OS_WIN) |
| + monitor_.reset(new test::TestStorageMonitor()); |
|
vandebo (ex-Chrome)
2013/05/22 21:40:34
Looks like the waitable event found it's way back.
Greg Billock
2013/05/23 00:55:59
Grrr. I must have branched without checking in som
|
| + base::WaitableEvent wait_for_init(false, false); |
| + monitor_->Initialize(base::Bind(&base::WaitableEvent::Signal, |
| + base::Unretained(&wait_for_init))); |
| + monitor_->MarkInitialized(); |
| + base::RunLoop().RunUntilIdle(); |
| + DCHECK(wait_for_init.IsSignaled()); |
| +#else |
| test::TestPortableDeviceWatcherWin* portable_device_watcher = |
| new test::TestPortableDeviceWatcherWin; |
| test::TestVolumeMountWatcherWin* mount_watcher = |
| @@ -728,7 +744,10 @@ void MediaFileSystemRegistryTest::SetUp() { |
| portable_device_watcher->set_use_dummy_mtp_storage_info(true); |
| monitor_.reset(new test::TestStorageMonitorWin( |
| mount_watcher, portable_device_watcher)); |
| - monitor_->Init(); |
| + base::WaitableEvent wait_for_init(false, false); |
| + wait_for_init.Reset(); |
| + monitor_->Initialize(base::Bind(&base::WaitableEvent::Signal, |
| + base::Unretained(&wait_for_init))); |
| // TODO(gbillock): Replace this with the correct event notification |
| // on the storage monitor finishing the startup scan when that exists. |
| base::RunLoop().RunUntilIdle(); |
| @@ -736,6 +755,7 @@ void MediaFileSystemRegistryTest::SetUp() { |
| base::RunLoop().RunUntilIdle(); |
| mount_watcher->FlushWorkerPoolForTesting(); |
| base::RunLoop().RunUntilIdle(); |
| + DCHECK(wait_for_init.IsSignaled()); |
| #endif |
| ChromeRenderViewHostTestHarness::SetUp(); |
| @@ -850,8 +870,7 @@ TEST_F(MediaFileSystemRegistryTest, |
| // Forget the device. |
| bool forget_gallery = false; |
| - MediaGalleriesPreferences* prefs = |
| - GetMediaFileSystemRegistry()->GetPreferences(profile_state->profile()); |
| + MediaGalleriesPreferences* prefs = GetPreferences(profile_state->profile()); |
| const MediaGalleriesPrefInfoMap& galleries = prefs->known_galleries(); |
| for (MediaGalleriesPrefInfoMap::const_iterator it = galleries.begin(); |
| it != galleries.end(); ++it) { |
| @@ -866,7 +885,7 @@ TEST_F(MediaFileSystemRegistryTest, |
| EXPECT_EQ(gallery_count, GetAutoAddedGalleries(profile_state).size()); |
| // Call GetPreferences() and the gallery count should not change. |
| - GetMediaFileSystemRegistry()->GetPreferences(profile_state->profile()); |
| + prefs = GetPreferences(profile_state->profile()); |
| EXPECT_EQ(gallery_count, GetAutoAddedGalleries(profile_state).size()); |
| } |
| @@ -884,7 +903,7 @@ TEST_F(MediaFileSystemRegistryTest, GalleryNameDefault) { |
| // TODO(gbillock): Put the platform-specific parts of this test in tests |
| // for those classes, not here. This test, internally, ends up creating an |
| -// MTP delegate. |
| +// MTP delegate. (Probably ./win/mtp_device_delegate_impl_win_unittest) |
| #if !defined(OS_MACOSX) |
| TEST_F(MediaFileSystemRegistryTest, GalleryNameMTP) { |
| FSInfoMap galleries_info; |