OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 <string> | 5 #include <string> |
6 | 6 |
7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
8 #include "base/file_path.h" | 8 #include "base/file_path.h" |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/location.h" | 10 #include "base/location.h" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "base/message_loop.h" | 13 #include "base/message_loop.h" |
14 #include "base/scoped_temp_dir.h" | 14 #include "base/scoped_temp_dir.h" |
15 #include "base/stringprintf.h" | 15 #include "base/stringprintf.h" |
16 #include "base/synchronization/condition_variable.h" | 16 #include "base/synchronization/condition_variable.h" |
17 #include "base/test/values_test_util.h" | 17 #include "base/test/values_test_util.h" |
18 #include "base/threading/platform_thread.h" | 18 #include "base/threading/platform_thread.h" |
19 #include "base/values.h" | 19 #include "base/values.h" |
20 #include "sync/engine/syncproto.h" | |
21 #include "sync/protocol/bookmark_specifics.pb.h" | 20 #include "sync/protocol/bookmark_specifics.pb.h" |
22 #include "sync/syncable/directory_backing_store.h" | 21 #include "sync/syncable/directory_backing_store.h" |
23 #include "sync/syncable/directory_change_delegate.h" | 22 #include "sync/syncable/directory_change_delegate.h" |
24 #include "sync/syncable/in_memory_directory_backing_store.h" | 23 #include "sync/syncable/in_memory_directory_backing_store.h" |
25 #include "sync/syncable/metahandle_set.h" | 24 #include "sync/syncable/metahandle_set.h" |
26 #include "sync/syncable/mutable_entry.h" | 25 #include "sync/syncable/mutable_entry.h" |
27 #include "sync/syncable/on_disk_directory_backing_store.h" | 26 #include "sync/syncable/on_disk_directory_backing_store.h" |
28 #include "sync/syncable/read_transaction.h" | 27 #include "sync/syncable/read_transaction.h" |
| 28 #include "sync/syncable/syncable_proto_util.h" |
29 #include "sync/syncable/syncable_util.h" | 29 #include "sync/syncable/syncable_util.h" |
30 #include "sync/syncable/write_transaction.h" | 30 #include "sync/syncable/write_transaction.h" |
31 #include "sync/test/engine/test_id_factory.h" | 31 #include "sync/test/engine/test_id_factory.h" |
32 #include "sync/test/engine/test_syncable_utils.h" | 32 #include "sync/test/engine/test_syncable_utils.h" |
33 #include "sync/test/fake_encryptor.h" | 33 #include "sync/test/fake_encryptor.h" |
34 #include "sync/test/null_directory_change_delegate.h" | 34 #include "sync/test/null_directory_change_delegate.h" |
35 #include "sync/test/null_transaction_observer.h" | 35 #include "sync/test/null_transaction_observer.h" |
36 #include "sync/util/test_unrecoverable_error_handler.h" | 36 #include "sync/util/test_unrecoverable_error_handler.h" |
37 #include "testing/gtest/include/gtest/gtest.h" | 37 #include "testing/gtest/include/gtest/gtest.h" |
38 | 38 |
(...skipping 1106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1145 | 1145 |
1146 MutableEntry server_item(&trans, CREATE_NEW_UPDATE_ITEM, | 1146 MutableEntry server_item(&trans, CREATE_NEW_UPDATE_ITEM, |
1147 id_factory.NewServerId()); | 1147 id_factory.NewServerId()); |
1148 ASSERT_TRUE(server_item.good()); | 1148 ASSERT_TRUE(server_item.good()); |
1149 server_item.Put(SERVER_SPECIFICS, specifics); | 1149 server_item.Put(SERVER_SPECIFICS, specifics); |
1150 server_item.Put(BASE_VERSION, 1); | 1150 server_item.Put(BASE_VERSION, 1); |
1151 server_item.Put(SERVER_IS_DIR, false); | 1151 server_item.Put(SERVER_IS_DIR, false); |
1152 server_item.Put(SERVER_IS_DEL, false); | 1152 server_item.Put(SERVER_IS_DEL, false); |
1153 ASSERT_EQ(datatype, server_item.GetServerModelType()); | 1153 ASSERT_EQ(datatype, server_item.GetServerModelType()); |
1154 | 1154 |
1155 syncer::SyncEntity folder_entity; | 1155 sync_pb::SyncEntity folder_entity; |
1156 folder_entity.set_id(id_factory.NewServerId()); | 1156 folder_entity.set_id_string(SyncableIdToProto(id_factory.NewServerId())); |
1157 folder_entity.set_deleted(false); | 1157 folder_entity.set_deleted(false); |
1158 folder_entity.set_folder(true); | 1158 folder_entity.set_folder(true); |
1159 folder_entity.mutable_specifics()->CopyFrom(specifics); | 1159 folder_entity.mutable_specifics()->CopyFrom(specifics); |
1160 ASSERT_EQ(datatype, folder_entity.GetModelType()); | 1160 ASSERT_EQ(datatype, GetModelType(folder_entity)); |
1161 | 1161 |
1162 syncer::SyncEntity item_entity; | 1162 sync_pb::SyncEntity item_entity; |
1163 item_entity.set_id(id_factory.NewServerId()); | 1163 item_entity.set_id_string(SyncableIdToProto(id_factory.NewServerId())); |
1164 item_entity.set_deleted(false); | 1164 item_entity.set_deleted(false); |
1165 item_entity.set_folder(false); | 1165 item_entity.set_folder(false); |
1166 item_entity.mutable_specifics()->CopyFrom(specifics); | 1166 item_entity.mutable_specifics()->CopyFrom(specifics); |
1167 ASSERT_EQ(datatype, item_entity.GetModelType()); | 1167 ASSERT_EQ(datatype, GetModelType(item_entity)); |
1168 } | 1168 } |
1169 } | 1169 } |
1170 | 1170 |
1171 // A test that roughly mimics the directory interaction that occurs when a | 1171 // A test that roughly mimics the directory interaction that occurs when a |
1172 // bookmark folder and entry are created then synced for the first time. It is | 1172 // bookmark folder and entry are created then synced for the first time. It is |
1173 // a more common variant of the 'DeletedAndUnsyncedChild' scenario tested below. | 1173 // a more common variant of the 'DeletedAndUnsyncedChild' scenario tested below. |
1174 TEST_F(SyncableDirectoryTest, ChangeEntryIDAndUpdateChildren_ParentAndChild) { | 1174 TEST_F(SyncableDirectoryTest, ChangeEntryIDAndUpdateChildren_ParentAndChild) { |
1175 TestIdFactory id_factory; | 1175 TestIdFactory id_factory; |
1176 Id orig_parent_id; | 1176 Id orig_parent_id; |
1177 Id orig_child_id; | 1177 Id orig_child_id; |
(...skipping 765 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1943 EXPECT_TRUE(CreateWithDefaultTag(factory_.NewServerId(), true)); | 1943 EXPECT_TRUE(CreateWithDefaultTag(factory_.NewServerId(), true)); |
1944 EXPECT_FALSE(CreateWithDefaultTag(factory_.NewServerId(), true)); | 1944 EXPECT_FALSE(CreateWithDefaultTag(factory_.NewServerId(), true)); |
1945 EXPECT_FALSE(CreateWithDefaultTag(factory_.NewServerId(), false)); | 1945 EXPECT_FALSE(CreateWithDefaultTag(factory_.NewServerId(), false)); |
1946 EXPECT_FALSE(CreateWithDefaultTag(factory_.NewLocalId(), false)); | 1946 EXPECT_FALSE(CreateWithDefaultTag(factory_.NewLocalId(), false)); |
1947 EXPECT_FALSE(CreateWithDefaultTag(factory_.NewLocalId(), true)); | 1947 EXPECT_FALSE(CreateWithDefaultTag(factory_.NewLocalId(), true)); |
1948 } | 1948 } |
1949 | 1949 |
1950 } // namespace | 1950 } // namespace |
1951 } // namespace syncable | 1951 } // namespace syncable |
1952 } // namespace syncer | 1952 } // namespace syncer |
OLD | NEW |