| 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" | 6 #include "sync/protocol/autofill_specifics.pb.h" |
| 7 #include "sync/protocol/bookmark_specifics.pb.h" | 7 #include "sync/protocol/bookmark_specifics.pb.h" |
| 8 #include "sync/protocol/preference_specifics.pb.h" | 8 #include "sync/protocol/preference_specifics.pb.h" |
| 9 #include "sync/protocol/sync.pb.h" | 9 #include "sync/protocol/sync.pb.h" |
| 10 #include "sync/test/engine/fake_model_worker.h" | 10 #include "sync/test/engine/fake_model_worker.h" |
| 11 #include "sync/test/engine/syncer_command_test.h" | 11 #include "sync/test/engine/syncer_command_test.h" |
| 12 | 12 |
| 13 using ::testing::_; | 13 using ::testing::_; |
| 14 | 14 |
| 15 namespace syncer { | 15 namespace syncer { |
| 16 | 16 |
| 17 // A test fixture for tests exercising DownloadUpdatesCommandTest. | 17 // A test fixture for tests exercising DownloadUpdatesCommandTest. |
| 18 class DownloadUpdatesCommandTest : public SyncerCommandTest { | 18 class DownloadUpdatesCommandTest : public SyncerCommandTest { |
| 19 protected: | 19 protected: |
| 20 DownloadUpdatesCommandTest() | 20 DownloadUpdatesCommandTest() |
| 21 : command_(true /* create_mobile_bookmarks_folder */) {} | 21 : command_(true /* create_mobile_bookmarks_folder */) {} |
| 22 | 22 |
| 23 virtual void SetUp() { | 23 virtual void SetUp() { |
| 24 workers()->clear(); | 24 workers()->clear(); |
| 25 mutable_routing_info()->clear(); | 25 mutable_routing_info()->clear(); |
| 26 workers()->push_back( | 26 workers()->push_back( |
| 27 make_scoped_refptr(new FakeModelWorker(GROUP_DB))); | 27 make_scoped_refptr(new FakeModelWorker(GROUP_DB))); |
| 28 workers()->push_back( | 28 workers()->push_back( |
| 29 make_scoped_refptr(new FakeModelWorker(GROUP_UI))); | 29 make_scoped_refptr(new FakeModelWorker(GROUP_UI))); |
| 30 (*mutable_routing_info())[syncer::AUTOFILL] = GROUP_DB; | 30 (*mutable_routing_info())[AUTOFILL] = GROUP_DB; |
| 31 (*mutable_routing_info())[syncer::BOOKMARKS] = GROUP_UI; | 31 (*mutable_routing_info())[BOOKMARKS] = GROUP_UI; |
| 32 (*mutable_routing_info())[syncer::PREFERENCES] = GROUP_UI; | 32 (*mutable_routing_info())[PREFERENCES] = GROUP_UI; |
| 33 SyncerCommandTest::SetUp(); | 33 SyncerCommandTest::SetUp(); |
| 34 } | 34 } |
| 35 | 35 |
| 36 DownloadUpdatesCommand command_; | 36 DownloadUpdatesCommand command_; |
| 37 | 37 |
| 38 private: | 38 private: |
| 39 DISALLOW_COPY_AND_ASSIGN(DownloadUpdatesCommandTest); | 39 DISALLOW_COPY_AND_ASSIGN(DownloadUpdatesCommandTest); |
| 40 }; | 40 }; |
| 41 | 41 |
| 42 TEST_F(DownloadUpdatesCommandTest, ExecuteNoPayloads) { | 42 TEST_F(DownloadUpdatesCommandTest, ExecuteNoPayloads) { |
| 43 ConfigureMockServerConnection(); | 43 ConfigureMockServerConnection(); |
| 44 mock_server()->ExpectGetUpdatesRequestTypes( | 44 mock_server()->ExpectGetUpdatesRequestTypes( |
| 45 GetRoutingInfoTypes(routing_info())); | 45 GetRoutingInfoTypes(routing_info())); |
| 46 command_.ExecuteImpl(session()); | 46 command_.ExecuteImpl(session()); |
| 47 } | 47 } |
| 48 | 48 |
| 49 TEST_F(DownloadUpdatesCommandTest, ExecuteWithPayloads) { | 49 TEST_F(DownloadUpdatesCommandTest, ExecuteWithPayloads) { |
| 50 ConfigureMockServerConnection(); | 50 ConfigureMockServerConnection(); |
| 51 sessions::SyncSourceInfo source; | 51 sessions::SyncSourceInfo source; |
| 52 source.types[syncer::AUTOFILL] = "autofill_payload"; | 52 source.types[AUTOFILL] = "autofill_payload"; |
| 53 source.types[syncer::BOOKMARKS] = "bookmark_payload"; | 53 source.types[BOOKMARKS] = "bookmark_payload"; |
| 54 source.types[syncer::PREFERENCES] = "preferences_payload"; | 54 source.types[PREFERENCES] = "preferences_payload"; |
| 55 mock_server()->ExpectGetUpdatesRequestTypes( | 55 mock_server()->ExpectGetUpdatesRequestTypes( |
| 56 GetRoutingInfoTypes(routing_info())); | 56 GetRoutingInfoTypes(routing_info())); |
| 57 mock_server()->ExpectGetUpdatesRequestPayloads(source.types); | 57 mock_server()->ExpectGetUpdatesRequestPayloads(source.types); |
| 58 command_.ExecuteImpl(session(source)); | 58 command_.ExecuteImpl(session(source)); |
| 59 } | 59 } |
| 60 | 60 |
| 61 TEST_F(DownloadUpdatesCommandTest, VerifyAppendDebugInfo) { | 61 TEST_F(DownloadUpdatesCommandTest, VerifyAppendDebugInfo) { |
| 62 sync_pb::DebugInfo debug_info; | 62 sync_pb::DebugInfo debug_info; |
| 63 EXPECT_CALL(*(mock_debug_info_getter()), GetAndClearDebugInfo(_)) | 63 EXPECT_CALL(*(mock_debug_info_getter()), GetAndClearDebugInfo(_)) |
| 64 .Times(1); | 64 .Times(1); |
| 65 command_.AppendClientDebugInfoIfNeeded(session(), &debug_info); | 65 command_.AppendClientDebugInfoIfNeeded(session(), &debug_info); |
| 66 | 66 |
| 67 // Now try to add it once more and make sure |GetAndClearDebugInfo| is not | 67 // Now try to add it once more and make sure |GetAndClearDebugInfo| is not |
| 68 // called. | 68 // called. |
| 69 command_.AppendClientDebugInfoIfNeeded(session(), &debug_info); | 69 command_.AppendClientDebugInfoIfNeeded(session(), &debug_info); |
| 70 } | 70 } |
| 71 | 71 |
| 72 } // namespace syncer | 72 } // namespace syncer |
| OLD | NEW |