| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 | 167 |
| 168 Profile* profile() const { return profile_.get(); } | 168 Profile* profile() const { return profile_.get(); } |
| 169 VolumeManager* volume_manager() const { return volume_manager_.get(); } | 169 VolumeManager* volume_manager() const { return volume_manager_.get(); } |
| 170 | 170 |
| 171 private: | 171 private: |
| 172 const MtpStorageInfo* GetFakeMtpStorageInfo( | 172 const MtpStorageInfo* GetFakeMtpStorageInfo( |
| 173 const std::string& /*storage_name*/) { | 173 const std::string& /*storage_name*/) { |
| 174 return &fake_mtp_storage_info_; | 174 return &fake_mtp_storage_info_; |
| 175 } | 175 } |
| 176 | 176 |
| 177 scoped_ptr<TestingProfile> profile_; | 177 std::unique_ptr<TestingProfile> profile_; |
| 178 scoped_ptr<extensions::ExtensionRegistry> extension_registry_; | 178 std::unique_ptr<extensions::ExtensionRegistry> extension_registry_; |
| 179 scoped_ptr<chromeos::file_system_provider::Service> | 179 std::unique_ptr<chromeos::file_system_provider::Service> |
| 180 file_system_provider_service_; | 180 file_system_provider_service_; |
| 181 scoped_ptr<VolumeManager> volume_manager_; | 181 std::unique_ptr<VolumeManager> volume_manager_; |
| 182 const MtpStorageInfo fake_mtp_storage_info_; | 182 const MtpStorageInfo fake_mtp_storage_info_; |
| 183 }; | 183 }; |
| 184 | 184 |
| 185 void SetUp() override { | 185 void SetUp() override { |
| 186 power_manager_client_.reset(new chromeos::FakePowerManagerClient); | 186 power_manager_client_.reset(new chromeos::FakePowerManagerClient); |
| 187 disk_mount_manager_.reset(new FakeDiskMountManager); | 187 disk_mount_manager_.reset(new FakeDiskMountManager); |
| 188 main_profile_.reset(new ProfileEnvironment(power_manager_client_.get(), | 188 main_profile_.reset(new ProfileEnvironment(power_manager_client_.get(), |
| 189 disk_mount_manager_.get())); | 189 disk_mount_manager_.get())); |
| 190 } | 190 } |
| 191 | 191 |
| 192 Profile* profile() const { return main_profile_->profile(); } | 192 Profile* profile() const { return main_profile_->profile(); } |
| 193 VolumeManager* volume_manager() const { | 193 VolumeManager* volume_manager() const { |
| 194 return main_profile_->volume_manager(); | 194 return main_profile_->volume_manager(); |
| 195 } | 195 } |
| 196 | 196 |
| 197 content::TestBrowserThreadBundle thread_bundle_; | 197 content::TestBrowserThreadBundle thread_bundle_; |
| 198 scoped_ptr<chromeos::FakePowerManagerClient> power_manager_client_; | 198 std::unique_ptr<chromeos::FakePowerManagerClient> power_manager_client_; |
| 199 scoped_ptr<FakeDiskMountManager> disk_mount_manager_; | 199 std::unique_ptr<FakeDiskMountManager> disk_mount_manager_; |
| 200 scoped_ptr<ProfileEnvironment> main_profile_; | 200 std::unique_ptr<ProfileEnvironment> main_profile_; |
| 201 }; | 201 }; |
| 202 | 202 |
| 203 TEST_F(VolumeManagerTest, OnDriveFileSystemMountAndUnmount) { | 203 TEST_F(VolumeManagerTest, OnDriveFileSystemMountAndUnmount) { |
| 204 LoggingObserver observer; | 204 LoggingObserver observer; |
| 205 volume_manager()->AddObserver(&observer); | 205 volume_manager()->AddObserver(&observer); |
| 206 | 206 |
| 207 volume_manager()->OnFileSystemMounted(); | 207 volume_manager()->OnFileSystemMounted(); |
| 208 | 208 |
| 209 ASSERT_EQ(1U, observer.events().size()); | 209 ASSERT_EQ(1U, observer.events().size()); |
| 210 LoggingObserver::Event event = observer.events()[0]; | 210 LoggingObserver::Event event = observer.events()[0]; |
| (...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 511 ASSERT_EQ(2U, observer.events().size()); | 511 ASSERT_EQ(2U, observer.events().size()); |
| 512 event = observer.events()[1]; | 512 event = observer.events()[1]; |
| 513 EXPECT_EQ(LoggingObserver::Event::VOLUME_UNMOUNTED, event.type); | 513 EXPECT_EQ(LoggingObserver::Event::VOLUME_UNMOUNTED, event.type); |
| 514 EXPECT_EQ("device1", event.device_path); | 514 EXPECT_EQ("device1", event.device_path); |
| 515 EXPECT_EQ(chromeos::MOUNT_ERROR_NONE, event.mount_error); | 515 EXPECT_EQ(chromeos::MOUNT_ERROR_NONE, event.mount_error); |
| 516 | 516 |
| 517 volume_manager()->RemoveObserver(&observer); | 517 volume_manager()->RemoveObserver(&observer); |
| 518 } | 518 } |
| 519 | 519 |
| 520 TEST_F(VolumeManagerTest, OnMountEvent_Remounting) { | 520 TEST_F(VolumeManagerTest, OnMountEvent_Remounting) { |
| 521 scoped_ptr<chromeos::disks::DiskMountManager::Disk> disk( | 521 std::unique_ptr<chromeos::disks::DiskMountManager::Disk> disk( |
| 522 new chromeos::disks::DiskMountManager::Disk( | 522 new chromeos::disks::DiskMountManager::Disk( |
| 523 "device1", "", "", "", "", "", "", "", "", "", "uuid1", "", | 523 "device1", "", "", "", "", "", "", "", "", "", "uuid1", "", |
| 524 chromeos::DEVICE_TYPE_UNKNOWN, 0, | 524 chromeos::DEVICE_TYPE_UNKNOWN, 0, false, false, false, false, false, |
| 525 false, false, false, false, false, false)); | 525 false)); |
| 526 disk_mount_manager_->AddDiskForTest(disk.release()); | 526 disk_mount_manager_->AddDiskForTest(disk.release()); |
| 527 disk_mount_manager_->MountPath( | 527 disk_mount_manager_->MountPath( |
| 528 "device1", "", "", chromeos::MOUNT_TYPE_DEVICE); | 528 "device1", "", "", chromeos::MOUNT_TYPE_DEVICE); |
| 529 | 529 |
| 530 const chromeos::disks::DiskMountManager::MountPointInfo kMountPoint( | 530 const chromeos::disks::DiskMountManager::MountPointInfo kMountPoint( |
| 531 "device1", | 531 "device1", |
| 532 "mount1", | 532 "mount1", |
| 533 chromeos::MOUNT_TYPE_DEVICE, | 533 chromeos::MOUNT_TYPE_DEVICE, |
| 534 chromeos::disks::MOUNT_CONDITION_NONE); | 534 chromeos::disks::MOUNT_CONDITION_NONE); |
| 535 | 535 |
| (...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 873 // Detach | 873 // Detach |
| 874 volume_manager()->OnRemovableStorageDetached(info); | 874 volume_manager()->OnRemovableStorageDetached(info); |
| 875 ASSERT_EQ(2u, observer.events().size()); | 875 ASSERT_EQ(2u, observer.events().size()); |
| 876 EXPECT_EQ(LoggingObserver::Event::VOLUME_UNMOUNTED, | 876 EXPECT_EQ(LoggingObserver::Event::VOLUME_UNMOUNTED, |
| 877 observer.events()[1].type); | 877 observer.events()[1].type); |
| 878 | 878 |
| 879 EXPECT_FALSE(volume.get()); | 879 EXPECT_FALSE(volume.get()); |
| 880 } | 880 } |
| 881 | 881 |
| 882 } // namespace file_manager | 882 } // namespace file_manager |
| OLD | NEW |