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

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

Issue 2890853002: Downloads: replace BrowserThread::FILE with task scheduler. (Closed)
Patch Set: Revert ScopedCOMInitializer invocations. Created 3 years, 5 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/parallel_download_job_unittest.cc
diff --git a/content/browser/download/parallel_download_job_unittest.cc b/content/browser/download/parallel_download_job_unittest.cc
index 2690ea4739bd6e735780c94356c5e6cec7af70ab..ae7d5b04c5286e40b4db829ce1d12416fc55efb3 100644
--- a/content/browser/download/parallel_download_job_unittest.cc
+++ b/content/browser/download/parallel_download_job_unittest.cc
@@ -9,9 +9,11 @@
#include "base/memory/ptr_util.h"
#include "base/run_loop.h"
+#include "base/test/scoped_task_environment.h"
#include "content/browser/download/download_destination_observer.h"
#include "content/browser/download/download_file_impl.h"
#include "content/browser/download/download_item_impl_delegate.h"
+#include "content/browser/download/download_task_runner.h"
#include "content/browser/download/mock_download_item_impl.h"
#include "content/browser/download/parallel_download_utils.h"
#include "content/public/test/test_browser_thread_bundle.h"
@@ -112,6 +114,11 @@ class ParallelDownloadJobForTest : public ParallelDownloadJob {
class ParallelDownloadJobTest : public testing::Test {
public:
+ ParallelDownloadJobTest()
+ : task_environment_(
+ base::test::ScopedTaskEnvironment::MainThreadType::UI,
+ base::test::ScopedTaskEnvironment::ExecutionMode::QUEUED) {}
+
void CreateParallelJob(int64_t initial_request_offset,
int64_t content_length,
const DownloadItem::ReceivedSlices& slices,
@@ -173,6 +180,7 @@ class ParallelDownloadJobTest : public testing::Test {
file_initialized_ = true;
}
+ base::test::ScopedTaskEnvironment task_environment_;
content::TestBrowserThreadBundle browser_threads_;
std::unique_ptr<DownloadItemImplDelegate> item_delegate_;
std::unique_ptr<MockDownloadItemImpl> download_item_;
@@ -379,10 +387,15 @@ TEST_F(ParallelDownloadJobTest, ParallelRequestNotCreatedUntilFileInitialized) {
EXPECT_CALL(*input_stream, RegisterCallback(_));
EXPECT_CALL(*input_stream, Read(_, _));
EXPECT_CALL(*(observer.get()), DestinationUpdate(_, _, _));
- base::RunLoop().RunUntilIdle();
+ task_environment_.RunUntilIdle();
EXPECT_TRUE(file_initialized_);
EXPECT_EQ(1u, job_->workers().size());
DestroyParallelJob();
+
+ // The download file lives on the download sequence, and must
+ // be deleted there.
+ GetDownloadTaskRunner()->DeleteSoon(FROM_HERE, std::move(download_file));
+ task_environment_.RunUntilIdle();
}
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698