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

Side by Side Diff: chrome/browser/sync/engine/verify_updates_command_unittest.cc

Issue 9699057: [Sync] Move 'sync' target to sync/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address Tim's comments Created 8 years, 9 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 | « chrome/browser/sync/engine/verify_updates_command.cc ('k') | chrome/browser/sync/glue/DEPS » ('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 "base/location.h"
6 #include "chrome/browser/sync/engine/verify_updates_command.h"
7 #include "chrome/browser/sync/sessions/session_state.h"
8 #include "chrome/browser/sync/sessions/sync_session.h"
9 #include "chrome/browser/sync/syncable/syncable.h"
10 #include "chrome/browser/sync/syncable/syncable_id.h"
11 #include "chrome/browser/sync/test/engine/fake_model_worker.h"
12 #include "chrome/browser/sync/test/engine/syncer_command_test.h"
13 #include "sync/protocol/bookmark_specifics.pb.h"
14 #include "testing/gtest/include/gtest/gtest.h"
15
16 namespace browser_sync {
17
18 using sessions::SyncSession;
19 using sessions::StatusController;
20 using std::string;
21 using syncable::Entry;
22 using syncable::Id;
23 using syncable::MutableEntry;
24 using syncable::ReadTransaction;
25 using syncable::UNITTEST;
26 using syncable::WriteTransaction;
27
28 class VerifyUpdatesCommandTest : public SyncerCommandTest {
29 public:
30 virtual void SetUp() {
31 workers()->clear();
32 mutable_routing_info()->clear();
33 workers()->push_back(make_scoped_refptr(new FakeModelWorker(GROUP_DB)));
34 workers()->push_back(make_scoped_refptr(new FakeModelWorker(GROUP_UI)));
35 (*mutable_routing_info())[syncable::PREFERENCES] = GROUP_UI;
36 (*mutable_routing_info())[syncable::BOOKMARKS] = GROUP_UI;
37 (*mutable_routing_info())[syncable::AUTOFILL] = GROUP_DB;
38 SyncerCommandTest::SetUp();
39 }
40
41 void CreateLocalItem(const std::string& item_id,
42 const std::string& parent_id,
43 const syncable::ModelType& type) {
44 WriteTransaction trans(FROM_HERE, UNITTEST, directory());
45 MutableEntry entry(&trans, syncable::CREATE_NEW_UPDATE_ITEM,
46 Id::CreateFromServerId(item_id));
47 ASSERT_TRUE(entry.good());
48
49 entry.Put(syncable::BASE_VERSION, 1);
50 entry.Put(syncable::SERVER_VERSION, 1);
51 entry.Put(syncable::NON_UNIQUE_NAME, item_id);
52 entry.Put(syncable::PARENT_ID, Id::CreateFromServerId(parent_id));
53 sync_pb::EntitySpecifics default_specifics;
54 AddDefaultFieldValue(type, &default_specifics);
55 entry.Put(syncable::SERVER_SPECIFICS, default_specifics);
56 }
57
58 void AddUpdate(GetUpdatesResponse* updates,
59 const std::string& id, const std::string& parent,
60 const syncable::ModelType& type) {
61 sync_pb::SyncEntity* e = updates->add_entries();
62 e->set_id_string("b1");
63 e->set_parent_id_string(parent);
64 e->set_non_unique_name("b1");
65 e->set_name("b1");
66 AddDefaultFieldValue(type, e->mutable_specifics());
67 }
68
69 VerifyUpdatesCommand command_;
70
71 };
72
73 TEST_F(VerifyUpdatesCommandTest, AllVerified) {
74 string root = syncable::GetNullId().GetServerId();
75
76 CreateLocalItem("b1", root, syncable::BOOKMARKS);
77 CreateLocalItem("b2", root, syncable::BOOKMARKS);
78 CreateLocalItem("p1", root, syncable::PREFERENCES);
79 CreateLocalItem("a1", root, syncable::AUTOFILL);
80
81 ExpectNoGroupsToChange(command_);
82
83 GetUpdatesResponse* updates = session()->mutable_status_controller()->
84 mutable_updates_response()->mutable_get_updates();
85 AddUpdate(updates, "b1", root, syncable::BOOKMARKS);
86 AddUpdate(updates, "b2", root, syncable::BOOKMARKS);
87 AddUpdate(updates, "p1", root, syncable::PREFERENCES);
88 AddUpdate(updates, "a1", root, syncable::AUTOFILL);
89
90 ExpectGroupsToChange(command_, GROUP_UI, GROUP_DB);
91
92 command_.ExecuteImpl(session());
93
94 StatusController* status = session()->mutable_status_controller();
95 {
96 sessions::ScopedModelSafeGroupRestriction r(status, GROUP_UI);
97 ASSERT_TRUE(status->update_progress());
98 EXPECT_EQ(3, status->update_progress()->VerifiedUpdatesSize());
99 }
100 {
101 sessions::ScopedModelSafeGroupRestriction r(status, GROUP_DB);
102 ASSERT_TRUE(status->update_progress());
103 EXPECT_EQ(1, status->update_progress()->VerifiedUpdatesSize());
104 }
105 {
106 sessions::ScopedModelSafeGroupRestriction r(status, GROUP_PASSIVE);
107 EXPECT_FALSE(status->update_progress());
108 }
109 }
110
111 }
OLDNEW
« no previous file with comments | « chrome/browser/sync/engine/verify_updates_command.cc ('k') | chrome/browser/sync/glue/DEPS » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698