Chromium Code Reviews| 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..800cd82507a82ee842dbb1f91a738371e97d955f 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::Bind(&BackgroundFetchJobControllerTest::JobComplete, |
| + base::Unretained(this))); |
| } |
| + void JobComplete() { job_complete_called_ = true; } |
|
Peter Beverloo
2017/03/15 16:53:38
nit: same re: naming.
harkness
2017/03/16 11:41:09
Done.
|
| + |
| 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 job_complete_called() const { return job_complete_called_; } |
| + |
| private: |
| + bool job_complete_called_ = 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(job_complete_called()); |
| // 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(job_complete_called()); |
| } |
| TEST_F(BackgroundFetchJobControllerTest, MultipleRequestJob) { |
| @@ -203,6 +213,7 @@ TEST_F(BackgroundFetchJobControllerTest, MultipleRequestJob) { |
| EXPECT_FALSE(job_data->IsComplete()); |
| } |
| EXPECT_FALSE(job_data->HasRequestsRemaining()); |
| + EXPECT_FALSE(job_complete_called()); |
| // 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(job_complete_called()); |
| } |
| } // namespace content |