| 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/engine/download_updates_command.h" | 5 #include "sync/engine/download_updates_command.h" |
| 6 #include "sync/protocol/autofill_specifics.pb.h" | |
| 7 #include "sync/protocol/bookmark_specifics.pb.h" | |
| 8 #include "sync/protocol/preference_specifics.pb.h" | |
| 9 #include "sync/protocol/sync.pb.h" | 6 #include "sync/protocol/sync.pb.h" |
| 7 #include "sync/sessions/nudge_tracker.h" |
| 10 #include "sync/test/engine/fake_model_worker.h" | 8 #include "sync/test/engine/fake_model_worker.h" |
| 11 #include "sync/test/engine/syncer_command_test.h" | 9 #include "sync/test/engine/syncer_command_test.h" |
| 12 | 10 |
| 13 using ::testing::_; | 11 using ::testing::_; |
| 14 | 12 |
| 15 namespace syncer { | 13 namespace syncer { |
| 16 | 14 |
| 17 // A test fixture for tests exercising DownloadUpdatesCommandTest. | 15 // A test fixture for tests exercising DownloadUpdatesCommandTest. |
| 18 class DownloadUpdatesCommandTest : public SyncerCommandTest { | 16 class DownloadUpdatesCommandTest : public SyncerCommandTest { |
| 19 protected: | 17 protected: |
| (...skipping 14 matching lines...) Expand all Loading... |
| 34 } | 32 } |
| 35 | 33 |
| 36 DownloadUpdatesCommand command_; | 34 DownloadUpdatesCommand command_; |
| 37 | 35 |
| 38 private: | 36 private: |
| 39 DISALLOW_COPY_AND_ASSIGN(DownloadUpdatesCommandTest); | 37 DISALLOW_COPY_AND_ASSIGN(DownloadUpdatesCommandTest); |
| 40 }; | 38 }; |
| 41 | 39 |
| 42 TEST_F(DownloadUpdatesCommandTest, ExecuteNoStates) { | 40 TEST_F(DownloadUpdatesCommandTest, ExecuteNoStates) { |
| 43 ConfigureMockServerConnection(); | 41 ConfigureMockServerConnection(); |
| 42 |
| 43 sessions::NudgeTracker nudge_tracker; |
| 44 nudge_tracker.RecordLocalChange(ModelTypeSet(BOOKMARKS)); |
| 45 |
| 44 mock_server()->ExpectGetUpdatesRequestTypes( | 46 mock_server()->ExpectGetUpdatesRequestTypes( |
| 45 GetRoutingInfoTypes(routing_info())); | 47 GetRoutingInfoTypes(routing_info())); |
| 46 command_.ExecuteImpl(session()); | 48 command_.ExecuteImpl(new sessions::SyncSession(context(), |
| 49 delegate(), |
| 50 nudge_tracker.source_info(), |
| 51 &nudge_tracker)); |
| 47 } | 52 } |
| 48 | 53 |
| 49 TEST_F(DownloadUpdatesCommandTest, ExecuteWithStates) { | 54 TEST_F(DownloadUpdatesCommandTest, ExecuteWithStates) { |
| 50 ConfigureMockServerConnection(); | 55 ConfigureMockServerConnection(); |
| 51 sessions::SyncSourceInfo source; | 56 |
| 52 source.types[AUTOFILL].payload = "autofill_payload"; | 57 sessions::NudgeTracker nudge_tracker; |
| 53 source.types[BOOKMARKS].payload = "bookmark_payload"; | 58 nudge_tracker.RecordRemoteInvalidation( |
| 54 source.types[PREFERENCES].payload = "preferences_payload"; | 59 ModelTypeSetToInvalidationMap(ModelTypeSet(AUTOFILL), |
| 60 "autofill_payload")); |
| 61 nudge_tracker.RecordRemoteInvalidation( |
| 62 ModelTypeSetToInvalidationMap(ModelTypeSet(BOOKMARKS), |
| 63 "bookmark_payload")); |
| 64 nudge_tracker.RecordRemoteInvalidation( |
| 65 ModelTypeSetToInvalidationMap(ModelTypeSet(PREFERENCES), |
| 66 "preferences_payload")); |
| 67 |
| 55 mock_server()->ExpectGetUpdatesRequestTypes( | 68 mock_server()->ExpectGetUpdatesRequestTypes( |
| 56 GetRoutingInfoTypes(routing_info())); | 69 GetRoutingInfoTypes(routing_info())); |
| 57 mock_server()->ExpectGetUpdatesRequestStates(source.types); | 70 mock_server()->ExpectGetUpdatesRequestStates( |
| 58 command_.ExecuteImpl(session(source)); | 71 nudge_tracker.source_info().types); |
| 72 command_.ExecuteImpl(new sessions::SyncSession(context(), |
| 73 delegate(), |
| 74 nudge_tracker.source_info(), |
| 75 &nudge_tracker)); |
| 59 } | 76 } |
| 60 | 77 |
| 61 TEST_F(DownloadUpdatesCommandTest, VerifyAppendDebugInfo) { | 78 TEST_F(DownloadUpdatesCommandTest, VerifyAppendDebugInfo) { |
| 62 sync_pb::DebugInfo debug_info; | 79 sync_pb::DebugInfo debug_info; |
| 63 EXPECT_CALL(*(mock_debug_info_getter()), GetAndClearDebugInfo(_)) | 80 EXPECT_CALL(*(mock_debug_info_getter()), GetAndClearDebugInfo(_)) |
| 64 .Times(1); | 81 .Times(1); |
| 65 command_.AppendClientDebugInfoIfNeeded(session(), &debug_info); | 82 command_.AppendClientDebugInfoIfNeeded(session(), &debug_info); |
| 66 | 83 |
| 67 // Now try to add it once more and make sure |GetAndClearDebugInfo| is not | 84 // Now try to add it once more and make sure |GetAndClearDebugInfo| is not |
| 68 // called. | 85 // called. |
| 69 command_.AppendClientDebugInfoIfNeeded(session(), &debug_info); | 86 command_.AppendClientDebugInfoIfNeeded(session(), &debug_info); |
| 70 } | 87 } |
| 71 | 88 |
| 72 } // namespace syncer | 89 } // namespace syncer |
| OLD | NEW |