| OLD | NEW |
| 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 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 448 EXPECT_TRUE(IsPathInUse(new_target_path)); | 448 EXPECT_TRUE(IsPathInUse(new_target_path)); |
| 449 | 449 |
| 450 // Destroying the item should release the reservation. | 450 // Destroying the item should release the reservation. |
| 451 item.reset(); | 451 item.reset(); |
| 452 message_loop_.RunUntilIdle(); | 452 message_loop_.RunUntilIdle(); |
| 453 EXPECT_FALSE(IsPathInUse(new_target_path)); | 453 EXPECT_FALSE(IsPathInUse(new_target_path)); |
| 454 } | 454 } |
| 455 | 455 |
| 456 // Tests for long name truncation. On other platforms automatic truncation | 456 // Tests for long name truncation. On other platforms automatic truncation |
| 457 // is not performed (yet). | 457 // is not performed (yet). |
| 458 #if defined(OS_WIN) || defined(OS_MAC) || defined(OS_CHROMEOS) | 458 #if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_CHROMEOS) |
| 459 | 459 |
| 460 TEST_F(DownloadPathReservationTrackerTest, BasicTruncation) { | 460 TEST_F(DownloadPathReservationTrackerTest, BasicTruncation) { |
| 461 int real_max_length = | 461 int real_max_length = |
| 462 file_util::GetMaximumPathComponentLength(default_download_path()); | 462 file_util::GetMaximumPathComponentLength(default_download_path()); |
| 463 ASSERT_NE(-1, real_max_length); | 463 ASSERT_NE(-1, real_max_length); |
| 464 | 464 |
| 465 // TODO(kinaba): the current implementation leaves spaces for appending | 465 // TODO(kinaba): the current implementation leaves spaces for appending |
| 466 // ".crdownload". So take it into account. Should be removed in the future. | 466 // ".crdownload". So take it into account. Should be removed in the future. |
| 467 const size_t max_length = real_max_length - 11; | 467 const size_t max_length = real_max_length - 11; |
| 468 | 468 |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 525 ASSERT_FALSE(IsPathInUse(path)); | 525 ASSERT_FALSE(IsPathInUse(path)); |
| 526 | 526 |
| 527 base::FilePath reserved_path; | 527 base::FilePath reserved_path; |
| 528 bool verified = false; | 528 bool verified = false; |
| 529 CallGetReservedPath(*item, path, false, &reserved_path, &verified); | 529 CallGetReservedPath(*item, path, false, &reserved_path, &verified); |
| 530 // We cannot truncate a path with very long extension. | 530 // We cannot truncate a path with very long extension. |
| 531 EXPECT_FALSE(verified); | 531 EXPECT_FALSE(verified); |
| 532 } | 532 } |
| 533 | 533 |
| 534 #endif | 534 #endif |
| OLD | NEW |