| 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 "base/file_path.h" | 8 #include "base/file_path.h" |
| 9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/scoped_temp_dir.h" | 10 #include "base/files/scoped_temp_dir.h" |
| 11 #include "content/browser/download/download_file_factory.h" | 11 #include "content/browser/download/download_file_factory.h" |
| 12 #include "content/browser/download/download_file_impl.h" | 12 #include "content/browser/download/download_file_impl.h" |
| 13 #include "content/browser/download/download_item_impl.h" | 13 #include "content/browser/download/download_item_impl.h" |
| 14 #include "content/browser/download/download_manager_impl.h" | 14 #include "content/browser/download/download_manager_impl.h" |
| 15 #include "content/browser/power_save_blocker.h" | 15 #include "content/browser/power_save_blocker.h" |
| 16 #include "content/browser/web_contents/web_contents_impl.h" | 16 #include "content/browser/web_contents/web_contents_impl.h" |
| 17 #include "content/public/test/download_test_observer.h" | 17 #include "content/public/test/download_test_observer.h" |
| 18 #include "content/public/test/test_utils.h" | 18 #include "content/public/test/test_utils.h" |
| 19 #include "content/shell/shell.h" | 19 #include "content/shell/shell.h" |
| 20 #include "content/shell/shell_browser_context.h" | 20 #include "content/shell/shell_browser_context.h" |
| (...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 448 | 448 |
| 449 private: | 449 private: |
| 450 static void EnsureNoPendingDownloadJobsOnIO(bool* result) { | 450 static void EnsureNoPendingDownloadJobsOnIO(bool* result) { |
| 451 if (URLRequestSlowDownloadJob::NumberOutstandingRequests()) | 451 if (URLRequestSlowDownloadJob::NumberOutstandingRequests()) |
| 452 *result = false; | 452 *result = false; |
| 453 BrowserThread::PostTask( | 453 BrowserThread::PostTask( |
| 454 BrowserThread::UI, FROM_HERE, MessageLoop::QuitClosure()); | 454 BrowserThread::UI, FROM_HERE, MessageLoop::QuitClosure()); |
| 455 } | 455 } |
| 456 | 456 |
| 457 // Location of the downloads directory for these tests | 457 // Location of the downloads directory for these tests |
| 458 ScopedTempDir downloads_directory_; | 458 base::ScopedTempDir downloads_directory_; |
| 459 }; | 459 }; |
| 460 | 460 |
| 461 IN_PROC_BROWSER_TEST_F(DownloadContentTest, DownloadCancelled) { | 461 IN_PROC_BROWSER_TEST_F(DownloadContentTest, DownloadCancelled) { |
| 462 SetupEnsureNoPendingDownloads(); | 462 SetupEnsureNoPendingDownloads(); |
| 463 | 463 |
| 464 // Create a download, wait until it's started, and confirm | 464 // Create a download, wait until it's started, and confirm |
| 465 // we're in the expected state. | 465 // we're in the expected state. |
| 466 scoped_ptr<DownloadTestObserver> observer(CreateInProgressWaiter(shell(), 1)); | 466 scoped_ptr<DownloadTestObserver> observer(CreateInProgressWaiter(shell(), 1)); |
| 467 NavigateToURL(shell(), GURL(URLRequestSlowDownloadJob::kUnknownSizeUrl)); | 467 NavigateToURL(shell(), GURL(URLRequestSlowDownloadJob::kUnknownSizeUrl)); |
| 468 observer->WaitForFinished(); | 468 observer->WaitForFinished(); |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 738 MockDownloadItemObserver observer; | 738 MockDownloadItemObserver observer; |
| 739 items[0]->AddObserver(&observer); | 739 items[0]->AddObserver(&observer); |
| 740 EXPECT_CALL(observer, OnDownloadDestroyed(items[0])); | 740 EXPECT_CALL(observer, OnDownloadDestroyed(items[0])); |
| 741 | 741 |
| 742 // Shutdown the download manager. Mostly this is confirming a lack of | 742 // Shutdown the download manager. Mostly this is confirming a lack of |
| 743 // crashes. | 743 // crashes. |
| 744 DownloadManagerForShell(shell())->Shutdown(); | 744 DownloadManagerForShell(shell())->Shutdown(); |
| 745 } | 745 } |
| 746 | 746 |
| 747 } // namespace content | 747 } // namespace content |
| OLD | NEW |