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

Side by Side Diff: chrome/browser/chromeos/disks/mock_disk_mount_manager.cc

Issue 10829160: Created a helper function "FindDiskBySourcePath" in DiskMountManager. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix nit Created 8 years, 4 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
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()) 54 ON_CALL(*this, mount_points())
55 .WillByDefault(Invoke(this, &MockDiskMountManager::mountPointsInternal)); 55 .WillByDefault(Invoke(this, &MockDiskMountManager::mountPointsInternal));
56 ON_CALL(*this, FindDiskBySourcePath(_))
57 .WillByDefault(Invoke(
58 this, &MockDiskMountManager::FindDiskBySourcePathInternal));
56 } 59 }
57 60
58 MockDiskMountManager::~MockDiskMountManager() { 61 MockDiskMountManager::~MockDiskMountManager() {
59 STLDeleteContainerPairSecondPointers(disks_.begin(), disks_.end()); 62 STLDeleteContainerPairSecondPointers(disks_.begin(), disks_.end());
60 disks_.clear(); 63 disks_.clear();
61 } 64 }
62 65
63 void MockDiskMountManager::NotifyDeviceInsertEvents() { 66 void MockDiskMountManager::NotifyDeviceInsertEvents() {
64 scoped_ptr<DiskMountManager::Disk> disk1(new DiskMountManager::Disk( 67 scoped_ptr<DiskMountManager::Disk> disk1(new DiskMountManager::Disk(
65 std::string(kTestDevicePath), 68 std::string(kTestDevicePath),
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 143
141 void MockDiskMountManager::SetupDefaultReplies() { 144 void MockDiskMountManager::SetupDefaultReplies() {
142 EXPECT_CALL(*this, AddObserver(_)) 145 EXPECT_CALL(*this, AddObserver(_))
143 .Times(AnyNumber()); 146 .Times(AnyNumber());
144 EXPECT_CALL(*this, RemoveObserver(_)) 147 EXPECT_CALL(*this, RemoveObserver(_))
145 .Times(AnyNumber()); 148 .Times(AnyNumber());
146 EXPECT_CALL(*this, disks()) 149 EXPECT_CALL(*this, disks())
147 .WillRepeatedly(ReturnRef(disks_)); 150 .WillRepeatedly(ReturnRef(disks_));
148 EXPECT_CALL(*this, mount_points()) 151 EXPECT_CALL(*this, mount_points())
149 .WillRepeatedly(ReturnRef(mount_points_)); 152 .WillRepeatedly(ReturnRef(mount_points_));
153 EXPECT_CALL(*this, FindDiskBySourcePath(_))
154 .Times(AnyNumber());
150 EXPECT_CALL(*this, RequestMountInfoRefresh()) 155 EXPECT_CALL(*this, RequestMountInfoRefresh())
151 .Times(AnyNumber()); 156 .Times(AnyNumber());
152 EXPECT_CALL(*this, MountPath(_, _, _, _)) 157 EXPECT_CALL(*this, MountPath(_, _, _, _))
153 .Times(AnyNumber()); 158 .Times(AnyNumber());
154 EXPECT_CALL(*this, UnmountPath(_)) 159 EXPECT_CALL(*this, UnmountPath(_))
155 .Times(AnyNumber()); 160 .Times(AnyNumber());
156 EXPECT_CALL(*this, FormatUnmountedDevice(_)) 161 EXPECT_CALL(*this, FormatUnmountedDevice(_))
157 .Times(AnyNumber()); 162 .Times(AnyNumber());
158 EXPECT_CALL(*this, FormatMountedDevice(_)) 163 EXPECT_CALL(*this, FormatMountedDevice(_))
159 .Times(AnyNumber()); 164 .Times(AnyNumber());
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 delete it->second; 200 delete it->second;
196 disks_.erase(it); 201 disks_.erase(it);
197 } 202 }
198 } 203 }
199 204
200 const DiskMountManager::MountPointMap& 205 const DiskMountManager::MountPointMap&
201 MockDiskMountManager::mountPointsInternal() const { 206 MockDiskMountManager::mountPointsInternal() const {
202 return mount_points_; 207 return mount_points_;
203 } 208 }
204 209
210 const DiskMountManager::Disk*
211 MockDiskMountManager::FindDiskBySourcePathInternal(
212 const std::string& source_path) const {
213 DiskMap::const_iterator disk_it = disks_.find(source_path);
214 return disk_it == disks_.end() ? NULL : disk_it->second;
215 }
216
205 void MockDiskMountManager::NotifyDiskChanged( 217 void MockDiskMountManager::NotifyDiskChanged(
206 DiskMountManagerEventType event, 218 DiskMountManagerEventType event,
207 const DiskMountManager::Disk* disk) { 219 const DiskMountManager::Disk* disk) {
208 // Make sure we run on UI thread. 220 // Make sure we run on UI thread.
209 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 221 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
210 222
211 FOR_EACH_OBSERVER(Observer, observers_, DiskChanged(event, disk)); 223 FOR_EACH_OBSERVER(Observer, observers_, DiskChanged(event, disk));
212 } 224 }
213 225
214 void MockDiskMountManager::NotifyDeviceChanged(DiskMountManagerEventType event, 226 void MockDiskMountManager::NotifyDeviceChanged(DiskMountManagerEventType event,
215 const std::string& path) { 227 const std::string& path) {
216 // Make sure we run on UI thread. 228 // Make sure we run on UI thread.
217 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 229 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
218 230
219 FOR_EACH_OBSERVER(Observer, observers_, DeviceChanged(event, path)); 231 FOR_EACH_OBSERVER(Observer, observers_, DeviceChanged(event, path));
220 } 232 }
221 233
222 } // namespace disks 234 } // namespace disks
223 } // namespace chromeos 235 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698