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 1607 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1618 ExpectDictBooleanValue(true, *value, "good"); | 1618 ExpectDictBooleanValue(true, *value, "good"); |
1619 EXPECT_TRUE(value->HasKey("kernel")); | 1619 EXPECT_TRUE(value->HasKey("kernel")); |
1620 ExpectDictStringValue("Bookmarks", *value, "modelType"); | 1620 ExpectDictStringValue("Bookmarks", *value, "modelType"); |
1621 ExpectDictBooleanValue(true, *value, "existsOnClientBecauseNameIsNonEmpty"); | 1621 ExpectDictBooleanValue(true, *value, "existsOnClientBecauseNameIsNonEmpty"); |
1622 ExpectDictBooleanValue(false, *value, "isRoot"); | 1622 ExpectDictBooleanValue(false, *value, "isRoot"); |
1623 } | 1623 } |
1624 | 1624 |
1625 dir()->SaveChanges(); | 1625 dir()->SaveChanges(); |
1626 } | 1626 } |
1627 | 1627 |
1628 // Test that the bookmark tag generation algorithm remains unchanged. | |
1629 TEST_F(SyncableDirectoryTest, BookmarkTagTest) { | |
1630 // This test needs its own InMemoryDirectoryBackingStore because it needs to | |
1631 // call request_consistent_cache_guid(). | |
1632 InMemoryDirectoryBackingStore* store = new InMemoryDirectoryBackingStore("x"); | |
1633 | |
1634 // The two inputs that form the bookmark tag are the directory's cache_guid | |
1635 // and its next_id value. We don't need to take any action to ensure | |
1636 // consistent next_id values, but we do need to explicitly request that our | |
1637 // InMemoryDirectoryBackingStore always return the same cache_guid. | |
1638 store->request_consistent_cache_guid(); | |
1639 | |
1640 Directory dir(store, unrecoverable_error_handler(), NULL, NULL, NULL); | |
1641 ASSERT_EQ( | |
1642 OPENED, | |
1643 dir.Open("x", directory_change_delegate(), NullTransactionObserver())); | |
1644 | |
1645 { | |
1646 WriteTransaction wtrans(FROM_HERE, UNITTEST, &dir); | |
1647 MutableEntry bm(&wtrans, CREATE, BOOKMARKS, wtrans.root_id(), "bm"); | |
1648 bm.PutIsUnsynced(true); | |
1649 | |
1650 // If this assertion fails, that might indicate that the algorithm used to | |
1651 // generate bookmark tags has been modified. This could have implications | |
1652 // for bookmark ordering. Please make sure you know what you're doing if | |
1653 // you intend to make such a change. | |
1654 ASSERT_EQ("6wHRAb3kbnXV5GHrejp4/c1y5tw=", bm.GetUniqueBookmarkTag()); | |
1655 } | |
1656 } | |
1657 | |
1658 // A thread that creates a bunch of directory entries. | 1628 // A thread that creates a bunch of directory entries. |
1659 class StressTransactionsDelegate : public base::PlatformThread::Delegate { | 1629 class StressTransactionsDelegate : public base::PlatformThread::Delegate { |
1660 public: | 1630 public: |
1661 StressTransactionsDelegate(Directory* dir, int thread_number) | 1631 StressTransactionsDelegate(Directory* dir, int thread_number) |
1662 : dir_(dir), thread_number_(thread_number) {} | 1632 : dir_(dir), thread_number_(thread_number) {} |
1663 | 1633 |
1664 private: | 1634 private: |
1665 Directory* const dir_; | 1635 Directory* const dir_; |
1666 const int thread_number_; | 1636 const int thread_number_; |
1667 | 1637 |
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2046 dir.OnCatastrophicError(); | 2016 dir.OnCatastrophicError(); |
2047 dir.OnCatastrophicError(); | 2017 dir.OnCatastrophicError(); |
2048 | 2018 |
2049 // See that the unrecoverable error handler has been invoked twice. | 2019 // See that the unrecoverable error handler has been invoked twice. |
2050 ASSERT_EQ(2, unrecoverable_error_handler.invocation_count()); | 2020 ASSERT_EQ(2, unrecoverable_error_handler.invocation_count()); |
2051 } | 2021 } |
2052 | 2022 |
2053 } // namespace syncable | 2023 } // namespace syncable |
2054 | 2024 |
2055 } // namespace syncer | 2025 } // namespace syncer |
OLD | NEW |