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

Side by Side Diff: components/offline_pages/background/mark_attempt_aborted_task_unittest.cc

Issue 2599593002: Fix for crbug.com/675863 - don't clobber PAUSE state. (Closed)
Patch Set: Add unit test back in. 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 unified diff | Download patch
« no previous file with comments | « no previous file | components/offline_pages/background/save_page_request.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/offline_pages/background/mark_attempt_aborted_task.h" 5 #include "components/offline_pages/background/mark_attempt_aborted_task.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/test/test_simple_task_runner.h" 10 #include "base/test/test_simple_task_runner.h"
11 #include "base/threading/thread_task_runner_handle.h" 11 #include "base/threading/thread_task_runner_handle.h"
12 #include "components/offline_pages/background/change_requests_state_task.h"
12 #include "components/offline_pages/background/mark_attempt_started_task.h" 13 #include "components/offline_pages/background/mark_attempt_started_task.h"
13 #include "components/offline_pages/background/request_queue_in_memory_store.h" 14 #include "components/offline_pages/background/request_queue_in_memory_store.h"
14 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
15 16
16 namespace offline_pages { 17 namespace offline_pages {
17 namespace { 18 namespace {
18 const int64_t kRequestId1 = 42; 19 const int64_t kRequestId1 = 42;
19 const int64_t kRequestId2 = 44; 20 const int64_t kRequestId2 = 44;
20 const GURL kUrl1("http://example.com"); 21 const GURL kUrl1("http://example.com");
21 const ClientId kClientId1("download", "1234"); 22 const ClientId kClientId1("download", "1234");
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 task.Run(); 135 task.Run();
135 PumpLoop(); 136 PumpLoop();
136 ASSERT_TRUE(last_result()); 137 ASSERT_TRUE(last_result());
137 EXPECT_EQ(1UL, last_result()->item_statuses.size()); 138 EXPECT_EQ(1UL, last_result()->item_statuses.size());
138 EXPECT_EQ(kRequestId2, last_result()->item_statuses.at(0).first); 139 EXPECT_EQ(kRequestId2, last_result()->item_statuses.at(0).first);
139 EXPECT_EQ(ItemActionStatus::NOT_FOUND, 140 EXPECT_EQ(ItemActionStatus::NOT_FOUND,
140 last_result()->item_statuses.at(0).second); 141 last_result()->item_statuses.at(0).second);
141 EXPECT_EQ(0UL, last_result()->updated_items.size()); 142 EXPECT_EQ(0UL, last_result()->updated_items.size());
142 } 143 }
143 144
145 TEST_F(MarkAttemptAbortedTaskTest, MarkAttemptAbortedWhenPaused) {
146 RequestQueueInMemoryStore store;
147 AddItemToStore(&store);
148
149 // First mark attempt started.
150 MarkAttemptStartedTask start_request_task(
151 &store, kRequestId1,
152 base::Bind(&MarkAttemptAbortedTaskTest::ChangeRequestsStateCallback,
153 base::Unretained(this)));
154 start_request_task.Run();
155 PumpLoop();
156 ClearResults();
157
158 // Mark the attempt as PAUSED, so we test the PAUSED to PAUSED transition.
159 std::vector<int64_t> requests;
160 requests.push_back(kRequestId1);
161 ChangeRequestsStateTask pauseTask(
162 &store, requests, SavePageRequest::RequestState::PAUSED,
163 base::Bind(&MarkAttemptAbortedTaskTest::ChangeRequestsStateCallback,
164 base::Unretained(this)));
165 pauseTask.Run();
166 PumpLoop();
167
168 // Abort the task, the state should not change from PAUSED.
169 MarkAttemptAbortedTask abortTask(
170 &store, kRequestId1,
171 base::Bind(&MarkAttemptAbortedTaskTest::ChangeRequestsStateCallback,
172 base::Unretained(this)));
173
174 abortTask.Run();
175 PumpLoop();
176 ASSERT_TRUE(last_result());
177 EXPECT_EQ(1UL, last_result()->item_statuses.size());
178 EXPECT_EQ(kRequestId1, last_result()->item_statuses.at(0).first);
179 EXPECT_EQ(ItemActionStatus::SUCCESS,
180 last_result()->item_statuses.at(0).second);
181 EXPECT_EQ(1UL, last_result()->updated_items.size());
182 EXPECT_EQ(SavePageRequest::RequestState::PAUSED,
183 last_result()->updated_items.at(0).request_state());
184 }
185
186
144 } // namespace offline_pages 187 } // namespace offline_pages
OLDNEW
« no previous file with comments | « no previous file | components/offline_pages/background/save_page_request.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698