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

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

Issue 1008993004: Sync: Handle empty (implicit) ParentId in GetPredecessorId and GetSuccessorId (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added extra unit test. Created 5 years, 9 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/parent_child_index.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 1862 matching lines...) Expand 10 before | Expand all | Expand 10 after
1873 // (subtract one to exclude roots themselves). 1873 // (subtract one to exclude roots themselves).
1874 Entry p_root(&trans, GET_BY_ID, p_root_id); 1874 Entry p_root(&trans, GET_BY_ID, p_root_id);
1875 ASSERT_EQ(item1_id, p_root.GetFirstChildId()); 1875 ASSERT_EQ(item1_id, p_root.GetFirstChildId());
1876 ASSERT_EQ(1, p_root.GetTotalNodeCount() - 1); 1876 ASSERT_EQ(1, p_root.GetTotalNodeCount() - 1);
1877 Entry a_root(&trans, GET_BY_ID, a_root_id); 1877 Entry a_root(&trans, GET_BY_ID, a_root_id);
1878 ASSERT_EQ(item2_id, a_root.GetFirstChildId()); 1878 ASSERT_EQ(item2_id, a_root.GetFirstChildId());
1879 ASSERT_EQ(1, a_root.GetTotalNodeCount() - 1); 1879 ASSERT_EQ(1, a_root.GetTotalNodeCount() - 1);
1880 } 1880 }
1881 } 1881 }
1882 1882
1883 // Verify that the successor / predecessor navigation still works for
1884 // directory entries with unset Parent IDs.
1885 TEST_F(SyncableDirectoryTest, MutableEntry_ImplicitParentId_Siblings) {
1886 TestIdFactory id_factory;
1887 const Id root_id = TestIdFactory::root();
1888 const Id p_root_id = id_factory.NewServerId();
1889 const Id item1_id = id_factory.FromNumber(1);
1890 const Id item2_id = id_factory.FromNumber(2);
1891
1892 // Create type root folder for PREFERENCES.
1893 {
1894 WriteTransaction trans(FROM_HERE, UNITTEST, dir().get());
1895 MutableEntry p_root(&trans, CREATE, PREFERENCES, root_id, "P");
1896 ASSERT_TRUE(p_root.good());
1897 p_root.PutIsDir(true);
1898 p_root.PutId(p_root_id);
1899 p_root.PutBaseVersion(1);
1900 }
1901
1902 // Create two PREFERENCES entries with implicit parent nodes.
1903 {
1904 WriteTransaction trans(FROM_HERE, UNITTEST, dir().get());
1905 MutableEntry item1(&trans, CREATE, PREFERENCES, "P1");
1906 item1.PutBaseVersion(1);
1907 item1.PutId(item1_id);
1908 MutableEntry item2(&trans, CREATE, PREFERENCES, "P2");
1909 item2.PutBaseVersion(1);
1910 item2.PutId(item2_id);
1911 }
1912
1913 // Verify GetSuccessorId and GetPredecessorId calls for these items.
1914 // Please note that items are sorted according to their ID, e.g.
1915 // item1 first, then item2.
1916 {
1917 ReadTransaction trans(FROM_HERE, dir().get());
1918 Entry item1(&trans, GET_BY_ID, item1_id);
1919 EXPECT_EQ(Id(), item1.GetPredecessorId());
1920 EXPECT_EQ(item2_id, item1.GetSuccessorId());
1921
1922 Entry item2(&trans, GET_BY_ID, item2_id);
1923 EXPECT_EQ(item1_id, item2.GetPredecessorId());
1924 EXPECT_EQ(Id(), item2.GetSuccessorId());
1925 }
1926 }
1927
1883 } // namespace syncable 1928 } // namespace syncable
1884 1929
1885 } // namespace syncer 1930 } // namespace syncer
OLDNEW
« no previous file with comments | « sync/syncable/directory.cc ('k') | sync/syncable/parent_child_index.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698