| 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 // This file contains download browser tests that are known to be runnable | 5 // This file contains download browser tests that are known to be runnable |
| 6 // in a pure content context. Over time tests should be migrated here. | 6 // in a pure content context. Over time tests should be migrated here. |
| 7 | 7 |
| 8 #include <stddef.h> |
| 9 #include <stdint.h> |
| 10 |
| 8 #include <vector> | 11 #include <vector> |
| 9 | 12 |
| 10 #include "base/callback_helpers.h" | 13 #include "base/callback_helpers.h" |
| 11 #include "base/feature_list.h" | 14 #include "base/feature_list.h" |
| 12 #include "base/files/file_path.h" | 15 #include "base/files/file_path.h" |
| 13 #include "base/files/file_util.h" | 16 #include "base/files/file_util.h" |
| 14 #include "base/files/scoped_temp_dir.h" | 17 #include "base/files/scoped_temp_dir.h" |
| 15 #include "base/format_macros.h" | 18 #include "base/format_macros.h" |
| 19 #include "base/macros.h" |
| 16 #include "base/memory/ref_counted.h" | 20 #include "base/memory/ref_counted.h" |
| 17 #include "base/strings/stringprintf.h" | 21 #include "base/strings/stringprintf.h" |
| 18 #include "base/strings/utf_string_conversions.h" | 22 #include "base/strings/utf_string_conversions.h" |
| 19 #include "base/threading/platform_thread.h" | 23 #include "base/threading/platform_thread.h" |
| 20 #include "base/time/time.h" | 24 #include "base/time/time.h" |
| 25 #include "build/build_config.h" |
| 21 #include "content/browser/byte_stream.h" | 26 #include "content/browser/byte_stream.h" |
| 22 #include "content/browser/download/download_file_factory.h" | 27 #include "content/browser/download/download_file_factory.h" |
| 23 #include "content/browser/download/download_file_impl.h" | 28 #include "content/browser/download/download_file_impl.h" |
| 24 #include "content/browser/download/download_item_impl.h" | 29 #include "content/browser/download/download_item_impl.h" |
| 25 #include "content/browser/download/download_manager_impl.h" | 30 #include "content/browser/download/download_manager_impl.h" |
| 26 #include "content/browser/download/download_resource_handler.h" | 31 #include "content/browser/download/download_resource_handler.h" |
| 27 #include "content/browser/web_contents/web_contents_impl.h" | 32 #include "content/browser/web_contents/web_contents_impl.h" |
| 28 #include "content/public/browser/power_save_blocker.h" | 33 #include "content/public/browser/power_save_blocker.h" |
| 29 #include "content/public/common/content_features.h" | 34 #include "content/public/common/content_features.h" |
| 30 #include "content/public/common/webplugininfo.h" | 35 #include "content/public/common/webplugininfo.h" |
| (...skipping 579 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 610 scoped_ptr<DownloadTestObserver> observer(CreateWaiter(shell, 1)); | 615 scoped_ptr<DownloadTestObserver> observer(CreateWaiter(shell, 1)); |
| 611 NavigateToURL(shell, url); | 616 NavigateToURL(shell, url); |
| 612 observer->WaitForFinished(); | 617 observer->WaitForFinished(); |
| 613 EXPECT_EQ(1u, observer->NumDownloadsSeenInState(expected_terminal_state)); | 618 EXPECT_EQ(1u, observer->NumDownloadsSeenInState(expected_terminal_state)); |
| 614 } | 619 } |
| 615 | 620 |
| 616 // Checks that |path| is has |file_size| bytes, and matches the |value| | 621 // Checks that |path| is has |file_size| bytes, and matches the |value| |
| 617 // string. | 622 // string. |
| 618 bool VerifyFile(const base::FilePath& path, | 623 bool VerifyFile(const base::FilePath& path, |
| 619 const std::string& value, | 624 const std::string& value, |
| 620 const int64 file_size) { | 625 const int64_t file_size) { |
| 621 std::string file_contents; | 626 std::string file_contents; |
| 622 | 627 |
| 623 bool read = base::ReadFileToString(path, &file_contents); | 628 bool read = base::ReadFileToString(path, &file_contents); |
| 624 EXPECT_TRUE(read) << "Failed reading file: " << path.value() << std::endl; | 629 EXPECT_TRUE(read) << "Failed reading file: " << path.value() << std::endl; |
| 625 if (!read) | 630 if (!read) |
| 626 return false; // Couldn't read the file. | 631 return false; // Couldn't read the file. |
| 627 | 632 |
| 628 // Note: we don't handle really large files (more than size_t can hold) | 633 // Note: we don't handle really large files (more than size_t can hold) |
| 629 // so we will fail in that case. | 634 // so we will fail in that case. |
| 630 size_t expected_size = static_cast<size_t>(file_size); | 635 size_t expected_size = static_cast<size_t>(file_size); |
| (...skipping 1166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1797 | 1802 |
| 1798 std::vector<DownloadItem*> downloads; | 1803 std::vector<DownloadItem*> downloads; |
| 1799 DownloadManagerForShell(shell())->GetAllDownloads(&downloads); | 1804 DownloadManagerForShell(shell())->GetAllDownloads(&downloads); |
| 1800 ASSERT_EQ(1u, downloads.size()); | 1805 ASSERT_EQ(1u, downloads.size()); |
| 1801 | 1806 |
| 1802 EXPECT_EQ(FILE_PATH_LITERAL("Jumboshrimp.txt"), | 1807 EXPECT_EQ(FILE_PATH_LITERAL("Jumboshrimp.txt"), |
| 1803 downloads[0]->GetTargetFilePath().BaseName().value()); | 1808 downloads[0]->GetTargetFilePath().BaseName().value()); |
| 1804 } | 1809 } |
| 1805 | 1810 |
| 1806 } // namespace content | 1811 } // namespace content |
| OLD | NEW |