Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(491)

Side by Side Diff: chrome/browser/download/chrome_download_manager_delegate_unittest.cc

Issue 11413050: chrome/browser: Update calls from RunAllPending() to RunUntilIdle(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/file_path.h" 5 #include "base/file_path.h"
6 #include "base/file_util.h" 6 #include "base/file_util.h"
7 #include "base/files/scoped_temp_dir.h" 7 #include "base/files/scoped_temp_dir.h"
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "base/observer_list.h" 9 #include "base/observer_list.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 delegate_ = new TestChromeDownloadManagerDelegate(profile()); 305 delegate_ = new TestChromeDownloadManagerDelegate(profile());
306 delegate_->SetDownloadManager(download_manager_.get()); 306 delegate_->SetDownloadManager(download_manager_.get());
307 pref_service_ = profile()->GetTestingPrefService(); 307 pref_service_ = profile()->GetTestingPrefService();
308 web_contents()->SetDelegate(&web_contents_delegate_); 308 web_contents()->SetDelegate(&web_contents_delegate_);
309 309
310 ASSERT_TRUE(test_download_dir_.CreateUniqueTempDir()); 310 ASSERT_TRUE(test_download_dir_.CreateUniqueTempDir());
311 SetDefaultDownloadPath(test_download_dir_.path()); 311 SetDefaultDownloadPath(test_download_dir_.path());
312 } 312 }
313 313
314 void ChromeDownloadManagerDelegateTest::TearDown() { 314 void ChromeDownloadManagerDelegateTest::TearDown() {
315 message_loop_.RunAllPending(); 315 message_loop_.RunUntilIdle();
316 delegate_->Shutdown(); 316 delegate_->Shutdown();
317 ChromeRenderViewHostTestHarness::TearDown(); 317 ChromeRenderViewHostTestHarness::TearDown();
318 } 318 }
319 319
320 void ChromeDownloadManagerDelegateTest::VerifyAndClearExpectations() { 320 void ChromeDownloadManagerDelegateTest::VerifyAndClearExpectations() {
321 ::testing::Mock::VerifyAndClearExpectations(delegate_); 321 ::testing::Mock::VerifyAndClearExpectations(delegate_);
322 ::testing::Mock::VerifyAndClearExpectations(download_manager_); 322 ::testing::Mock::VerifyAndClearExpectations(download_manager_);
323 EXPECT_CALL(*download_manager_, RemoveObserver(_)).WillRepeatedly(Return()); 323 EXPECT_CALL(*download_manager_, RemoveObserver(_)).WillRepeatedly(Return());
324 EXPECT_CALL(*download_manager_, GetAllDownloads(_)) 324 EXPECT_CALL(*download_manager_, GetAllDownloads(_))
325 .WillRepeatedly(Return()); 325 .WillRepeatedly(Return());
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
440 ChooseDownloadPath(item, expected_prompt_path, _)) 440 ChooseDownloadPath(item, expected_prompt_path, _))
441 .WillOnce(WithArg<2>(ScheduleCallback(expected_target_path))); 441 .WillOnce(WithArg<2>(ScheduleCallback(expected_target_path)));
442 } 442 }
443 443
444 // Kick off the test. 444 // Kick off the test.
445 base::WeakPtrFactory<ChromeDownloadManagerDelegateTest> factory(this); 445 base::WeakPtrFactory<ChromeDownloadManagerDelegateTest> factory(this);
446 EXPECT_TRUE(delegate_->DetermineDownloadTarget( 446 EXPECT_TRUE(delegate_->DetermineDownloadTarget(
447 item, 447 item,
448 base::Bind(&ChromeDownloadManagerDelegateTest::DownloadTargetVerifier, 448 base::Bind(&ChromeDownloadManagerDelegateTest::DownloadTargetVerifier,
449 factory.GetWeakPtr(), base::Unretained(&test_case)))); 449 factory.GetWeakPtr(), base::Unretained(&test_case))));
450 message_loop_.RunAllPending(); 450 message_loop_.RunUntilIdle();
451 VerifyAndClearExpectations(); 451 VerifyAndClearExpectations();
452 } 452 }
453 453
454 void ChromeDownloadManagerDelegateTest::RunTestCases( 454 void ChromeDownloadManagerDelegateTest::RunTestCases(
455 const DownloadTestCase test_cases[], 455 const DownloadTestCase test_cases[],
456 size_t test_case_count) { 456 size_t test_case_count) {
457 for (size_t i = 0; i < test_case_count; ++i) { 457 for (size_t i = 0; i < test_case_count; ++i) {
458 scoped_ptr<content::MockDownloadItem> item(CreateActiveDownloadItem(i)); 458 scoped_ptr<content::MockDownloadItem> item(CreateActiveDownloadItem(i));
459 SCOPED_TRACE(testing::Message() << "Running test case " << i); 459 SCOPED_TRACE(testing::Message() << "Running test case " << i);
460 RunTestCaseWithDownloadItem(test_cases[i], item.get()); 460 RunTestCaseWithDownloadItem(test_cases[i], item.get());
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after
908 // Run the first test case again. Since the last download path was cleared, 908 // Run the first test case again. Since the last download path was cleared,
909 // this test case should behave identically to the first time it was run. 909 // this test case should behave identically to the first time it was run.
910 RunTestCases(kLastSavePathTestCases, 1); 910 RunTestCases(kLastSavePathTestCases, 1);
911 } 911 }
912 912
913 // TODO(asanka): Add more tests. 913 // TODO(asanka): Add more tests.
914 // * Default download path is not writable. 914 // * Default download path is not writable.
915 // * Download path doesn't exist. 915 // * Download path doesn't exist.
916 // * IsDangerousFile(). 916 // * IsDangerousFile().
917 // * Filename generation. 917 // * Filename generation.
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698