Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: sync/engine/download_updates_command_unittest.cc

Issue 15764010: Experimental functionize patch (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sync: Expose sync functionality as functions Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « sync/engine/download_updates_command.cc ('k') | sync/engine/get_commit_ids_command.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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.
4
5 #include "sync/engine/download_updates_command.h"
6 #include "sync/protocol/sync.pb.h"
7 #include "sync/sessions/nudge_tracker.h"
8 #include "sync/test/engine/fake_model_worker.h"
9 #include "sync/test/engine/syncer_command_test.h"
10
11 using ::testing::_;
12
13 namespace syncer {
14
15 // A test fixture for tests exercising DownloadUpdatesCommandTest.
16 class DownloadUpdatesCommandTest : public SyncerCommandTest {
17 protected:
18 DownloadUpdatesCommandTest()
19 : command_(true /* create_mobile_bookmarks_folder */) {}
20
21 virtual void SetUp() {
22 workers()->clear();
23 mutable_routing_info()->clear();
24 workers()->push_back(
25 make_scoped_refptr(new FakeModelWorker(GROUP_DB)));
26 workers()->push_back(
27 make_scoped_refptr(new FakeModelWorker(GROUP_UI)));
28 (*mutable_routing_info())[AUTOFILL] = GROUP_DB;
29 (*mutable_routing_info())[BOOKMARKS] = GROUP_UI;
30 (*mutable_routing_info())[PREFERENCES] = GROUP_UI;
31 SyncerCommandTest::SetUp();
32 }
33
34 DownloadUpdatesCommand command_;
35
36 private:
37 DISALLOW_COPY_AND_ASSIGN(DownloadUpdatesCommandTest);
38 };
39
40 TEST_F(DownloadUpdatesCommandTest, ExecuteNoStates) {
41 ConfigureMockServerConnection();
42
43 sessions::NudgeTracker nudge_tracker;
44 nudge_tracker.RecordLocalChange(ModelTypeSet(BOOKMARKS));
45
46 mock_server()->ExpectGetUpdatesRequestTypes(
47 GetRoutingInfoTypes(routing_info()));
48 scoped_ptr<sessions::SyncSession> session(
49 sessions::SyncSession::BuildForNudge(context(),
50 delegate(),
51 nudge_tracker.GetSourceInfo(),
52 &nudge_tracker));
53 command_.ExecuteImpl(session.get());
54 }
55
56 TEST_F(DownloadUpdatesCommandTest, ExecuteWithStates) {
57 ConfigureMockServerConnection();
58
59 sessions::NudgeTracker nudge_tracker;
60 nudge_tracker.RecordRemoteInvalidation(
61 ModelTypeSetToInvalidationMap(ModelTypeSet(AUTOFILL),
62 "autofill_payload"));
63 nudge_tracker.RecordRemoteInvalidation(
64 ModelTypeSetToInvalidationMap(ModelTypeSet(BOOKMARKS),
65 "bookmark_payload"));
66 nudge_tracker.RecordRemoteInvalidation(
67 ModelTypeSetToInvalidationMap(ModelTypeSet(PREFERENCES),
68 "preferences_payload"));
69
70 mock_server()->ExpectGetUpdatesRequestTypes(
71 GetRoutingInfoTypes(routing_info()));
72 mock_server()->ExpectGetUpdatesRequestStates(
73 nudge_tracker.GetSourceInfo().types);
74 scoped_ptr<sessions::SyncSession> session(
75 sessions::SyncSession::BuildForNudge(context(),
76 delegate(),
77 nudge_tracker.GetSourceInfo(),
78 &nudge_tracker));
79 command_.ExecuteImpl(session.get());
80 }
81
82 TEST_F(DownloadUpdatesCommandTest, VerifyAppendDebugInfo) {
83 sync_pb::DebugInfo debug_info;
84 EXPECT_CALL(*(mock_debug_info_getter()), GetAndClearDebugInfo(_))
85 .Times(1);
86 command_.AppendClientDebugInfoIfNeeded(session(), &debug_info);
87
88 // Now try to add it once more and make sure |GetAndClearDebugInfo| is not
89 // called.
90 command_.AppendClientDebugInfoIfNeeded(session(), &debug_info);
91 }
92
93 } // namespace syncer
OLDNEW
« no previous file with comments | « sync/engine/download_updates_command.cc ('k') | sync/engine/get_commit_ids_command.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698