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 <sstream> | 5 #include <sstream> |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
(...skipping 881 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
892 | 892 |
893 ASSERT_EQ(url, item->GetOriginalUrl()) << s.str(); | 893 ASSERT_EQ(url, item->GetOriginalUrl()) << s.str(); |
894 | 894 |
895 ASSERT_EQ(download_info.reason, item->GetLastReason()) << s.str(); | 895 ASSERT_EQ(download_info.reason, item->GetLastReason()) << s.str(); |
896 | 896 |
897 if (item->GetState() == content::DownloadItem::COMPLETE) { | 897 if (item->GetState() == content::DownloadItem::COMPLETE) { |
898 // Clean up the file, in case it ended up in the My Documents folder. | 898 // Clean up the file, in case it ended up in the My Documents folder. |
899 base::FilePath destination_folder = GetDownloadDirectory(browser()); | 899 base::FilePath destination_folder = GetDownloadDirectory(browser()); |
900 base::FilePath my_downloaded_file = item->GetTargetFilePath(); | 900 base::FilePath my_downloaded_file = item->GetTargetFilePath(); |
901 EXPECT_TRUE(file_util::PathExists(my_downloaded_file)); | 901 EXPECT_TRUE(file_util::PathExists(my_downloaded_file)); |
902 EXPECT_TRUE(file_util::Delete(my_downloaded_file, false)); | 902 EXPECT_TRUE(base::Delete(my_downloaded_file, false)); |
903 | 903 |
904 EXPECT_EQ(download_info.should_redirect_to_documents ? | 904 EXPECT_EQ(download_info.should_redirect_to_documents ? |
905 std::string::npos : | 905 std::string::npos : |
906 0u, | 906 0u, |
907 my_downloaded_file.value().find(destination_folder.value())); | 907 my_downloaded_file.value().find(destination_folder.value())); |
908 if (download_info.should_redirect_to_documents) { | 908 if (download_info.should_redirect_to_documents) { |
909 // If it's not where we asked it to be, it should be in the | 909 // If it's not where we asked it to be, it should be in the |
910 // My Documents folder. | 910 // My Documents folder. |
911 base::FilePath my_docs_folder; | 911 base::FilePath my_docs_folder; |
912 EXPECT_TRUE(PathService::Get(chrome::DIR_USER_DOCUMENTS, | 912 EXPECT_TRUE(PathService::Get(chrome::DIR_USER_DOCUMENTS, |
(...skipping 2051 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2964 EXPECT_EQ(dir.value(), off_prefs->SaveFilePath().value()); | 2964 EXPECT_EQ(dir.value(), off_prefs->SaveFilePath().value()); |
2965 | 2965 |
2966 off_prefs->SetSaveFilePath(dir.AppendASCII("off")); | 2966 off_prefs->SetSaveFilePath(dir.AppendASCII("off")); |
2967 EXPECT_EQ(dir.value(), on_prefs->SaveFilePath().value()); | 2967 EXPECT_EQ(dir.value(), on_prefs->SaveFilePath().value()); |
2968 EXPECT_EQ(dir.AppendASCII("off").value(), off_prefs->SaveFilePath().value()); | 2968 EXPECT_EQ(dir.AppendASCII("off").value(), off_prefs->SaveFilePath().value()); |
2969 | 2969 |
2970 on_prefs->SetSaveFilePath(dir.AppendASCII("on")); | 2970 on_prefs->SetSaveFilePath(dir.AppendASCII("on")); |
2971 EXPECT_EQ(dir.AppendASCII("on").value(), on_prefs->SaveFilePath().value()); | 2971 EXPECT_EQ(dir.AppendASCII("on").value(), on_prefs->SaveFilePath().value()); |
2972 EXPECT_EQ(dir.AppendASCII("off").value(), off_prefs->SaveFilePath().value()); | 2972 EXPECT_EQ(dir.AppendASCII("off").value(), off_prefs->SaveFilePath().value()); |
2973 } | 2973 } |
OLD | NEW |