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 45e7fc2da9416eda5255fa2938e923351f183263..83b9bf468a4f8ee774efaaf35f3d71f3ffeb8033 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" |
@@ -386,7 +387,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_; |
@@ -724,7 +725,15 @@ MediaFileSystemRegistryTest::GetAutoAddedGalleries( |
} |
void MediaFileSystemRegistryTest::SetUp() { |
-#if defined(OS_WIN) |
+#if !defined(OS_WIN) |
+ monitor_.reset(new test::TestStorageMonitor()); |
+ 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 = |
@@ -732,7 +741,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(); |
@@ -740,6 +752,7 @@ void MediaFileSystemRegistryTest::SetUp() { |
base::RunLoop().RunUntilIdle(); |
mount_watcher->FlushWorkerPoolForTesting(); |
base::RunLoop().RunUntilIdle(); |
+ DCHECK(wait_for_init.IsSignaled()); |
#endif |
ChromeRenderViewHostTestHarness::SetUp(); |
@@ -855,7 +868,7 @@ TEST_F(MediaFileSystemRegistryTest, |
// Forget the device. |
bool forget_gallery = false; |
MediaGalleriesPreferences* prefs = |
- GetMediaFileSystemRegistry()->GetPreferences(profile_state->profile()); |
+ GetProfileState(0)->GetMediaGalleriesPrefs(); |
const MediaGalleriesPrefInfoMap& galleries = prefs->known_galleries(); |
for (MediaGalleriesPrefInfoMap::const_iterator it = galleries.begin(); |
it != galleries.end(); ++it) { |
@@ -868,10 +881,6 @@ TEST_F(MediaFileSystemRegistryTest, |
MessageLoop::current()->RunUntilIdle(); |
EXPECT_TRUE(forget_gallery); |
EXPECT_EQ(gallery_count, GetAutoAddedGalleries(profile_state).size()); |
- |
- // Call GetPreferences() and the gallery count should not change. |
- GetMediaFileSystemRegistry()->GetPreferences(profile_state->profile()); |
- EXPECT_EQ(gallery_count, GetAutoAddedGalleries(profile_state).size()); |
} |
TEST_F(MediaFileSystemRegistryTest, GalleryNameDefault) { |
@@ -888,7 +897,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(SUPPORT_MTP_DEVICE_FILESYSTEM) |
#if !defined(OS_MACOSX) |
TEST_F(MediaFileSystemRegistryTest, GalleryNameMTP) { |