OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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 <stdint.h> | 5 #include <stdint.h> |
6 | 6 |
| 7 #include <memory> |
7 #include <string> | 8 #include <string> |
8 | 9 |
9 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
10 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
11 #include "base/files/file_util.h" | 12 #include "base/files/file_util.h" |
12 #include "base/files/scoped_temp_dir.h" | 13 #include "base/files/scoped_temp_dir.h" |
13 #include "base/location.h" | 14 #include "base/location.h" |
14 #include "base/logging.h" | 15 #include "base/logging.h" |
15 #include "base/memory/scoped_ptr.h" | |
16 #include "base/message_loop/message_loop.h" | 16 #include "base/message_loop/message_loop.h" |
17 #include "base/stl_util.h" | 17 #include "base/stl_util.h" |
18 #include "base/synchronization/condition_variable.h" | 18 #include "base/synchronization/condition_variable.h" |
19 #include "base/test/values_test_util.h" | 19 #include "base/test/values_test_util.h" |
20 #include "base/threading/platform_thread.h" | 20 #include "base/threading/platform_thread.h" |
21 #include "base/values.h" | 21 #include "base/values.h" |
22 #include "build/build_config.h" | 22 #include "build/build_config.h" |
23 #include "sync/protocol/bookmark_specifics.pb.h" | 23 #include "sync/protocol/bookmark_specifics.pb.h" |
24 #include "sync/syncable/directory_backing_store.h" | 24 #include "sync/syncable/directory_backing_store.h" |
25 #include "sync/syncable/directory_change_delegate.h" | 25 #include "sync/syncable/directory_change_delegate.h" |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 base::MessageLoop message_loop; | 132 base::MessageLoop message_loop; |
133 FakeEncryptor encryptor; | 133 FakeEncryptor encryptor; |
134 TestUnrecoverableErrorHandler handler; | 134 TestUnrecoverableErrorHandler handler; |
135 base::ScopedTempDir temp_dir; | 135 base::ScopedTempDir temp_dir; |
136 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); | 136 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); |
137 base::FilePath file_path = temp_dir.path().Append( | 137 base::FilePath file_path = temp_dir.path().Append( |
138 FILE_PATH_LITERAL("Test.sqlite3")); | 138 FILE_PATH_LITERAL("Test.sqlite3")); |
139 std::string name = "user@x.com"; | 139 std::string name = "user@x.com"; |
140 NullDirectoryChangeDelegate delegate; | 140 NullDirectoryChangeDelegate delegate; |
141 | 141 |
142 scoped_ptr<TestDirectory> test_dir(TestDirectory::Create( | 142 std::unique_ptr<TestDirectory> test_dir(TestDirectory::Create( |
143 &encryptor, MakeWeakHandle(handler.GetWeakPtr()), name, file_path)); | 143 &encryptor, MakeWeakHandle(handler.GetWeakPtr()), name, file_path)); |
144 | 144 |
145 test_dir->StartFailingSaveChanges(); | 145 test_dir->StartFailingSaveChanges(); |
146 ASSERT_EQ(FAILED_INITIAL_WRITE, test_dir->Open(name, &delegate, | 146 ASSERT_EQ(FAILED_INITIAL_WRITE, test_dir->Open(name, &delegate, |
147 NullTransactionObserver())); | 147 NullTransactionObserver())); |
148 } | 148 } |
149 | 149 |
150 // A variant of SyncableDirectoryTest that uses a real sqlite database. | 150 // A variant of SyncableDirectoryTest that uses a real sqlite database. |
151 class OnDiskSyncableDirectoryTest : public SyncableDirectoryTest { | 151 class OnDiskSyncableDirectoryTest : public SyncableDirectoryTest { |
152 protected: | 152 protected: |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 | 186 |
187 void SaveAndReloadDir() { | 187 void SaveAndReloadDir() { |
188 dir()->SaveChanges(); | 188 dir()->SaveChanges(); |
189 CreateDirectory(); | 189 CreateDirectory(); |
190 } | 190 } |
191 | 191 |
192 void StartFailingSaveChanges() { | 192 void StartFailingSaveChanges() { |
193 test_directory_->StartFailingSaveChanges(); | 193 test_directory_->StartFailingSaveChanges(); |
194 } | 194 } |
195 | 195 |
196 TestDirectory* test_directory_; // mirrors scoped_ptr<Directory> dir_ | 196 TestDirectory* test_directory_; // mirrors std::unique_ptr<Directory> dir_ |
197 base::ScopedTempDir temp_dir_; | 197 base::ScopedTempDir temp_dir_; |
198 base::FilePath file_path_; | 198 base::FilePath file_path_; |
199 }; | 199 }; |
200 | 200 |
201 sync_pb::DataTypeContext BuildContext(ModelType type) { | 201 sync_pb::DataTypeContext BuildContext(ModelType type) { |
202 sync_pb::DataTypeContext context; | 202 sync_pb::DataTypeContext context; |
203 context.set_context("context"); | 203 context.set_context("context"); |
204 context.set_data_type_id(GetSpecificsFieldNumberFromModelType(type)); | 204 context.set_data_type_id(GetSpecificsFieldNumberFromModelType(type)); |
205 return context; | 205 return context; |
206 } | 206 } |
(...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
670 TEST_F(SyncableClientTagTest, TestClientTagIndexDuplicateServer) { | 670 TEST_F(SyncableClientTagTest, TestClientTagIndexDuplicateServer) { |
671 EXPECT_TRUE(CreateWithDefaultTag(factory_.NewServerId(), true)); | 671 EXPECT_TRUE(CreateWithDefaultTag(factory_.NewServerId(), true)); |
672 EXPECT_FALSE(CreateWithDefaultTag(factory_.NewServerId(), true)); | 672 EXPECT_FALSE(CreateWithDefaultTag(factory_.NewServerId(), true)); |
673 EXPECT_FALSE(CreateWithDefaultTag(factory_.NewServerId(), false)); | 673 EXPECT_FALSE(CreateWithDefaultTag(factory_.NewServerId(), false)); |
674 EXPECT_FALSE(CreateWithDefaultTag(factory_.NewLocalId(), false)); | 674 EXPECT_FALSE(CreateWithDefaultTag(factory_.NewLocalId(), false)); |
675 EXPECT_FALSE(CreateWithDefaultTag(factory_.NewLocalId(), true)); | 675 EXPECT_FALSE(CreateWithDefaultTag(factory_.NewLocalId(), true)); |
676 } | 676 } |
677 | 677 |
678 } // namespace syncable | 678 } // namespace syncable |
679 } // namespace syncer | 679 } // namespace syncer |
OLD | NEW |