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

Unified Diff: components/sync/engine_impl/directory_update_handler_unittest.cc

Issue 2130453004: [Sync] Move //sync to //components/sync. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 4 years, 5 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
Index: components/sync/engine_impl/directory_update_handler_unittest.cc
diff --git a/sync/engine/directory_update_handler_unittest.cc b/components/sync/engine_impl/directory_update_handler_unittest.cc
similarity index 90%
rename from sync/engine/directory_update_handler_unittest.cc
rename to components/sync/engine_impl/directory_update_handler_unittest.cc
index cefe23100e02120cfa504db075077030b3f7fa96..ac9f6f72e4418dac19e86cc934898b2a0a22ca49 100644
--- a/sync/engine/directory_update_handler_unittest.cc
+++ b/components/sync/engine_impl/directory_update_handler_unittest.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "sync/engine/directory_update_handler.h"
+#include "components/sync/engine_impl/directory_update_handler.h"
#include <stdint.h>
@@ -15,24 +15,24 @@
#include "base/macros.h"
#include "base/memory/ptr_util.h"
#include "base/message_loop/message_loop.h"
-#include "sync/engine/syncer_proto_util.h"
-#include "sync/internal_api/public/base/attachment_id_proto.h"
-#include "sync/internal_api/public/base/model_type.h"
-#include "sync/internal_api/public/test/test_entry_factory.h"
-#include "sync/protocol/sync.pb.h"
-#include "sync/sessions/directory_type_debug_info_emitter.h"
-#include "sync/sessions/status_controller.h"
-#include "sync/syncable/directory.h"
-#include "sync/syncable/entry.h"
-#include "sync/syncable/mutable_entry.h"
-#include "sync/syncable/syncable_model_neutral_write_transaction.h"
-#include "sync/syncable/syncable_proto_util.h"
-#include "sync/syncable/syncable_read_transaction.h"
-#include "sync/syncable/syncable_write_transaction.h"
-#include "sync/test/engine/fake_model_worker.h"
-#include "sync/test/engine/test_directory_setter_upper.h"
-#include "sync/test/engine/test_id_factory.h"
-#include "sync/test/engine/test_syncable_utils.h"
+#include "components/sync/base/attachment_id_proto.h"
+#include "components/sync/base/model_type.h"
+#include "components/sync/core/test/test_entry_factory.h"
+#include "components/sync/engine_impl/syncer_proto_util.h"
+#include "components/sync/protocol/sync.pb.h"
+#include "components/sync/sessions_impl/directory_type_debug_info_emitter.h"
+#include "components/sync/sessions_impl/status_controller.h"
+#include "components/sync/syncable/directory.h"
+#include "components/sync/syncable/entry.h"
+#include "components/sync/syncable/mutable_entry.h"
+#include "components/sync/syncable/syncable_model_neutral_write_transaction.h"
+#include "components/sync/syncable/syncable_proto_util.h"
+#include "components/sync/syncable/syncable_read_transaction.h"
+#include "components/sync/syncable/syncable_write_transaction.h"
+#include "components/sync/test/engine/fake_model_worker.h"
+#include "components/sync/test/engine/test_directory_setter_upper.h"
+#include "components/sync/test/engine/test_id_factory.h"
+#include "components/sync/test/engine/test_syncable_utils.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace syncer {
@@ -50,8 +50,7 @@ static const int64_t kDefaultVersion = 1000;
class DirectoryUpdateHandlerProcessUpdateTest : public ::testing::Test {
public:
DirectoryUpdateHandlerProcessUpdateTest()
- : ui_worker_(new FakeModelWorker(GROUP_UI)) {
- }
+ : ui_worker_(new FakeModelWorker(GROUP_UI)) {}
~DirectoryUpdateHandlerProcessUpdateTest() override {}
@@ -59,9 +58,7 @@ class DirectoryUpdateHandlerProcessUpdateTest : public ::testing::Test {
void TearDown() override { dir_maker_.TearDown(); }
- syncable::Directory* dir() {
- return dir_maker_.directory();
- }
+ syncable::Directory* dir() { return dir_maker_.directory(); }
protected:
std::unique_ptr<sync_pb::SyncEntity> CreateUpdate(const std::string& id,
@@ -70,24 +67,19 @@ class DirectoryUpdateHandlerProcessUpdateTest : public ::testing::Test {
// This exists mostly to give tests access to the protected member function.
// Warning: This takes the syncable directory lock.
- void UpdateSyncEntities(
- DirectoryUpdateHandler* handler,
- const SyncEntityList& applicable_updates,
- sessions::StatusController* status);
+ void UpdateSyncEntities(DirectoryUpdateHandler* handler,
+ const SyncEntityList& applicable_updates,
+ sessions::StatusController* status);
// Another function to access private member functions.
- void UpdateProgressMarkers(
- DirectoryUpdateHandler* handler,
- const sync_pb::DataTypeProgressMarker& progress);
+ void UpdateProgressMarkers(DirectoryUpdateHandler* handler,
+ const sync_pb::DataTypeProgressMarker& progress);
- scoped_refptr<FakeModelWorker> ui_worker() {
- return ui_worker_;
- }
+ scoped_refptr<FakeModelWorker> ui_worker() { return ui_worker_; }
bool EntryExists(const std::string& id) {
syncable::ReadTransaction trans(FROM_HERE, dir());
- syncable::Entry e(&trans, syncable::GET_BY_ID,
- Id::CreateFromServerId(id));
+ syncable::Entry e(&trans, syncable::GET_BY_ID, Id::CreateFromServerId(id));
return e.good() && !e.GetIsDel();
}
@@ -148,7 +140,7 @@ TEST_F(DirectoryUpdateHandlerProcessUpdateTest, NewBookmarkTag) {
std::unique_ptr<sync_pb::SyncEntity> e =
CreateUpdate(SyncableIdToProto(server_id), root, BOOKMARKS);
e->set_originator_cache_guid(
- std::string(kCacheGuid, arraysize(kCacheGuid)-1));
+ std::string(kCacheGuid, arraysize(kCacheGuid) - 1));
Id client_id = Id::CreateFromClientString("-2");
e->set_originator_client_item_id(client_id.GetServerId());
e->set_position_in_parent(0);
@@ -261,8 +253,8 @@ TEST_F(DirectoryUpdateHandlerProcessUpdateTest, ProcessNewProgressMarkers) {
TEST_F(DirectoryUpdateHandlerProcessUpdateTest, GarbageCollectionByVersion) {
DirectoryTypeDebugInfoEmitter emitter(SYNCED_NOTIFICATIONS, &type_observers_);
- DirectoryUpdateHandler handler(dir(), SYNCED_NOTIFICATIONS,
- ui_worker(), &emitter);
+ DirectoryUpdateHandler handler(dir(), SYNCED_NOTIFICATIONS, ui_worker(),
+ &emitter);
sessions::StatusController status;
sync_pb::DataTypeProgressMarker progress;
@@ -292,9 +284,8 @@ TEST_F(DirectoryUpdateHandlerProcessUpdateTest, GarbageCollectionByVersion) {
updates.push_back(e2.get());
// Process and apply updates.
- EXPECT_EQ(
- SYNCER_OK,
- handler.ProcessGetUpdatesResponse(progress, context, updates, &status));
+ EXPECT_EQ(SYNCER_OK, handler.ProcessGetUpdatesResponse(progress, context,
+ updates, &status));
handler.ApplyUpdates(&status);
// Verify none is deleted because they are unapplied during GC.
@@ -304,9 +295,8 @@ TEST_F(DirectoryUpdateHandlerProcessUpdateTest, GarbageCollectionByVersion) {
// Process and apply again. Old entry is deleted but not root.
progress.mutable_gc_directive()->set_version_watermark(kDefaultVersion + 20);
- EXPECT_EQ(SYNCER_OK,
- handler.ProcessGetUpdatesResponse(
- progress, context, SyncEntityList(), &status));
+ EXPECT_EQ(SYNCER_OK, handler.ProcessGetUpdatesResponse(
+ progress, context, SyncEntityList(), &status));
handler.ApplyUpdates(&status);
EXPECT_FALSE(EntryExists(e1->id_string()));
EXPECT_TRUE(EntryExists(e2->id_string()));
@@ -314,8 +304,8 @@ TEST_F(DirectoryUpdateHandlerProcessUpdateTest, GarbageCollectionByVersion) {
TEST_F(DirectoryUpdateHandlerProcessUpdateTest, ContextVersion) {
DirectoryTypeDebugInfoEmitter emitter(SYNCED_NOTIFICATIONS, &type_observers_);
- DirectoryUpdateHandler handler(dir(), SYNCED_NOTIFICATIONS,
- ui_worker(), &emitter);
+ DirectoryUpdateHandler handler(dir(), SYNCED_NOTIFICATIONS, ui_worker(),
+ &emitter);
sessions::StatusController status;
int field_number = GetSpecificsFieldNumberFromModelType(SYNCED_NOTIFICATIONS);
@@ -337,9 +327,8 @@ TEST_F(DirectoryUpdateHandlerProcessUpdateTest, ContextVersion) {
updates.push_back(e1.get());
// The first response should be processed fine.
- EXPECT_EQ(SYNCER_OK,
- handler.ProcessGetUpdatesResponse(
- progress, old_context, updates, &status));
+ EXPECT_EQ(SYNCER_OK, handler.ProcessGetUpdatesResponse(progress, old_context,
+ updates, &status));
handler.ApplyUpdates(&status);
// The PREFERENCES root should be auto-created.
@@ -350,8 +339,8 @@ TEST_F(DirectoryUpdateHandlerProcessUpdateTest, ContextVersion) {
{
sync_pb::DataTypeContext dir_context;
syncable::ReadTransaction trans(FROM_HERE, dir());
- trans.directory()->GetDataTypeContext(
- &trans, SYNCED_NOTIFICATIONS, &dir_context);
+ trans.directory()->GetDataTypeContext(&trans, SYNCED_NOTIFICATIONS,
+ &dir_context);
EXPECT_EQ(old_context.SerializeAsString(), dir_context.SerializeAsString());
}
@@ -369,8 +358,8 @@ TEST_F(DirectoryUpdateHandlerProcessUpdateTest, ContextVersion) {
// The second response, with an old context version, should result in an
// error and the updates should be dropped.
EXPECT_EQ(DATATYPE_TRIGGERED_RETRY,
- handler.ProcessGetUpdatesResponse(
- progress, new_context, updates, &status));
+ handler.ProcessGetUpdatesResponse(progress, new_context, updates,
+ &status));
handler.ApplyUpdates(&status);
EXPECT_FALSE(EntryExists(e2->id_string()));
@@ -378,8 +367,8 @@ TEST_F(DirectoryUpdateHandlerProcessUpdateTest, ContextVersion) {
{
sync_pb::DataTypeContext dir_context;
syncable::ReadTransaction trans(FROM_HERE, dir());
- trans.directory()->GetDataTypeContext(
- &trans, SYNCED_NOTIFICATIONS, &dir_context);
+ trans.directory()->GetDataTypeContext(&trans, SYNCED_NOTIFICATIONS,
+ &dir_context);
EXPECT_EQ(old_context.SerializeAsString(), dir_context.SerializeAsString());
}
}
@@ -411,17 +400,15 @@ TEST_F(DirectoryUpdateHandlerProcessUpdateTest,
updates.push_back(e1.get());
// Process and apply updates.
- EXPECT_EQ(
- SYNCER_OK,
- handler.ProcessGetUpdatesResponse(progress, context, updates, &status));
+ EXPECT_EQ(SYNCER_OK, handler.ProcessGetUpdatesResponse(progress, context,
+ updates, &status));
handler.ApplyUpdates(&status);
ASSERT_TRUE(TypeRootExists(ARTICLES));
ASSERT_TRUE(EntryExists(e1->id_string()));
{
syncable::ReadTransaction trans(FROM_HERE, dir());
- syncable::Entry e(&trans,
- syncable::GET_BY_ID,
+ syncable::Entry e(&trans, syncable::GET_BY_ID,
Id::CreateFromServerId(e1->id_string()));
// See that the attachment_metadata is correct.
@@ -535,13 +522,9 @@ class DirectoryUpdateHandlerApplyUpdateTest : public ::testing::Test {
update_handler_map_.find(ARTICLES)->second->ApplyUpdates(status);
}
- TestEntryFactory* entry_factory() {
- return entry_factory_.get();
- }
+ TestEntryFactory* entry_factory() { return entry_factory_.get(); }
- syncable::Directory* directory() {
- return dir_maker_.directory();
- }
+ syncable::Directory* directory() { return dir_maker_.directory(); }
private:
base::MessageLoop loop_; // Needed to initialize the directory.
@@ -607,8 +590,7 @@ TEST_F(DirectoryUpdateHandlerApplyUpdateTest, SimpleBookmark) {
}
// Test that the applicator can handle updates delivered out of order.
-TEST_F(DirectoryUpdateHandlerApplyUpdateTest,
- BookmarkChildrenBeforeParent) {
+TEST_F(DirectoryUpdateHandlerApplyUpdateTest, BookmarkChildrenBeforeParent) {
// Start with some bookmarks whose parents are unknown.
std::string root_server_id = Id::GetRoot().GetServerId();
int64_t a_handle = entry_factory()->CreateUnappliedNewBookmarkItemWithParent(
@@ -755,9 +737,9 @@ TEST_F(DirectoryUpdateHandlerApplyUpdateTest, BookmarkFolderLoop) {
}
// Item 'Y' is child of 'X'.
- entry_factory()->CreateUnsyncedItem(
- TestIdFactory::MakeServer("Y"), TestIdFactory::MakeServer("X"), "Y", true,
- BOOKMARKS, NULL);
+ entry_factory()->CreateUnsyncedItem(TestIdFactory::MakeServer("Y"),
+ TestIdFactory::MakeServer("X"), "Y", true,
+ BOOKMARKS, NULL);
// If the server's update were applied, we would have X be a child of Y, and Y
// as a child of X. That's a directory loop. The UpdateApplicator should
@@ -782,17 +764,15 @@ TEST_F(DirectoryUpdateHandlerApplyUpdateTest, BookmarkFolderLoop) {
// Test update application where the update has been orphaned by a local folder
// deletion. The update application attempt should fail.
-TEST_F(DirectoryUpdateHandlerApplyUpdateTest,
- HierarchyConflictDeletedParent) {
+TEST_F(DirectoryUpdateHandlerApplyUpdateTest, HierarchyConflictDeletedParent) {
// Create a locally deleted parent item.
int64_t parent_handle;
- entry_factory()->CreateUnsyncedItem(
- Id::CreateFromServerId("parent"), TestIdFactory::root(),
- "parent", true, BOOKMARKS, &parent_handle);
+ entry_factory()->CreateUnsyncedItem(Id::CreateFromServerId("parent"),
+ TestIdFactory::root(), "parent", true,
+ BOOKMARKS, &parent_handle);
{
syncable::WriteTransaction trans(FROM_HERE, UNITTEST, directory());
- syncable::MutableEntry entry(&trans,
- syncable::GET_BY_HANDLE,
+ syncable::MutableEntry entry(&trans, syncable::GET_BY_HANDLE,
parent_handle);
entry.PutIsDel(true);
}
@@ -828,8 +808,7 @@ TEST_F(DirectoryUpdateHandlerApplyUpdateTest,
entry_factory()->CreateSyncedItem("parent", BOOKMARKS, true);
{
syncable::WriteTransaction trans(FROM_HERE, UNITTEST, directory());
- syncable::MutableEntry entry(&trans,
- syncable::GET_BY_HANDLE,
+ syncable::MutableEntry entry(&trans, syncable::GET_BY_HANDLE,
parent_handle);
ASSERT_TRUE(entry.good());
@@ -841,9 +820,9 @@ TEST_F(DirectoryUpdateHandlerApplyUpdateTest,
}
// Create a local child of the server-deleted directory.
- entry_factory()->CreateUnsyncedItem(
- TestIdFactory::MakeServer("child"), TestIdFactory::MakeServer("parent"),
- "child", false, BOOKMARKS, NULL);
+ entry_factory()->CreateUnsyncedItem(TestIdFactory::MakeServer("child"),
+ TestIdFactory::MakeServer("parent"),
+ "child", false, BOOKMARKS, NULL);
// The server's request to delete the directory must be ignored, otherwise our
// unsynced new child would be orphaned. This is a hierarchy conflict.
@@ -866,8 +845,7 @@ TEST_F(DirectoryUpdateHandlerApplyUpdateTest,
// Attempt to apply updates where the updated item's parent is not known to this
// client. The update application attempt should fail.
-TEST_F(DirectoryUpdateHandlerApplyUpdateTest,
- HierarchyConflictUnknownParent) {
+TEST_F(DirectoryUpdateHandlerApplyUpdateTest, HierarchyConflictUnknownParent) {
// We shouldn't be able to do anything with either of these items.
int64_t x_handle = entry_factory()->CreateUnappliedNewItemWithParent(
"some_item", DefaultBookmarkSpecifics(), "unknown_parent");
@@ -1051,7 +1029,7 @@ TEST_F(DirectoryUpdateHandlerApplyUpdateTest, SomeUndecryptablePassword) {
cryptographer->AddKey(params);
cryptographer->Encrypt(data,
- specifics.mutable_password()->mutable_encrypted());
+ specifics.mutable_password()->mutable_encrypted());
}
decryptable_handle =
entry_factory()->CreateUnappliedNewItem("item1", specifics, false);
@@ -1066,8 +1044,8 @@ TEST_F(DirectoryUpdateHandlerApplyUpdateTest, SomeUndecryptablePassword) {
sync_pb::PasswordSpecificsData data;
data.set_origin("http://example.com/2");
- other_cryptographer.Encrypt(data,
- specifics.mutable_password()->mutable_encrypted());
+ other_cryptographer.Encrypt(
+ data, specifics.mutable_password()->mutable_encrypted());
undecryptable_handle =
entry_factory()->CreateUnappliedNewItem("item2", specifics, false);
}
« no previous file with comments | « components/sync/engine_impl/directory_update_handler.cc ('k') | components/sync/engine_impl/get_commit_ids.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698