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

Side by Side Diff: chrome/browser/sync/engine/syncer_thread_unittest.cc

Issue 275015: For sync exponential backoff, allow one nudge per exponential backoff interva... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/sync/engine/syncer_thread.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 <list> 5 #include <list>
6 #include <map> 6 #include <map>
7 #include <set> 7 #include <set>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/scoped_ptr.h" 10 #include "base/scoped_ptr.h"
11 #include "base/time.h" 11 #include "base/time.h"
12 #include "chrome/browser/sync/engine/model_safe_worker.h" 12 #include "chrome/browser/sync/engine/model_safe_worker.h"
13 #include "chrome/browser/sync/engine/syncer_thread.h" 13 #include "chrome/browser/sync/engine/syncer_thread.h"
14 #include "chrome/browser/sync/engine/syncer_thread_timed_stop.h" 14 #include "chrome/browser/sync/engine/syncer_thread_timed_stop.h"
15 #include "chrome/test/sync/engine/mock_server_connection.h" 15 #include "chrome/test/sync/engine/mock_server_connection.h"
16 #include "chrome/test/sync/engine/test_directory_setter_upper.h" 16 #include "chrome/test/sync/engine/test_directory_setter_upper.h"
17 #include "testing/gtest/include/gtest/gtest.h" 17 #include "testing/gtest/include/gtest/gtest.h"
18 18
19 using base::TimeTicks; 19 using base::TimeTicks;
20 using base::TimeDelta; 20 using base::TimeDelta;
21 21
22 namespace browser_sync { 22 namespace browser_sync {
23 23
24 typedef testing::Test SyncerThreadTest; 24 typedef testing::Test SyncerThreadTest;
25 typedef SyncerThread::WaitInterval WaitInterval;
25 26
26 class SyncerThreadWithSyncerTest : public testing::Test { 27 class SyncerThreadWithSyncerTest : public testing::Test {
27 public: 28 public:
28 SyncerThreadWithSyncerTest() {} 29 SyncerThreadWithSyncerTest() {}
29 virtual void SetUp() { 30 virtual void SetUp() {
30 metadb_.SetUp(); 31 metadb_.SetUp();
31 connection_.reset(new MockConnectionManager(metadb_.manager(), 32 connection_.reset(new MockConnectionManager(metadb_.manager(),
32 metadb_.name())); 33 metadb_.name()));
33 allstatus_.reset(new AllStatus()); 34 allstatus_.reset(new AllStatus());
34 35
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 syncer_thread->CalculateSyncWaitTime(last_poll_time, 152 syncer_thread->CalculateSyncWaitTime(last_poll_time,
152 over_sync_max_interval)); 153 over_sync_max_interval));
153 } 154 }
154 155
155 TEST_F(SyncerThreadTest, CalculatePollingWaitTime) { 156 TEST_F(SyncerThreadTest, CalculatePollingWaitTime) {
156 // Set up the environment. 157 // Set up the environment.
157 int user_idle_milliseconds_param = 0; 158 int user_idle_milliseconds_param = 0;
158 scoped_refptr<SyncerThread> syncer_thread( 159 scoped_refptr<SyncerThread> syncer_thread(
159 SyncerThreadFactory::Create(NULL, NULL, NULL, NULL, NULL)); 160 SyncerThreadFactory::Create(NULL, NULL, NULL, NULL, NULL));
160 syncer_thread->DisableIdleDetection(); 161 syncer_thread->DisableIdleDetection();
162 // Hold the lock to appease asserts in code.
163 AutoLock lock(syncer_thread->lock_);
161 164
162 // Notifications disabled should result in a polling interval of 165 // Notifications disabled should result in a polling interval of
163 // kDefaultShortPollInterval. 166 // kDefaultShortPollInterval.
164 { 167 {
165 AllStatus::Status status = {}; 168 AllStatus::Status status = {};
166 status.notifications_enabled = 0; 169 status.notifications_enabled = 0;
167 bool continue_sync_cycle_param = false; 170 bool continue_sync_cycle_param = false;
168 171
169 // No work and no backoff. 172 // No work and no backoff.
170 ASSERT_TRUE(SyncerThread::kDefaultShortPollIntervalSeconds == 173 WaitInterval interval = syncer_thread->CalculatePollingWaitTime(
171 syncer_thread->CalculatePollingWaitTime( 174 status,
172 status, 175 0,
173 0, 176 &user_idle_milliseconds_param,
174 &user_idle_milliseconds_param, 177 &continue_sync_cycle_param,
175 &continue_sync_cycle_param)); 178 false);
179
180 ASSERT_EQ(SyncerThread::kDefaultShortPollIntervalSeconds,
181 interval.poll_delta.InSeconds());
182 ASSERT_EQ(WaitInterval::NORMAL, interval.mode);
183 ASSERT_FALSE(interval.had_nudge_during_backoff);
176 ASSERT_FALSE(continue_sync_cycle_param); 184 ASSERT_FALSE(continue_sync_cycle_param);
177 185
178 // In this case the continue_sync_cycle is turned off. 186 // In this case the continue_sync_cycle is turned off.
179 continue_sync_cycle_param = true; 187 continue_sync_cycle_param = true;
180 ASSERT_TRUE(SyncerThread::kDefaultShortPollIntervalSeconds == 188 interval = syncer_thread->CalculatePollingWaitTime(
181 syncer_thread->CalculatePollingWaitTime( 189 status,
182 status, 190 0,
183 0, 191 &user_idle_milliseconds_param,
184 &user_idle_milliseconds_param, 192 &continue_sync_cycle_param,
185 &continue_sync_cycle_param)); 193 false);
194
195 ASSERT_EQ(SyncerThread::kDefaultShortPollIntervalSeconds,
196 interval.poll_delta.InSeconds());
197 ASSERT_EQ(WaitInterval::NORMAL, interval.mode);
198 ASSERT_FALSE(interval.had_nudge_during_backoff);
186 ASSERT_FALSE(continue_sync_cycle_param); 199 ASSERT_FALSE(continue_sync_cycle_param);
187
188 // TODO(brg) : Find a way to test exponential backoff is inoperable.
189 // Exponential backoff should be turned on when notifications are disabled
190 // but this can not be tested since we can not set the last input info.
191 } 200 }
192 201
193 // Notifications enabled should result in a polling interval of 202 // Notifications enabled should result in a polling interval of
194 // SyncerThread::kDefaultLongPollIntervalSeconds. 203 // SyncerThread::kDefaultLongPollIntervalSeconds.
195 { 204 {
196 AllStatus::Status status = {}; 205 AllStatus::Status status = {};
197 status.notifications_enabled = 1; 206 status.notifications_enabled = 1;
198 bool continue_sync_cycle_param = false; 207 bool continue_sync_cycle_param = false;
199 208
200 // No work and no backoff. 209 // No work and no backoff.
201 ASSERT_TRUE(SyncerThread::kDefaultLongPollIntervalSeconds == 210 WaitInterval interval = syncer_thread->CalculatePollingWaitTime(
202 syncer_thread->CalculatePollingWaitTime( 211 status,
203 status, 212 0,
204 0, 213 &user_idle_milliseconds_param,
205 &user_idle_milliseconds_param, 214 &continue_sync_cycle_param,
206 &continue_sync_cycle_param)); 215 false);
216
217 ASSERT_EQ(SyncerThread::kDefaultLongPollIntervalSeconds,
218 interval.poll_delta.InSeconds());
219 ASSERT_EQ(WaitInterval::NORMAL, interval.mode);
220 ASSERT_FALSE(interval.had_nudge_during_backoff);
207 ASSERT_FALSE(continue_sync_cycle_param); 221 ASSERT_FALSE(continue_sync_cycle_param);
208 222
209 // In this case the continue_sync_cycle is turned off. 223 // In this case the continue_sync_cycle is turned off.
210 continue_sync_cycle_param = true; 224 continue_sync_cycle_param = true;
211 ASSERT_TRUE(SyncerThread::kDefaultLongPollIntervalSeconds == 225 interval = syncer_thread->CalculatePollingWaitTime(
212 syncer_thread->CalculatePollingWaitTime( 226 status,
213 status, 227 0,
214 0, 228 &user_idle_milliseconds_param,
215 &user_idle_milliseconds_param, 229 &continue_sync_cycle_param,
216 &continue_sync_cycle_param)); 230 false);
231
232 ASSERT_EQ(SyncerThread::kDefaultLongPollIntervalSeconds,
233 interval.poll_delta.InSeconds());
234 ASSERT_EQ(WaitInterval::NORMAL, interval.mode);
235 ASSERT_FALSE(interval.had_nudge_during_backoff);
217 ASSERT_FALSE(continue_sync_cycle_param); 236 ASSERT_FALSE(continue_sync_cycle_param);
218
219 // TODO(brg) : Find a way to test exponential backoff.
220 // Exponential backoff should be turned off when notifications are enabled,
221 // but this can not be tested since we can not set the last input info.
222 } 237 }
223 238
224 // There are two states which can cause a continuation, either the updates 239 // There are two states which can cause a continuation, either the updates
225 // available do not match the updates received, or the unsynced count is 240 // available do not match the updates received, or the unsynced count is
226 // non-zero. 241 // non-zero.
227 { 242 {
228 AllStatus::Status status = {}; 243 AllStatus::Status status = {};
229 status.updates_available = 1; 244 status.updates_available = 1;
230 status.updates_received = 0; 245 status.updates_received = 0;
231 bool continue_sync_cycle_param = false; 246 bool continue_sync_cycle_param = false;
232 247
233 ASSERT_TRUE(0 <= syncer_thread->CalculatePollingWaitTime( 248 WaitInterval interval = syncer_thread->CalculatePollingWaitTime(
234 status, 249 status,
235 0, 250 0,
236 &user_idle_milliseconds_param, 251 &user_idle_milliseconds_param,
237 &continue_sync_cycle_param)); 252 &continue_sync_cycle_param,
253 false);
254
255 ASSERT_LE(0, interval.poll_delta.InSeconds());
256 ASSERT_EQ(WaitInterval::NORMAL, interval.mode);
257 ASSERT_FALSE(interval.had_nudge_during_backoff);
238 ASSERT_TRUE(continue_sync_cycle_param); 258 ASSERT_TRUE(continue_sync_cycle_param);
239 259
240 continue_sync_cycle_param = false; 260 continue_sync_cycle_param = false;
241 ASSERT_TRUE(3 >= syncer_thread->CalculatePollingWaitTime( 261 interval = syncer_thread->CalculatePollingWaitTime(
242 status, 262 status,
243 0, 263 0,
244 &user_idle_milliseconds_param, 264 &user_idle_milliseconds_param,
245 &continue_sync_cycle_param)); 265 &continue_sync_cycle_param,
266 false);
267
268 ASSERT_GE(3, interval.poll_delta.InSeconds());
269 ASSERT_EQ(WaitInterval::NORMAL, interval.mode);
270 ASSERT_FALSE(interval.had_nudge_during_backoff);
246 ASSERT_TRUE(continue_sync_cycle_param); 271 ASSERT_TRUE(continue_sync_cycle_param);
247 272
248 ASSERT_TRUE(0 <= syncer_thread->CalculatePollingWaitTime( 273 interval = syncer_thread->CalculatePollingWaitTime(
249 status, 274 status,
250 0, 275 0,
251 &user_idle_milliseconds_param, 276 &user_idle_milliseconds_param,
252 &continue_sync_cycle_param)); 277 &continue_sync_cycle_param,
253 ASSERT_TRUE(2 >= syncer_thread->CalculatePollingWaitTime( 278 false);
254 status, 279
255 0, 280 ASSERT_LE(0, interval.poll_delta.InSeconds());
256 &user_idle_milliseconds_param, 281 ASSERT_EQ(WaitInterval::EXPONENTIAL_BACKOFF, interval.mode);
257 &continue_sync_cycle_param)); 282 ASSERT_FALSE(interval.had_nudge_during_backoff);
283
284 interval = syncer_thread->CalculatePollingWaitTime(
285 status,
286 0,
287 &user_idle_milliseconds_param,
288 &continue_sync_cycle_param,
289 false);
290
291 ASSERT_GE(2, interval.poll_delta.InSeconds());
292 ASSERT_EQ(WaitInterval::EXPONENTIAL_BACKOFF, interval.mode);
293 ASSERT_FALSE(interval.had_nudge_during_backoff);
258 ASSERT_TRUE(continue_sync_cycle_param); 294 ASSERT_TRUE(continue_sync_cycle_param);
259 295
260 status.updates_received = 1; 296 status.updates_received = 1;
261 ASSERT_TRUE(SyncerThread::kDefaultShortPollIntervalSeconds == 297 interval = syncer_thread->CalculatePollingWaitTime(
262 syncer_thread->CalculatePollingWaitTime( 298 status,
263 status, 299 0,
264 10, 300 &user_idle_milliseconds_param,
265 &user_idle_milliseconds_param, 301 &continue_sync_cycle_param,
266 &continue_sync_cycle_param)); 302 false);
303
304 ASSERT_EQ(SyncerThread::kDefaultShortPollIntervalSeconds,
305 interval.poll_delta.InSeconds());
306 ASSERT_EQ(WaitInterval::NORMAL, interval.mode);
307 ASSERT_FALSE(interval.had_nudge_during_backoff);
267 ASSERT_FALSE(continue_sync_cycle_param); 308 ASSERT_FALSE(continue_sync_cycle_param);
268 } 309 }
269 310
270 { 311 {
271 AllStatus::Status status = {}; 312 AllStatus::Status status = {};
272 status.unsynced_count = 1; 313 status.unsynced_count = 1;
273 bool continue_sync_cycle_param = false; 314 bool continue_sync_cycle_param = false;
274 315
275 ASSERT_TRUE(0 <= syncer_thread->CalculatePollingWaitTime( 316 WaitInterval interval = syncer_thread->CalculatePollingWaitTime(
276 status, 317 status,
277 0, 318 0,
278 &user_idle_milliseconds_param, 319 &user_idle_milliseconds_param,
279 &continue_sync_cycle_param)); 320 &continue_sync_cycle_param,
321 false);
322
323 ASSERT_LE(0, interval.poll_delta.InSeconds());
324 ASSERT_EQ(WaitInterval::NORMAL, interval.mode);
325 ASSERT_FALSE(interval.had_nudge_during_backoff);
280 ASSERT_TRUE(continue_sync_cycle_param); 326 ASSERT_TRUE(continue_sync_cycle_param);
281 327
282 continue_sync_cycle_param = false; 328 continue_sync_cycle_param = false;
283 ASSERT_TRUE(2 >= syncer_thread->CalculatePollingWaitTime( 329 interval = syncer_thread->CalculatePollingWaitTime(
284 status, 330 status,
285 0, 331 0,
286 &user_idle_milliseconds_param, 332 &user_idle_milliseconds_param,
287 &continue_sync_cycle_param)); 333 &continue_sync_cycle_param,
334 false);
335
336 ASSERT_GE(2, interval.poll_delta.InSeconds());
337 ASSERT_EQ(WaitInterval::NORMAL, interval.mode);
338 ASSERT_FALSE(interval.had_nudge_during_backoff);
288 ASSERT_TRUE(continue_sync_cycle_param); 339 ASSERT_TRUE(continue_sync_cycle_param);
289 340
290 status.unsynced_count = 0; 341 status.unsynced_count = 0;
291 ASSERT_TRUE(SyncerThread::kDefaultShortPollIntervalSeconds == 342 interval = syncer_thread->CalculatePollingWaitTime(
292 syncer_thread->CalculatePollingWaitTime( 343 status,
293 status, 344 4,
294 4, 345 &user_idle_milliseconds_param,
295 &user_idle_milliseconds_param, 346 &continue_sync_cycle_param,
296 &continue_sync_cycle_param)); 347 false);
348
349 ASSERT_EQ(SyncerThread::kDefaultShortPollIntervalSeconds,
350 interval.poll_delta.InSeconds());
351 ASSERT_EQ(WaitInterval::NORMAL, interval.mode);
352 ASSERT_FALSE(interval.had_nudge_during_backoff);
297 ASSERT_FALSE(continue_sync_cycle_param); 353 ASSERT_FALSE(continue_sync_cycle_param);
298 } 354 }
299 355
300 // Regression for exponential backoff reset when the syncer is nudged. 356 // Regression for exponential backoff reset when the syncer is nudged.
301 { 357 {
302 AllStatus::Status status = {}; 358 AllStatus::Status status = {};
303 status.unsynced_count = 1; 359 status.unsynced_count = 1;
304 bool continue_sync_cycle_param = false; 360 bool continue_sync_cycle_param = false;
305 361
306 // Expect move from default polling interval to exponential backoff due to 362 // Expect move from default polling interval to exponential backoff due to
307 // unsynced_count != 0. 363 // unsynced_count != 0.
308 ASSERT_TRUE(0 <= syncer_thread->CalculatePollingWaitTime( 364 WaitInterval interval = syncer_thread->CalculatePollingWaitTime(
309 status, 365 status,
310 3600, 366 3600,
311 &user_idle_milliseconds_param, 367 &user_idle_milliseconds_param,
312 &continue_sync_cycle_param)); 368 &continue_sync_cycle_param,
369 false);
370
371 ASSERT_LE(0, interval.poll_delta.InSeconds());
372 ASSERT_EQ(WaitInterval::NORMAL, interval.mode);
373 ASSERT_FALSE(interval.had_nudge_during_backoff);
313 ASSERT_TRUE(continue_sync_cycle_param); 374 ASSERT_TRUE(continue_sync_cycle_param);
314 375
315 continue_sync_cycle_param = false; 376 continue_sync_cycle_param = false;
316 ASSERT_TRUE(2 >= syncer_thread->CalculatePollingWaitTime( 377 interval = syncer_thread->CalculatePollingWaitTime(
317 status, 378 status,
318 3600, 379 3600,
319 &user_idle_milliseconds_param, 380 &user_idle_milliseconds_param,
320 &continue_sync_cycle_param)); 381 &continue_sync_cycle_param,
382 false);
383
384 ASSERT_GE(2, interval.poll_delta.InSeconds());
385 ASSERT_EQ(WaitInterval::NORMAL, interval.mode);
386 ASSERT_FALSE(interval.had_nudge_during_backoff);
321 ASSERT_TRUE(continue_sync_cycle_param); 387 ASSERT_TRUE(continue_sync_cycle_param);
322 388
323 // Expect exponential backoff. 389 // Expect exponential backoff.
324 ASSERT_TRUE(2 <= syncer_thread->CalculatePollingWaitTime( 390 interval = syncer_thread->CalculatePollingWaitTime(
325 status, 391 status,
326 2, 392 2,
327 &user_idle_milliseconds_param, 393 &user_idle_milliseconds_param,
328 &continue_sync_cycle_param)); 394 &continue_sync_cycle_param,
329 ASSERT_TRUE(6 >= syncer_thread->CalculatePollingWaitTime( 395 false);
330 status, 396
331 2, 397 ASSERT_LE(2, interval.poll_delta.InSeconds());
332 &user_idle_milliseconds_param, 398 ASSERT_EQ(WaitInterval::EXPONENTIAL_BACKOFF, interval.mode);
333 &continue_sync_cycle_param)); 399 ASSERT_FALSE(interval.had_nudge_during_backoff);
400 ASSERT_TRUE(continue_sync_cycle_param);
401
402 interval = syncer_thread->CalculatePollingWaitTime(
403 status,
404 2,
405 &user_idle_milliseconds_param,
406 &continue_sync_cycle_param,
407 false);
408
409 ASSERT_GE(6, interval.poll_delta.InSeconds());
410 ASSERT_EQ(WaitInterval::EXPONENTIAL_BACKOFF, interval.mode);
411 ASSERT_FALSE(interval.had_nudge_during_backoff);
412 ASSERT_TRUE(continue_sync_cycle_param);
413
414 syncer_thread->vault_.current_wait_interval_ = interval;
415
416 interval = syncer_thread->CalculatePollingWaitTime(
417 status,
418 static_cast<int>(interval.poll_delta.InSeconds()),
419 &user_idle_milliseconds_param,
420 &continue_sync_cycle_param,
421 true);
422
423 // Don't change poll on a failed nudge during backoff.
424 ASSERT_TRUE(syncer_thread->vault_.current_wait_interval_.poll_delta ==
425 interval.poll_delta);
426 ASSERT_EQ(WaitInterval::EXPONENTIAL_BACKOFF, interval.mode);
427 ASSERT_TRUE(interval.had_nudge_during_backoff);
428 ASSERT_TRUE(continue_sync_cycle_param);
429
430 // If we got a nudge and we weren't in backoff mode, we see exponential
431 // backoff.
432 syncer_thread->vault_.current_wait_interval_.mode = WaitInterval::NORMAL;
433 interval = syncer_thread->CalculatePollingWaitTime(
434 status,
435 2,
436 &user_idle_milliseconds_param,
437 &continue_sync_cycle_param,
438 true);
439
440 // 5 and 3 are bounds on the backoff randomization formula given input of 2.
441 ASSERT_GE(5, interval.poll_delta.InSeconds());
442 ASSERT_LE(3, interval.poll_delta.InSeconds());
443 ASSERT_EQ(WaitInterval::EXPONENTIAL_BACKOFF, interval.mode);
444 ASSERT_FALSE(interval.had_nudge_during_backoff);
445 ASSERT_TRUE(continue_sync_cycle_param);
446
447 // And if another interval expires, we get a bigger backoff.
448 WaitInterval new_interval = syncer_thread->CalculatePollingWaitTime(
449 status,
450 static_cast<int>(interval.poll_delta.InSeconds()),
451 &user_idle_milliseconds_param,
452 &continue_sync_cycle_param,
453 false);
454
455 ASSERT_GE(12, new_interval.poll_delta.InSeconds());
456 ASSERT_LE(5, new_interval.poll_delta.InSeconds());
457 ASSERT_EQ(WaitInterval::EXPONENTIAL_BACKOFF, interval.mode);
458 ASSERT_FALSE(new_interval.had_nudge_during_backoff);
334 ASSERT_TRUE(continue_sync_cycle_param); 459 ASSERT_TRUE(continue_sync_cycle_param);
335 460
336 // A nudge resets the continue_sync_cycle_param value, so our backoff 461 // A nudge resets the continue_sync_cycle_param value, so our backoff
337 // should return to the minimum. 462 // should return to the minimum.
338 continue_sync_cycle_param = false; 463 continue_sync_cycle_param = false;
339 ASSERT_TRUE(0 <= syncer_thread->CalculatePollingWaitTime( 464 interval = syncer_thread->CalculatePollingWaitTime(
340 status, 465 status,
341 3600, 466 3600,
342 &user_idle_milliseconds_param, 467 &user_idle_milliseconds_param,
343 &continue_sync_cycle_param)); 468 &continue_sync_cycle_param,
469 true);
470
471 ASSERT_LE(0, interval.poll_delta.InSeconds());
472 ASSERT_EQ(WaitInterval::NORMAL, interval.mode);
473 ASSERT_FALSE(interval.had_nudge_during_backoff);
344 ASSERT_TRUE(continue_sync_cycle_param); 474 ASSERT_TRUE(continue_sync_cycle_param);
345 475
346 continue_sync_cycle_param = false; 476 continue_sync_cycle_param = false;
347 ASSERT_TRUE(2 >= syncer_thread->CalculatePollingWaitTime( 477 interval = syncer_thread->CalculatePollingWaitTime(
348 status, 478 status,
349 3600, 479 3600,
350 &user_idle_milliseconds_param, 480 &user_idle_milliseconds_param,
351 &continue_sync_cycle_param)); 481 &continue_sync_cycle_param,
482 true);
483
484 ASSERT_GE(2, interval.poll_delta.InSeconds());
485 ASSERT_EQ(WaitInterval::NORMAL, interval.mode);
486 ASSERT_FALSE(interval.had_nudge_during_backoff);
352 ASSERT_TRUE(continue_sync_cycle_param); 487 ASSERT_TRUE(continue_sync_cycle_param);
353 488
354 // Setting unsynced_count = 0 returns us to the default polling interval. 489 // Setting unsynced_count = 0 returns us to the default polling interval.
355 status.unsynced_count = 0; 490 status.unsynced_count = 0;
356 ASSERT_TRUE(SyncerThread::kDefaultShortPollIntervalSeconds == 491 interval = syncer_thread->CalculatePollingWaitTime(
357 syncer_thread->CalculatePollingWaitTime( 492 status,
358 status, 493 4,
359 4, 494 &user_idle_milliseconds_param,
360 &user_idle_milliseconds_param, 495 &continue_sync_cycle_param,
361 &continue_sync_cycle_param)); 496 true);
497
498 ASSERT_EQ(SyncerThread::kDefaultShortPollIntervalSeconds,
499 interval.poll_delta.InSeconds());
500 ASSERT_EQ(WaitInterval::NORMAL, interval.mode);
501 ASSERT_FALSE(interval.had_nudge_during_backoff);
362 ASSERT_FALSE(continue_sync_cycle_param); 502 ASSERT_FALSE(continue_sync_cycle_param);
363 } 503 }
364 } 504 }
365 505
366 TEST_F(SyncerThreadWithSyncerTest, Polling) { 506 TEST_F(SyncerThreadWithSyncerTest, Polling) {
367 SyncShareIntercept interceptor; 507 SyncShareIntercept interceptor;
368 connection()->SetMidCommitObserver(&interceptor); 508 connection()->SetMidCommitObserver(&interceptor);
369 509
370 const TimeDelta poll_interval = TimeDelta::FromSeconds(1); 510 const TimeDelta poll_interval = TimeDelta::FromSeconds(1);
371 syncer_thread()->SetSyncerShortPollInterval(poll_interval); 511 syncer_thread()->SetSyncerShortPollInterval(poll_interval);
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 syncer_thread()->NudgeSyncer(5, SyncerThread::kUnknown); 555 syncer_thread()->NudgeSyncer(5, SyncerThread::kUnknown);
416 interceptor.WaitForSyncShare(1, TimeDelta::FromSeconds(1)); 556 interceptor.WaitForSyncShare(1, TimeDelta::FromSeconds(1));
417 EXPECT_EQ(static_cast<unsigned int>(2), 557 EXPECT_EQ(static_cast<unsigned int>(2),
418 interceptor.times_sync_occured().size()); 558 interceptor.times_sync_occured().size());
419 559
420 // SyncerThread should be waiting again. Signal it to stop. 560 // SyncerThread should be waiting again. Signal it to stop.
421 EXPECT_TRUE(syncer_thread()->Stop(2000)); 561 EXPECT_TRUE(syncer_thread()->Stop(2000));
422 } 562 }
423 563
424 } // namespace browser_sync 564 } // namespace browser_sync
OLDNEW
« no previous file with comments | « chrome/browser/sync/engine/syncer_thread.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698