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/download/download_path_reservation_tracker_unittest.cc

Issue 14625016: downloads: Make GetCrDownloadPath a static method on DownloadTargetDeterminer. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 7 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 "base/file_util.h" 5 #include "base/file_util.h"
6 #include "base/files/file_path.h" 6 #include "base/files/file_path.h"
7 #include "base/files/scoped_temp_dir.h" 7 #include "base/files/scoped_temp_dir.h"
8 #include "base/memory/weak_ptr.h" 8 #include "base/memory/weak_ptr.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/observer_list.h" 10 #include "base/observer_list.h"
11 #include "base/test/test_file_util.h" 11 #include "base/test/test_file_util.h"
12 #include "chrome/browser/download/download_path_reservation_tracker.h" 12 #include "chrome/browser/download/download_path_reservation_tracker.h"
13 #include "chrome/browser/download/download_util.h" 13 #include "chrome/browser/download/download_target_determiner.h"
14 #include "content/public/test/mock_download_item.h" 14 #include "content/public/test/mock_download_item.h"
15 #include "content/public/test/test_browser_thread.h" 15 #include "content/public/test/test_browser_thread.h"
16 #include "testing/gmock/include/gmock/gmock.h" 16 #include "testing/gmock/include/gmock/gmock.h"
17 #include "testing/gtest/include/gtest/gtest.h" 17 #include "testing/gtest/include/gtest/gtest.h"
18 18
19 using content::BrowserThread; 19 using content::BrowserThread;
20 using content::DownloadId; 20 using content::DownloadId;
21 using content::DownloadItem; 21 using content::DownloadItem;
22 using content::MockDownloadItem; 22 using content::MockDownloadItem;
23 using testing::AnyNumber; 23 using testing::AnyNumber;
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 // If there are files on the file system, a unique reservation should uniquify 275 // If there are files on the file system, a unique reservation should uniquify
276 // around it. 276 // around it.
277 TEST_F(DownloadPathReservationTrackerTest, ConflictingFiles) { 277 TEST_F(DownloadPathReservationTrackerTest, ConflictingFiles) {
278 scoped_ptr<FakeDownloadItem> item(CreateDownloadItem(1)); 278 scoped_ptr<FakeDownloadItem> item(CreateDownloadItem(1));
279 base::FilePath path( 279 base::FilePath path(
280 GetPathInDownloadsDirectory(FILE_PATH_LITERAL("foo.txt"))); 280 GetPathInDownloadsDirectory(FILE_PATH_LITERAL("foo.txt")));
281 base::FilePath path1( 281 base::FilePath path1(
282 GetPathInDownloadsDirectory(FILE_PATH_LITERAL("foo (1).txt"))); 282 GetPathInDownloadsDirectory(FILE_PATH_LITERAL("foo (1).txt")));
283 // Create a file at |path|, and a .crdownload file at |path1|. 283 // Create a file at |path|, and a .crdownload file at |path1|.
284 ASSERT_EQ(0, file_util::WriteFile(path, "", 0)); 284 ASSERT_EQ(0, file_util::WriteFile(path, "", 0));
285 ASSERT_EQ(0, file_util::WriteFile(download_util::GetCrDownloadPath(path1), 285 ASSERT_EQ(0,
286 "", 0)); 286 file_util::WriteFile(
287 DownloadTargetDeterminer::GetCrDownloadPath(path1), "", 0));
287 ASSERT_TRUE(IsPathInUse(path)); 288 ASSERT_TRUE(IsPathInUse(path));
288 289
289 base::FilePath reserved_path; 290 base::FilePath reserved_path;
290 bool verified = false; 291 bool verified = false;
291 bool create_directory = false; 292 bool create_directory = false;
292 DownloadPathReservationTracker::FilenameConflictAction conflict_action = 293 DownloadPathReservationTracker::FilenameConflictAction conflict_action =
293 DownloadPathReservationTracker::UNIQUIFY; 294 DownloadPathReservationTracker::UNIQUIFY;
294 CallGetReservedPath( 295 CallGetReservedPath(
295 *item, 296 *item,
296 path, 297 path,
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after
670 path, 671 path,
671 create_directory, 672 create_directory,
672 conflict_action, 673 conflict_action,
673 &reserved_path, 674 &reserved_path,
674 &verified); 675 &verified);
675 // We cannot truncate a path with very long extension. 676 // We cannot truncate a path with very long extension.
676 EXPECT_FALSE(verified); 677 EXPECT_FALSE(verified);
677 } 678 }
678 679
679 #endif 680 #endif
OLDNEW
« no previous file with comments | « chrome/browser/download/download_browsertest.cc ('k') | chrome/browser/download/download_target_determiner.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698