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> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 #include <utility> | 10 #include <utility> |
(...skipping 541 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
552 net::HttpRequestHeaders request_headers_; | 552 net::HttpRequestHeaders request_headers_; |
553 TestDownloadRequestHandler::OnStartResponseCallback response_callback_; | 553 TestDownloadRequestHandler::OnStartResponseCallback response_callback_; |
554 }; | 554 }; |
555 | 555 |
556 class DownloadContentTest : public ContentBrowserTest { | 556 class DownloadContentTest : public ContentBrowserTest { |
557 protected: | 557 protected: |
558 void SetUpOnMainThread() override { | 558 void SetUpOnMainThread() override { |
559 ASSERT_TRUE(downloads_directory_.CreateUniqueTempDir()); | 559 ASSERT_TRUE(downloads_directory_.CreateUniqueTempDir()); |
560 | 560 |
561 test_delegate_.reset(new TestShellDownloadManagerDelegate()); | 561 test_delegate_.reset(new TestShellDownloadManagerDelegate()); |
562 test_delegate_->SetDownloadBehaviorForTesting(downloads_directory_.path()); | 562 test_delegate_->SetDownloadBehaviorForTesting( |
| 563 downloads_directory_.GetPath()); |
563 DownloadManager* manager = DownloadManagerForShell(shell()); | 564 DownloadManager* manager = DownloadManagerForShell(shell()); |
564 manager->GetDelegate()->Shutdown(); | 565 manager->GetDelegate()->Shutdown(); |
565 manager->SetDelegate(test_delegate_.get()); | 566 manager->SetDelegate(test_delegate_.get()); |
566 test_delegate_->SetDownloadManager(manager); | 567 test_delegate_->SetDownloadManager(manager); |
567 | 568 |
568 BrowserThread::PostTask( | 569 BrowserThread::PostTask( |
569 BrowserThread::IO, FROM_HERE, | 570 BrowserThread::IO, FROM_HERE, |
570 base::Bind(&net::URLRequestSlowDownloadJob::AddUrlHandler)); | 571 base::Bind(&net::URLRequestSlowDownloadJob::AddUrlHandler)); |
571 base::FilePath mock_base(GetTestFilePath("download", "")); | 572 base::FilePath mock_base(GetTestFilePath("download", "")); |
572 BrowserThread::PostTask( | 573 BrowserThread::PostTask( |
573 BrowserThread::IO, FROM_HERE, | 574 BrowserThread::IO, FROM_HERE, |
574 base::Bind( | 575 base::Bind( |
575 &net::URLRequestMockHTTPJob::AddUrlHandlers, mock_base, | 576 &net::URLRequestMockHTTPJob::AddUrlHandlers, mock_base, |
576 make_scoped_refptr(content::BrowserThread::GetBlockingPool()))); | 577 make_scoped_refptr(content::BrowserThread::GetBlockingPool()))); |
577 } | 578 } |
578 | 579 |
579 void SetUpCommandLine(base::CommandLine* commnad_line) override { | 580 void SetUpCommandLine(base::CommandLine* commnad_line) override { |
580 IsolateAllSitesForTesting(commnad_line); | 581 IsolateAllSitesForTesting(commnad_line); |
581 } | 582 } |
582 | 583 |
583 TestShellDownloadManagerDelegate* GetDownloadManagerDelegate() { | 584 TestShellDownloadManagerDelegate* GetDownloadManagerDelegate() { |
584 return test_delegate_.get(); | 585 return test_delegate_.get(); |
585 } | 586 } |
586 | 587 |
587 const base::FilePath& GetDownloadDirectory() const { | 588 const base::FilePath& GetDownloadDirectory() const { |
588 return downloads_directory_.path(); | 589 return downloads_directory_.GetPath(); |
589 } | 590 } |
590 | 591 |
591 // Create a DownloadTestObserverTerminal that will wait for the | 592 // Create a DownloadTestObserverTerminal that will wait for the |
592 // specified number of downloads to finish. | 593 // specified number of downloads to finish. |
593 DownloadTestObserver* CreateWaiter( | 594 DownloadTestObserver* CreateWaiter( |
594 Shell* shell, int num_downloads) { | 595 Shell* shell, int num_downloads) { |
595 DownloadManager* download_manager = DownloadManagerForShell(shell); | 596 DownloadManager* download_manager = DownloadManagerForShell(shell); |
596 return new DownloadTestObserverTerminal(download_manager, num_downloads, | 597 return new DownloadTestObserverTerminal(download_manager, num_downloads, |
597 DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_FAIL); | 598 DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_FAIL); |
598 } | 599 } |
(...skipping 1944 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2543 GURL document_url = | 2544 GURL document_url = |
2544 origin_two.GetURL("/iframe-host.html?target=" + frame_url.spec()); | 2545 origin_two.GetURL("/iframe-host.html?target=" + frame_url.spec()); |
2545 DownloadItem* download = StartDownloadAndReturnItem(shell(), document_url); | 2546 DownloadItem* download = StartDownloadAndReturnItem(shell(), document_url); |
2546 WaitForCompletion(download); | 2547 WaitForCompletion(download); |
2547 | 2548 |
2548 EXPECT_STREQ(FILE_PATH_LITERAL("download-test.lib"), | 2549 EXPECT_STREQ(FILE_PATH_LITERAL("download-test.lib"), |
2549 download->GetTargetFilePath().BaseName().value().c_str()); | 2550 download->GetTargetFilePath().BaseName().value().c_str()); |
2550 } | 2551 } |
2551 | 2552 |
2552 } // namespace content | 2553 } // namespace content |
OLD | NEW |