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

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

Issue 14556015: [Media Galleries] Lazily initialize the storage monitor. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Rebase on prefs Created 7 years, 7 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_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..f409fa3b5e947d9167d76ff14eea096ffaefac76 100644
--- a/chrome/browser/media_galleries/media_file_system_registry_unittest.cc
+++ b/chrome/browser/media_galleries/media_file_system_registry_unittest.cc
@@ -7,6 +7,7 @@
#include <algorithm>
#include <set>
+#include "base/bind_helpers.h"
#include "base/command_line.h"
#include "base/file_util.h"
#include "base/files/scoped_temp_dir.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/23 15:04:17 Am I being dense? How is this different than just
Greg Billock 2013/05/30 22:17:47 The test isn't a subclass -- it's just a convenien
+}
+
std::string MediaFileSystemRegistryTest::AddUserGallery(
StorageInfo::Type type,
const std::string& unique_id,
@@ -720,7 +728,12 @@ MediaFileSystemRegistryTest::GetAutoAddedGalleries(
}
void MediaFileSystemRegistryTest::SetUp() {
-#if defined(OS_WIN)
+#if !defined(OS_WIN)
+ monitor_.reset(new test::TestStorageMonitor());
vandebo (ex-Chrome) 2013/05/23 15:04:17 Put this in the #else clause. Can use TestStoageM
Greg Billock 2013/05/30 22:17:47 The Win mock is for the MTP thing, which really sh
+ monitor_->Initialize(base::Bind(&base::DoNothing));
+ monitor_->MarkInitialized();
+ base::RunLoop().RunUntilIdle();
+#else
test::TestPortableDeviceWatcherWin* portable_device_watcher =
new test::TestPortableDeviceWatcherWin;
test::TestVolumeMountWatcherWin* mount_watcher =
@@ -728,7 +741,7 @@ 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();
+ monitor_->Initialize(base::Bind(&base::DoNothing));
// TODO(gbillock): Replace this with the correct event notification
// on the storage monitor finishing the startup scan when that exists.
base::RunLoop().RunUntilIdle();
@@ -850,8 +863,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 +878,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 +896,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;

Powered by Google App Engine
This is Rietveld 408576698