Chromium Code Reviews| Index: chrome/browser/media_gallery/media_file_system_registry_unittest.cc |
| diff --git a/chrome/browser/media_gallery/media_file_system_registry_unittest.cc b/chrome/browser/media_gallery/media_file_system_registry_unittest.cc |
| index 1a5e4d6c954601b57f79739e571a6a1f7bbe8038..3b1d986a05d56e6f2a95ee35824282a28c55890a 100644 |
| --- a/chrome/browser/media_gallery/media_file_system_registry_unittest.cc |
| +++ b/chrome/browser/media_gallery/media_file_system_registry_unittest.cc |
| @@ -29,6 +29,8 @@ |
| #include "chrome/browser/media_gallery/media_galleries_test_util.h" |
| #include "chrome/browser/system_monitor/media_storage_util.h" |
| #include "chrome/browser/system_monitor/removable_device_constants.h" |
| +#include "chrome/browser/system_monitor/removable_storage_notifications.h" |
| +#include "chrome/browser/system_monitor/test_removable_storage_notifications.h" |
| #include "chrome/common/extensions/extension.h" |
| #include "chrome/test/base/chrome_render_view_host_test_harness.h" |
| #include "chrome/test/base/testing_browser_process.h" |
| @@ -300,6 +302,8 @@ class ProfileState { |
| DISALLOW_COPY_AND_ASSIGN(ProfileState); |
| }; |
| +} // namespace |
| + |
| class MediaFileSystemRegistryTest : public ChromeRenderViewHostTestHarness { |
| public: |
| MediaFileSystemRegistryTest(); |
| @@ -348,6 +352,17 @@ class MediaFileSystemRegistryTest : public ChromeRenderViewHostTestHarness { |
| std::vector<MediaFileSystemInfo> GetAutoAddedGalleries( |
| ProfileState* profile_state); |
| + void ProcessAttach(const std::string& id, |
| + const string16& name, |
| + const FilePath::StringType& location) { |
| + chrome::RemovableStorageNotifications::GetInstance()->ProcessAttach( |
|
Lei Zhang
2013/01/26 01:27:49
nit: no need for chrome:: Since we're already insi
Greg Billock
2013/01/26 01:42:07
Done.
|
| + id, name, location); |
| + } |
| + |
| + void ProcessDetach(const std::string& id) { |
| + chrome::RemovableStorageNotifications::GetInstance()->ProcessDetach(id); |
| + } |
| + |
| protected: |
| void SetUp(); |
| void TearDown(); |
| @@ -371,16 +386,17 @@ class MediaFileSystemRegistryTest : public ChromeRenderViewHostTestHarness { |
| content::TestBrowserThread ui_thread_; |
| content::TestBrowserThread file_thread_; |
| - // For AttachDevice() and DetachDevice(). |
| - scoped_ptr<base::SystemMonitor> system_monitor_; |
| - |
| MockProfileSharedRenderProcessHostFactory rph_factory_; |
| ScopedVector<ProfileState> profile_states_; |
| + chrome::test::TestRemovableStorageNotifications notifications_; |
| + |
| DISALLOW_COPY_AND_ASSIGN(MediaFileSystemRegistryTest); |
| }; |
| +namespace { |
| + |
| bool MediaFileSystemInfoComparator(const MediaFileSystemInfo& a, |
| const MediaFileSystemInfo& b) { |
| CHECK_NE(a.name, b.name); // Name must be unique. |
| @@ -577,6 +593,8 @@ int ProfileState::GetAndClearComparisonCount() { |
| return result; |
| } |
| +} // namespace |
| + |
| ///////////////////////////////// |
| // MediaFileSystemRegistryTest // |
| ///////////////////////////////// |
| @@ -619,8 +637,7 @@ std::string MediaFileSystemRegistryTest::AttachDevice( |
| std::string device_id = MediaStorageUtil::MakeDeviceId(type, unique_id); |
| DCHECK(MediaStorageUtil::IsRemovableDevice(device_id)); |
| string16 name = location.LossyDisplayName(); |
| - base::SystemMonitor::Get()->ProcessRemovableStorageAttached(device_id, name, |
| - location.value()); |
| + ProcessAttach(device_id, name, location.value()); |
| bool user_added = (type == MediaStorageUtil::REMOVABLE_MASS_STORAGE_NO_DCIM); |
| for (size_t i = 0; i < profile_states_.size(); ++i) { |
| profile_states_[i]->GetMediaGalleriesPrefs()->AddGallery( |
| @@ -632,7 +649,7 @@ std::string MediaFileSystemRegistryTest::AttachDevice( |
| void MediaFileSystemRegistryTest::DetachDevice(const std::string& device_id) { |
| DCHECK(MediaStorageUtil::IsRemovableDevice(device_id)); |
| - base::SystemMonitor::Get()->ProcessRemovableStorageDetached(device_id); |
| + ProcessDetach(device_id); |
| MessageLoop::current()->RunUntilIdle(); |
| } |
| @@ -731,12 +748,6 @@ MediaFileSystemRegistryTest::GetAutoAddedGalleries( |
| } |
| void MediaFileSystemRegistryTest::SetUp() { |
| -#if defined(OS_MACOSX) |
| - // This needs to happen before SystemMonitor's ctor. |
| - base::SystemMonitor::AllocateSystemIOPorts(); |
| -#endif |
| - system_monitor_.reset(new base::SystemMonitor); |
| - |
| ChromeRenderViewHostTestHarness::SetUp(); |
| DeleteContents(); |
| SetRenderProcessHostFactory(&rph_factory_); |
| @@ -893,6 +904,4 @@ TEST_F(MediaFileSystemRegistryTest, GalleryNameUserAddedPath) { |
| false /*removable*/, false /* media device */); |
| } |
| -} // namespace |
| - |
| } // namespace chrome |