Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2431)

Unified Diff: chrome/browser/media_gallery/media_file_system_registry_unittest.cc

Issue 11573048: [Media Galleries] Move RemovableStorageInfo notifications to chrome namespace (part 2) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Make singleton pointer live in base class. Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 a627398250b29e3e3bf1a10a0be58d866b0e8a3c..d1ce4cc978fc27c54857d112633be38deeee0409 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,7 @@
#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/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 +301,25 @@ class ProfileState {
DISALLOW_COPY_AND_ASSIGN(ProfileState);
};
+class FakeRemovableStorageNotifications
vandebo (ex-Chrome) 2013/01/18 18:42:58 I don't see what this class does here?
Greg Billock 2013/01/22 20:00:39 Needed to set up the singleton (done in the base c
vandebo (ex-Chrome) 2013/01/22 23:37:24 Ahh, I see. There's a second copy (and a third) o
Greg Billock 2013/01/23 00:28:01 Used "test_*" since that seems the moniker in the
+ : public chrome::RemovableStorageNotifications {
+ public:
+ FakeRemovableStorageNotifications() : RemovableStorageNotifications() {}
+ virtual ~FakeRemovableStorageNotifications() {}
+
+ virtual bool GetDeviceInfoForPath(
+ const FilePath& path,
+ StorageInfo* device_info) const {
+ return false;
+ }
+
+ virtual uint64 GetStorageSize(const std::string& location) const {
+ return 0;
+ }
+};
+
+} // namespace
+
class MediaFileSystemRegistryTest : public ChromeRenderViewHostTestHarness {
public:
MediaFileSystemRegistryTest();
@@ -348,6 +368,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(
+ id, name, location);
+ }
+
+ void ProcessDetach(const std::string& id) {
+ chrome::RemovableStorageNotifications::GetInstance()->ProcessDetach(id);
+ }
+
protected:
void SetUp();
void TearDown();
@@ -371,16 +402,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_;
+ FakeRemovableStorageNotifications notifications_;
vandebo (ex-Chrome) 2013/01/18 18:42:58 Not used
Greg Billock 2013/01/22 20:00:39 see above On 2013/01/18 18:42:58, vandebo wrote:
+
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 +609,8 @@ int ProfileState::GetAndClearComparisonCount() {
return result;
}
+} // namespace
+
/////////////////////////////////
// MediaFileSystemRegistryTest //
/////////////////////////////////
@@ -619,8 +653,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 +665,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 +764,7 @@ 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);
-
+ // Need to create BrowserMainParts here? Or does one of these harnesses do it?
vandebo (ex-Chrome) 2013/01/18 18:42:58 I don't think a BrowserMainParts is created... not
Greg Billock 2013/01/22 20:00:39 Yeah, I looked into that, and got nowhere. Used th
ChromeRenderViewHostTestHarness::SetUp();
DeleteContents();
SetRenderProcessHostFactory(&rph_factory_);
@@ -887,6 +915,4 @@ TEST_F(MediaFileSystemRegistryTest, GalleryNameUserAddedPath) {
false /*removable*/, false /* media device */);
}
-} // namespace
-
} // namespace chrome

Powered by Google App Engine
This is Rietveld 408576698