Chromium Code Reviews| 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 "base/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "base/logging.h" | 6 #include "base/logging.h" |
| 7 #include "base/path_service.h" | 7 #include "base/path_service.h" |
| 8 #include "base/stringprintf.h" | 8 #include "base/stringprintf.h" |
| 9 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
| 10 #include "chrome/browser/download/download_service.h" | 10 #include "chrome/browser/download/download_service.h" |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 108 GURL url(URLRequestSlowDownloadJob::kKnownSizeUrl); | 108 GURL url(URLRequestSlowDownloadJob::kKnownSizeUrl); |
| 109 | 109 |
| 110 if (num_downloads == 0) | 110 if (num_downloads == 0) |
| 111 return; | 111 return; |
| 112 | 112 |
| 113 // Setup an observer waiting for the given number of downloads | 113 // Setup an observer waiting for the given number of downloads |
| 114 // to get to IN_PROGRESS. | 114 // to get to IN_PROGRESS. |
| 115 DownloadManager* download_manager = | 115 DownloadManager* download_manager = |
| 116 browser->profile()->GetDownloadManager(); | 116 browser->profile()->GetDownloadManager(); |
| 117 scoped_ptr<DownloadTestObserver> observer( | 117 scoped_ptr<DownloadTestObserver> observer( |
| 118 new DownloadTestObserver( | 118 new DownloadTestObserverInProgress(download_manager, |
| 119 download_manager, num_downloads, | 119 num_downloads, |
| 120 DownloadItem::IN_PROGRESS, | 120 true)); // Bail on select file. |
| 121 true, // Bail on select file. | |
| 122 DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_FAIL)); | |
| 123 | 121 |
| 124 // Set of that number of downloads. | 122 // Set of that number of downloads. |
| 123 size_t count_downloads = num_downloads; | |
| 125 while (num_downloads--) | 124 while (num_downloads--) |
| 126 ui_test_utils::NavigateToURLWithDisposition( | 125 ui_test_utils::NavigateToURLWithDisposition( |
| 127 browser, url, NEW_BACKGROUND_TAB, | 126 browser, url, NEW_BACKGROUND_TAB, |
| 128 ui_test_utils::BROWSER_TEST_NONE); | 127 ui_test_utils::BROWSER_TEST_NONE); |
| 129 | 128 |
| 130 // Wait for them. | 129 // Wait for them. |
| 131 observer->WaitForFinished(); | 130 observer->WaitForFinished(); |
| 131 DCHECK_EQ(count_downloads, | |
|
sky
2012/03/09 20:20:28
Why are you using DCHECK in a test?
ahendrickson
2012/03/09 20:49:14
Oops, missed that one. Fixed.
| |
| 132 observer->NumDownloadsSeenInState(DownloadItem::IN_PROGRESS)); | |
| 132 } | 133 } |
| 133 | 134 |
| 134 // All all downloads created in CreateStalledDownloads() to | 135 // All all downloads created in CreateStalledDownloads() to |
| 135 // complete, and block in this routine until they do complete. | 136 // complete, and block in this routine until they do complete. |
| 136 void CompleteAllDownloads(Browser* browser) { | 137 void CompleteAllDownloads(Browser* browser) { |
| 137 GURL finish_url(URLRequestSlowDownloadJob::kFinishDownloadUrl); | 138 GURL finish_url(URLRequestSlowDownloadJob::kFinishDownloadUrl); |
| 138 ui_test_utils::NavigateToURL(browser, finish_url); | 139 ui_test_utils::NavigateToURL(browser, finish_url); |
| 139 | 140 |
| 140 // Go through and, for every single profile, wait until there are | 141 // Go through and, for every single profile, wait until there are |
| 141 // no active downloads on that download manager. | 142 // no active downloads on that download manager. |
| (...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 554 #define MAYBE_DownloadsCloseCheck_5 DownloadsCloseCheck_5 | 555 #define MAYBE_DownloadsCloseCheck_5 DownloadsCloseCheck_5 |
| 555 #endif | 556 #endif |
| 556 | 557 |
| 557 IN_PROC_BROWSER_TEST_F(BrowserCloseTest, MAYBE_DownloadsCloseCheck_5) { | 558 IN_PROC_BROWSER_TEST_F(BrowserCloseTest, MAYBE_DownloadsCloseCheck_5) { |
| 558 ASSERT_TRUE(SetupForDownloadCloseCheck()); | 559 ASSERT_TRUE(SetupForDownloadCloseCheck()); |
| 559 for (size_t i = 5 * arraysize(download_close_check_cases) / 6; | 560 for (size_t i = 5 * arraysize(download_close_check_cases) / 6; |
| 560 i < 6 * arraysize(download_close_check_cases) / 6; ++i) { | 561 i < 6 * arraysize(download_close_check_cases) / 6; ++i) { |
| 561 ExecuteDownloadCloseCheckCase(i); | 562 ExecuteDownloadCloseCheckCase(i); |
| 562 } | 563 } |
| 563 } | 564 } |
| OLD | NEW |