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 "chrome/browser/chromeos/disks/mock_disk_mount_manager.h" | 5 #include "chrome/browser/chromeos/disks/mock_disk_mount_manager.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 } | 44 } |
45 | 45 |
46 MockDiskMountManager::MockDiskMountManager() { | 46 MockDiskMountManager::MockDiskMountManager() { |
47 ON_CALL(*this, AddObserver(_)) | 47 ON_CALL(*this, AddObserver(_)) |
48 .WillByDefault(Invoke(this, &MockDiskMountManager::AddObserverInternal)); | 48 .WillByDefault(Invoke(this, &MockDiskMountManager::AddObserverInternal)); |
49 ON_CALL(*this, RemoveObserver(_)) | 49 ON_CALL(*this, RemoveObserver(_)) |
50 .WillByDefault(Invoke(this, | 50 .WillByDefault(Invoke(this, |
51 &MockDiskMountManager::RemoveObserverInternal)); | 51 &MockDiskMountManager::RemoveObserverInternal)); |
52 ON_CALL(*this, disks()) | 52 ON_CALL(*this, disks()) |
53 .WillByDefault(Invoke(this, &MockDiskMountManager::disksInternal)); | 53 .WillByDefault(Invoke(this, &MockDiskMountManager::disksInternal)); |
| 54 ON_CALL(*this, mount_points()) |
| 55 .WillByDefault(Invoke(this, &MockDiskMountManager::mountPointsInternal)); |
54 } | 56 } |
55 | 57 |
56 MockDiskMountManager::~MockDiskMountManager() { | 58 MockDiskMountManager::~MockDiskMountManager() { |
57 STLDeleteContainerPairSecondPointers(disks_.begin(), disks_.end()); | 59 STLDeleteContainerPairSecondPointers(disks_.begin(), disks_.end()); |
58 disks_.clear(); | 60 disks_.clear(); |
59 } | 61 } |
60 | 62 |
61 void MockDiskMountManager::NotifyDeviceInsertEvents() { | 63 void MockDiskMountManager::NotifyDeviceInsertEvents() { |
62 scoped_ptr<DiskMountManager::Disk> disk1(new DiskMountManager::Disk( | 64 scoped_ptr<DiskMountManager::Disk> disk1(new DiskMountManager::Disk( |
63 std::string(kTestDevicePath), | 65 std::string(kTestDevicePath), |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 NotifyDiskChanged(MOUNT_DISK_REMOVED, disk.get()); | 138 NotifyDiskChanged(MOUNT_DISK_REMOVED, disk.get()); |
137 } | 139 } |
138 | 140 |
139 void MockDiskMountManager::SetupDefaultReplies() { | 141 void MockDiskMountManager::SetupDefaultReplies() { |
140 EXPECT_CALL(*this, AddObserver(_)) | 142 EXPECT_CALL(*this, AddObserver(_)) |
141 .Times(AnyNumber()); | 143 .Times(AnyNumber()); |
142 EXPECT_CALL(*this, RemoveObserver(_)) | 144 EXPECT_CALL(*this, RemoveObserver(_)) |
143 .Times(AnyNumber()); | 145 .Times(AnyNumber()); |
144 EXPECT_CALL(*this, disks()) | 146 EXPECT_CALL(*this, disks()) |
145 .WillRepeatedly(ReturnRef(disks_)); | 147 .WillRepeatedly(ReturnRef(disks_)); |
| 148 EXPECT_CALL(*this, mount_points()) |
| 149 .WillRepeatedly(ReturnRef(mount_points_)); |
146 EXPECT_CALL(*this, RequestMountInfoRefresh()) | 150 EXPECT_CALL(*this, RequestMountInfoRefresh()) |
147 .Times(AnyNumber()); | 151 .Times(AnyNumber()); |
148 EXPECT_CALL(*this, MountPath(_, _, _, _)) | 152 EXPECT_CALL(*this, MountPath(_, _, _, _)) |
149 .Times(AnyNumber()); | 153 .Times(AnyNumber()); |
150 EXPECT_CALL(*this, UnmountPath(_)) | 154 EXPECT_CALL(*this, UnmountPath(_)) |
151 .Times(AnyNumber()); | 155 .Times(AnyNumber()); |
152 EXPECT_CALL(*this, FormatUnmountedDevice(_)) | 156 EXPECT_CALL(*this, FormatUnmountedDevice(_)) |
153 .Times(AnyNumber()); | 157 .Times(AnyNumber()); |
154 EXPECT_CALL(*this, FormatMountedDevice(_)) | 158 EXPECT_CALL(*this, FormatMountedDevice(_)) |
155 .Times(AnyNumber()); | 159 .Times(AnyNumber()); |
(...skipping 30 matching lines...) Expand all Loading... |
186 | 190 |
187 void MockDiskMountManager::RemoveDiskEntryForMountDevice( | 191 void MockDiskMountManager::RemoveDiskEntryForMountDevice( |
188 const DiskMountManager::MountPointInfo& mount_info) { | 192 const DiskMountManager::MountPointInfo& mount_info) { |
189 DiskMountManager::DiskMap::iterator it = disks_.find(mount_info.source_path); | 193 DiskMountManager::DiskMap::iterator it = disks_.find(mount_info.source_path); |
190 if (it != disks_.end()) { | 194 if (it != disks_.end()) { |
191 delete it->second; | 195 delete it->second; |
192 disks_.erase(it); | 196 disks_.erase(it); |
193 } | 197 } |
194 } | 198 } |
195 | 199 |
| 200 const DiskMountManager::MountPointMap& |
| 201 MockDiskMountManager::mountPointsInternal() const { |
| 202 return mount_points_; |
| 203 } |
| 204 |
196 void MockDiskMountManager::NotifyDiskChanged( | 205 void MockDiskMountManager::NotifyDiskChanged( |
197 DiskMountManagerEventType event, | 206 DiskMountManagerEventType event, |
198 const DiskMountManager::Disk* disk) { | 207 const DiskMountManager::Disk* disk) { |
199 // Make sure we run on UI thread. | 208 // Make sure we run on UI thread. |
200 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 209 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
201 | 210 |
202 FOR_EACH_OBSERVER(Observer, observers_, DiskChanged(event, disk)); | 211 FOR_EACH_OBSERVER(Observer, observers_, DiskChanged(event, disk)); |
203 } | 212 } |
204 | 213 |
205 void MockDiskMountManager::NotifyDeviceChanged(DiskMountManagerEventType event, | 214 void MockDiskMountManager::NotifyDeviceChanged(DiskMountManagerEventType event, |
206 const std::string& path) { | 215 const std::string& path) { |
207 // Make sure we run on UI thread. | 216 // Make sure we run on UI thread. |
208 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 217 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
209 | 218 |
210 FOR_EACH_OBSERVER(Observer, observers_, DeviceChanged(event, path)); | 219 FOR_EACH_OBSERVER(Observer, observers_, DeviceChanged(event, path)); |
211 } | 220 } |
212 | 221 |
213 } // namespace disks | 222 } // namespace disks |
214 } // namespace chromeos | 223 } // namespace chromeos |
OLD | NEW |