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
3 // found in the LICENSE file.
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"
10 #include "sync/test/engine/fake_model_worker.h"
11 #include "sync/test/engine/syncer_command_test.h"
17 // A test fixture for tests exercising DownloadUpdatesCommandTest.
18 class DownloadUpdatesCommandTest
: public SyncerCommandTest
{
20 DownloadUpdatesCommandTest()
21 : command_(true /* create_mobile_bookmarks_folder */) {}
23 virtual void SetUp() {
25 mutable_routing_info()->clear();
27 make_scoped_refptr(new FakeModelWorker(GROUP_DB
)));
29 make_scoped_refptr(new FakeModelWorker(GROUP_UI
)));
30 (*mutable_routing_info())[AUTOFILL
] = GROUP_DB
;
31 (*mutable_routing_info())[BOOKMARKS
] = GROUP_UI
;
32 (*mutable_routing_info())[PREFERENCES
] = GROUP_UI
;
33 SyncerCommandTest::SetUp();
36 DownloadUpdatesCommand command_
;
39 DISALLOW_COPY_AND_ASSIGN(DownloadUpdatesCommandTest
);
42 TEST_F(DownloadUpdatesCommandTest
, ExecuteNoStates
) {
43 ConfigureMockServerConnection();
44 mock_server()->ExpectGetUpdatesRequestTypes(
45 GetRoutingInfoTypes(routing_info()));
46 command_
.ExecuteImpl(session());
49 TEST_F(DownloadUpdatesCommandTest
, ExecuteWithStates
) {
50 ConfigureMockServerConnection();
51 sessions::SyncSourceInfo source
;
52 source
.types
[AUTOFILL
].payload
= "autofill_payload";
53 source
.types
[BOOKMARKS
].payload
= "bookmark_payload";
54 source
.types
[PREFERENCES
].payload
= "preferences_payload";
55 mock_server()->ExpectGetUpdatesRequestTypes(
56 GetRoutingInfoTypes(routing_info()));
57 mock_server()->ExpectGetUpdatesRequestStates(source
.types
);
58 command_
.ExecuteImpl(session(source
));
61 TEST_F(DownloadUpdatesCommandTest
, VerifyAppendDebugInfo
) {
62 sync_pb::DebugInfo debug_info
;
63 EXPECT_CALL(*(mock_debug_info_getter()), GetAndClearDebugInfo(_
))
65 command_
.AppendClientDebugInfoIfNeeded(session(), &debug_info
);
67 // Now try to add it once more and make sure |GetAndClearDebugInfo| is not
69 command_
.AppendClientDebugInfoIfNeeded(session(), &debug_info
);