| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chromeos/disks/mock_disk_mount_manager.h" | 5 #include "chromeos/disks/mock_disk_mount_manager.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 ON_CALL(*this, RemoveObserver(_)) | 51 ON_CALL(*this, RemoveObserver(_)) |
| 52 .WillByDefault(Invoke(this, | 52 .WillByDefault(Invoke(this, |
| 53 &MockDiskMountManager::RemoveObserverInternal)); | 53 &MockDiskMountManager::RemoveObserverInternal)); |
| 54 ON_CALL(*this, disks()) | 54 ON_CALL(*this, disks()) |
| 55 .WillByDefault(Invoke(this, &MockDiskMountManager::disksInternal)); | 55 .WillByDefault(Invoke(this, &MockDiskMountManager::disksInternal)); |
| 56 ON_CALL(*this, mount_points()) | 56 ON_CALL(*this, mount_points()) |
| 57 .WillByDefault(Invoke(this, &MockDiskMountManager::mountPointsInternal)); | 57 .WillByDefault(Invoke(this, &MockDiskMountManager::mountPointsInternal)); |
| 58 ON_CALL(*this, FindDiskBySourcePath(_)) | 58 ON_CALL(*this, FindDiskBySourcePath(_)) |
| 59 .WillByDefault(Invoke( | 59 .WillByDefault(Invoke( |
| 60 this, &MockDiskMountManager::FindDiskBySourcePathInternal)); | 60 this, &MockDiskMountManager::FindDiskBySourcePathInternal)); |
| 61 ON_CALL(*this, EnsureMountInfoRefreshed(_)) |
| 62 .WillByDefault(Invoke( |
| 63 this, &MockDiskMountManager::EnsureMountInfoRefreshedInternal)); |
| 61 } | 64 } |
| 62 | 65 |
| 63 MockDiskMountManager::~MockDiskMountManager() { | 66 MockDiskMountManager::~MockDiskMountManager() { |
| 64 STLDeleteContainerPairSecondPointers(disks_.begin(), disks_.end()); | 67 STLDeleteContainerPairSecondPointers(disks_.begin(), disks_.end()); |
| 65 disks_.clear(); | 68 disks_.clear(); |
| 66 } | 69 } |
| 67 | 70 |
| 68 void MockDiskMountManager::NotifyDeviceInsertEvents() { | 71 void MockDiskMountManager::NotifyDeviceInsertEvents() { |
| 69 scoped_ptr<DiskMountManager::Disk> disk1(new DiskMountManager::Disk( | 72 scoped_ptr<DiskMountManager::Disk> disk1(new DiskMountManager::Disk( |
| 70 std::string(kTestDevicePath), | 73 std::string(kTestDevicePath), |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 EXPECT_CALL(*this, AddObserver(_)) | 158 EXPECT_CALL(*this, AddObserver(_)) |
| 156 .Times(AnyNumber()); | 159 .Times(AnyNumber()); |
| 157 EXPECT_CALL(*this, RemoveObserver(_)) | 160 EXPECT_CALL(*this, RemoveObserver(_)) |
| 158 .Times(AnyNumber()); | 161 .Times(AnyNumber()); |
| 159 EXPECT_CALL(*this, disks()) | 162 EXPECT_CALL(*this, disks()) |
| 160 .WillRepeatedly(ReturnRef(disks_)); | 163 .WillRepeatedly(ReturnRef(disks_)); |
| 161 EXPECT_CALL(*this, mount_points()) | 164 EXPECT_CALL(*this, mount_points()) |
| 162 .WillRepeatedly(ReturnRef(mount_points_)); | 165 .WillRepeatedly(ReturnRef(mount_points_)); |
| 163 EXPECT_CALL(*this, FindDiskBySourcePath(_)) | 166 EXPECT_CALL(*this, FindDiskBySourcePath(_)) |
| 164 .Times(AnyNumber()); | 167 .Times(AnyNumber()); |
| 165 EXPECT_CALL(*this, RequestMountInfoRefresh()) | 168 EXPECT_CALL(*this, EnsureMountInfoRefreshed(_)) |
| 166 .Times(AnyNumber()); | 169 .Times(AnyNumber()); |
| 167 EXPECT_CALL(*this, MountPath(_, _, _, _)) | 170 EXPECT_CALL(*this, MountPath(_, _, _, _)) |
| 168 .Times(AnyNumber()); | 171 .Times(AnyNumber()); |
| 169 EXPECT_CALL(*this, UnmountPath(_, _, _)) | 172 EXPECT_CALL(*this, UnmountPath(_, _, _)) |
| 170 .Times(AnyNumber()); | 173 .Times(AnyNumber()); |
| 171 EXPECT_CALL(*this, FormatMountedDevice(_)) | 174 EXPECT_CALL(*this, FormatMountedDevice(_)) |
| 172 .Times(AnyNumber()); | 175 .Times(AnyNumber()); |
| 173 EXPECT_CALL(*this, UnmountDeviceRecursively(_, _)) | 176 EXPECT_CALL(*this, UnmountDeviceRecursively(_, _)) |
| 174 .Times(AnyNumber()); | 177 .Times(AnyNumber()); |
| 175 } | 178 } |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 return mount_points_; | 230 return mount_points_; |
| 228 } | 231 } |
| 229 | 232 |
| 230 const DiskMountManager::Disk* | 233 const DiskMountManager::Disk* |
| 231 MockDiskMountManager::FindDiskBySourcePathInternal( | 234 MockDiskMountManager::FindDiskBySourcePathInternal( |
| 232 const std::string& source_path) const { | 235 const std::string& source_path) const { |
| 233 DiskMap::const_iterator disk_it = disks_.find(source_path); | 236 DiskMap::const_iterator disk_it = disks_.find(source_path); |
| 234 return disk_it == disks_.end() ? NULL : disk_it->second; | 237 return disk_it == disks_.end() ? NULL : disk_it->second; |
| 235 } | 238 } |
| 236 | 239 |
| 240 void MockDiskMountManager::EnsureMountInfoRefreshedInternal( |
| 241 const EnsureMountInfoRefreshedCallback& callback) { |
| 242 callback.Run(true); |
| 243 } |
| 244 |
| 237 void MockDiskMountManager::NotifyDiskChanged( | 245 void MockDiskMountManager::NotifyDiskChanged( |
| 238 DiskEvent event, | 246 DiskEvent event, |
| 239 const DiskMountManager::Disk* disk) { | 247 const DiskMountManager::Disk* disk) { |
| 240 FOR_EACH_OBSERVER(Observer, observers_, OnDiskEvent(event, disk)); | 248 FOR_EACH_OBSERVER(Observer, observers_, OnDiskEvent(event, disk)); |
| 241 } | 249 } |
| 242 | 250 |
| 243 void MockDiskMountManager::NotifyDeviceChanged(DeviceEvent event, | 251 void MockDiskMountManager::NotifyDeviceChanged(DeviceEvent event, |
| 244 const std::string& path) { | 252 const std::string& path) { |
| 245 FOR_EACH_OBSERVER(Observer, observers_, OnDeviceEvent(event, path)); | 253 FOR_EACH_OBSERVER(Observer, observers_, OnDeviceEvent(event, path)); |
| 246 } | 254 } |
| 247 | 255 |
| 248 } // namespace disks | 256 } // namespace disks |
| 249 } // namespace chromeos | 257 } // namespace chromeos |
| OLD | NEW |