| 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" |
| 11 #include "base/prefs/pref_service.h" | 11 #include "base/prefs/pref_service.h" |
| 12 #include "chrome/browser/chromeos/file_manager/fake_disk_mount_manager.h" | 12 #include "chrome/browser/chromeos/file_manager/fake_disk_mount_manager.h" |
| 13 #include "chrome/browser/chromeos/file_manager/volume_manager_observer.h" | 13 #include "chrome/browser/chromeos/file_manager/volume_manager_observer.h" |
| 14 #include "chrome/browser/chromeos/file_system_provider/fake_provided_file_system
.h" | 14 #include "chrome/browser/chromeos/file_system_provider/fake_provided_file_system
.h" |
| 15 #include "chrome/browser/chromeos/file_system_provider/service.h" | 15 #include "chrome/browser/chromeos/file_system_provider/service.h" |
| 16 #include "chrome/common/pref_names.h" | 16 #include "chrome/common/pref_names.h" |
| 17 #include "chrome/test/base/testing_profile.h" | 17 #include "chrome/test/base/testing_profile.h" |
| 18 #include "chromeos/dbus/fake_power_manager_client.h" | 18 #include "chromeos/dbus/fake_power_manager_client.h" |
| 19 #include "chromeos/disks/disk_mount_manager.h" | 19 #include "chromeos/disks/disk_mount_manager.h" |
| 20 #include "content/public/test/test_browser_thread_bundle.h" | 20 #include "content/public/test/test_browser_thread_bundle.h" |
| 21 #include "extensions/browser/extension_registry.h" |
| 21 #include "testing/gtest/include/gtest/gtest.h" | 22 #include "testing/gtest/include/gtest/gtest.h" |
| 22 | 23 |
| 23 namespace file_manager { | 24 namespace file_manager { |
| 24 namespace { | 25 namespace { |
| 25 | 26 |
| 26 class LoggingObserver : public VolumeManagerObserver { | 27 class LoggingObserver : public VolumeManagerObserver { |
| 27 public: | 28 public: |
| 28 struct Event { | 29 struct Event { |
| 29 enum EventType { | 30 enum EventType { |
| 30 DISK_ADDED, | 31 DISK_ADDED, |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 } // namespace | 139 } // namespace |
| 139 | 140 |
| 140 class VolumeManagerTest : public testing::Test { | 141 class VolumeManagerTest : public testing::Test { |
| 141 protected: | 142 protected: |
| 142 // Helper class that contains per-profile objects. | 143 // Helper class that contains per-profile objects. |
| 143 class ProfileEnvironment { | 144 class ProfileEnvironment { |
| 144 public: | 145 public: |
| 145 ProfileEnvironment(chromeos::PowerManagerClient* power_manager_client, | 146 ProfileEnvironment(chromeos::PowerManagerClient* power_manager_client, |
| 146 chromeos::disks::DiskMountManager* disk_manager) | 147 chromeos::disks::DiskMountManager* disk_manager) |
| 147 : profile_(new TestingProfile), | 148 : profile_(new TestingProfile), |
| 149 extension_registry_( |
| 150 new extensions::ExtensionRegistry(profile_.get())), |
| 148 file_system_provider_service_( | 151 file_system_provider_service_( |
| 149 new chromeos::file_system_provider::Service(profile_.get())), | 152 new chromeos::file_system_provider::Service( |
| 153 profile_.get(), |
| 154 extension_registry_.get())), |
| 150 volume_manager_( | 155 volume_manager_( |
| 151 new VolumeManager(profile_.get(), | 156 new VolumeManager(profile_.get(), |
| 152 NULL, // DriveIntegrationService | 157 NULL, // DriveIntegrationService |
| 153 power_manager_client, | 158 power_manager_client, |
| 154 disk_manager, | 159 disk_manager, |
| 155 file_system_provider_service_.get())) { | 160 file_system_provider_service_.get())) { |
| 156 file_system_provider_service_->SetFileSystemFactoryForTests(base::Bind( | 161 file_system_provider_service_->SetFileSystemFactoryForTests(base::Bind( |
| 157 &chromeos::file_system_provider::FakeProvidedFileSystem::Create)); | 162 &chromeos::file_system_provider::FakeProvidedFileSystem::Create)); |
| 158 } | 163 } |
| 159 | 164 |
| 160 Profile* profile() const { return profile_.get(); } | 165 Profile* profile() const { return profile_.get(); } |
| 161 VolumeManager* volume_manager() const { return volume_manager_.get(); } | 166 VolumeManager* volume_manager() const { return volume_manager_.get(); } |
| 162 | 167 |
| 163 private: | 168 private: |
| 164 scoped_ptr<TestingProfile> profile_; | 169 scoped_ptr<TestingProfile> profile_; |
| 170 scoped_ptr<extensions::ExtensionRegistry> extension_registry_; |
| 165 scoped_ptr<chromeos::file_system_provider::Service> | 171 scoped_ptr<chromeos::file_system_provider::Service> |
| 166 file_system_provider_service_; | 172 file_system_provider_service_; |
| 167 scoped_ptr<VolumeManager> volume_manager_; | 173 scoped_ptr<VolumeManager> volume_manager_; |
| 168 }; | 174 }; |
| 169 | 175 |
| 170 virtual void SetUp() OVERRIDE { | 176 virtual void SetUp() OVERRIDE { |
| 171 power_manager_client_.reset(new chromeos::FakePowerManagerClient); | 177 power_manager_client_.reset(new chromeos::FakePowerManagerClient); |
| 172 disk_mount_manager_.reset(new FakeDiskMountManager); | 178 disk_mount_manager_.reset(new FakeDiskMountManager); |
| 173 main_profile_.reset(new ProfileEnvironment(power_manager_client_.get(), | 179 main_profile_.reset(new ProfileEnvironment(power_manager_client_.get(), |
| 174 disk_mount_manager_.get())); | 180 disk_mount_manager_.get())); |
| (...skipping 628 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 803 chromeos::disks::DiskMountManager::MountPointInfo( | 809 chromeos::disks::DiskMountManager::MountPointInfo( |
| 804 "/other/profile/drive/folder/3.zip", | 810 "/other/profile/drive/folder/3.zip", |
| 805 "/archive/3", | 811 "/archive/3", |
| 806 chromeos::MOUNT_TYPE_ARCHIVE, | 812 chromeos::MOUNT_TYPE_ARCHIVE, |
| 807 chromeos::disks::MOUNT_CONDITION_NONE)); | 813 chromeos::disks::MOUNT_CONDITION_NONE)); |
| 808 EXPECT_FALSE(volume_manager()->FindVolumeInfoById("archive:3", &volume_info)); | 814 EXPECT_FALSE(volume_manager()->FindVolumeInfoById("archive:3", &volume_info)); |
| 809 EXPECT_EQ(3u, observer.events().size()); | 815 EXPECT_EQ(3u, observer.events().size()); |
| 810 } | 816 } |
| 811 | 817 |
| 812 } // namespace file_manager | 818 } // namespace file_manager |
| OLD | NEW |