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

Side by Side Diff: sync/internal_api/attachments/task_queue_unittest.cc

Issue 1539843002: Convert Pass()→std::move() in sync/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "sync/internal_api/public/attachments/task_queue.h" 5 #include <utility>
6
7 #include <vector> 6 #include <vector>
8 7
9 #include "base/bind.h" 8 #include "base/bind.h"
10 #include "base/memory/weak_ptr.h" 9 #include "base/memory/weak_ptr.h"
11 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
12 #include "base/run_loop.h" 11 #include "base/run_loop.h"
13 #include "base/timer/mock_timer.h" 12 #include "base/timer/mock_timer.h"
13 #include "sync/internal_api/public/attachments/task_queue.h"
Nicolas Zea 2015/12/18 23:46:55 keep up top
14 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
15 15
16 using base::TimeDelta; 16 using base::TimeDelta;
17 17
18 namespace syncer { 18 namespace syncer {
19 19
20 namespace { 20 namespace {
21 21
22 const TimeDelta kZero; 22 const TimeDelta kZero;
23 23
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 queue_->MarkAsSucceeded(2); 93 queue_->MarkAsSucceeded(2);
94 RunLoop(); 94 RunLoop();
95 95
96 ASSERT_TRUE(dispatched_.empty()); 96 ASSERT_TRUE(dispatched_.empty());
97 } 97 }
98 98
99 // See that Retry works as expected. 99 // See that Retry works as expected.
100 TEST_F(TaskQueueTest, Retry) { 100 TEST_F(TaskQueueTest, Retry) {
101 scoped_ptr<base::MockTimer> timer_to_pass(new base::MockTimer(false, false)); 101 scoped_ptr<base::MockTimer> timer_to_pass(new base::MockTimer(false, false));
102 base::MockTimer* mock_timer = timer_to_pass.get(); 102 base::MockTimer* mock_timer = timer_to_pass.get();
103 queue_->SetTimerForTest(timer_to_pass.Pass()); 103 queue_->SetTimerForTest(std::move(timer_to_pass));
104 104
105 // 1st attempt. 105 // 1st attempt.
106 queue_->AddToQueue(1); 106 queue_->AddToQueue(1);
107 ASSERT_TRUE(mock_timer->IsRunning()); 107 ASSERT_TRUE(mock_timer->IsRunning());
108 ASSERT_EQ(kZero, mock_timer->GetCurrentDelay()); 108 ASSERT_EQ(kZero, mock_timer->GetCurrentDelay());
109 TimeDelta last_delay = mock_timer->GetCurrentDelay(); 109 TimeDelta last_delay = mock_timer->GetCurrentDelay();
110 mock_timer->Fire(); 110 mock_timer->Fire();
111 RunLoop(); 111 RunLoop();
112 112
113 // 2nd attempt. 113 // 2nd attempt.
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 queue_->Cancel(1); 191 queue_->Cancel(1);
192 RunLoop(); 192 RunLoop();
193 193
194 ASSERT_TRUE(dispatched_.empty()); 194 ASSERT_TRUE(dispatched_.empty());
195 } 195 }
196 196
197 // See that ResetBackoff resets the backoff delay. 197 // See that ResetBackoff resets the backoff delay.
198 TEST_F(TaskQueueTest, ResetBackoff) { 198 TEST_F(TaskQueueTest, ResetBackoff) {
199 scoped_ptr<base::MockTimer> timer_to_pass(new base::MockTimer(false, false)); 199 scoped_ptr<base::MockTimer> timer_to_pass(new base::MockTimer(false, false));
200 base::MockTimer* mock_timer = timer_to_pass.get(); 200 base::MockTimer* mock_timer = timer_to_pass.get();
201 queue_->SetTimerForTest(timer_to_pass.Pass()); 201 queue_->SetTimerForTest(std::move(timer_to_pass));
202 202
203 // Add an item, mark it as failed, re-add it and see that we now have a 203 // Add an item, mark it as failed, re-add it and see that we now have a
204 // backoff delay. 204 // backoff delay.
205 queue_->AddToQueue(1); 205 queue_->AddToQueue(1);
206 ASSERT_TRUE(mock_timer->IsRunning()); 206 ASSERT_TRUE(mock_timer->IsRunning());
207 ASSERT_EQ(kZero, mock_timer->GetCurrentDelay()); 207 ASSERT_EQ(kZero, mock_timer->GetCurrentDelay());
208 mock_timer->Fire(); 208 mock_timer->Fire();
209 RunLoop(); 209 RunLoop();
210 ASSERT_FALSE(mock_timer->IsRunning()); 210 ASSERT_FALSE(mock_timer->IsRunning());
211 ASSERT_EQ(1U, dispatched_.size()); 211 ASSERT_EQ(1U, dispatched_.size());
(...skipping 12 matching lines...) Expand all
224 mock_timer->Fire(); 224 mock_timer->Fire();
225 RunLoop(); 225 RunLoop();
226 ASSERT_FALSE(mock_timer->IsRunning()); 226 ASSERT_FALSE(mock_timer->IsRunning());
227 ASSERT_EQ(1U, dispatched_.size()); 227 ASSERT_EQ(1U, dispatched_.size());
228 EXPECT_EQ(1, dispatched_.front()); 228 EXPECT_EQ(1, dispatched_.front());
229 dispatched_.clear(); 229 dispatched_.clear();
230 queue_->MarkAsSucceeded(1); 230 queue_->MarkAsSucceeded(1);
231 } 231 }
232 232
233 } // namespace syncer 233 } // namespace syncer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698