OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/engine/download.h" | 5 #include "sync/engine/download.h" |
6 #include "sync/protocol/sync.pb.h" | 6 #include "sync/protocol/sync.pb.h" |
7 #include "sync/sessions/nudge_tracker.h" | 7 #include "sync/sessions/nudge_tracker.h" |
8 #include "sync/test/engine/fake_model_worker.h" | 8 #include "sync/test/engine/fake_model_worker.h" |
9 #include "sync/test/engine/syncer_command_test.h" | 9 #include "sync/test/engine/syncer_command_test.h" |
10 | 10 |
(...skipping 27 matching lines...) Expand all Loading... |
38 TEST_F(DownloadUpdatesTest, ExecuteNoStates) { | 38 TEST_F(DownloadUpdatesTest, ExecuteNoStates) { |
39 ConfigureMockServerConnection(); | 39 ConfigureMockServerConnection(); |
40 | 40 |
41 sessions::NudgeTracker nudge_tracker; | 41 sessions::NudgeTracker nudge_tracker; |
42 nudge_tracker.RecordLocalChange(ModelTypeSet(BOOKMARKS)); | 42 nudge_tracker.RecordLocalChange(ModelTypeSet(BOOKMARKS)); |
43 | 43 |
44 mock_server()->ExpectGetUpdatesRequestTypes( | 44 mock_server()->ExpectGetUpdatesRequestTypes( |
45 GetRoutingInfoTypes(routing_info())); | 45 GetRoutingInfoTypes(routing_info())); |
46 scoped_ptr<sessions::SyncSession> session( | 46 scoped_ptr<sessions::SyncSession> session( |
47 sessions::SyncSession::Build(context(), | 47 sessions::SyncSession::Build(context(), |
48 delegate(), | 48 delegate())); |
49 nudge_tracker.GetSourceInfo())); | |
50 NormalDownloadUpdates(session.get(), | 49 NormalDownloadUpdates(session.get(), |
51 false, | 50 false, |
52 GetRoutingInfoTypes(routing_info()), | 51 GetRoutingInfoTypes(routing_info()), |
53 nudge_tracker); | 52 nudge_tracker); |
54 } | 53 } |
55 | 54 |
56 TEST_F(DownloadUpdatesTest, ExecuteWithStates) { | 55 TEST_F(DownloadUpdatesTest, ExecuteWithStates) { |
57 ConfigureMockServerConnection(); | 56 ConfigureMockServerConnection(); |
58 | 57 |
59 sessions::NudgeTracker nudge_tracker; | 58 sessions::NudgeTracker nudge_tracker; |
60 nudge_tracker.RecordRemoteInvalidation( | 59 nudge_tracker.RecordRemoteInvalidation( |
61 ModelTypeSetToInvalidationMap(ModelTypeSet(AUTOFILL), | 60 ModelTypeSetToInvalidationMap(ModelTypeSet(AUTOFILL), |
62 "autofill_payload")); | 61 "autofill_payload")); |
63 nudge_tracker.RecordRemoteInvalidation( | 62 nudge_tracker.RecordRemoteInvalidation( |
64 ModelTypeSetToInvalidationMap(ModelTypeSet(BOOKMARKS), | 63 ModelTypeSetToInvalidationMap(ModelTypeSet(BOOKMARKS), |
65 "bookmark_payload")); | 64 "bookmark_payload")); |
66 nudge_tracker.RecordRemoteInvalidation( | 65 nudge_tracker.RecordRemoteInvalidation( |
67 ModelTypeSetToInvalidationMap(ModelTypeSet(PREFERENCES), | 66 ModelTypeSetToInvalidationMap(ModelTypeSet(PREFERENCES), |
68 "preferences_payload")); | 67 "preferences_payload")); |
69 | 68 |
| 69 ModelTypeInvalidationMap invalidation_map; |
| 70 Invalidation i1; |
| 71 i1.payload = "autofill_payload"; |
| 72 invalidation_map.insert(std::make_pair(AUTOFILL, i1)); |
| 73 Invalidation i2; |
| 74 i2.payload = "bookmark_payload"; |
| 75 invalidation_map.insert(std::make_pair(BOOKMARKS, i2)); |
| 76 Invalidation i3; |
| 77 i3.payload = "preferences_payload"; |
| 78 invalidation_map.insert(std::make_pair(PREFERENCES, i3)); |
| 79 |
70 mock_server()->ExpectGetUpdatesRequestTypes( | 80 mock_server()->ExpectGetUpdatesRequestTypes( |
71 GetRoutingInfoTypes(routing_info())); | 81 GetRoutingInfoTypes(routing_info())); |
72 mock_server()->ExpectGetUpdatesRequestStates( | 82 mock_server()->ExpectGetUpdatesRequestStates( |
73 nudge_tracker.GetSourceInfo().types); | 83 invalidation_map); |
74 scoped_ptr<sessions::SyncSession> session( | 84 scoped_ptr<sessions::SyncSession> session( |
75 sessions::SyncSession::Build(context(), | 85 sessions::SyncSession::Build(context(), delegate())); |
76 delegate(), | |
77 nudge_tracker.GetSourceInfo())); | |
78 NormalDownloadUpdates(session.get(), | 86 NormalDownloadUpdates(session.get(), |
79 false, | 87 false, |
80 GetRoutingInfoTypes(routing_info()), | 88 GetRoutingInfoTypes(routing_info()), |
81 nudge_tracker); | 89 nudge_tracker); |
82 } | 90 } |
83 | 91 |
84 TEST_F(DownloadUpdatesTest, VerifyAppendDebugInfo) { | 92 TEST_F(DownloadUpdatesTest, VerifyAppendDebugInfo) { |
85 sync_pb::DebugInfo debug_info; | 93 sync_pb::DebugInfo debug_info; |
86 EXPECT_CALL(*(mock_debug_info_getter()), GetAndClearDebugInfo(_)) | 94 EXPECT_CALL(*(mock_debug_info_getter()), GetAndClearDebugInfo(_)) |
87 .Times(1); | 95 .Times(1); |
88 // The first of a set of repeated GUs will set it. | 96 // The first of a set of repeated GUs will set it. |
89 AppendClientDebugInfoIfNeeded(session(), &debug_info); | 97 AppendClientDebugInfoIfNeeded(session(), &debug_info); |
90 | 98 |
91 // Subsequent GUs will not. | 99 // Subsequent GUs will not. |
92 // Verify by checking that GetAndClearDebugInfo() is not called again. | 100 // Verify by checking that GetAndClearDebugInfo() is not called again. |
93 AppendClientDebugInfoIfNeeded(session(), &debug_info); | 101 AppendClientDebugInfoIfNeeded(session(), &debug_info); |
94 } | 102 } |
95 | 103 |
96 } // namespace syncer | 104 } // namespace syncer |
OLD | NEW |