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

Unified Diff: content/browser/download/download_item_impl_unittest.cc

Issue 2890853002: Downloads: replace BrowserThread::FILE with task scheduler. (Closed)
Patch Set: Address Francios' comments. Created 3 years, 6 months 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/download/download_item_impl_unittest.cc
diff --git a/content/browser/download/download_item_impl_unittest.cc b/content/browser/download/download_item_impl_unittest.cc
index 1d10e52f4946c3627b33d0518e63e64d5e78071e..9fb7dcce649d23817599151e6ea66d17d16f0e75 100644
--- a/content/browser/download/download_item_impl_unittest.cc
+++ b/content/browser/download/download_item_impl_unittest.cc
@@ -35,6 +35,7 @@
#include "content/public/test/mock_download_item.h"
#include "content/public/test/test_browser_context.h"
#include "content/public/test/test_browser_thread_bundle.h"
+#include "content/public/test/test_utils.h"
#include "content/public/test/web_contents_tester.h"
#include "crypto/secure_hash.h"
#include "net/http/http_response_headers.h"
@@ -266,9 +267,7 @@ class DownloadItemTest : public testing::Test {
create_info_->etag = "SomethingToSatisfyResumption";
}
- ~DownloadItemTest() {
- RunAllPendingInMessageLoops();
- }
+ ~DownloadItemTest() {}
DownloadItemImpl* CreateDownloadItemWithCreateInfo(
std::unique_ptr<DownloadCreateInfo> info) {
@@ -320,7 +319,7 @@ class DownloadItemTest : public testing::Test {
base::MakeUnique<NiceMock<MockRequestHandle>>();
item->Start(std::move(download_file), std::move(request_handle),
*create_info_);
- RunAllPendingInMessageLoops();
+ RunAllBlockingPoolTasksUntilIdle();
// So that we don't have a function writing to a stack variable
// lying around if the above failed.
@@ -352,7 +351,7 @@ class DownloadItemTest : public testing::Test {
callback.Run(target_path, DownloadItem::TARGET_DISPOSITION_OVERWRITE,
danger_type, intermediate_path,
DOWNLOAD_INTERRUPT_REASON_NONE);
- RunAllPendingInMessageLoops();
+ RunAllBlockingPoolTasksUntilIdle();
return download_file;
}
@@ -370,7 +369,7 @@ class DownloadItemTest : public testing::Test {
item->DestinationObserverAsWeakPtr()->DestinationCompleted(
0, std::unique_ptr<crypto::SecureHash>());
- RunAllPendingInMessageLoops();
+ RunAllBlockingPoolTasksUntilIdle();
}
// Cleanup a download item (specifically get rid of the DownloadFile on it).
@@ -384,7 +383,7 @@ class DownloadItemTest : public testing::Test {
if (download_file)
EXPECT_CALL(*download_file, Cancel());
item->Cancel(true);
- RunAllPendingInMessageLoops();
+ RunAllBlockingPoolTasksUntilIdle();
}
}
@@ -393,8 +392,6 @@ class DownloadItemTest : public testing::Test {
allocated_downloads_.erase(item);
}
- void RunAllPendingInMessageLoops() { base::RunLoop().RunUntilIdle(); }
-
MockDelegate* mock_delegate() {
return &delegate_;
}
@@ -587,7 +584,7 @@ TEST_F(DownloadItemTest, NotificationAfterOnDownloadTargetDetermined) {
DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, intermediate_path,
DOWNLOAD_INTERRUPT_REASON_NONE);
EXPECT_FALSE(observer.CheckAndResetDownloadUpdated());
- RunAllPendingInMessageLoops();
+ RunAllBlockingPoolTasksUntilIdle();
EXPECT_TRUE(observer.CheckAndResetDownloadUpdated());
EXPECT_EQ(new_intermediate_path, item->GetFullPath());
@@ -615,7 +612,7 @@ TEST_F(DownloadItemTest, NotificationAfterTogglePause) {
item->Resume();
ASSERT_TRUE(observer.CheckAndResetDownloadUpdated());
- RunAllPendingInMessageLoops();
+ RunAllBlockingPoolTasksUntilIdle();
CleanupItem(item, mock_download_file, DownloadItem::IN_PROGRESS);
}
@@ -658,7 +655,7 @@ TEST_F(DownloadItemTest, AutomaticResumption_Continue) {
// the mock doesn't follow through with the resumption.
// ResumeInterruptedDownload() being called is sufficient for verifying that
// the automatic resumption was triggered.
- RunAllPendingInMessageLoops();
+ RunAllBlockingPoolTasksUntilIdle();
// The download item is currently in RESUMING_INTERNAL state, which maps to
// IN_PROGRESS.
@@ -692,7 +689,7 @@ TEST_F(DownloadItemTest, AutomaticResumption_Restart) {
// Since the download is resumed automatically, the interrupt count doesn't
// increase.
ASSERT_EQ(0, observer.interrupt_count());
- RunAllPendingInMessageLoops();
+ RunAllBlockingPoolTasksUntilIdle();
CleanupItem(item, nullptr, DownloadItem::IN_PROGRESS);
}
@@ -714,7 +711,7 @@ TEST_F(DownloadItemTest, AutomaticResumption_NeedsUserAction) {
// Should not try to auto-resume.
ASSERT_EQ(1, observer.interrupt_count());
ASSERT_EQ(0, observer.resume_count());
- RunAllPendingInMessageLoops();
+ RunAllBlockingPoolTasksUntilIdle();
CleanupItem(item, nullptr, DownloadItem::INTERRUPTED);
}
@@ -753,7 +750,7 @@ TEST_F(DownloadItemTest, AutomaticResumption_ContentLengthMismatch) {
ASSERT_EQ(0, observer.interrupt_count());
ASSERT_EQ(0, observer.resume_count());
- RunAllPendingInMessageLoops();
+ RunAllBlockingPoolTasksUntilIdle();
CleanupItem(item, nullptr, DownloadItem::IN_PROGRESS);
}
@@ -776,7 +773,7 @@ TEST_F(DownloadItemTest, UnresumableInterrupt) {
// Complete download to trigger final rename.
item->DestinationObserverAsWeakPtr()->DestinationCompleted(
0, std::unique_ptr<crypto::SecureHash>());
- RunAllPendingInMessageLoops();
+ RunAllBlockingPoolTasksUntilIdle();
ASSERT_TRUE(observer.CheckAndResetDownloadUpdated());
// Should not try to auto-resume.
@@ -822,7 +819,7 @@ TEST_F(DownloadItemTest, AutomaticResumption_AttemptLimit) {
// to allow for holding onto the request handle.
item->Start(std::move(mock_download_file), std::move(mock_request_handle),
*create_info());
- RunAllPendingInMessageLoops();
+ RunAllBlockingPoolTasksUntilIdle();
base::FilePath target_path(kDummyTargetPath);
base::FilePath intermediate_path(kDummyIntermediatePath);
@@ -842,7 +839,7 @@ TEST_F(DownloadItemTest, AutomaticResumption_AttemptLimit) {
target_path, DownloadItem::TARGET_DISPOSITION_OVERWRITE,
DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, intermediate_path,
DOWNLOAD_INTERRUPT_REASON_NONE);
- RunAllPendingInMessageLoops();
+ RunAllBlockingPoolTasksUntilIdle();
// Use a continuable interrupt.
EXPECT_CALL(*mock_download_file_ref, Cancel()).Times(0);
@@ -850,7 +847,7 @@ TEST_F(DownloadItemTest, AutomaticResumption_AttemptLimit) {
DOWNLOAD_INTERRUPT_REASON_FILE_TRANSIENT_ERROR, 1,
std::unique_ptr<crypto::SecureHash>());
- RunAllPendingInMessageLoops();
+ RunAllBlockingPoolTasksUntilIdle();
::testing::Mock::VerifyAndClearExpectations(mock_download_file_ref);
}
@@ -898,7 +895,7 @@ TEST_F(DownloadItemTest, FailedResumptionDoesntUpdateOriginState) {
item->DestinationObserverAsWeakPtr()->DestinationError(
DOWNLOAD_INTERRUPT_REASON_FILE_TRANSIENT_ERROR, 1,
std::unique_ptr<crypto::SecureHash>());
- RunAllPendingInMessageLoops();
+ RunAllBlockingPoolTasksUntilIdle();
EXPECT_EQ(DownloadItem::IN_PROGRESS, item->GetState());
// Now change the create info. The changes should not cause the DownloadItem
@@ -930,7 +927,7 @@ TEST_F(DownloadItemTest, FailedResumptionDoesntUpdateOriginState) {
DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS,
base::FilePath(kDummyIntermediatePath),
DOWNLOAD_INTERRUPT_REASON_NONE);
- RunAllPendingInMessageLoops();
+ RunAllBlockingPoolTasksUntilIdle();
ASSERT_TRUE(item->GetResponseHeaders());
EXPECT_EQ(kFirstResponseCode, item->GetResponseHeaders()->response_code());
@@ -969,7 +966,7 @@ TEST_F(DownloadItemTest, SucceededResumptionUpdatesOriginState) {
item->DestinationObserverAsWeakPtr()->DestinationError(
DOWNLOAD_INTERRUPT_REASON_FILE_TRANSIENT_ERROR, 0,
std::unique_ptr<crypto::SecureHash>());
- RunAllPendingInMessageLoops();
+ RunAllBlockingPoolTasksUntilIdle();
EXPECT_EQ(DownloadItem::IN_PROGRESS, item->GetState());
// Now change the create info. The changes should not cause the DownloadItem
@@ -1028,7 +1025,7 @@ TEST_F(DownloadItemTest, ClearReceivedSliceIfEtagChanged) {
std::unique_ptr<crypto::SecureHash>());
EXPECT_EQ(kReceivedSlice, item->GetReceivedSlices());
- RunAllPendingInMessageLoops();
+ RunAllBlockingPoolTasksUntilIdle();
// Change the strong validator and resume the download, the received slices
// should be cleared.
@@ -1072,7 +1069,7 @@ TEST_F(DownloadItemTest, ResumeUsesFinalURL) {
// the mock doesn't follow through with the resumption.
// ResumeInterruptedDownload() being called is sufficient for verifying that
// the resumption was triggered.
- RunAllPendingInMessageLoops();
+ RunAllBlockingPoolTasksUntilIdle();
// The download is currently in RESUMING_INTERNAL, which maps to IN_PROGRESS.
CleanupItem(item, nullptr, DownloadItem::IN_PROGRESS);
@@ -1093,7 +1090,7 @@ TEST_F(DownloadItemTest, DisplayName) {
callback.Run(target_path, DownloadItem::TARGET_DISPOSITION_OVERWRITE,
DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, intermediate_path,
DOWNLOAD_INTERRUPT_REASON_NONE);
- RunAllPendingInMessageLoops();
+ RunAllBlockingPoolTasksUntilIdle();
EXPECT_EQ(FILE_PATH_LITERAL("foo.bar"),
item->GetFileNameToReportUser().value());
item->SetDisplayName(base::FilePath(FILE_PATH_LITERAL("new.name")));
@@ -1113,7 +1110,7 @@ TEST_F(DownloadItemTest, Start) {
EXPECT_CALL(*mock_delegate(), DetermineDownloadTarget(item, _));
item->Start(std::move(download_file), std::move(request_handle),
*create_info());
- RunAllPendingInMessageLoops();
+ RunAllBlockingPoolTasksUntilIdle();
CleanupItem(item, mock_download_file, DownloadItem::IN_PROGRESS);
}
@@ -1146,7 +1143,7 @@ TEST_F(DownloadItemTest, InitDownloadFileFails) {
DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS,
base::FilePath(kDummyIntermediatePath),
DOWNLOAD_INTERRUPT_REASON_NONE);
- RunAllPendingInMessageLoops();
+ RunAllBlockingPoolTasksUntilIdle();
EXPECT_EQ(DownloadItem::INTERRUPTED, item->GetState());
EXPECT_EQ(DOWNLOAD_INTERRUPT_REASON_FILE_ACCESS_DENIED,
@@ -1171,7 +1168,7 @@ TEST_F(DownloadItemTest, StartFailedDownload) {
item->Start(std::move(null_download_file), std::move(null_request_handle),
*create_info());
EXPECT_EQ(DownloadItem::IN_PROGRESS, item->GetState());
- RunAllPendingInMessageLoops();
+ RunAllBlockingPoolTasksUntilIdle();
// The DownloadItemImpl should attempt to determine a target path even if the
// download was interrupted.
@@ -1182,7 +1179,7 @@ TEST_F(DownloadItemTest, StartFailedDownload) {
DownloadItem::TARGET_DISPOSITION_OVERWRITE,
DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, target_path,
DOWNLOAD_INTERRUPT_REASON_NONE);
- RunAllPendingInMessageLoops();
+ RunAllBlockingPoolTasksUntilIdle();
EXPECT_EQ(target_path, item->GetTargetFilePath());
CleanupItem(item, NULL, DownloadItem::INTERRUPTED);
@@ -1205,7 +1202,7 @@ TEST_F(DownloadItemTest, CallbackAfterRename) {
callback.Run(final_path, DownloadItem::TARGET_DISPOSITION_OVERWRITE,
DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, intermediate_path,
DOWNLOAD_INTERRUPT_REASON_NONE);
- RunAllPendingInMessageLoops();
+ RunAllBlockingPoolTasksUntilIdle();
// All the callbacks should have happened by now.
::testing::Mock::VerifyAndClearExpectations(download_file);
mock_delegate()->VerifyAndClearExpectations();
@@ -1220,7 +1217,7 @@ TEST_F(DownloadItemTest, CallbackAfterRename) {
EXPECT_CALL(*download_file, Detach());
item->DestinationObserverAsWeakPtr()->DestinationCompleted(
0, std::unique_ptr<crypto::SecureHash>());
- RunAllPendingInMessageLoops();
+ RunAllBlockingPoolTasksUntilIdle();
::testing::Mock::VerifyAndClearExpectations(download_file);
mock_delegate()->VerifyAndClearExpectations();
}
@@ -1245,7 +1242,7 @@ TEST_F(DownloadItemTest, CallbackAfterInterruptedRename) {
callback.Run(final_path, DownloadItem::TARGET_DISPOSITION_OVERWRITE,
DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, intermediate_path,
DOWNLOAD_INTERRUPT_REASON_NONE);
- RunAllPendingInMessageLoops();
+ RunAllBlockingPoolTasksUntilIdle();
// All the callbacks should have happened by now.
::testing::Mock::VerifyAndClearExpectations(download_file);
mock_delegate()->VerifyAndClearExpectations();
@@ -1263,7 +1260,7 @@ TEST_F(DownloadItemTest, Interrupted) {
EXPECT_CALL(*download_file, Cancel());
item->DestinationObserverAsWeakPtr()->DestinationError(
reason, 0, std::unique_ptr<crypto::SecureHash>());
- RunAllPendingInMessageLoops();
+ RunAllBlockingPoolTasksUntilIdle();
EXPECT_EQ(DownloadItem::INTERRUPTED, item->GetState());
EXPECT_EQ(reason, item->GetLastReason());
@@ -1298,7 +1295,7 @@ TEST_F(DownloadItemTest, InterruptedBeforeIntermediateRename_Restart) {
callback.Run(final_path, DownloadItem::TARGET_DISPOSITION_OVERWRITE,
DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, intermediate_path,
DOWNLOAD_INTERRUPT_REASON_NONE);
- RunAllPendingInMessageLoops();
+ RunAllBlockingPoolTasksUntilIdle();
// All the callbacks should have happened by now.
::testing::Mock::VerifyAndClearExpectations(download_file);
mock_delegate()->VerifyAndClearExpectations();
@@ -1337,7 +1334,7 @@ TEST_F(DownloadItemTest, InterruptedBeforeIntermediateRename_Continue) {
callback.Run(final_path, DownloadItem::TARGET_DISPOSITION_OVERWRITE,
DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, intermediate_path,
DOWNLOAD_INTERRUPT_REASON_NONE);
- RunAllPendingInMessageLoops();
+ RunAllBlockingPoolTasksUntilIdle();
// All the callbacks should have happened by now.
::testing::Mock::VerifyAndClearExpectations(download_file);
mock_delegate()->VerifyAndClearExpectations();
@@ -1371,7 +1368,7 @@ TEST_F(DownloadItemTest, InterruptedBeforeIntermediateRename_Failed) {
callback.Run(final_path, DownloadItem::TARGET_DISPOSITION_OVERWRITE,
DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, intermediate_path,
DOWNLOAD_INTERRUPT_REASON_NONE);
- RunAllPendingInMessageLoops();
+ RunAllBlockingPoolTasksUntilIdle();
// All the callbacks should have happened by now.
::testing::Mock::VerifyAndClearExpectations(download_file);
mock_delegate()->VerifyAndClearExpectations();
@@ -1594,7 +1591,7 @@ TEST_F(DownloadItemTest, EnabledActionsForNormalDownload) {
EXPECT_CALL(*download_file, Detach());
item->DestinationObserverAsWeakPtr()->DestinationCompleted(
0, std::unique_ptr<crypto::SecureHash>());
- RunAllPendingInMessageLoops();
+ RunAllBlockingPoolTasksUntilIdle();
ASSERT_EQ(DownloadItem::COMPLETE, item->GetState());
EXPECT_TRUE(item->CanShowInFolder());
@@ -1627,7 +1624,7 @@ TEST_F(DownloadItemTest, EnabledActionsForTemporaryDownload) {
EXPECT_CALL(*download_file, Detach());
item->DestinationObserverAsWeakPtr()->DestinationCompleted(
0, std::unique_ptr<crypto::SecureHash>());
- RunAllPendingInMessageLoops();
+ RunAllBlockingPoolTasksUntilIdle();
ASSERT_EQ(DownloadItem::COMPLETE, item->GetState());
EXPECT_FALSE(item->CanShowInFolder());
@@ -1643,7 +1640,7 @@ TEST_F(DownloadItemTest, EnabledActionsForInterruptedDownload) {
item->DestinationObserverAsWeakPtr()->DestinationError(
DOWNLOAD_INTERRUPT_REASON_FILE_FAILED, 0,
std::unique_ptr<crypto::SecureHash>());
- RunAllPendingInMessageLoops();
+ RunAllBlockingPoolTasksUntilIdle();
ASSERT_EQ(DownloadItem::INTERRUPTED, item->GetState());
ASSERT_FALSE(item->GetTargetFilePath().empty());
@@ -1658,7 +1655,7 @@ TEST_F(DownloadItemTest, EnabledActionsForCancelledDownload) {
EXPECT_CALL(*download_file, Cancel());
item->Cancel(true);
- RunAllPendingInMessageLoops();
+ RunAllBlockingPoolTasksUntilIdle();
ASSERT_EQ(DownloadItem::CANCELLED, item->GetState());
EXPECT_FALSE(item->CanShowInFolder());
@@ -1693,7 +1690,7 @@ TEST_F(DownloadItemTest, CompleteDelegate_ReturnTrue) {
EXPECT_CALL(*download_file, FullPath())
.WillOnce(ReturnRefOfCopy(base::FilePath()));
EXPECT_CALL(*download_file, Detach());
- RunAllPendingInMessageLoops();
+ RunAllBlockingPoolTasksUntilIdle();
EXPECT_EQ(DownloadItem::COMPLETE, item->GetState());
}
@@ -1733,7 +1730,7 @@ TEST_F(DownloadItemTest, CompleteDelegate_BlockOnce) {
EXPECT_CALL(*download_file, FullPath())
.WillOnce(ReturnRefOfCopy(base::FilePath()));
EXPECT_CALL(*download_file, Detach());
- RunAllPendingInMessageLoops();
+ RunAllBlockingPoolTasksUntilIdle();
EXPECT_EQ(DownloadItem::COMPLETE, item->GetState());
}
@@ -1776,13 +1773,13 @@ TEST_F(DownloadItemTest, CompleteDelegate_SetDanger) {
EXPECT_CALL(*download_file, FullPath())
.WillOnce(ReturnRefOfCopy(base::FilePath()));
EXPECT_CALL(*download_file, Detach());
- RunAllPendingInMessageLoops();
+ RunAllBlockingPoolTasksUntilIdle();
EXPECT_EQ(DownloadItem::IN_PROGRESS, item->GetState());
EXPECT_TRUE(item->IsDangerous());
item->ValidateDangerousDownload();
EXPECT_EQ(DOWNLOAD_DANGER_TYPE_USER_VALIDATED, item->GetDangerType());
- RunAllPendingInMessageLoops();
+ RunAllBlockingPoolTasksUntilIdle();
EXPECT_EQ(DownloadItem::COMPLETE, item->GetState());
}
@@ -1829,7 +1826,7 @@ TEST_F(DownloadItemTest, CompleteDelegate_BlockTwice) {
EXPECT_CALL(*download_file, FullPath())
.WillOnce(ReturnRefOfCopy(base::FilePath()));
EXPECT_CALL(*download_file, Detach());
- RunAllPendingInMessageLoops();
+ RunAllBlockingPoolTasksUntilIdle();
EXPECT_EQ(DownloadItem::COMPLETE, item->GetState());
}
@@ -1851,7 +1848,7 @@ TEST_F(DownloadItemTest, StealDangerousDownloadAndDiscard) {
base::Bind(&DownloadItemTest::OnDownloadFileAcquired,
weak_ptr_factory.GetWeakPtr(),
base::Unretained(&returned_path)));
- RunAllPendingInMessageLoops();
+ RunAllBlockingPoolTasksUntilIdle();
EXPECT_EQ(full_path, returned_path);
}
@@ -1870,7 +1867,7 @@ TEST_F(DownloadItemTest, StealDangerousDownloadAndKeep) {
base::Bind(&DownloadItemTest::OnDownloadFileAcquired,
weak_ptr_factory.GetWeakPtr(),
base::Unretained(&returned_path)));
- RunAllPendingInMessageLoops();
+ RunAllBlockingPoolTasksUntilIdle();
EXPECT_NE(full_path, returned_path);
CleanupItem(item, download_file, DownloadItem::IN_PROGRESS);
}
@@ -1896,7 +1893,7 @@ TEST_F(DownloadItemTest, StealInterruptedContinuableDangerousDownload) {
true, base::Bind(&DownloadItemTest::OnDownloadFileAcquired,
weak_ptr_factory.GetWeakPtr(),
base::Unretained(&returned_path)));
- RunAllPendingInMessageLoops();
+ RunAllBlockingPoolTasksUntilIdle();
EXPECT_EQ(full_path, returned_path);
}
@@ -1918,7 +1915,7 @@ TEST_F(DownloadItemTest, StealInterruptedNonContinuableDangerousDownload) {
true, base::Bind(&DownloadItemTest::OnDownloadFileAcquired,
weak_ptr_factory.GetWeakPtr(),
base::Unretained(&returned_path)));
- RunAllPendingInMessageLoops();
+ RunAllBlockingPoolTasksUntilIdle();
EXPECT_TRUE(returned_path.empty());
}
@@ -2175,7 +2172,7 @@ TEST_P(DownloadItemDestinationUpdateRaceTest, DownloadCancelledByUser) {
item_->DestinationObserverAsWeakPtr();
ScheduleObservations(PreInitializeFileObservations(), destination_observer);
- RunAllPendingInMessageLoops();
+ RunAllBlockingPoolTasksUntilIdle();
base::RunLoop initialize_completion_loop;
DownloadTargetCallback target_callback;
@@ -2187,7 +2184,7 @@ TEST_P(DownloadItemDestinationUpdateRaceTest, DownloadCancelledByUser) {
initialize_callback.Run(DOWNLOAD_INTERRUPT_REASON_NONE);
initialize_completion_loop.Run();
- RunAllPendingInMessageLoops();
+ RunAllBlockingPoolTasksUntilIdle();
ASSERT_FALSE(target_callback.is_null());
ScheduleObservations(PostTargetDeterminationObservations(),
@@ -2197,7 +2194,7 @@ TEST_P(DownloadItemDestinationUpdateRaceTest, DownloadCancelledByUser) {
DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, base::FilePath(),
DOWNLOAD_INTERRUPT_REASON_NONE);
EXPECT_EQ(DownloadItem::CANCELLED, item_->GetState());
- RunAllPendingInMessageLoops();
+ RunAllBlockingPoolTasksUntilIdle();
}
// Run through the DII workflow, but the intermediate rename fails.
@@ -2228,7 +2225,7 @@ TEST_P(DownloadItemDestinationUpdateRaceTest, IntermediateRenameFails) {
item_->DestinationObserverAsWeakPtr();
ScheduleObservations(PreInitializeFileObservations(), destination_observer);
- RunAllPendingInMessageLoops();
+ RunAllBlockingPoolTasksUntilIdle();
base::RunLoop initialize_completion_loop;
DownloadTargetCallback target_callback;
@@ -2240,7 +2237,7 @@ TEST_P(DownloadItemDestinationUpdateRaceTest, IntermediateRenameFails) {
initialize_callback.Run(DOWNLOAD_INTERRUPT_REASON_NONE);
initialize_completion_loop.Run();
- RunAllPendingInMessageLoops();
+ RunAllBlockingPoolTasksUntilIdle();
ASSERT_FALSE(target_callback.is_null());
ScheduleObservations(PostTargetDeterminationObservations(),
@@ -2258,7 +2255,7 @@ TEST_P(DownloadItemDestinationUpdateRaceTest, IntermediateRenameFails) {
destination_observer);
intermediate_rename_callback.Run(DOWNLOAD_INTERRUPT_REASON_FILE_FAILED,
base::FilePath());
- RunAllPendingInMessageLoops();
+ RunAllBlockingPoolTasksUntilIdle();
EXPECT_EQ(DownloadItem::INTERRUPTED, item_->GetState());
}
@@ -2298,7 +2295,7 @@ TEST_P(DownloadItemDestinationUpdateRaceTest, IntermediateRenameSucceeds) {
item_->DestinationObserverAsWeakPtr();
ScheduleObservations(PreInitializeFileObservations(), destination_observer);
- RunAllPendingInMessageLoops();
+ RunAllBlockingPoolTasksUntilIdle();
base::RunLoop initialize_completion_loop;
DownloadTargetCallback target_callback;
@@ -2310,7 +2307,7 @@ TEST_P(DownloadItemDestinationUpdateRaceTest, IntermediateRenameSucceeds) {
initialize_callback.Run(DOWNLOAD_INTERRUPT_REASON_NONE);
initialize_completion_loop.Run();
- RunAllPendingInMessageLoops();
+ RunAllBlockingPoolTasksUntilIdle();
ASSERT_FALSE(target_callback.is_null());
ScheduleObservations(PostTargetDeterminationObservations(),
@@ -2333,7 +2330,7 @@ TEST_P(DownloadItemDestinationUpdateRaceTest, IntermediateRenameSucceeds) {
destination_observer);
intermediate_rename_callback.Run(DOWNLOAD_INTERRUPT_REASON_NONE,
base::FilePath(kDummyIntermediatePath));
- RunAllPendingInMessageLoops();
+ RunAllBlockingPoolTasksUntilIdle();
// The state of the download depends on the observer events that were played
// back to the DownloadItemImpl. Hence we can't establish a single expectation
@@ -2346,7 +2343,7 @@ TEST_P(DownloadItemDestinationUpdateRaceTest, IntermediateRenameSucceeds) {
EXPECT_EQ(DOWNLOAD_INTERRUPT_REASON_NETWORK_FAILED, item_->GetLastReason());
item_->Cancel(true);
- RunAllPendingInMessageLoops();
+ RunAllBlockingPoolTasksUntilIdle();
}
TEST(MockDownloadItem, Compiles) {

Powered by Google App Engine
This is Rietveld 408576698