| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/cros/mock_mount_library.h" | 5 #include "chrome/browser/chromeos/cros/mock_mount_library.h" |
| 6 | 6 |
| 7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
| 8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
| 9 #include "chrome/browser/chromeos/cros/cros_library.h" | 9 #include "chrome/browser/chromeos/cros/cros_library.h" |
| 10 #include "content/browser/browser_thread.h" | 10 #include "content/browser/browser_thread.h" |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 std::string(kTestFilePath), | 56 std::string(kTestFilePath), |
| 57 std::string(), | 57 std::string(), |
| 58 std::string(kTestDriveLabel), | 58 std::string(kTestDriveLabel), |
| 59 std::string(kTestParentPath), | 59 std::string(kTestParentPath), |
| 60 std::string(kTestSystemPathPrefix), | 60 std::string(kTestSystemPathPrefix), |
| 61 FLASH, | 61 FLASH, |
| 62 4294967295U, | 62 4294967295U, |
| 63 false, | 63 false, |
| 64 false, | 64 false, |
| 65 true, | 65 true, |
| 66 false, |
| 66 false)); | 67 false)); |
| 67 | 68 |
| 68 disks_.clear(); | 69 disks_.clear(); |
| 69 disks_.insert(std::pair<std::string, MountLibrary::Disk*>( | 70 disks_.insert(std::pair<std::string, MountLibrary::Disk*>( |
| 70 std::string(kTestDevicePath), disk1.get())); | 71 std::string(kTestDevicePath), disk1.get())); |
| 71 | 72 |
| 72 // Device Added | 73 // Device Added |
| 73 chromeos::MountLibraryEventType evt; | 74 chromeos::MountLibraryEventType evt; |
| 74 evt = chromeos::MOUNT_DEVICE_ADDED; | 75 evt = chromeos::MOUNT_DEVICE_ADDED; |
| 75 UpdateDeviceChanged(evt, kTestSystemPath); | 76 UpdateDeviceChanged(evt, kTestSystemPath); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 86 std::string(kTestFilePath), | 87 std::string(kTestFilePath), |
| 87 std::string(kTestDeviceLabel), | 88 std::string(kTestDeviceLabel), |
| 88 std::string(kTestDriveLabel), | 89 std::string(kTestDriveLabel), |
| 89 std::string(kTestParentPath), | 90 std::string(kTestParentPath), |
| 90 std::string(kTestSystemPathPrefix), | 91 std::string(kTestSystemPathPrefix), |
| 91 FLASH, | 92 FLASH, |
| 92 1073741824, | 93 1073741824, |
| 93 false, | 94 false, |
| 94 false, | 95 false, |
| 95 true, | 96 true, |
| 97 false, |
| 96 false)); | 98 false)); |
| 97 disks_.clear(); | 99 disks_.clear(); |
| 98 disks_.insert(std::pair<std::string, MountLibrary::Disk*>( | 100 disks_.insert(std::pair<std::string, MountLibrary::Disk*>( |
| 99 std::string(kTestDevicePath), disk2.get())); | 101 std::string(kTestDevicePath), disk2.get())); |
| 100 evt = chromeos::MOUNT_DISK_CHANGED; | 102 evt = chromeos::MOUNT_DISK_CHANGED; |
| 101 UpdateDiskChanged(evt, disk2.get()); | 103 UpdateDiskChanged(evt, disk2.get()); |
| 102 } | 104 } |
| 103 | 105 |
| 104 void MockMountLibrary::FireDeviceRemoveEvents() { | 106 void MockMountLibrary::FireDeviceRemoveEvents() { |
| 105 scoped_ptr<MountLibrary::Disk> disk(new MountLibrary::Disk( | 107 scoped_ptr<MountLibrary::Disk> disk(new MountLibrary::Disk( |
| 106 std::string(kTestDevicePath), | 108 std::string(kTestDevicePath), |
| 107 std::string(kTestMountPath), | 109 std::string(kTestMountPath), |
| 108 std::string(kTestSystemPath), | 110 std::string(kTestSystemPath), |
| 109 std::string(kTestFilePath), | 111 std::string(kTestFilePath), |
| 110 std::string(kTestDeviceLabel), | 112 std::string(kTestDeviceLabel), |
| 111 std::string(kTestDriveLabel), | 113 std::string(kTestDriveLabel), |
| 112 std::string(kTestParentPath), | 114 std::string(kTestParentPath), |
| 113 std::string(kTestSystemPathPrefix), | 115 std::string(kTestSystemPathPrefix), |
| 114 FLASH, | 116 FLASH, |
| 115 1073741824, | 117 1073741824, |
| 116 false, | 118 false, |
| 117 false, | 119 false, |
| 118 true, | 120 true, |
| 121 false, |
| 119 false)); | 122 false)); |
| 120 disks_.clear(); | 123 disks_.clear(); |
| 121 disks_.insert(std::pair<std::string, MountLibrary::Disk*>( | 124 disks_.insert(std::pair<std::string, MountLibrary::Disk*>( |
| 122 std::string(kTestDevicePath), disk.get())); | 125 std::string(kTestDevicePath), disk.get())); |
| 123 UpdateDiskChanged(chromeos::MOUNT_DISK_REMOVED, disk.get()); | 126 UpdateDiskChanged(chromeos::MOUNT_DISK_REMOVED, disk.get()); |
| 124 } | 127 } |
| 125 | 128 |
| 126 void MockMountLibrary::SetupDefaultReplies() { | 129 void MockMountLibrary::SetupDefaultReplies() { |
| 127 EXPECT_CALL(*this, AddObserver(_)) | 130 EXPECT_CALL(*this, AddObserver(_)) |
| 128 .Times(AnyNumber()); | 131 .Times(AnyNumber()); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 155 | 158 |
| 156 void MockMountLibrary::UpdateDeviceChanged(MountLibraryEventType evt, | 159 void MockMountLibrary::UpdateDeviceChanged(MountLibraryEventType evt, |
| 157 const std::string& path) { | 160 const std::string& path) { |
| 158 // Make sure we run on UI thread. | 161 // Make sure we run on UI thread. |
| 159 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 162 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 160 | 163 |
| 161 FOR_EACH_OBSERVER(Observer, observers_, DeviceChanged(evt, path)); | 164 FOR_EACH_OBSERVER(Observer, observers_, DeviceChanged(evt, path)); |
| 162 } | 165 } |
| 163 | 166 |
| 164 } // namespace chromeos | 167 } // namespace chromeos |
| OLD | NEW |