| 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/sessions/nudge_tracker.h" | 5 #include "sync/sessions/nudge_tracker.h" |
| 6 | 6 |
| 7 #include "sync/internal_api/public/base/model_type_invalidation_map.h" | 7 #include "sync/internal_api/public/base/model_type_invalidation_map.h" |
| 8 #include "sync/internal_api/public/sessions/sync_source_info.h" | 8 #include "sync/internal_api/public/sessions/sync_source_info.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 | 10 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 nudge_tracker.FillProtoMessage(type, &gu_trigger); | 46 nudge_tracker.FillProtoMessage(type, &gu_trigger); |
| 47 return gu_trigger.local_modification_nudges(); | 47 return gu_trigger.local_modification_nudges(); |
| 48 } | 48 } |
| 49 | 49 |
| 50 int ProtoRefreshRequestedCount(const NudgeTracker& nudge_tracker, | 50 int ProtoRefreshRequestedCount(const NudgeTracker& nudge_tracker, |
| 51 ModelType type) { | 51 ModelType type) { |
| 52 sync_pb::GetUpdateTriggers gu_trigger; | 52 sync_pb::GetUpdateTriggers gu_trigger; |
| 53 nudge_tracker.FillProtoMessage(type, &gu_trigger); | 53 nudge_tracker.FillProtoMessage(type, &gu_trigger); |
| 54 return gu_trigger.datatype_refresh_nudges(); | 54 return gu_trigger.datatype_refresh_nudges(); |
| 55 } | 55 } |
| 56 |
| 57 void FullySync(NudgeTracker* nudge_tracker) { |
| 58 // We enable invalidations and perform a successful sync cycle so our |
| 59 // invalidations list will be 100% up to date and reliable. |
| 60 nudge_tracker->OnInvalidationsEnabled(); |
| 61 nudge_tracker->RecordSuccessfulSyncCycle(); |
| 62 } |
| 56 }; | 63 }; |
| 57 | 64 |
| 58 // Exercise an empty NudgeTracker. | 65 // Exercise an empty NudgeTracker. |
| 59 // Use with valgrind to detect uninitialized members. | 66 // Use with valgrind to detect uninitialized members. |
| 60 TEST_F(NudgeTrackerTest, EmptyNudgeTracker) { | 67 TEST_F(NudgeTrackerTest, EmptyNudgeTracker) { |
| 61 NudgeTracker nudge_tracker; | 68 NudgeTracker nudge_tracker; |
| 62 | 69 |
| 63 EXPECT_FALSE(nudge_tracker.IsSyncRequired()); | 70 EXPECT_FALSE(nudge_tracker.IsSyncRequired()); |
| 64 EXPECT_EQ(sync_pb::GetUpdatesCallerInfo::UNKNOWN, | 71 EXPECT_EQ(sync_pb::GetUpdatesCallerInfo::UNKNOWN, |
| 65 nudge_tracker.updates_source()); | 72 nudge_tracker.updates_source()); |
| (...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 405 ModelTypeSet(SESSIONS, PREFERENCES), | 412 ModelTypeSet(SESSIONS, PREFERENCES), |
| 406 nudge_tracker.GetThrottledTypes())); | 413 nudge_tracker.GetThrottledTypes())); |
| 407 EXPECT_EQ(throttle2_length - throttle1_length, | 414 EXPECT_EQ(throttle2_length - throttle1_length, |
| 408 nudge_tracker.GetTimeUntilNextUnthrottle(t1)); | 415 nudge_tracker.GetTimeUntilNextUnthrottle(t1)); |
| 409 | 416 |
| 410 // Expire the second interval. | 417 // Expire the second interval. |
| 411 nudge_tracker.UpdateTypeThrottlingState(t2); | 418 nudge_tracker.UpdateTypeThrottlingState(t2); |
| 412 EXPECT_TRUE(nudge_tracker.GetThrottledTypes().Empty()); | 419 EXPECT_TRUE(nudge_tracker.GetThrottledTypes().Empty()); |
| 413 } | 420 } |
| 414 | 421 |
| 415 | |
| 416 } // namespace sessions | 422 } // namespace sessions |
| 417 } // namespace syncer | 423 } // namespace syncer |
| OLD | NEW |