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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 111 | 111 |
| 112 if (num_downloads == 0) | 112 if (num_downloads == 0) |
| 113 return; | 113 return; |
| 114 | 114 |
| 115 // Setup an observer waiting for the given number of downloads | 115 // Setup an observer waiting for the given number of downloads |
| 116 // to get to IN_PROGRESS. | 116 // to get to IN_PROGRESS. |
| 117 DownloadManager* download_manager = | 117 DownloadManager* download_manager = |
| 118 BrowserContext::GetDownloadManager(browser->profile()); | 118 BrowserContext::GetDownloadManager(browser->profile()); |
| 119 scoped_ptr<DownloadTestObserver> observer( | 119 scoped_ptr<DownloadTestObserver> observer( |
| 120 new DownloadTestObserverInProgress(download_manager, | 120 new DownloadTestObserverInProgress(download_manager, |
| 121 num_downloads, | 121 num_downloads)); |
| 122 true)); // Bail on select file. | |
| 123 | 122 |
| 124 // Set of that number of downloads. | 123 // Set of that number of downloads. |
| 125 size_t count_downloads = num_downloads; | 124 size_t count_downloads = num_downloads; |
| 126 while (num_downloads--) | 125 while (num_downloads--) |
| 127 ui_test_utils::NavigateToURLWithDisposition( | 126 ui_test_utils::NavigateToURLWithDisposition( |
| 128 browser, url, NEW_BACKGROUND_TAB, | 127 browser, url, NEW_BACKGROUND_TAB, |
| 129 ui_test_utils::BROWSER_TEST_NONE); | 128 ui_test_utils::BROWSER_TEST_NONE); |
| 130 | 129 |
| 131 // Wait for them. | 130 // Wait for them. |
| 132 observer->WaitForFinished(); | 131 observer->WaitForFinished(); |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 232 EXPECT_TRUE(result); | 231 EXPECT_TRUE(result); |
| 233 if (!result) return false; | 232 if (!result) return false; |
| 234 first_profile_->GetPrefs()->SetFilePath( | 233 first_profile_->GetPrefs()->SetFilePath( |
| 235 prefs::kDownloadDefaultDirectory, | 234 prefs::kDownloadDefaultDirectory, |
| 236 first_profile_downloads_dir_.path()); | 235 first_profile_downloads_dir_.path()); |
| 237 | 236 |
| 238 second_profile_ = CreateSecondProfile(); | 237 second_profile_ = CreateSecondProfile(); |
| 239 EXPECT_TRUE(second_profile_); | 238 EXPECT_TRUE(second_profile_); |
| 240 if (!second_profile_) return false; | 239 if (!second_profile_) return false; |
| 241 | 240 |
| 241 first_file_chooser_observer_.reset( | |
| 242 new DownloadTestFileChooserObserver(first_profile_)); | |
| 243 second_file_chooser_observer_.reset( | |
| 244 new DownloadTestFileChooserObserver(second_profile_)); | |
|
Randy Smith (Not in Mondays)
2012/07/19 18:14:57
We do downloads in this test on incognito profiles
asanka
2012/07/23 19:47:10
Done.
| |
| 245 | |
| 242 return true; | 246 return true; |
| 243 } | 247 } |
| 244 | 248 |
| 245 // Test a specific DownloadsCloseCheckCase. Returns false if | 249 // Test a specific DownloadsCloseCheckCase. Returns false if |
| 246 // an assertion has failed and the test should be aborted. | 250 // an assertion has failed and the test should be aborted. |
| 247 bool ExecuteDownloadCloseCheckCase(size_t i) { | 251 bool ExecuteDownloadCloseCheckCase(size_t i) { |
| 248 const DownloadsCloseCheckCase& check_case(download_close_check_cases[i]); | 252 const DownloadsCloseCheckCase& check_case(download_close_check_cases[i]); |
| 249 | 253 |
| 250 // Test invariant: so that we don't actually try and close the browser, | 254 // Test invariant: so that we don't actually try and close the browser, |
| 251 // we always enter the function with a single browser window open on the | 255 // we always enter the function with a single browser window open on the |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 364 | 368 |
| 365 return true; | 369 return true; |
| 366 } | 370 } |
| 367 | 371 |
| 368 static const DownloadsCloseCheckCase download_close_check_cases[]; | 372 static const DownloadsCloseCheckCase download_close_check_cases[]; |
| 369 | 373 |
| 370 // DownloadCloseCheck variables. | 374 // DownloadCloseCheck variables. |
| 371 Profile* first_profile_; | 375 Profile* first_profile_; |
| 372 Profile* second_profile_; | 376 Profile* second_profile_; |
| 373 | 377 |
| 378 // FileChooserObservers that suppress file chooser dialogs. | |
| 379 scoped_ptr<DownloadTestFileChooserObserver> first_file_chooser_observer_; | |
| 380 scoped_ptr<DownloadTestFileChooserObserver> second_file_chooser_observer_; | |
| 381 | |
| 374 ScopedTempDir first_profile_downloads_dir_; | 382 ScopedTempDir first_profile_downloads_dir_; |
| 375 ScopedTempDir second_profile_data_dir_; | 383 ScopedTempDir second_profile_data_dir_; |
| 376 ScopedTempDir second_profile_downloads_dir_; | 384 ScopedTempDir second_profile_downloads_dir_; |
| 377 }; | 385 }; |
| 378 | 386 |
| 379 const BrowserCloseTest::DownloadsCloseCheckCase | 387 const BrowserCloseTest::DownloadsCloseCheckCase |
| 380 BrowserCloseTest::download_close_check_cases[] = { | 388 BrowserCloseTest::download_close_check_cases[] = { |
| 381 // Top level nesting is {profile_a, profile_b} | 389 // Top level nesting is {profile_a, profile_b} |
| 382 // Second level nesting is {regular, incognito | 390 // Second level nesting is {regular, incognito |
| 383 // Third level (inner) nesting is {windows, downloads} | 391 // Third level (inner) nesting is {windows, downloads} |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 569 } | 577 } |
| 570 } | 578 } |
| 571 | 579 |
| 572 IN_PROC_BROWSER_TEST_F(BrowserCloseTest, MAYBE_DownloadsCloseCheck_5) { | 580 IN_PROC_BROWSER_TEST_F(BrowserCloseTest, MAYBE_DownloadsCloseCheck_5) { |
| 573 ASSERT_TRUE(SetupForDownloadCloseCheck()); | 581 ASSERT_TRUE(SetupForDownloadCloseCheck()); |
| 574 for (size_t i = 5 * arraysize(download_close_check_cases) / 6; | 582 for (size_t i = 5 * arraysize(download_close_check_cases) / 6; |
| 575 i < 6 * arraysize(download_close_check_cases) / 6; ++i) { | 583 i < 6 * arraysize(download_close_check_cases) / 6; ++i) { |
| 576 ExecuteDownloadCloseCheckCase(i); | 584 ExecuteDownloadCloseCheckCase(i); |
| 577 } | 585 } |
| 578 } | 586 } |
| OLD | NEW |