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

Side by Side Diff: sync/syncable/directory_unittest.cc

Issue 867793003: Remove dependency on server generated type root folders (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added extra comment about existing type root folder. Created 5 years, 10 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
« no previous file with comments | « sync/syncable/directory.cc ('k') | sync/syncable/entry_kernel.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "sync/syncable/directory_unittest.h" 5 #include "sync/syncable/directory_unittest.h"
6 6
7 #include "base/strings/stringprintf.h" 7 #include "base/strings/stringprintf.h"
8 #include "base/test/values_test_util.h" 8 #include "base/test/values_test_util.h"
9 #include "sync/internal_api/public/base/attachment_id_proto.h" 9 #include "sync/internal_api/public/base/attachment_id_proto.h"
10 #include "sync/syncable/syncable_proto_util.h" 10 #include "sync/syncable/syncable_proto_util.h"
(...skipping 1026 matching lines...) Expand 10 before | Expand all | Expand 10 after
1037 ChangeEntryIDAndUpdateChildren(&trans, &parent, id_factory.NewServerId()); 1037 ChangeEntryIDAndUpdateChildren(&trans, &parent, id_factory.NewServerId());
1038 parent.PutIsUnsynced(false); 1038 parent.PutIsUnsynced(false);
1039 parent.PutBaseVersion(1); 1039 parent.PutBaseVersion(1);
1040 parent.PutServerVersion(1); 1040 parent.PutServerVersion(1);
1041 } 1041 }
1042 1042
1043 // Final check for validity. 1043 // Final check for validity.
1044 EXPECT_EQ(OPENED, SimulateSaveAndReloadDir()); 1044 EXPECT_EQ(OPENED, SimulateSaveAndReloadDir());
1045 } 1045 }
1046 1046
1047 // A test that roughly mimics the directory interaction that occurs when a
1048 // type root folder is created locally and then re-created (updated) from the
1049 // server.
1050 TEST_F(SyncableDirectoryTest, ChangeEntryIDAndUpdateChildren_ImplicitParent) {
1051 TestIdFactory id_factory;
1052 Id orig_parent_id;
1053 Id child_id;
1054
1055 {
1056 // Create two client-side items, a parent and child.
1057 WriteTransaction trans(FROM_HERE, UNITTEST, dir().get());
1058
1059 MutableEntry parent(&trans, CREATE, PREFERENCES, id_factory.root(),
1060 "parent");
1061 parent.PutIsDir(true);
1062 parent.PutIsUnsynced(true);
1063
1064 // The child has unset parent ID. The parent is inferred from the type.
1065 MutableEntry child(&trans, CREATE, PREFERENCES, "child");
1066 child.PutIsUnsynced(true);
1067
1068 orig_parent_id = parent.GetId();
1069 child_id = child.GetId();
1070 }
1071
1072 {
1073 // Simulate what happens after committing two items. Their IDs will be
1074 // replaced with server IDs. The child is renamed first, then the parent.
1075 WriteTransaction trans(FROM_HERE, UNITTEST, dir().get());
1076
1077 MutableEntry parent(&trans, GET_BY_ID, orig_parent_id);
1078
1079 ChangeEntryIDAndUpdateChildren(&trans, &parent, id_factory.NewServerId());
1080 parent.PutIsUnsynced(false);
1081 parent.PutBaseVersion(1);
1082 parent.PutServerVersion(1);
1083 }
1084
1085 // Final check for validity.
1086 EXPECT_EQ(OPENED, SimulateSaveAndReloadDir());
1087
1088 // Verify that child's PARENT_ID hasn't been updated.
1089 {
1090 ReadTransaction trans(FROM_HERE, dir().get());
1091 Entry child(&trans, GET_BY_ID, child_id);
1092 EXPECT_TRUE(child.good());
1093 EXPECT_TRUE(child.GetParentId().IsNull());
1094 }
1095 }
1096
1047 // A test based on the scenario where we create a bookmark folder and entry 1097 // A test based on the scenario where we create a bookmark folder and entry
1048 // locally, but with a twist. In this case, the bookmark is deleted before we 1098 // locally, but with a twist. In this case, the bookmark is deleted before we
1049 // are able to sync either it or its parent folder. This scenario used to cause 1099 // are able to sync either it or its parent folder. This scenario used to cause
1050 // directory corruption, see crbug.com/125381. 1100 // directory corruption, see crbug.com/125381.
1051 TEST_F(SyncableDirectoryTest, 1101 TEST_F(SyncableDirectoryTest,
1052 ChangeEntryIDAndUpdateChildren_DeletedAndUnsyncedChild) { 1102 ChangeEntryIDAndUpdateChildren_DeletedAndUnsyncedChild) {
1053 TestIdFactory id_factory; 1103 TestIdFactory id_factory;
1054 Id orig_parent_id; 1104 Id orig_parent_id;
1055 Id orig_child_id; 1105 Id orig_child_id;
1056 1106
(...skipping 769 matching lines...) Expand 10 before | Expand all | Expand 10 after
1826 ASSERT_EQ(1, p_root.GetTotalNodeCount() - 1); 1876 ASSERT_EQ(1, p_root.GetTotalNodeCount() - 1);
1827 Entry a_root(&trans, GET_BY_ID, a_root_id); 1877 Entry a_root(&trans, GET_BY_ID, a_root_id);
1828 ASSERT_EQ(item2_id, a_root.GetFirstChildId()); 1878 ASSERT_EQ(item2_id, a_root.GetFirstChildId());
1829 ASSERT_EQ(1, a_root.GetTotalNodeCount() - 1); 1879 ASSERT_EQ(1, a_root.GetTotalNodeCount() - 1);
1830 } 1880 }
1831 } 1881 }
1832 1882
1833 } // namespace syncable 1883 } // namespace syncable
1834 1884
1835 } // namespace syncer 1885 } // namespace syncer
OLDNEW
« no previous file with comments | « sync/syncable/directory.cc ('k') | sync/syncable/entry_kernel.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698