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

Unified Diff: components/sync/syncable/syncable_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
« no previous file with comments | « components/sync/syncable/syncable_read_transaction.cc ('k') | components/sync/syncable/syncable_util.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/sync/syncable/syncable_unittest.cc
diff --git a/sync/syncable/syncable_unittest.cc b/components/sync/syncable/syncable_unittest.cc
similarity index 84%
rename from sync/syncable/syncable_unittest.cc
rename to components/sync/syncable/syncable_unittest.cc
index 95d15314fe9e58cd8dc1cfedb7cce7e8635d9280..b97bbca9e37e8c7d3635581875ea3bdf6ab376a2 100644
--- a/sync/syncable/syncable_unittest.cc
+++ b/components/sync/syncable/syncable_unittest.cc
@@ -20,24 +20,24 @@
#include "base/threading/platform_thread.h"
#include "base/values.h"
#include "build/build_config.h"
-#include "sync/protocol/bookmark_specifics.pb.h"
-#include "sync/syncable/directory_backing_store.h"
-#include "sync/syncable/directory_change_delegate.h"
-#include "sync/syncable/directory_unittest.h"
-#include "sync/syncable/in_memory_directory_backing_store.h"
-#include "sync/syncable/metahandle_set.h"
-#include "sync/syncable/mutable_entry.h"
-#include "sync/syncable/on_disk_directory_backing_store.h"
-#include "sync/syncable/syncable_proto_util.h"
-#include "sync/syncable/syncable_read_transaction.h"
-#include "sync/syncable/syncable_util.h"
-#include "sync/syncable/syncable_write_transaction.h"
-#include "sync/test/engine/test_id_factory.h"
-#include "sync/test/engine/test_syncable_utils.h"
-#include "sync/test/fake_encryptor.h"
-#include "sync/test/null_directory_change_delegate.h"
-#include "sync/test/null_transaction_observer.h"
-#include "sync/util/test_unrecoverable_error_handler.h"
+#include "components/sync/base/test_unrecoverable_error_handler.h"
+#include "components/sync/protocol/bookmark_specifics.pb.h"
+#include "components/sync/syncable/directory_backing_store.h"
+#include "components/sync/syncable/directory_change_delegate.h"
+#include "components/sync/syncable/directory_unittest.h"
+#include "components/sync/syncable/in_memory_directory_backing_store.h"
+#include "components/sync/syncable/metahandle_set.h"
+#include "components/sync/syncable/mutable_entry.h"
+#include "components/sync/syncable/on_disk_directory_backing_store.h"
+#include "components/sync/syncable/syncable_proto_util.h"
+#include "components/sync/syncable/syncable_read_transaction.h"
+#include "components/sync/syncable/syncable_util.h"
+#include "components/sync/syncable/syncable_write_transaction.h"
+#include "components/sync/test/engine/test_id_factory.h"
+#include "components/sync/test/engine/test_syncable_utils.h"
+#include "components/sync/test/fake_encryptor.h"
+#include "components/sync/test/null_directory_change_delegate.h"
+#include "components/sync/test/null_transaction_observer.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace syncer {
@@ -64,11 +64,10 @@ class TestBackingStore : public OnDiskDirectoryBackingStore {
TestBackingStore::TestBackingStore(const std::string& dir_name,
const base::FilePath& backing_filepath)
- : OnDiskDirectoryBackingStore(dir_name, backing_filepath),
- fail_save_changes_(false) {
-}
+ : OnDiskDirectoryBackingStore(dir_name, backing_filepath),
+ fail_save_changes_(false) {}
-TestBackingStore::~TestBackingStore() { }
+TestBackingStore::~TestBackingStore() {}
bool TestBackingStore::SaveChanges(
const Directory::SaveChangesSnapshot& snapshot) {
@@ -91,9 +90,7 @@ class TestDirectory : public Directory {
~TestDirectory() override;
- void StartFailingSaveChanges() {
- backing_store_->StartFailingSaveChanges();
- }
+ void StartFailingSaveChanges() { backing_store_->StartFailingSaveChanges(); }
private:
TestDirectory(Encryptor* encryptor,
@@ -120,7 +117,7 @@ TestDirectory::TestDirectory(
: Directory(backing_store, handler, base::Closure(), NULL, NULL),
backing_store_(backing_store) {}
-TestDirectory::~TestDirectory() { }
+TestDirectory::~TestDirectory() {}
// crbug.com/144422
#if defined(OS_ANDROID)
@@ -134,8 +131,8 @@ TEST(OnDiskSyncableDirectory, MAYBE_FailInitialWrite) {
TestUnrecoverableErrorHandler handler;
base::ScopedTempDir temp_dir;
ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
- base::FilePath file_path = temp_dir.path().Append(
- FILE_PATH_LITERAL("Test.sqlite3"));
+ base::FilePath file_path =
+ temp_dir.path().Append(FILE_PATH_LITERAL("Test.sqlite3"));
std::string name = "user@x.com";
NullDirectoryChangeDelegate delegate;
@@ -143,8 +140,8 @@ TEST(OnDiskSyncableDirectory, MAYBE_FailInitialWrite) {
&encryptor, MakeWeakHandle(handler.GetWeakPtr()), name, file_path));
test_dir->StartFailingSaveChanges();
- ASSERT_EQ(FAILED_INITIAL_WRITE, test_dir->Open(name, &delegate,
- NullTransactionObserver()));
+ ASSERT_EQ(FAILED_INITIAL_WRITE,
+ test_dir->Open(name, &delegate, NullTransactionObserver()));
}
// A variant of SyncableDirectoryTest that uses a real sqlite database.
@@ -155,8 +152,7 @@ class OnDiskSyncableDirectoryTest : public SyncableDirectoryTest {
void SetUp() override {
SyncableDirectoryTest::SetUp();
ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
- file_path_ = temp_dir_.path().Append(
- FILE_PATH_LITERAL("Test.sqlite3"));
+ file_path_ = temp_dir_.path().Append(FILE_PATH_LITERAL("Test.sqlite3"));
base::DeleteFile(file_path_, false);
CreateDirectory();
}
@@ -177,10 +173,8 @@ class OnDiskSyncableDirectoryTest : public SyncableDirectoryTest {
kDirectoryName, file_path_);
dir().reset(test_directory_);
ASSERT_TRUE(dir().get());
- ASSERT_EQ(OPENED,
- dir()->Open(kDirectoryName,
- directory_change_delegate(),
- NullTransactionObserver()));
+ ASSERT_EQ(OPENED, dir()->Open(kDirectoryName, directory_change_delegate(),
+ NullTransactionObserver()));
ASSERT_TRUE(dir()->good());
}
@@ -189,9 +183,7 @@ class OnDiskSyncableDirectoryTest : public SyncableDirectoryTest {
CreateDirectory();
}
- void StartFailingSaveChanges() {
- test_directory_->StartFailingSaveChanges();
- }
+ void StartFailingSaveChanges() { test_directory_->StartFailingSaveChanges(); }
TestDirectory* test_directory_; // mirrors std::unique_ptr<Directory> dir_
base::ScopedTempDir temp_dir_;
@@ -247,8 +239,7 @@ TEST_F(OnDiskSyncableDirectoryTest, TestPurgeEntriesWithTypeIn) {
item2.PutServerSpecifics(bookmark_specs);
item2.PutIsUnappliedUpdate(true);
- MutableEntry item3(&trans, CREATE, PREFERENCES,
- trans.root_id(), "Item");
+ MutableEntry item3(&trans, CREATE, PREFERENCES, trans.root_id(), "Item");
ASSERT_TRUE(item3.good());
item3.PutSpecifics(preference_specs);
item3.PutServerSpecifics(preference_specs);
@@ -260,15 +251,14 @@ TEST_F(OnDiskSyncableDirectoryTest, TestPurgeEntriesWithTypeIn) {
item4.PutServerSpecifics(preference_specs);
item4.PutIsUnappliedUpdate(true);
- MutableEntry item5(&trans, CREATE, AUTOFILL,
- trans.root_id(), "Item");
+ MutableEntry item5(&trans, CREATE, AUTOFILL, trans.root_id(), "Item");
ASSERT_TRUE(item5.good());
item5.PutSpecifics(autofill_specs);
item5.PutServerSpecifics(autofill_specs);
item5.PutIsUnsynced(true);
MutableEntry item6(&trans, CREATE_NEW_UPDATE_ITEM,
- id_factory.NewServerId());
+ id_factory.NewServerId());
ASSERT_TRUE(item6.good());
item6.PutServerSpecifics(autofill_specs);
item6.PutIsUnappliedUpdate(true);
@@ -332,12 +322,12 @@ TEST_F(OnDiskSyncableDirectoryTest,
Id create_id;
EntryKernel create_pre_save, update_pre_save;
EntryKernel create_post_save, update_post_save;
- std::string create_name = "Create";
+ std::string create_name = "Create";
{
WriteTransaction trans(FROM_HERE, UNITTEST, dir().get());
- MutableEntry create(
- &trans, CREATE, BOOKMARKS, trans.root_id(), create_name);
+ MutableEntry create(&trans, CREATE, BOOKMARKS, trans.root_id(),
+ create_name);
MutableEntry update(&trans, CREATE_NEW_UPDATE_ITEM, update_id);
create.PutIsUnsynced(true);
update.PutIsUnappliedUpdate(true);
@@ -358,10 +348,8 @@ TEST_F(OnDiskSyncableDirectoryTest,
base::Closure(), NULL, NULL));
ASSERT_TRUE(dir().get());
- ASSERT_EQ(OPENED,
- dir()->Open(kDirectoryName,
- directory_change_delegate(),
- NullTransactionObserver()));
+ ASSERT_EQ(OPENED, dir()->Open(kDirectoryName, directory_change_delegate(),
+ NullTransactionObserver()));
ASSERT_TRUE(dir()->good());
{
@@ -373,7 +361,7 @@ TEST_F(OnDiskSyncableDirectoryTest,
update_post_save = update.GetKernelCopy();
}
int i = BEGIN_FIELDS;
- for ( ; i < INT64_FIELDS_END ; ++i) {
+ for (; i < INT64_FIELDS_END; ++i) {
EXPECT_EQ(
create_pre_save.ref((Int64Field)i) + (i == TRANSACTION_VERSION ? 1 : 0),
create_post_save.ref((Int64Field)i))
@@ -382,52 +370,50 @@ TEST_F(OnDiskSyncableDirectoryTest,
update_post_save.ref((Int64Field)i))
<< "int64_t field #" << i << " changed during save/load";
}
- for ( ; i < TIME_FIELDS_END ; ++i) {
+ for (; i < TIME_FIELDS_END; ++i) {
EXPECT_EQ(create_pre_save.ref((TimeField)i),
create_post_save.ref((TimeField)i))
- << "time field #" << i << " changed during save/load";
+ << "time field #" << i << " changed during save/load";
EXPECT_EQ(update_pre_save.ref((TimeField)i),
update_post_save.ref((TimeField)i))
- << "time field #" << i << " changed during save/load";
+ << "time field #" << i << " changed during save/load";
}
- for ( ; i < ID_FIELDS_END ; ++i) {
- EXPECT_EQ(create_pre_save.ref((IdField)i),
- create_post_save.ref((IdField)i))
- << "id field #" << i << " changed during save/load";
- EXPECT_EQ(update_pre_save.ref((IdField)i),
- update_pre_save.ref((IdField)i))
- << "id field #" << i << " changed during save/load";
+ for (; i < ID_FIELDS_END; ++i) {
+ EXPECT_EQ(create_pre_save.ref((IdField)i), create_post_save.ref((IdField)i))
+ << "id field #" << i << " changed during save/load";
+ EXPECT_EQ(update_pre_save.ref((IdField)i), update_pre_save.ref((IdField)i))
+ << "id field #" << i << " changed during save/load";
}
- for ( ; i < BIT_FIELDS_END ; ++i) {
+ for (; i < BIT_FIELDS_END; ++i) {
EXPECT_EQ(create_pre_save.ref((BitField)i),
create_post_save.ref((BitField)i))
- << "Bit field #" << i << " changed during save/load";
+ << "Bit field #" << i << " changed during save/load";
EXPECT_EQ(update_pre_save.ref((BitField)i),
update_post_save.ref((BitField)i))
- << "Bit field #" << i << " changed during save/load";
+ << "Bit field #" << i << " changed during save/load";
}
- for ( ; i < STRING_FIELDS_END ; ++i) {
+ for (; i < STRING_FIELDS_END; ++i) {
EXPECT_EQ(create_pre_save.ref((StringField)i),
create_post_save.ref((StringField)i))
- << "String field #" << i << " changed during save/load";
+ << "String field #" << i << " changed during save/load";
EXPECT_EQ(update_pre_save.ref((StringField)i),
update_post_save.ref((StringField)i))
- << "String field #" << i << " changed during save/load";
+ << "String field #" << i << " changed during save/load";
}
- for ( ; i < PROTO_FIELDS_END; ++i) {
+ for (; i < PROTO_FIELDS_END; ++i) {
EXPECT_EQ(create_pre_save.ref((ProtoField)i).SerializeAsString(),
create_post_save.ref((ProtoField)i).SerializeAsString())
- << "Blob field #" << i << " changed during save/load";
+ << "Blob field #" << i << " changed during save/load";
EXPECT_EQ(update_pre_save.ref((ProtoField)i).SerializeAsString(),
update_post_save.ref((ProtoField)i).SerializeAsString())
- << "Blob field #" << i << " changed during save/load";
+ << "Blob field #" << i << " changed during save/load";
}
- for ( ; i < UNIQUE_POSITION_FIELDS_END; ++i) {
- EXPECT_TRUE(create_pre_save.ref((UniquePositionField)i).Equals(
- create_post_save.ref((UniquePositionField)i)))
+ for (; i < UNIQUE_POSITION_FIELDS_END; ++i) {
+ EXPECT_TRUE(create_pre_save.ref((UniquePositionField)i)
+ .Equals(create_post_save.ref((UniquePositionField)i)))
<< "Position field #" << i << " changed during save/load";
- EXPECT_TRUE(update_pre_save.ref((UniquePositionField)i).Equals(
- update_post_save.ref((UniquePositionField)i)))
+ EXPECT_TRUE(update_pre_save.ref((UniquePositionField)i)
+ .Equals(update_post_save.ref((UniquePositionField)i)))
<< "Position field #" << i << " changed during save/load";
}
}
@@ -484,8 +470,8 @@ TEST_F(OnDiskSyncableDirectoryTest, TestSaveChangesFailure) {
EXPECT_TRUE(IsInDirtyMetahandles(handle1));
// New item.
- MutableEntry kids_on_block(
- &trans, CREATE, BOOKMARKS, trans.root_id(), "kids");
+ MutableEntry kids_on_block(&trans, CREATE, BOOKMARKS, trans.root_id(),
+ "kids");
ASSERT_TRUE(kids_on_block.good());
handle2 = kids_on_block.GetMetahandle();
kids_on_block.PutBaseVersion(1);
@@ -590,8 +576,7 @@ class SyncableClientTagTest : public SyncableDirectoryTest {
bool CreateWithDefaultTag(Id id, bool deleted) {
WriteTransaction wtrans(FROM_HERE, UNITTEST, dir().get());
- MutableEntry me(&wtrans, CREATE, PREFERENCES,
- wtrans.root_id(), test_name_);
+ MutableEntry me(&wtrans, CREATE, PREFERENCES, wtrans.root_id(), test_name_);
CHECK(me.good());
me.PutId(id);
if (id.ServerKnows()) {
« no previous file with comments | « components/sync/syncable/syncable_read_transaction.cc ('k') | components/sync/syncable/syncable_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698