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

Side by Side Diff: chrome/browser/download/download_path_reservation_tracker_unittest.cc

Issue 12767006: [Cleanup] Remove StringPrintf from global namespace (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase, once more Created 7 years, 9 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"
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 base::FilePath path( 333 base::FilePath path(
334 GetPathInDownloadsDirectory(FILE_PATH_LITERAL("foo.txt"))); 334 GetPathInDownloadsDirectory(FILE_PATH_LITERAL("foo.txt")));
335 scoped_ptr<FakeDownloadItem> items[ 335 scoped_ptr<FakeDownloadItem> items[
336 DownloadPathReservationTracker::kMaxUniqueFiles + 1]; 336 DownloadPathReservationTracker::kMaxUniqueFiles + 1];
337 // Create |kMaxUniqueFiles + 1| reservations for |path|. The first reservation 337 // Create |kMaxUniqueFiles + 1| reservations for |path|. The first reservation
338 // will have no uniquifier. The |kMaxUniqueFiles| remaining reservations do. 338 // will have no uniquifier. The |kMaxUniqueFiles| remaining reservations do.
339 for (int i = 0; i <= DownloadPathReservationTracker::kMaxUniqueFiles; i++) { 339 for (int i = 0; i <= DownloadPathReservationTracker::kMaxUniqueFiles; i++) {
340 base::FilePath reserved_path; 340 base::FilePath reserved_path;
341 base::FilePath expected_path; 341 base::FilePath expected_path;
342 bool verified = false; 342 bool verified = false;
343 if (i > 0) 343 if (i > 0) {
344 expected_path = path.InsertBeforeExtensionASCII(StringPrintf(" (%d)", i)); 344 expected_path =
345 else 345 path.InsertBeforeExtensionASCII(base::StringPrintf(" (%d)", i));
346 } else {
346 expected_path = path; 347 expected_path = path;
348 }
347 items[i].reset(CreateDownloadItem(i)); 349 items[i].reset(CreateDownloadItem(i));
348 EXPECT_FALSE(IsPathInUse(expected_path)); 350 EXPECT_FALSE(IsPathInUse(expected_path));
349 CallGetReservedPath(*items[i], path, true, &reserved_path, &verified); 351 CallGetReservedPath(*items[i], path, true, &reserved_path, &verified);
350 EXPECT_TRUE(IsPathInUse(expected_path)); 352 EXPECT_TRUE(IsPathInUse(expected_path));
351 EXPECT_EQ(expected_path.value(), reserved_path.value()); 353 EXPECT_EQ(expected_path.value(), reserved_path.value());
352 EXPECT_TRUE(verified); 354 EXPECT_TRUE(verified);
353 } 355 }
354 // The next reservation for |path| will fail to be unique. 356 // The next reservation for |path| will fail to be unique.
355 scoped_ptr<FakeDownloadItem> item( 357 scoped_ptr<FakeDownloadItem> item(
356 CreateDownloadItem(DownloadPathReservationTracker::kMaxUniqueFiles + 1)); 358 CreateDownloadItem(DownloadPathReservationTracker::kMaxUniqueFiles + 1));
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
523 ASSERT_FALSE(IsPathInUse(path)); 525 ASSERT_FALSE(IsPathInUse(path));
524 526
525 base::FilePath reserved_path; 527 base::FilePath reserved_path;
526 bool verified = false; 528 bool verified = false;
527 CallGetReservedPath(*item, path, false, &reserved_path, &verified); 529 CallGetReservedPath(*item, path, false, &reserved_path, &verified);
528 // We cannot truncate a path with very long extension. 530 // We cannot truncate a path with very long extension.
529 EXPECT_FALSE(verified); 531 EXPECT_FALSE(verified);
530 } 532 }
531 533
532 #endif 534 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698