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

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

Issue 11365142: Small refactoring in DiskMountManager (event reporting; format method). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: few lint nits Created 8 years, 1 month 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
« no previous file with comments | « chromeos/disks/mock_disk_mount_manager.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "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.h" 9 #include "base/message_loop.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 false, // is_read_only 85 false, // is_read_only
86 true, // has_media 86 true, // has_media
87 false, // on_boot_device 87 false, // on_boot_device
88 false)); // is_hidden 88 false)); // is_hidden
89 89
90 disks_.clear(); 90 disks_.clear();
91 disks_.insert(std::pair<std::string, DiskMountManager::Disk*>( 91 disks_.insert(std::pair<std::string, DiskMountManager::Disk*>(
92 std::string(kTestDevicePath), disk1.get())); 92 std::string(kTestDevicePath), disk1.get()));
93 93
94 // Device Added 94 // Device Added
95 DiskMountManagerEventType event; 95 NotifyDeviceChanged(DEVICE_ADDED, kTestSystemPath);
96 event = MOUNT_DEVICE_ADDED;
97 NotifyDeviceChanged(event, kTestSystemPath);
98 96
99 // Disk Added 97 // Disk Added
100 event = MOUNT_DISK_ADDED; 98 NotifyDiskChanged(DISK_ADDED, disk1.get());
101 NotifyDiskChanged(event, disk1.get());
102 99
103 // Disk Changed 100 // Disk Changed
104 scoped_ptr<DiskMountManager::Disk> disk2(new DiskMountManager::Disk( 101 scoped_ptr<DiskMountManager::Disk> disk2(new DiskMountManager::Disk(
105 std::string(kTestDevicePath), 102 std::string(kTestDevicePath),
106 std::string(kTestMountPath), 103 std::string(kTestMountPath),
107 std::string(kTestSystemPath), 104 std::string(kTestSystemPath),
108 std::string(kTestFilePath), 105 std::string(kTestFilePath),
109 std::string(kTestDeviceLabel), 106 std::string(kTestDeviceLabel),
110 std::string(kTestDriveLabel), 107 std::string(kTestDriveLabel),
111 std::string(kTestVendorId), 108 std::string(kTestVendorId),
112 std::string(kTestVendorName), 109 std::string(kTestVendorName),
113 std::string(kTestProductId), 110 std::string(kTestProductId),
114 std::string(kTestProductName), 111 std::string(kTestProductName),
115 std::string(kTestUuid), 112 std::string(kTestUuid),
116 std::string(kTestSystemPathPrefix), 113 std::string(kTestSystemPathPrefix),
117 DEVICE_TYPE_MOBILE, 114 DEVICE_TYPE_MOBILE,
118 1073741824, 115 1073741824,
119 false, // is_parent 116 false, // is_parent
120 false, // is_read_only 117 false, // is_read_only
121 true, // has_media 118 true, // has_media
122 false, // on_boot_device 119 false, // on_boot_device
123 false)); // is_hidden 120 false)); // is_hidden
124 disks_.clear(); 121 disks_.clear();
125 disks_.insert(std::pair<std::string, DiskMountManager::Disk*>( 122 disks_.insert(std::pair<std::string, DiskMountManager::Disk*>(
126 std::string(kTestDevicePath), disk2.get())); 123 std::string(kTestDevicePath), disk2.get()));
127 event = MOUNT_DISK_CHANGED; 124 NotifyDiskChanged(DISK_CHANGED, disk2.get());
128 NotifyDiskChanged(event, disk2.get());
129 } 125 }
130 126
131 void MockDiskMountManager::NotifyDeviceRemoveEvents() { 127 void MockDiskMountManager::NotifyDeviceRemoveEvents() {
132 scoped_ptr<DiskMountManager::Disk> disk(new DiskMountManager::Disk( 128 scoped_ptr<DiskMountManager::Disk> disk(new DiskMountManager::Disk(
133 std::string(kTestDevicePath), 129 std::string(kTestDevicePath),
134 std::string(kTestMountPath), 130 std::string(kTestMountPath),
135 std::string(kTestSystemPath), 131 std::string(kTestSystemPath),
136 std::string(kTestFilePath), 132 std::string(kTestFilePath),
137 std::string(kTestDeviceLabel), 133 std::string(kTestDeviceLabel),
138 std::string(kTestDriveLabel), 134 std::string(kTestDriveLabel),
139 std::string(kTestVendorId), 135 std::string(kTestVendorId),
140 std::string(kTestVendorName), 136 std::string(kTestVendorName),
141 std::string(kTestProductId), 137 std::string(kTestProductId),
142 std::string(kTestProductName), 138 std::string(kTestProductName),
143 std::string(kTestUuid), 139 std::string(kTestUuid),
144 std::string(kTestSystemPathPrefix), 140 std::string(kTestSystemPathPrefix),
145 DEVICE_TYPE_SD, 141 DEVICE_TYPE_SD,
146 1073741824, 142 1073741824,
147 false, // is_parent 143 false, // is_parent
148 false, // is_read_only 144 false, // is_read_only
149 true, // has_media 145 true, // has_media
150 false, // on_boot_device 146 false, // on_boot_device
151 false)); // is_hidden 147 false)); // is_hidden
152 disks_.clear(); 148 disks_.clear();
153 disks_.insert(std::pair<std::string, DiskMountManager::Disk*>( 149 disks_.insert(std::pair<std::string, DiskMountManager::Disk*>(
154 std::string(kTestDevicePath), disk.get())); 150 std::string(kTestDevicePath), disk.get()));
155 NotifyDiskChanged(MOUNT_DISK_REMOVED, disk.get()); 151 NotifyDiskChanged(DISK_REMOVED, disk.get());
156 } 152 }
157 153
158 void MockDiskMountManager::SetupDefaultReplies() { 154 void MockDiskMountManager::SetupDefaultReplies() {
159 EXPECT_CALL(*this, AddObserver(_)) 155 EXPECT_CALL(*this, AddObserver(_))
160 .Times(AnyNumber()); 156 .Times(AnyNumber());
161 EXPECT_CALL(*this, RemoveObserver(_)) 157 EXPECT_CALL(*this, RemoveObserver(_))
162 .Times(AnyNumber()); 158 .Times(AnyNumber());
163 EXPECT_CALL(*this, disks()) 159 EXPECT_CALL(*this, disks())
164 .WillRepeatedly(ReturnRef(disks_)); 160 .WillRepeatedly(ReturnRef(disks_));
165 EXPECT_CALL(*this, mount_points()) 161 EXPECT_CALL(*this, mount_points())
166 .WillRepeatedly(ReturnRef(mount_points_)); 162 .WillRepeatedly(ReturnRef(mount_points_));
167 EXPECT_CALL(*this, FindDiskBySourcePath(_)) 163 EXPECT_CALL(*this, FindDiskBySourcePath(_))
168 .Times(AnyNumber()); 164 .Times(AnyNumber());
169 EXPECT_CALL(*this, RequestMountInfoRefresh()) 165 EXPECT_CALL(*this, RequestMountInfoRefresh())
170 .Times(AnyNumber()); 166 .Times(AnyNumber());
171 EXPECT_CALL(*this, MountPath(_, _, _, _)) 167 EXPECT_CALL(*this, MountPath(_, _, _, _))
172 .Times(AnyNumber()); 168 .Times(AnyNumber());
173 EXPECT_CALL(*this, UnmountPath(_, _)) 169 EXPECT_CALL(*this, UnmountPath(_, _))
174 .Times(AnyNumber()); 170 .Times(AnyNumber());
175 EXPECT_CALL(*this, FormatUnmountedDevice(_))
176 .Times(AnyNumber());
177 EXPECT_CALL(*this, FormatMountedDevice(_)) 171 EXPECT_CALL(*this, FormatMountedDevice(_))
178 .Times(AnyNumber()); 172 .Times(AnyNumber());
179 EXPECT_CALL(*this, UnmountDeviceRecursive(_, _, _)) 173 EXPECT_CALL(*this, UnmountDeviceRecursive(_, _, _))
180 .Times(AnyNumber()); 174 .Times(AnyNumber());
181 } 175 }
182 176
183 void MockDiskMountManager::CreateDiskEntryForMountDevice( 177 void MockDiskMountManager::CreateDiskEntryForMountDevice(
184 const DiskMountManager::MountPointInfo& mount_info, 178 const DiskMountManager::MountPointInfo& mount_info,
185 const std::string& device_id, 179 const std::string& device_id,
186 const std::string& device_label) { 180 const std::string& device_label) {
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 } 221 }
228 222
229 const DiskMountManager::Disk* 223 const DiskMountManager::Disk*
230 MockDiskMountManager::FindDiskBySourcePathInternal( 224 MockDiskMountManager::FindDiskBySourcePathInternal(
231 const std::string& source_path) const { 225 const std::string& source_path) const {
232 DiskMap::const_iterator disk_it = disks_.find(source_path); 226 DiskMap::const_iterator disk_it = disks_.find(source_path);
233 return disk_it == disks_.end() ? NULL : disk_it->second; 227 return disk_it == disks_.end() ? NULL : disk_it->second;
234 } 228 }
235 229
236 void MockDiskMountManager::NotifyDiskChanged( 230 void MockDiskMountManager::NotifyDiskChanged(
237 DiskMountManagerEventType event, 231 DiskEvent event,
238 const DiskMountManager::Disk* disk) { 232 const DiskMountManager::Disk* disk) {
239 FOR_EACH_OBSERVER(Observer, observers_, DiskChanged(event, disk)); 233 FOR_EACH_OBSERVER(Observer, observers_, OnDiskEvent(event, disk));
240 } 234 }
241 235
242 void MockDiskMountManager::NotifyDeviceChanged(DiskMountManagerEventType event, 236 void MockDiskMountManager::NotifyDeviceChanged(DeviceEvent event,
243 const std::string& path) { 237 const std::string& path) {
244 FOR_EACH_OBSERVER(Observer, observers_, DeviceChanged(event, path)); 238 FOR_EACH_OBSERVER(Observer, observers_, OnDeviceEvent(event, path));
245 } 239 }
246 240
247 } // namespace disks 241 } // namespace disks
248 } // namespace chromeos 242 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/disks/mock_disk_mount_manager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698