Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(15)

Side by Side Diff: chrome/browser/chromeos/extensions/file_browser_private_apitest.cc

Issue 10829160: Created a helper function "FindDiskBySourcePath" in DiskMountManager. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix nit Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 <stdio.h> 5 #include <stdio.h>
6 6
7 #include "base/stl_util.h" 7 #include "base/stl_util.h"
8 #include "chrome/browser/chromeos/disks/mock_disk_mount_manager.h" 8 #include "chrome/browser/chromeos/disks/mock_disk_mount_manager.h"
9 #include "chrome/browser/extensions/extension_apitest.h" 9 #include "chrome/browser/extensions/extension_apitest.h"
10 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
11 #include "chrome/browser/ui/browser.h" 11 #include "chrome/browser/ui/browser.h"
12 #include "chrome/test/base/ui_test_utils.h" 12 #include "chrome/test/base/ui_test_utils.h"
13 #include "content/public/browser/browser_thread.h" 13 #include "content/public/browser/browser_thread.h"
14 #include "webkit/fileapi/file_system_context.h" 14 #include "webkit/fileapi/file_system_context.h"
15 #include "webkit/fileapi/file_system_mount_point_provider.h" 15 #include "webkit/fileapi/file_system_mount_point_provider.h"
16 16
17 using ::testing::_; 17 using ::testing::_;
18 using ::testing::AnyNumber;
18 using ::testing::ReturnRef; 19 using ::testing::ReturnRef;
19 using ::testing::StrEq; 20 using ::testing::StrEq;
20 using content::BrowserContext; 21 using content::BrowserContext;
21 22
22 using chromeos::disks::DiskMountManager; 23 using chromeos::disks::DiskMountManager;
23 24
24 namespace { 25 namespace {
25 26
26 struct TestDiskInfo { 27 struct TestDiskInfo {
27 const char* system_path; 28 const char* system_path;
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 } 146 }
146 147
147 // ExtensionApiTest override 148 // ExtensionApiTest override
148 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { 149 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE {
149 ExtensionApiTest::SetUpInProcessBrowserTestFixture(); 150 ExtensionApiTest::SetUpInProcessBrowserTestFixture();
150 151
151 disk_mount_manager_mock_ = new chromeos::disks::MockDiskMountManager; 152 disk_mount_manager_mock_ = new chromeos::disks::MockDiskMountManager;
152 chromeos::disks::DiskMountManager::InitializeForTesting( 153 chromeos::disks::DiskMountManager::InitializeForTesting(
153 disk_mount_manager_mock_); 154 disk_mount_manager_mock_);
154 disk_mount_manager_mock_->SetupDefaultReplies(); 155 disk_mount_manager_mock_->SetupDefaultReplies();
156
157 // OVERRIDE FindDiskBySourcePath mock function.
158 ON_CALL(*disk_mount_manager_mock_, FindDiskBySourcePath(_)).
159 WillByDefault(Invoke(
160 this, &ExtensionFileBrowserPrivateApiTest::FindVolumeBySourcePath));
155 } 161 }
156 162
157 // ExtensionApiTest override 163 // ExtensionApiTest override
158 virtual void TearDownInProcessBrowserTestFixture() OVERRIDE { 164 virtual void TearDownInProcessBrowserTestFixture() OVERRIDE {
159 chromeos::disks::DiskMountManager::Shutdown(); 165 chromeos::disks::DiskMountManager::Shutdown();
160 disk_mount_manager_mock_ = NULL; 166 disk_mount_manager_mock_ = NULL;
161 167
162 ExtensionApiTest::TearDownInProcessBrowserTestFixture(); 168 ExtensionApiTest::TearDownInProcessBrowserTestFixture();
163 } 169 }
164 170
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 kTestDisks[disk_info_index].has_media, 209 kTestDisks[disk_info_index].has_media,
204 kTestDisks[disk_info_index].on_boot_device, 210 kTestDisks[disk_info_index].on_boot_device,
205 kTestDisks[disk_info_index].is_hidden 211 kTestDisks[disk_info_index].is_hidden
206 ) 212 )
207 )); 213 ));
208 214
209 } 215 }
210 } 216 }
211 } 217 }
212 218
219 const DiskMountManager::Disk* FindVolumeBySourcePath(
220 const std::string& source_path) {
221 DiskMountManager::DiskMap::const_iterator volume_it =
222 volumes_.find(source_path);
223 return (volume_it == volumes_.end()) ? NULL : volume_it->second;
224 }
225
213 protected: 226 protected:
214 chromeos::disks::MockDiskMountManager* disk_mount_manager_mock_; 227 chromeos::disks::MockDiskMountManager* disk_mount_manager_mock_;
215 DiskMountManager::DiskMap volumes_; 228 DiskMountManager::DiskMap volumes_;
216 DiskMountManager::MountPointMap mount_points_; 229 DiskMountManager::MountPointMap mount_points_;
217 230
218 private: 231 private:
219 FilePath test_mount_point_; 232 FilePath test_mount_point_;
220 }; 233 };
221 234
222 IN_PROC_BROWSER_TEST_F(ExtensionFileBrowserPrivateApiTest, FileBrowserMount) { 235 IN_PROC_BROWSER_TEST_F(ExtensionFileBrowserPrivateApiTest, FileBrowserMount) {
223 // We will call fileBrowserPrivate.unmountVolume once. To test that method, we 236 // We will call fileBrowserPrivate.unmountVolume once. To test that method, we
224 // check that UnmountPath is really called with the same value. 237 // check that UnmountPath is really called with the same value.
225 AddTmpMountPoint(); 238 AddTmpMountPoint();
226 EXPECT_CALL(*disk_mount_manager_mock_, UnmountPath(_)) 239 EXPECT_CALL(*disk_mount_manager_mock_, UnmountPath(_))
227 .Times(0); 240 .Times(0);
228 EXPECT_CALL(*disk_mount_manager_mock_, 241 EXPECT_CALL(*disk_mount_manager_mock_,
229 UnmountPath(StrEq("/media/archive/archive_mount_path"))).Times(1); 242 UnmountPath(StrEq("/media/archive/archive_mount_path"))).Times(1);
230 243
231 EXPECT_CALL(*disk_mount_manager_mock_, disks()) 244 EXPECT_CALL(*disk_mount_manager_mock_, disks())
232 .WillRepeatedly(ReturnRef(volumes_)); 245 .WillRepeatedly(ReturnRef(volumes_));
233 246
234 EXPECT_CALL(*disk_mount_manager_mock_, mount_points()) 247 EXPECT_CALL(*disk_mount_manager_mock_, mount_points())
235 .WillRepeatedly(ReturnRef(mount_points_)); 248 .WillRepeatedly(ReturnRef(mount_points_));
236 249
237 ASSERT_TRUE(RunComponentExtensionTest("filebrowser_mount")) << message_; 250 ASSERT_TRUE(RunComponentExtensionTest("filebrowser_mount")) << message_;
238 } 251 }
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/extensions/file_browser_private_api.cc ('k') | chrome/browser/chromeos/imageburner/burn_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698