OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/notifier/ack_tracker.h" | 5 #include "sync/notifier/ack_tracker.h" |
6 | 6 |
7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/time/tick_clock.h" | 10 #include "base/time/tick_clock.h" |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 | 102 |
103 FakeTickClock fake_tick_clock_; | 103 FakeTickClock fake_tick_clock_; |
104 ::testing::StrictMock<MockDelegate> delegate_; | 104 ::testing::StrictMock<MockDelegate> delegate_; |
105 AckTracker ack_tracker_; | 105 AckTracker ack_tracker_; |
106 | 106 |
107 const invalidation::ObjectId kIdOne; | 107 const invalidation::ObjectId kIdOne; |
108 const invalidation::ObjectId kIdTwo; | 108 const invalidation::ObjectId kIdTwo; |
109 | 109 |
110 // AckTracker uses base::Timer internally, which depends on the existence of a | 110 // AckTracker uses base::Timer internally, which depends on the existence of a |
111 // MessageLoop. | 111 // MessageLoop. |
112 MessageLoop message_loop_; | 112 base::MessageLoop message_loop_; |
113 }; | 113 }; |
114 | 114 |
115 // Tests that various combinations of Track()/Ack() behave as | 115 // Tests that various combinations of Track()/Ack() behave as |
116 // expected. | 116 // expected. |
117 TEST_F(AckTrackerTest, TrackAndAck) { | 117 TEST_F(AckTrackerTest, TrackAndAck) { |
118 ObjectIdSet ids_one; | 118 ObjectIdSet ids_one; |
119 ids_one.insert(kIdOne); | 119 ids_one.insert(kIdOne); |
120 ObjectIdSet ids_two; | 120 ObjectIdSet ids_two; |
121 ids_two.insert(kIdTwo); | 121 ids_two.insert(kIdTwo); |
122 ObjectIdSet ids_all; | 122 ObjectIdSet ids_all; |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
343 EXPECT_EQ(base::TimeDelta::FromSeconds(120), GetTimerDelay()); | 343 EXPECT_EQ(base::TimeDelta::FromSeconds(120), GetTimerDelay()); |
344 fake_tick_clock_.LeapForward(120); | 344 fake_tick_clock_.LeapForward(120); |
345 EXPECT_CALL(delegate_, OnTimeout(ids)); | 345 EXPECT_CALL(delegate_, OnTimeout(ids)); |
346 EXPECT_TRUE(TriggerTimeoutNow()); | 346 EXPECT_TRUE(TriggerTimeoutNow()); |
347 | 347 |
348 ack_tracker_.Ack(ids); | 348 ack_tracker_.Ack(ids); |
349 EXPECT_TRUE(ack_tracker_.IsQueueEmptyForTest()); | 349 EXPECT_TRUE(ack_tracker_.IsQueueEmptyForTest()); |
350 } | 350 } |
351 | 351 |
352 } // namespace syncer | 352 } // namespace syncer |
OLD | NEW |