| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 sync_pb::GetUpdateTriggers gu_trigger; | 64 sync_pb::GetUpdateTriggers gu_trigger; |
| 65 nudge_tracker_.FillProtoMessage(type, &gu_trigger); | 65 nudge_tracker_.FillProtoMessage(type, &gu_trigger); |
| 66 return gu_trigger.datatype_refresh_nudges(); | 66 return gu_trigger.datatype_refresh_nudges(); |
| 67 } | 67 } |
| 68 | 68 |
| 69 void SetInvalidationsInSync() { | 69 void SetInvalidationsInSync() { |
| 70 nudge_tracker_.OnInvalidationsEnabled(); | 70 nudge_tracker_.OnInvalidationsEnabled(); |
| 71 nudge_tracker_.RecordSuccessfulSyncCycle(); | 71 nudge_tracker_.RecordSuccessfulSyncCycle(); |
| 72 } | 72 } |
| 73 | 73 |
| 74 scoped_ptr<InvalidationInterface> BuildInvalidation( | 74 std::unique_ptr<InvalidationInterface> BuildInvalidation( |
| 75 int64_t version, | 75 int64_t version, |
| 76 const std::string& payload) { | 76 const std::string& payload) { |
| 77 return MockInvalidation::Build(version, payload); | 77 return MockInvalidation::Build(version, payload); |
| 78 } | 78 } |
| 79 | 79 |
| 80 static scoped_ptr<InvalidationInterface> BuildUnknownVersionInvalidation() { | 80 static std::unique_ptr<InvalidationInterface> |
| 81 BuildUnknownVersionInvalidation() { |
| 81 return MockInvalidation::BuildUnknownVersion(); | 82 return MockInvalidation::BuildUnknownVersion(); |
| 82 } | 83 } |
| 83 | 84 |
| 84 protected: | 85 protected: |
| 85 NudgeTracker nudge_tracker_; | 86 NudgeTracker nudge_tracker_; |
| 86 }; | 87 }; |
| 87 | 88 |
| 88 // Exercise an empty NudgeTracker. | 89 // Exercise an empty NudgeTracker. |
| 89 // Use with valgrind to detect uninitialized members. | 90 // Use with valgrind to detect uninitialized members. |
| 90 TEST_F(NudgeTrackerTest, EmptyNudgeTracker) { | 91 TEST_F(NudgeTrackerTest, EmptyNudgeTracker) { |
| (...skipping 738 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 829 bool IsInvalidationAcknowledged(int tracking_id) { | 830 bool IsInvalidationAcknowledged(int tracking_id) { |
| 830 return tracker_.IsAcknowledged(tracking_id); | 831 return tracker_.IsAcknowledged(tracking_id); |
| 831 } | 832 } |
| 832 | 833 |
| 833 bool IsInvalidationDropped(int tracking_id) { | 834 bool IsInvalidationDropped(int tracking_id) { |
| 834 return tracker_.IsDropped(tracking_id); | 835 return tracker_.IsDropped(tracking_id); |
| 835 } | 836 } |
| 836 | 837 |
| 837 int SendInvalidation(ModelType type, int version, const std::string& hint) { | 838 int SendInvalidation(ModelType type, int version, const std::string& hint) { |
| 838 // Build and register the invalidation. | 839 // Build and register the invalidation. |
| 839 scoped_ptr<TrackableMockInvalidation> inv = | 840 std::unique_ptr<TrackableMockInvalidation> inv = |
| 840 tracker_.IssueInvalidation(version, hint); | 841 tracker_.IssueInvalidation(version, hint); |
| 841 int id = inv->GetTrackingId(); | 842 int id = inv->GetTrackingId(); |
| 842 | 843 |
| 843 // Send it to the NudgeTracker. | 844 // Send it to the NudgeTracker. |
| 844 nudge_tracker_.RecordRemoteInvalidation(type, std::move(inv)); | 845 nudge_tracker_.RecordRemoteInvalidation(type, std::move(inv)); |
| 845 | 846 |
| 846 // Return its ID to the test framework for use in assertions. | 847 // Return its ID to the test framework for use in assertions. |
| 847 return id; | 848 return id; |
| 848 } | 849 } |
| 849 | 850 |
| 850 int SendUnknownVersionInvalidation(ModelType type) { | 851 int SendUnknownVersionInvalidation(ModelType type) { |
| 851 // Build and register the invalidation. | 852 // Build and register the invalidation. |
| 852 scoped_ptr<TrackableMockInvalidation> inv = | 853 std::unique_ptr<TrackableMockInvalidation> inv = |
| 853 tracker_.IssueUnknownVersionInvalidation(); | 854 tracker_.IssueUnknownVersionInvalidation(); |
| 854 int id = inv->GetTrackingId(); | 855 int id = inv->GetTrackingId(); |
| 855 | 856 |
| 856 // Send it to the NudgeTracker. | 857 // Send it to the NudgeTracker. |
| 857 nudge_tracker_.RecordRemoteInvalidation(type, std::move(inv)); | 858 nudge_tracker_.RecordRemoteInvalidation(type, std::move(inv)); |
| 858 | 859 |
| 859 // Return its ID to the test framework for use in assertions. | 860 // Return its ID to the test framework for use in assertions. |
| 860 return id; | 861 return id; |
| 861 } | 862 } |
| 862 | 863 |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 972 EXPECT_TRUE(IsInvalidationAcknowledged(inv2_id)); | 973 EXPECT_TRUE(IsInvalidationAcknowledged(inv2_id)); |
| 973 EXPECT_TRUE(IsInvalidationAcknowledged(inv3_id)); | 974 EXPECT_TRUE(IsInvalidationAcknowledged(inv3_id)); |
| 974 EXPECT_TRUE(IsInvalidationAcknowledged(inv4_id)); | 975 EXPECT_TRUE(IsInvalidationAcknowledged(inv4_id)); |
| 975 EXPECT_TRUE(IsInvalidationAcknowledged(inv5_id)); | 976 EXPECT_TRUE(IsInvalidationAcknowledged(inv5_id)); |
| 976 | 977 |
| 977 EXPECT_TRUE(AllInvalidationsAccountedFor()); | 978 EXPECT_TRUE(AllInvalidationsAccountedFor()); |
| 978 } | 979 } |
| 979 | 980 |
| 980 } // namespace sessions | 981 } // namespace sessions |
| 981 } // namespace syncer | 982 } // namespace syncer |
| OLD | NEW |