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

Unified Diff: components/sync/model_impl/model_type_store_impl_unittest.cc

Issue 2489683002: [Sync] Make all ModelTypeStore write methods go through WriteBatch. (Closed)
Patch Set: Address comment. Created 4 years, 1 month 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/model_impl/model_type_store_impl.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/sync/model_impl/model_type_store_impl_unittest.cc
diff --git a/components/sync/model_impl/model_type_store_impl_unittest.cc b/components/sync/model_impl/model_type_store_impl_unittest.cc
index 15ac6a9ae6b6c2e82164e5a27d88168889cf6ca4..ab709dd18190182b3e2fd1eed75b2e249cab25f8 100644
--- a/components/sync/model_impl/model_type_store_impl_unittest.cc
+++ b/components/sync/model_impl/model_type_store_impl_unittest.cc
@@ -69,7 +69,7 @@ class ModelTypeStoreImplTest : public testing::Test {
const std::string& key,
const std::string& data) {
auto write_batch = store->CreateWriteBatch();
- store->WriteData(write_batch.get(), key, data);
+ write_batch->WriteData(key, data);
ModelTypeStore::Result result;
store->CommitWriteBatch(std::move(write_batch),
base::Bind(&CaptureResult, &result));
@@ -102,6 +102,31 @@ class ModelTypeStoreImplTest : public testing::Test {
ASSERT_EQ(ModelTypeStore::Result::SUCCESS, result);
}
+ static void WriteRawMetadata(ModelTypeStore* store,
+ const std::string& key,
+ const std::string& raw_metadata) {
+ auto write_batch = store->CreateWriteBatch();
+ store->WriteMetadata(write_batch.get(), key, raw_metadata);
+
+ ModelTypeStore::Result result;
+ store->CommitWriteBatch(std::move(write_batch),
+ base::Bind(&CaptureResult, &result));
+ PumpLoop();
+ ASSERT_EQ(ModelTypeStore::Result::SUCCESS, result);
+ }
+
+ static void WriteRawModelTypeState(ModelTypeStore* store,
+ const std::string& raw_model_type_state) {
+ auto write_batch = store->CreateWriteBatch();
+ store->WriteGlobalMetadata(write_batch.get(), raw_model_type_state);
+
+ ModelTypeStore::Result result;
+ store->CommitWriteBatch(std::move(write_batch),
+ base::Bind(&CaptureResult, &result));
+ PumpLoop();
+ ASSERT_EQ(ModelTypeStore::Result::SUCCESS, result);
+ }
+
void WriteTestData() {
WriteData(store(), "id1", "data1");
WriteMetadata(store(), "id1", CreateEntityMetadata("metadata1"));
@@ -236,7 +261,7 @@ TEST_F(ModelTypeStoreImplTest, MissingModelTypeState) {
ModelTypeStore::Result result;
auto write_batch = store()->CreateWriteBatch();
- store()->DeleteGlobalMetadata(write_batch.get());
+ write_batch->GetMetadataChangeList()->ClearModelTypeState();
store()->CommitWriteBatch(std::move(write_batch),
base::Bind(&CaptureResult, &result));
PumpLoop();
@@ -258,13 +283,7 @@ TEST_F(ModelTypeStoreImplTest, CorruptModelTypeState) {
WriteTestData();
// Write a ModelTypeState that can't be parsed.
- ModelTypeStore::Result result;
- auto write_batch = store()->CreateWriteBatch();
- store()->WriteGlobalMetadata(write_batch.get(), "unparseable");
- store()->CommitWriteBatch(std::move(write_batch),
- base::Bind(&CaptureResult, &result));
- PumpLoop();
- ASSERT_EQ(ModelTypeStore::Result::SUCCESS, result);
+ WriteRawModelTypeState(store(), "unparseable");
SyncError error;
std::unique_ptr<MetadataBatch> metadata_batch;
@@ -282,13 +301,7 @@ TEST_F(ModelTypeStoreImplTest, CorruptEntityMetadata) {
WriteTestData();
// Write an EntityMetadata that can't be parsed.
- ModelTypeStore::Result result;
- auto write_batch = store()->CreateWriteBatch();
- store()->WriteMetadata(write_batch.get(), "id", "unparseable");
- store()->CommitWriteBatch(std::move(write_batch),
- base::Bind(&CaptureResult, &result));
- PumpLoop();
- ASSERT_EQ(ModelTypeStore::Result::SUCCESS, result);
+ WriteRawMetadata(store(), "id", "unparseable");
SyncError error;
std::unique_ptr<MetadataBatch> metadata_batch;
« no previous file with comments | « components/sync/model_impl/model_type_store_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698