| 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 <utility> | 5 #include <utility> |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
| 9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
| 10 #include "chrome/browser/download/download_prefs.h" | 10 #include "chrome/browser/download/download_prefs.h" |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 ExtensionApiTest::TearDownOnMainThread(); | 151 ExtensionApiTest::TearDownOnMainThread(); |
| 152 } | 152 } |
| 153 | 153 |
| 154 void InitializeDownloadSettings() { | 154 void InitializeDownloadSettings() { |
| 155 ASSERT_TRUE(browser()); | 155 ASSERT_TRUE(browser()); |
| 156 ASSERT_TRUE(downloads_dir_.CreateUniqueTempDir()); | 156 ASSERT_TRUE(downloads_dir_.CreateUniqueTempDir()); |
| 157 | 157 |
| 158 // Setup default downloads directory to the scoped tmp directory created for | 158 // Setup default downloads directory to the scoped tmp directory created for |
| 159 // the test. | 159 // the test. |
| 160 browser()->profile()->GetPrefs()->SetFilePath( | 160 browser()->profile()->GetPrefs()->SetFilePath( |
| 161 prefs::kDownloadDefaultDirectory, downloads_dir_.path()); | 161 prefs::kDownloadDefaultDirectory, downloads_dir_.GetPath()); |
| 162 // Ensure there are no prompts for download during the test. | 162 // Ensure there are no prompts for download during the test. |
| 163 browser()->profile()->GetPrefs()->SetBoolean( | 163 browser()->profile()->GetPrefs()->SetBoolean( |
| 164 prefs::kPromptForDownload, false); | 164 prefs::kPromptForDownload, false); |
| 165 | 165 |
| 166 DownloadManager* manager = GetDownloadManager(); | 166 DownloadManager* manager = GetDownloadManager(); |
| 167 DownloadPrefs::FromDownloadManager(manager)->ResetAutoOpen(); | 167 DownloadPrefs::FromDownloadManager(manager)->ResetAutoOpen(); |
| 168 manager->RemoveAllDownloads(); | 168 manager->RemoveAllDownloads(); |
| 169 } | 169 } |
| 170 | 170 |
| 171 // Sends onExecuteContentHandler event with the MIME type "test/done" to the | 171 // Sends onExecuteContentHandler event with the MIME type "test/done" to the |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 373 | 373 |
| 374 DownloadManager* download_manager = GetDownloadManager(); | 374 DownloadManager* download_manager = GetDownloadManager(); |
| 375 std::unique_ptr<content::DownloadTestObserver> download_observer( | 375 std::unique_ptr<content::DownloadTestObserver> download_observer( |
| 376 new content::DownloadTestObserverInProgress(download_manager, 1)); | 376 new content::DownloadTestObserverInProgress(download_manager, 1)); |
| 377 | 377 |
| 378 // The resource's URL on the test server. | 378 // The resource's URL on the test server. |
| 379 GURL url = test_server_->GetURL("/text_path.txt"); | 379 GURL url = test_server_->GetURL("/text_path.txt"); |
| 380 | 380 |
| 381 // The download's target file path. | 381 // The download's target file path. |
| 382 base::FilePath target_path = | 382 base::FilePath target_path = |
| 383 downloads_dir_.path().Append(FILE_PATH_LITERAL("download_target.txt")); | 383 downloads_dir_.GetPath().Append(FILE_PATH_LITERAL("download_target.txt")); |
| 384 | 384 |
| 385 // Set the downloads parameters. | 385 // Set the downloads parameters. |
| 386 content::WebContents* web_contents = | 386 content::WebContents* web_contents = |
| 387 browser()->tab_strip_model()->GetActiveWebContents(); | 387 browser()->tab_strip_model()->GetActiveWebContents(); |
| 388 ASSERT_TRUE(web_contents); | 388 ASSERT_TRUE(web_contents); |
| 389 std::unique_ptr<DownloadUrlParameters> params( | 389 std::unique_ptr<DownloadUrlParameters> params( |
| 390 DownloadUrlParameters::CreateForWebContentsMainFrame( | 390 DownloadUrlParameters::CreateForWebContentsMainFrame( |
| 391 web_contents, url)); | 391 web_contents, url)); |
| 392 params->set_file_path(target_path); | 392 params->set_file_path(target_path); |
| 393 | 393 |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 448 base::RunLoop().RunUntilIdle(); | 448 base::RunLoop().RunUntilIdle(); |
| 449 EXPECT_TRUE(catcher.GetNextResult()); | 449 EXPECT_TRUE(catcher.GetNextResult()); |
| 450 | 450 |
| 451 ui_test_utils::NavigateToURL(browser(), | 451 ui_test_utils::NavigateToURL(browser(), |
| 452 test_server_->GetURL("/abort.rtf")); | 452 test_server_->GetURL("/abort.rtf")); |
| 453 base::RunLoop().RunUntilIdle(); | 453 base::RunLoop().RunUntilIdle(); |
| 454 EXPECT_TRUE(catcher.GetNextResult()); | 454 EXPECT_TRUE(catcher.GetNextResult()); |
| 455 } | 455 } |
| 456 | 456 |
| 457 } // namespace | 457 } // namespace |
| OLD | NEW |