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

Unified Diff: sync/engine/process_updates_command_unittest.cc

Issue 11091009: sync: Merge {Verify,Process}UpdatesCommand (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Amend comment Created 8 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sync/engine/process_updates_command.cc ('k') | sync/engine/syncer.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sync/engine/process_updates_command_unittest.cc
diff --git a/sync/engine/process_updates_command_unittest.cc b/sync/engine/process_updates_command_unittest.cc
index 59f22101cef48f3b8a2a3e7db1e3b12b2be575b3..fc543fb3858aee0786073cee278aea69d0dd8af1 100644
--- a/sync/engine/process_updates_command_unittest.cc
+++ b/sync/engine/process_updates_command_unittest.cc
@@ -3,11 +3,11 @@
// found in the LICENSE file.
#include "base/basictypes.h"
-#include "base/memory/ref_counted.h"
#include "sync/engine/process_updates_command.h"
#include "sync/internal_api/public/base/model_type.h"
#include "sync/sessions/session_state.h"
#include "sync/sessions/sync_session.h"
+#include "sync/syncable/mutable_entry.h"
#include "sync/syncable/syncable_id.h"
#include "sync/test/engine/fake_model_worker.h"
#include "sync/test/engine/syncer_command_test.h"
@@ -15,6 +15,11 @@
namespace syncer {
+using syncable::Id;
+using syncable::MutableEntry;
+using syncable::UNITTEST;
+using syncable::WriteTransaction;
+
namespace {
class ProcessUpdatesCommandTest : public SyncerCommandTest {
@@ -27,24 +32,67 @@ class ProcessUpdatesCommandTest : public SyncerCommandTest {
make_scoped_refptr(new FakeModelWorker(GROUP_UI)));
workers()->push_back(
make_scoped_refptr(new FakeModelWorker(GROUP_DB)));
+ (*mutable_routing_info())[PREFERENCES] = GROUP_UI;
(*mutable_routing_info())[BOOKMARKS] = GROUP_UI;
(*mutable_routing_info())[AUTOFILL] = GROUP_DB;
SyncerCommandTest::SetUp();
}
+ void CreateLocalItem(const std::string& item_id,
+ const std::string& parent_id,
+ const ModelType& type) {
+ WriteTransaction trans(FROM_HERE, UNITTEST, directory());
+ MutableEntry entry(&trans, syncable::CREATE_NEW_UPDATE_ITEM,
+ Id::CreateFromServerId(item_id));
+ ASSERT_TRUE(entry.good());
+
+ entry.Put(syncable::BASE_VERSION, 1);
+ entry.Put(syncable::SERVER_VERSION, 1);
+ entry.Put(syncable::NON_UNIQUE_NAME, item_id);
+ entry.Put(syncable::PARENT_ID, Id::CreateFromServerId(parent_id));
+ sync_pb::EntitySpecifics default_specifics;
+ AddDefaultFieldValue(type, &default_specifics);
+ entry.Put(syncable::SERVER_SPECIFICS, default_specifics);
+ }
+
+ void AddUpdate(sync_pb::GetUpdatesResponse* updates,
+ const std::string& id, const std::string& parent,
+ const ModelType& type) {
+ sync_pb::SyncEntity* e = updates->add_entries();
+ e->set_id_string("b1");
+ e->set_parent_id_string(parent);
+ e->set_non_unique_name("b1");
+ e->set_name("b1");
+ AddDefaultFieldValue(type, e->mutable_specifics());
+ }
+
ProcessUpdatesCommand command_;
private:
DISALLOW_COPY_AND_ASSIGN(ProcessUpdatesCommandTest);
};
-TEST_F(ProcessUpdatesCommandTest, GetGroupsToChange) {
+TEST_F(ProcessUpdatesCommandTest, GroupsToChange) {
+ std::string root = syncable::GetNullId().GetServerId();
+
+ CreateLocalItem("b1", root, BOOKMARKS);
+ CreateLocalItem("b2", root, BOOKMARKS);
+ CreateLocalItem("p1", root, PREFERENCES);
+ CreateLocalItem("a1", root, AUTOFILL);
+
ExpectNoGroupsToChange(command_);
- // Add a verified update for GROUP_DB.
- session()->mutable_status_controller()->
- GetUnrestrictedMutableUpdateProgressForTest(GROUP_DB)->
- AddVerifyResult(VerifyResult(), sync_pb::SyncEntity());
- ExpectGroupToChange(command_, GROUP_DB);
+
+ sync_pb::GetUpdatesResponse* updates =
+ session()->mutable_status_controller()->
+ mutable_updates_response()->mutable_get_updates();
+ AddUpdate(updates, "b1", root, BOOKMARKS);
+ AddUpdate(updates, "b2", root, BOOKMARKS);
+ AddUpdate(updates, "p1", root, PREFERENCES);
+ AddUpdate(updates, "a1", root, AUTOFILL);
+
+ ExpectGroupsToChange(command_, GROUP_UI, GROUP_DB);
+
+ command_.ExecuteImpl(session());
}
} // namespace
« no previous file with comments | « sync/engine/process_updates_command.cc ('k') | sync/engine/syncer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698