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

Unified Diff: components/offline_pages/background/request_queue_store_unittest.cc

Issue 2219393004: Adds an observer for the request coordinator. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@resumeAPI
Patch Set: Fix nits. Created 4 years, 4 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: components/offline_pages/background/request_queue_store_unittest.cc
diff --git a/components/offline_pages/background/request_queue_store_unittest.cc b/components/offline_pages/background/request_queue_store_unittest.cc
index 23406d49f07598ee8b79c1b69de55423f266ab2a..79b6fc7a2a121f5e887da527df9de335fc74f64f 100644
--- a/components/offline_pages/background/request_queue_store_unittest.cc
+++ b/components/offline_pages/background/request_queue_store_unittest.cc
@@ -67,13 +67,21 @@ class RequestQueueStoreTestBase : public testing::Test {
const std::vector<SavePageRequest>& requests);
// Callback used for add/update request.
void AddOrUpdateDone(UpdateStatus result);
+ void UpdateMultipleRequestsDone(
+ const RequestQueue::UpdateMultipleRequestResults& results,
+ const std::vector<SavePageRequest>& requests);
// Callback used for remove requests.
- void RemoveDone(const RequestQueue::UpdateMultipleRequestResults& results);
+ void RemoveDone(const RequestQueue::UpdateMultipleRequestResults& results,
+ const std::vector<SavePageRequest>& requests);
// Callback used for reset.
void ResetDone(bool result);
LastResult last_result() const { return last_result_; }
UpdateStatus last_update_status() const { return last_update_status_; }
+ const RequestQueue::UpdateMultipleRequestResults&
+ last_multiple_update_results() const {
+ return last_multiple_update_results_;
+ }
const RequestQueue::UpdateMultipleRequestResults& last_remove_results()
const {
return last_remove_results_;
@@ -88,6 +96,7 @@ class RequestQueueStoreTestBase : public testing::Test {
private:
LastResult last_result_;
UpdateStatus last_update_status_;
+ RequestQueue::UpdateMultipleRequestResults last_multiple_update_results_;
RequestQueue::UpdateMultipleRequestResults last_remove_results_;
std::vector<SavePageRequest> last_requests_;
@@ -130,9 +139,18 @@ void RequestQueueStoreTestBase::AddOrUpdateDone(UpdateStatus status) {
last_update_status_ = status;
}
+void RequestQueueStoreTestBase::UpdateMultipleRequestsDone(
+ const RequestQueue::UpdateMultipleRequestResults& results,
+ const std::vector<SavePageRequest>& requests) {
+ last_multiple_update_results_ = results;
+ last_requests_ = requests;
+}
+
void RequestQueueStoreTestBase::RemoveDone(
- const RequestQueue::UpdateMultipleRequestResults& results) {
+ const RequestQueue::UpdateMultipleRequestResults& results,
+ const std::vector<SavePageRequest>& requests) {
last_remove_results_ = results;
+ last_requests_ = requests;
}
void RequestQueueStoreTestBase::ResetDone(bool result) {
@@ -287,6 +305,7 @@ TYPED_TEST(RequestQueueStoreTest, RemoveRequests) {
this->last_remove_results().at(0).second);
ASSERT_EQ(RequestQueue::UpdateRequestResult::SUCCESS,
this->last_remove_results().at(1).second);
+ ASSERT_EQ(kRequestId, this->last_requests().at(0).request_id());
this->ClearResults();
store->GetRequests(base::Bind(&RequestQueueStoreTestBase::GetRequestsDone,
@@ -329,13 +348,16 @@ TYPED_TEST(RequestQueueStoreTest, PauseAndResumeRequest) {
std::vector<int64_t> request_ids{kRequestId};
store->ChangeRequestsState(
request_ids, SavePageRequest::RequestState::PAUSED,
- base::Bind(&RequestQueueStoreTestBase::AddOrUpdateDone,
+ base::Bind(&RequestQueueStoreTestBase::UpdateMultipleRequestsDone,
base::Unretained(this)));
ASSERT_EQ(LastResult::kNone, this->last_result());
this->PumpLoop();
// Verify pause succeeded
- ASSERT_EQ(UpdateStatus::UPDATED, this->last_update_status());
+ ASSERT_EQ(1ul, this->last_multiple_update_results().size());
+ ASSERT_EQ(RequestQueue::UpdateRequestResult::SUCCESS,
+ this->last_multiple_update_results().at(0).second);
+ ASSERT_EQ(kRequestId, this->last_requests().at(0).request_id());
this->ClearResults();
// Get the request from the queue to check it out
@@ -353,13 +375,16 @@ TYPED_TEST(RequestQueueStoreTest, PauseAndResumeRequest) {
// Now resume the same request we paused.
store->ChangeRequestsState(
request_ids, SavePageRequest::RequestState::AVAILABLE,
- base::Bind(&RequestQueueStoreTestBase::AddOrUpdateDone,
+ base::Bind(&RequestQueueStoreTestBase::UpdateMultipleRequestsDone,
base::Unretained(this)));
ASSERT_EQ(LastResult::kNone, this->last_result());
this->PumpLoop();
// Verify resume succeeded.
- ASSERT_EQ(UpdateStatus::UPDATED, this->last_update_status());
+ ASSERT_EQ(1ul, this->last_multiple_update_results().size());
+ ASSERT_EQ(RequestQueue::UpdateRequestResult::SUCCESS,
+ this->last_multiple_update_results().at(0).second);
+ ASSERT_EQ(kRequestId, this->last_requests().at(0).request_id());
this->ClearResults();
// Get the request from the queue to check it out

Powered by Google App Engine
This is Rietveld 408576698