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/test/base/testing_profile.h" | 10 #include "chrome/test/base/testing_profile.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 | 21 |
22 // Test file system for verifying the behavior of DownloadHandler, by simulating | 22 // Test file system for verifying the behavior of DownloadHandler, by simulating |
23 // various responses from FileSystem. | 23 // various responses from FileSystem. |
24 class DownloadHandlerTestFileSystem : public DummyFileSystem { | 24 class DownloadHandlerTestFileSystem : public DummyFileSystem { |
25 public: | 25 public: |
26 DownloadHandlerTestFileSystem() : error_(FILE_ERROR_FAILED) {} | 26 DownloadHandlerTestFileSystem() : error_(FILE_ERROR_FAILED) {} |
27 | 27 |
28 void set_error(FileError error) { error_ = error; } | 28 void set_error(FileError error) { error_ = error; } |
29 | 29 |
30 // FileSystemInterface overrides. | 30 // FileSystemInterface overrides. |
31 virtual void GetResourceEntry( | 31 void GetResourceEntry(const base::FilePath& file_path, |
32 const base::FilePath& file_path, | 32 const GetResourceEntryCallback& callback) override { |
33 const GetResourceEntryCallback& callback) override { | |
34 callback.Run(error_, scoped_ptr<ResourceEntry>( | 33 callback.Run(error_, scoped_ptr<ResourceEntry>( |
35 error_ == FILE_ERROR_OK ? new ResourceEntry : NULL)); | 34 error_ == FILE_ERROR_OK ? new ResourceEntry : NULL)); |
36 } | 35 } |
37 | 36 |
38 virtual void CreateDirectory( | 37 void CreateDirectory(const base::FilePath& directory_path, |
39 const base::FilePath& directory_path, | 38 bool is_exclusive, |
40 bool is_exclusive, | 39 bool is_recursive, |
41 bool is_recursive, | 40 const FileOperationCallback& callback) override { |
42 const FileOperationCallback& callback) override { | |
43 callback.Run(error_); | 41 callback.Run(error_); |
44 } | 42 } |
45 | 43 |
46 private: | 44 private: |
47 FileError error_; | 45 FileError error_; |
48 }; | 46 }; |
49 | 47 |
50 } // namespace | 48 } // namespace |
51 | 49 |
52 class DownloadHandlerTest : public testing::Test { | 50 class DownloadHandlerTest : public testing::Test { |
53 public: | 51 public: |
54 DownloadHandlerTest() | 52 DownloadHandlerTest() |
55 : download_manager_(new content::MockDownloadManager) {} | 53 : download_manager_(new content::MockDownloadManager) {} |
56 | 54 |
57 virtual void SetUp() override { | 55 void SetUp() override { |
58 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 56 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
59 | 57 |
60 // Set expectations for download item. | 58 // Set expectations for download item. |
61 EXPECT_CALL(download_item_, GetState()) | 59 EXPECT_CALL(download_item_, GetState()) |
62 .WillRepeatedly(testing::Return(content::DownloadItem::IN_PROGRESS)); | 60 .WillRepeatedly(testing::Return(content::DownloadItem::IN_PROGRESS)); |
63 | 61 |
64 download_handler_.reset(new DownloadHandler(&test_file_system_)); | 62 download_handler_.reset(new DownloadHandler(&test_file_system_)); |
65 download_handler_->Initialize(download_manager_.get(), temp_dir_.path()); | 63 download_handler_->Initialize(download_manager_.get(), temp_dir_.path()); |
66 } | 64 } |
67 | 65 |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 download_handler_->CheckForFileExistence( | 189 download_handler_->CheckForFileExistence( |
192 &download_item_, | 190 &download_item_, |
193 google_apis::test_util::CreateCopyResultCallback(&file_exists)); | 191 google_apis::test_util::CreateCopyResultCallback(&file_exists)); |
194 content::RunAllBlockingPoolTasksUntilIdle(); | 192 content::RunAllBlockingPoolTasksUntilIdle(); |
195 | 193 |
196 // Check the result. | 194 // Check the result. |
197 EXPECT_FALSE(file_exists); | 195 EXPECT_FALSE(file_exists); |
198 } | 196 } |
199 | 197 |
200 } // namespace drive | 198 } // namespace drive |
OLD | NEW |