| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/file_manager/volume_manager.h" | 5 #include "chrome/browser/chromeos/file_manager/volume_manager.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 VolumeManagerTest() { | 140 VolumeManagerTest() { |
| 141 } | 141 } |
| 142 virtual ~VolumeManagerTest() { | 142 virtual ~VolumeManagerTest() { |
| 143 } | 143 } |
| 144 | 144 |
| 145 virtual void SetUp() OVERRIDE { | 145 virtual void SetUp() OVERRIDE { |
| 146 power_manager_client_.reset(new chromeos::FakePowerManagerClient); | 146 power_manager_client_.reset(new chromeos::FakePowerManagerClient); |
| 147 disk_mount_manager_.reset(new FakeDiskMountManager); | 147 disk_mount_manager_.reset(new FakeDiskMountManager); |
| 148 profile_.reset(new TestingProfile); | 148 profile_.reset(new TestingProfile); |
| 149 volume_manager_.reset(new VolumeManager(profile_.get(), | 149 volume_manager_.reset(new VolumeManager(profile_.get(), |
| 150 NULL, // DriveIntegrationService |
| 150 power_manager_client_.get(), | 151 power_manager_client_.get(), |
| 151 disk_mount_manager_.get())); | 152 disk_mount_manager_.get())); |
| 152 } | 153 } |
| 153 | 154 |
| 154 content::TestBrowserThreadBundle thread_bundle_; | 155 content::TestBrowserThreadBundle thread_bundle_; |
| 155 scoped_ptr<chromeos::FakePowerManagerClient> power_manager_client_; | 156 scoped_ptr<chromeos::FakePowerManagerClient> power_manager_client_; |
| 156 scoped_ptr<FakeDiskMountManager> disk_mount_manager_; | 157 scoped_ptr<FakeDiskMountManager> disk_mount_manager_; |
| 157 scoped_ptr<TestingProfile> profile_; | 158 scoped_ptr<TestingProfile> profile_; |
| 158 scoped_ptr<VolumeManager> volume_manager_; | 159 scoped_ptr<VolumeManager> volume_manager_; |
| 159 }; | 160 }; |
| 160 | 161 |
| 162 TEST_F(VolumeManagerTest, OnFileSystemMounted) { |
| 163 LoggingObserver observer; |
| 164 volume_manager_->AddObserver(&observer); |
| 165 |
| 166 volume_manager_->OnFileSystemMounted(); |
| 167 |
| 168 ASSERT_EQ(1U, observer.events().size()); |
| 169 const LoggingObserver::Event& event = observer.events()[0]; |
| 170 EXPECT_EQ(LoggingObserver::Event::VOLUME_MOUNTED, event.type); |
| 171 EXPECT_EQ(drive::util::GetDriveMountPointPath().AsUTF8Unsafe(), |
| 172 event.device_path); |
| 173 EXPECT_EQ(chromeos::MOUNT_ERROR_NONE, event.mount_error); |
| 174 EXPECT_FALSE(event.is_remounting); |
| 175 |
| 176 volume_manager_->RemoveObserver(&observer); |
| 177 } |
| 178 |
| 179 TEST_F(VolumeManagerTest, OnFileSystemBeingUnmounted) { |
| 180 LoggingObserver observer; |
| 181 volume_manager_->AddObserver(&observer); |
| 182 |
| 183 volume_manager_->OnFileSystemBeingUnmounted(); |
| 184 |
| 185 ASSERT_EQ(1U, observer.events().size()); |
| 186 const LoggingObserver::Event& event = observer.events()[0]; |
| 187 EXPECT_EQ(LoggingObserver::Event::VOLUME_UNMOUNTED, event.type); |
| 188 EXPECT_EQ(drive::util::GetDriveMountPointPath().AsUTF8Unsafe(), |
| 189 event.device_path); |
| 190 EXPECT_EQ(chromeos::MOUNT_ERROR_NONE, event.mount_error); |
| 191 |
| 192 volume_manager_->RemoveObserver(&observer); |
| 193 } |
| 194 |
| 161 TEST_F(VolumeManagerTest, OnDiskEvent_Hidden) { | 195 TEST_F(VolumeManagerTest, OnDiskEvent_Hidden) { |
| 162 LoggingObserver observer; | 196 LoggingObserver observer; |
| 163 volume_manager_->AddObserver(&observer); | 197 volume_manager_->AddObserver(&observer); |
| 164 | 198 |
| 165 const bool kIsHidden = true; | 199 const bool kIsHidden = true; |
| 166 const chromeos::disks::DiskMountManager::Disk kDisk( | 200 const chromeos::disks::DiskMountManager::Disk kDisk( |
| 167 "device1", "", "", "", "", "", "", "", "", "", "", "", | 201 "device1", "", "", "", "", "", "", "", "", "", "", "", |
| 168 chromeos::DEVICE_TYPE_UNKNOWN, 0, false, false, false, false, kIsHidden); | 202 chromeos::DEVICE_TYPE_UNKNOWN, 0, false, false, false, false, kIsHidden); |
| 169 | 203 |
| 170 volume_manager_->OnDiskEvent( | 204 volume_manager_->OnDiskEvent( |
| (...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 612 const FakeDiskMountManager::UnmountRequest& unmount_request1 = | 646 const FakeDiskMountManager::UnmountRequest& unmount_request1 = |
| 613 disk_mount_manager_->unmount_requests()[0]; | 647 disk_mount_manager_->unmount_requests()[0]; |
| 614 EXPECT_EQ("mount1", unmount_request1.mount_path); | 648 EXPECT_EQ("mount1", unmount_request1.mount_path); |
| 615 | 649 |
| 616 const FakeDiskMountManager::UnmountRequest& unmount_request2 = | 650 const FakeDiskMountManager::UnmountRequest& unmount_request2 = |
| 617 disk_mount_manager_->unmount_requests()[1]; | 651 disk_mount_manager_->unmount_requests()[1]; |
| 618 EXPECT_EQ("mount2", unmount_request2.mount_path); | 652 EXPECT_EQ("mount2", unmount_request2.mount_path); |
| 619 } | 653 } |
| 620 | 654 |
| 621 } // namespace file_manager | 655 } // namespace file_manager |
| OLD | NEW |