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

Side by Side Diff: components/sync/model_impl/model_type_store_backend_unittest.cc

Issue 2422253002: [Sync] Rewriting ".reset(new" pattern to use "= base::MakeUnique" instead. (Closed)
Patch Set: Fixing compile. Created 4 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/sync/model_impl/model_type_store_backend.h" 5 #include "components/sync/model_impl/model_type_store_backend.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/memory/ptr_util.h"
9 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
10 #include "third_party/leveldatabase/src/include/leveldb/env.h" 11 #include "third_party/leveldatabase/src/include/leveldb/env.h"
11 #include "third_party/leveldatabase/src/include/leveldb/write_batch.h" 12 #include "third_party/leveldatabase/src/include/leveldb/write_batch.h"
12 13
13 namespace syncer { 14 namespace syncer {
14 15
15 class ModelTypeStoreBackendTest : public testing::Test { 16 class ModelTypeStoreBackendTest : public testing::Test {
16 public: 17 public:
17 scoped_refptr<ModelTypeStoreBackend> GetOrCreateBackend() { 18 scoped_refptr<ModelTypeStoreBackend> GetOrCreateBackend() {
18 std::string path = "/test_db"; 19 std::string path = "/test_db";
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 ModelTypeStore::RecordList record_list; 118 ModelTypeStore::RecordList record_list;
118 id_list.push_back("id1"); 119 id_list.push_back("id1");
119 id_list.push_back("id2"); 120 id_list.push_back("id2");
120 result = backend->ReadRecordsWithPrefix("prefix:", id_list, &record_list, 121 result = backend->ReadRecordsWithPrefix("prefix:", id_list, &record_list,
121 &missing_id_list); 122 &missing_id_list);
122 ASSERT_EQ(ModelTypeStore::Result::SUCCESS, result); 123 ASSERT_EQ(ModelTypeStore::Result::SUCCESS, result);
123 ASSERT_EQ(2UL, record_list.size()); 124 ASSERT_EQ(2UL, record_list.size());
124 ASSERT_TRUE(missing_id_list.empty()); 125 ASSERT_TRUE(missing_id_list.empty());
125 126
126 // Delete one record. 127 // Delete one record.
127 write_batch.reset(new leveldb::WriteBatch()); 128 write_batch = base::MakeUnique<leveldb::WriteBatch>();
128 write_batch->Delete("prefix:id2"); 129 write_batch->Delete("prefix:id2");
129 result = backend->WriteModifications(std::move(write_batch)); 130 result = backend->WriteModifications(std::move(write_batch));
130 ASSERT_EQ(ModelTypeStore::Result::SUCCESS, result); 131 ASSERT_EQ(ModelTypeStore::Result::SUCCESS, result);
131 132
132 // Ensure deleted record id is returned in missing_id_list. 133 // Ensure deleted record id is returned in missing_id_list.
133 record_list.clear(); 134 record_list.clear();
134 missing_id_list.clear(); 135 missing_id_list.clear();
135 result = backend->ReadRecordsWithPrefix("prefix:", id_list, &record_list, 136 result = backend->ReadRecordsWithPrefix("prefix:", id_list, &record_list,
136 &missing_id_list); 137 &missing_id_list);
137 ASSERT_EQ(ModelTypeStore::Result::SUCCESS, result); 138 ASSERT_EQ(ModelTypeStore::Result::SUCCESS, result);
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 ASSERT_TRUE(backend_second->HasOneRef()); 184 ASSERT_TRUE(backend_second->HasOneRef());
184 ASSERT_FALSE(BackendExistsForPath(path)); 185 ASSERT_FALSE(BackendExistsForPath(path));
185 186
186 // delete another backend. 187 // delete another backend.
187 backend_second = nullptr; 188 backend_second = nullptr;
188 ASSERT_FALSE(backend_second.get()); 189 ASSERT_FALSE(backend_second.get());
189 ASSERT_FALSE(BackendExistsForPath("/test_db2")); 190 ASSERT_FALSE(BackendExistsForPath("/test_db2"));
190 } 191 }
191 192
192 } // namespace syncer 193 } // namespace syncer
OLDNEW
« no previous file with comments | « components/sync/model_impl/attachments/task_queue_unittest.cc ('k') | components/sync/model_impl/model_type_store_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698