diff options
author | reillyg <reillyg@chromium.org> | 2015-06-19 14:06:34 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-06-19 21:08:17 +0000 |
commit | a4407051b3f269d24d8d190e9b65eb403a7e8263 (patch) | |
tree | 00d011d9d11f2c4d8b7b15d04bca924c51edae6b /components/storage_monitor | |
parent | 6573dce68029e89f87113d9d66ab9a0207015fe7 (diff) | |
download | chromium_src-a4407051b3f269d24d8d190e9b65eb403a7e8263.zip chromium_src-a4407051b3f269d24d8d190e9b65eb403a7e8263.tar.gz chromium_src-a4407051b3f269d24d8d190e9b65eb403a7e8263.tar.bz2 |
Add a test to exercise GalleryWatchManager::OnRemoveableStorageDetached.
This path was previously unexercised and is implicated in issue 467627.
Another test based on this one will soon be added that tests what
happens when a storage removal event occurs after profile shutdown.
BUG=467627
Review URL: https://codereview.chromium.org/1197883002
Cr-Commit-Position: refs/heads/master@{#335345}
Diffstat (limited to 'components/storage_monitor')
-rw-r--r-- | components/storage_monitor/test_storage_monitor.cc | 17 | ||||
-rw-r--r-- | components/storage_monitor/test_storage_monitor.h | 5 |
2 files changed, 21 insertions, 1 deletions
diff --git a/components/storage_monitor/test_storage_monitor.cc b/components/storage_monitor/test_storage_monitor.cc index fb5cc57..95a8198 100644 --- a/components/storage_monitor/test_storage_monitor.cc +++ b/components/storage_monitor/test_storage_monitor.cc @@ -84,8 +84,18 @@ bool TestStorageMonitor::GetStorageInfoForPath( if (!path.IsAbsolute()) return false; + bool is_removable = false; + for (const base::FilePath& removable : removable_paths_) { + if (path == removable || removable.IsParent(path)) { + is_removable = true; + break; + } + } + std::string device_id = StorageInfo::MakeDeviceId( - StorageInfo::FIXED_MASS_STORAGE, path.AsUTF8Unsafe()); + is_removable ? StorageInfo::REMOVABLE_MASS_STORAGE_NO_DCIM + : StorageInfo::FIXED_MASS_STORAGE, + path.AsUTF8Unsafe()); *device_info = StorageInfo(device_id, path.value(), base::string16(), base::string16(), base::string16(), 0); @@ -119,4 +129,9 @@ void TestStorageMonitor::EjectDevice( callback.Run(EJECT_OK); } +void TestStorageMonitor::AddRemovablePath(const base::FilePath& path) { + CHECK(path.IsAbsolute()); + removable_paths_.push_back(path); +} + } // namespace storage_monitor diff --git a/components/storage_monitor/test_storage_monitor.h b/components/storage_monitor/test_storage_monitor.h index 7726e57..da3809b 100644 --- a/components/storage_monitor/test_storage_monitor.h +++ b/components/storage_monitor/test_storage_monitor.h @@ -57,6 +57,8 @@ class TestStorageMonitor : public StorageMonitor { const std::string& ejected_device() const { return ejected_device_; } + void AddRemovablePath(const base::FilePath& path); + bool init_called() const { return init_called_; } private: @@ -66,6 +68,9 @@ class TestStorageMonitor : public StorageMonitor { // The last device to be ejected. std::string ejected_device_; + // Paths considered for testing purposes to be on removable storage. + std::vector<base::FilePath> removable_paths_; + #if defined(OS_LINUX) scoped_ptr<device::MediaTransferProtocolManager> media_transfer_protocol_manager_; |