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 <stddef.h> | 5 #include <stddef.h> |
6 #include <stdint.h> | 6 #include <stdint.h> |
7 | 7 |
8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
10 #include "base/files/scoped_temp_dir.h" | 10 #include "base/files/scoped_temp_dir.h" |
11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
12 #include "base/message_loop/message_loop.h" | 12 #include "base/message_loop/message_loop.h" |
13 #include "base/observer_list.h" | 13 #include "base/observer_list.h" |
14 #include "base/run_loop.h" | 14 #include "base/run_loop.h" |
15 #include "base/strings/stringprintf.h" | 15 #include "base/strings/stringprintf.h" |
16 #include "base/test/test_file_util.h" | 16 #include "base/test/test_file_util.h" |
17 #include "build/build_config.h" | 17 #include "build/build_config.h" |
18 #include "chrome/browser/download/download_path_reservation_tracker.h" | 18 #include "chrome/browser/download/download_path_reservation_tracker.h" |
19 #include "chrome/browser/download/download_target_determiner.h" | 19 #include "chrome/browser/download/download_target_determiner.h" |
20 #include "chrome/common/features.h" | |
21 #include "content/public/test/mock_download_item.h" | 20 #include "content/public/test/mock_download_item.h" |
22 #include "content/public/test/test_browser_thread.h" | 21 #include "content/public/test/test_browser_thread.h" |
23 #include "testing/gmock/include/gmock/gmock.h" | 22 #include "testing/gmock/include/gmock/gmock.h" |
24 #include "testing/gtest/include/gtest/gtest.h" | 23 #include "testing/gtest/include/gtest/gtest.h" |
25 | 24 |
26 using content::BrowserThread; | 25 using content::BrowserThread; |
27 using content::DownloadItem; | 26 using content::DownloadItem; |
28 using content::MockDownloadItem; | 27 using content::MockDownloadItem; |
29 using testing::AnyNumber; | 28 using testing::AnyNumber; |
30 using testing::Return; | 29 using testing::Return; |
(...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
496 bool create_directory = false; | 495 bool create_directory = false; |
497 CallGetReservedPath( | 496 CallGetReservedPath( |
498 item.get(), | 497 item.get(), |
499 path, | 498 path, |
500 create_directory, | 499 create_directory, |
501 conflict_action, | 500 conflict_action, |
502 &reserved_path, | 501 &reserved_path, |
503 &verified); | 502 &verified); |
504 // Verification fails. | 503 // Verification fails. |
505 EXPECT_FALSE(verified); | 504 EXPECT_FALSE(verified); |
506 #if BUILDFLAG(ANDROID_JAVA_UI) | 505 #if defined(OS_ANDROID) |
507 EXPECT_TRUE(reserved_path.empty()); | 506 EXPECT_TRUE(reserved_path.empty()); |
508 #else | 507 #else |
509 EXPECT_EQ(path.BaseName().value(), reserved_path.BaseName().value()); | 508 EXPECT_EQ(path.BaseName().value(), reserved_path.BaseName().value()); |
510 #endif | 509 #endif |
511 } | 510 } |
512 SetDownloadItemState(item.get(), DownloadItem::COMPLETE); | 511 SetDownloadItemState(item.get(), DownloadItem::COMPLETE); |
513 } | 512 } |
514 | 513 |
515 // If the default download directory doesn't exist, then it should be | 514 // If the default download directory doesn't exist, then it should be |
516 // created. But only if we are actually going to create the download path there. | 515 // created. But only if we are actually going to create the download path there. |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
709 create_directory, | 708 create_directory, |
710 conflict_action, | 709 conflict_action, |
711 &reserved_path, | 710 &reserved_path, |
712 &verified); | 711 &verified); |
713 // We cannot truncate a path with very long extension. | 712 // We cannot truncate a path with very long extension. |
714 EXPECT_FALSE(verified); | 713 EXPECT_FALSE(verified); |
715 SetDownloadItemState(item.get(), DownloadItem::COMPLETE); | 714 SetDownloadItemState(item.get(), DownloadItem::COMPLETE); |
716 } | 715 } |
717 | 716 |
718 #endif // Platforms that support filename truncation. | 717 #endif // Platforms that support filename truncation. |
OLD | NEW |