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 12 matching lines...) Expand all Loading... |
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 virtual void GetResourceEntry( |
32 const base::FilePath& file_path, | 32 const base::FilePath& file_path, |
33 const GetResourceEntryCallback& callback) OVERRIDE { | 33 const GetResourceEntryCallback& callback) override { |
34 callback.Run(error_, scoped_ptr<ResourceEntry>( | 34 callback.Run(error_, scoped_ptr<ResourceEntry>( |
35 error_ == FILE_ERROR_OK ? new ResourceEntry : NULL)); | 35 error_ == FILE_ERROR_OK ? new ResourceEntry : NULL)); |
36 } | 36 } |
37 | 37 |
38 virtual void CreateDirectory( | 38 virtual void CreateDirectory( |
39 const base::FilePath& directory_path, | 39 const base::FilePath& directory_path, |
40 bool is_exclusive, | 40 bool is_exclusive, |
41 bool is_recursive, | 41 bool is_recursive, |
42 const FileOperationCallback& callback) OVERRIDE { | 42 const FileOperationCallback& callback) override { |
43 callback.Run(error_); | 43 callback.Run(error_); |
44 } | 44 } |
45 | 45 |
46 private: | 46 private: |
47 FileError error_; | 47 FileError error_; |
48 }; | 48 }; |
49 | 49 |
50 } // namespace | 50 } // namespace |
51 | 51 |
52 class DownloadHandlerTest : public testing::Test { | 52 class DownloadHandlerTest : public testing::Test { |
53 public: | 53 public: |
54 DownloadHandlerTest() | 54 DownloadHandlerTest() |
55 : download_manager_(new content::MockDownloadManager) {} | 55 : download_manager_(new content::MockDownloadManager) {} |
56 | 56 |
57 virtual void SetUp() OVERRIDE { | 57 virtual void SetUp() override { |
58 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 58 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
59 | 59 |
60 // Set expectations for download item. | 60 // Set expectations for download item. |
61 EXPECT_CALL(download_item_, GetState()) | 61 EXPECT_CALL(download_item_, GetState()) |
62 .WillRepeatedly(testing::Return(content::DownloadItem::IN_PROGRESS)); | 62 .WillRepeatedly(testing::Return(content::DownloadItem::IN_PROGRESS)); |
63 | 63 |
64 download_handler_.reset(new DownloadHandler(&test_file_system_)); | 64 download_handler_.reset(new DownloadHandler(&test_file_system_)); |
65 download_handler_->Initialize(download_manager_.get(), temp_dir_.path()); | 65 download_handler_->Initialize(download_manager_.get(), temp_dir_.path()); |
66 } | 66 } |
67 | 67 |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 download_handler_->CheckForFileExistence( | 191 download_handler_->CheckForFileExistence( |
192 &download_item_, | 192 &download_item_, |
193 google_apis::test_util::CreateCopyResultCallback(&file_exists)); | 193 google_apis::test_util::CreateCopyResultCallback(&file_exists)); |
194 content::RunAllBlockingPoolTasksUntilIdle(); | 194 content::RunAllBlockingPoolTasksUntilIdle(); |
195 | 195 |
196 // Check the result. | 196 // Check the result. |
197 EXPECT_FALSE(file_exists); | 197 EXPECT_FALSE(file_exists); |
198 } | 198 } |
199 | 199 |
200 } // namespace drive | 200 } // namespace drive |
OLD | NEW |