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

Unified Diff: content/browser/background_fetch/background_fetch_data_manager_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_data_manager_unittest.cc
diff --git a/content/browser/background_fetch/background_fetch_data_manager_unittest.cc b/content/browser/background_fetch/background_fetch_data_manager_unittest.cc
index 031aabdc129b37718b972868f3969089971ac68c..374d213d6c931602d29475eb3e2d50d8ec8be8fe 100644
--- a/content/browser/background_fetch/background_fetch_data_manager_unittest.cc
+++ b/content/browser/background_fetch/background_fetch_data_manager_unittest.cc
@@ -10,6 +10,8 @@
#include "content/browser/background_fetch/background_fetch_request_info.h"
#include "content/browser/service_worker/embedded_worker_test_helper.h"
#include "content/browser/service_worker/service_worker_context_wrapper.h"
+#include "content/public/browser/download_interrupt_reasons.h"
+#include "content/public/browser/download_item.h"
#include "content/public/test/test_browser_context.h"
#include "content/public/test/test_browser_thread_bundle.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -70,21 +72,35 @@ TEST_F(BackgroundFetchDataManagerTest, AddRequest) {
const BackgroundFetchRequestInfo& request_info =
job_data->GetNextBackgroundFetchRequestInfo();
EXPECT_EQ(request_info.tag(), kTag);
+ EXPECT_EQ(request_info.state(),
+ DownloadItem::DownloadState::MAX_DOWNLOAD_STATE);
+ EXPECT_EQ(request_info.interrupt_reason(),
+ DownloadInterruptReason::DOWNLOAD_INTERRUPT_REASON_NONE);
}
// At this point, all the fetches have been started, but none finished.
EXPECT_FALSE(job_data->HasRequestsRemaining());
EXPECT_FALSE(job_data->IsComplete());
- // Complete all buy one of the fetch requests.
+ // Complete all but one of the fetch requests.
for (int i = 0; i < 9; i++) {
- EXPECT_FALSE(
- job_data->BackgroundFetchRequestInfoComplete(request_guids[i]));
+ EXPECT_FALSE(job_data->UpdateBackgroundFetchRequestState(
+ request_guids[i], DownloadItem::DownloadState::COMPLETE,
+ DownloadInterruptReason::DOWNLOAD_INTERRUPT_REASON_NONE));
EXPECT_FALSE(job_data->IsComplete());
}
+ // Set the state of the last task to be interrupted. This should not complete
+ // the job.
+ EXPECT_FALSE(job_data->UpdateBackgroundFetchRequestState(
+ request_guids[9], DownloadItem::DownloadState::INTERRUPTED,
+ DownloadInterruptReason::DOWNLOAD_INTERRUPT_REASON_USER_SHUTDOWN));
+ EXPECT_FALSE(job_data->IsComplete());
+
// Complete the final fetch request.
- EXPECT_FALSE(job_data->BackgroundFetchRequestInfoComplete(request_guids[9]));
+ EXPECT_FALSE(job_data->UpdateBackgroundFetchRequestState(
+ request_guids[9], DownloadItem::DownloadState::COMPLETE,
+ DownloadInterruptReason::DOWNLOAD_INTERRUPT_REASON_NONE));
EXPECT_TRUE(job_data->IsComplete());
}

Powered by Google App Engine
This is Rietveld 408576698