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

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

Issue 6267015: sync: fix a couple less-than comparisons to be less-than-eq in tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/chrome/browser/sync
Patch Set: Created 9 years, 10 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 | « no previous file | 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "base/synchronization/waitable_event.h" 5 #include "base/synchronization/waitable_event.h"
6 #include "base/test/test_timeouts.h" 6 #include "base/test/test_timeouts.h"
7 #include "chrome/browser/sync/engine/mock_model_safe_workers.h" 7 #include "chrome/browser/sync/engine/mock_model_safe_workers.h"
8 #include "chrome/browser/sync/engine/syncer.h" 8 #include "chrome/browser/sync/engine/syncer.h"
9 #include "chrome/browser/sync/engine/syncer_thread2.h" 9 #include "chrome/browser/sync/engine/syncer_thread2.h"
10 #include "chrome/browser/sync/sessions/test_util.h" 10 #include "chrome/browser/sync/sessions/test_util.h"
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 } 81 }
82 82
83 void AnalyzePollRun(const SyncShareRecords& records, size_t min_num_samples, 83 void AnalyzePollRun(const SyncShareRecords& records, size_t min_num_samples,
84 const TimeTicks& optimal_start, const TimeDelta& poll_interval) { 84 const TimeTicks& optimal_start, const TimeDelta& poll_interval) {
85 const std::vector<TimeTicks>& data(records.times); 85 const std::vector<TimeTicks>& data(records.times);
86 EXPECT_GE(data.size(), min_num_samples); 86 EXPECT_GE(data.size(), min_num_samples);
87 for (size_t i = 0; i < data.size(); i++) { 87 for (size_t i = 0; i < data.size(); i++) {
88 SCOPED_TRACE(testing::Message() << "SyncShare # (" << i << ")"); 88 SCOPED_TRACE(testing::Message() << "SyncShare # (" << i << ")");
89 TimeTicks optimal_next_sync = optimal_start + poll_interval * i; 89 TimeTicks optimal_next_sync = optimal_start + poll_interval * i;
90 EXPECT_GE(data[i], optimal_next_sync); 90 EXPECT_GE(data[i], optimal_next_sync);
91 EXPECT_LT(data[i], optimal_next_sync + poll_interval); 91 EXPECT_LE(data[i], optimal_next_sync + poll_interval);
92 EXPECT_EQ(GetUpdatesCallerInfo::PERIODIC, 92 EXPECT_EQ(GetUpdatesCallerInfo::PERIODIC,
93 records.snapshots[i]->source.first); 93 records.snapshots[i]->source.first);
94 } 94 }
95 } 95 }
96 96
97 bool GetBackoffAndResetTest(base::WaitableEvent* done) { 97 bool GetBackoffAndResetTest(base::WaitableEvent* done) {
98 syncable::ModelTypeBitSet nudge_types; 98 syncable::ModelTypeBitSet nudge_types;
99 syncer_thread()->Start(SyncerThread::NORMAL_MODE); 99 syncer_thread()->Start(SyncerThread::NORMAL_MODE);
100 syncer_thread()->ScheduleNudge(zero(), NUDGE_SOURCE_LOCAL, nudge_types); 100 syncer_thread()->ScheduleNudge(zero(), NUDGE_SOURCE_LOCAL, nudge_types);
101 done->TimedWait(timeout()); 101 done->TimedWait(timeout());
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after
495 .WillOnce(Invoke(sessions::test_util::SimulateCommitFailed)) 495 .WillOnce(Invoke(sessions::test_util::SimulateCommitFailed))
496 .WillOnce(Invoke(sessions::test_util::SimulateCommitFailed)) 496 .WillOnce(Invoke(sessions::test_util::SimulateCommitFailed))
497 .WillRepeatedly(DoAll(Invoke(sessions::test_util::SimulateSuccess), 497 .WillRepeatedly(DoAll(Invoke(sessions::test_util::SimulateSuccess),
498 RecordSyncShareAndPostSignal(&r, kMinNumSamples, this, &done))); 498 RecordSyncShareAndPostSignal(&r, kMinNumSamples, this, &done)));
499 EXPECT_CALL(*delay(), GetDelay(_)).WillOnce(Return(backoff)); 499 EXPECT_CALL(*delay(), GetDelay(_)).WillOnce(Return(backoff));
500 500
501 // Optimal start for the post-backoff poll party. 501 // Optimal start for the post-backoff poll party.
502 TimeTicks optimal_start = TimeTicks::Now() + poll + backoff; 502 TimeTicks optimal_start = TimeTicks::Now() + poll + backoff;
503 syncer_thread()->Start(SyncerThread::NORMAL_MODE); 503 syncer_thread()->Start(SyncerThread::NORMAL_MODE);
504 done.TimedWait(timeout()); 504 done.TimedWait(timeout());
505 syncer_thread()->Stop();
505 506
506 // Check for healthy polling after backoff is relieved. 507 // Check for healthy polling after backoff is relieved.
507 // Can't use AnalyzePollRun because first sync is a continuation. Bleh. 508 // Can't use AnalyzePollRun because first sync is a continuation. Bleh.
508 for (size_t i = 0; i < r.times.size(); i++) { 509 for (size_t i = 0; i < r.times.size(); i++) {
509 SCOPED_TRACE(testing::Message() << "SyncShare # (" << i << ")"); 510 SCOPED_TRACE(testing::Message() << "SyncShare # (" << i << ")");
510 TimeTicks optimal_next_sync = optimal_start + poll * i; 511 TimeTicks optimal_next_sync = optimal_start + poll * i;
511 EXPECT_GE(r.times[i], optimal_next_sync); 512 EXPECT_GE(r.times[i], optimal_next_sync);
512 EXPECT_LT(r.times[i], optimal_next_sync + poll); 513 EXPECT_LE(r.times[i], optimal_next_sync + poll);
513 EXPECT_EQ(i == 0 ? GetUpdatesCallerInfo::SYNC_CYCLE_CONTINUATION 514 EXPECT_EQ(i == 0 ? GetUpdatesCallerInfo::SYNC_CYCLE_CONTINUATION
514 : GetUpdatesCallerInfo::PERIODIC, 515 : GetUpdatesCallerInfo::PERIODIC,
515 r.snapshots[i]->source.first); 516 r.snapshots[i]->source.first);
516 } 517 }
517 } 518 }
518 519
519 TEST_F(SyncerThread2Test, GetRecommendedDelay) { 520 TEST_F(SyncerThread2Test, GetRecommendedDelay) {
520 EXPECT_LE(TimeDelta::FromSeconds(0), 521 EXPECT_LE(TimeDelta::FromSeconds(0),
521 SyncerThread::GetRecommendedDelay(TimeDelta::FromSeconds(0))); 522 SyncerThread::GetRecommendedDelay(TimeDelta::FromSeconds(0)));
522 EXPECT_LE(TimeDelta::FromSeconds(1), 523 EXPECT_LE(TimeDelta::FromSeconds(1),
(...skipping 22 matching lines...) Expand all
545 TEST_F(SyncerThread2Test, DISABLED_StartWhenNotConnected) { 546 TEST_F(SyncerThread2Test, DISABLED_StartWhenNotConnected) {
546 547
547 } 548 }
548 549
549 } // namespace s3 550 } // namespace s3
550 } // namespace browser_sync 551 } // namespace browser_sync
551 552
552 // SyncerThread won't outlive the test! 553 // SyncerThread won't outlive the test!
553 DISABLE_RUNNABLE_METHOD_REFCOUNT(browser_sync::s3::SyncerThread2Test); 554 DISABLE_RUNNABLE_METHOD_REFCOUNT(browser_sync::s3::SyncerThread2Test);
554 555
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698