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 "chrome/browser/download/download_browsertest.h" | 5 #include "chrome/browser/download/download_browsertest.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 #include <sstream> | 8 #include <sstream> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
430 | 430 |
431 void TearDownOnMainThread() override { | 431 void TearDownOnMainThread() override { |
432 // Needs to be torn down on the main thread. file_activity_observer_ holds a | 432 // Needs to be torn down on the main thread. file_activity_observer_ holds a |
433 // reference to the ChromeDownloadManagerDelegate which should be destroyed | 433 // reference to the ChromeDownloadManagerDelegate which should be destroyed |
434 // on the UI thread. | 434 // on the UI thread. |
435 file_activity_observer_.reset(); | 435 file_activity_observer_.reset(); |
436 } | 436 } |
437 | 437 |
438 // Returning false indicates a failure of the setup, and should be asserted | 438 // Returning false indicates a failure of the setup, and should be asserted |
439 // in the caller. | 439 // in the caller. |
440 virtual bool InitialSetup() { | 440 bool InitialSetup() { |
441 bool have_test_dir = PathService::Get(chrome::DIR_TEST_DATA, &test_dir_); | 441 bool have_test_dir = PathService::Get(chrome::DIR_TEST_DATA, &test_dir_); |
442 EXPECT_TRUE(have_test_dir); | 442 EXPECT_TRUE(have_test_dir); |
443 if (!have_test_dir) | 443 if (!have_test_dir) |
444 return false; | 444 return false; |
445 | 445 |
446 // Sanity check default values for window and tab count. | 446 // Sanity check default values for window and tab count. |
447 int window_count = chrome::GetTotalBrowserCount(); | 447 int window_count = chrome::GetTotalBrowserCount(); |
448 EXPECT_EQ(1, window_count); | 448 EXPECT_EQ(1, window_count); |
449 EXPECT_EQ(1, browser()->tab_strip_model()->count()); | 449 EXPECT_EQ(1, browser()->tab_strip_model()->count()); |
450 | 450 |
451 // Set up the temporary download folder. | 451 // Set up the temporary download folder. |
452 bool created_downloads_dir = CreateAndSetDownloadsDirectory(browser()); | 452 bool created_downloads_dir = CreateAndSetDownloadsDirectory(browser()); |
453 EXPECT_TRUE(created_downloads_dir); | 453 EXPECT_TRUE(created_downloads_dir); |
454 if (!created_downloads_dir) | 454 if (!created_downloads_dir) |
455 return false; | 455 return false; |
456 browser()->profile()->GetPrefs()->SetBoolean( | 456 browser()->profile()->GetPrefs()->SetBoolean( |
457 prefs::kPromptForDownload, false); | 457 prefs::kPromptForDownload, false); |
458 | 458 |
459 DownloadManager* manager = DownloadManagerForBrowser(browser()); | 459 DownloadManager* manager = DownloadManagerForBrowser(browser()); |
460 DownloadPrefs::FromDownloadManager(manager)->ResetAutoOpen(); | 460 DownloadPrefs::FromDownloadManager(manager)->ResetAutoOpen(); |
461 manager->RemoveAllDownloads(); | |
462 | 461 |
463 file_activity_observer_.reset( | 462 file_activity_observer_.reset( |
464 new DownloadTestFileActivityObserver(browser()->profile())); | 463 new DownloadTestFileActivityObserver(browser()->profile())); |
465 | 464 |
466 return true; | 465 return true; |
467 } | 466 } |
468 | 467 |
469 protected: | 468 protected: |
470 enum SizeTestType { | 469 enum SizeTestType { |
471 SIZE_TEST_TYPE_KNOWN, | 470 SIZE_TEST_TYPE_KNOWN, |
(...skipping 3265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3737 browser(), 1, | 3736 browser(), 1, |
3738 content::DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_DENY)); | 3737 content::DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_DENY)); |
3739 ui_test_utils::NavigateToURL(browser(), extension_url); | 3738 ui_test_utils::NavigateToURL(browser(), extension_url); |
3740 | 3739 |
3741 observer->WaitForFinished(); | 3740 observer->WaitForFinished(); |
3742 | 3741 |
3743 // Download shelf should close. | 3742 // Download shelf should close. |
3744 EXPECT_FALSE(browser()->window()->IsDownloadShelfVisible()); | 3743 EXPECT_FALSE(browser()->window()->IsDownloadShelfVisible()); |
3745 } | 3744 } |
3746 #endif // defined(OS_CHROMEOS) | 3745 #endif // defined(OS_CHROMEOS) |
OLD | NEW |