| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/drive/download_handler.h" | 5 #include "chrome/browser/chromeos/drive/download_handler.h" |
| 6 | 6 |
| 7 #include "base/files/scoped_temp_dir.h" | 7 #include "base/files/scoped_temp_dir.h" |
| 8 #include "chrome/browser/chromeos/drive/dummy_file_system.h" | 8 #include "chrome/browser/chromeos/drive/dummy_file_system.h" |
| 9 #include "chrome/browser/chromeos/drive/file_system_util.h" | 9 #include "chrome/browser/chromeos/drive/file_system_util.h" |
| 10 #include "chrome/browser/chromeos/drive/file_write_helper.h" | |
| 11 #include "chrome/browser/chromeos/drive/test_util.h" | 10 #include "chrome/browser/chromeos/drive/test_util.h" |
| 12 #include "content/public/test/mock_download_item.h" | 11 #include "content/public/test/mock_download_item.h" |
| 13 #include "content/public/test/mock_download_manager.h" | 12 #include "content/public/test/mock_download_manager.h" |
| 14 #include "content/public/test/test_browser_thread_bundle.h" | 13 #include "content/public/test/test_browser_thread_bundle.h" |
| 15 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
| 16 | 15 |
| 17 namespace drive { | 16 namespace drive { |
| 18 | 17 |
| 19 namespace { | 18 namespace { |
| 20 | 19 |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 DownloadHandlerTest() | 69 DownloadHandlerTest() |
| 71 : download_manager_(new content::MockDownloadManager) {} | 70 : download_manager_(new content::MockDownloadManager) {} |
| 72 | 71 |
| 73 virtual void SetUp() OVERRIDE { | 72 virtual void SetUp() OVERRIDE { |
| 74 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 73 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
| 75 | 74 |
| 76 // Set expectations for download item. | 75 // Set expectations for download item. |
| 77 EXPECT_CALL(download_item_, GetState()) | 76 EXPECT_CALL(download_item_, GetState()) |
| 78 .WillRepeatedly(testing::Return(content::DownloadItem::IN_PROGRESS)); | 77 .WillRepeatedly(testing::Return(content::DownloadItem::IN_PROGRESS)); |
| 79 | 78 |
| 80 file_write_helper_.reset(new FileWriteHelper(&test_file_system_)); | 79 download_handler_.reset(new DownloadHandler(&test_file_system_)); |
| 81 download_handler_.reset( | |
| 82 new DownloadHandler(file_write_helper_.get(), &test_file_system_)); | |
| 83 download_handler_->Initialize(download_manager_.get(), temp_dir_.path()); | 80 download_handler_->Initialize(download_manager_.get(), temp_dir_.path()); |
| 84 } | 81 } |
| 85 | 82 |
| 86 protected: | 83 protected: |
| 87 base::ScopedTempDir temp_dir_; | 84 base::ScopedTempDir temp_dir_; |
| 88 content::TestBrowserThreadBundle thread_bundle_; | 85 content::TestBrowserThreadBundle thread_bundle_; |
| 89 scoped_ptr<content::MockDownloadManager> download_manager_; | 86 scoped_ptr<content::MockDownloadManager> download_manager_; |
| 90 DownloadHandlerTestFileSystem test_file_system_; | 87 DownloadHandlerTestFileSystem test_file_system_; |
| 91 scoped_ptr<FileWriteHelper> file_write_helper_; | |
| 92 scoped_ptr<DownloadHandler> download_handler_; | 88 scoped_ptr<DownloadHandler> download_handler_; |
| 93 content::MockDownloadItem download_item_; | 89 content::MockDownloadItem download_item_; |
| 94 }; | 90 }; |
| 95 | 91 |
| 96 TEST_F(DownloadHandlerTest, SubstituteDriveDownloadPathNonDrivePath) { | 92 TEST_F(DownloadHandlerTest, SubstituteDriveDownloadPathNonDrivePath) { |
| 97 const base::FilePath non_drive_path(FILE_PATH_LITERAL("/foo/bar")); | 93 const base::FilePath non_drive_path(FILE_PATH_LITERAL("/foo/bar")); |
| 98 ASSERT_FALSE(util::IsUnderDriveMountPoint(non_drive_path)); | 94 ASSERT_FALSE(util::IsUnderDriveMountPoint(non_drive_path)); |
| 99 | 95 |
| 100 // Call SubstituteDriveDownloadPath() | 96 // Call SubstituteDriveDownloadPath() |
| 101 base::FilePath substituted_path; | 97 base::FilePath substituted_path; |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 download_handler_->CheckForFileExistence( | 248 download_handler_->CheckForFileExistence( |
| 253 &download_item_, | 249 &download_item_, |
| 254 google_apis::test_util::CreateCopyResultCallback(&file_exists)); | 250 google_apis::test_util::CreateCopyResultCallback(&file_exists)); |
| 255 test_util::RunBlockingPoolTask(); | 251 test_util::RunBlockingPoolTask(); |
| 256 | 252 |
| 257 // Check the result. | 253 // Check the result. |
| 258 EXPECT_FALSE(file_exists); | 254 EXPECT_FALSE(file_exists); |
| 259 } | 255 } |
| 260 | 256 |
| 261 } // namespace drive | 257 } // namespace drive |
| OLD | NEW |