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

Side by Side Diff: chrome/browser/chromeos/drive/download_handler_unittest.cc

Issue 2318023002: //chrome/browser/chromeos: Change ScopedTempDir::path() to GetPath() (Closed)
Patch Set: Just rebased Created 4 years, 3 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
OLDNEW
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 <stdint.h> 7 #include <stdint.h>
8 8
9 #include "base/files/scoped_temp_dir.h" 9 #include "base/files/scoped_temp_dir.h"
10 #include "base/run_loop.h" 10 #include "base/run_loop.h"
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 : download_manager_(new DownloadHandlerTestDownloadManager) {} 92 : download_manager_(new DownloadHandlerTestDownloadManager) {}
93 93
94 void SetUp() override { 94 void SetUp() override {
95 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); 95 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
96 96
97 // Set expectations for download item. 97 // Set expectations for download item.
98 EXPECT_CALL(download_item_, GetState()) 98 EXPECT_CALL(download_item_, GetState())
99 .WillRepeatedly(testing::Return(content::DownloadItem::IN_PROGRESS)); 99 .WillRepeatedly(testing::Return(content::DownloadItem::IN_PROGRESS));
100 100
101 download_handler_.reset(new DownloadHandler(&test_file_system_)); 101 download_handler_.reset(new DownloadHandler(&test_file_system_));
102 download_handler_->Initialize(download_manager_.get(), temp_dir_.path()); 102 download_handler_->Initialize(download_manager_.get(), temp_dir_.GetPath());
103 download_handler_->SetFreeDiskSpaceDelayForTesting( 103 download_handler_->SetFreeDiskSpaceDelayForTesting(
104 base::TimeDelta::FromMilliseconds(0)); 104 base::TimeDelta::FromMilliseconds(0));
105 } 105 }
106 106
107 protected: 107 protected:
108 base::ScopedTempDir temp_dir_; 108 base::ScopedTempDir temp_dir_;
109 content::TestBrowserThreadBundle thread_bundle_; 109 content::TestBrowserThreadBundle thread_bundle_;
110 TestingProfile profile_; 110 TestingProfile profile_;
111 std::unique_ptr<DownloadHandlerTestDownloadManager> download_manager_; 111 std::unique_ptr<DownloadHandlerTestDownloadManager> download_manager_;
112 std::unique_ptr<DownloadHandlerTestDownloadManager> 112 std::unique_ptr<DownloadHandlerTestDownloadManager>
(...skipping 29 matching lines...) Expand all
142 142
143 // Call SubstituteDriveDownloadPath() 143 // Call SubstituteDriveDownloadPath()
144 base::FilePath substituted_path; 144 base::FilePath substituted_path;
145 download_handler_->SubstituteDriveDownloadPath( 145 download_handler_->SubstituteDriveDownloadPath(
146 drive_path, 146 drive_path,
147 &download_item_, 147 &download_item_,
148 google_apis::test_util::CreateCopyResultCallback(&substituted_path)); 148 google_apis::test_util::CreateCopyResultCallback(&substituted_path));
149 content::RunAllBlockingPoolTasksUntilIdle(); 149 content::RunAllBlockingPoolTasksUntilIdle();
150 150
151 // Check the result. 151 // Check the result.
152 EXPECT_TRUE(temp_dir_.path().IsParent(substituted_path)); 152 EXPECT_TRUE(temp_dir_.GetPath().IsParent(substituted_path));
153 ASSERT_TRUE(download_handler_->IsDriveDownload(&download_item_)); 153 ASSERT_TRUE(download_handler_->IsDriveDownload(&download_item_));
154 EXPECT_EQ(drive_path, download_handler_->GetTargetPath(&download_item_)); 154 EXPECT_EQ(drive_path, download_handler_->GetTargetPath(&download_item_));
155 } 155 }
156 156
157 TEST_F(DownloadHandlerTest, SubstituteDriveDownloadPathGetEntryFailure) { 157 TEST_F(DownloadHandlerTest, SubstituteDriveDownloadPathGetEntryFailure) {
158 const base::FilePath drive_path = 158 const base::FilePath drive_path =
159 util::GetDriveMountPointPath(&profile_).AppendASCII("test.dat"); 159 util::GetDriveMountPointPath(&profile_).AppendASCII("test.dat");
160 160
161 // Test the case that access to the download target directory failed for some 161 // Test the case that access to the download target directory failed for some
162 // reason. 162 // reason.
(...skipping 20 matching lines...) Expand all
183 183
184 // Call SubstituteDriveDownloadPath() 184 // Call SubstituteDriveDownloadPath()
185 base::FilePath substituted_path; 185 base::FilePath substituted_path;
186 download_handler_->SubstituteDriveDownloadPath( 186 download_handler_->SubstituteDriveDownloadPath(
187 drive_path, 187 drive_path,
188 NULL, // DownloadItem is not available at this moment. 188 NULL, // DownloadItem is not available at this moment.
189 google_apis::test_util::CreateCopyResultCallback(&substituted_path)); 189 google_apis::test_util::CreateCopyResultCallback(&substituted_path));
190 content::RunAllBlockingPoolTasksUntilIdle(); 190 content::RunAllBlockingPoolTasksUntilIdle();
191 191
192 // Check the result of SubstituteDriveDownloadPath(). 192 // Check the result of SubstituteDriveDownloadPath().
193 EXPECT_TRUE(temp_dir_.path().IsParent(substituted_path)); 193 EXPECT_TRUE(temp_dir_.GetPath().IsParent(substituted_path));
194 194
195 // |download_item_| is not a drive download yet. 195 // |download_item_| is not a drive download yet.
196 EXPECT_FALSE(download_handler_->IsDriveDownload(&download_item_)); 196 EXPECT_FALSE(download_handler_->IsDriveDownload(&download_item_));
197 197
198 // Call SetDownloadParams(). 198 // Call SetDownloadParams().
199 download_handler_->SetDownloadParams(drive_path, &download_item_); 199 download_handler_->SetDownloadParams(drive_path, &download_item_);
200 200
201 // |download_item_| is a drive download now. 201 // |download_item_| is a drive download now.
202 ASSERT_TRUE(download_handler_->IsDriveDownload(&download_item_)); 202 ASSERT_TRUE(download_handler_->IsDriveDownload(&download_item_));
203 EXPECT_EQ(drive_path, download_handler_->GetTargetPath(&download_item_)); 203 EXPECT_EQ(drive_path, download_handler_->GetTargetPath(&download_item_));
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 download_item_d.is_done_ = false; 348 download_item_d.is_done_ = false;
349 download_item_d.total_bytes_ = 0; 349 download_item_d.total_bytes_ = 0;
350 downloads.push_back(&download_item_d); 350 downloads.push_back(&download_item_d);
351 351
352 // Unknown size downloads should be counted as 0 byte. 352 // Unknown size downloads should be counted as 0 byte.
353 ASSERT_EQ(download_item_a.total_bytes_ - download_item_a.received_bytes_, 353 ASSERT_EQ(download_item_a.total_bytes_ - download_item_a.received_bytes_,
354 download_handler_->CalculateRequestSpace(downloads)); 354 download_handler_->CalculateRequestSpace(downloads));
355 } 355 }
356 356
357 } // namespace drive 357 } // namespace drive
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698