| 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/disks/mock_disk_mount_manager.h" | 5 #include "chrome/browser/chromeos/disks/mock_disk_mount_manager.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 "content/public/browser/browser_thread.h" | 9 #include "content/public/browser/browser_thread.h" |
| 10 | 10 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 | 54 |
| 55 void MockDiskMountManager::NotifyDeviceInsertEvents() { | 55 void MockDiskMountManager::NotifyDeviceInsertEvents() { |
| 56 scoped_ptr<DiskMountManager::Disk> disk1(new DiskMountManager::Disk( | 56 scoped_ptr<DiskMountManager::Disk> disk1(new DiskMountManager::Disk( |
| 57 std::string(kTestDevicePath), | 57 std::string(kTestDevicePath), |
| 58 std::string(), | 58 std::string(), |
| 59 std::string(kTestSystemPath), | 59 std::string(kTestSystemPath), |
| 60 std::string(kTestFilePath), | 60 std::string(kTestFilePath), |
| 61 std::string(), | 61 std::string(), |
| 62 std::string(kTestDriveLabel), | 62 std::string(kTestDriveLabel), |
| 63 std::string(kTestSystemPathPrefix), | 63 std::string(kTestSystemPathPrefix), |
| 64 FLASH, | 64 DEVICE_TYPE_USB, |
| 65 4294967295U, | 65 4294967295U, |
| 66 false, // is_parent | 66 false, // is_parent |
| 67 false, // is_read_only | 67 false, // is_read_only |
| 68 true, // has_media | 68 true, // has_media |
| 69 false, // on_boot_device | 69 false, // on_boot_device |
| 70 false)); // is_hidden | 70 false)); // is_hidden |
| 71 | 71 |
| 72 disks_.clear(); | 72 disks_.clear(); |
| 73 disks_.insert(std::pair<std::string, DiskMountManager::Disk*>( | 73 disks_.insert(std::pair<std::string, DiskMountManager::Disk*>( |
| 74 std::string(kTestDevicePath), disk1.get())); | 74 std::string(kTestDevicePath), disk1.get())); |
| 75 | 75 |
| 76 // Device Added | 76 // Device Added |
| 77 DiskMountManagerEventType event; | 77 DiskMountManagerEventType event; |
| 78 event = MOUNT_DEVICE_ADDED; | 78 event = MOUNT_DEVICE_ADDED; |
| 79 NotifyDeviceChanged(event, kTestSystemPath); | 79 NotifyDeviceChanged(event, kTestSystemPath); |
| 80 | 80 |
| 81 // Disk Added | 81 // Disk Added |
| 82 event = MOUNT_DISK_ADDED; | 82 event = MOUNT_DISK_ADDED; |
| 83 NotifyDiskChanged(event, disk1.get()); | 83 NotifyDiskChanged(event, disk1.get()); |
| 84 | 84 |
| 85 // Disk Changed | 85 // Disk Changed |
| 86 scoped_ptr<DiskMountManager::Disk> disk2(new DiskMountManager::Disk( | 86 scoped_ptr<DiskMountManager::Disk> disk2(new DiskMountManager::Disk( |
| 87 std::string(kTestDevicePath), | 87 std::string(kTestDevicePath), |
| 88 std::string(kTestMountPath), | 88 std::string(kTestMountPath), |
| 89 std::string(kTestSystemPath), | 89 std::string(kTestSystemPath), |
| 90 std::string(kTestFilePath), | 90 std::string(kTestFilePath), |
| 91 std::string(kTestDeviceLabel), | 91 std::string(kTestDeviceLabel), |
| 92 std::string(kTestDriveLabel), | 92 std::string(kTestDriveLabel), |
| 93 std::string(kTestSystemPathPrefix), | 93 std::string(kTestSystemPathPrefix), |
| 94 FLASH, | 94 DEVICE_TYPE_MOBILE, |
| 95 1073741824, | 95 1073741824, |
| 96 false, // is_parent | 96 false, // is_parent |
| 97 false, // is_read_only | 97 false, // is_read_only |
| 98 true, // has_media | 98 true, // has_media |
| 99 false, // on_boot_device | 99 false, // on_boot_device |
| 100 false)); // is_hidden | 100 false)); // is_hidden |
| 101 disks_.clear(); | 101 disks_.clear(); |
| 102 disks_.insert(std::pair<std::string, DiskMountManager::Disk*>( | 102 disks_.insert(std::pair<std::string, DiskMountManager::Disk*>( |
| 103 std::string(kTestDevicePath), disk2.get())); | 103 std::string(kTestDevicePath), disk2.get())); |
| 104 event = MOUNT_DISK_CHANGED; | 104 event = MOUNT_DISK_CHANGED; |
| 105 NotifyDiskChanged(event, disk2.get()); | 105 NotifyDiskChanged(event, disk2.get()); |
| 106 } | 106 } |
| 107 | 107 |
| 108 void MockDiskMountManager::NotifyDeviceRemoveEvents() { | 108 void MockDiskMountManager::NotifyDeviceRemoveEvents() { |
| 109 scoped_ptr<DiskMountManager::Disk> disk(new DiskMountManager::Disk( | 109 scoped_ptr<DiskMountManager::Disk> disk(new DiskMountManager::Disk( |
| 110 std::string(kTestDevicePath), | 110 std::string(kTestDevicePath), |
| 111 std::string(kTestMountPath), | 111 std::string(kTestMountPath), |
| 112 std::string(kTestSystemPath), | 112 std::string(kTestSystemPath), |
| 113 std::string(kTestFilePath), | 113 std::string(kTestFilePath), |
| 114 std::string(kTestDeviceLabel), | 114 std::string(kTestDeviceLabel), |
| 115 std::string(kTestDriveLabel), | 115 std::string(kTestDriveLabel), |
| 116 std::string(kTestSystemPathPrefix), | 116 std::string(kTestSystemPathPrefix), |
| 117 FLASH, | 117 DEVICE_TYPE_SD, |
| 118 1073741824, | 118 1073741824, |
| 119 false, // is_parent | 119 false, // is_parent |
| 120 false, // is_read_only | 120 false, // is_read_only |
| 121 true, // has_media | 121 true, // has_media |
| 122 false, // on_boot_device | 122 false, // on_boot_device |
| 123 false)); // is_hidden | 123 false)); // is_hidden |
| 124 disks_.clear(); | 124 disks_.clear(); |
| 125 disks_.insert(std::pair<std::string, DiskMountManager::Disk*>( | 125 disks_.insert(std::pair<std::string, DiskMountManager::Disk*>( |
| 126 std::string(kTestDevicePath), disk.get())); | 126 std::string(kTestDevicePath), disk.get())); |
| 127 NotifyDiskChanged(MOUNT_DISK_REMOVED, disk.get()); | 127 NotifyDiskChanged(MOUNT_DISK_REMOVED, disk.get()); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 void MockDiskMountManager::NotifyDeviceChanged(DiskMountManagerEventType event, | 160 void MockDiskMountManager::NotifyDeviceChanged(DiskMountManagerEventType event, |
| 161 const std::string& path) { | 161 const std::string& path) { |
| 162 // Make sure we run on UI thread. | 162 // Make sure we run on UI thread. |
| 163 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 163 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 164 | 164 |
| 165 FOR_EACH_OBSERVER(Observer, observers_, DeviceChanged(event, path)); | 165 FOR_EACH_OBSERVER(Observer, observers_, DeviceChanged(event, path)); |
| 166 } | 166 } |
| 167 | 167 |
| 168 } // namespace disks | 168 } // namespace disks |
| 169 } // namespace chromeos | 169 } // namespace chromeos |
| OLD | NEW |