OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/get_updates_processor.h" | 5 #include "sync/engine/get_updates_processor.h" |
6 | 6 |
7 #include "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
9 #include "sync/engine/get_updates_delegate.h" | 9 #include "sync/engine/get_updates_delegate.h" |
10 #include "sync/engine/update_handler.h" | 10 #include "sync/engine/update_handler.h" |
11 #include "sync/internal_api/public/base/model_type_test_util.h" | 11 #include "sync/internal_api/public/base/model_type_test_util.h" |
12 #include "sync/protocol/sync.pb.h" | 12 #include "sync/protocol/sync.pb.h" |
13 #include "sync/sessions/debug_info_getter.h" | 13 #include "sync/sessions/debug_info_getter.h" |
14 #include "sync/sessions/nudge_tracker.h" | 14 #include "sync/sessions/nudge_tracker.h" |
15 #include "sync/sessions/status_controller.h" | 15 #include "sync/sessions/status_controller.h" |
16 #include "sync/test/engine/fake_model_worker.h" | 16 #include "sync/test/engine/fake_model_worker.h" |
17 #include "sync/test/engine/mock_update_handler.h" | 17 #include "sync/test/engine/mock_update_handler.h" |
| 18 #include "sync/test/mock_invalidation.h" |
18 #include "sync/test/sessions/mock_debug_info_getter.h" | 19 #include "sync/test/sessions/mock_debug_info_getter.h" |
19 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
20 | 21 |
21 namespace syncer { | 22 namespace syncer { |
22 | 23 |
| 24 namespace { |
| 25 |
| 26 scoped_ptr<InvalidationInterface> BuildInvalidation( |
| 27 int64 version, |
| 28 const std::string& payload) { |
| 29 return MockInvalidation::Build(version, payload) |
| 30 .PassAs<InvalidationInterface>(); |
| 31 } |
| 32 |
| 33 } // namespace |
| 34 |
23 using sessions::MockDebugInfoGetter; | 35 using sessions::MockDebugInfoGetter; |
24 | 36 |
25 // A test fixture for tests exercising download updates functions. | 37 // A test fixture for tests exercising download updates functions. |
26 class GetUpdatesProcessorTest : public ::testing::Test { | 38 class GetUpdatesProcessorTest : public ::testing::Test { |
27 protected: | 39 protected: |
28 GetUpdatesProcessorTest() : | 40 GetUpdatesProcessorTest() : |
29 kTestStartTime(base::TimeTicks::Now()), | 41 kTestStartTime(base::TimeTicks::Now()), |
30 update_handler_deleter_(&update_handler_map_) {} | 42 update_handler_deleter_(&update_handler_map_) {} |
31 | 43 |
32 virtual void SetUp() { | 44 virtual void SetUp() { |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 EXPECT_EQ(0, gu_trigger.local_modification_nudges()); | 138 EXPECT_EQ(0, gu_trigger.local_modification_nudges()); |
127 EXPECT_EQ(0, gu_trigger.datatype_refresh_nudges()); | 139 EXPECT_EQ(0, gu_trigger.datatype_refresh_nudges()); |
128 } | 140 } |
129 } | 141 } |
130 } | 142 } |
131 | 143 |
132 // Basic test to ensure invalidation payloads are expressed in the request. | 144 // Basic test to ensure invalidation payloads are expressed in the request. |
133 TEST_F(GetUpdatesProcessorTest, NotifyMany) { | 145 TEST_F(GetUpdatesProcessorTest, NotifyMany) { |
134 sessions::NudgeTracker nudge_tracker; | 146 sessions::NudgeTracker nudge_tracker; |
135 nudge_tracker.RecordRemoteInvalidation( | 147 nudge_tracker.RecordRemoteInvalidation( |
136 BuildInvalidationMap(AUTOFILL, 1, "autofill_payload")); | 148 AUTOFILL, BuildInvalidation(1, "autofill_payload")); |
137 nudge_tracker.RecordRemoteInvalidation( | 149 nudge_tracker.RecordRemoteInvalidation( |
138 BuildInvalidationMap(BOOKMARKS, 1, "bookmark_payload")); | 150 BOOKMARKS, BuildInvalidation(1, "bookmark_payload")); |
139 nudge_tracker.RecordRemoteInvalidation( | 151 nudge_tracker.RecordRemoteInvalidation( |
140 BuildInvalidationMap(PREFERENCES, 1, "preferences_payload")); | 152 PREFERENCES, BuildInvalidation(1, "preferences_payload")); |
141 ModelTypeSet notified_types; | 153 ModelTypeSet notified_types; |
142 notified_types.Put(AUTOFILL); | 154 notified_types.Put(AUTOFILL); |
143 notified_types.Put(BOOKMARKS); | 155 notified_types.Put(BOOKMARKS); |
144 notified_types.Put(PREFERENCES); | 156 notified_types.Put(PREFERENCES); |
145 | 157 |
146 sync_pb::ClientToServerMessage message; | 158 sync_pb::ClientToServerMessage message; |
147 NormalGetUpdatesDelegate normal_delegate(nudge_tracker); | 159 NormalGetUpdatesDelegate normal_delegate(nudge_tracker); |
148 scoped_ptr<GetUpdatesProcessor> processor( | 160 scoped_ptr<GetUpdatesProcessor> processor( |
149 BuildGetUpdatesProcessor(normal_delegate)); | 161 BuildGetUpdatesProcessor(normal_delegate)); |
150 processor->PrepareGetUpdates(enabled_types(), &message); | 162 processor->PrepareGetUpdates(enabled_types(), &message); |
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
455 TEST_F(DownloadUpdatesDebugInfoTest, VerifyCopyOverwrites) { | 467 TEST_F(DownloadUpdatesDebugInfoTest, VerifyCopyOverwrites) { |
456 sync_pb::DebugInfo debug_info; | 468 sync_pb::DebugInfo debug_info; |
457 AddDebugEvent(); | 469 AddDebugEvent(); |
458 GetUpdatesProcessor::CopyClientDebugInfo(debug_info_getter(), &debug_info); | 470 GetUpdatesProcessor::CopyClientDebugInfo(debug_info_getter(), &debug_info); |
459 EXPECT_EQ(1, debug_info.events_size()); | 471 EXPECT_EQ(1, debug_info.events_size()); |
460 GetUpdatesProcessor::CopyClientDebugInfo(debug_info_getter(), &debug_info); | 472 GetUpdatesProcessor::CopyClientDebugInfo(debug_info_getter(), &debug_info); |
461 EXPECT_EQ(1, debug_info.events_size()); | 473 EXPECT_EQ(1, debug_info.events_size()); |
462 } | 474 } |
463 | 475 |
464 } // namespace syncer | 476 } // namespace syncer |
OLD | NEW |