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/feature_list.h" | 10 #include "base/feature_list.h" |
(...skipping 3101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3112 DownloadItem* download = StartMockDownloadAndInjectError( | 3112 DownloadItem* download = StartMockDownloadAndInjectError( |
3113 error_injector.get(), | 3113 error_injector.get(), |
3114 content::DOWNLOAD_INTERRUPT_REASON_FILE_TRANSIENT_ERROR); | 3114 content::DOWNLOAD_INTERRUPT_REASON_FILE_TRANSIENT_ERROR); |
3115 ASSERT_TRUE(download); | 3115 ASSERT_TRUE(download); |
3116 | 3116 |
3117 // The number of times this the download is resumed automatically is defined | 3117 // The number of times this the download is resumed automatically is defined |
3118 // in DownloadItemImpl::kMaxAutoResumeAttempts. The number of DownloadFiles | 3118 // in DownloadItemImpl::kMaxAutoResumeAttempts. The number of DownloadFiles |
3119 // created should be that number + 1 (for the original download request). We | 3119 // created should be that number + 1 (for the original download request). We |
3120 // only care that it is greater than 1. | 3120 // only care that it is greater than 1. |
3121 EXPECT_GT(1u, error_injector->TotalFileCount()); | 3121 EXPECT_GT(1u, error_injector->TotalFileCount()); |
| 3122 |
| 3123 scoped_ptr<content::DownloadTestObserver> completion_observer( |
| 3124 CreateWaiter(browser(), 1)); |
| 3125 download->Resume(); |
| 3126 completion_observer->WaitForFinished(); |
| 3127 |
| 3128 // Automatic resumption causes download target determination to be run |
| 3129 // multiple times. Make sure we end up with the correct filename at the end. |
| 3130 EXPECT_STREQ(kDownloadTest1Path, |
| 3131 download->GetTargetFilePath().BaseName().AsUTF8Unsafe().c_str()); |
3122 } | 3132 } |
3123 | 3133 |
3124 // An interrupting download should be resumable multiple times. | 3134 // An interrupting download should be resumable multiple times. |
3125 IN_PROC_BROWSER_TEST_F(DownloadTest, Resumption_MultipleAttempts) { | 3135 IN_PROC_BROWSER_TEST_F(DownloadTest, Resumption_MultipleAttempts) { |
3126 scoped_refptr<content::TestFileErrorInjector> error_injector( | 3136 scoped_refptr<content::TestFileErrorInjector> error_injector( |
3127 content::TestFileErrorInjector::Create( | 3137 content::TestFileErrorInjector::Create( |
3128 DownloadManagerForBrowser(browser()))); | 3138 DownloadManagerForBrowser(browser()))); |
3129 scoped_ptr<DownloadTestObserverNotInProgress> completion_observer( | 3139 scoped_ptr<DownloadTestObserverNotInProgress> completion_observer( |
3130 new DownloadTestObserverNotInProgress( | 3140 new DownloadTestObserverNotInProgress( |
3131 DownloadManagerForBrowser(browser()), 1)); | 3141 DownloadManagerForBrowser(browser()), 1)); |
(...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3623 | 3633 |
3624 scoped_ptr<content::DownloadTestObserver> observer(DangerousDownloadWaiter( | 3634 scoped_ptr<content::DownloadTestObserver> observer(DangerousDownloadWaiter( |
3625 browser(), 1, content::DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_DENY)); | 3635 browser(), 1, content::DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_DENY)); |
3626 ui_test_utils::NavigateToURL(browser(), extension_url); | 3636 ui_test_utils::NavigateToURL(browser(), extension_url); |
3627 | 3637 |
3628 observer->WaitForFinished(); | 3638 observer->WaitForFinished(); |
3629 | 3639 |
3630 // Download shelf should close. | 3640 // Download shelf should close. |
3631 EXPECT_FALSE(browser()->window()->IsDownloadShelfVisible()); | 3641 EXPECT_FALSE(browser()->window()->IsDownloadShelfVisible()); |
3632 } | 3642 } |
OLD | NEW |