| 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 22 matching lines...) Expand all Loading... |
| 33 observers_.RemoveObserver(observer); | 33 observers_.RemoveObserver(observer); |
| 34 } | 34 } |
| 35 | 35 |
| 36 MockMountLibrary::MockMountLibrary() { | 36 MockMountLibrary::MockMountLibrary() { |
| 37 ON_CALL(*this, AddObserver(_)) | 37 ON_CALL(*this, AddObserver(_)) |
| 38 .WillByDefault(Invoke(this, &MockMountLibrary::AddObserverInternal)); | 38 .WillByDefault(Invoke(this, &MockMountLibrary::AddObserverInternal)); |
| 39 ON_CALL(*this, RemoveObserver(_)) | 39 ON_CALL(*this, RemoveObserver(_)) |
| 40 .WillByDefault(Invoke(this, &MockMountLibrary::RemoveObserverInternal)); | 40 .WillByDefault(Invoke(this, &MockMountLibrary::RemoveObserverInternal)); |
| 41 ON_CALL(*this, disks()) | 41 ON_CALL(*this, disks()) |
| 42 .WillByDefault(Invoke(this, &MockMountLibrary::disksInternal)); | 42 .WillByDefault(Invoke(this, &MockMountLibrary::disksInternal)); |
| 43 ON_CALL(*this, mount_points()) |
| 44 .WillByDefault(Invoke(this, &MockMountLibrary::mountPointsInternal)); |
| 43 } | 45 } |
| 44 | 46 |
| 45 MockMountLibrary::~MockMountLibrary() { | 47 MockMountLibrary::~MockMountLibrary() { |
| 46 | 48 |
| 47 } | 49 } |
| 48 | 50 |
| 49 void MockMountLibrary::FireDeviceInsertEvents() { | 51 void MockMountLibrary::FireDeviceInsertEvents() { |
| 50 | 52 |
| 51 scoped_ptr<MountLibrary::Disk> disk1(new MountLibrary::Disk( | 53 scoped_ptr<MountLibrary::Disk> disk1(new MountLibrary::Disk( |
| 52 std::string(kTestDevicePath), | 54 std::string(kTestDevicePath), |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 | 123 |
| 122 void MockMountLibrary::SetupDefaultReplies() { | 124 void MockMountLibrary::SetupDefaultReplies() { |
| 123 EXPECT_CALL(*this, AddObserver(_)) | 125 EXPECT_CALL(*this, AddObserver(_)) |
| 124 .Times(AnyNumber()); | 126 .Times(AnyNumber()); |
| 125 EXPECT_CALL(*this, RemoveObserver(_)) | 127 EXPECT_CALL(*this, RemoveObserver(_)) |
| 126 .Times(AnyNumber()); | 128 .Times(AnyNumber()); |
| 127 EXPECT_CALL(*this, disks()) | 129 EXPECT_CALL(*this, disks()) |
| 128 .WillRepeatedly(ReturnRef(disks_)); | 130 .WillRepeatedly(ReturnRef(disks_)); |
| 129 EXPECT_CALL(*this, RequestMountInfoRefresh()) | 131 EXPECT_CALL(*this, RequestMountInfoRefresh()) |
| 130 .Times(AnyNumber()); | 132 .Times(AnyNumber()); |
| 131 EXPECT_CALL(*this, MountPath(_)) | 133 EXPECT_CALL(*this, MountPath(_, _, _)) |
| 132 .Times(AnyNumber()); | 134 .Times(AnyNumber()); |
| 133 EXPECT_CALL(*this, UnmountPath(_)) | 135 EXPECT_CALL(*this, UnmountPath(_)) |
| 134 .Times(AnyNumber()); | 136 .Times(AnyNumber()); |
| 135 EXPECT_CALL(*this, UnmountDeviceRecursive(_, _, _)) | 137 EXPECT_CALL(*this, UnmountDeviceRecursive(_, _, _)) |
| 136 .Times(AnyNumber()); | 138 .Times(AnyNumber()); |
| 137 } | 139 } |
| 138 | 140 |
| 139 void MockMountLibrary::UpdateDiskChanged(MountLibraryEventType evt, | 141 void MockMountLibrary::UpdateDiskChanged(MountLibraryEventType evt, |
| 140 const MountLibrary::Disk* disk) { | 142 const MountLibrary::Disk* disk) { |
| 141 // Make sure we run on UI thread. | 143 // Make sure we run on UI thread. |
| 142 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 144 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 143 | 145 |
| 144 FOR_EACH_OBSERVER(Observer, observers_, DiskChanged(evt, disk)); | 146 FOR_EACH_OBSERVER(Observer, observers_, DiskChanged(evt, disk)); |
| 145 } | 147 } |
| 146 | 148 |
| 147 | 149 |
| 148 void MockMountLibrary::UpdateDeviceChanged(MountLibraryEventType evt, | 150 void MockMountLibrary::UpdateDeviceChanged(MountLibraryEventType evt, |
| 149 const std::string& path) { | 151 const std::string& path) { |
| 150 // Make sure we run on UI thread. | 152 // Make sure we run on UI thread. |
| 151 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 153 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 152 | 154 |
| 153 FOR_EACH_OBSERVER(Observer, observers_, DeviceChanged(evt, path)); | 155 FOR_EACH_OBSERVER(Observer, observers_, DeviceChanged(evt, path)); |
| 154 } | 156 } |
| 155 | 157 |
| 156 } // namespace chromeos | 158 } // namespace chromeos |
| OLD | NEW |