| 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 <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/callback_helpers.h" | 10 #include "base/callback_helpers.h" |
| 11 #include "base/command_line.h" | 11 #include "base/feature_list.h" |
| 12 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
| 13 #include "base/files/file_util.h" | 13 #include "base/files/file_util.h" |
| 14 #include "base/files/scoped_temp_dir.h" | 14 #include "base/files/scoped_temp_dir.h" |
| 15 #include "base/format_macros.h" | 15 #include "base/format_macros.h" |
| 16 #include "base/memory/ref_counted.h" | 16 #include "base/memory/ref_counted.h" |
| 17 #include "base/strings/stringprintf.h" | 17 #include "base/strings/stringprintf.h" |
| 18 #include "base/strings/utf_string_conversions.h" | 18 #include "base/strings/utf_string_conversions.h" |
| 19 #include "base/threading/platform_thread.h" | 19 #include "base/threading/platform_thread.h" |
| 20 #include "base/time/time.h" | 20 #include "base/time/time.h" |
| 21 #include "content/browser/byte_stream.h" | 21 #include "content/browser/byte_stream.h" |
| 22 #include "content/browser/download/download_file_factory.h" | 22 #include "content/browser/download/download_file_factory.h" |
| 23 #include "content/browser/download/download_file_impl.h" | 23 #include "content/browser/download/download_file_impl.h" |
| 24 #include "content/browser/download/download_item_impl.h" | 24 #include "content/browser/download/download_item_impl.h" |
| 25 #include "content/browser/download/download_manager_impl.h" | 25 #include "content/browser/download/download_manager_impl.h" |
| 26 #include "content/browser/download/download_resource_handler.h" | 26 #include "content/browser/download/download_resource_handler.h" |
| 27 #include "content/browser/web_contents/web_contents_impl.h" | 27 #include "content/browser/web_contents/web_contents_impl.h" |
| 28 #include "content/public/browser/power_save_blocker.h" | 28 #include "content/public/browser/power_save_blocker.h" |
| 29 #include "content/public/common/content_switches.h" | 29 #include "content/public/common/content_features.h" |
| 30 #include "content/public/common/webplugininfo.h" | 30 #include "content/public/common/webplugininfo.h" |
| 31 #include "content/public/test/browser_test_utils.h" | 31 #include "content/public/test/browser_test_utils.h" |
| 32 #include "content/public/test/content_browser_test.h" | 32 #include "content/public/test/content_browser_test.h" |
| 33 #include "content/public/test/content_browser_test_utils.h" | 33 #include "content/public/test/content_browser_test_utils.h" |
| 34 #include "content/public/test/download_test_observer.h" | 34 #include "content/public/test/download_test_observer.h" |
| 35 #include "content/public/test/test_download_request_handler.h" | 35 #include "content/public/test/test_download_request_handler.h" |
| 36 #include "content/public/test/test_file_error_injector.h" | 36 #include "content/public/test/test_file_error_injector.h" |
| 37 #include "content/public/test/test_utils.h" | 37 #include "content/public/test/test_utils.h" |
| 38 #include "content/shell/browser/shell.h" | 38 #include "content/shell/browser/shell.h" |
| 39 #include "content/shell/browser/shell_browser_context.h" | 39 #include "content/shell/browser/shell_browser_context.h" |
| (...skipping 662 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 702 // run once with RESUME_WITH_RENDERER and once with RESUME_WITHOUT_RENDERER. | 702 // run once with RESUME_WITH_RENDERER and once with RESUME_WITHOUT_RENDERER. |
| 703 // Use initiator_shell_for_resumption() to retrieve the Shell object that should | 703 // Use initiator_shell_for_resumption() to retrieve the Shell object that should |
| 704 // be used as the originator for the initial download. Prior to calling | 704 // be used as the originator for the initial download. Prior to calling |
| 705 // Resume(), call PrepareToResume() which will cause the originating Shell to be | 705 // Resume(), call PrepareToResume() which will cause the originating Shell to be |
| 706 // deleted if the test parameter is RESUME_WITHOUT_RENDERER. | 706 // deleted if the test parameter is RESUME_WITHOUT_RENDERER. |
| 707 class DownloadResumptionContentTest | 707 class DownloadResumptionContentTest |
| 708 : public DownloadContentTest, | 708 : public DownloadContentTest, |
| 709 public ::testing::WithParamInterface<DownloadResumptionTestType> { | 709 public ::testing::WithParamInterface<DownloadResumptionTestType> { |
| 710 public: | 710 public: |
| 711 void SetUpOnMainThread() override { | 711 void SetUpOnMainThread() override { |
| 712 base::CommandLine::ForCurrentProcess()->AppendSwitch( | 712 base::FeatureList::ClearInstanceForTesting(); |
| 713 switches::kEnableDownloadResumption); | 713 scoped_ptr<base::FeatureList> feature_list(new base::FeatureList); |
| 714 feature_list->InitializeFromCommandLine( |
| 715 features::kDownloadResumption.name, std::string()); |
| 716 base::FeatureList::SetInstance(std::move(feature_list)); |
| 717 |
| 714 DownloadContentTest::SetUpOnMainThread(); | 718 DownloadContentTest::SetUpOnMainThread(); |
| 715 | 719 |
| 716 if (GetParam() == DownloadResumptionTestType::RESUME_WITHOUT_RENDERER) | 720 if (GetParam() == DownloadResumptionTestType::RESUME_WITHOUT_RENDERER) |
| 717 initiator_shell_for_resumption_ = CreateBrowser(); | 721 initiator_shell_for_resumption_ = CreateBrowser(); |
| 718 else | 722 else |
| 719 initiator_shell_for_resumption_ = shell(); | 723 initiator_shell_for_resumption_ = shell(); |
| 720 | 724 |
| 721 ASSERT_EQ(DownloadManagerForShell(shell()), | 725 ASSERT_EQ(DownloadManagerForShell(shell()), |
| 722 DownloadManagerForShell(initiator_shell_for_resumption())); | 726 DownloadManagerForShell(initiator_shell_for_resumption())); |
| 723 } | 727 } |
| (...skipping 988 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1712 | 1716 |
| 1713 std::vector<DownloadItem*> downloads; | 1717 std::vector<DownloadItem*> downloads; |
| 1714 DownloadManagerForShell(shell())->GetAllDownloads(&downloads); | 1718 DownloadManagerForShell(shell())->GetAllDownloads(&downloads); |
| 1715 ASSERT_EQ(1u, downloads.size()); | 1719 ASSERT_EQ(1u, downloads.size()); |
| 1716 | 1720 |
| 1717 EXPECT_EQ(FILE_PATH_LITERAL("Jumboshrimp.txt"), | 1721 EXPECT_EQ(FILE_PATH_LITERAL("Jumboshrimp.txt"), |
| 1718 downloads[0]->GetTargetFilePath().BaseName().value()); | 1722 downloads[0]->GetTargetFilePath().BaseName().value()); |
| 1719 } | 1723 } |
| 1720 | 1724 |
| 1721 } // namespace content | 1725 } // namespace content |
| OLD | NEW |