| 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( | 
|  | 49       sessions::SyncSession::BuildForNudge(context(), | 
|  | 50                                            delegate(), | 
|  | 51                                            nudge_tracker.GetSourceInfo(), | 
|  | 52                                            &nudge_tracker)); | 
| 47 } | 53 } | 
| 48 | 54 | 
| 49 TEST_F(DownloadUpdatesCommandTest, ExecuteWithStates) { | 55 TEST_F(DownloadUpdatesCommandTest, ExecuteWithStates) { | 
| 50   ConfigureMockServerConnection(); | 56   ConfigureMockServerConnection(); | 
| 51   sessions::SyncSourceInfo source; | 57 | 
| 52   source.types[AUTOFILL].payload = "autofill_payload"; | 58   sessions::NudgeTracker nudge_tracker; | 
| 53   source.types[BOOKMARKS].payload = "bookmark_payload"; | 59   nudge_tracker.RecordRemoteInvalidation( | 
| 54   source.types[PREFERENCES].payload = "preferences_payload"; | 60       ModelTypeSetToInvalidationMap(ModelTypeSet(AUTOFILL), | 
|  | 61                                     "autofill_payload")); | 
|  | 62   nudge_tracker.RecordRemoteInvalidation( | 
|  | 63       ModelTypeSetToInvalidationMap(ModelTypeSet(BOOKMARKS), | 
|  | 64                                     "bookmark_payload")); | 
|  | 65   nudge_tracker.RecordRemoteInvalidation( | 
|  | 66       ModelTypeSetToInvalidationMap(ModelTypeSet(PREFERENCES), | 
|  | 67                                     "preferences_payload")); | 
|  | 68 | 
| 55   mock_server()->ExpectGetUpdatesRequestTypes( | 69   mock_server()->ExpectGetUpdatesRequestTypes( | 
| 56       GetRoutingInfoTypes(routing_info())); | 70       GetRoutingInfoTypes(routing_info())); | 
| 57   mock_server()->ExpectGetUpdatesRequestStates(source.types); | 71   mock_server()->ExpectGetUpdatesRequestStates( | 
| 58   command_.ExecuteImpl(session(source)); | 72       nudge_tracker.GetSourceInfo().types); | 
|  | 73   command_.ExecuteImpl( | 
|  | 74       sessions::SyncSession::BuildForNudge(context(), | 
|  | 75                                            delegate(), | 
|  | 76                                            nudge_tracker.GetSourceInfo(), | 
|  | 77                                            &nudge_tracker)); | 
| 59 } | 78 } | 
| 60 | 79 | 
| 61 TEST_F(DownloadUpdatesCommandTest, VerifyAppendDebugInfo) { | 80 TEST_F(DownloadUpdatesCommandTest, VerifyAppendDebugInfo) { | 
| 62   sync_pb::DebugInfo debug_info; | 81   sync_pb::DebugInfo debug_info; | 
| 63   EXPECT_CALL(*(mock_debug_info_getter()), GetAndClearDebugInfo(_)) | 82   EXPECT_CALL(*(mock_debug_info_getter()), GetAndClearDebugInfo(_)) | 
| 64       .Times(1); | 83       .Times(1); | 
| 65   command_.AppendClientDebugInfoIfNeeded(session(), &debug_info); | 84   command_.AppendClientDebugInfoIfNeeded(session(), &debug_info); | 
| 66 | 85 | 
| 67   // Now try to add it once more and make sure |GetAndClearDebugInfo| is not | 86   // Now try to add it once more and make sure |GetAndClearDebugInfo| is not | 
| 68   // called. | 87   // called. | 
| 69   command_.AppendClientDebugInfoIfNeeded(session(), &debug_info); | 88   command_.AppendClientDebugInfoIfNeeded(session(), &debug_info); | 
| 70 } | 89 } | 
| 71 | 90 | 
| 72 }  // namespace syncer | 91 }  // namespace syncer | 
| OLD | NEW | 
|---|