| 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/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| (...skipping 942 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 953 | 953 |
| 954 ASSERT_EQ(url, item->GetOriginalUrl()) << s.str(); | 954 ASSERT_EQ(url, item->GetOriginalUrl()) << s.str(); |
| 955 | 955 |
| 956 ASSERT_EQ(download_info.reason, item->GetLastReason()) << s.str(); | 956 ASSERT_EQ(download_info.reason, item->GetLastReason()) << s.str(); |
| 957 | 957 |
| 958 if (item->GetState() == content::DownloadItem::COMPLETE) { | 958 if (item->GetState() == content::DownloadItem::COMPLETE) { |
| 959 // Clean up the file, in case it ended up in the My Documents folder. | 959 // Clean up the file, in case it ended up in the My Documents folder. |
| 960 base::FilePath destination_folder = GetDownloadDirectory(browser()); | 960 base::FilePath destination_folder = GetDownloadDirectory(browser()); |
| 961 base::FilePath my_downloaded_file = item->GetTargetFilePath(); | 961 base::FilePath my_downloaded_file = item->GetTargetFilePath(); |
| 962 EXPECT_TRUE(base::PathExists(my_downloaded_file)); | 962 EXPECT_TRUE(base::PathExists(my_downloaded_file)); |
| 963 EXPECT_TRUE(base::Delete(my_downloaded_file, false)); | 963 EXPECT_TRUE(base::DeleteFile(my_downloaded_file, false)); |
| 964 | 964 |
| 965 EXPECT_EQ(download_info.should_redirect_to_documents ? | 965 EXPECT_EQ(download_info.should_redirect_to_documents ? |
| 966 std::string::npos : | 966 std::string::npos : |
| 967 0u, | 967 0u, |
| 968 my_downloaded_file.value().find(destination_folder.value())); | 968 my_downloaded_file.value().find(destination_folder.value())); |
| 969 if (download_info.should_redirect_to_documents) { | 969 if (download_info.should_redirect_to_documents) { |
| 970 // If it's not where we asked it to be, it should be in the | 970 // If it's not where we asked it to be, it should be in the |
| 971 // My Documents folder. | 971 // My Documents folder. |
| 972 base::FilePath my_docs_folder; | 972 base::FilePath my_docs_folder; |
| 973 EXPECT_TRUE(PathService::Get(chrome::DIR_USER_DOCUMENTS, | 973 EXPECT_TRUE(PathService::Get(chrome::DIR_USER_DOCUMENTS, |
| (...skipping 2253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3227 | 3227 |
| 3228 // No errors this time. The download should complete successfully. | 3228 // No errors this time. The download should complete successfully. |
| 3229 EXPECT_FALSE(completion_observer->IsFinished()); | 3229 EXPECT_FALSE(completion_observer->IsFinished()); |
| 3230 completion_observer->StartObserving(); | 3230 completion_observer->StartObserving(); |
| 3231 download->Resume(); | 3231 download->Resume(); |
| 3232 completion_observer->WaitForFinished(); | 3232 completion_observer->WaitForFinished(); |
| 3233 EXPECT_EQ(DownloadItem::COMPLETE, download->GetState()); | 3233 EXPECT_EQ(DownloadItem::COMPLETE, download->GetState()); |
| 3234 | 3234 |
| 3235 EXPECT_FALSE(DidShowFileChooser()); | 3235 EXPECT_FALSE(DidShowFileChooser()); |
| 3236 } | 3236 } |
| OLD | NEW |