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

Unified Diff: content/browser/background_fetch/background_fetch_job_controller_unittest.cc

Issue 2753583002: Add the JobComplete callback and error/interrupt information (Closed)
Patch Set: added argument name Created 3 years, 9 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/background_fetch/background_fetch_job_controller_unittest.cc
diff --git a/content/browser/background_fetch/background_fetch_job_controller_unittest.cc b/content/browser/background_fetch/background_fetch_job_controller_unittest.cc
index 654a5ca898ec81bbced6fa9997721f4cb5dd19f0..de2ebb3e41cac181fdb7d4fb5e45242bf6c0b490 100644
--- a/content/browser/background_fetch/background_fetch_job_controller_unittest.cc
+++ b/content/browser/background_fetch/background_fetch_job_controller_unittest.cc
@@ -93,9 +93,13 @@ class BackgroundFetchJobControllerTest : public ::testing::Test {
job_controller_ = base::MakeUnique<BackgroundFetchJobController>(
kJobGuid, &browser_context_,
BrowserContext::GetDefaultStoragePartition(&browser_context_),
- std::move(job_data));
+ std::move(job_data),
+ base::BindOnce(&BackgroundFetchJobControllerTest::DidCompleteJob,
+ base::Unretained(this)));
}
+ void DidCompleteJob() { did_complete_job_ = true; }
+
void StartProcessing() {
base::RunLoop run_loop;
BrowserThread::PostTask(
@@ -119,7 +123,10 @@ class BackgroundFetchJobControllerTest : public ::testing::Test {
DownloadItem::Observer* ItemObserver() const { return job_controller_.get(); }
+ bool did_complete_job() const { return did_complete_job_; }
+
private:
+ bool did_complete_job_ = false;
TestBrowserThreadBundle thread_bundle_;
TestBrowserContext browser_context_;
std::unique_ptr<BackgroundFetchJobController> job_controller_;
@@ -154,12 +161,15 @@ TEST_F(BackgroundFetchJobControllerTest, SingleRequestJob) {
// Update the observer with no actual change.
ItemObserver()->OnDownloadUpdated(item);
EXPECT_FALSE(job_data->IsComplete());
+ EXPECT_FALSE(did_complete_job());
// Update the item to be completed then update the observer. The JobController
// should update the JobData that the request is complete.
item->SetState(DownloadItem::DownloadState::COMPLETE);
ItemObserver()->OnDownloadUpdated(item);
EXPECT_TRUE(job_data->IsComplete());
+
+ EXPECT_TRUE(did_complete_job());
}
TEST_F(BackgroundFetchJobControllerTest, MultipleRequestJob) {
@@ -203,6 +213,7 @@ TEST_F(BackgroundFetchJobControllerTest, MultipleRequestJob) {
EXPECT_FALSE(job_data->IsComplete());
}
EXPECT_FALSE(job_data->HasRequestsRemaining());
+ EXPECT_FALSE(did_complete_job());
// Finally, update the last request to be complete. The JobController should
// see that there are no more requests and mark the job as done.
@@ -211,6 +222,8 @@ TEST_F(BackgroundFetchJobControllerTest, MultipleRequestJob) {
item->SetState(DownloadItem::DownloadState::COMPLETE);
ItemObserver()->OnDownloadUpdated(item);
EXPECT_TRUE(job_data->IsComplete());
+
+ EXPECT_TRUE(did_complete_job());
}
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698