OLD | NEW |
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 1331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1342 const Id id = TestIdFactory::FromNumber(99); | 1342 const Id id = TestIdFactory::FromNumber(99); |
1343 std::string name = "Jeff"; | 1343 std::string name = "Jeff"; |
1344 { | 1344 { |
1345 ReadTransaction rtrans(FROM_HERE, dir().get()); | 1345 ReadTransaction rtrans(FROM_HERE, dir().get()); |
1346 Entry e(&rtrans, GET_BY_ID, id); | 1346 Entry e(&rtrans, GET_BY_ID, id); |
1347 ASSERT_FALSE(e.good()); // Hasn't been written yet. | 1347 ASSERT_FALSE(e.good()); // Hasn't been written yet. |
1348 | 1348 |
1349 Entry root(&rtrans, GET_BY_ID, rtrans.root_id()); | 1349 Entry root(&rtrans, GET_BY_ID, rtrans.root_id()); |
1350 ASSERT_TRUE(root.good()); | 1350 ASSERT_TRUE(root.good()); |
1351 EXPECT_FALSE(dir()->HasChildren(&rtrans, rtrans.root_id())); | 1351 EXPECT_FALSE(dir()->HasChildren(&rtrans, rtrans.root_id())); |
1352 EXPECT_TRUE(root.GetFirstChildId().IsRoot()); | 1352 EXPECT_TRUE(root.GetFirstChildId().IsNull()); |
1353 } | 1353 } |
1354 | 1354 |
1355 { | 1355 { |
1356 WriteTransaction wtrans(FROM_HERE, UNITTEST, dir().get()); | 1356 WriteTransaction wtrans(FROM_HERE, UNITTEST, dir().get()); |
1357 MutableEntry me(&wtrans, CREATE, BOOKMARKS, wtrans.root_id(), name); | 1357 MutableEntry me(&wtrans, CREATE, BOOKMARKS, wtrans.root_id(), name); |
1358 ASSERT_TRUE(me.good()); | 1358 ASSERT_TRUE(me.good()); |
1359 me.PutId(id); | 1359 me.PutId(id); |
1360 me.PutBaseVersion(1); | 1360 me.PutBaseVersion(1); |
1361 written_metahandle = me.GetMetahandle(); | 1361 written_metahandle = me.GetMetahandle(); |
1362 } | 1362 } |
(...skipping 22 matching lines...) Expand all Loading... |
1385 | 1385 |
1386 // Test children ops after the children have been deleted. | 1386 // Test children ops after the children have been deleted. |
1387 { | 1387 { |
1388 ReadTransaction rtrans(FROM_HERE, dir().get()); | 1388 ReadTransaction rtrans(FROM_HERE, dir().get()); |
1389 Entry e(&rtrans, GET_BY_ID, id); | 1389 Entry e(&rtrans, GET_BY_ID, id); |
1390 ASSERT_TRUE(e.good()); | 1390 ASSERT_TRUE(e.good()); |
1391 | 1391 |
1392 Entry root(&rtrans, GET_BY_ID, rtrans.root_id()); | 1392 Entry root(&rtrans, GET_BY_ID, rtrans.root_id()); |
1393 ASSERT_TRUE(root.good()); | 1393 ASSERT_TRUE(root.good()); |
1394 EXPECT_FALSE(dir()->HasChildren(&rtrans, rtrans.root_id())); | 1394 EXPECT_FALSE(dir()->HasChildren(&rtrans, rtrans.root_id())); |
1395 EXPECT_TRUE(root.GetFirstChildId().IsRoot()); | 1395 EXPECT_TRUE(root.GetFirstChildId().IsNull()); |
1396 } | 1396 } |
1397 | 1397 |
1398 dir()->SaveChanges(); | 1398 dir()->SaveChanges(); |
1399 } | 1399 } |
1400 | 1400 |
1401 TEST_F(SyncableDirectoryTest, ClientIndexRebuildsProperly) { | 1401 TEST_F(SyncableDirectoryTest, ClientIndexRebuildsProperly) { |
1402 int64 written_metahandle; | 1402 int64 written_metahandle; |
1403 TestIdFactory factory; | 1403 TestIdFactory factory; |
1404 const Id id = factory.NewServerId(); | 1404 const Id id = factory.NewServerId(); |
1405 std::string name = "cheesepuffs"; | 1405 std::string name = "cheesepuffs"; |
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1762 { | 1762 { |
1763 ReadTransaction trans(FROM_HERE, dir().get()); | 1763 ReadTransaction trans(FROM_HERE, dir().get()); |
1764 dir()->GetAttachmentIdsToUpload(&trans, PREFERENCES, &id_set); | 1764 dir()->GetAttachmentIdsToUpload(&trans, PREFERENCES, &id_set); |
1765 } | 1765 } |
1766 ASSERT_TRUE(id_set.empty()); | 1766 ASSERT_TRUE(id_set.empty()); |
1767 } | 1767 } |
1768 | 1768 |
1769 } // namespace syncable | 1769 } // namespace syncable |
1770 | 1770 |
1771 } // namespace syncer | 1771 } // namespace syncer |
OLD | NEW |