OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/stl_util.h" | 5 #include "base/stl_util.h" |
6 #include "chrome/browser/chromeos/file_manager/drive_test_util.h" | 6 #include "chrome/browser/chromeos/file_manager/drive_test_util.h" |
7 #include "chrome/browser/extensions/extension_apitest.h" | 7 #include "chrome/browser/extensions/extension_apitest.h" |
8 #include "chromeos/dbus/cros_disks_client.h" | 8 #include "chromeos/dbus/cros_disks_client.h" |
9 #include "chromeos/disks/mock_disk_mount_manager.h" | 9 #include "chromeos/disks/mock_disk_mount_manager.h" |
10 | 10 |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 true, | 101 true, |
102 false, | 102 false, |
103 false, | 103 false, |
104 true, | 104 true, |
105 false | 105 false |
106 } | 106 } |
107 }; | 107 }; |
108 | 108 |
109 } // namespace | 109 } // namespace |
110 | 110 |
111 class FileBrowserPrivateApiTest : public ExtensionApiTest { | 111 class FileManagerPrivateApiTest : public ExtensionApiTest { |
112 public: | 112 public: |
113 FileBrowserPrivateApiTest() | 113 FileManagerPrivateApiTest() |
114 : disk_mount_manager_mock_(NULL) { | 114 : disk_mount_manager_mock_(NULL) { |
115 InitMountPoints(); | 115 InitMountPoints(); |
116 } | 116 } |
117 | 117 |
118 virtual ~FileBrowserPrivateApiTest() { | 118 virtual ~FileManagerPrivateApiTest() { |
119 DCHECK(!disk_mount_manager_mock_); | 119 DCHECK(!disk_mount_manager_mock_); |
120 STLDeleteValues(&volumes_); | 120 STLDeleteValues(&volumes_); |
121 } | 121 } |
122 | 122 |
123 // ExtensionApiTest override | 123 // ExtensionApiTest override |
124 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { | 124 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { |
125 ExtensionApiTest::SetUpInProcessBrowserTestFixture(); | 125 ExtensionApiTest::SetUpInProcessBrowserTestFixture(); |
126 | 126 |
127 disk_mount_manager_mock_ = new chromeos::disks::MockDiskMountManager; | 127 disk_mount_manager_mock_ = new chromeos::disks::MockDiskMountManager; |
128 chromeos::disks::DiskMountManager::InitializeForTesting( | 128 chromeos::disks::DiskMountManager::InitializeForTesting( |
129 disk_mount_manager_mock_); | 129 disk_mount_manager_mock_); |
130 disk_mount_manager_mock_->SetupDefaultReplies(); | 130 disk_mount_manager_mock_->SetupDefaultReplies(); |
131 | 131 |
132 // OVERRIDE mock functions. | 132 // OVERRIDE mock functions. |
133 ON_CALL(*disk_mount_manager_mock_, FindDiskBySourcePath(_)).WillByDefault( | 133 ON_CALL(*disk_mount_manager_mock_, FindDiskBySourcePath(_)).WillByDefault( |
134 Invoke(this, &FileBrowserPrivateApiTest::FindVolumeBySourcePath)); | 134 Invoke(this, &FileManagerPrivateApiTest::FindVolumeBySourcePath)); |
135 EXPECT_CALL(*disk_mount_manager_mock_, disks()) | 135 EXPECT_CALL(*disk_mount_manager_mock_, disks()) |
136 .WillRepeatedly(ReturnRef(volumes_)); | 136 .WillRepeatedly(ReturnRef(volumes_)); |
137 EXPECT_CALL(*disk_mount_manager_mock_, mount_points()) | 137 EXPECT_CALL(*disk_mount_manager_mock_, mount_points()) |
138 .WillRepeatedly(ReturnRef(mount_points_)); | 138 .WillRepeatedly(ReturnRef(mount_points_)); |
139 } | 139 } |
140 | 140 |
141 // ExtensionApiTest override | 141 // ExtensionApiTest override |
142 virtual void TearDownInProcessBrowserTestFixture() OVERRIDE { | 142 virtual void TearDownInProcessBrowserTestFixture() OVERRIDE { |
143 chromeos::disks::DiskMountManager::Shutdown(); | 143 chromeos::disks::DiskMountManager::Shutdown(); |
144 disk_mount_manager_mock_ = NULL; | 144 disk_mount_manager_mock_ = NULL; |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 volumes_.find(source_path); | 234 volumes_.find(source_path); |
235 return (volume_it == volumes_.end()) ? NULL : volume_it->second; | 235 return (volume_it == volumes_.end()) ? NULL : volume_it->second; |
236 } | 236 } |
237 | 237 |
238 protected: | 238 protected: |
239 chromeos::disks::MockDiskMountManager* disk_mount_manager_mock_; | 239 chromeos::disks::MockDiskMountManager* disk_mount_manager_mock_; |
240 DiskMountManager::DiskMap volumes_; | 240 DiskMountManager::DiskMap volumes_; |
241 DiskMountManager::MountPointMap mount_points_; | 241 DiskMountManager::MountPointMap mount_points_; |
242 }; | 242 }; |
243 | 243 |
244 IN_PROC_BROWSER_TEST_F(FileBrowserPrivateApiTest, Mount) { | 244 IN_PROC_BROWSER_TEST_F(FileManagerPrivateApiTest, Mount) { |
245 file_manager::test_util::WaitUntilDriveMountPointIsAdded( | 245 file_manager::test_util::WaitUntilDriveMountPointIsAdded( |
246 browser()->profile()); | 246 browser()->profile()); |
247 | 247 |
248 // We will call fileBrowserPrivate.unmountVolume once. To test that method, we | 248 // We will call fileManagerPrivate.unmountVolume once. To test that method, we |
249 // check that UnmountPath is really called with the same value. | 249 // check that UnmountPath is really called with the same value. |
250 EXPECT_CALL(*disk_mount_manager_mock_, UnmountPath(_, _, _)) | 250 EXPECT_CALL(*disk_mount_manager_mock_, UnmountPath(_, _, _)) |
251 .Times(0); | 251 .Times(0); |
252 EXPECT_CALL(*disk_mount_manager_mock_, | 252 EXPECT_CALL(*disk_mount_manager_mock_, |
253 UnmountPath( | 253 UnmountPath( |
254 chromeos::CrosDisksClient::GetArchiveMountPoint().AppendASCII( | 254 chromeos::CrosDisksClient::GetArchiveMountPoint().AppendASCII( |
255 "archive_mount_path").AsUTF8Unsafe(), | 255 "archive_mount_path").AsUTF8Unsafe(), |
256 chromeos::UNMOUNT_OPTIONS_NONE, _)).Times(1); | 256 chromeos::UNMOUNT_OPTIONS_NONE, _)).Times(1); |
257 | 257 |
258 ASSERT_TRUE(RunComponentExtensionTest("file_browser/mount_test")) | 258 ASSERT_TRUE(RunComponentExtensionTest("file_browser/mount_test")) |
259 << message_; | 259 << message_; |
260 } | 260 } |
OLD | NEW |