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

Unified Diff: components/offline_pages/core/background/mark_attempt_aborted_task_unittest.cc

Issue 2598573003: Fix for crbug.com/675863 - don't clobber PAUSE state. (Closed)
Patch Set: CR feedback per DewittJ and DougArnett Created 4 years 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 | « no previous file | components/offline_pages/core/background/save_page_request.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/offline_pages/core/background/mark_attempt_aborted_task_unittest.cc
diff --git a/components/offline_pages/core/background/mark_attempt_aborted_task_unittest.cc b/components/offline_pages/core/background/mark_attempt_aborted_task_unittest.cc
index 0a94c696b7cf1d1a536dc4a2456fa65f350e291e..bc15169e305cb36ee49a70bdbb598bba952900b0 100644
--- a/components/offline_pages/core/background/mark_attempt_aborted_task_unittest.cc
+++ b/components/offline_pages/core/background/mark_attempt_aborted_task_unittest.cc
@@ -9,6 +9,7 @@
#include "base/bind.h"
#include "base/test/test_simple_task_runner.h"
#include "base/threading/thread_task_runner_handle.h"
+#include "components/offline_pages/core/background/change_requests_state_task.h"
#include "components/offline_pages/core/background/mark_attempt_started_task.h"
#include "components/offline_pages/core/background/request_queue_in_memory_store.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -157,4 +158,46 @@ TEST_F(MarkAttemptAbortedTaskTest, MarkAttemptAbortedWhenItemMissing) {
EXPECT_EQ(0UL, last_result()->updated_items.size());
}
+TEST_F(MarkAttemptAbortedTaskTest, MarkAttemptAbortedWhenPaused) {
+ RequestQueueInMemoryStore store;
+ InitializeStore(&store);
+ AddItemToStore(&store);
+
+ // First mark attempt started.
+ MarkAttemptStartedTask start_request_task(
+ &store, kRequestId1,
+ base::Bind(&MarkAttemptAbortedTaskTest::ChangeRequestsStateCallback,
+ base::Unretained(this)));
+ start_request_task.Run();
+ PumpLoop();
+ ClearResults();
+
+ // Mark the attempt as PAUSED, so we test the PAUSED to PAUSED transition.
+ std::vector<int64_t> requests;
+ requests.push_back(kRequestId1);
+ ChangeRequestsStateTask pauseTask(
+ &store, requests, SavePageRequest::RequestState::PAUSED,
+ base::Bind(&MarkAttemptAbortedTaskTest::ChangeRequestsStateCallback,
+ base::Unretained(this)));
+ pauseTask.Run();
+ PumpLoop();
+
+ // Abort the task, the state should not change from PAUSED.
+ MarkAttemptAbortedTask abortTask(
+ &store, kRequestId1,
+ base::Bind(&MarkAttemptAbortedTaskTest::ChangeRequestsStateCallback,
+ base::Unretained(this)));
+
+ abortTask.Run();
+ PumpLoop();
+ ASSERT_TRUE(last_result());
+ EXPECT_EQ(1UL, last_result()->item_statuses.size());
+ EXPECT_EQ(kRequestId1, last_result()->item_statuses.at(0).first);
+ EXPECT_EQ(ItemActionStatus::SUCCESS,
+ last_result()->item_statuses.at(0).second);
+ EXPECT_EQ(1UL, last_result()->updated_items.size());
+ EXPECT_EQ(SavePageRequest::RequestState::PAUSED,
+ last_result()->updated_items.at(0).request_state());
+}
+
} // namespace offline_pages
« no previous file with comments | « no previous file | components/offline_pages/core/background/save_page_request.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698