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

Unified Diff: components/offline_pages/background/request_queue_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
« no previous file with comments | « components/offline_pages/background/request_queue_store_unittest.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/offline_pages/background/request_queue_unittest.cc
diff --git a/components/offline_pages/background/request_queue_unittest.cc b/components/offline_pages/background/request_queue_unittest.cc
index 079513ea7209963ef405e8d0eb8f6f821dfc2b7f..5bc5d3e233fdfab71b0300e4e7db35383af2c46f 100644
--- a/components/offline_pages/background/request_queue_unittest.cc
+++ b/components/offline_pages/background/request_queue_unittest.cc
@@ -49,8 +49,13 @@ class RequestQueueTest : public testing::Test {
void GetRequestsDone(GetRequestsResult result,
const std::vector<SavePageRequest>& requests);
// Callback for removing request.
- void RemoveRequestDone(
- const RequestQueue::UpdateMultipleRequestResults& results);
+ void RemoveRequestsDone(
+ const RequestQueue::UpdateMultipleRequestResults& results,
+ const std::vector<SavePageRequest>& requests);
+
+ void UpdateMultipleRequestsDone(
+ const RequestQueue::UpdateMultipleRequestResults& results,
+ const std::vector<SavePageRequest>& requests);
void UpdateRequestDone(UpdateRequestResult result);
@@ -66,6 +71,11 @@ class RequestQueueTest : public testing::Test {
return last_remove_results_;
}
+ const RequestQueue::UpdateMultipleRequestResults&
+ last_multiple_update_results() const {
+ return last_multiple_update_results_;
+ }
+
UpdateRequestResult last_update_result() const { return last_update_result_; }
GetRequestsResult last_get_requests_result() const {
@@ -79,6 +89,7 @@ class RequestQueueTest : public testing::Test {
AddRequestResult last_add_result_;
std::unique_ptr<SavePageRequest> last_added_request_;
RequestQueue::UpdateMultipleRequestResults last_remove_results_;
+ RequestQueue::UpdateMultipleRequestResults last_multiple_update_results_;
UpdateRequestResult last_update_result_;
GetRequestsResult last_get_requests_result_;
@@ -121,9 +132,18 @@ void RequestQueueTest::GetRequestsDone(
last_requests_ = requests;
}
-void RequestQueueTest::RemoveRequestDone(
- const RequestQueue::UpdateMultipleRequestResults& results) {
+void RequestQueueTest::RemoveRequestsDone(
+ const RequestQueue::UpdateMultipleRequestResults& results,
+ const std::vector<SavePageRequest>& requests) {
last_remove_results_ = results;
+ last_requests_ = requests;
+}
+
+void RequestQueueTest::UpdateMultipleRequestsDone(
+ const RequestQueue::UpdateMultipleRequestResults& results,
+ const std::vector<SavePageRequest>& requests) {
+ last_multiple_update_results_ = results;
+ last_requests_ = requests;
}
void RequestQueueTest::UpdateRequestDone(UpdateRequestResult result) {
@@ -167,9 +187,9 @@ TEST_F(RequestQueueTest, RemoveRequest) {
std::vector<int64_t> remove_requests;
remove_requests.push_back(kRequestId);
- queue()->RemoveRequests(
- remove_requests,
- base::Bind(&RequestQueueTest::RemoveRequestDone, base::Unretained(this)));
+ queue()->RemoveRequests(remove_requests,
+ base::Bind(&RequestQueueTest::RemoveRequestsDone,
+ base::Unretained(this)));
PumpLoop();
ASSERT_EQ(1ul, last_remove_results().size());
ASSERT_EQ(UpdateRequestResult::SUCCESS, last_remove_results().at(0).second);
@@ -200,9 +220,9 @@ TEST_F(RequestQueueTest, RemoveSeveralRequests) {
std::vector<int64_t> remove_requests;
remove_requests.push_back(kRequestId);
remove_requests.push_back(kRequestId2);
- queue()->RemoveRequests(
- remove_requests,
- base::Bind(&RequestQueueTest::RemoveRequestDone, base::Unretained(this)));
+ queue()->RemoveRequests(remove_requests,
+ base::Bind(&RequestQueueTest::RemoveRequestsDone,
+ base::Unretained(this)));
PumpLoop();
ASSERT_EQ(2ul, last_remove_results().size());
ASSERT_EQ(UpdateRequestResult::SUCCESS, last_remove_results().at(0).second);
@@ -240,9 +260,12 @@ TEST_F(RequestQueueTest, PauseAndResume) {
// Pause the request.
queue()->ChangeRequestsState(
request_ids, SavePageRequest::RequestState::PAUSED,
- base::Bind(&RequestQueueTest::UpdateRequestDone, base::Unretained(this)));
+ base::Bind(&RequestQueueTest::UpdateMultipleRequestsDone,
+ base::Unretained(this)));
PumpLoop();
- ASSERT_EQ(UpdateRequestResult::SUCCESS, last_update_result());
+ ASSERT_EQ(1ul, last_multiple_update_results().size());
+ ASSERT_EQ(UpdateRequestResult::SUCCESS,
+ last_multiple_update_results().at(0).second);
queue()->GetRequests(
base::Bind(&RequestQueueTest::GetRequestsDone, base::Unretained(this)));
@@ -257,9 +280,12 @@ TEST_F(RequestQueueTest, PauseAndResume) {
// Resume the request.
queue()->ChangeRequestsState(
request_ids, SavePageRequest::RequestState::AVAILABLE,
- base::Bind(&RequestQueueTest::UpdateRequestDone, base::Unretained(this)));
+ base::Bind(&RequestQueueTest::UpdateMultipleRequestsDone,
+ base::Unretained(this)));
PumpLoop();
- ASSERT_EQ(UpdateRequestResult::SUCCESS, last_update_result());
+ ASSERT_EQ(1ul, last_multiple_update_results().size());
+ ASSERT_EQ(UpdateRequestResult::SUCCESS,
+ last_multiple_update_results().at(0).second);
queue()->GetRequests(
base::Bind(&RequestQueueTest::GetRequestsDone, base::Unretained(this)));
@@ -297,9 +323,9 @@ TEST_F(RequestQueueTest, MultipleRequestsAddGetRemove) {
std::vector<int64_t> remove_requests;
remove_requests.push_back(request1.request_id());
- queue()->RemoveRequests(
- remove_requests,
- base::Bind(&RequestQueueTest::RemoveRequestDone, base::Unretained(this)));
+ queue()->RemoveRequests(remove_requests,
+ base::Bind(&RequestQueueTest::RemoveRequestsDone,
+ base::Unretained(this)));
PumpLoop();
ASSERT_EQ(1ul, last_remove_results().size());
ASSERT_EQ(kRequestId, last_remove_results().at(0).first);
« no previous file with comments | « components/offline_pages/background/request_queue_store_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698