| 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 <stddef.h> | 5 #include <stddef.h> |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "base/rand_util.h" | 11 #include "base/rand_util.h" |
| 12 #include "base/run_loop.h" | 12 #include "base/run_loop.h" |
| 13 #include "base/strings/stringprintf.h" | 13 #include "base/strings/stringprintf.h" |
| 14 #include "base/values.h" | 14 #include "base/values.h" |
| 15 #include "build/build_config.h" | 15 #include "build/build_config.h" |
| 16 #include "chrome/browser/policy/profile_policy_connector_factory.h" | 16 #include "chrome/browser/policy/profile_policy_connector_factory.h" |
| 17 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
| 18 #include "chrome/browser/sync/test/integration/bookmarks_helper.h" | 18 #include "chrome/browser/sync/test/integration/bookmarks_helper.h" |
| 19 #include "chrome/browser/sync/test/integration/profile_sync_service_harness.h" | 19 #include "chrome/browser/sync/test/integration/profile_sync_service_harness.h" |
| 20 #include "chrome/browser/sync/test/integration/sync_integration_test_util.h" | 20 #include "chrome/browser/sync/test/integration/sync_integration_test_util.h" |
| 21 #include "chrome/browser/sync/test/integration/sync_test.h" | 21 #include "chrome/browser/sync/test/integration/sync_test.h" |
| 22 #include "chrome/browser/sync/test/integration/updated_progress_marker_checker.h
" |
| 22 #include "components/bookmarks/browser/bookmark_node.h" | 23 #include "components/bookmarks/browser/bookmark_node.h" |
| 23 #include "components/browser_sync/profile_sync_service.h" | 24 #include "components/browser_sync/profile_sync_service.h" |
| 24 #include "components/policy/core/common/mock_configuration_policy_provider.h" | 25 #include "components/policy/core/common/mock_configuration_policy_provider.h" |
| 25 #include "components/policy/core/common/policy_map.h" | 26 #include "components/policy/core/common/policy_map.h" |
| 26 #include "components/policy/core/common/policy_types.h" | 27 #include "components/policy/core/common/policy_types.h" |
| 27 #include "components/policy/policy_constants.h" | 28 #include "components/policy/policy_constants.h" |
| 28 #include "components/sync/driver/sync_service.h" | 29 #include "components/sync/driver/sync_service.h" |
| 29 #include "components/sync/engine/cycle/sync_cycle_snapshot.h" | 30 #include "components/sync/engine/cycle/sync_cycle_snapshot.h" |
| 30 #include "testing/gmock/include/gmock/gmock.h" | 31 #include "testing/gmock/include/gmock/gmock.h" |
| 31 #include "ui/base/layout.h" | 32 #include "ui/base/layout.h" |
| 32 | 33 |
| 33 using bookmarks::BookmarkNode; | 34 using bookmarks::BookmarkNode; |
| 34 using bookmarks_helper::AddFolder; | 35 using bookmarks_helper::AddFolder; |
| 35 using bookmarks_helper::AddURL; | 36 using bookmarks_helper::AddURL; |
| 36 using bookmarks_helper::AllModelsMatch; | 37 using bookmarks_helper::AllModelsMatch; |
| 37 using bookmarks_helper::AllModelsMatchVerifier; | 38 using bookmarks_helper::AllModelsMatchVerifier; |
| 38 using bookmarks_helper::AwaitAllModelsMatch; | |
| 39 using bookmarks_helper::CheckFaviconExpired; | 39 using bookmarks_helper::CheckFaviconExpired; |
| 40 using bookmarks_helper::ContainsDuplicateBookmarks; | 40 using bookmarks_helper::ContainsDuplicateBookmarks; |
| 41 using bookmarks_helper::CountAllBookmarks; | 41 using bookmarks_helper::CountAllBookmarks; |
| 42 using bookmarks_helper::CountBookmarksWithTitlesMatching; | 42 using bookmarks_helper::CountBookmarksWithTitlesMatching; |
| 43 using bookmarks_helper::CountBookmarksWithUrlsMatching; | 43 using bookmarks_helper::CountBookmarksWithUrlsMatching; |
| 44 using bookmarks_helper::CountFoldersWithTitlesMatching; | 44 using bookmarks_helper::CountFoldersWithTitlesMatching; |
| 45 using bookmarks_helper::CreateFavicon; | 45 using bookmarks_helper::CreateFavicon; |
| 46 using bookmarks_helper::ExpireFavicon; | 46 using bookmarks_helper::ExpireFavicon; |
| 47 using bookmarks_helper::GetBookmarkBarNode; | 47 using bookmarks_helper::GetBookmarkBarNode; |
| 48 using bookmarks_helper::GetManagedNode; | 48 using bookmarks_helper::GetManagedNode; |
| 49 using bookmarks_helper::GetOtherNode; | 49 using bookmarks_helper::GetOtherNode; |
| 50 using bookmarks_helper::GetSyncedBookmarksNode; | 50 using bookmarks_helper::GetSyncedBookmarksNode; |
| 51 using bookmarks_helper::GetUniqueNodeByURL; | 51 using bookmarks_helper::GetUniqueNodeByURL; |
| 52 using bookmarks_helper::HasNodeWithURL; | 52 using bookmarks_helper::HasNodeWithURL; |
| 53 using bookmarks_helper::IndexedFolderName; | 53 using bookmarks_helper::IndexedFolderName; |
| 54 using bookmarks_helper::IndexedSubfolderName; | 54 using bookmarks_helper::IndexedSubfolderName; |
| 55 using bookmarks_helper::IndexedSubsubfolderName; | 55 using bookmarks_helper::IndexedSubsubfolderName; |
| 56 using bookmarks_helper::IndexedURL; | 56 using bookmarks_helper::IndexedURL; |
| 57 using bookmarks_helper::IndexedURLTitle; | 57 using bookmarks_helper::IndexedURLTitle; |
| 58 using bookmarks_helper::Move; | 58 using bookmarks_helper::Move; |
| 59 using bookmarks_helper::Remove; | 59 using bookmarks_helper::Remove; |
| 60 using bookmarks_helper::RemoveAll; | 60 using bookmarks_helper::RemoveAll; |
| 61 using bookmarks_helper::ReverseChildOrder; | 61 using bookmarks_helper::ReverseChildOrder; |
| 62 using bookmarks_helper::SetFavicon; | 62 using bookmarks_helper::SetFavicon; |
| 63 using bookmarks_helper::SetTitle; | 63 using bookmarks_helper::SetTitle; |
| 64 using bookmarks_helper::SetURL; | 64 using bookmarks_helper::SetURL; |
| 65 using bookmarks_helper::SortChildren; | 65 using bookmarks_helper::SortChildren; |
| 66 using sync_integration_test_util::AwaitCommitActivityCompletion; | |
| 67 using sync_integration_test_util::AwaitPassphraseAccepted; | |
| 68 using sync_integration_test_util::AwaitPassphraseRequired; | |
| 69 | 66 |
| 70 namespace { | 67 namespace { |
| 71 | 68 |
| 72 const char kGenericURL[] = "http://www.host.ext:1234/path/filename"; | 69 const char kGenericURL[] = "http://www.host.ext:1234/path/filename"; |
| 73 const char kGenericURLTitle[] = "URL Title"; | 70 const char kGenericURLTitle[] = "URL Title"; |
| 74 const char kGenericFolderName[] = "Folder Name"; | 71 const char kGenericFolderName[] = "Folder Name"; |
| 75 const char kGenericSubfolderName[] = "Subfolder Name"; | 72 const char kGenericSubfolderName[] = "Subfolder Name"; |
| 76 const char kValidPassphrase[] = "passphrase!"; | 73 const char kValidPassphrase[] = "passphrase!"; |
| 77 | 74 |
| 78 } // namespace | 75 } // namespace |
| (...skipping 1633 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1712 ASSERT_TRUE(AllModelsMatch()); | 1709 ASSERT_TRUE(AllModelsMatch()); |
| 1713 } | 1710 } |
| 1714 | 1711 |
| 1715 // TCM ID - 7343544. | 1712 // TCM ID - 7343544. |
| 1716 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest, DisableSync) { | 1713 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest, DisableSync) { |
| 1717 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 1714 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
| 1718 ASSERT_TRUE(AllModelsMatchVerifier()); | 1715 ASSERT_TRUE(AllModelsMatchVerifier()); |
| 1719 | 1716 |
| 1720 ASSERT_TRUE(GetClient(1)->DisableSyncForAllDatatypes()); | 1717 ASSERT_TRUE(GetClient(1)->DisableSyncForAllDatatypes()); |
| 1721 ASSERT_TRUE(AddFolder(0, IndexedFolderName(0)) != NULL); | 1718 ASSERT_TRUE(AddFolder(0, IndexedFolderName(0)) != NULL); |
| 1722 ASSERT_TRUE(AwaitCommitActivityCompletion(GetSyncService(0))); | 1719 ASSERT_TRUE(UpdatedProgressMarkerChecker(GetSyncService(0)).Wait()); |
| 1723 ASSERT_FALSE(AllModelsMatch()); | 1720 ASSERT_FALSE(AllModelsMatch()); |
| 1724 | 1721 |
| 1725 ASSERT_TRUE(AddFolder(1, IndexedFolderName(1)) != NULL); | 1722 ASSERT_TRUE(AddFolder(1, IndexedFolderName(1)) != NULL); |
| 1726 ASSERT_FALSE(AllModelsMatch()); | 1723 ASSERT_FALSE(AllModelsMatch()); |
| 1727 | 1724 |
| 1728 ASSERT_TRUE(GetClient(1)->EnableSyncForAllDatatypes()); | 1725 ASSERT_TRUE(GetClient(1)->EnableSyncForAllDatatypes()); |
| 1729 ASSERT_TRUE(AwaitQuiescence()); | 1726 ASSERT_TRUE(AwaitQuiescence()); |
| 1730 ASSERT_TRUE(AllModelsMatch()); | 1727 ASSERT_TRUE(AllModelsMatch()); |
| 1731 } | 1728 } |
| 1732 | 1729 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 1759 IN_PROC_BROWSER_TEST_F(LegacyTwoClientBookmarksSyncTest, MC_DeleteBookmark) { | 1756 IN_PROC_BROWSER_TEST_F(LegacyTwoClientBookmarksSyncTest, MC_DeleteBookmark) { |
| 1760 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 1757 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
| 1761 ASSERT_TRUE(GetClient(1)->DisableSyncForDatatype(syncer::BOOKMARKS)); | 1758 ASSERT_TRUE(GetClient(1)->DisableSyncForDatatype(syncer::BOOKMARKS)); |
| 1762 | 1759 |
| 1763 const GURL bar_url("http://example.com/bar"); | 1760 const GURL bar_url("http://example.com/bar"); |
| 1764 const GURL other_url("http://example.com/other"); | 1761 const GURL other_url("http://example.com/other"); |
| 1765 | 1762 |
| 1766 ASSERT_TRUE(AddURL(0, GetBookmarkBarNode(0), 0, "bar", bar_url) != NULL); | 1763 ASSERT_TRUE(AddURL(0, GetBookmarkBarNode(0), 0, "bar", bar_url) != NULL); |
| 1767 ASSERT_TRUE(AddURL(0, GetOtherNode(0), 0, "other", other_url) != NULL); | 1764 ASSERT_TRUE(AddURL(0, GetOtherNode(0), 0, "other", other_url) != NULL); |
| 1768 | 1765 |
| 1769 ASSERT_TRUE(AwaitCommitActivityCompletion(GetSyncService(0))); | 1766 ASSERT_TRUE(UpdatedProgressMarkerChecker(GetSyncService(0)).Wait()); |
| 1770 | 1767 |
| 1771 ASSERT_TRUE(HasNodeWithURL(0, bar_url)); | 1768 ASSERT_TRUE(HasNodeWithURL(0, bar_url)); |
| 1772 ASSERT_TRUE(HasNodeWithURL(0, other_url)); | 1769 ASSERT_TRUE(HasNodeWithURL(0, other_url)); |
| 1773 ASSERT_FALSE(HasNodeWithURL(1, bar_url)); | 1770 ASSERT_FALSE(HasNodeWithURL(1, bar_url)); |
| 1774 ASSERT_FALSE(HasNodeWithURL(1, other_url)); | 1771 ASSERT_FALSE(HasNodeWithURL(1, other_url)); |
| 1775 | 1772 |
| 1776 Remove(0, GetBookmarkBarNode(0), 0); | 1773 Remove(0, GetBookmarkBarNode(0), 0); |
| 1777 ASSERT_TRUE(AwaitCommitActivityCompletion(GetSyncService(0))); | 1774 ASSERT_TRUE(UpdatedProgressMarkerChecker(GetSyncService(0)).Wait()); |
| 1778 | 1775 |
| 1779 ASSERT_FALSE(HasNodeWithURL(0, bar_url)); | 1776 ASSERT_FALSE(HasNodeWithURL(0, bar_url)); |
| 1780 ASSERT_TRUE(HasNodeWithURL(0, other_url)); | 1777 ASSERT_TRUE(HasNodeWithURL(0, other_url)); |
| 1781 | 1778 |
| 1782 ASSERT_TRUE(GetClient(1)->EnableSyncForDatatype(syncer::BOOKMARKS)); | 1779 ASSERT_TRUE(GetClient(1)->EnableSyncForDatatype(syncer::BOOKMARKS)); |
| 1783 ASSERT_TRUE(AwaitQuiescence()); | 1780 ASSERT_TRUE(AwaitQuiescence()); |
| 1784 | 1781 |
| 1785 ASSERT_FALSE(HasNodeWithURL(0, bar_url)); | 1782 ASSERT_FALSE(HasNodeWithURL(0, bar_url)); |
| 1786 ASSERT_TRUE(HasNodeWithURL(0, other_url)); | 1783 ASSERT_TRUE(HasNodeWithURL(0, other_url)); |
| 1787 ASSERT_FALSE(HasNodeWithURL(1, bar_url)); | 1784 ASSERT_FALSE(HasNodeWithURL(1, bar_url)); |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1997 ASSERT_TRUE(AddURL(0, 0, IndexedURLTitle(0), GURL(IndexedURL(0))) != NULL); | 1994 ASSERT_TRUE(AddURL(0, 0, IndexedURLTitle(0), GURL(IndexedURL(0))) != NULL); |
| 1998 ASSERT_TRUE(AddURL(0, 1, IndexedURLTitle(1), GURL(IndexedURL(1))) != NULL); | 1995 ASSERT_TRUE(AddURL(0, 1, IndexedURLTitle(1), GURL(IndexedURL(1))) != NULL); |
| 1999 ASSERT_TRUE(AddURL(0, 2, IndexedURLTitle(2), GURL(IndexedURL(2))) != NULL); | 1996 ASSERT_TRUE(AddURL(0, 2, IndexedURLTitle(2), GURL(IndexedURL(2))) != NULL); |
| 2000 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); | 1997 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); |
| 2001 ASSERT_TRUE(AllModelsMatchVerifier()); | 1998 ASSERT_TRUE(AllModelsMatchVerifier()); |
| 2002 | 1999 |
| 2003 // Set a passphrase and enable encryption on Client 0. Client 1 will not | 2000 // Set a passphrase and enable encryption on Client 0. Client 1 will not |
| 2004 // understand the bookmark updates. | 2001 // understand the bookmark updates. |
| 2005 GetSyncService(0)->SetEncryptionPassphrase( | 2002 GetSyncService(0)->SetEncryptionPassphrase( |
| 2006 kValidPassphrase, sync_driver::SyncService::EXPLICIT); | 2003 kValidPassphrase, sync_driver::SyncService::EXPLICIT); |
| 2007 ASSERT_TRUE(AwaitPassphraseAccepted(GetSyncService(0))); | 2004 ASSERT_TRUE(PassphraseAcceptedChecker(GetSyncService(0)).Wait()); |
| 2008 ASSERT_TRUE(EnableEncryption(0)); | 2005 ASSERT_TRUE(EnableEncryption(0)); |
| 2009 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); | 2006 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); |
| 2010 ASSERT_TRUE(IsEncryptionComplete(0)); | 2007 ASSERT_TRUE(IsEncryptionComplete(0)); |
| 2011 ASSERT_TRUE(IsEncryptionComplete(1)); | 2008 ASSERT_TRUE(IsEncryptionComplete(1)); |
| 2012 ASSERT_TRUE(GetSyncService(1)->IsPassphraseRequired()); | 2009 ASSERT_TRUE(GetSyncService(1)->IsPassphraseRequired()); |
| 2013 | 2010 |
| 2014 // Client 1 adds bookmarks between the first two and between the second two. | 2011 // Client 1 adds bookmarks between the first two and between the second two. |
| 2015 ASSERT_TRUE(AddURL(0, 1, IndexedURLTitle(3), GURL(IndexedURL(3))) != NULL); | 2012 ASSERT_TRUE(AddURL(0, 1, IndexedURLTitle(3), GURL(IndexedURL(3))) != NULL); |
| 2016 ASSERT_TRUE(AddURL(0, 3, IndexedURLTitle(4), GURL(IndexedURL(4))) != NULL); | 2013 ASSERT_TRUE(AddURL(0, 3, IndexedURLTitle(4), GURL(IndexedURL(4))) != NULL); |
| 2017 EXPECT_FALSE(AllModelsMatchVerifier()); | 2014 EXPECT_FALSE(AllModelsMatchVerifier()); |
| 2018 EXPECT_FALSE(AllModelsMatch()); | 2015 EXPECT_FALSE(AllModelsMatch()); |
| 2019 | 2016 |
| 2020 // Set the passphrase. Everything should resolve. | 2017 // Set the passphrase. Everything should resolve. |
| 2021 ASSERT_TRUE(AwaitPassphraseRequired(GetSyncService(1))); | 2018 ASSERT_TRUE(PassphraseRequiredChecker(GetSyncService(1)).Wait()); |
| 2022 ASSERT_TRUE(GetSyncService(1)->SetDecryptionPassphrase(kValidPassphrase)); | 2019 ASSERT_TRUE(GetSyncService(1)->SetDecryptionPassphrase(kValidPassphrase)); |
| 2023 ASSERT_TRUE(AwaitPassphraseAccepted(GetSyncService(1))); | 2020 ASSERT_TRUE(PassphraseAcceptedChecker(GetSyncService(1)).Wait()); |
| 2024 ASSERT_TRUE(AwaitQuiescence()); | 2021 ASSERT_TRUE(AwaitQuiescence()); |
| 2025 EXPECT_TRUE(AllModelsMatch()); | 2022 EXPECT_TRUE(AllModelsMatch()); |
| 2026 ASSERT_EQ(0, GetClient(1)->GetLastCycleSnapshot().num_encryption_conflicts()); | 2023 ASSERT_EQ(0, GetClient(1)->GetLastCycleSnapshot().num_encryption_conflicts()); |
| 2027 | 2024 |
| 2028 // Ensure everything is syncing normally by appending a final bookmark. | 2025 // Ensure everything is syncing normally by appending a final bookmark. |
| 2029 ASSERT_TRUE(AddURL(1, 5, IndexedURLTitle(5), GURL(IndexedURL(5))) != NULL); | 2026 ASSERT_TRUE(AddURL(1, 5, IndexedURLTitle(5), GURL(IndexedURL(5))) != NULL); |
| 2030 ASSERT_TRUE(GetClient(1)->AwaitMutualSyncCycleCompletion(GetClient(0))); | 2027 ASSERT_TRUE(GetClient(1)->AwaitMutualSyncCycleCompletion(GetClient(0))); |
| 2031 EXPECT_TRUE(AllModelsMatch()); | 2028 EXPECT_TRUE(AllModelsMatch()); |
| 2032 ASSERT_EQ(0, GetClient(1)->GetLastCycleSnapshot().num_encryption_conflicts()); | 2029 ASSERT_EQ(0, GetClient(1)->GetLastCycleSnapshot().num_encryption_conflicts()); |
| 2033 } | 2030 } |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2238 } | 2235 } |
| 2239 | 2236 |
| 2240 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest, E2E_ONLY(SanitySetup)) { | 2237 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest, E2E_ONLY(SanitySetup)) { |
| 2241 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 2238 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
| 2242 } | 2239 } |
| 2243 | 2240 |
| 2244 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest, | 2241 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest, |
| 2245 E2E_ONLY(OneClientAddsBookmark)) { | 2242 E2E_ONLY(OneClientAddsBookmark)) { |
| 2246 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 2243 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
| 2247 // All profiles should sync same bookmarks. | 2244 // All profiles should sync same bookmarks. |
| 2248 ASSERT_TRUE(AwaitAllModelsMatch()) << | 2245 ASSERT_TRUE(BookmarksMatchChecker().Wait()) |
| 2249 "Initial bookmark models did not match for all profiles"; | 2246 << "Initial bookmark models did not match for all profiles"; |
| 2250 // For clean profiles, the bookmarks count should be zero. We are not | 2247 // For clean profiles, the bookmarks count should be zero. We are not |
| 2251 // enforcing this, we only check that the final count is equal to initial | 2248 // enforcing this, we only check that the final count is equal to initial |
| 2252 // count plus new bookmarks count. | 2249 // count plus new bookmarks count. |
| 2253 int init_bookmarks_count = CountAllBookmarks(0); | 2250 int init_bookmarks_count = CountAllBookmarks(0); |
| 2254 | 2251 |
| 2255 // Add one new bookmark to the first profile. | 2252 // Add one new bookmark to the first profile. |
| 2256 ASSERT_TRUE( | 2253 ASSERT_TRUE( |
| 2257 AddURL(0, "Google URL 0", GURL("http://www.google.com/0")) != NULL); | 2254 AddURL(0, "Google URL 0", GURL("http://www.google.com/0")) != NULL); |
| 2258 | 2255 |
| 2259 // Blocks and waits for bookmarks models in all profiles to match. | 2256 // Blocks and waits for bookmarks models in all profiles to match. |
| 2260 ASSERT_TRUE(AwaitAllModelsMatch()); | 2257 ASSERT_TRUE(BookmarksMatchChecker().Wait()); |
| 2261 // Check that total number of bookmarks is as expected. | 2258 // Check that total number of bookmarks is as expected. |
| 2262 for (int i = 0; i < num_clients(); ++i) { | 2259 for (int i = 0; i < num_clients(); ++i) { |
| 2263 ASSERT_EQ(CountAllBookmarks(i), init_bookmarks_count + 1) << | 2260 ASSERT_EQ(CountAllBookmarks(i), init_bookmarks_count + 1) << |
| 2264 "Total bookmark count is wrong."; | 2261 "Total bookmark count is wrong."; |
| 2265 } | 2262 } |
| 2266 } | 2263 } |
| 2267 | 2264 |
| 2268 // TODO(shadi): crbug.com/569213: Enable this as E2E test. | 2265 // TODO(shadi): crbug.com/569213: Enable this as E2E test. |
| 2269 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest, | 2266 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest, |
| 2270 OneClientAddsFolderAndBookmark) { | 2267 OneClientAddsFolderAndBookmark) { |
| 2271 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 2268 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
| 2272 // All profiles should sync same bookmarks. | 2269 // All profiles should sync same bookmarks. |
| 2273 ASSERT_TRUE(AwaitAllModelsMatch()) | 2270 ASSERT_TRUE(BookmarksMatchChecker().Wait()) |
| 2274 << "Initial bookmark models did not match for all profiles"; | 2271 << "Initial bookmark models did not match for all profiles"; |
| 2275 | 2272 |
| 2276 // Add one new bookmark to the first profile. | 2273 // Add one new bookmark to the first profile. |
| 2277 const BookmarkNode* new_folder = AddFolder(0, 0, "Folder 0"); | 2274 const BookmarkNode* new_folder = AddFolder(0, 0, "Folder 0"); |
| 2278 ASSERT_TRUE(new_folder != NULL); | 2275 ASSERT_TRUE(new_folder != NULL); |
| 2279 ASSERT_TRUE(AddURL(0, new_folder, 0, "Google URL 0", | 2276 ASSERT_TRUE(AddURL(0, new_folder, 0, "Google URL 0", |
| 2280 GURL("http://www.google.com/0")) != NULL); | 2277 GURL("http://www.google.com/0")) != NULL); |
| 2281 | 2278 |
| 2282 // Blocks and waits for bookmarks models in all profiles to match. | 2279 // Blocks and waits for bookmarks models in all profiles to match. |
| 2283 ASSERT_TRUE(AwaitAllModelsMatch()); | 2280 ASSERT_TRUE(BookmarksMatchChecker().Wait()); |
| 2284 // Check that both profiles have the folder and the bookmark created above. | 2281 // Check that both profiles have the folder and the bookmark created above. |
| 2285 for (int i = 0; i < num_clients(); ++i) { | 2282 for (int i = 0; i < num_clients(); ++i) { |
| 2286 ASSERT_EQ(1, CountFoldersWithTitlesMatching(i, "Folder 0")) | 2283 ASSERT_EQ(1, CountFoldersWithTitlesMatching(i, "Folder 0")) |
| 2287 << "Failed to match the folder"; | 2284 << "Failed to match the folder"; |
| 2288 ASSERT_EQ( | 2285 ASSERT_EQ( |
| 2289 1, CountBookmarksWithUrlsMatching(i, GURL("http://www.google.com/0"))) | 2286 1, CountBookmarksWithUrlsMatching(i, GURL("http://www.google.com/0"))) |
| 2290 << "Failed to match the bookmark"; | 2287 << "Failed to match the bookmark"; |
| 2291 } | 2288 } |
| 2292 } | 2289 } |
| 2293 | 2290 |
| 2294 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest, | 2291 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest, |
| 2295 E2E_ONLY(TwoClientsAddBookmarks)) { | 2292 E2E_ONLY(TwoClientsAddBookmarks)) { |
| 2296 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 2293 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
| 2297 // ALl profiles should sync same bookmarks. | 2294 // ALl profiles should sync same bookmarks. |
| 2298 ASSERT_TRUE(AwaitAllModelsMatch()) << | 2295 ASSERT_TRUE(BookmarksMatchChecker().Wait()) |
| 2299 "Initial bookmark models did not match for all profiles"; | 2296 << "Initial bookmark models did not match for all profiles"; |
| 2300 // For clean profiles, the bookmarks count should be zero. We are not | 2297 // For clean profiles, the bookmarks count should be zero. We are not |
| 2301 // enforcing this, we only check that the final count is equal to initial | 2298 // enforcing this, we only check that the final count is equal to initial |
| 2302 // count plus new bookmarks count. | 2299 // count plus new bookmarks count. |
| 2303 int init_bookmarks_count = CountAllBookmarks(0); | 2300 int init_bookmarks_count = CountAllBookmarks(0); |
| 2304 | 2301 |
| 2305 // Add one new bookmark per profile. | 2302 // Add one new bookmark per profile. |
| 2306 for (int i = 0; i < num_clients(); ++i) { | 2303 for (int i = 0; i < num_clients(); ++i) { |
| 2307 ASSERT_TRUE(AddURL(i, base::StringPrintf("Google URL %d", i), | 2304 ASSERT_TRUE(AddURL(i, base::StringPrintf("Google URL %d", i), |
| 2308 GURL(base::StringPrintf("http://www.google.com/%d", i))) != NULL); | 2305 GURL(base::StringPrintf("http://www.google.com/%d", i))) != NULL); |
| 2309 } | 2306 } |
| 2310 | 2307 |
| 2311 // Blocks and waits for bookmarks models in all profiles to match. | 2308 // Blocks and waits for bookmarks models in all profiles to match. |
| 2312 ASSERT_TRUE(AwaitAllModelsMatch()); | 2309 ASSERT_TRUE(BookmarksMatchChecker().Wait()); |
| 2313 | 2310 |
| 2314 // Check that total number of bookmarks is as expected. | 2311 // Check that total number of bookmarks is as expected. |
| 2315 for (int i = 0; i < num_clients(); ++i) { | 2312 for (int i = 0; i < num_clients(); ++i) { |
| 2316 ASSERT_EQ(CountAllBookmarks(i), init_bookmarks_count + num_clients()) << | 2313 ASSERT_EQ(CountAllBookmarks(i), init_bookmarks_count + num_clients()) << |
| 2317 "Total bookmark count is wrong."; | 2314 "Total bookmark count is wrong."; |
| 2318 } | 2315 } |
| 2319 } | 2316 } |
| 2320 | 2317 |
| 2321 // Verify that a bookmark added on a client with bookmark syncing disabled gets | 2318 // Verify that a bookmark added on a client with bookmark syncing disabled gets |
| 2322 // synced to a second client once bookmark syncing is re-enabled. | 2319 // synced to a second client once bookmark syncing is re-enabled. |
| 2323 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest, | 2320 IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest, |
| 2324 E2E_ENABLED(AddBookmarkWhileDisabled)) { | 2321 E2E_ENABLED(AddBookmarkWhileDisabled)) { |
| 2325 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 2322 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
| 2326 ASSERT_TRUE(AwaitAllModelsMatch()) | 2323 ASSERT_TRUE(BookmarksMatchChecker().Wait()) |
| 2327 << "Initial bookmark models did not match for all profiles"; | 2324 << "Initial bookmark models did not match for all profiles"; |
| 2328 const int initial_count = CountAllBookmarks(0); | 2325 const int initial_count = CountAllBookmarks(0); |
| 2329 | 2326 |
| 2330 // Verify that we can sync. Add a bookmark on the first client and verify it's | 2327 // Verify that we can sync. Add a bookmark on the first client and verify it's |
| 2331 // synced to the second client. | 2328 // synced to the second client. |
| 2332 const std::string url_title = "a happy little url"; | 2329 const std::string url_title = "a happy little url"; |
| 2333 const GURL url("https://example.com"); | 2330 const GURL url("https://example.com"); |
| 2334 ASSERT_TRUE(AddURL(0, GetBookmarkBarNode(0), 0, url_title, url) != NULL); | 2331 ASSERT_TRUE(AddURL(0, GetBookmarkBarNode(0), 0, url_title, url) != NULL); |
| 2335 ASSERT_TRUE(AwaitAllModelsMatch()); | 2332 ASSERT_TRUE(BookmarksMatchChecker().Wait()); |
| 2336 ASSERT_EQ(initial_count + 1, CountAllBookmarks(0)); | 2333 ASSERT_EQ(initial_count + 1, CountAllBookmarks(0)); |
| 2337 ASSERT_EQ(initial_count + 1, CountAllBookmarks(1)); | 2334 ASSERT_EQ(initial_count + 1, CountAllBookmarks(1)); |
| 2338 | 2335 |
| 2339 // Disable bookmark syncing on the first client, add another bookmark, | 2336 // Disable bookmark syncing on the first client, add another bookmark, |
| 2340 // re-enable bookmark syncing and see that the second bookmark reaches the | 2337 // re-enable bookmark syncing and see that the second bookmark reaches the |
| 2341 // second client. | 2338 // second client. |
| 2342 ASSERT_TRUE(GetClient(0)->DisableSyncForDatatype(syncer::BOOKMARKS)); | 2339 ASSERT_TRUE(GetClient(0)->DisableSyncForDatatype(syncer::BOOKMARKS)); |
| 2343 const std::string url_title_2 = "another happy little url"; | 2340 const std::string url_title_2 = "another happy little url"; |
| 2344 const GURL url_2("https://example.com/second"); | 2341 const GURL url_2("https://example.com/second"); |
| 2345 ASSERT_TRUE(AddURL(0, GetBookmarkBarNode(0), 0, url_title_2, url_2) != NULL); | 2342 ASSERT_TRUE(AddURL(0, GetBookmarkBarNode(0), 0, url_title_2, url_2) != NULL); |
| 2346 ASSERT_TRUE(GetClient(0)->EnableSyncForDatatype(syncer::BOOKMARKS)); | 2343 ASSERT_TRUE(GetClient(0)->EnableSyncForDatatype(syncer::BOOKMARKS)); |
| 2347 ASSERT_TRUE(AwaitAllModelsMatch()); | 2344 ASSERT_TRUE(BookmarksMatchChecker().Wait()); |
| 2348 ASSERT_EQ(initial_count + 2, CountAllBookmarks(0)); | 2345 ASSERT_EQ(initial_count + 2, CountAllBookmarks(0)); |
| 2349 ASSERT_EQ(initial_count + 2, CountAllBookmarks(1)); | 2346 ASSERT_EQ(initial_count + 2, CountAllBookmarks(1)); |
| 2350 } | 2347 } |
| OLD | NEW |