summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
authortim@chromium.org <tim@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-29 19:08:29 +0000
committertim@chromium.org <tim@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-29 19:08:29 +0000
commitcb91fa208d1c5d98a8c0cd2dde26cdb225fec929 (patch)
tree14a8fc7fa000433cca8725657835b1f8dcac4d0f /chrome/browser
parent42dbdc3e3a1e81c7e4b3945b858ebec13c37110e (diff)
downloadchromium_src-cb91fa208d1c5d98a8c0cd2dde26cdb225fec929.zip
chromium_src-cb91fa208d1c5d98a8c0cd2dde26cdb225fec929.tar.gz
chromium_src-cb91fa208d1c5d98a8c0cd2dde26cdb225fec929.tar.bz2
Unflakify SyncerThreadWithSyncerTest.Polling by using TimeTicks instead of system time. Should have done that first, but I had started writing the test before writing the code and learning how to use TimeTicks.
TEST=SyncerThreadWithSyncerTest.Polling BUG=23336 Review URL: http://codereview.chromium.org/248034 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@27522 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/sync/engine/syncer_thread_unittest.cc22
1 files changed, 7 insertions, 15 deletions
diff --git a/chrome/browser/sync/engine/syncer_thread_unittest.cc b/chrome/browser/sync/engine/syncer_thread_unittest.cc
index ce6b9cc..f23b0500 100644
--- a/chrome/browser/sync/engine/syncer_thread_unittest.cc
+++ b/chrome/browser/sync/engine/syncer_thread_unittest.cc
@@ -17,7 +17,7 @@
#include "chrome/test/sync/engine/test_directory_setter_upper.h"
#include "testing/gtest/include/gtest/gtest.h"
-using base::Time;
+using base::TimeTicks;
using base::TimeDelta;
namespace browser_sync {
@@ -62,18 +62,18 @@ class SyncShareIntercept : public MockConnectionManager::MidCommitObserver {
SyncShareIntercept() : sync_occured_(false, false) {}
virtual ~SyncShareIntercept() {}
virtual void Observe() {
- times_sync_occured_.push_back(Time::NowFromSystemTime());
+ times_sync_occured_.push_back(TimeTicks::Now());
sync_occured_.Signal();
}
void WaitForSyncShare(int at_least_this_many, TimeDelta max_wait) {
while (at_least_this_many-- > 0)
sync_occured_.TimedWait(max_wait);
}
- std::vector<Time> times_sync_occured() const {
+ std::vector<TimeTicks> times_sync_occured() const {
return times_sync_occured_;
}
private:
- std::vector<Time> times_sync_occured_;
+ std::vector<TimeTicks> times_sync_occured_;
base::WaitableEvent sync_occured_;
DISALLOW_COPY_AND_ASSIGN(SyncShareIntercept);
};
@@ -364,8 +364,6 @@ TEST_F(SyncerThreadTest, CalculatePollingWaitTime) {
}
}
-// This test is disabled. see bug 23336.
-#if 0
TEST_F(SyncerThreadWithSyncerTest, Polling) {
SyncShareIntercept interceptor;
connection()->SetMidCommitObserver(&interceptor);
@@ -388,24 +386,18 @@ TEST_F(SyncerThreadWithSyncerTest, Polling) {
EXPECT_TRUE(syncer_thread()->Stop(2000));
// Now analyze the run.
- std::vector<Time> data = interceptor.times_sync_occured();
+ std::vector<TimeTicks> data = interceptor.times_sync_occured();
EXPECT_GE(data.size(), static_cast<unsigned int>(3));
for (unsigned int i = 0; i < data.size() - 1; i++) {
- Time optimal_next_sync = data[i] + poll_interval;
- // The pthreads impl uses a different time impl and is slightly (~900usecs)
- // off, so this expectation can fail with --syncer-thread-pthreads.
- EXPECT_TRUE(data[i + 1] >= optimal_next_sync)
- << "difference is "
- << (data[i + 1] - optimal_next_sync).InMicroseconds() << " usecs. "
- << "~900usec delta is OK with --syncer-thread-pthreads";
+ TimeTicks optimal_next_sync = data[i] + poll_interval;
+ EXPECT_TRUE(data[i + 1] >= optimal_next_sync);
// This should be reliable, as there are no blocking or I/O operations
// except the explicit 2 second wait, so if it takes longer than this
// there is a problem.
EXPECT_TRUE(data[i + 1] < optimal_next_sync + poll_interval);
}
}
-#endif
TEST_F(SyncerThreadWithSyncerTest, Nudge) {
SyncShareIntercept interceptor;