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

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: Cleaned up Created 4 years, 12 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 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 "sync/internal_api/public/attachments/task_queue.h"
6 6
7 #include <utility>
7 #include <vector> 8 #include <vector>
8 9
9 #include "base/bind.h" 10 #include "base/bind.h"
10 #include "base/memory/weak_ptr.h" 11 #include "base/memory/weak_ptr.h"
11 #include "base/message_loop/message_loop.h" 12 #include "base/message_loop/message_loop.h"
12 #include "base/run_loop.h" 13 #include "base/run_loop.h"
13 #include "base/timer/mock_timer.h" 14 #include "base/timer/mock_timer.h"
14 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
15 16
16 using base::TimeDelta; 17 using base::TimeDelta;
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 queue_->MarkAsSucceeded(2); 94 queue_->MarkAsSucceeded(2);
94 RunLoop(); 95 RunLoop();
95 96
96 ASSERT_TRUE(dispatched_.empty()); 97 ASSERT_TRUE(dispatched_.empty());
97 } 98 }
98 99
99 // See that Retry works as expected. 100 // See that Retry works as expected.
100 TEST_F(TaskQueueTest, Retry) { 101 TEST_F(TaskQueueTest, Retry) {
101 scoped_ptr<base::MockTimer> timer_to_pass(new base::MockTimer(false, false)); 102 scoped_ptr<base::MockTimer> timer_to_pass(new base::MockTimer(false, false));
102 base::MockTimer* mock_timer = timer_to_pass.get(); 103 base::MockTimer* mock_timer = timer_to_pass.get();
103 queue_->SetTimerForTest(timer_to_pass.Pass()); 104 queue_->SetTimerForTest(std::move(timer_to_pass));
104 105
105 // 1st attempt. 106 // 1st attempt.
106 queue_->AddToQueue(1); 107 queue_->AddToQueue(1);
107 ASSERT_TRUE(mock_timer->IsRunning()); 108 ASSERT_TRUE(mock_timer->IsRunning());
108 ASSERT_EQ(kZero, mock_timer->GetCurrentDelay()); 109 ASSERT_EQ(kZero, mock_timer->GetCurrentDelay());
109 TimeDelta last_delay = mock_timer->GetCurrentDelay(); 110 TimeDelta last_delay = mock_timer->GetCurrentDelay();
110 mock_timer->Fire(); 111 mock_timer->Fire();
111 RunLoop(); 112 RunLoop();
112 113
113 // 2nd attempt. 114 // 2nd attempt.
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 queue_->Cancel(1); 192 queue_->Cancel(1);
192 RunLoop(); 193 RunLoop();
193 194
194 ASSERT_TRUE(dispatched_.empty()); 195 ASSERT_TRUE(dispatched_.empty());
195 } 196 }
196 197
197 // See that ResetBackoff resets the backoff delay. 198 // See that ResetBackoff resets the backoff delay.
198 TEST_F(TaskQueueTest, ResetBackoff) { 199 TEST_F(TaskQueueTest, ResetBackoff) {
199 scoped_ptr<base::MockTimer> timer_to_pass(new base::MockTimer(false, false)); 200 scoped_ptr<base::MockTimer> timer_to_pass(new base::MockTimer(false, false));
200 base::MockTimer* mock_timer = timer_to_pass.get(); 201 base::MockTimer* mock_timer = timer_to_pass.get();
201 queue_->SetTimerForTest(timer_to_pass.Pass()); 202 queue_->SetTimerForTest(std::move(timer_to_pass));
202 203
203 // Add an item, mark it as failed, re-add it and see that we now have a 204 // Add an item, mark it as failed, re-add it and see that we now have a
204 // backoff delay. 205 // backoff delay.
205 queue_->AddToQueue(1); 206 queue_->AddToQueue(1);
206 ASSERT_TRUE(mock_timer->IsRunning()); 207 ASSERT_TRUE(mock_timer->IsRunning());
207 ASSERT_EQ(kZero, mock_timer->GetCurrentDelay()); 208 ASSERT_EQ(kZero, mock_timer->GetCurrentDelay());
208 mock_timer->Fire(); 209 mock_timer->Fire();
209 RunLoop(); 210 RunLoop();
210 ASSERT_FALSE(mock_timer->IsRunning()); 211 ASSERT_FALSE(mock_timer->IsRunning());
211 ASSERT_EQ(1U, dispatched_.size()); 212 ASSERT_EQ(1U, dispatched_.size());
(...skipping 12 matching lines...) Expand all
224 mock_timer->Fire(); 225 mock_timer->Fire();
225 RunLoop(); 226 RunLoop();
226 ASSERT_FALSE(mock_timer->IsRunning()); 227 ASSERT_FALSE(mock_timer->IsRunning());
227 ASSERT_EQ(1U, dispatched_.size()); 228 ASSERT_EQ(1U, dispatched_.size());
228 EXPECT_EQ(1, dispatched_.front()); 229 EXPECT_EQ(1, dispatched_.front());
229 dispatched_.clear(); 230 dispatched_.clear();
230 queue_->MarkAsSucceeded(1); 231 queue_->MarkAsSucceeded(1);
231 } 232 }
232 233
233 } // namespace syncer 234 } // namespace syncer
OLDNEW
« no previous file with comments | « sync/internal_api/attachments/on_disk_attachment_store_unittest.cc ('k') | sync/internal_api/events/protocol_event.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698