| 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 "base/rand_util.h" | 5 #include "base/rand_util.h" |
| 6 #include "chrome/browser/profiles/profile.h" | 6 #include "chrome/browser/profiles/profile.h" |
| 7 #include "chrome/browser/sync/profile_sync_service_harness.h" | 7 #include "chrome/browser/sync/profile_sync_service_harness.h" |
| 8 #include "chrome/browser/sync/test/integration/bookmarks_helper.h" | 8 #include "chrome/browser/sync/test/integration/bookmarks_helper.h" |
| 9 #include "chrome/browser/sync/test/integration/passwords_helper.h" | 9 #include "chrome/browser/sync/test/integration/passwords_helper.h" |
| 10 #include "chrome/browser/sync/test/integration/sync_test.h" | 10 #include "chrome/browser/sync/test/integration/sync_test.h" |
| (...skipping 1797 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1808 | 1808 |
| 1809 // Set a passphrase and enable encryption on Client 0. Client 1 will not | 1809 // Set a passphrase and enable encryption on Client 0. Client 1 will not |
| 1810 // understand the bookmark updates. | 1810 // understand the bookmark updates. |
| 1811 SetEncryptionPassphrase(0, kValidPassphrase, ProfileSyncService::EXPLICIT); | 1811 SetEncryptionPassphrase(0, kValidPassphrase, ProfileSyncService::EXPLICIT); |
| 1812 ASSERT_TRUE(GetClient(0)->AwaitPassphraseAccepted()); | 1812 ASSERT_TRUE(GetClient(0)->AwaitPassphraseAccepted()); |
| 1813 ASSERT_TRUE(EnableEncryption(0, syncable::BOOKMARKS)); | 1813 ASSERT_TRUE(EnableEncryption(0, syncable::BOOKMARKS)); |
| 1814 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); | 1814 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); |
| 1815 ASSERT_TRUE(IsEncrypted(0, syncable::BOOKMARKS)); | 1815 ASSERT_TRUE(IsEncrypted(0, syncable::BOOKMARKS)); |
| 1816 ASSERT_TRUE(IsEncrypted(1, syncable::BOOKMARKS)); | 1816 ASSERT_TRUE(IsEncrypted(1, syncable::BOOKMARKS)); |
| 1817 ASSERT_TRUE(GetClient(1)->service()->IsPassphraseRequired()); | 1817 ASSERT_TRUE(GetClient(1)->service()->IsPassphraseRequired()); |
| 1818 ASSERT_GT(GetClient(1)->GetLastSessionSnapshot()-> | 1818 ASSERT_GT(GetClient(1)->GetLastSessionSnapshot().num_encryption_conflicts(), |
| 1819 num_encryption_conflicts, 3); // The encrypted nodes. | 1819 3); // The encrypted nodes. |
| 1820 | 1820 |
| 1821 // Client 1 adds bookmarks between the first two and between the second two. | 1821 // Client 1 adds bookmarks between the first two and between the second two. |
| 1822 ASSERT_TRUE(AddURL(0, 1, IndexedURLTitle(3), GURL(IndexedURL(3))) != NULL); | 1822 ASSERT_TRUE(AddURL(0, 1, IndexedURLTitle(3), GURL(IndexedURL(3))) != NULL); |
| 1823 ASSERT_TRUE(AddURL(0, 3, IndexedURLTitle(4), GURL(IndexedURL(4))) != NULL); | 1823 ASSERT_TRUE(AddURL(0, 3, IndexedURLTitle(4), GURL(IndexedURL(4))) != NULL); |
| 1824 EXPECT_FALSE(AllModelsMatchVerifier()); | 1824 EXPECT_FALSE(AllModelsMatchVerifier()); |
| 1825 EXPECT_FALSE(AllModelsMatch()); | 1825 EXPECT_FALSE(AllModelsMatch()); |
| 1826 | 1826 |
| 1827 // Set the passphrase. Everything should resolve. | 1827 // Set the passphrase. Everything should resolve. |
| 1828 ASSERT_TRUE(GetClient(1)->AwaitPassphraseRequired()); | 1828 ASSERT_TRUE(GetClient(1)->AwaitPassphraseRequired()); |
| 1829 ASSERT_TRUE(SetDecryptionPassphrase(1, kValidPassphrase)); | 1829 ASSERT_TRUE(SetDecryptionPassphrase(1, kValidPassphrase)); |
| 1830 ASSERT_TRUE(GetClient(1)->AwaitPassphraseAccepted()); | 1830 ASSERT_TRUE(GetClient(1)->AwaitPassphraseAccepted()); |
| 1831 ASSERT_TRUE(AwaitQuiescence()); | 1831 ASSERT_TRUE(AwaitQuiescence()); |
| 1832 EXPECT_TRUE(AllModelsMatch()); | 1832 EXPECT_TRUE(AllModelsMatch()); |
| 1833 ASSERT_EQ(0, GetClient(1)->GetLastSessionSnapshot()-> | 1833 ASSERT_EQ(0, |
| 1834 num_encryption_conflicts); | 1834 GetClient(1)->GetLastSessionSnapshot().num_encryption_conflicts()); |
| 1835 | 1835 |
| 1836 // Ensure everything is syncing normally by appending a final bookmark. | 1836 // Ensure everything is syncing normally by appending a final bookmark. |
| 1837 ASSERT_TRUE(AddURL(1, 5, IndexedURLTitle(5), GURL(IndexedURL(5))) != NULL); | 1837 ASSERT_TRUE(AddURL(1, 5, IndexedURLTitle(5), GURL(IndexedURL(5))) != NULL); |
| 1838 ASSERT_TRUE(GetClient(1)->AwaitMutualSyncCycleCompletion(GetClient(0))); | 1838 ASSERT_TRUE(GetClient(1)->AwaitMutualSyncCycleCompletion(GetClient(0))); |
| 1839 EXPECT_TRUE(AllModelsMatch()); | 1839 EXPECT_TRUE(AllModelsMatch()); |
| 1840 ASSERT_EQ(0, GetClient(1)->GetLastSessionSnapshot()-> | 1840 ASSERT_EQ(0, |
| 1841 num_encryption_conflicts); | 1841 GetClient(1)->GetLastSessionSnapshot().num_encryption_conflicts()); |
| 1842 } | 1842 } |
| 1843 | 1843 |
| 1844 // Deliberately racy rearranging of bookmarks to test that our conflict resolver | 1844 // Deliberately racy rearranging of bookmarks to test that our conflict resolver |
| 1845 // code results in a consistent view across machines (no matter what the final | 1845 // code results in a consistent view across machines (no matter what the final |
| 1846 // order is). | 1846 // order is). |
| 1847 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest, RacyPositionChanges) { | 1847 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest, RacyPositionChanges) { |
| 1848 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 1848 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
| 1849 ASSERT_TRUE(AllModelsMatchVerifier()); | 1849 ASSERT_TRUE(AllModelsMatchVerifier()); |
| 1850 | 1850 |
| 1851 // Add initial bookmarks. | 1851 // Add initial bookmarks. |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1935 | 1935 |
| 1936 // Now add a bookmark within the Synced Bookmarks folder and ensure it syncs | 1936 // Now add a bookmark within the Synced Bookmarks folder and ensure it syncs |
| 1937 // over. | 1937 // over. |
| 1938 const BookmarkNode* synced_bookmarks = GetSyncedBookmarksNode(0); | 1938 const BookmarkNode* synced_bookmarks = GetSyncedBookmarksNode(0); |
| 1939 ASSERT_TRUE(synced_bookmarks); | 1939 ASSERT_TRUE(synced_bookmarks); |
| 1940 ASSERT_TRUE(AddURL(0, synced_bookmarks, 0, L"Google2", | 1940 ASSERT_TRUE(AddURL(0, synced_bookmarks, 0, L"Google2", |
| 1941 GURL("http://www.google2.com"))); | 1941 GURL("http://www.google2.com"))); |
| 1942 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); | 1942 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); |
| 1943 ASSERT_TRUE(AllModelsMatch()); | 1943 ASSERT_TRUE(AllModelsMatch()); |
| 1944 } | 1944 } |
| OLD | NEW |